-
Notifications
You must be signed in to change notification settings - Fork 58
/
jsx-runtime.js
2 lines (2 loc) · 8.85 KB
/
jsx-runtime.js
1
2
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.apprun=t():e.apprun=t()}(this,(()=>(()=>{"use strict";var e={859:(e,t,n)=>{n.d(t,{A:()=>s});let r;const o="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g;o.app&&o._AppRunVersions?r=o.app:(r=new class{constructor(){this._events={}}on(e,t,n={}){this._events[e]=this._events[e]||[],this._events[e].push({fn:t,options:n})}off(e,t){const n=this._events[e]||[];this._events[e]=n.filter((e=>e.fn!==t))}find(e){return this._events[e]}run(e,...t){const n=this.getSubscribers(e,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+e),n.forEach((n=>{const{fn:r,options:o}=n;return o.delay?this.delay(e,r,t,o):Object.keys(o).length>0?r.apply(this,[...t,o]):r.apply(this,t),!n.options.once})),n.length}once(e,t,n={}){this.on(e,t,Object.assign(Object.assign({},n),{once:!0}))}delay(e,t,n,r){r._t&&clearTimeout(r._t),r._t=setTimeout((()=>{clearTimeout(r._t),Object.keys(r).length>0?t.apply(this,[...n,r]):t.apply(this,n)}),r.delay)}runAsync(e,...t){const n=this.getSubscribers(e,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+e);const r=n.map((e=>{const{fn:n,options:r}=e;return Object.keys(r).length>0?n.apply(this,[...t,r]):n.apply(this,t)}));return Promise.all(r)}query(e,...t){return this.runAsync(e,...t)}getSubscribers(e,t){const n=t[e]||[];return t[e]=n.filter((e=>!e.options.once)),Object.keys(t).filter((t=>t.endsWith("*")&&e.startsWith(t.replace("*","")))).sort(((e,t)=>t.length-e.length)).forEach((r=>n.push(...t[r].map((t=>Object.assign(Object.assign({},t),{options:Object.assign(Object.assign({},t.options),{event:e})})))))),n}},o.app=r,o._AppRunVersions="AppRun-3");const s=r},741:(e,t,n)=>{n.d(t,{A:()=>a});var r=n(859);const o=(e,t)=>(t?e.state[t]:e.state)||"",s=(e,t,n)=>{if(t){const r=e.state||{};r[t]=n,e.setState(r)}else e.setState(n)},i=(e,t)=>{if(Array.isArray(e))return e.map((e=>i(e,t)));{let{type:n,tag:a,props:c,children:l}=e;return a=a||n,l=l||(null==c?void 0:c.children),c&&Object.keys(c).forEach((e=>{e.startsWith("$")&&(((e,t,n,i)=>{if(e.startsWith("$on")){const n=t[e];if(e=e.substring(1),"boolean"==typeof n)t[e]=t=>i.run?i.run(e,t):r.A.run(e,t);else if("string"==typeof n)t[e]=e=>i.run?i.run(n,e):r.A.run(n,e);else if("function"==typeof n)t[e]=e=>i.setState(n(i.state,e));else if(Array.isArray(n)){const[o,...s]=n;"string"==typeof o?t[e]=e=>i.run?i.run(o,...s,e):r.A.run(o,...s,e):"function"==typeof o&&(t[e]=e=>i.setState(o(i.state,...s,e)))}}else if("$bind"===e){const r=t.type||"text",a="string"==typeof t[e]?t[e]:t.name;if("input"===n)switch(r){case"checkbox":t.checked=o(i,a),t.onclick=e=>s(i,a||e.target.name,e.target.checked);break;case"radio":t.checked=o(i,a)===t.value,t.onclick=e=>s(i,a||e.target.name,e.target.value);break;case"number":case"range":t.value=o(i,a),t.oninput=e=>s(i,a||e.target.name,Number(e.target.value));break;default:t.value=o(i,a),t.oninput=e=>s(i,a||e.target.name,e.target.value)}else"select"===n?(t.value=o(i,a),t.onchange=e=>{e.target.multiple||s(i,a||e.target.name,e.target.value)}):"option"===n?(t.selected=o(i,a),t.onclick=e=>s(i,a||e.target.name,e.target.selected)):"textarea"===n&&(t.innerHTML=o(i,a),t.oninput=e=>s(i,a||e.target.name,e.target.value))}else r.A.run("$",{key:e,tag:n,props:t,component:i})})(e,c,a,t),delete c[e])})),l&&i(l,t),e}},a=i},791:(e,t,n)=>{n.d(t,{FK:()=>o,cJ:()=>l,n:()=>a,t_:()=>f});var r=n(741);function o(e,...t){return i(t)}const s="_props";function i(e){const t=[],n=e=>{null!=e&&""!==e&&!1!==e&&t.push("function"==typeof e||"object"==typeof e?e:`${e}`)};return e&&e.forEach((e=>{Array.isArray(e)?e.forEach((e=>n(e))):n(e)})),t}function a(e,t,...n){const r=i(n);if("string"==typeof e)return{tag:e,props:t,children:r};if(Array.isArray(e))return e;if(void 0===e&&n)return r;if(Object.getPrototypeOf(e).__isAppRunComponent)return{tag:e,props:t,children:r};if("function"==typeof e)return e(t,r);throw new Error(`Unknown tag in vdom ${e}`)}const c=new WeakMap,l=(e,t,n={})=>{null!=t&&!1!==t&&function(e,t,n={}){if(null==t||!1===t)return;if(t=y(t,n),!e)return;const r="SVG"===e.nodeName;Array.isArray(t)?p(e,t,r):p(e,[t],r)}("string"==typeof e&&e?document.getElementById(e)||document.querySelector(e):e,t=(0,r.A)(t,n),n)};function u(e,t,n){3!==t._op&&(n=n||"svg"===t.tag,function(e,t){const n=e.nodeName,r=`${t.tag||""}`;return n.toUpperCase()===r.toUpperCase()}(e,t)?(!(2&t._op)&&p(e,t.children,n),!(1&t._op)&&g(e,t.props,n)):e.parentNode.replaceChild(h(t,n),e))}function p(e,t,n){var r,o;const s=(null===(r=e.childNodes)||void 0===r?void 0:r.length)||0,i=(null==t?void 0:t.length)||0,a=Math.min(s,i);for(let r=0;r<a;r++){const o=t[r];if(3===o._op)continue;const s=e.childNodes[r];if("string"==typeof o)s.textContent!==o&&(3===s.nodeType?s.nodeValue=o:e.replaceChild(d(o),s));else if(o instanceof HTMLElement||o instanceof SVGElement)e.insertBefore(o,s);else{const t=o.props&&o.props.key;if(t)if(s.key===t)u(e.childNodes[r],o,n);else{const i=c[t];if(i){const t=i.nextSibling;e.insertBefore(i,s),t?e.insertBefore(s,t):e.appendChild(s),u(e.childNodes[r],o,n)}else e.replaceChild(h(o,n),s)}else u(e.childNodes[r],o,n)}}let l=(null===(o=e.childNodes)||void 0===o?void 0:o.length)||0;for(;l>a;)e.removeChild(e.lastChild),l--;if(i>a){const r=document.createDocumentFragment();for(let e=a;e<t.length;e++)r.appendChild(h(t[e],n));e.appendChild(r)}}const f=e=>{const t=document.createElement("section");return t.insertAdjacentHTML("afterbegin",e),Array.from(t.children)};function d(e){if(0===(null==e?void 0:e.indexOf("_html:"))){const t=document.createElement("div");return t.insertAdjacentHTML("afterbegin",e.substring(6)),t}return document.createTextNode(null!=e?e:"")}function h(e,t){if(e instanceof HTMLElement||e instanceof SVGElement)return e;if("string"==typeof e)return d(e);if(!e.tag||"function"==typeof e.tag)return d(JSON.stringify(e));const n=(t=t||"svg"===e.tag)?document.createElementNS("http://www.w3.org/2000/svg",e.tag):document.createElement(e.tag);return g(n,e.props,t),e.children&&e.children.forEach((e=>n.appendChild(h(e,t)))),n}function g(e,t,n){const r=e[s]||{};t=function(e,t){t.class=t.class||t.className,delete t.className;const n={};return e&&Object.keys(e).forEach((e=>n[e]=null)),t&&Object.keys(t).forEach((e=>n[e]=t[e])),n}(r,t||{}),e[s]=t;for(const r in t){const o=t[r];if(r.startsWith("data-")){const t=r.substring(5).replace(/-(\w)/g,(e=>e[1].toUpperCase()));e.dataset[t]!==o&&(o||""===o?e.dataset[t]=o:delete e.dataset[t])}else if("style"===r)if(e.style.cssText&&(e.style.cssText=""),"string"==typeof o)e.style.cssText=o;else for(const t in o)e.style[t]!==o[t]&&(e.style[t]=o[t]);else if(r.startsWith("xlink")){const t=r.replace("xlink","").toLowerCase();null==o||!1===o?e.removeAttributeNS("http://www.w3.org/1999/xlink",t):e.setAttributeNS("http://www.w3.org/1999/xlink",t,o)}else r.startsWith("on")?o&&"function"!=typeof o?"string"==typeof o&&(o?e.setAttribute(r,o):e.removeAttribute(r)):e[r]=o:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(r)||n?e.getAttribute(r)!==o&&(o?e.setAttribute(r,o):e.removeAttribute(r)):e[r]!==o&&(e[r]=o);"key"===r&&o&&(c[o]=e)}t&&"function"==typeof t.ref&&window.requestAnimationFrame((()=>t.ref(e)))}function y(e,t,n=0){var r;if("string"==typeof e)return e;if(Array.isArray(e))return e.map((e=>y(e,t,n++)));let o=e;if(e&&"function"==typeof e.tag&&Object.getPrototypeOf(e.tag).__isAppRunComponent&&(o=function(e,t,n){const{tag:r,props:o,children:s}=e;let i=`_${n}`,a=o&&o.id;a?i=a:a=`_${n}${Date.now()}`;let c="section";o&&o.as&&(c=o.as,delete o.as),t.__componentCache||(t.__componentCache={});let l=t.__componentCache[i];if(l&&l instanceof r&&l.element)l.renderState(l.state);else{const e=document.createElement(c);l=t.__componentCache[i]=new r(Object.assign(Object.assign({},o),{children:s})).mount(e,{render:!0})}if(l.mounted){const e=l.mounted(o,s,l.state);void 0!==e&&l.setState(e)}return g(l.element,o,!1),l.element}(e,t,n)),o&&Array.isArray(o.children)){const e=null===(r=o.props)||void 0===r?void 0:r._component;if(e){let t=0;o.children=o.children.map((n=>y(n,e,t++)))}else o.children=o.children.map((e=>y(e,t,n++)))}return o}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};n.r(r),n.d(r,{Fragment:()=>o.FK,createElement:()=>o.n,jsx:()=>o.n,jsxs:()=>o.n,render:()=>o.cJ,safeHTML:()=>o.t_});var o=n(791);return r})()));
//# sourceMappingURL=jsx-runtime.js.map