rumious 0.0.8 → 0.0.9

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.
@@ -1 +1 @@
1
- "use strict";class e{constructor(e){this.target=e,this.app=e.app,this.hooks={onRendered:[],onBeforeRender:[]}}find(e){return this.target[e]}get(e){return this.target[e]}addHook(e,t){if(!this.hooks[e])throw new Error(`Hook type "${e}" is not defined!`);this.hooks[e].push(t)}async runHooks(e,...t){if(this.hooks[e])for(const n of this.hooks[e])await n(...t)}}class t{constructor(){this.asynchronousRender=!1,this.element=null,this.app=null,this.props={},this.forwardRefs={},this.renderContext=new e(this),this.renderer=null,this.wrapped=null}prepare(e,t,n={},r=null){this.element=e,this.props=t,this.renderer=r,this.wrapped=n,this.renderContext.app=this.app}template(){return{}}render(e){return this.renderer(e,document.createDocumentFragment(),this.renderContext)}requestRender(){let e=this.template(),t=this.renderer(e,document.createDocumentFragment(),this.renderContext);this.element.appendChild(t),this.onRender()}async requestCleanUp(){if(this.element){let e=this.element.cloneNode(!0);for(this.element.replaceWith(e),this.element=e;this.element.firstChild;)this.element.removeChild(this.element.firstChild)}}onInit(){}onCreate(){}onRender(){}onUpdate(){}onDestroy(){}}function n(e){return Object.getPrototypeOf(e)===t}class r{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class o{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function i(e){return"function"==typeof e}class s{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class a extends s{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!i(n))throw new Error(`${e} is not a function!`);return n.bind(t.target)};if("string"===this.value.type)n=r(this.value.value);else if("expression"===this.value.type){if(n=this.value.value,!i(n))throw new Error("Event handler requires a function!")}else"dynamic_value"===this.value.type&&(n=r(this.value.value.objectName));n&&e.addEventListener(this.name,n)}}class l extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");t.reactor.addBinding((()=>{let n=t.get();this.bindAttr(e,n)})),this.bindAttr(e,t.get())}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target),r=t.find(this.value.value.objectName);if(!r)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");r.reactor.addBinding((()=>{let n=this.value.evaluator?.(t.target);this.bindAttr(e,n)})),this.bindAttr(e,n)}}normalizeValue(e){return"object"==typeof e?e.toString?.()??"":e}async bindAttr(e,t){switch(this.name){case"html":e.innerHTML=this.normalizeValue(t);break;case"text":e.textContent=this.normalizeValue(t);break;case"show":e.style.display=this.normalizeValue(t)?"block":"none";break;case"hide":e.style.display=this.normalizeValue(t)?"none":"block";break;case"className":e.className=this.normalizeValue(t);break;case"style":Object.assign(e.style,t);break;case"disabled":e.disabled=!!this.normalizeValue(t);break;case"visible":e.style.visibility=this.normalizeValue(t)?"visible":"hidden";break;default:e.setAttribute(this.name,this.normalizeValue(t))}}}class c extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");n.set(e)}}}class u extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");n.set(e)}}}const p={on:(e,t)=>new a("on",e,t),bind:(e,t)=>new l("bind",e,t),ref:(e,t)=>new c("ref",e,t),childsRef:(e,t)=>new u("childsRef",e,t)};function f(e,t,n){return function(e,t,n){return p[e]?.(t,n)}(e,t,n)}function h(e,t,...o){return n(e)?y(e,t,o):e===g?g(...o):new r(e,t||{},v(o))}function d(e){return new r("TEXT_ELEMENT",{nodeValue:e},[])}function y(e,t,n){let i=new r("COMPONENT",{...t},new o(v(n)));return i.component=e,i}function g(...e){return new r("FRAGMENT",{},v(e))}function v(e){return e.map((e=>"object"==typeof e?e:d(e)))}window.RUMIOUS_JSX_SUPPORT={createElement:h,createFragment:g,createDirective:f};class m extends HTMLElement{constructor(){super(),this.instance=null,this.ref=null}cleanUp(){Object.setPrototypeOf(this,HTMLUnknownElement.prototype),this.remove()}init(e,t,n={},r,o){this.instance=new e,this.instance.element=this,this.instance.app=o,this.instance.prepare(this,t,n,r),this.instance.onInit()}connectedCallback(){this.instance.asynchronousRender?(async()=>{this.instance.onCreate(),this.instance.requestRender()})():(this.instance.onCreate(),this.instance.requestRender())}disconnectedCallback(){this.instance.onDestroy(),this.instance.requestCleanUp(),this.cleanUp()}}function b(e="r-component"){return window.customElements.get(e)||window.customElements.define(e,class extends m{static tag=e}),document.createElement(e)}class w{constructor(){this.contents=[],this.targets=[],this.observers=new WeakMap}commit(e=[]){this.contents=e}setTarget(e,t,n){this.targets.push({element:e,context:n,renderer:t}),this.observeTarget(e)}observeTarget(e){if(this.observers.has(e))return;const t=new MutationObserver((()=>{e.parentNode||this.removeTarget(e)}));t.observe(e,{childList:!1,subtree:!1}),this.observers.set(e,t)}removeTarget(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e)),this.targets=this.targets.filter((t=>t.element!==e))}inject(e=!1){for(let t of this.targets)e&&(t.element.textContent=""),this.contents.forEach((e=>{"html"===e.type?t.element.innerHTML=e.value:"text"===e.type?t.element.textContent=e.value:"component"===e.type&&t.renderer(h(e.value,e.props??{},e.child??{}),t.element,t.context)}))}}function O(e,t,n){for(const[r,o]of Object.entries(t||{}))o instanceof s?o.init(e,n):r.startsWith("on")&&/^[a-zA-Z]+([A-Z][a-z]*)*$/.test(r)?e.addEventListener(r.substring(2).toLowerCase(),o):e.setAttribute(r,o)}function x(e,t,n={}){if(!e)return t;if(null===(o=e)||"object"!=typeof o&&"function"!=typeof o)return x(d(e),t,n);var o;if(Array.isArray(e)){for(const r of e)x(r,t,n);return t}if(e instanceof r){let r;switch(e.type){case"COMPONENT":return function(e,t,n,r){const o=function(e,t,n,r,o=null){const i=b(e.tag??"r-component");return i.init(e,t,n,r,o?.app),i}(e.component,e.props,e.children,n,r);return O(o,e.props,r),t.appendChild(o),t}(e,t,x,n);case"FRAGMENT":case"ELEMENT_LIST":for(const r of e.children)x(r,t,n);return t;case"TEXT_ELEMENT":r=function(e){return document.createTextNode(e.props.nodeValue)}(e);break;default:r=function(e,t){const n=document.createElement(e.type);O(n,e.props,t);for(const r of e.children)x(r,n,t);return n}(e,n)}return t.appendChild(r),t}if(e instanceof HTMLElement)return t.appendChild(e),t;if(e instanceof w){if(t instanceof HTMLDocument)throw"Rumious Render: Unsupported inject content in HTMLDocument!";return e.setTarget(t,x,n),e.inject(!0),t}return x(d(JSON.stringify(e)),t,n)}class E{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}removeBinding(e){for(let t=this.bindings.length-1;t>=0;t--)this.bindings[t]===e&&this.bindings.splice(t,1)}addBinding(e){this.bindings.push(e)}}class M{constructor(e,t="",n){this.state=e,this.path=t,this.fn=n}trigger(...e){let t=this.fn(...e);this.state.set(this.path,t)}}const k="remove",R="replace",j="add",S=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),C=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),T=Symbol.iterator,A={mutable:"mutable",immutable:"immutable"},P={};function z(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function D(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const e=Reflect.getOwnPropertyDescriptor(n,t);if(e)return e;n=Reflect.getPrototypeOf(n)}}}function I(e){return Object.getPrototypeOf(e)===Set.prototype}function L(e){return Object.getPrototypeOf(e)===Map.prototype}function N(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function _(e){return!!U(e)}function U(e){return"object"!=typeof e?null:null==e?void 0:e[S]}function V(e){var t;const n=U(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function F(e,t){if(!e||"object"!=typeof e)return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((n=t.mark(e,A))===A.immutable||"function"==typeof n)}function q(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=U($(n,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;const o=3===e.parent.type,i=o?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(o&&n.size>i||z(n,i)))return null;t.push(i)}if(e.parent)return q(e.parent,t);t.reverse();try{!function(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if("object"!=typeof(e=$(3===H(e)?Array.from(e):e,r)))throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}}(e.copy,t)}catch(e){return null}return t}function H(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function $(e,t){return 2===H(e)?e.get(t):e[t]}function B(e,t,n){2===H(e)?e.set(t,n):e[t]=n}function W(e,t){const n=U(e);return(n?N(n):e)[t]}function X(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function K(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Y(e,t){return t?e:[""].concat(e).map((e=>{const t=`${e}`;return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const Z=Object.prototype.propertyIsEnumerable;function G(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return I(e)?Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values()):new(0,Object.getPrototypeOf(e).constructor)(e.values());if(e instanceof Map)return L(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,A),void 0!==n)&&n!==A.mutable){if(n===A.immutable)return function(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);r.enumerable&&r.configurable&&r.writable?t[n]=e[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r))})),t}(e);if("function"==typeof n){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){const t={};return Object.keys(e).forEach((n=>{t[n]=e[n]})),Object.getOwnPropertySymbols(e).forEach((n=>{Z.call(e,n)&&(t[n]=e[n])})),t}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function J(e){e.copy||(e.copy=G(e.original,e.options))}function Q(e){if(!F(e))return V(e);if(Array.isArray(e))return e.map(Q);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,Q(t)]));return L(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(Q);return I(e)?new Set(t):new(0,Object.getPrototypeOf(e).constructor)(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Q(e[n]);return t}function ee(e){return _(e)?Q(e):e}function te(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&te(e.parent))}function ne(){throw new Error("Cannot modify frozen object")}function re(e,t,n,r,o){{n=null!=n?n:new WeakMap,r=null!=r?r:[],o=null!=o?o:[];const i=n.has(e)?n.get(e):e;if(r.length>0){const e=r.indexOf(i);if(i&&"object"==typeof i&&-1!==e){if(r[0]===i)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${o.slice(0,e).map(((e,t)=>{if("symbol"==typeof e)return`[${e.toString()}]`;const n=r[t];return"object"==typeof e&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(e):e})).join("/")}`)}r.push(i),o.push(t)}else r.push(i)}if(Object.isFrozen(e)||_(e))return r.pop(),void o.pop();switch(H(e)){case 2:for(const[t,i]of e)re(t,t,n,r,o),re(i,t,n,r,o);e.set=e.clear=e.delete=ne;break;case 3:for(const t of e)re(t,t,n,r,o);e.add=e.clear=e.delete=ne;break;case 1:Object.freeze(e);let t=0;for(const i of e)re(i,t,n,r,o),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{re(e[t],t,n,r,o)}))}r.pop(),o.pop()}function oe(e,t){const n=H(e);if(0===n)Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)}));else if(1===n){let n=0;for(const r of e)t(n,r,e),n+=1}else e.forEach(((n,r)=>t(r,n,e)))}function ie(e,t,n){if(_(e)||!F(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,o=r?new Map:void 0;if(t.add(e),oe(e,((i,s)=>{var a;if(_(s)){const t=U(s);J(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;B(r?o:e,i,n)}else ie(s,t,n)})),o){const t=e,n=Array.from(t);t.clear(),n.forEach((e=>{t.add(o.has(e)?o.get(e):e)}))}}function se(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&ie($(n,t),e.finalities.handledSet,e.options)}function ae(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(V(t))})))}function le(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=q(e);o&&t(e,o,n,r)}e.finalized=!0}}function ce(e,t,n,r){const o=U(n);o&&(o.callbacks||(o.callbacks=[]),o.callbacks.push(((i,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(X($(l,t),n)){let n=o.original;o.copy&&(n=o.copy),ae(e),le(e,r,i,s),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(a=e.options.updatedValues)&&void 0!==a?a:new WeakMap,e.options.updatedValues.set(n,o.original)),B(l,t,n)}})),e.options.enableAutoFreeze&&o.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),F(n,e.options)&&e.finalities.draft.push((()=>{X($(3===e.type?e.setMap:e.copy,t),n)&&se(e,t)}))}function ue(e,t,n,r){const{pathAsArray:o=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return function({original:e,copy:t,assignedMap:n},r,o,i,s){n.forEach(((n,a)=>{const l=$(e,a),c=ee($(t,a)),u=n?z(e,a)?R:j:k;if(X(l,c)&&u===R)return;const p=Y(r.concat(a),s);o.push(u===k?{op:u,path:p}:{op:u,path:p,value:c}),i.push(u===j?{op:k,path:p}:u===k?{op:j,path:p,value:l}:{op:R,path:p,value:l})}))}(e,t,n,r,o);case 1:return function(e,t,n,r,o){let{original:i,assignedMap:s,options:a}=e,l=e.copy;l.length<i.length&&([i,l]=[l,i],[n,r]=[r,n]);for(let e=0;e<i.length;e+=1)if(s.get(e.toString())&&l[e]!==i[e]){const s=Y(t.concat([e]),o);n.push({op:R,path:s,value:ee(l[e])}),r.push({op:R,path:s,value:ee(i[e])})}for(let e=i.length;e<l.length;e+=1){const r=Y(t.concat([e]),o);n.push({op:j,path:r,value:ee(l[e])})}if(i.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=Y(t.concat(["length"]),o);r.push({op:R,path:e,value:i.length})}else for(let e=l.length;i.length<e;e-=1){const n=Y(t.concat([e-1]),o);r.push({op:k,path:n})}}}(e,t,n,r,o);case 3:return function({original:e,copy:t},n,r,o,i){let s=0;e.forEach((e=>{if(!t.has(e)){const t=Y(n.concat([s]),i);r.push({op:k,path:t,value:e}),o.unshift({op:j,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=Y(n.concat([s]),i);r.push({op:j,path:e,value:t}),o.unshift({op:k,path:e,value:t})}s+=1}))}(e,t,n,r,o)}}const pe=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!F(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},fe={get size(){return N(U(this)).size},has(e){return N(U(this)).has(e)},set(e,t){const n=U(this),r=N(n);return r.has(e)&&X(r.get(e),t)||(J(n),te(n),n.assignedMap.set(e,!0),n.copy.set(e,t),ce(n,e,t,ue)),this},delete(e){if(!this.has(e))return!1;const t=U(this);return J(t),te(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=U(this);if(this.size){J(e),te(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){N(U(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=U(this),o=N(r).get(e),i=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,o,A))===A.mutable;if(r.options.strict&&pe(o,r.options,i),i)return o;if(r.finalized||!F(o,r.options))return o;if(o!==r.original.get(e))return o;const s=P.createDraft({original:o,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return J(r),r.copy.set(e,s),s},keys(){return N(U(this)).keys()},values(){const e=this.keys();return{[T]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[T]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[T](){return this.entries()}},he=Reflect.ownKeys(fe),de=(e,t,{isValuesIterator:n})=>()=>{var r,o;const i=t.next();if(i.done)return i;const s=i.value;let a=e.setMap.get(s);const l=U(a),c=(null===(o=(r=e.options).mark)||void 0===o?void 0:o.call(r,a,A))===A.mutable;if(e.options.strict&&pe(s,e.options,c),c||l||!F(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=P.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,t),a=t}return{done:!1,value:n?a:[a,a]}},ye={get size(){return U(this).setMap.size},has(e){const t=U(this);if(t.setMap.has(e))return!0;J(t);const n=U(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=U(this);return this.has(e)||(J(t),te(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),ce(t,e,e,ue)),this},delete(e){if(!this.has(e))return!1;const t=U(this);J(t),te(t);const n=U(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=U(this);J(e),te(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=U(this);J(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:de(e,t,{isValuesIterator:!0})}},entries(){const e=U(this);J(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:de(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[T](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(ye,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const ge=Reflect.ownKeys(ye),ve=new WeakSet,me={get(e,t,n){var r,o;const i=null===(r=e.copy)||void 0===r?void 0:r[t];if(i&&ve.has(i))return i;if(t===S)return e;let s;if(e.options.mark){const r="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(r,A),s===A.mutable)return e.options.strict&&pe(r,e.options,!0),r}const a=N(e);if(a instanceof Map&&he.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(fe,"size").get.call(e.proxy);const n=fe[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&ge.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ye,"size").get.call(e.proxy);const n=ye[t];if(n)return n.bind(e.proxy)}if(!z(a,t)){const n=D(a,t);return n?"value"in n?n.value:null===(o=n.get)||void 0===o?void 0:o.call(e.proxy):void 0}const l=a[t];if(e.options.strict&&pe(l,e.options),e.finalized||!F(l,e.options))return l;if(l===W(e.original,t)){if(J(e),e.copy[t]=be({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=U(e.copy[t]);return J(n),te(n),n.copy}return e.copy[t]}return l},set(e,t,n){var r;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");let o;if(1===e.type&&"length"!==t&&(!(Number.isInteger(o=Number(t))&&o>=0)||0!==t&&0!==o&&String(o)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");const i=D(N(e),t);if(null==i?void 0:i.set)return i.set.call(e.proxy,n),!0;const s=W(N(e),t),a=U(s);return a&&X(a.original,n)?(e.copy[t]=n,e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.set(t,!1),!0):(X(n,s)&&(void 0!==n||z(e.original,t))||(J(e),te(e),z(e.original,t)&&X(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,ce(e,t,n,ue)),!0)},has:(e,t)=>t in N(e),ownKeys:e=>Reflect.ownKeys(N(e)),getOwnPropertyDescriptor(e,t){const n=N(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},getPrototypeOf:e=>Reflect.getPrototypeOf(e.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return 1===e.type?me.set.call(this,e,t,void 0,e.proxy):(void 0!==W(e.original,t)||t in e.original?(J(e),te(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function be(e){const{original:t,parentDraft:n,key:r,finalities:o,options:i}=e,s=H(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:o,options:i,setMap:3===s?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===s?Object.assign([],a):a,me);if(o.revoke.push(c),ve.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var o,i;const s=U(l);let a=3===e.type?e.setMap:e.copy;const c=$(a,r),u=U(c);if(u){let i=u.original;u.operated&&(i=V(c)),ae(u),le(u,ue,t,n),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(o=e.options.updatedValues)&&void 0!==o?o:new WeakMap,e.options.updatedValues.set(i,u.original)),B(a,r,i)}null===(i=s.callbacks)||void 0===i||i.forEach((e=>{e(t,n)}))}))}else{const e=U(l);e.finalities.draft.push(((t,n)=>{ae(e),le(e,ue,t,n)}))}return l}function we(e,t,n,r,o){var i;const s=U(e),a=null!==(i=null==s?void 0:s.original)&&void 0!==i?i:e,l=!!t.length;if(null==s?void 0:s.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);const c=l?t[0]:s?s.operated?s.copy:s.original:e;return s&&K(s),o&&re(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:R,path:[],value:t[0]}]:n,r&&l?[{op:R,path:[],value:a}]:r]}function Oe(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:o=!0}=e;oe(n,((n,r,o)=>{const i=U(r);if(i&&t&&i.finalities===t.finalities){e.isContainDraft=!0;const t=i.original;if(o instanceof Set){const e=Array.from(o);o.clear(),e.forEach((e=>o.add(n===e?t:e)))}else B(o,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,Oe(e))})),o&&e.isContainDraft}function xe(e){var t;const n=U(e);if(!F(e,null==n?void 0:n.options))return e;const r=H(e);if(n&&!n.operated)return n.original;let o;function i(){o=2===r?L(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):G(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{i()}finally{n.finalized=!1}}else o=e;if(oe(o,((t,r)=>{if(n&&X($(n.original,t),r))return;const s=xe(r);s!==r&&(o===e&&i(),B(o,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:o;return I(e)?new Set(o):new(Object.getPrototypeOf(e).constructor)(o)}return o}function Ee(e){if(!_(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return xe(e)}P.createDraft=be;const Me=function e(t,n,r){var o,i,s;if("function"==typeof t&&"function"!=typeof n)return function(r,...o){return e(r,(e=>t.call(this,e,...o)),n)};const a=t,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},void 0),c);const u=_(a)?Ee(a):a,p=Array.isArray(c.mark)?(e,t)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(e,t);if(r)return r}}:c.mark,f=null!==(o=c.enablePatches)&&void 0!==o&&o,h=null!==(i=c.strict)&&void 0!==i&&i,d={enableAutoFreeze:null!==(s=c.enableAutoFreeze)&&void 0!==s&&s,mark:p,strict:h,enablePatches:f};if(!F(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[y,g]=function(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let o,i;t.enablePatches&&(o=[],i=[]);const s=(null===(n=t.mark)||void 0===n?void 0:n.call(t,e,A))!==A.mutable&&F(e,t)?be({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=we(s,e,o,i,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!F(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[y,g]}let v;try{v=l(y)}catch(e){throw K(U(y)),e}const m=e=>{const t=U(y);if(!_(e)){if(void 0!==e&&!X(e,y)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==e?void 0:e[C];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&Oe({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&Oe({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=U(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([Ee(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw K(U(y)),e})):m(v)};function ke(e,t){e.set(Me(e.get(),t))}Object.prototype.constructor.toString();class Re{constructor(e,t=null){this.value=e,this.reactor=t??new E(this,[])}produce(e){return ke(this,e)}reducer(...e){let t;return t=1===e.length?new M(this,"",e[0]):new M(this,e[0],e[1]),t.trigger.bind(t)}setObjectByPath(e="",t){if(0===e.length)return void(this.value=t);if("string"!=typeof e||!e)throw new Error("Invalid path");let n=e.split("."),r=this.value;for(let e=0;e<n.length-1;e++){let t=n[e];t in r||(r[t]={}),r=r[t]}r[n[n.length-1]]=t}set(...e){if(1===e.length)this.value=e[0];else{let t=e[0],n=e[1];this.setObjectByPath(t,n)}this.reactor.react()}get(){return this.value}}function je(e){return new Re(e)}class Se{constructor(e){this.target=e}set html(e){this.target.innerHTML=e}query(e){return this.target.querySelectorAll(e)}set text(e){this.target.textContent=e}on(e,t){this.target.addEventListener(e,t)}off(e,t){this.target.removeEventListener(e,t)}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Ce{constructor(e){this.target=e}query(e){return this.target.querySelectorAll(e)}index(e){return Array.from(this.target.children)[e]}list(){return Array.from(this.target.children)}get parent(){return this.target}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Te{constructor(e){this.target=e}set(e){this.target=e.forwardRefs}}window.RUMIOUS_CONTEXTS||(window.RUMIOUS_CONTEXTS={});class Ae{constructor(e={}){this.data=e,this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter((e=>e!==t)))}emit(e,...t){this.events[e]&&this.events[e].forEach((e=>e(...t)))}set(e,t){let n=je(t);return this.data[e]=n,n}get(e){return this.data[e]}}class Pe{constructor(e,t={}){this.hasExecuted=!1,this.result=null,this.callback=e,this.dependents=[],this.options=t}onLoad(e){this.hasExecuted?e(this.result):this.dependents.push(e)}execute(){return new Promise(((e,t)=>{if(this.hasExecuted)return e(this.result);this.hasExecuted=!0;const n=async()=>{try{this.result=await this.callback(),e(this.result),this.dependents.forEach((e=>e(this.result)))}catch(e){t(e)}};this.options.idle&&"requestIdleCallback"in window?requestIdleCallback(n):n()}))}}const ze=new Map;exports.Pending=class extends t{static tag="r-pending";constructor(){super(),this.asynchronousRender=!0}async setLoader(e){this.loader=e;try{this.result=await this.loader.execute(),this.renderResult()}catch(e){this.error=e,this.renderError()}}renderResult(){if(!this.result)throw"Rumious Render: Cannot find component when lazy loading!";this.element.before(this.render(h(this.result,{}))),this.element.remove()}renderError(){this.element.appendChild(this.render(this.props.errorComponent??this.error))}onRender(){let{loader:e}=this.props;this.setLoader(e)}template(){return this.props.fallback}},exports.RumiousApp=class{constructor(t=document.createElement("span"),n={}){this.root=t,this.app=this,this.modules=[],this.configs=n,this.renderContext=new e(this)}render(e){this.renderContext.runHooks("onBeforeRender",this.renderContext),x(e,this.root,this.renderContext),this.renderContext.runHooks("onRendered",this.renderContext)}addModule(e,t={}){return e.init(this,t)}},exports.RumiousChildrensRef=Ce,exports.RumiousComponent=t,exports.RumiousComponentElement=m,exports.RumiousComponentRef=Te,exports.RumiousContext=Ae,exports.RumiousDymanicInjector=w,exports.RumiousElementRef=Se,exports.RumiousLazyLoader=Pe,exports.RumiousReactor=E,exports.RumiousReducer=M,exports.RumiousState=Re,exports.createChildrensRef=function(e){return new Ce(e)},exports.createComponent=y,exports.createComponentElement=b,exports.createComponentRef=function(e){return new Te(e)},exports.createContext=function(e="",t={}){if(!t||"object"!=typeof t)throw"Rumious context: Initial value must be object !";return window.RUMIOUS_CONTEXTS[e]||(window.RUMIOUS_CONTEXTS[e]=new Ae(t)),window.RUMIOUS_CONTEXTS[e]},exports.createDirective=f,exports.createElement=h,exports.createElementRef=function(e){return new Se(e)},exports.createState=je,exports.createTextElement=d,exports.denounce=function(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},exports.injectHTML=function(e){let t=new w;return t.commit([{type:"html",value:e}]),t},exports.injectText=function(e){let t=new w;return t.commit([{type:"text",value:e}]),t},exports.isComponent=n,exports.isState=function(e){return e instanceof Re},exports.lazyLoad=function(e,t={}){const n=t.key||e.toString();return ze.has(n)||ze.set(n,new Pe(e,t)),ze.get(n)},exports.leadingTrailingDebounce=function(e,t){let n,r=!0;return function(...o){r&&(e.apply(this,o),r=!1),clearTimeout(n),n=setTimeout((()=>{e.apply(this,o),r=!0}),t)}},exports.produceState=ke,exports.rafThrottle=function(e){let t=!1;return function(...n){t||(t=!0,requestAnimationFrame((()=>{e.apply(this,n),t=!1})))}},exports.styleHelper=function(e){let t="";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){t+=`${n} {`;const r=e[n];for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t+=`${e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}: ${r[e]};`);t+="} "}return t.trim()},exports.tholle=function(e,t){let n=0;return function(...r){const o=Date.now();o-n>=t&&(n=o,e.apply(this,r))}},exports.trailingThrottle=function(e,t){let n=0,r=null,o=null;function i(){n=Date.now(),e.apply(this,r),r=null}return function(...e){const s=Date.now();r=e,s-n>=t?i():o||(o=setTimeout((()=>{o=null,i()}),t-(s-n)))}},exports.unwatch=function(e,t){e.reactor.removeBinding(t)},exports.watch=function(e,t){e.reactor.addBinding(t)};
1
+ "use strict";class e{constructor(e){this.target=e,this.app=e.app,this.hooks={onRendered:[],onBeforeRender:[]}}find(e){return this.target[e]}get(e){return this.target[e]}addHook(e,t){if(!this.hooks[e])throw new Error(`Hook type "${e}" is not defined!`);this.hooks[e].push(t)}async runHooks(e,...t){if(this.hooks[e])for(const n of this.hooks[e])await n(...t)}}class t{constructor(){this.asynchronousRender=!1,this.element=null,this.app=null,this.props={},this.forwardRefs={},this.renderContext=new e(this),this.renderer=null,this.wrapped=null}prepare(e,t,n={},r=null){this.element=e,this.props=t,this.renderer=r,this.wrapped=n,this.renderContext.app=this.app}template(){return{}}render(e){return this.renderer(e,document.createDocumentFragment(),this.renderContext)}requestRender(){let e=this.template(),t=this.renderer(e,document.createDocumentFragment(),this.renderContext);this.element.appendChild(t),this.onRender()}async requestCleanUp(){if(this.element){let e=this.element.cloneNode(!0);for(this.element.replaceWith(e),this.element=e;this.element.firstChild;)this.element.removeChild(this.element.firstChild)}}onInit(){}onCreate(){}onRender(){}onUpdate(){}onDestroy(){}}function n(e){return Object.getPrototypeOf(e)===t}class r{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class o{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function i(e){return"function"==typeof e}class s{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class a extends s{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!i(n))throw new Error(`${e} is not a function!`);return n.bind(t.target)};if("string"===this.value.type)n=r(this.value.value);else if("expression"===this.value.type){if(n=this.value.value,!i(n))throw new Error("Event handler requires a function!")}else"dynamic_value"===this.value.type&&(n=r(this.value.value.objectName));n&&e.addEventListener(this.name,n)}}class l extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");t.reactor.addBinding((()=>{let n=t.get();this.bindAttr(e,n)})),this.bindAttr(e,t.get())}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target),r=t.find(this.value.value.objectName);if(!r)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");r.reactor.addBinding((()=>{let n=this.value.evaluator?.(t.target);this.bindAttr(e,n)})),this.bindAttr(e,n)}}normalizeValue(e){return"object"==typeof e?e.toString?.()??"":e}async bindAttr(e,t){switch(this.name){case"html":e.innerHTML=this.normalizeValue(t);break;case"text":e.textContent=this.normalizeValue(t);break;case"show":e.style.display=this.normalizeValue(t)?"block":"none";break;case"hide":e.style.display=this.normalizeValue(t)?"none":"block";break;case"className":e.className=this.normalizeValue(t);break;case"style":Object.assign(e.style,t);break;case"disabled":e.disabled=!!this.normalizeValue(t);break;case"visible":e.style.visibility=this.normalizeValue(t)?"visible":"hidden";break;default:e.setAttribute(this.name,this.normalizeValue(t))}}}class c extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");n.set(e)}}}class u extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");n.set(e)}}}const p={on:(e,t)=>new a("on",e,t),bind:(e,t)=>new l("bind",e,t),ref:(e,t)=>new c("ref",e,t),childsRef:(e,t)=>new u("childsRef",e,t)};function f(e,t,n){return function(e,t,n){return p[e]?.(t,n)}(e,t,n)}function h(e,t,...o){return n(e)?y(e,t,o):e===g?g(...o):new r(e,t||{},v(o))}function d(e){return new r("TEXT_ELEMENT",{nodeValue:e},[])}function y(e,t,n){let i=new r("COMPONENT",{...t},new o(v(n)));return i.component=e,i}function g(...e){return new r("FRAGMENT",{},v(e))}function v(e){return e.map((e=>"object"==typeof e?e:d(e)))}window.RUMIOUS_JSX_SUPPORT={createElement:h,createFragment:g,createDirective:f};class m extends HTMLElement{constructor(){super(),this.instance=null,this.ref=null}cleanUp(){Object.setPrototypeOf(this,HTMLUnknownElement.prototype),this.remove()}init(e,t,n={},r,o){this.instance=new e,this.instance.element=this,this.instance.app=o,this.instance.prepare(this,t,n,r),this.instance.onInit()}connectedCallback(){this.instance.asynchronousRender?(async()=>{this.instance.onCreate(),this.instance.requestRender()})():(this.instance.onCreate(),this.instance.requestRender())}disconnectedCallback(){this.instance.onDestroy(),this.instance.requestCleanUp(),this.cleanUp()}}function b(e="r-component"){return window.customElements.get(e)||window.customElements.define(e,class extends m{static tag=e}),document.createElement(e)}class w{constructor(){this.contents=[],this.targets=[],this.observers=new WeakMap}commit(e=[]){this.contents=e}setTarget(e,t,n){this.targets.push({element:e,context:n,renderer:t}),this.observeTarget(e)}observeTarget(e){if(this.observers.has(e))return;const t=new MutationObserver((()=>{e.parentNode||this.removeTarget(e)}));t.observe(document.body,{childList:!0}),this.observers.set(e,t)}removeTarget(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e)),this.targets=this.targets.filter((t=>t.element!==e))}inject(e=!1){for(let t of this.targets)e&&(t.element.textContent=""),this.contents.forEach((e=>{"html"===e.type?t.element.innerHTML=e.value:"text"===e.type?t.element.textContent=e.value:"component"===e.type&&t.renderer(h(e.value,e.props??{},e.child??{}),t.element,t.context)}))}}function O(e,t,n){for(const[r,o]of Object.entries(t||{}))o instanceof s?o.init(e,n):r.startsWith("on")&&/^[a-zA-Z]+([A-Z][a-z]*)*$/.test(r)?e.addEventListener(r.substring(2).toLowerCase(),o):e.setAttribute(r,o)}function x(e,t,n={}){if(!e)return t;if(null===(o=e)||"object"!=typeof o&&"function"!=typeof o)return x(d(e),t,n);var o;if(Array.isArray(e)){for(const r of e)x(r,t,n);return t}if(e instanceof r){let r;switch(e.type){case"COMPONENT":return function(e,t,n,r){const o=function(e,t,n,r,o=null){const i=b(e.tag??"r-component");return i.init(e,t,n,r,o?.app),i}(e.component,e.props,e.children,n,r);return O(o,e.props,r),t.appendChild(o),t}(e,t,x,n);case"FRAGMENT":case"ELEMENT_LIST":for(const r of e.children)x(r,t,n);return t;case"TEXT_ELEMENT":r=function(e){return document.createTextNode(e.props.nodeValue)}(e);break;default:r=function(e,t){const n=document.createElement(e.type);O(n,e.props,t);for(const r of e.children)x(r,n,t);return n}(e,n)}return t.appendChild(r),t}if(e instanceof HTMLElement)return t.appendChild(e),t;if(e instanceof w){if(t instanceof HTMLDocument)throw"Rumious Render: Unsupported inject content in HTMLDocument!";return e.setTarget(t,x,n),e.inject(!0),t}return x(d(JSON.stringify(e)),t,n)}class E{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}removeBinding(e){for(let t=this.bindings.length-1;t>=0;t--)this.bindings[t]===e&&this.bindings.splice(t,1)}addBinding(e){this.bindings.push(e)}}class M{constructor(e,t="",n){this.state=e,this.path=t,this.fn=n}trigger(...e){let t=this.fn(...e);this.state.set(this.path,t)}}const k="remove",R="replace",j="add",S=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),C=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),T=Symbol.iterator,A={mutable:"mutable",immutable:"immutable"},P={};function z(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function D(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const e=Reflect.getOwnPropertyDescriptor(n,t);if(e)return e;n=Reflect.getPrototypeOf(n)}}}function I(e){return Object.getPrototypeOf(e)===Set.prototype}function L(e){return Object.getPrototypeOf(e)===Map.prototype}function N(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function _(e){return!!U(e)}function U(e){return"object"!=typeof e?null:null==e?void 0:e[S]}function V(e){var t;const n=U(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function F(e,t){if(!e||"object"!=typeof e)return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((n=t.mark(e,A))===A.immutable||"function"==typeof n)}function q(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=U($(n,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;const o=3===e.parent.type,i=o?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(o&&n.size>i||z(n,i)))return null;t.push(i)}if(e.parent)return q(e.parent,t);t.reverse();try{!function(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if("object"!=typeof(e=$(3===H(e)?Array.from(e):e,r)))throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}}(e.copy,t)}catch(e){return null}return t}function H(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function $(e,t){return 2===H(e)?e.get(t):e[t]}function B(e,t,n){2===H(e)?e.set(t,n):e[t]=n}function W(e,t){const n=U(e);return(n?N(n):e)[t]}function X(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function K(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Y(e,t){return t?e:[""].concat(e).map((e=>{const t=`${e}`;return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const Z=Object.prototype.propertyIsEnumerable;function G(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return I(e)?Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values()):new(0,Object.getPrototypeOf(e).constructor)(e.values());if(e instanceof Map)return L(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,A),void 0!==n)&&n!==A.mutable){if(n===A.immutable)return function(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);r.enumerable&&r.configurable&&r.writable?t[n]=e[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r))})),t}(e);if("function"==typeof n){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){const t={};return Object.keys(e).forEach((n=>{t[n]=e[n]})),Object.getOwnPropertySymbols(e).forEach((n=>{Z.call(e,n)&&(t[n]=e[n])})),t}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function J(e){e.copy||(e.copy=G(e.original,e.options))}function Q(e){if(!F(e))return V(e);if(Array.isArray(e))return e.map(Q);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,Q(t)]));return L(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(Q);return I(e)?new Set(t):new(0,Object.getPrototypeOf(e).constructor)(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=Q(e[n]);return t}function ee(e){return _(e)?Q(e):e}function te(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&te(e.parent))}function ne(){throw new Error("Cannot modify frozen object")}function re(e,t,n,r,o){{n=null!=n?n:new WeakMap,r=null!=r?r:[],o=null!=o?o:[];const i=n.has(e)?n.get(e):e;if(r.length>0){const e=r.indexOf(i);if(i&&"object"==typeof i&&-1!==e){if(r[0]===i)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${o.slice(0,e).map(((e,t)=>{if("symbol"==typeof e)return`[${e.toString()}]`;const n=r[t];return"object"==typeof e&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(e):e})).join("/")}`)}r.push(i),o.push(t)}else r.push(i)}if(Object.isFrozen(e)||_(e))return r.pop(),void o.pop();switch(H(e)){case 2:for(const[t,i]of e)re(t,t,n,r,o),re(i,t,n,r,o);e.set=e.clear=e.delete=ne;break;case 3:for(const t of e)re(t,t,n,r,o);e.add=e.clear=e.delete=ne;break;case 1:Object.freeze(e);let t=0;for(const i of e)re(i,t,n,r,o),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{re(e[t],t,n,r,o)}))}r.pop(),o.pop()}function oe(e,t){const n=H(e);if(0===n)Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)}));else if(1===n){let n=0;for(const r of e)t(n,r,e),n+=1}else e.forEach(((n,r)=>t(r,n,e)))}function ie(e,t,n){if(_(e)||!F(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,o=r?new Map:void 0;if(t.add(e),oe(e,((i,s)=>{var a;if(_(s)){const t=U(s);J(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;B(r?o:e,i,n)}else ie(s,t,n)})),o){const t=e,n=Array.from(t);t.clear(),n.forEach((e=>{t.add(o.has(e)?o.get(e):e)}))}}function se(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&ie($(n,t),e.finalities.handledSet,e.options)}function ae(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(V(t))})))}function le(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=q(e);o&&t(e,o,n,r)}e.finalized=!0}}function ce(e,t,n,r){const o=U(n);o&&(o.callbacks||(o.callbacks=[]),o.callbacks.push(((i,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(X($(l,t),n)){let n=o.original;o.copy&&(n=o.copy),ae(e),le(e,r,i,s),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(a=e.options.updatedValues)&&void 0!==a?a:new WeakMap,e.options.updatedValues.set(n,o.original)),B(l,t,n)}})),e.options.enableAutoFreeze&&o.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),F(n,e.options)&&e.finalities.draft.push((()=>{X($(3===e.type?e.setMap:e.copy,t),n)&&se(e,t)}))}function ue(e,t,n,r){const{pathAsArray:o=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return function({original:e,copy:t,assignedMap:n},r,o,i,s){n.forEach(((n,a)=>{const l=$(e,a),c=ee($(t,a)),u=n?z(e,a)?R:j:k;if(X(l,c)&&u===R)return;const p=Y(r.concat(a),s);o.push(u===k?{op:u,path:p}:{op:u,path:p,value:c}),i.push(u===j?{op:k,path:p}:u===k?{op:j,path:p,value:l}:{op:R,path:p,value:l})}))}(e,t,n,r,o);case 1:return function(e,t,n,r,o){let{original:i,assignedMap:s,options:a}=e,l=e.copy;l.length<i.length&&([i,l]=[l,i],[n,r]=[r,n]);for(let e=0;e<i.length;e+=1)if(s.get(e.toString())&&l[e]!==i[e]){const s=Y(t.concat([e]),o);n.push({op:R,path:s,value:ee(l[e])}),r.push({op:R,path:s,value:ee(i[e])})}for(let e=i.length;e<l.length;e+=1){const r=Y(t.concat([e]),o);n.push({op:j,path:r,value:ee(l[e])})}if(i.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=Y(t.concat(["length"]),o);r.push({op:R,path:e,value:i.length})}else for(let e=l.length;i.length<e;e-=1){const n=Y(t.concat([e-1]),o);r.push({op:k,path:n})}}}(e,t,n,r,o);case 3:return function({original:e,copy:t},n,r,o,i){let s=0;e.forEach((e=>{if(!t.has(e)){const t=Y(n.concat([s]),i);r.push({op:k,path:t,value:e}),o.unshift({op:j,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=Y(n.concat([s]),i);r.push({op:j,path:e,value:t}),o.unshift({op:k,path:e,value:t})}s+=1}))}(e,t,n,r,o)}}const pe=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!F(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},fe={get size(){return N(U(this)).size},has(e){return N(U(this)).has(e)},set(e,t){const n=U(this),r=N(n);return r.has(e)&&X(r.get(e),t)||(J(n),te(n),n.assignedMap.set(e,!0),n.copy.set(e,t),ce(n,e,t,ue)),this},delete(e){if(!this.has(e))return!1;const t=U(this);return J(t),te(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=U(this);if(this.size){J(e),te(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){N(U(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=U(this),o=N(r).get(e),i=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,o,A))===A.mutable;if(r.options.strict&&pe(o,r.options,i),i)return o;if(r.finalized||!F(o,r.options))return o;if(o!==r.original.get(e))return o;const s=P.createDraft({original:o,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return J(r),r.copy.set(e,s),s},keys(){return N(U(this)).keys()},values(){const e=this.keys();return{[T]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[T]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[T](){return this.entries()}},he=Reflect.ownKeys(fe),de=(e,t,{isValuesIterator:n})=>()=>{var r,o;const i=t.next();if(i.done)return i;const s=i.value;let a=e.setMap.get(s);const l=U(a),c=(null===(o=(r=e.options).mark)||void 0===o?void 0:o.call(r,a,A))===A.mutable;if(e.options.strict&&pe(s,e.options,c),c||l||!F(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=P.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,t),a=t}return{done:!1,value:n?a:[a,a]}},ye={get size(){return U(this).setMap.size},has(e){const t=U(this);if(t.setMap.has(e))return!0;J(t);const n=U(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=U(this);return this.has(e)||(J(t),te(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),ce(t,e,e,ue)),this},delete(e){if(!this.has(e))return!1;const t=U(this);J(t),te(t);const n=U(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=U(this);J(e),te(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=U(this);J(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:de(e,t,{isValuesIterator:!0})}},entries(){const e=U(this);J(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:de(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[T](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(ye,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const ge=Reflect.ownKeys(ye),ve=new WeakSet,me={get(e,t,n){var r,o;const i=null===(r=e.copy)||void 0===r?void 0:r[t];if(i&&ve.has(i))return i;if(t===S)return e;let s;if(e.options.mark){const r="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(r,A),s===A.mutable)return e.options.strict&&pe(r,e.options,!0),r}const a=N(e);if(a instanceof Map&&he.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(fe,"size").get.call(e.proxy);const n=fe[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&ge.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ye,"size").get.call(e.proxy);const n=ye[t];if(n)return n.bind(e.proxy)}if(!z(a,t)){const n=D(a,t);return n?"value"in n?n.value:null===(o=n.get)||void 0===o?void 0:o.call(e.proxy):void 0}const l=a[t];if(e.options.strict&&pe(l,e.options),e.finalized||!F(l,e.options))return l;if(l===W(e.original,t)){if(J(e),e.copy[t]=be({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=U(e.copy[t]);return J(n),te(n),n.copy}return e.copy[t]}return l},set(e,t,n){var r;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");let o;if(1===e.type&&"length"!==t&&(!(Number.isInteger(o=Number(t))&&o>=0)||0!==t&&0!==o&&String(o)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");const i=D(N(e),t);if(null==i?void 0:i.set)return i.set.call(e.proxy,n),!0;const s=W(N(e),t),a=U(s);return a&&X(a.original,n)?(e.copy[t]=n,e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.set(t,!1),!0):(X(n,s)&&(void 0!==n||z(e.original,t))||(J(e),te(e),z(e.original,t)&&X(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,ce(e,t,n,ue)),!0)},has:(e,t)=>t in N(e),ownKeys:e=>Reflect.ownKeys(N(e)),getOwnPropertyDescriptor(e,t){const n=N(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},getPrototypeOf:e=>Reflect.getPrototypeOf(e.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return 1===e.type?me.set.call(this,e,t,void 0,e.proxy):(void 0!==W(e.original,t)||t in e.original?(J(e),te(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function be(e){const{original:t,parentDraft:n,key:r,finalities:o,options:i}=e,s=H(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:o,options:i,setMap:3===s?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===s?Object.assign([],a):a,me);if(o.revoke.push(c),ve.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var o,i;const s=U(l);let a=3===e.type?e.setMap:e.copy;const c=$(a,r),u=U(c);if(u){let i=u.original;u.operated&&(i=V(c)),ae(u),le(u,ue,t,n),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(o=e.options.updatedValues)&&void 0!==o?o:new WeakMap,e.options.updatedValues.set(i,u.original)),B(a,r,i)}null===(i=s.callbacks)||void 0===i||i.forEach((e=>{e(t,n)}))}))}else{const e=U(l);e.finalities.draft.push(((t,n)=>{ae(e),le(e,ue,t,n)}))}return l}function we(e,t,n,r,o){var i;const s=U(e),a=null!==(i=null==s?void 0:s.original)&&void 0!==i?i:e,l=!!t.length;if(null==s?void 0:s.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);const c=l?t[0]:s?s.operated?s.copy:s.original:e;return s&&K(s),o&&re(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:R,path:[],value:t[0]}]:n,r&&l?[{op:R,path:[],value:a}]:r]}function Oe(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:o=!0}=e;oe(n,((n,r,o)=>{const i=U(r);if(i&&t&&i.finalities===t.finalities){e.isContainDraft=!0;const t=i.original;if(o instanceof Set){const e=Array.from(o);o.clear(),e.forEach((e=>o.add(n===e?t:e)))}else B(o,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,Oe(e))})),o&&e.isContainDraft}function xe(e){var t;const n=U(e);if(!F(e,null==n?void 0:n.options))return e;const r=H(e);if(n&&!n.operated)return n.original;let o;function i(){o=2===r?L(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):G(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{i()}finally{n.finalized=!1}}else o=e;if(oe(o,((t,r)=>{if(n&&X($(n.original,t),r))return;const s=xe(r);s!==r&&(o===e&&i(),B(o,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:o;return I(e)?new Set(o):new(Object.getPrototypeOf(e).constructor)(o)}return o}function Ee(e){if(!_(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return xe(e)}P.createDraft=be;const Me=function e(t,n,r){var o,i,s;if("function"==typeof t&&"function"!=typeof n)return function(r,...o){return e(r,(e=>t.call(this,e,...o)),n)};const a=t,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},void 0),c);const u=_(a)?Ee(a):a,p=Array.isArray(c.mark)?(e,t)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(e,t);if(r)return r}}:c.mark,f=null!==(o=c.enablePatches)&&void 0!==o&&o,h=null!==(i=c.strict)&&void 0!==i&&i,d={enableAutoFreeze:null!==(s=c.enableAutoFreeze)&&void 0!==s&&s,mark:p,strict:h,enablePatches:f};if(!F(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[y,g]=function(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let o,i;t.enablePatches&&(o=[],i=[]);const s=(null===(n=t.mark)||void 0===n?void 0:n.call(t,e,A))!==A.mutable&&F(e,t)?be({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=we(s,e,o,i,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!F(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[y,g]}let v;try{v=l(y)}catch(e){throw K(U(y)),e}const m=e=>{const t=U(y);if(!_(e)){if(void 0!==e&&!X(e,y)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==e?void 0:e[C];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&Oe({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&Oe({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=U(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([Ee(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw K(U(y)),e})):m(v)};function ke(e,t){e.set(Me(e.get(),t))}Object.prototype.constructor.toString();class Re{constructor(e,t=null){this.value=e,this.reactor=t??new E(this,[])}produce(e){return ke(this,e)}reducer(...e){let t;return t=1===e.length?new M(this,"",e[0]):new M(this,e[0],e[1]),t.trigger.bind(t)}setObjectByPath(e="",t){if(0===e.length)return void(this.value=t);if("string"!=typeof e||!e)throw new Error("Invalid path");let n=e.split("."),r=this.value;for(let e=0;e<n.length-1;e++){let t=n[e];t in r||(r[t]={}),r=r[t]}r[n[n.length-1]]=t}set(...e){if(1===e.length)this.value=e[0];else{let t=e[0],n=e[1];this.setObjectByPath(t,n)}this.reactor.react()}get(){return this.value}}function je(e){return new Re(e)}class Se{constructor(e){this.target=e}set html(e){this.target.innerHTML=e}query(e){return this.target.querySelectorAll(e)}set text(e){this.target.textContent=e}on(e,t){this.target.addEventListener(e,t)}off(e,t){this.target.removeEventListener(e,t)}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Ce{constructor(e){this.target=e}query(e){return this.target.querySelectorAll(e)}index(e){return Array.from(this.target.children)[e]}list(){return Array.from(this.target.children)}get parent(){return this.target}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Te{constructor(e){this.target=e}set(e){this.target=e.forwardRefs}}window.RUMIOUS_CONTEXTS||(window.RUMIOUS_CONTEXTS={});class Ae{constructor(e={}){this.data=e,this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter((e=>e!==t)))}emit(e,...t){this.events[e]&&this.events[e].forEach((e=>e(...t)))}set(e,t){let n=je(t);return this.data[e]=n,n}get(e){return this.data[e]}}class Pe{constructor(e,t={}){this.hasExecuted=!1,this.result=null,this.callback=e,this.dependents=[],this.options=t}onLoad(e){this.hasExecuted?e(this.result):this.dependents.push(e)}execute(){return new Promise(((e,t)=>{if(this.hasExecuted)return e(this.result);this.hasExecuted=!0;const n=async()=>{try{this.result=await this.callback(),e(this.result),this.dependents.forEach((e=>e(this.result)))}catch(e){t(e)}};this.options.idle&&"requestIdleCallback"in window?requestIdleCallback(n):n()}))}}const ze=new Map;exports.Pending=class extends t{static tag="r-pending";constructor(){super(),this.asynchronousRender=!0}async setLoader(e){this.loader=e;try{this.result=await this.loader.execute(),this.renderResult()}catch(e){this.error=e,this.renderError()}}renderResult(){if(!this.result)throw"Rumious Render: Cannot find component when lazy loading!";this.element.before(this.render(h(this.result,{}))),this.element.remove()}renderError(){this.element.appendChild(this.render(this.props.errorComponent??this.error))}onRender(){let{loader:e}=this.props;this.setLoader(e)}template(){return this.props.fallback}},exports.RumiousApp=class{constructor(t=document.createElement("span"),n={}){this.root=t,this.app=this,this.modules=[],this.configs=n,this.renderContext=new e(this)}render(e){this.renderContext.runHooks("onBeforeRender",this.renderContext),x(e,this.root,this.renderContext),this.renderContext.runHooks("onRendered",this.renderContext)}addModule(e,t={}){return e.init(this,t)}},exports.RumiousChildrensRef=Ce,exports.RumiousComponent=t,exports.RumiousComponentElement=m,exports.RumiousComponentRef=Te,exports.RumiousContext=Ae,exports.RumiousDymanicInjector=w,exports.RumiousElementRef=Se,exports.RumiousLazyLoader=Pe,exports.RumiousReactor=E,exports.RumiousReducer=M,exports.RumiousState=Re,exports.createChildrensRef=function(e){return new Ce(e)},exports.createComponent=y,exports.createComponentElement=b,exports.createComponentRef=function(e){return new Te(e)},exports.createContext=function(e="",t={}){if(!t||"object"!=typeof t)throw"Rumious context: Initial value must be object !";return window.RUMIOUS_CONTEXTS[e]||(window.RUMIOUS_CONTEXTS[e]=new Ae(t)),window.RUMIOUS_CONTEXTS[e]},exports.createDirective=f,exports.createElement=h,exports.createElementRef=function(e){return new Se(e)},exports.createState=je,exports.createTextElement=d,exports.denounce=function(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},exports.injectHTML=function(e){let t=new w;return t.commit([{type:"html",value:e}]),t},exports.injectText=function(e){let t=new w;return t.commit([{type:"text",value:e}]),t},exports.isComponent=n,exports.isState=function(e){return e instanceof Re},exports.lazyLoad=function(e,t={}){const n=t.key||e.toString();return ze.has(n)||ze.set(n,new Pe(e,t)),ze.get(n)},exports.leadingTrailingDebounce=function(e,t){let n,r=!0;return function(...o){r&&(e.apply(this,o),r=!1),clearTimeout(n),n=setTimeout((()=>{e.apply(this,o),r=!0}),t)}},exports.produceState=ke,exports.rafThrottle=function(e){let t=!1;return function(...n){t||(t=!0,requestAnimationFrame((()=>{e.apply(this,n),t=!1})))}},exports.styleHelper=function(e){let t="";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){t+=`${n} {`;const r=e[n];for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t+=`${e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}: ${r[e]};`);t+="} "}return t.trim()},exports.tholle=function(e,t){let n=0;return function(...r){const o=Date.now();o-n>=t&&(n=o,e.apply(this,r))}},exports.trailingThrottle=function(e,t){let n=0,r=null,o=null;function i(){n=Date.now(),e.apply(this,r),r=null}return function(...e){const s=Date.now();r=e,s-n>=t?i():o||(o=setTimeout((()=>{o=null,i()}),t-(s-n)))}},exports.unwatch=function(e,t){e.reactor.removeBinding(t)},exports.watch=function(e,t){e.reactor.addBinding(t)};
@@ -1 +1 @@
1
- class e{constructor(e){this.target=e,this.app=e.app,this.hooks={onRendered:[],onBeforeRender:[]}}find(e){return this.target[e]}get(e){return this.target[e]}addHook(e,t){if(!this.hooks[e])throw new Error(`Hook type "${e}" is not defined!`);this.hooks[e].push(t)}async runHooks(e,...t){if(this.hooks[e])for(const n of this.hooks[e])await n(...t)}}class t{constructor(){this.asynchronousRender=!1,this.element=null,this.app=null,this.props={},this.forwardRefs={},this.renderContext=new e(this),this.renderer=null,this.wrapped=null}prepare(e,t,n={},r=null){this.element=e,this.props=t,this.renderer=r,this.wrapped=n,this.renderContext.app=this.app}template(){return{}}render(e){return this.renderer(e,document.createDocumentFragment(),this.renderContext)}requestRender(){let e=this.template(),t=this.renderer(e,document.createDocumentFragment(),this.renderContext);this.element.appendChild(t),this.onRender()}async requestCleanUp(){if(this.element){let e=this.element.cloneNode(!0);for(this.element.replaceWith(e),this.element=e;this.element.firstChild;)this.element.removeChild(this.element.firstChild)}}onInit(){}onCreate(){}onRender(){}onUpdate(){}onDestroy(){}}function n(e){return Object.getPrototypeOf(e)===t}class r{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class i{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function o(e){return"function"==typeof e}class s{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class a extends s{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!o(n))throw new Error(`${e} is not a function!`);return n.bind(t.target)};if("string"===this.value.type)n=r(this.value.value);else if("expression"===this.value.type){if(n=this.value.value,!o(n))throw new Error("Event handler requires a function!")}else"dynamic_value"===this.value.type&&(n=r(this.value.value.objectName));n&&e.addEventListener(this.name,n)}}class l extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");t.reactor.addBinding((()=>{let n=t.get();this.bindAttr(e,n)})),this.bindAttr(e,t.get())}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target),r=t.find(this.value.value.objectName);if(!r)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");r.reactor.addBinding((()=>{let n=this.value.evaluator?.(t.target);this.bindAttr(e,n)})),this.bindAttr(e,n)}}normalizeValue(e){return"object"==typeof e?e.toString?.()??"":e}async bindAttr(e,t){switch(this.name){case"html":e.innerHTML=this.normalizeValue(t);break;case"text":e.textContent=this.normalizeValue(t);break;case"show":e.style.display=this.normalizeValue(t)?"block":"none";break;case"hide":e.style.display=this.normalizeValue(t)?"none":"block";break;case"className":e.className=this.normalizeValue(t);break;case"style":Object.assign(e.style,t);break;case"disabled":e.disabled=!!this.normalizeValue(t);break;case"visible":e.style.visibility=this.normalizeValue(t)?"visible":"hidden";break;default:e.setAttribute(this.name,this.normalizeValue(t))}}}class c extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");n.set(e)}}}class u extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");n.set(e)}}}const p={on:(e,t)=>new a("on",e,t),bind:(e,t)=>new l("bind",e,t),ref:(e,t)=>new c("ref",e,t),childsRef:(e,t)=>new u("childsRef",e,t)};function f(e,t,n){return function(e,t,n){return p[e]?.(t,n)}(e,t,n)}function h(e,t,...i){return n(e)?y(e,t,i):e===g?g(...i):new r(e,t||{},v(i))}function d(e){return new r("TEXT_ELEMENT",{nodeValue:e},[])}function y(e,t,n){let o=new r("COMPONENT",{...t},new i(v(n)));return o.component=e,o}function g(...e){return new r("FRAGMENT",{},v(e))}function v(e){return e.map((e=>"object"==typeof e?e:d(e)))}window.RUMIOUS_JSX_SUPPORT={createElement:h,createFragment:g,createDirective:f};class m extends HTMLElement{constructor(){super(),this.instance=null,this.ref=null}cleanUp(){Object.setPrototypeOf(this,HTMLUnknownElement.prototype),this.remove()}init(e,t,n={},r,i){this.instance=new e,this.instance.element=this,this.instance.app=i,this.instance.prepare(this,t,n,r),this.instance.onInit()}connectedCallback(){this.instance.asynchronousRender?(async()=>{this.instance.onCreate(),this.instance.requestRender()})():(this.instance.onCreate(),this.instance.requestRender())}disconnectedCallback(){this.instance.onDestroy(),this.instance.requestCleanUp(),this.cleanUp()}}function b(e="r-component"){return window.customElements.get(e)||window.customElements.define(e,class extends m{static tag=e}),document.createElement(e)}class w{constructor(){this.contents=[],this.targets=[],this.observers=new WeakMap}commit(e=[]){this.contents=e}setTarget(e,t,n){this.targets.push({element:e,context:n,renderer:t}),this.observeTarget(e)}observeTarget(e){if(this.observers.has(e))return;const t=new MutationObserver((()=>{e.parentNode||this.removeTarget(e)}));t.observe(e,{childList:!1,subtree:!1}),this.observers.set(e,t)}removeTarget(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e)),this.targets=this.targets.filter((t=>t.element!==e))}inject(e=!1){for(let t of this.targets)e&&(t.element.textContent=""),this.contents.forEach((e=>{"html"===e.type?t.element.innerHTML=e.value:"text"===e.type?t.element.textContent=e.value:"component"===e.type&&t.renderer(h(e.value,e.props??{},e.child??{}),t.element,t.context)}))}}function O(e){let t=new w;return t.commit([{type:"html",value:e}]),t}function M(e){let t=new w;return t.commit([{type:"text",value:e}]),t}function E(e,t,n){for(const[r,i]of Object.entries(t||{}))i instanceof s?i.init(e,n):r.startsWith("on")&&/^[a-zA-Z]+([A-Z][a-z]*)*$/.test(r)?e.addEventListener(r.substring(2).toLowerCase(),i):e.setAttribute(r,i)}function k(e,t,n={}){if(!e)return t;if(null===(i=e)||"object"!=typeof i&&"function"!=typeof i)return k(d(e),t,n);var i;if(Array.isArray(e)){for(const r of e)k(r,t,n);return t}if(e instanceof r){let r;switch(e.type){case"COMPONENT":return function(e,t,n,r){const i=function(e,t,n,r,i=null){const o=b(e.tag??"r-component");return o.init(e,t,n,r,i?.app),o}(e.component,e.props,e.children,n,r);return E(i,e.props,r),t.appendChild(i),t}(e,t,k,n);case"FRAGMENT":case"ELEMENT_LIST":for(const r of e.children)k(r,t,n);return t;case"TEXT_ELEMENT":r=function(e){return document.createTextNode(e.props.nodeValue)}(e);break;default:r=function(e,t){const n=document.createElement(e.type);E(n,e.props,t);for(const r of e.children)k(r,n,t);return n}(e,n)}return t.appendChild(r),t}if(e instanceof HTMLElement)return t.appendChild(e),t;if(e instanceof w){if(t instanceof HTMLDocument)throw"Rumious Render: Unsupported inject content in HTMLDocument!";return e.setTarget(t,k,n),e.inject(!0),t}return k(d(JSON.stringify(e)),t,n)}class j{constructor(t=document.createElement("span"),n={}){this.root=t,this.app=this,this.modules=[],this.configs=n,this.renderContext=new e(this)}render(e){this.renderContext.runHooks("onBeforeRender",this.renderContext),k(e,this.root,this.renderContext),this.renderContext.runHooks("onRendered",this.renderContext)}addModule(e,t={}){return e.init(this,t)}}function S(e){let t="";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){t+=`${n} {`;const r=e[n];for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t+=`${e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}: ${r[e]};`);t+="} "}return t.trim()}class R{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}removeBinding(e){for(let t=this.bindings.length-1;t>=0;t--)this.bindings[t]===e&&this.bindings.splice(t,1)}addBinding(e){this.bindings.push(e)}}class x{constructor(e,t="",n){this.state=e,this.path=t,this.fn=n}trigger(...e){let t=this.fn(...e);this.state.set(this.path,t)}}const C="remove",A="replace",P="add",T=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),z=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),D=Symbol.iterator,I={mutable:"mutable",immutable:"immutable"},N={};function _(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function L(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const e=Reflect.getOwnPropertyDescriptor(n,t);if(e)return e;n=Reflect.getPrototypeOf(n)}}}function U(e){return Object.getPrototypeOf(e)===Set.prototype}function V(e){return Object.getPrototypeOf(e)===Map.prototype}function F(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function q(e){return!!$(e)}function $(e){return"object"!=typeof e?null:null==e?void 0:e[T]}function H(e){var t;const n=$(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function B(e,t){if(!e||"object"!=typeof e)return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((n=t.mark(e,I))===I.immutable||"function"==typeof n)}function W(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=$(K(n,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;const i=3===e.parent.type,o=i?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(i&&n.size>o||_(n,o)))return null;t.push(o)}if(e.parent)return W(e.parent,t);t.reverse();try{!function(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if("object"!=typeof(e=K(3===X(e)?Array.from(e):e,r)))throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}}(e.copy,t)}catch(e){return null}return t}function X(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function K(e,t){return 2===X(e)?e.get(t):e[t]}function Y(e,t,n){2===X(e)?e.set(t,n):e[t]=n}function Z(e,t){const n=$(e);return(n?F(n):e)[t]}function G(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function J(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Q(e,t){return t?e:[""].concat(e).map((e=>{const t=`${e}`;return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const ee=Object.prototype.propertyIsEnumerable;function te(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return U(e)?Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values()):new(0,Object.getPrototypeOf(e).constructor)(e.values());if(e instanceof Map)return V(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,I),void 0!==n)&&n!==I.mutable){if(n===I.immutable)return function(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);r.enumerable&&r.configurable&&r.writable?t[n]=e[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r))})),t}(e);if("function"==typeof n){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){const t={};return Object.keys(e).forEach((n=>{t[n]=e[n]})),Object.getOwnPropertySymbols(e).forEach((n=>{ee.call(e,n)&&(t[n]=e[n])})),t}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function ne(e){e.copy||(e.copy=te(e.original,e.options))}function re(e){if(!B(e))return H(e);if(Array.isArray(e))return e.map(re);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,re(t)]));return V(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(re);return U(e)?new Set(t):new(0,Object.getPrototypeOf(e).constructor)(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=re(e[n]);return t}function ie(e){return q(e)?re(e):e}function oe(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&oe(e.parent))}function se(){throw new Error("Cannot modify frozen object")}function ae(e,t,n,r,i){{n=null!=n?n:new WeakMap,r=null!=r?r:[],i=null!=i?i:[];const o=n.has(e)?n.get(e):e;if(r.length>0){const e=r.indexOf(o);if(o&&"object"==typeof o&&-1!==e){if(r[0]===o)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${i.slice(0,e).map(((e,t)=>{if("symbol"==typeof e)return`[${e.toString()}]`;const n=r[t];return"object"==typeof e&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(e):e})).join("/")}`)}r.push(o),i.push(t)}else r.push(o)}if(Object.isFrozen(e)||q(e))return r.pop(),void i.pop();switch(X(e)){case 2:for(const[t,o]of e)ae(t,t,n,r,i),ae(o,t,n,r,i);e.set=e.clear=e.delete=se;break;case 3:for(const t of e)ae(t,t,n,r,i);e.add=e.clear=e.delete=se;break;case 1:Object.freeze(e);let t=0;for(const o of e)ae(o,t,n,r,i),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{ae(e[t],t,n,r,i)}))}r.pop(),i.pop()}function le(e,t){const n=X(e);if(0===n)Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)}));else if(1===n){let n=0;for(const r of e)t(n,r,e),n+=1}else e.forEach(((n,r)=>t(r,n,e)))}function ce(e,t,n){if(q(e)||!B(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,i=r?new Map:void 0;if(t.add(e),le(e,((o,s)=>{var a;if(q(s)){const t=$(s);ne(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;Y(r?i:e,o,n)}else ce(s,t,n)})),i){const t=e,n=Array.from(t);t.clear(),n.forEach((e=>{t.add(i.has(e)?i.get(e):e)}))}}function ue(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&ce(K(n,t),e.finalities.handledSet,e.options)}function pe(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(H(t))})))}function fe(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const i=W(e);i&&t(e,i,n,r)}e.finalized=!0}}function he(e,t,n,r){const i=$(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push(((o,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(G(K(l,t),n)){let n=i.original;i.copy&&(n=i.copy),pe(e),fe(e,r,o,s),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(a=e.options.updatedValues)&&void 0!==a?a:new WeakMap,e.options.updatedValues.set(n,i.original)),Y(l,t,n)}})),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),B(n,e.options)&&e.finalities.draft.push((()=>{G(K(3===e.type?e.setMap:e.copy,t),n)&&ue(e,t)}))}function de(e,t,n,r){const{pathAsArray:i=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return function({original:e,copy:t,assignedMap:n},r,i,o,s){n.forEach(((n,a)=>{const l=K(e,a),c=ie(K(t,a)),u=n?_(e,a)?A:P:C;if(G(l,c)&&u===A)return;const p=Q(r.concat(a),s);i.push(u===C?{op:u,path:p}:{op:u,path:p,value:c}),o.push(u===P?{op:C,path:p}:u===C?{op:P,path:p,value:l}:{op:A,path:p,value:l})}))}(e,t,n,r,i);case 1:return function(e,t,n,r,i){let{original:o,assignedMap:s,options:a}=e,l=e.copy;l.length<o.length&&([o,l]=[l,o],[n,r]=[r,n]);for(let e=0;e<o.length;e+=1)if(s.get(e.toString())&&l[e]!==o[e]){const s=Q(t.concat([e]),i);n.push({op:A,path:s,value:ie(l[e])}),r.push({op:A,path:s,value:ie(o[e])})}for(let e=o.length;e<l.length;e+=1){const r=Q(t.concat([e]),i);n.push({op:P,path:r,value:ie(l[e])})}if(o.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=Q(t.concat(["length"]),i);r.push({op:A,path:e,value:o.length})}else for(let e=l.length;o.length<e;e-=1){const n=Q(t.concat([e-1]),i);r.push({op:C,path:n})}}}(e,t,n,r,i);case 3:return function({original:e,copy:t},n,r,i,o){let s=0;e.forEach((e=>{if(!t.has(e)){const t=Q(n.concat([s]),o);r.push({op:C,path:t,value:e}),i.unshift({op:P,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=Q(n.concat([s]),o);r.push({op:P,path:e,value:t}),i.unshift({op:C,path:e,value:t})}s+=1}))}(e,t,n,r,i)}}const ye=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!B(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},ge={get size(){return F($(this)).size},has(e){return F($(this)).has(e)},set(e,t){const n=$(this),r=F(n);return r.has(e)&&G(r.get(e),t)||(ne(n),oe(n),n.assignedMap.set(e,!0),n.copy.set(e,t),he(n,e,t,de)),this},delete(e){if(!this.has(e))return!1;const t=$(this);return ne(t),oe(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=$(this);if(this.size){ne(e),oe(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){F($(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=$(this),i=F(r).get(e),o=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,i,I))===I.mutable;if(r.options.strict&&ye(i,r.options,o),o)return i;if(r.finalized||!B(i,r.options))return i;if(i!==r.original.get(e))return i;const s=N.createDraft({original:i,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return ne(r),r.copy.set(e,s),s},keys(){return F($(this)).keys()},values(){const e=this.keys();return{[D]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[D]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[D](){return this.entries()}},ve=Reflect.ownKeys(ge),me=(e,t,{isValuesIterator:n})=>()=>{var r,i;const o=t.next();if(o.done)return o;const s=o.value;let a=e.setMap.get(s);const l=$(a),c=(null===(i=(r=e.options).mark)||void 0===i?void 0:i.call(r,a,I))===I.mutable;if(e.options.strict&&ye(s,e.options,c),c||l||!B(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=N.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,t),a=t}return{done:!1,value:n?a:[a,a]}},be={get size(){return $(this).setMap.size},has(e){const t=$(this);if(t.setMap.has(e))return!0;ne(t);const n=$(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=$(this);return this.has(e)||(ne(t),oe(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),he(t,e,e,de)),this},delete(e){if(!this.has(e))return!1;const t=$(this);ne(t),oe(t);const n=$(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=$(this);ne(e),oe(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=$(this);ne(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:me(e,t,{isValuesIterator:!0})}},entries(){const e=$(this);ne(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:me(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[D](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(be,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const we=Reflect.ownKeys(be),Oe=new WeakSet,Me={get(e,t,n){var r,i;const o=null===(r=e.copy)||void 0===r?void 0:r[t];if(o&&Oe.has(o))return o;if(t===T)return e;let s;if(e.options.mark){const r="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(r,I),s===I.mutable)return e.options.strict&&ye(r,e.options,!0),r}const a=F(e);if(a instanceof Map&&ve.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ge,"size").get.call(e.proxy);const n=ge[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&we.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(be,"size").get.call(e.proxy);const n=be[t];if(n)return n.bind(e.proxy)}if(!_(a,t)){const n=L(a,t);return n?"value"in n?n.value:null===(i=n.get)||void 0===i?void 0:i.call(e.proxy):void 0}const l=a[t];if(e.options.strict&&ye(l,e.options),e.finalized||!B(l,e.options))return l;if(l===Z(e.original,t)){if(ne(e),e.copy[t]=Ee({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=$(e.copy[t]);return ne(n),oe(n),n.copy}return e.copy[t]}return l},set(e,t,n){var r;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");let i;if(1===e.type&&"length"!==t&&(!(Number.isInteger(i=Number(t))&&i>=0)||0!==t&&0!==i&&String(i)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");const o=L(F(e),t);if(null==o?void 0:o.set)return o.set.call(e.proxy,n),!0;const s=Z(F(e),t),a=$(s);return a&&G(a.original,n)?(e.copy[t]=n,e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.set(t,!1),!0):(G(n,s)&&(void 0!==n||_(e.original,t))||(ne(e),oe(e),_(e.original,t)&&G(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,he(e,t,n,de)),!0)},has:(e,t)=>t in F(e),ownKeys:e=>Reflect.ownKeys(F(e)),getOwnPropertyDescriptor(e,t){const n=F(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},getPrototypeOf:e=>Reflect.getPrototypeOf(e.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return 1===e.type?Me.set.call(this,e,t,void 0,e.proxy):(void 0!==Z(e.original,t)||t in e.original?(ne(e),oe(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function Ee(e){const{original:t,parentDraft:n,key:r,finalities:i,options:o}=e,s=X(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:i,options:o,setMap:3===s?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===s?Object.assign([],a):a,Me);if(i.revoke.push(c),Oe.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var i,o;const s=$(l);let a=3===e.type?e.setMap:e.copy;const c=K(a,r),u=$(c);if(u){let o=u.original;u.operated&&(o=H(c)),pe(u),fe(u,de,t,n),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(i=e.options.updatedValues)&&void 0!==i?i:new WeakMap,e.options.updatedValues.set(o,u.original)),Y(a,r,o)}null===(o=s.callbacks)||void 0===o||o.forEach((e=>{e(t,n)}))}))}else{const e=$(l);e.finalities.draft.push(((t,n)=>{pe(e),fe(e,de,t,n)}))}return l}function ke(e,t,n,r,i){var o;const s=$(e),a=null!==(o=null==s?void 0:s.original)&&void 0!==o?o:e,l=!!t.length;if(null==s?void 0:s.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);const c=l?t[0]:s?s.operated?s.copy:s.original:e;return s&&J(s),i&&ae(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:A,path:[],value:t[0]}]:n,r&&l?[{op:A,path:[],value:a}]:r]}function je(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:i=!0}=e;le(n,((n,r,i)=>{const o=$(r);if(o&&t&&o.finalities===t.finalities){e.isContainDraft=!0;const t=o.original;if(i instanceof Set){const e=Array.from(i);i.clear(),e.forEach((e=>i.add(n===e?t:e)))}else Y(i,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,je(e))})),i&&e.isContainDraft}function Se(e){var t;const n=$(e);if(!B(e,null==n?void 0:n.options))return e;const r=X(e);if(n&&!n.operated)return n.original;let i;function o(){i=2===r?V(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):te(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{o()}finally{n.finalized=!1}}else i=e;if(le(i,((t,r)=>{if(n&&G(K(n.original,t),r))return;const s=Se(r);s!==r&&(i===e&&o(),Y(i,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:i;return U(e)?new Set(i):new(Object.getPrototypeOf(e).constructor)(i)}return i}function Re(e){if(!q(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return Se(e)}N.createDraft=Ee;const xe=function e(t,n,r){var i,o,s;if("function"==typeof t&&"function"!=typeof n)return function(r,...i){return e(r,(e=>t.call(this,e,...i)),n)};const a=t,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},void 0),c);const u=q(a)?Re(a):a,p=Array.isArray(c.mark)?(e,t)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(e,t);if(r)return r}}:c.mark,f=null!==(i=c.enablePatches)&&void 0!==i&&i,h=null!==(o=c.strict)&&void 0!==o&&o,d={enableAutoFreeze:null!==(s=c.enableAutoFreeze)&&void 0!==s&&s,mark:p,strict:h,enablePatches:f};if(!B(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[y,g]=function(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let i,o;t.enablePatches&&(i=[],o=[]);const s=(null===(n=t.mark)||void 0===n?void 0:n.call(t,e,I))!==I.mutable&&B(e,t)?Ee({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=ke(s,e,i,o,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!B(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[y,g]}let v;try{v=l(y)}catch(e){throw J($(y)),e}const m=e=>{const t=$(y);if(!q(e)){if(void 0!==e&&!G(e,y)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==e?void 0:e[z];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&je({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&je({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=$(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([Re(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw J($(y)),e})):m(v)};function Ce(e,t){e.set(xe(e.get(),t))}Object.prototype.constructor.toString();class Ae{constructor(e,t=null){this.value=e,this.reactor=t??new R(this,[])}produce(e){return Ce(this,e)}reducer(...e){let t;return t=1===e.length?new x(this,"",e[0]):new x(this,e[0],e[1]),t.trigger.bind(t)}setObjectByPath(e="",t){if(0===e.length)return void(this.value=t);if("string"!=typeof e||!e)throw new Error("Invalid path");let n=e.split("."),r=this.value;for(let e=0;e<n.length-1;e++){let t=n[e];t in r||(r[t]={}),r=r[t]}r[n[n.length-1]]=t}set(...e){if(1===e.length)this.value=e[0];else{let t=e[0],n=e[1];this.setObjectByPath(t,n)}this.reactor.react()}get(){return this.value}}function Pe(e){return new Ae(e)}function Te(e){return e instanceof Ae}function ze(e,t){e.reactor.addBinding(t)}function De(e,t){e.reactor.removeBinding(t)}class Ie{constructor(e){this.target=e}set html(e){this.target.innerHTML=e}query(e){return this.target.querySelectorAll(e)}set text(e){this.target.textContent=e}on(e,t){this.target.addEventListener(e,t)}off(e,t){this.target.removeEventListener(e,t)}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}function Ne(e){return new Ie(e)}class _e{constructor(e){this.target=e}query(e){return this.target.querySelectorAll(e)}index(e){return Array.from(this.target.children)[e]}list(){return Array.from(this.target.children)}get parent(){return this.target}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}function Le(e){return new _e(e)}class Ue{constructor(e){this.target=e}set(e){this.target=e.forwardRefs}}function Ve(e){return new Ue(e)}window.RUMIOUS_CONTEXTS||(window.RUMIOUS_CONTEXTS={});class Fe{constructor(e={}){this.data=e,this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter((e=>e!==t)))}emit(e,...t){this.events[e]&&this.events[e].forEach((e=>e(...t)))}set(e,t){let n=Pe(t);return this.data[e]=n,n}get(e){return this.data[e]}}function qe(e="",t={}){if(!t||"object"!=typeof t)throw"Rumious context: Initial value must be object !";return window.RUMIOUS_CONTEXTS[e]||(window.RUMIOUS_CONTEXTS[e]=new Fe(t)),window.RUMIOUS_CONTEXTS[e]}class $e extends t{static tag="r-pending";constructor(){super(),this.asynchronousRender=!0}async setLoader(e){this.loader=e;try{this.result=await this.loader.execute(),this.renderResult()}catch(e){this.error=e,this.renderError()}}renderResult(){if(!this.result)throw"Rumious Render: Cannot find component when lazy loading!";this.element.before(this.render(h(this.result,{}))),this.element.remove()}renderError(){this.element.appendChild(this.render(this.props.errorComponent??this.error))}onRender(){let{loader:e}=this.props;this.setLoader(e)}template(){return this.props.fallback}}class He{constructor(e,t={}){this.hasExecuted=!1,this.result=null,this.callback=e,this.dependents=[],this.options=t}onLoad(e){this.hasExecuted?e(this.result):this.dependents.push(e)}execute(){return new Promise(((e,t)=>{if(this.hasExecuted)return e(this.result);this.hasExecuted=!0;const n=async()=>{try{this.result=await this.callback(),e(this.result),this.dependents.forEach((e=>e(this.result)))}catch(e){t(e)}};this.options.idle&&"requestIdleCallback"in window?requestIdleCallback(n):n()}))}}const Be=new Map;function We(e,t={}){const n=t.key||e.toString();return Be.has(n)||Be.set(n,new He(e,t)),Be.get(n)}function Xe(e,t){let n=0;return function(...r){const i=Date.now();i-n>=t&&(n=i,e.apply(this,r))}}function Ke(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}}function Ye(e,t){let n=0,r=null,i=null;function o(){n=Date.now(),e.apply(this,r),r=null}return function(...e){const s=Date.now();r=e,s-n>=t?o():i||(i=setTimeout((()=>{i=null,o()}),t-(s-n)))}}function Ze(e,t){let n,r=!0;return function(...i){r&&(e.apply(this,i),r=!1),clearTimeout(n),n=setTimeout((()=>{e.apply(this,i),r=!0}),t)}}function Ge(e){let t=!1;return function(...n){t||(t=!0,requestAnimationFrame((()=>{e.apply(this,n),t=!1})))}}export{$e as Pending,j as RumiousApp,_e as RumiousChildrensRef,t as RumiousComponent,m as RumiousComponentElement,Ue as RumiousComponentRef,Fe as RumiousContext,w as RumiousDymanicInjector,Ie as RumiousElementRef,He as RumiousLazyLoader,R as RumiousReactor,x as RumiousReducer,Ae as RumiousState,Le as createChildrensRef,y as createComponent,b as createComponentElement,Ve as createComponentRef,qe as createContext,f as createDirective,h as createElement,Ne as createElementRef,Pe as createState,d as createTextElement,Ke as denounce,O as injectHTML,M as injectText,n as isComponent,Te as isState,We as lazyLoad,Ze as leadingTrailingDebounce,Ce as produceState,Ge as rafThrottle,S as styleHelper,Xe as tholle,Ye as trailingThrottle,De as unwatch,ze as watch};
1
+ class e{constructor(e){this.target=e,this.app=e.app,this.hooks={onRendered:[],onBeforeRender:[]}}find(e){return this.target[e]}get(e){return this.target[e]}addHook(e,t){if(!this.hooks[e])throw new Error(`Hook type "${e}" is not defined!`);this.hooks[e].push(t)}async runHooks(e,...t){if(this.hooks[e])for(const n of this.hooks[e])await n(...t)}}class t{constructor(){this.asynchronousRender=!1,this.element=null,this.app=null,this.props={},this.forwardRefs={},this.renderContext=new e(this),this.renderer=null,this.wrapped=null}prepare(e,t,n={},r=null){this.element=e,this.props=t,this.renderer=r,this.wrapped=n,this.renderContext.app=this.app}template(){return{}}render(e){return this.renderer(e,document.createDocumentFragment(),this.renderContext)}requestRender(){let e=this.template(),t=this.renderer(e,document.createDocumentFragment(),this.renderContext);this.element.appendChild(t),this.onRender()}async requestCleanUp(){if(this.element){let e=this.element.cloneNode(!0);for(this.element.replaceWith(e),this.element=e;this.element.firstChild;)this.element.removeChild(this.element.firstChild)}}onInit(){}onCreate(){}onRender(){}onUpdate(){}onDestroy(){}}function n(e){return Object.getPrototypeOf(e)===t}class r{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class i{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function o(e){return"function"==typeof e}class s{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class a extends s{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!o(n))throw new Error(`${e} is not a function!`);return n.bind(t.target)};if("string"===this.value.type)n=r(this.value.value);else if("expression"===this.value.type){if(n=this.value.value,!o(n))throw new Error("Event handler requires a function!")}else"dynamic_value"===this.value.type&&(n=r(this.value.value.objectName));n&&e.addEventListener(this.name,n)}}class l extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");t.reactor.addBinding((()=>{let n=t.get();this.bindAttr(e,n)})),this.bindAttr(e,t.get())}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target),r=t.find(this.value.value.objectName);if(!r)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");r.reactor.addBinding((()=>{let n=this.value.evaluator?.(t.target);this.bindAttr(e,n)})),this.bindAttr(e,n)}}normalizeValue(e){return"object"==typeof e?e.toString?.()??"":e}async bindAttr(e,t){switch(this.name){case"html":e.innerHTML=this.normalizeValue(t);break;case"text":e.textContent=this.normalizeValue(t);break;case"show":e.style.display=this.normalizeValue(t)?"block":"none";break;case"hide":e.style.display=this.normalizeValue(t)?"none":"block";break;case"className":e.className=this.normalizeValue(t);break;case"style":Object.assign(e.style,t);break;case"disabled":e.disabled=!!this.normalizeValue(t);break;case"visible":e.style.visibility=this.normalizeValue(t)?"visible":"hidden";break;default:e.setAttribute(this.name,this.normalizeValue(t))}}}class c extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");n.set(e)}}}class u extends s{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");n.set(e)}}}const p={on:(e,t)=>new a("on",e,t),bind:(e,t)=>new l("bind",e,t),ref:(e,t)=>new c("ref",e,t),childsRef:(e,t)=>new u("childsRef",e,t)};function f(e,t,n){return function(e,t,n){return p[e]?.(t,n)}(e,t,n)}function h(e,t,...i){return n(e)?y(e,t,i):e===g?g(...i):new r(e,t||{},v(i))}function d(e){return new r("TEXT_ELEMENT",{nodeValue:e},[])}function y(e,t,n){let o=new r("COMPONENT",{...t},new i(v(n)));return o.component=e,o}function g(...e){return new r("FRAGMENT",{},v(e))}function v(e){return e.map((e=>"object"==typeof e?e:d(e)))}window.RUMIOUS_JSX_SUPPORT={createElement:h,createFragment:g,createDirective:f};class m extends HTMLElement{constructor(){super(),this.instance=null,this.ref=null}cleanUp(){Object.setPrototypeOf(this,HTMLUnknownElement.prototype),this.remove()}init(e,t,n={},r,i){this.instance=new e,this.instance.element=this,this.instance.app=i,this.instance.prepare(this,t,n,r),this.instance.onInit()}connectedCallback(){this.instance.asynchronousRender?(async()=>{this.instance.onCreate(),this.instance.requestRender()})():(this.instance.onCreate(),this.instance.requestRender())}disconnectedCallback(){this.instance.onDestroy(),this.instance.requestCleanUp(),this.cleanUp()}}function b(e="r-component"){return window.customElements.get(e)||window.customElements.define(e,class extends m{static tag=e}),document.createElement(e)}class w{constructor(){this.contents=[],this.targets=[],this.observers=new WeakMap}commit(e=[]){this.contents=e}setTarget(e,t,n){this.targets.push({element:e,context:n,renderer:t}),this.observeTarget(e)}observeTarget(e){if(this.observers.has(e))return;const t=new MutationObserver((()=>{e.parentNode||this.removeTarget(e)}));t.observe(document.body,{childList:!0}),this.observers.set(e,t)}removeTarget(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e)),this.targets=this.targets.filter((t=>t.element!==e))}inject(e=!1){for(let t of this.targets)e&&(t.element.textContent=""),this.contents.forEach((e=>{"html"===e.type?t.element.innerHTML=e.value:"text"===e.type?t.element.textContent=e.value:"component"===e.type&&t.renderer(h(e.value,e.props??{},e.child??{}),t.element,t.context)}))}}function O(e){let t=new w;return t.commit([{type:"html",value:e}]),t}function M(e){let t=new w;return t.commit([{type:"text",value:e}]),t}function E(e,t,n){for(const[r,i]of Object.entries(t||{}))i instanceof s?i.init(e,n):r.startsWith("on")&&/^[a-zA-Z]+([A-Z][a-z]*)*$/.test(r)?e.addEventListener(r.substring(2).toLowerCase(),i):e.setAttribute(r,i)}function k(e,t,n={}){if(!e)return t;if(null===(i=e)||"object"!=typeof i&&"function"!=typeof i)return k(d(e),t,n);var i;if(Array.isArray(e)){for(const r of e)k(r,t,n);return t}if(e instanceof r){let r;switch(e.type){case"COMPONENT":return function(e,t,n,r){const i=function(e,t,n,r,i=null){const o=b(e.tag??"r-component");return o.init(e,t,n,r,i?.app),o}(e.component,e.props,e.children,n,r);return E(i,e.props,r),t.appendChild(i),t}(e,t,k,n);case"FRAGMENT":case"ELEMENT_LIST":for(const r of e.children)k(r,t,n);return t;case"TEXT_ELEMENT":r=function(e){return document.createTextNode(e.props.nodeValue)}(e);break;default:r=function(e,t){const n=document.createElement(e.type);E(n,e.props,t);for(const r of e.children)k(r,n,t);return n}(e,n)}return t.appendChild(r),t}if(e instanceof HTMLElement)return t.appendChild(e),t;if(e instanceof w){if(t instanceof HTMLDocument)throw"Rumious Render: Unsupported inject content in HTMLDocument!";return e.setTarget(t,k,n),e.inject(!0),t}return k(d(JSON.stringify(e)),t,n)}class j{constructor(t=document.createElement("span"),n={}){this.root=t,this.app=this,this.modules=[],this.configs=n,this.renderContext=new e(this)}render(e){this.renderContext.runHooks("onBeforeRender",this.renderContext),k(e,this.root,this.renderContext),this.renderContext.runHooks("onRendered",this.renderContext)}addModule(e,t={}){return e.init(this,t)}}function S(e){let t="";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){t+=`${n} {`;const r=e[n];for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t+=`${e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}: ${r[e]};`);t+="} "}return t.trim()}class R{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}removeBinding(e){for(let t=this.bindings.length-1;t>=0;t--)this.bindings[t]===e&&this.bindings.splice(t,1)}addBinding(e){this.bindings.push(e)}}class x{constructor(e,t="",n){this.state=e,this.path=t,this.fn=n}trigger(...e){let t=this.fn(...e);this.state.set(this.path,t)}}const C="remove",A="replace",P="add",T=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),z=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),D=Symbol.iterator,I={mutable:"mutable",immutable:"immutable"},N={};function _(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function L(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const e=Reflect.getOwnPropertyDescriptor(n,t);if(e)return e;n=Reflect.getPrototypeOf(n)}}}function U(e){return Object.getPrototypeOf(e)===Set.prototype}function V(e){return Object.getPrototypeOf(e)===Map.prototype}function F(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function q(e){return!!$(e)}function $(e){return"object"!=typeof e?null:null==e?void 0:e[T]}function H(e){var t;const n=$(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function B(e,t){if(!e||"object"!=typeof e)return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((n=t.mark(e,I))===I.immutable||"function"==typeof n)}function W(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=$(K(n,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;const i=3===e.parent.type,o=i?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(i&&n.size>o||_(n,o)))return null;t.push(o)}if(e.parent)return W(e.parent,t);t.reverse();try{!function(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if("object"!=typeof(e=K(3===X(e)?Array.from(e):e,r)))throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}}(e.copy,t)}catch(e){return null}return t}function X(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function K(e,t){return 2===X(e)?e.get(t):e[t]}function Y(e,t,n){2===X(e)?e.set(t,n):e[t]=n}function Z(e,t){const n=$(e);return(n?F(n):e)[t]}function G(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function J(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Q(e,t){return t?e:[""].concat(e).map((e=>{const t=`${e}`;return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const ee=Object.prototype.propertyIsEnumerable;function te(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return U(e)?Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values()):new(0,Object.getPrototypeOf(e).constructor)(e.values());if(e instanceof Map)return V(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,I),void 0!==n)&&n!==I.mutable){if(n===I.immutable)return function(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);r.enumerable&&r.configurable&&r.writable?t[n]=e[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r))})),t}(e);if("function"==typeof n){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){const t={};return Object.keys(e).forEach((n=>{t[n]=e[n]})),Object.getOwnPropertySymbols(e).forEach((n=>{ee.call(e,n)&&(t[n]=e[n])})),t}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function ne(e){e.copy||(e.copy=te(e.original,e.options))}function re(e){if(!B(e))return H(e);if(Array.isArray(e))return e.map(re);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,re(t)]));return V(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(re);return U(e)?new Set(t):new(0,Object.getPrototypeOf(e).constructor)(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=re(e[n]);return t}function ie(e){return q(e)?re(e):e}function oe(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&oe(e.parent))}function se(){throw new Error("Cannot modify frozen object")}function ae(e,t,n,r,i){{n=null!=n?n:new WeakMap,r=null!=r?r:[],i=null!=i?i:[];const o=n.has(e)?n.get(e):e;if(r.length>0){const e=r.indexOf(o);if(o&&"object"==typeof o&&-1!==e){if(r[0]===o)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${i.slice(0,e).map(((e,t)=>{if("symbol"==typeof e)return`[${e.toString()}]`;const n=r[t];return"object"==typeof e&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(e):e})).join("/")}`)}r.push(o),i.push(t)}else r.push(o)}if(Object.isFrozen(e)||q(e))return r.pop(),void i.pop();switch(X(e)){case 2:for(const[t,o]of e)ae(t,t,n,r,i),ae(o,t,n,r,i);e.set=e.clear=e.delete=se;break;case 3:for(const t of e)ae(t,t,n,r,i);e.add=e.clear=e.delete=se;break;case 1:Object.freeze(e);let t=0;for(const o of e)ae(o,t,n,r,i),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{ae(e[t],t,n,r,i)}))}r.pop(),i.pop()}function le(e,t){const n=X(e);if(0===n)Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)}));else if(1===n){let n=0;for(const r of e)t(n,r,e),n+=1}else e.forEach(((n,r)=>t(r,n,e)))}function ce(e,t,n){if(q(e)||!B(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,i=r?new Map:void 0;if(t.add(e),le(e,((o,s)=>{var a;if(q(s)){const t=$(s);ne(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;Y(r?i:e,o,n)}else ce(s,t,n)})),i){const t=e,n=Array.from(t);t.clear(),n.forEach((e=>{t.add(i.has(e)?i.get(e):e)}))}}function ue(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&ce(K(n,t),e.finalities.handledSet,e.options)}function pe(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(H(t))})))}function fe(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const i=W(e);i&&t(e,i,n,r)}e.finalized=!0}}function he(e,t,n,r){const i=$(n);i&&(i.callbacks||(i.callbacks=[]),i.callbacks.push(((o,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(G(K(l,t),n)){let n=i.original;i.copy&&(n=i.copy),pe(e),fe(e,r,o,s),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(a=e.options.updatedValues)&&void 0!==a?a:new WeakMap,e.options.updatedValues.set(n,i.original)),Y(l,t,n)}})),e.options.enableAutoFreeze&&i.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),B(n,e.options)&&e.finalities.draft.push((()=>{G(K(3===e.type?e.setMap:e.copy,t),n)&&ue(e,t)}))}function de(e,t,n,r){const{pathAsArray:i=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return function({original:e,copy:t,assignedMap:n},r,i,o,s){n.forEach(((n,a)=>{const l=K(e,a),c=ie(K(t,a)),u=n?_(e,a)?A:P:C;if(G(l,c)&&u===A)return;const p=Q(r.concat(a),s);i.push(u===C?{op:u,path:p}:{op:u,path:p,value:c}),o.push(u===P?{op:C,path:p}:u===C?{op:P,path:p,value:l}:{op:A,path:p,value:l})}))}(e,t,n,r,i);case 1:return function(e,t,n,r,i){let{original:o,assignedMap:s,options:a}=e,l=e.copy;l.length<o.length&&([o,l]=[l,o],[n,r]=[r,n]);for(let e=0;e<o.length;e+=1)if(s.get(e.toString())&&l[e]!==o[e]){const s=Q(t.concat([e]),i);n.push({op:A,path:s,value:ie(l[e])}),r.push({op:A,path:s,value:ie(o[e])})}for(let e=o.length;e<l.length;e+=1){const r=Q(t.concat([e]),i);n.push({op:P,path:r,value:ie(l[e])})}if(o.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=Q(t.concat(["length"]),i);r.push({op:A,path:e,value:o.length})}else for(let e=l.length;o.length<e;e-=1){const n=Q(t.concat([e-1]),i);r.push({op:C,path:n})}}}(e,t,n,r,i);case 3:return function({original:e,copy:t},n,r,i,o){let s=0;e.forEach((e=>{if(!t.has(e)){const t=Q(n.concat([s]),o);r.push({op:C,path:t,value:e}),i.unshift({op:P,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=Q(n.concat([s]),o);r.push({op:P,path:e,value:t}),i.unshift({op:C,path:e,value:t})}s+=1}))}(e,t,n,r,i)}}const ye=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!B(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},ge={get size(){return F($(this)).size},has(e){return F($(this)).has(e)},set(e,t){const n=$(this),r=F(n);return r.has(e)&&G(r.get(e),t)||(ne(n),oe(n),n.assignedMap.set(e,!0),n.copy.set(e,t),he(n,e,t,de)),this},delete(e){if(!this.has(e))return!1;const t=$(this);return ne(t),oe(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=$(this);if(this.size){ne(e),oe(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){F($(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=$(this),i=F(r).get(e),o=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,i,I))===I.mutable;if(r.options.strict&&ye(i,r.options,o),o)return i;if(r.finalized||!B(i,r.options))return i;if(i!==r.original.get(e))return i;const s=N.createDraft({original:i,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return ne(r),r.copy.set(e,s),s},keys(){return F($(this)).keys()},values(){const e=this.keys();return{[D]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[D]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[D](){return this.entries()}},ve=Reflect.ownKeys(ge),me=(e,t,{isValuesIterator:n})=>()=>{var r,i;const o=t.next();if(o.done)return o;const s=o.value;let a=e.setMap.get(s);const l=$(a),c=(null===(i=(r=e.options).mark)||void 0===i?void 0:i.call(r,a,I))===I.mutable;if(e.options.strict&&ye(s,e.options,c),c||l||!B(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=N.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,t),a=t}return{done:!1,value:n?a:[a,a]}},be={get size(){return $(this).setMap.size},has(e){const t=$(this);if(t.setMap.has(e))return!0;ne(t);const n=$(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=$(this);return this.has(e)||(ne(t),oe(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),he(t,e,e,de)),this},delete(e){if(!this.has(e))return!1;const t=$(this);ne(t),oe(t);const n=$(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=$(this);ne(e),oe(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=$(this);ne(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:me(e,t,{isValuesIterator:!0})}},entries(){const e=$(this);ne(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:me(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[D](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(be,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const we=Reflect.ownKeys(be),Oe=new WeakSet,Me={get(e,t,n){var r,i;const o=null===(r=e.copy)||void 0===r?void 0:r[t];if(o&&Oe.has(o))return o;if(t===T)return e;let s;if(e.options.mark){const r="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(r,I),s===I.mutable)return e.options.strict&&ye(r,e.options,!0),r}const a=F(e);if(a instanceof Map&&ve.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ge,"size").get.call(e.proxy);const n=ge[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&we.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(be,"size").get.call(e.proxy);const n=be[t];if(n)return n.bind(e.proxy)}if(!_(a,t)){const n=L(a,t);return n?"value"in n?n.value:null===(i=n.get)||void 0===i?void 0:i.call(e.proxy):void 0}const l=a[t];if(e.options.strict&&ye(l,e.options),e.finalized||!B(l,e.options))return l;if(l===Z(e.original,t)){if(ne(e),e.copy[t]=Ee({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=$(e.copy[t]);return ne(n),oe(n),n.copy}return e.copy[t]}return l},set(e,t,n){var r;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");let i;if(1===e.type&&"length"!==t&&(!(Number.isInteger(i=Number(t))&&i>=0)||0!==t&&0!==i&&String(i)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");const o=L(F(e),t);if(null==o?void 0:o.set)return o.set.call(e.proxy,n),!0;const s=Z(F(e),t),a=$(s);return a&&G(a.original,n)?(e.copy[t]=n,e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.set(t,!1),!0):(G(n,s)&&(void 0!==n||_(e.original,t))||(ne(e),oe(e),_(e.original,t)&&G(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,he(e,t,n,de)),!0)},has:(e,t)=>t in F(e),ownKeys:e=>Reflect.ownKeys(F(e)),getOwnPropertyDescriptor(e,t){const n=F(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},getPrototypeOf:e=>Reflect.getPrototypeOf(e.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return 1===e.type?Me.set.call(this,e,t,void 0,e.proxy):(void 0!==Z(e.original,t)||t in e.original?(ne(e),oe(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function Ee(e){const{original:t,parentDraft:n,key:r,finalities:i,options:o}=e,s=X(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:i,options:o,setMap:3===s?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===s?Object.assign([],a):a,Me);if(i.revoke.push(c),Oe.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var i,o;const s=$(l);let a=3===e.type?e.setMap:e.copy;const c=K(a,r),u=$(c);if(u){let o=u.original;u.operated&&(o=H(c)),pe(u),fe(u,de,t,n),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(i=e.options.updatedValues)&&void 0!==i?i:new WeakMap,e.options.updatedValues.set(o,u.original)),Y(a,r,o)}null===(o=s.callbacks)||void 0===o||o.forEach((e=>{e(t,n)}))}))}else{const e=$(l);e.finalities.draft.push(((t,n)=>{pe(e),fe(e,de,t,n)}))}return l}function ke(e,t,n,r,i){var o;const s=$(e),a=null!==(o=null==s?void 0:s.original)&&void 0!==o?o:e,l=!!t.length;if(null==s?void 0:s.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);const c=l?t[0]:s?s.operated?s.copy:s.original:e;return s&&J(s),i&&ae(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:A,path:[],value:t[0]}]:n,r&&l?[{op:A,path:[],value:a}]:r]}function je(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:i=!0}=e;le(n,((n,r,i)=>{const o=$(r);if(o&&t&&o.finalities===t.finalities){e.isContainDraft=!0;const t=o.original;if(i instanceof Set){const e=Array.from(i);i.clear(),e.forEach((e=>i.add(n===e?t:e)))}else Y(i,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,je(e))})),i&&e.isContainDraft}function Se(e){var t;const n=$(e);if(!B(e,null==n?void 0:n.options))return e;const r=X(e);if(n&&!n.operated)return n.original;let i;function o(){i=2===r?V(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):te(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{o()}finally{n.finalized=!1}}else i=e;if(le(i,((t,r)=>{if(n&&G(K(n.original,t),r))return;const s=Se(r);s!==r&&(i===e&&o(),Y(i,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:i;return U(e)?new Set(i):new(Object.getPrototypeOf(e).constructor)(i)}return i}function Re(e){if(!q(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return Se(e)}N.createDraft=Ee;const xe=function e(t,n,r){var i,o,s;if("function"==typeof t&&"function"!=typeof n)return function(r,...i){return e(r,(e=>t.call(this,e,...i)),n)};const a=t,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},void 0),c);const u=q(a)?Re(a):a,p=Array.isArray(c.mark)?(e,t)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(e,t);if(r)return r}}:c.mark,f=null!==(i=c.enablePatches)&&void 0!==i&&i,h=null!==(o=c.strict)&&void 0!==o&&o,d={enableAutoFreeze:null!==(s=c.enableAutoFreeze)&&void 0!==s&&s,mark:p,strict:h,enablePatches:f};if(!B(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[y,g]=function(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let i,o;t.enablePatches&&(i=[],o=[]);const s=(null===(n=t.mark)||void 0===n?void 0:n.call(t,e,I))!==I.mutable&&B(e,t)?Ee({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=ke(s,e,i,o,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!B(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[y,g]}let v;try{v=l(y)}catch(e){throw J($(y)),e}const m=e=>{const t=$(y);if(!q(e)){if(void 0!==e&&!G(e,y)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==e?void 0:e[z];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&je({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&je({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=$(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([Re(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw J($(y)),e})):m(v)};function Ce(e,t){e.set(xe(e.get(),t))}Object.prototype.constructor.toString();class Ae{constructor(e,t=null){this.value=e,this.reactor=t??new R(this,[])}produce(e){return Ce(this,e)}reducer(...e){let t;return t=1===e.length?new x(this,"",e[0]):new x(this,e[0],e[1]),t.trigger.bind(t)}setObjectByPath(e="",t){if(0===e.length)return void(this.value=t);if("string"!=typeof e||!e)throw new Error("Invalid path");let n=e.split("."),r=this.value;for(let e=0;e<n.length-1;e++){let t=n[e];t in r||(r[t]={}),r=r[t]}r[n[n.length-1]]=t}set(...e){if(1===e.length)this.value=e[0];else{let t=e[0],n=e[1];this.setObjectByPath(t,n)}this.reactor.react()}get(){return this.value}}function Pe(e){return new Ae(e)}function Te(e){return e instanceof Ae}function ze(e,t){e.reactor.addBinding(t)}function De(e,t){e.reactor.removeBinding(t)}class Ie{constructor(e){this.target=e}set html(e){this.target.innerHTML=e}query(e){return this.target.querySelectorAll(e)}set text(e){this.target.textContent=e}on(e,t){this.target.addEventListener(e,t)}off(e,t){this.target.removeEventListener(e,t)}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}function Ne(e){return new Ie(e)}class _e{constructor(e){this.target=e}query(e){return this.target.querySelectorAll(e)}index(e){return Array.from(this.target.children)[e]}list(){return Array.from(this.target.children)}get parent(){return this.target}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}function Le(e){return new _e(e)}class Ue{constructor(e){this.target=e}set(e){this.target=e.forwardRefs}}function Ve(e){return new Ue(e)}window.RUMIOUS_CONTEXTS||(window.RUMIOUS_CONTEXTS={});class Fe{constructor(e={}){this.data=e,this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter((e=>e!==t)))}emit(e,...t){this.events[e]&&this.events[e].forEach((e=>e(...t)))}set(e,t){let n=Pe(t);return this.data[e]=n,n}get(e){return this.data[e]}}function qe(e="",t={}){if(!t||"object"!=typeof t)throw"Rumious context: Initial value must be object !";return window.RUMIOUS_CONTEXTS[e]||(window.RUMIOUS_CONTEXTS[e]=new Fe(t)),window.RUMIOUS_CONTEXTS[e]}class $e extends t{static tag="r-pending";constructor(){super(),this.asynchronousRender=!0}async setLoader(e){this.loader=e;try{this.result=await this.loader.execute(),this.renderResult()}catch(e){this.error=e,this.renderError()}}renderResult(){if(!this.result)throw"Rumious Render: Cannot find component when lazy loading!";this.element.before(this.render(h(this.result,{}))),this.element.remove()}renderError(){this.element.appendChild(this.render(this.props.errorComponent??this.error))}onRender(){let{loader:e}=this.props;this.setLoader(e)}template(){return this.props.fallback}}class He{constructor(e,t={}){this.hasExecuted=!1,this.result=null,this.callback=e,this.dependents=[],this.options=t}onLoad(e){this.hasExecuted?e(this.result):this.dependents.push(e)}execute(){return new Promise(((e,t)=>{if(this.hasExecuted)return e(this.result);this.hasExecuted=!0;const n=async()=>{try{this.result=await this.callback(),e(this.result),this.dependents.forEach((e=>e(this.result)))}catch(e){t(e)}};this.options.idle&&"requestIdleCallback"in window?requestIdleCallback(n):n()}))}}const Be=new Map;function We(e,t={}){const n=t.key||e.toString();return Be.has(n)||Be.set(n,new He(e,t)),Be.get(n)}function Xe(e,t){let n=0;return function(...r){const i=Date.now();i-n>=t&&(n=i,e.apply(this,r))}}function Ke(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}}function Ye(e,t){let n=0,r=null,i=null;function o(){n=Date.now(),e.apply(this,r),r=null}return function(...e){const s=Date.now();r=e,s-n>=t?o():i||(i=setTimeout((()=>{i=null,o()}),t-(s-n)))}}function Ze(e,t){let n,r=!0;return function(...i){r&&(e.apply(this,i),r=!1),clearTimeout(n),n=setTimeout((()=>{e.apply(this,i),r=!0}),t)}}function Ge(e){let t=!1;return function(...n){t||(t=!0,requestAnimationFrame((()=>{e.apply(this,n),t=!1})))}}export{$e as Pending,j as RumiousApp,_e as RumiousChildrensRef,t as RumiousComponent,m as RumiousComponentElement,Ue as RumiousComponentRef,Fe as RumiousContext,w as RumiousDymanicInjector,Ie as RumiousElementRef,He as RumiousLazyLoader,R as RumiousReactor,x as RumiousReducer,Ae as RumiousState,Le as createChildrensRef,y as createComponent,b as createComponentElement,Ve as createComponentRef,qe as createContext,f as createDirective,h as createElement,Ne as createElementRef,Pe as createState,d as createTextElement,Ke as denounce,O as injectHTML,M as injectText,n as isComponent,Te as isState,We as lazyLoad,Ze as leadingTrailingDebounce,Ce as produceState,Ge as rafThrottle,S as styleHelper,Xe as tholle,Ye as trailingThrottle,De as unwatch,ze as watch};
package/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- var Rumious=function(e){"use strict";class t{constructor(e){this.target=e,this.app=e.app,this.hooks={onRendered:[],onBeforeRender:[]}}find(e){return this.target[e]}get(e){return this.target[e]}addHook(e,t){if(!this.hooks[e])throw new Error(`Hook type "${e}" is not defined!`);this.hooks[e].push(t)}async runHooks(e,...t){if(this.hooks[e])for(const n of this.hooks[e])await n(...t)}}class n{constructor(){this.asynchronousRender=!1,this.element=null,this.app=null,this.props={},this.forwardRefs={},this.renderContext=new t(this),this.renderer=null,this.wrapped=null}prepare(e,t,n={},r=null){this.element=e,this.props=t,this.renderer=r,this.wrapped=n,this.renderContext.app=this.app}template(){return{}}render(e){return this.renderer(e,document.createDocumentFragment(),this.renderContext)}requestRender(){let e=this.template(),t=this.renderer(e,document.createDocumentFragment(),this.renderContext);this.element.appendChild(t),this.onRender()}async requestCleanUp(){if(this.element){let e=this.element.cloneNode(!0);for(this.element.replaceWith(e),this.element=e;this.element.firstChild;)this.element.removeChild(this.element.firstChild)}}onInit(){}onCreate(){}onRender(){}onUpdate(){}onDestroy(){}}function r(e){return Object.getPrototypeOf(e)===n}class o{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class i{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function s(e){return"function"==typeof e}class a{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class l extends a{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!s(n))throw new Error(`${e} is not a function!`);return n.bind(t.target)};if("string"===this.value.type)n=r(this.value.value);else if("expression"===this.value.type){if(n=this.value.value,!s(n))throw new Error("Event handler requires a function!")}else"dynamic_value"===this.value.type&&(n=r(this.value.value.objectName));n&&e.addEventListener(this.name,n)}}class c extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");t.reactor.addBinding((()=>{let n=t.get();this.bindAttr(e,n)})),this.bindAttr(e,t.get())}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target),r=t.find(this.value.value.objectName);if(!r)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");r.reactor.addBinding((()=>{let n=this.value.evaluator?.(t.target);this.bindAttr(e,n)})),this.bindAttr(e,n)}}normalizeValue(e){return"object"==typeof e?e.toString?.()??"":e}async bindAttr(e,t){switch(this.name){case"html":e.innerHTML=this.normalizeValue(t);break;case"text":e.textContent=this.normalizeValue(t);break;case"show":e.style.display=this.normalizeValue(t)?"block":"none";break;case"hide":e.style.display=this.normalizeValue(t)?"none":"block";break;case"className":e.className=this.normalizeValue(t);break;case"style":Object.assign(e.style,t);break;case"disabled":e.disabled=!!this.normalizeValue(t);break;case"visible":e.style.visibility=this.normalizeValue(t)?"visible":"hidden";break;default:e.setAttribute(this.name,this.normalizeValue(t))}}}class u extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");n.set(e)}}}class p extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");n.set(e)}}}const f={on:(e,t)=>new l("on",e,t),bind:(e,t)=>new c("bind",e,t),ref:(e,t)=>new u("ref",e,t),childsRef:(e,t)=>new p("childsRef",e,t)};function h(e,t,n){return function(e,t,n){return f[e]?.(t,n)}(e,t,n)}function d(e,t,...n){return r(e)?g(e,t,n):e===v?v(...n):new o(e,t||{},m(n))}function y(e){return new o("TEXT_ELEMENT",{nodeValue:e},[])}function g(e,t,n){let r=new o("COMPONENT",{...t},new i(m(n)));return r.component=e,r}function v(...e){return new o("FRAGMENT",{},m(e))}function m(e){return e.map((e=>"object"==typeof e?e:y(e)))}window.RUMIOUS_JSX_SUPPORT={createElement:d,createFragment:v,createDirective:h};class b extends HTMLElement{constructor(){super(),this.instance=null,this.ref=null}cleanUp(){Object.setPrototypeOf(this,HTMLUnknownElement.prototype),this.remove()}init(e,t,n={},r,o){this.instance=new e,this.instance.element=this,this.instance.app=o,this.instance.prepare(this,t,n,r),this.instance.onInit()}connectedCallback(){this.instance.asynchronousRender?(async()=>{this.instance.onCreate(),this.instance.requestRender()})():(this.instance.onCreate(),this.instance.requestRender())}disconnectedCallback(){this.instance.onDestroy(),this.instance.requestCleanUp(),this.cleanUp()}}function w(e="r-component"){return window.customElements.get(e)||window.customElements.define(e,class extends b{static tag=e}),document.createElement(e)}class O{constructor(){this.contents=[],this.targets=[],this.observers=new WeakMap}commit(e=[]){this.contents=e}setTarget(e,t,n){this.targets.push({element:e,context:n,renderer:t}),this.observeTarget(e)}observeTarget(e){if(this.observers.has(e))return;const t=new MutationObserver((()=>{e.parentNode||this.removeTarget(e)}));t.observe(e,{childList:!1,subtree:!1}),this.observers.set(e,t)}removeTarget(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e)),this.targets=this.targets.filter((t=>t.element!==e))}inject(e=!1){for(let t of this.targets)e&&(t.element.textContent=""),this.contents.forEach((e=>{"html"===e.type?t.element.innerHTML=e.value:"text"===e.type?t.element.textContent=e.value:"component"===e.type&&t.renderer(d(e.value,e.props??{},e.child??{}),t.element,t.context)}))}}function E(e,t,n){for(const[r,o]of Object.entries(t||{}))o instanceof a?o.init(e,n):r.startsWith("on")&&/^[a-zA-Z]+([A-Z][a-z]*)*$/.test(r)?e.addEventListener(r.substring(2).toLowerCase(),o):e.setAttribute(r,o)}function M(e,t,n={}){if(!e)return t;if(null===(r=e)||"object"!=typeof r&&"function"!=typeof r)return M(y(e),t,n);var r;if(Array.isArray(e)){for(const r of e)M(r,t,n);return t}if(e instanceof o){let r;switch(e.type){case"COMPONENT":return function(e,t,n,r){const o=function(e,t,n,r,o=null){const i=w(e.tag??"r-component");return i.init(e,t,n,r,o?.app),i}(e.component,e.props,e.children,n,r);return E(o,e.props,r),t.appendChild(o),t}(e,t,M,n);case"FRAGMENT":case"ELEMENT_LIST":for(const r of e.children)M(r,t,n);return t;case"TEXT_ELEMENT":r=function(e){return document.createTextNode(e.props.nodeValue)}(e);break;default:r=function(e,t){const n=document.createElement(e.type);E(n,e.props,t);for(const r of e.children)M(r,n,t);return n}(e,n)}return t.appendChild(r),t}if(e instanceof HTMLElement)return t.appendChild(e),t;if(e instanceof O){if(t instanceof HTMLDocument)throw"Rumious Render: Unsupported inject content in HTMLDocument!";return e.setTarget(t,M,n),e.inject(!0),t}return M(y(JSON.stringify(e)),t,n)}class k{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}removeBinding(e){for(let t=this.bindings.length-1;t>=0;t--)this.bindings[t]===e&&this.bindings.splice(t,1)}addBinding(e){this.bindings.push(e)}}class R{constructor(e,t="",n){this.state=e,this.path=t,this.fn=n}trigger(...e){let t=this.fn(...e);this.state.set(this.path,t)}}const j="remove",S="replace",x="add",C=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),T=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),A=Symbol.iterator,P={mutable:"mutable",immutable:"immutable"},z={};function D(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function I(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const e=Reflect.getOwnPropertyDescriptor(n,t);if(e)return e;n=Reflect.getPrototypeOf(n)}}}function L(e){return Object.getPrototypeOf(e)===Set.prototype}function N(e){return Object.getPrototypeOf(e)===Map.prototype}function _(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function U(e){return!!V(e)}function V(e){return"object"!=typeof e?null:null==e?void 0:e[C]}function F(e){var t;const n=V(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function q(e,t){if(!e||"object"!=typeof e)return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((n=t.mark(e,P))===P.immutable||"function"==typeof n)}function H(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=V(B(n,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;const o=3===e.parent.type,i=o?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(o&&n.size>i||D(n,i)))return null;t.push(i)}if(e.parent)return H(e.parent,t);t.reverse();try{!function(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if("object"!=typeof(e=B(3===$(e)?Array.from(e):e,r)))throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}}(e.copy,t)}catch(e){return null}return t}function $(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function B(e,t){return 2===$(e)?e.get(t):e[t]}function W(e,t,n){2===$(e)?e.set(t,n):e[t]=n}function X(e,t){const n=V(e);return(n?_(n):e)[t]}function K(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function Y(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Z(e,t){return t?e:[""].concat(e).map((e=>{const t=`${e}`;return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const G=Object.prototype.propertyIsEnumerable;function J(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return L(e)?Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values()):new(0,Object.getPrototypeOf(e).constructor)(e.values());if(e instanceof Map)return N(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,P),void 0!==n)&&n!==P.mutable){if(n===P.immutable)return function(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);r.enumerable&&r.configurable&&r.writable?t[n]=e[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r))})),t}(e);if("function"==typeof n){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){const t={};return Object.keys(e).forEach((n=>{t[n]=e[n]})),Object.getOwnPropertySymbols(e).forEach((n=>{G.call(e,n)&&(t[n]=e[n])})),t}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(e){e.copy||(e.copy=J(e.original,e.options))}function ee(e){if(!q(e))return F(e);if(Array.isArray(e))return e.map(ee);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,ee(t)]));return N(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(ee);return L(e)?new Set(t):new(0,Object.getPrototypeOf(e).constructor)(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=ee(e[n]);return t}function te(e){return U(e)?ee(e):e}function ne(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&ne(e.parent))}function re(){throw new Error("Cannot modify frozen object")}function oe(e,t,n,r,o){{n=null!=n?n:new WeakMap,r=null!=r?r:[],o=null!=o?o:[];const i=n.has(e)?n.get(e):e;if(r.length>0){const e=r.indexOf(i);if(i&&"object"==typeof i&&-1!==e){if(r[0]===i)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${o.slice(0,e).map(((e,t)=>{if("symbol"==typeof e)return`[${e.toString()}]`;const n=r[t];return"object"==typeof e&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(e):e})).join("/")}`)}r.push(i),o.push(t)}else r.push(i)}if(Object.isFrozen(e)||U(e))return r.pop(),void o.pop();switch($(e)){case 2:for(const[t,i]of e)oe(t,t,n,r,o),oe(i,t,n,r,o);e.set=e.clear=e.delete=re;break;case 3:for(const t of e)oe(t,t,n,r,o);e.add=e.clear=e.delete=re;break;case 1:Object.freeze(e);let t=0;for(const i of e)oe(i,t,n,r,o),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{oe(e[t],t,n,r,o)}))}r.pop(),o.pop()}function ie(e,t){const n=$(e);if(0===n)Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)}));else if(1===n){let n=0;for(const r of e)t(n,r,e),n+=1}else e.forEach(((n,r)=>t(r,n,e)))}function se(e,t,n){if(U(e)||!q(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,o=r?new Map:void 0;if(t.add(e),ie(e,((i,s)=>{var a;if(U(s)){const t=V(s);Q(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;W(r?o:e,i,n)}else se(s,t,n)})),o){const t=e,n=Array.from(t);t.clear(),n.forEach((e=>{t.add(o.has(e)?o.get(e):e)}))}}function ae(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&se(B(n,t),e.finalities.handledSet,e.options)}function le(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(F(t))})))}function ce(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=H(e);o&&t(e,o,n,r)}e.finalized=!0}}function ue(e,t,n,r){const o=V(n);o&&(o.callbacks||(o.callbacks=[]),o.callbacks.push(((i,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(K(B(l,t),n)){let n=o.original;o.copy&&(n=o.copy),le(e),ce(e,r,i,s),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(a=e.options.updatedValues)&&void 0!==a?a:new WeakMap,e.options.updatedValues.set(n,o.original)),W(l,t,n)}})),e.options.enableAutoFreeze&&o.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),q(n,e.options)&&e.finalities.draft.push((()=>{K(B(3===e.type?e.setMap:e.copy,t),n)&&ae(e,t)}))}function pe(e,t,n,r){const{pathAsArray:o=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return function({original:e,copy:t,assignedMap:n},r,o,i,s){n.forEach(((n,a)=>{const l=B(e,a),c=te(B(t,a)),u=n?D(e,a)?S:x:j;if(K(l,c)&&u===S)return;const p=Z(r.concat(a),s);o.push(u===j?{op:u,path:p}:{op:u,path:p,value:c}),i.push(u===x?{op:j,path:p}:u===j?{op:x,path:p,value:l}:{op:S,path:p,value:l})}))}(e,t,n,r,o);case 1:return function(e,t,n,r,o){let{original:i,assignedMap:s,options:a}=e,l=e.copy;l.length<i.length&&([i,l]=[l,i],[n,r]=[r,n]);for(let e=0;e<i.length;e+=1)if(s.get(e.toString())&&l[e]!==i[e]){const s=Z(t.concat([e]),o);n.push({op:S,path:s,value:te(l[e])}),r.push({op:S,path:s,value:te(i[e])})}for(let e=i.length;e<l.length;e+=1){const r=Z(t.concat([e]),o);n.push({op:x,path:r,value:te(l[e])})}if(i.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=Z(t.concat(["length"]),o);r.push({op:S,path:e,value:i.length})}else for(let e=l.length;i.length<e;e-=1){const n=Z(t.concat([e-1]),o);r.push({op:j,path:n})}}}(e,t,n,r,o);case 3:return function({original:e,copy:t},n,r,o,i){let s=0;e.forEach((e=>{if(!t.has(e)){const t=Z(n.concat([s]),i);r.push({op:j,path:t,value:e}),o.unshift({op:x,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=Z(n.concat([s]),i);r.push({op:x,path:e,value:t}),o.unshift({op:j,path:e,value:t})}s+=1}))}(e,t,n,r,o)}}const fe=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!q(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},he={get size(){return _(V(this)).size},has(e){return _(V(this)).has(e)},set(e,t){const n=V(this),r=_(n);return r.has(e)&&K(r.get(e),t)||(Q(n),ne(n),n.assignedMap.set(e,!0),n.copy.set(e,t),ue(n,e,t,pe)),this},delete(e){if(!this.has(e))return!1;const t=V(this);return Q(t),ne(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=V(this);if(this.size){Q(e),ne(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){_(V(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=V(this),o=_(r).get(e),i=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,o,P))===P.mutable;if(r.options.strict&&fe(o,r.options,i),i)return o;if(r.finalized||!q(o,r.options))return o;if(o!==r.original.get(e))return o;const s=z.createDraft({original:o,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return Q(r),r.copy.set(e,s),s},keys(){return _(V(this)).keys()},values(){const e=this.keys();return{[A]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[A]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[A](){return this.entries()}},de=Reflect.ownKeys(he),ye=(e,t,{isValuesIterator:n})=>()=>{var r,o;const i=t.next();if(i.done)return i;const s=i.value;let a=e.setMap.get(s);const l=V(a),c=(null===(o=(r=e.options).mark)||void 0===o?void 0:o.call(r,a,P))===P.mutable;if(e.options.strict&&fe(s,e.options,c),c||l||!q(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=z.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,t),a=t}return{done:!1,value:n?a:[a,a]}},ge={get size(){return V(this).setMap.size},has(e){const t=V(this);if(t.setMap.has(e))return!0;Q(t);const n=V(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=V(this);return this.has(e)||(Q(t),ne(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),ue(t,e,e,pe)),this},delete(e){if(!this.has(e))return!1;const t=V(this);Q(t),ne(t);const n=V(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=V(this);Q(e),ne(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=V(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ye(e,t,{isValuesIterator:!0})}},entries(){const e=V(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ye(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[A](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(ge,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const ve=Reflect.ownKeys(ge),me=new WeakSet,be={get(e,t,n){var r,o;const i=null===(r=e.copy)||void 0===r?void 0:r[t];if(i&&me.has(i))return i;if(t===C)return e;let s;if(e.options.mark){const r="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(r,P),s===P.mutable)return e.options.strict&&fe(r,e.options,!0),r}const a=_(e);if(a instanceof Map&&de.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(he,"size").get.call(e.proxy);const n=he[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&ve.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ge,"size").get.call(e.proxy);const n=ge[t];if(n)return n.bind(e.proxy)}if(!D(a,t)){const n=I(a,t);return n?"value"in n?n.value:null===(o=n.get)||void 0===o?void 0:o.call(e.proxy):void 0}const l=a[t];if(e.options.strict&&fe(l,e.options),e.finalized||!q(l,e.options))return l;if(l===X(e.original,t)){if(Q(e),e.copy[t]=we({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=V(e.copy[t]);return Q(n),ne(n),n.copy}return e.copy[t]}return l},set(e,t,n){var r;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");let o;if(1===e.type&&"length"!==t&&(!(Number.isInteger(o=Number(t))&&o>=0)||0!==t&&0!==o&&String(o)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");const i=I(_(e),t);if(null==i?void 0:i.set)return i.set.call(e.proxy,n),!0;const s=X(_(e),t),a=V(s);return a&&K(a.original,n)?(e.copy[t]=n,e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.set(t,!1),!0):(K(n,s)&&(void 0!==n||D(e.original,t))||(Q(e),ne(e),D(e.original,t)&&K(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,ue(e,t,n,pe)),!0)},has:(e,t)=>t in _(e),ownKeys:e=>Reflect.ownKeys(_(e)),getOwnPropertyDescriptor(e,t){const n=_(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},getPrototypeOf:e=>Reflect.getPrototypeOf(e.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return 1===e.type?be.set.call(this,e,t,void 0,e.proxy):(void 0!==X(e.original,t)||t in e.original?(Q(e),ne(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function we(e){const{original:t,parentDraft:n,key:r,finalities:o,options:i}=e,s=$(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:o,options:i,setMap:3===s?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===s?Object.assign([],a):a,be);if(o.revoke.push(c),me.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var o,i;const s=V(l);let a=3===e.type?e.setMap:e.copy;const c=B(a,r),u=V(c);if(u){let i=u.original;u.operated&&(i=F(c)),le(u),ce(u,pe,t,n),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(o=e.options.updatedValues)&&void 0!==o?o:new WeakMap,e.options.updatedValues.set(i,u.original)),W(a,r,i)}null===(i=s.callbacks)||void 0===i||i.forEach((e=>{e(t,n)}))}))}else{const e=V(l);e.finalities.draft.push(((t,n)=>{le(e),ce(e,pe,t,n)}))}return l}function Oe(e,t,n,r,o){var i;const s=V(e),a=null!==(i=null==s?void 0:s.original)&&void 0!==i?i:e,l=!!t.length;if(null==s?void 0:s.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);const c=l?t[0]:s?s.operated?s.copy:s.original:e;return s&&Y(s),o&&oe(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:S,path:[],value:t[0]}]:n,r&&l?[{op:S,path:[],value:a}]:r]}function Ee(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:o=!0}=e;ie(n,((n,r,o)=>{const i=V(r);if(i&&t&&i.finalities===t.finalities){e.isContainDraft=!0;const t=i.original;if(o instanceof Set){const e=Array.from(o);o.clear(),e.forEach((e=>o.add(n===e?t:e)))}else W(o,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,Ee(e))})),o&&e.isContainDraft}function Me(e){var t;const n=V(e);if(!q(e,null==n?void 0:n.options))return e;const r=$(e);if(n&&!n.operated)return n.original;let o;function i(){o=2===r?N(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):J(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{i()}finally{n.finalized=!1}}else o=e;if(ie(o,((t,r)=>{if(n&&K(B(n.original,t),r))return;const s=Me(r);s!==r&&(o===e&&i(),W(o,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:o;return L(e)?new Set(o):new(Object.getPrototypeOf(e).constructor)(o)}return o}function ke(e){if(!U(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return Me(e)}z.createDraft=we;const Re=function e(t,n,r){var o,i,s;if("function"==typeof t&&"function"!=typeof n)return function(r,...o){return e(r,(e=>t.call(this,e,...o)),n)};const a=t,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},void 0),c);const u=U(a)?ke(a):a,p=Array.isArray(c.mark)?(e,t)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(e,t);if(r)return r}}:c.mark,f=null!==(o=c.enablePatches)&&void 0!==o&&o,h=null!==(i=c.strict)&&void 0!==i&&i,d={enableAutoFreeze:null!==(s=c.enableAutoFreeze)&&void 0!==s&&s,mark:p,strict:h,enablePatches:f};if(!q(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[y,g]=function(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let o,i;t.enablePatches&&(o=[],i=[]);const s=(null===(n=t.mark)||void 0===n?void 0:n.call(t,e,P))!==P.mutable&&q(e,t)?we({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=Oe(s,e,o,i,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!q(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[y,g]}let v;try{v=l(y)}catch(e){throw Y(V(y)),e}const m=e=>{const t=V(y);if(!U(e)){if(void 0!==e&&!K(e,y)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==e?void 0:e[T];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&Ee({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&Ee({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=V(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([ke(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw Y(V(y)),e})):m(v)};function je(e,t){e.set(Re(e.get(),t))}Object.prototype.constructor.toString();class Se{constructor(e,t=null){this.value=e,this.reactor=t??new k(this,[])}produce(e){return je(this,e)}reducer(...e){let t;return t=1===e.length?new R(this,"",e[0]):new R(this,e[0],e[1]),t.trigger.bind(t)}setObjectByPath(e="",t){if(0===e.length)return void(this.value=t);if("string"!=typeof e||!e)throw new Error("Invalid path");let n=e.split("."),r=this.value;for(let e=0;e<n.length-1;e++){let t=n[e];t in r||(r[t]={}),r=r[t]}r[n[n.length-1]]=t}set(...e){if(1===e.length)this.value=e[0];else{let t=e[0],n=e[1];this.setObjectByPath(t,n)}this.reactor.react()}get(){return this.value}}function xe(e){return new Se(e)}class Ce{constructor(e){this.target=e}set html(e){this.target.innerHTML=e}query(e){return this.target.querySelectorAll(e)}set text(e){this.target.textContent=e}on(e,t){this.target.addEventListener(e,t)}off(e,t){this.target.removeEventListener(e,t)}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Te{constructor(e){this.target=e}query(e){return this.target.querySelectorAll(e)}index(e){return Array.from(this.target.children)[e]}list(){return Array.from(this.target.children)}get parent(){return this.target}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Ae{constructor(e){this.target=e}set(e){this.target=e.forwardRefs}}window.RUMIOUS_CONTEXTS||(window.RUMIOUS_CONTEXTS={});class Pe{constructor(e={}){this.data=e,this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter((e=>e!==t)))}emit(e,...t){this.events[e]&&this.events[e].forEach((e=>e(...t)))}set(e,t){let n=xe(t);return this.data[e]=n,n}get(e){return this.data[e]}}class ze{constructor(e,t={}){this.hasExecuted=!1,this.result=null,this.callback=e,this.dependents=[],this.options=t}onLoad(e){this.hasExecuted?e(this.result):this.dependents.push(e)}execute(){return new Promise(((e,t)=>{if(this.hasExecuted)return e(this.result);this.hasExecuted=!0;const n=async()=>{try{this.result=await this.callback(),e(this.result),this.dependents.forEach((e=>e(this.result)))}catch(e){t(e)}};this.options.idle&&"requestIdleCallback"in window?requestIdleCallback(n):n()}))}}const De=new Map;return e.Pending=class extends n{static tag="r-pending";constructor(){super(),this.asynchronousRender=!0}async setLoader(e){this.loader=e;try{this.result=await this.loader.execute(),this.renderResult()}catch(e){this.error=e,this.renderError()}}renderResult(){if(!this.result)throw"Rumious Render: Cannot find component when lazy loading!";this.element.before(this.render(d(this.result,{}))),this.element.remove()}renderError(){this.element.appendChild(this.render(this.props.errorComponent??this.error))}onRender(){let{loader:e}=this.props;this.setLoader(e)}template(){return this.props.fallback}},e.RumiousApp=class{constructor(e=document.createElement("span"),n={}){this.root=e,this.app=this,this.modules=[],this.configs=n,this.renderContext=new t(this)}render(e){this.renderContext.runHooks("onBeforeRender",this.renderContext),M(e,this.root,this.renderContext),this.renderContext.runHooks("onRendered",this.renderContext)}addModule(e,t={}){return e.init(this,t)}},e.RumiousChildrensRef=Te,e.RumiousComponent=n,e.RumiousComponentElement=b,e.RumiousComponentRef=Ae,e.RumiousContext=Pe,e.RumiousDymanicInjector=O,e.RumiousElementRef=Ce,e.RumiousLazyLoader=ze,e.RumiousReactor=k,e.RumiousReducer=R,e.RumiousState=Se,e.createChildrensRef=function(e){return new Te(e)},e.createComponent=g,e.createComponentElement=w,e.createComponentRef=function(e){return new Ae(e)},e.createContext=function(e="",t={}){if(!t||"object"!=typeof t)throw"Rumious context: Initial value must be object !";return window.RUMIOUS_CONTEXTS[e]||(window.RUMIOUS_CONTEXTS[e]=new Pe(t)),window.RUMIOUS_CONTEXTS[e]},e.createDirective=h,e.createElement=d,e.createElementRef=function(e){return new Ce(e)},e.createState=xe,e.createTextElement=y,e.denounce=function(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},e.injectHTML=function(e){let t=new O;return t.commit([{type:"html",value:e}]),t},e.injectText=function(e){let t=new O;return t.commit([{type:"text",value:e}]),t},e.isComponent=r,e.isState=function(e){return e instanceof Se},e.lazyLoad=function(e,t={}){const n=t.key||e.toString();return De.has(n)||De.set(n,new ze(e,t)),De.get(n)},e.leadingTrailingDebounce=function(e,t){let n,r=!0;return function(...o){r&&(e.apply(this,o),r=!1),clearTimeout(n),n=setTimeout((()=>{e.apply(this,o),r=!0}),t)}},e.produceState=je,e.rafThrottle=function(e){let t=!1;return function(...n){t||(t=!0,requestAnimationFrame((()=>{e.apply(this,n),t=!1})))}},e.styleHelper=function(e){let t="";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){t+=`${n} {`;const r=e[n];for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t+=`${e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}: ${r[e]};`);t+="} "}return t.trim()},e.tholle=function(e,t){let n=0;return function(...r){const o=Date.now();o-n>=t&&(n=o,e.apply(this,r))}},e.trailingThrottle=function(e,t){let n=0,r=null,o=null;function i(){n=Date.now(),e.apply(this,r),r=null}return function(...e){const s=Date.now();r=e,s-n>=t?i():o||(o=setTimeout((()=>{o=null,i()}),t-(s-n)))}},e.unwatch=function(e,t){e.reactor.removeBinding(t)},e.watch=function(e,t){e.reactor.addBinding(t)},e}({});
1
+ var Rumious=function(e){"use strict";class t{constructor(e){this.target=e,this.app=e.app,this.hooks={onRendered:[],onBeforeRender:[]}}find(e){return this.target[e]}get(e){return this.target[e]}addHook(e,t){if(!this.hooks[e])throw new Error(`Hook type "${e}" is not defined!`);this.hooks[e].push(t)}async runHooks(e,...t){if(this.hooks[e])for(const n of this.hooks[e])await n(...t)}}class n{constructor(){this.asynchronousRender=!1,this.element=null,this.app=null,this.props={},this.forwardRefs={},this.renderContext=new t(this),this.renderer=null,this.wrapped=null}prepare(e,t,n={},r=null){this.element=e,this.props=t,this.renderer=r,this.wrapped=n,this.renderContext.app=this.app}template(){return{}}render(e){return this.renderer(e,document.createDocumentFragment(),this.renderContext)}requestRender(){let e=this.template(),t=this.renderer(e,document.createDocumentFragment(),this.renderContext);this.element.appendChild(t),this.onRender()}async requestCleanUp(){if(this.element){let e=this.element.cloneNode(!0);for(this.element.replaceWith(e),this.element=e;this.element.firstChild;)this.element.removeChild(this.element.firstChild)}}onInit(){}onCreate(){}onRender(){}onUpdate(){}onDestroy(){}}function r(e){return Object.getPrototypeOf(e)===n}class o{constructor(e,t,n=[]){this.type=e,this.props=t,this.children=n}}class i{constructor(e){this.type="ELEMENT_LIST",this.children=e}forEach(e){this.children.forEach(e)}}function s(e){return"function"==typeof e}class a{constructor(e,t,n){this.type=e,this.name=t,this.value=n}init(){}}class l extends a{async init(e,t){let n=null;const r=e=>{if(!t.find(e))return null;const n=t.get(e);if(!s(n))throw new Error(`${e} is not a function!`);return n.bind(t.target)};if("string"===this.value.type)n=r(this.value.value);else if("expression"===this.value.type){if(n=this.value.value,!s(n))throw new Error("Event handler requires a function!")}else"dynamic_value"===this.value.type&&(n=r(this.value.value.objectName));n&&e.addEventListener(this.name,n)}}class c extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");t.reactor.addBinding((()=>{let n=t.get();this.bindAttr(e,n)})),this.bindAttr(e,t.get())}else if("dynamic_value"===this.value.type){let n=this.value.evaluator?.(t.target),r=t.find(this.value.value.objectName);if(!r)throw new Error("Invalid props value: Directive bind requires a RumiousState Object!");r.reactor.addBinding((()=>{let n=this.value.evaluator?.(t.target);this.bindAttr(e,n)})),this.bindAttr(e,n)}}normalizeValue(e){return"object"==typeof e?e.toString?.()??"":e}async bindAttr(e,t){switch(this.name){case"html":e.innerHTML=this.normalizeValue(t);break;case"text":e.textContent=this.normalizeValue(t);break;case"show":e.style.display=this.normalizeValue(t)?"block":"none";break;case"hide":e.style.display=this.normalizeValue(t)?"none":"block";break;case"className":e.className=this.normalizeValue(t);break;case"style":Object.assign(e.style,t);break;case"disabled":e.disabled=!!this.normalizeValue(t);break;case"visible":e.style.visibility=this.normalizeValue(t)?"visible":"hidden";break;default:e.setAttribute(this.name,this.normalizeValue(t))}}}class u extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive ref requires a RumiousRef Object!");n.set(e)}}}class p extends a{async init(e,t){if("expression"===this.value.type){let t=this.value.value;if(!t)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");t.set(e)}else if("dynamic_value"===this.value.type){let n=t.find(this.value.value.objectName);if(!n)throw new Error("Invalid props value: Directive childsRef requires a RumiousChildRef Object!");n.set(e)}}}const f={on:(e,t)=>new l("on",e,t),bind:(e,t)=>new c("bind",e,t),ref:(e,t)=>new u("ref",e,t),childsRef:(e,t)=>new p("childsRef",e,t)};function h(e,t,n){return function(e,t,n){return f[e]?.(t,n)}(e,t,n)}function d(e,t,...n){return r(e)?g(e,t,n):e===v?v(...n):new o(e,t||{},m(n))}function y(e){return new o("TEXT_ELEMENT",{nodeValue:e},[])}function g(e,t,n){let r=new o("COMPONENT",{...t},new i(m(n)));return r.component=e,r}function v(...e){return new o("FRAGMENT",{},m(e))}function m(e){return e.map((e=>"object"==typeof e?e:y(e)))}window.RUMIOUS_JSX_SUPPORT={createElement:d,createFragment:v,createDirective:h};class b extends HTMLElement{constructor(){super(),this.instance=null,this.ref=null}cleanUp(){Object.setPrototypeOf(this,HTMLUnknownElement.prototype),this.remove()}init(e,t,n={},r,o){this.instance=new e,this.instance.element=this,this.instance.app=o,this.instance.prepare(this,t,n,r),this.instance.onInit()}connectedCallback(){this.instance.asynchronousRender?(async()=>{this.instance.onCreate(),this.instance.requestRender()})():(this.instance.onCreate(),this.instance.requestRender())}disconnectedCallback(){this.instance.onDestroy(),this.instance.requestCleanUp(),this.cleanUp()}}function w(e="r-component"){return window.customElements.get(e)||window.customElements.define(e,class extends b{static tag=e}),document.createElement(e)}class O{constructor(){this.contents=[],this.targets=[],this.observers=new WeakMap}commit(e=[]){this.contents=e}setTarget(e,t,n){this.targets.push({element:e,context:n,renderer:t}),this.observeTarget(e)}observeTarget(e){if(this.observers.has(e))return;const t=new MutationObserver((()=>{e.parentNode||this.removeTarget(e)}));t.observe(document.body,{childList:!0}),this.observers.set(e,t)}removeTarget(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e)),this.targets=this.targets.filter((t=>t.element!==e))}inject(e=!1){for(let t of this.targets)e&&(t.element.textContent=""),this.contents.forEach((e=>{"html"===e.type?t.element.innerHTML=e.value:"text"===e.type?t.element.textContent=e.value:"component"===e.type&&t.renderer(d(e.value,e.props??{},e.child??{}),t.element,t.context)}))}}function E(e,t,n){for(const[r,o]of Object.entries(t||{}))o instanceof a?o.init(e,n):r.startsWith("on")&&/^[a-zA-Z]+([A-Z][a-z]*)*$/.test(r)?e.addEventListener(r.substring(2).toLowerCase(),o):e.setAttribute(r,o)}function M(e,t,n={}){if(!e)return t;if(null===(r=e)||"object"!=typeof r&&"function"!=typeof r)return M(y(e),t,n);var r;if(Array.isArray(e)){for(const r of e)M(r,t,n);return t}if(e instanceof o){let r;switch(e.type){case"COMPONENT":return function(e,t,n,r){const o=function(e,t,n,r,o=null){const i=w(e.tag??"r-component");return i.init(e,t,n,r,o?.app),i}(e.component,e.props,e.children,n,r);return E(o,e.props,r),t.appendChild(o),t}(e,t,M,n);case"FRAGMENT":case"ELEMENT_LIST":for(const r of e.children)M(r,t,n);return t;case"TEXT_ELEMENT":r=function(e){return document.createTextNode(e.props.nodeValue)}(e);break;default:r=function(e,t){const n=document.createElement(e.type);E(n,e.props,t);for(const r of e.children)M(r,n,t);return n}(e,n)}return t.appendChild(r),t}if(e instanceof HTMLElement)return t.appendChild(e),t;if(e instanceof O){if(t instanceof HTMLDocument)throw"Rumious Render: Unsupported inject content in HTMLDocument!";return e.setTarget(t,M,n),e.inject(!0),t}return M(y(JSON.stringify(e)),t,n)}class k{constructor(e=null,t=[]){this.target=e,this.bindings=t}react(){this.bindings.forEach((e=>e()))}removeBinding(e){for(let t=this.bindings.length-1;t>=0;t--)this.bindings[t]===e&&this.bindings.splice(t,1)}addBinding(e){this.bindings.push(e)}}class R{constructor(e,t="",n){this.state=e,this.path=t,this.fn=n}trigger(...e){let t=this.fn(...e);this.state.set(this.path,t)}}const j="remove",S="replace",x="add",C=Symbol.for("__MUTATIVE_PROXY_DRAFT__"),T=Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"),A=Symbol.iterator,P={mutable:"mutable",immutable:"immutable"},z={};function D(e,t){return e instanceof Map?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function I(e,t){if(t in e){let n=Reflect.getPrototypeOf(e);for(;n;){const e=Reflect.getOwnPropertyDescriptor(n,t);if(e)return e;n=Reflect.getPrototypeOf(n)}}}function L(e){return Object.getPrototypeOf(e)===Set.prototype}function N(e){return Object.getPrototypeOf(e)===Map.prototype}function _(e){var t;return null!==(t=e.copy)&&void 0!==t?t:e.original}function U(e){return!!V(e)}function V(e){return"object"!=typeof e?null:null==e?void 0:e[C]}function F(e){var t;const n=V(e);return n?null!==(t=n.copy)&&void 0!==t?t:n.original:e}function q(e,t){if(!e||"object"!=typeof e)return!1;let n;return Object.getPrototypeOf(e)===Object.prototype||Array.isArray(e)||e instanceof Map||e instanceof Set||!!(null==t?void 0:t.mark)&&((n=t.mark(e,P))===P.immutable||"function"==typeof n)}function H(e,t=[]){if(Object.hasOwnProperty.call(e,"key")){const n=e.parent.copy,r=V(B(n,e.key));if(null!==r&&(null==r?void 0:r.original)!==e.original)return null;const o=3===e.parent.type,i=o?Array.from(e.parent.setMap.keys()).indexOf(e.key):e.key;if(!(o&&n.size>i||D(n,i)))return null;t.push(i)}if(e.parent)return H(e.parent,t);t.reverse();try{!function(e,t){for(let n=0;n<t.length-1;n+=1){const r=t[n];if("object"!=typeof(e=B(3===$(e)?Array.from(e):e,r)))throw new Error(`Cannot resolve patch at '${t.join("/")}'.`)}}(e.copy,t)}catch(e){return null}return t}function $(e){return Array.isArray(e)?1:e instanceof Map?2:e instanceof Set?3:0}function B(e,t){return 2===$(e)?e.get(t):e[t]}function W(e,t,n){2===$(e)?e.set(t,n):e[t]=n}function X(e,t){const n=V(e);return(n?_(n):e)[t]}function K(e,t){return e===t?0!==e||1/e==1/t:e!=e&&t!=t}function Y(e){if(e)for(;e.finalities.revoke.length>0;)e.finalities.revoke.pop()()}function Z(e,t){return t?e:[""].concat(e).map((e=>{const t=`${e}`;return-1===t.indexOf("/")&&-1===t.indexOf("~")?t:t.replace(/~/g,"~0").replace(/\//g,"~1")})).join("/")}const G=Object.prototype.propertyIsEnumerable;function J(e,t){let n;if(Array.isArray(e))return Array.prototype.concat.call(e);if(e instanceof Set)return L(e)?Set.prototype.difference?Set.prototype.difference.call(e,new Set):new Set(e.values()):new(0,Object.getPrototypeOf(e).constructor)(e.values());if(e instanceof Map)return N(e)?new Map(e):new(0,Object.getPrototypeOf(e).constructor)(e);if((null==t?void 0:t.mark)&&(n=t.mark(e,P),void 0!==n)&&n!==P.mutable){if(n===P.immutable)return function(e){const t=Object.create(Object.getPrototypeOf(e));return Reflect.ownKeys(e).forEach((n=>{let r=Reflect.getOwnPropertyDescriptor(e,n);r.enumerable&&r.configurable&&r.writable?t[n]=e[n]:(r.writable||(r.writable=!0,r.configurable=!0),(r.get||r.set)&&(r={configurable:!0,writable:!0,enumerable:r.enumerable,value:e[n]}),Reflect.defineProperty(t,n,r))})),t}(e);if("function"==typeof n){if(t.enablePatches||t.enableAutoFreeze)throw new Error("You can't use mark and patches or auto freeze together.");return n()}throw new Error(`Unsupported mark result: ${n}`)}if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){const t={};return Object.keys(e).forEach((n=>{t[n]=e[n]})),Object.getOwnPropertySymbols(e).forEach((n=>{G.call(e,n)&&(t[n]=e[n])})),t}throw new Error("Please check mark() to ensure that it is a stable marker draftable function.")}function Q(e){e.copy||(e.copy=J(e.original,e.options))}function ee(e){if(!q(e))return F(e);if(Array.isArray(e))return e.map(ee);if(e instanceof Map){const t=Array.from(e.entries()).map((([e,t])=>[e,ee(t)]));return N(e)?new Map(t):new(0,Object.getPrototypeOf(e).constructor)(t)}if(e instanceof Set){const t=Array.from(e).map(ee);return L(e)?new Set(t):new(0,Object.getPrototypeOf(e).constructor)(t)}const t=Object.create(Object.getPrototypeOf(e));for(const n in e)t[n]=ee(e[n]);return t}function te(e){return U(e)?ee(e):e}function ne(e){var t;e.assignedMap=null!==(t=e.assignedMap)&&void 0!==t?t:new Map,e.operated||(e.operated=!0,e.parent&&ne(e.parent))}function re(){throw new Error("Cannot modify frozen object")}function oe(e,t,n,r,o){{n=null!=n?n:new WeakMap,r=null!=r?r:[],o=null!=o?o:[];const i=n.has(e)?n.get(e):e;if(r.length>0){const e=r.indexOf(i);if(i&&"object"==typeof i&&-1!==e){if(r[0]===i)throw new Error("Forbids circular reference");throw new Error(`Forbids circular reference: ~/${o.slice(0,e).map(((e,t)=>{if("symbol"==typeof e)return`[${e.toString()}]`;const n=r[t];return"object"==typeof e&&(n instanceof Map||n instanceof Set)?Array.from(n.keys()).indexOf(e):e})).join("/")}`)}r.push(i),o.push(t)}else r.push(i)}if(Object.isFrozen(e)||U(e))return r.pop(),void o.pop();switch($(e)){case 2:for(const[t,i]of e)oe(t,t,n,r,o),oe(i,t,n,r,o);e.set=e.clear=e.delete=re;break;case 3:for(const t of e)oe(t,t,n,r,o);e.add=e.clear=e.delete=re;break;case 1:Object.freeze(e);let t=0;for(const i of e)oe(i,t,n,r,o),t+=1;break;default:Object.freeze(e),Object.keys(e).forEach((t=>{oe(e[t],t,n,r,o)}))}r.pop(),o.pop()}function ie(e,t){const n=$(e);if(0===n)Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)}));else if(1===n){let n=0;for(const r of e)t(n,r,e),n+=1}else e.forEach(((n,r)=>t(r,n,e)))}function se(e,t,n){if(U(e)||!q(e,n)||t.has(e)||Object.isFrozen(e))return;const r=e instanceof Set,o=r?new Map:void 0;if(t.add(e),ie(e,((i,s)=>{var a;if(U(s)){const t=V(s);Q(t);const n=(null===(a=t.assignedMap)||void 0===a?void 0:a.size)||t.operated?t.copy:t.original;W(r?o:e,i,n)}else se(s,t,n)})),o){const t=e,n=Array.from(t);t.clear(),n.forEach((e=>{t.add(o.has(e)?o.get(e):e)}))}}function ae(e,t){const n=3===e.type?e.setMap:e.copy;e.finalities.revoke.length>1&&e.assignedMap.get(t)&&n&&se(B(n,t),e.finalities.handledSet,e.options)}function le(e){3===e.type&&e.copy&&(e.copy.clear(),e.setMap.forEach((t=>{e.copy.add(F(t))})))}function ce(e,t,n,r){if(e.operated&&e.assignedMap&&e.assignedMap.size>0&&!e.finalized){if(n&&r){const o=H(e);o&&t(e,o,n,r)}e.finalized=!0}}function ue(e,t,n,r){const o=V(n);o&&(o.callbacks||(o.callbacks=[]),o.callbacks.push(((i,s)=>{var a;const l=3===e.type?e.setMap:e.copy;if(K(B(l,t),n)){let n=o.original;o.copy&&(n=o.copy),le(e),ce(e,r,i,s),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(a=e.options.updatedValues)&&void 0!==a?a:new WeakMap,e.options.updatedValues.set(n,o.original)),W(l,t,n)}})),e.options.enableAutoFreeze&&o.finalities!==e.finalities&&(e.options.enableAutoFreeze=!1)),q(n,e.options)&&e.finalities.draft.push((()=>{K(B(3===e.type?e.setMap:e.copy,t),n)&&ae(e,t)}))}function pe(e,t,n,r){const{pathAsArray:o=!0}=e.options.enablePatches;switch(e.type){case 0:case 2:return function({original:e,copy:t,assignedMap:n},r,o,i,s){n.forEach(((n,a)=>{const l=B(e,a),c=te(B(t,a)),u=n?D(e,a)?S:x:j;if(K(l,c)&&u===S)return;const p=Z(r.concat(a),s);o.push(u===j?{op:u,path:p}:{op:u,path:p,value:c}),i.push(u===x?{op:j,path:p}:u===j?{op:x,path:p,value:l}:{op:S,path:p,value:l})}))}(e,t,n,r,o);case 1:return function(e,t,n,r,o){let{original:i,assignedMap:s,options:a}=e,l=e.copy;l.length<i.length&&([i,l]=[l,i],[n,r]=[r,n]);for(let e=0;e<i.length;e+=1)if(s.get(e.toString())&&l[e]!==i[e]){const s=Z(t.concat([e]),o);n.push({op:S,path:s,value:te(l[e])}),r.push({op:S,path:s,value:te(i[e])})}for(let e=i.length;e<l.length;e+=1){const r=Z(t.concat([e]),o);n.push({op:x,path:r,value:te(l[e])})}if(i.length<l.length){const{arrayLengthAssignment:e=!0}=a.enablePatches;if(e){const e=Z(t.concat(["length"]),o);r.push({op:S,path:e,value:i.length})}else for(let e=l.length;i.length<e;e-=1){const n=Z(t.concat([e-1]),o);r.push({op:j,path:n})}}}(e,t,n,r,o);case 3:return function({original:e,copy:t},n,r,o,i){let s=0;e.forEach((e=>{if(!t.has(e)){const t=Z(n.concat([s]),i);r.push({op:j,path:t,value:e}),o.unshift({op:x,path:t,value:e})}s+=1})),s=0,t.forEach((t=>{if(!e.has(t)){const e=Z(n.concat([s]),i);r.push({op:x,path:e,value:t}),o.unshift({op:j,path:e,value:t})}s+=1}))}(e,t,n,r,o)}}const fe=(e,t,n=!1)=>{if("object"==typeof e&&null!==e&&(!q(e,t)||n))throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.")},he={get size(){return _(V(this)).size},has(e){return _(V(this)).has(e)},set(e,t){const n=V(this),r=_(n);return r.has(e)&&K(r.get(e),t)||(Q(n),ne(n),n.assignedMap.set(e,!0),n.copy.set(e,t),ue(n,e,t,pe)),this},delete(e){if(!this.has(e))return!1;const t=V(this);return Q(t),ne(t),t.original.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.copy.delete(e),!0},clear(){const e=V(this);if(this.size){Q(e),ne(e),e.assignedMap=new Map;for(const[t]of e.original)e.assignedMap.set(t,!1);e.copy.clear()}},forEach(e,t){_(V(this)).forEach(((n,r)=>{e.call(t,this.get(r),r,this)}))},get(e){var t,n;const r=V(this),o=_(r).get(e),i=(null===(n=(t=r.options).mark)||void 0===n?void 0:n.call(t,o,P))===P.mutable;if(r.options.strict&&fe(o,r.options,i),i)return o;if(r.finalized||!q(o,r.options))return o;if(o!==r.original.get(e))return o;const s=z.createDraft({original:o,parentDraft:r,key:e,finalities:r.finalities,options:r.options});return Q(r),r.copy.set(e,s),s},keys(){return _(V(this)).keys()},values(){const e=this.keys();return{[A]:()=>this.values(),next:()=>{const t=e.next();return t.done?t:{done:!1,value:this.get(t.value)}}}},entries(){const e=this.keys();return{[A]:()=>this.entries(),next:()=>{const t=e.next();if(t.done)return t;const n=this.get(t.value);return{done:!1,value:[t.value,n]}}}},[A](){return this.entries()}},de=Reflect.ownKeys(he),ye=(e,t,{isValuesIterator:n})=>()=>{var r,o;const i=t.next();if(i.done)return i;const s=i.value;let a=e.setMap.get(s);const l=V(a),c=(null===(o=(r=e.options).mark)||void 0===o?void 0:o.call(r,a,P))===P.mutable;if(e.options.strict&&fe(s,e.options,c),c||l||!q(s,e.options)||e.finalized||!e.original.has(s))l&&(a=l.proxy);else{const t=z.createDraft({original:s,parentDraft:e,key:s,finalities:e.finalities,options:e.options});e.setMap.set(s,t),a=t}return{done:!1,value:n?a:[a,a]}},ge={get size(){return V(this).setMap.size},has(e){const t=V(this);if(t.setMap.has(e))return!0;Q(t);const n=V(e);return!(!n||!t.setMap.has(n.original))},add(e){const t=V(this);return this.has(e)||(Q(t),ne(t),t.assignedMap.set(e,!0),t.setMap.set(e,e),ue(t,e,e,pe)),this},delete(e){if(!this.has(e))return!1;const t=V(this);Q(t),ne(t);const n=V(e);return n&&t.setMap.has(n.original)?(t.assignedMap.set(n.original,!1),t.setMap.delete(n.original)):(!n&&t.setMap.has(e)?t.assignedMap.set(e,!1):t.assignedMap.delete(e),t.setMap.delete(e))},clear(){if(!this.size)return;const e=V(this);Q(e),ne(e);for(const t of e.original)e.assignedMap.set(t,!1);e.setMap.clear()},values(){const e=V(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.values(),next:ye(e,t,{isValuesIterator:!0})}},entries(){const e=V(this);Q(e);const t=e.setMap.keys();return{[Symbol.iterator]:()=>this.entries(),next:ye(e,t,{isValuesIterator:!1})}},keys(){return this.values()},[A](){return this.values()},forEach(e,t){const n=this.values();let r=n.next();for(;!r.done;)e.call(t,r.value,r.value,this),r=n.next()}};Set.prototype.difference&&Object.assign(ge,{intersection(e){return Set.prototype.intersection.call(new Set(this.values()),e)},union(e){return Set.prototype.union.call(new Set(this.values()),e)},difference(e){return Set.prototype.difference.call(new Set(this.values()),e)},symmetricDifference(e){return Set.prototype.symmetricDifference.call(new Set(this.values()),e)},isSubsetOf(e){return Set.prototype.isSubsetOf.call(new Set(this.values()),e)},isSupersetOf(e){return Set.prototype.isSupersetOf.call(new Set(this.values()),e)},isDisjointFrom(e){return Set.prototype.isDisjointFrom.call(new Set(this.values()),e)}});const ve=Reflect.ownKeys(ge),me=new WeakSet,be={get(e,t,n){var r,o;const i=null===(r=e.copy)||void 0===r?void 0:r[t];if(i&&me.has(i))return i;if(t===C)return e;let s;if(e.options.mark){const r="size"===t&&(e.original instanceof Map||e.original instanceof Set)?Reflect.get(e.original,t):Reflect.get(e.original,t,n);if(s=e.options.mark(r,P),s===P.mutable)return e.options.strict&&fe(r,e.options,!0),r}const a=_(e);if(a instanceof Map&&de.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(he,"size").get.call(e.proxy);const n=he[t];if(n)return n.bind(e.proxy)}if(a instanceof Set&&ve.includes(t)){if("size"===t)return Object.getOwnPropertyDescriptor(ge,"size").get.call(e.proxy);const n=ge[t];if(n)return n.bind(e.proxy)}if(!D(a,t)){const n=I(a,t);return n?"value"in n?n.value:null===(o=n.get)||void 0===o?void 0:o.call(e.proxy):void 0}const l=a[t];if(e.options.strict&&fe(l,e.options),e.finalized||!q(l,e.options))return l;if(l===X(e.original,t)){if(Q(e),e.copy[t]=we({original:e.original[t],parentDraft:e,key:1===e.type?Number(t):t,finalities:e.finalities,options:e.options}),"function"==typeof s){const n=V(e.copy[t]);return Q(n),ne(n),n.copy}return e.copy[t]}return l},set(e,t,n){var r;if(3===e.type||2===e.type)throw new Error("Map/Set draft does not support any property assignment.");let o;if(1===e.type&&"length"!==t&&(!(Number.isInteger(o=Number(t))&&o>=0)||0!==t&&0!==o&&String(o)!==String(t)))throw new Error("Only supports setting array indices and the 'length' property.");const i=I(_(e),t);if(null==i?void 0:i.set)return i.set.call(e.proxy,n),!0;const s=X(_(e),t),a=V(s);return a&&K(a.original,n)?(e.copy[t]=n,e.assignedMap=null!==(r=e.assignedMap)&&void 0!==r?r:new Map,e.assignedMap.set(t,!1),!0):(K(n,s)&&(void 0!==n||D(e.original,t))||(Q(e),ne(e),D(e.original,t)&&K(n,e.original[t])?e.assignedMap.delete(t):e.assignedMap.set(t,!0),e.copy[t]=n,ue(e,t,n,pe)),!0)},has:(e,t)=>t in _(e),ownKeys:e=>Reflect.ownKeys(_(e)),getOwnPropertyDescriptor(e,t){const n=_(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},getPrototypeOf:e=>Reflect.getPrototypeOf(e.original),setPrototypeOf(){throw new Error("Cannot call 'setPrototypeOf()' on drafts")},defineProperty(){throw new Error("Cannot call 'defineProperty()' on drafts")},deleteProperty(e,t){var n;return 1===e.type?be.set.call(this,e,t,void 0,e.proxy):(void 0!==X(e.original,t)||t in e.original?(Q(e),ne(e),e.assignedMap.set(t,!1)):(e.assignedMap=null!==(n=e.assignedMap)&&void 0!==n?n:new Map,e.assignedMap.delete(t)),e.copy&&delete e.copy[t],!0)}};function we(e){const{original:t,parentDraft:n,key:r,finalities:o,options:i}=e,s=$(t),a={type:s,finalized:!1,parent:n,original:t,copy:null,proxy:null,finalities:o,options:i,setMap:3===s?new Map(t.entries()):void 0};(r||"key"in e)&&(a.key=r);const{proxy:l,revoke:c}=Proxy.revocable(1===s?Object.assign([],a):a,be);if(o.revoke.push(c),me.add(l),a.proxy=l,n){const e=n;e.finalities.draft.push(((t,n)=>{var o,i;const s=V(l);let a=3===e.type?e.setMap:e.copy;const c=B(a,r),u=V(c);if(u){let i=u.original;u.operated&&(i=F(c)),le(u),ce(u,pe,t,n),e.options.enableAutoFreeze&&(e.options.updatedValues=null!==(o=e.options.updatedValues)&&void 0!==o?o:new WeakMap,e.options.updatedValues.set(i,u.original)),W(a,r,i)}null===(i=s.callbacks)||void 0===i||i.forEach((e=>{e(t,n)}))}))}else{const e=V(l);e.finalities.draft.push(((t,n)=>{le(e),ce(e,pe,t,n)}))}return l}function Oe(e,t,n,r,o){var i;const s=V(e),a=null!==(i=null==s?void 0:s.original)&&void 0!==i?i:e,l=!!t.length;if(null==s?void 0:s.operated)for(;s.finalities.draft.length>0;)s.finalities.draft.pop()(n,r);const c=l?t[0]:s?s.operated?s.copy:s.original:e;return s&&Y(s),o&&oe(c,c,null==s?void 0:s.options.updatedValues),[c,n&&l?[{op:S,path:[],value:t[0]}]:n,r&&l?[{op:S,path:[],value:a}]:r]}function Ee(e){const{rootDraft:t,value:n,useRawReturn:r=!1,isRoot:o=!0}=e;ie(n,((n,r,o)=>{const i=V(r);if(i&&t&&i.finalities===t.finalities){e.isContainDraft=!0;const t=i.original;if(o instanceof Set){const e=Array.from(o);o.clear(),e.forEach((e=>o.add(n===e?t:e)))}else W(o,n,t)}else"object"==typeof r&&null!==r&&(e.value=r,e.isRoot=!1,Ee(e))})),o&&e.isContainDraft}function Me(e){var t;const n=V(e);if(!q(e,null==n?void 0:n.options))return e;const r=$(e);if(n&&!n.operated)return n.original;let o;function i(){o=2===r?N(e)?new Map(e):new(Object.getPrototypeOf(e).constructor)(e):3===r?Array.from(n.setMap.values()):J(e,null==n?void 0:n.options)}if(n){n.finalized=!0;try{i()}finally{n.finalized=!1}}else o=e;if(ie(o,((t,r)=>{if(n&&K(B(n.original,t),r))return;const s=Me(r);s!==r&&(o===e&&i(),W(o,t,s))})),3===r){const e=null!==(t=null==n?void 0:n.original)&&void 0!==t?t:o;return L(e)?new Set(o):new(Object.getPrototypeOf(e).constructor)(o)}return o}function ke(e){if(!U(e))throw new Error(`current() is only used for Draft, parameter: ${e}`);return Me(e)}z.createDraft=we;const Re=function e(t,n,r){var o,i,s;if("function"==typeof t&&"function"!=typeof n)return function(r,...o){return e(r,(e=>t.call(this,e,...o)),n)};const a=t,l=n;let c=r;if("function"!=typeof n&&(c=n),void 0!==c&&"[object Object]"!==Object.prototype.toString.call(c))throw new Error(`Invalid options: ${c}, 'options' should be an object.`);c=Object.assign(Object.assign({},void 0),c);const u=U(a)?ke(a):a,p=Array.isArray(c.mark)?(e,t)=>{for(const n of c.mark){if("function"!=typeof n)throw new Error(`Invalid mark: ${n}, 'mark' should be a function.`);const r=n(e,t);if(r)return r}}:c.mark,f=null!==(o=c.enablePatches)&&void 0!==o&&o,h=null!==(i=c.strict)&&void 0!==i&&i,d={enableAutoFreeze:null!==(s=c.enableAutoFreeze)&&void 0!==s&&s,mark:p,strict:h,enablePatches:f};if(!q(u,d)&&"object"==typeof u&&null!==u)throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");const[y,g]=function(e,t){var n;const r={draft:[],revoke:[],handledSet:new WeakSet};let o,i;t.enablePatches&&(o=[],i=[]);const s=(null===(n=t.mark)||void 0===n?void 0:n.call(t,e,P))!==P.mutable&&q(e,t)?we({original:e,parentDraft:null,finalities:r,options:t}):e;return[s,(e=[])=>{const[n,r,a]=Oe(s,e,o,i,t.enableAutoFreeze);return t.enablePatches?[n,r,a]:n}]}(u,d);if("function"!=typeof n){if(!q(u,d))throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");return[y,g]}let v;try{v=l(y)}catch(e){throw Y(V(y)),e}const m=e=>{const t=V(y);if(!U(e)){if(void 0!==e&&!K(e,y)&&(null==t?void 0:t.operated))throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");const n=null==e?void 0:e[T];if(n){const r=n[0];return d.strict&&"object"==typeof e&&null!==e&&Ee({rootDraft:t,value:e,useRawReturn:!0}),g([r])}if(void 0!==e)return"object"==typeof e&&null!==e&&Ee({rootDraft:t,value:e}),g([e])}if(e===y||void 0===e)return g([]);const n=V(e);if(d===n.options){if(n.operated)throw new Error("Cannot return a modified child draft.");return g([ke(e)])}return g([e])};return v instanceof Promise?v.then(m,(e=>{throw Y(V(y)),e})):m(v)};function je(e,t){e.set(Re(e.get(),t))}Object.prototype.constructor.toString();class Se{constructor(e,t=null){this.value=e,this.reactor=t??new k(this,[])}produce(e){return je(this,e)}reducer(...e){let t;return t=1===e.length?new R(this,"",e[0]):new R(this,e[0],e[1]),t.trigger.bind(t)}setObjectByPath(e="",t){if(0===e.length)return void(this.value=t);if("string"!=typeof e||!e)throw new Error("Invalid path");let n=e.split("."),r=this.value;for(let e=0;e<n.length-1;e++){let t=n[e];t in r||(r[t]={}),r=r[t]}r[n[n.length-1]]=t}set(...e){if(1===e.length)this.value=e[0];else{let t=e[0],n=e[1];this.setObjectByPath(t,n)}this.reactor.react()}get(){return this.value}}function xe(e){return new Se(e)}class Ce{constructor(e){this.target=e}set html(e){this.target.innerHTML=e}query(e){return this.target.querySelectorAll(e)}set text(e){this.target.textContent=e}on(e,t){this.target.addEventListener(e,t)}off(e,t){this.target.removeEventListener(e,t)}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Te{constructor(e){this.target=e}query(e){return this.target.querySelectorAll(e)}index(e){return Array.from(this.target.children)[e]}list(){return Array.from(this.target.children)}get parent(){return this.target}remove(){this.target.remove()}addChild(e){this.target.appendChild(e)}set(e){this.target=e}}class Ae{constructor(e){this.target=e}set(e){this.target=e.forwardRefs}}window.RUMIOUS_CONTEXTS||(window.RUMIOUS_CONTEXTS={});class Pe{constructor(e={}){this.data=e,this.events={}}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}off(e,t){this.events[e]&&(this.events[e]=this.events[e].filter((e=>e!==t)))}emit(e,...t){this.events[e]&&this.events[e].forEach((e=>e(...t)))}set(e,t){let n=xe(t);return this.data[e]=n,n}get(e){return this.data[e]}}class ze{constructor(e,t={}){this.hasExecuted=!1,this.result=null,this.callback=e,this.dependents=[],this.options=t}onLoad(e){this.hasExecuted?e(this.result):this.dependents.push(e)}execute(){return new Promise(((e,t)=>{if(this.hasExecuted)return e(this.result);this.hasExecuted=!0;const n=async()=>{try{this.result=await this.callback(),e(this.result),this.dependents.forEach((e=>e(this.result)))}catch(e){t(e)}};this.options.idle&&"requestIdleCallback"in window?requestIdleCallback(n):n()}))}}const De=new Map;return e.Pending=class extends n{static tag="r-pending";constructor(){super(),this.asynchronousRender=!0}async setLoader(e){this.loader=e;try{this.result=await this.loader.execute(),this.renderResult()}catch(e){this.error=e,this.renderError()}}renderResult(){if(!this.result)throw"Rumious Render: Cannot find component when lazy loading!";this.element.before(this.render(d(this.result,{}))),this.element.remove()}renderError(){this.element.appendChild(this.render(this.props.errorComponent??this.error))}onRender(){let{loader:e}=this.props;this.setLoader(e)}template(){return this.props.fallback}},e.RumiousApp=class{constructor(e=document.createElement("span"),n={}){this.root=e,this.app=this,this.modules=[],this.configs=n,this.renderContext=new t(this)}render(e){this.renderContext.runHooks("onBeforeRender",this.renderContext),M(e,this.root,this.renderContext),this.renderContext.runHooks("onRendered",this.renderContext)}addModule(e,t={}){return e.init(this,t)}},e.RumiousChildrensRef=Te,e.RumiousComponent=n,e.RumiousComponentElement=b,e.RumiousComponentRef=Ae,e.RumiousContext=Pe,e.RumiousDymanicInjector=O,e.RumiousElementRef=Ce,e.RumiousLazyLoader=ze,e.RumiousReactor=k,e.RumiousReducer=R,e.RumiousState=Se,e.createChildrensRef=function(e){return new Te(e)},e.createComponent=g,e.createComponentElement=w,e.createComponentRef=function(e){return new Ae(e)},e.createContext=function(e="",t={}){if(!t||"object"!=typeof t)throw"Rumious context: Initial value must be object !";return window.RUMIOUS_CONTEXTS[e]||(window.RUMIOUS_CONTEXTS[e]=new Pe(t)),window.RUMIOUS_CONTEXTS[e]},e.createDirective=h,e.createElement=d,e.createElementRef=function(e){return new Ce(e)},e.createState=xe,e.createTextElement=y,e.denounce=function(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout((()=>e.apply(this,r)),t)}},e.injectHTML=function(e){let t=new O;return t.commit([{type:"html",value:e}]),t},e.injectText=function(e){let t=new O;return t.commit([{type:"text",value:e}]),t},e.isComponent=r,e.isState=function(e){return e instanceof Se},e.lazyLoad=function(e,t={}){const n=t.key||e.toString();return De.has(n)||De.set(n,new ze(e,t)),De.get(n)},e.leadingTrailingDebounce=function(e,t){let n,r=!0;return function(...o){r&&(e.apply(this,o),r=!1),clearTimeout(n),n=setTimeout((()=>{e.apply(this,o),r=!0}),t)}},e.produceState=je,e.rafThrottle=function(e){let t=!1;return function(...n){t||(t=!0,requestAnimationFrame((()=>{e.apply(this,n),t=!1})))}},e.styleHelper=function(e){let t="";for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)){t+=`${n} {`;const r=e[n];for(const e in r)Object.prototype.hasOwnProperty.call(r,e)&&(t+=`${e.replace(/[A-Z]/g,(e=>`-${e.toLowerCase()}`))}: ${r[e]};`);t+="} "}return t.trim()},e.tholle=function(e,t){let n=0;return function(...r){const o=Date.now();o-n>=t&&(n=o,e.apply(this,r))}},e.trailingThrottle=function(e,t){let n=0,r=null,o=null;function i(){n=Date.now(),e.apply(this,r),r=null}return function(...e){const s=Date.now();r=e,s-n>=t?i():o||(o=setTimeout((()=>{o=null,i()}),t-(s-n)))}},e.unwatch=function(e,t){e.reactor.removeBinding(t)},e.watch=function(e,t){e.reactor.addBinding(t)},e}({});
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  'use strict';
2
2
 
3
- module.exports = require('./dist/index.cjs.js');
3
+ module.exports = require('./dist/index.cjs.min.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rumious",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "The simple library for build UI",
5
5
  "keywords": [
6
6
  "rumious",