ziko 1.8.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ziko.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sun Aug 09 2026 11:06:22 GMT+0100 (UTC+01:00)
5
+ Date : Wed Aug 26 2026 10:48:40 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -2432,11 +2432,10 @@ var LifecycleMethods = /*#__PURE__*/Object.freeze({
2432
2432
  unmount: unmount
2433
2433
  });
2434
2434
 
2435
+ const STATE_GETTER = Symbol.for("ziko/hooks/STATE_GETTER");
2436
+
2435
2437
  // import { __init__global__ } from "../__ziko__/index.js";
2436
2438
 
2437
- // if (!globalThis.__Ziko__) __init__global__();
2438
-
2439
- const STATE_GETTER = Symbol.for("ziko.stateGetter");
2440
2439
 
2441
2440
  function useState(initialValue) {
2442
2441
  const state = {
@@ -2640,6 +2639,7 @@ async function __addItem__(adder, pusher, ...ele) {
2640
2639
  // Fix Items Latter
2641
2640
  if (ele[i] instanceof Function) {
2642
2641
  if (isStateGetter(ele[i])) {
2642
+ console.log({s : ele[i]()});
2643
2643
  const getter = ele[i]();
2644
2644
  ele[i] = text(getter.value);
2645
2645
  getter._subscribe(
@@ -5035,23 +5035,29 @@ function useDerived(deriveFn, sources) {
5035
5035
  let value = deriveFn(...sources.map(s => s().value));
5036
5036
  const subscribers = new Set();
5037
5037
 
5038
- sources.forEach(source => {
5039
- const srcValue = source();
5040
- srcValue._subscribe(() => {
5041
- {
5042
- const newVal = deriveFn(...sources.map(s => s().value));
5043
- if (newVal !== value) {
5044
- value = newVal;
5045
- subscribers.forEach(fn => fn(value));
5046
- }
5047
- }
5048
- });
5049
- });
5050
- return () => ({
5038
+ // const unsubscribers = sources.map(source => {
5039
+ // const srcValue = source();
5040
+
5041
+ // return srcValue._subscribe(() => {
5042
+ // const newVal = deriveFn(...sources.map(s => s().value));
5043
+
5044
+ // if (!Object.is(newVal, value)) {
5045
+ // value = newVal;
5046
+ // subscribers.forEach(fn => fn(value));
5047
+ // }
5048
+ // });
5049
+ // });
5050
+
5051
+ const getter = () => ({
5051
5052
  value,
5052
- isStateGetter : () => true,
5053
- _subscribe: (fn) => subscribers.add(fn)
5054
- })
5053
+ _subscribe: (fn) => {
5054
+ subscribers.add(fn);
5055
+ return () => subscribers.delete(fn);
5056
+ },
5057
+ });
5058
+
5059
+ getter[STATE_GETTER] = true;
5060
+ return getter
5055
5061
  }
5056
5062
 
5057
5063
  const mapfun=(fun,...X)=>{
@@ -5590,7 +5596,6 @@ exports.PI = PI$1;
5590
5596
  exports.PtrListeners = PtrListeners;
5591
5597
  exports.Random = Random;
5592
5598
  exports.SPA = SPA;
5593
- exports.STATE_GETTER = STATE_GETTER;
5594
5599
  exports.SVGWrapper = SVGWrapper;
5595
5600
  exports.Scheduler = Scheduler;
5596
5601
  exports.Suspense = Suspense;
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sun Aug 09 2026 11:06:22 GMT+0100 (UTC+01:00)
5
+ Date : Wed Aug 26 2026 10:48:40 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -2436,11 +2436,10 @@
2436
2436
  unmount: unmount
2437
2437
  });
2438
2438
 
2439
+ const STATE_GETTER = Symbol.for("ziko/hooks/STATE_GETTER");
2440
+
2439
2441
  // import { __init__global__ } from "../__ziko__/index.js";
2440
2442
 
2441
- // if (!globalThis.__Ziko__) __init__global__();
2442
-
2443
- const STATE_GETTER = Symbol.for("ziko.stateGetter");
2444
2443
 
2445
2444
  function useState(initialValue) {
2446
2445
  const state = {
@@ -2644,6 +2643,7 @@
2644
2643
  // Fix Items Latter
2645
2644
  if (ele[i] instanceof Function) {
2646
2645
  if (isStateGetter(ele[i])) {
2646
+ console.log({s : ele[i]()});
2647
2647
  const getter = ele[i]();
2648
2648
  ele[i] = text(getter.value);
2649
2649
  getter._subscribe(
@@ -5039,23 +5039,29 @@
5039
5039
  let value = deriveFn(...sources.map(s => s().value));
5040
5040
  const subscribers = new Set();
5041
5041
 
5042
- sources.forEach(source => {
5043
- const srcValue = source();
5044
- srcValue._subscribe(() => {
5045
- {
5046
- const newVal = deriveFn(...sources.map(s => s().value));
5047
- if (newVal !== value) {
5048
- value = newVal;
5049
- subscribers.forEach(fn => fn(value));
5050
- }
5051
- }
5052
- });
5053
- });
5054
- return () => ({
5042
+ // const unsubscribers = sources.map(source => {
5043
+ // const srcValue = source();
5044
+
5045
+ // return srcValue._subscribe(() => {
5046
+ // const newVal = deriveFn(...sources.map(s => s().value));
5047
+
5048
+ // if (!Object.is(newVal, value)) {
5049
+ // value = newVal;
5050
+ // subscribers.forEach(fn => fn(value));
5051
+ // }
5052
+ // });
5053
+ // });
5054
+
5055
+ const getter = () => ({
5055
5056
  value,
5056
- isStateGetter : () => true,
5057
- _subscribe: (fn) => subscribers.add(fn)
5058
- })
5057
+ _subscribe: (fn) => {
5058
+ subscribers.add(fn);
5059
+ return () => subscribers.delete(fn);
5060
+ },
5061
+ });
5062
+
5063
+ getter[STATE_GETTER] = true;
5064
+ return getter
5059
5065
  }
5060
5066
 
5061
5067
  const mapfun=(fun,...X)=>{
@@ -5594,7 +5600,6 @@
5594
5600
  exports.PtrListeners = PtrListeners;
5595
5601
  exports.Random = Random;
5596
5602
  exports.SPA = SPA;
5597
- exports.STATE_GETTER = STATE_GETTER;
5598
5603
  exports.SVGWrapper = SVGWrapper;
5599
5604
  exports.Scheduler = Scheduler;
5600
5605
  exports.Suspense = Suspense;
package/dist/ziko.min.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /*
2
2
  Project: ziko.js
3
3
  Author: Zakaria Elalaoui
4
- Date : Sun Aug 09 2026 11:06:22 GMT+0100 (UTC+01:00)
4
+ Date : Wed Aug 26 2026 10:48:40 GMT+0100 (UTC+01:00)
5
5
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
6
6
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
7
7
  Released under MIT License
8
8
  */
9
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Ziko={})}(this,function(t){"use strict";const{PI:e,E:s}=Math,r=Number.EPSILON,n=(t,...e)=>{const s=e.map(e=>{return"object"!=typeof(s=e)&&"function"!=typeof s||null===s||e?.__mapfun__?t(e):e instanceof Array?e.map(e=>n(t,e)):ArrayBuffer.isView(e)?e.map(e=>t(e)):e instanceof Set?new Set(n(t,...e)):e instanceof Map?new Map([...e].map(e=>[e[0],n(t,e[1])])):e.isMatrix?.()?new e.constructor(e.rows,e.cols,n(e.arr.flat(1))):e instanceof Object?Object.fromEntries(Object.entries(e).map(e=>[e[0],n(t,e[1])])):void 0;var s});return 1==s.length?s[0]:s},i=(t,e)=>t.isComplex?.()?new t.constructor(e(t.a),e(t.b)):t.isMatrix?.()?new t.constructor(t.rows,t.cols,t.arr.flat(1).map(e)):(t instanceof Array&&n(e,...t),e(t)),o=(t,e)=>{if(0===t.length)return NaN;let s=t.sort((t,e)=>t-e),r=e/100*(s.length-1),n=Math.floor(r),i=r-n;return n===s.length-1?s[n]:s[n]*(1-i)+s[n+1]*i},h=t=>o(t,25),l=t=>o(t,75),u=(...t)=>t.reduce((t,e)=>t+e)/t.length,m=(...t)=>{const e=t.length;if(0===e)return NaN;const s=u(...t);return t.reduce((t,e)=>t+(e-s)**2,0)/e},p=(...t)=>{const e=t.length;if(e<2)return NaN;const s=u(...t);return t.reduce((t,e)=>t+(e-s)**2,0)/(e-1)},f=(t,e)=>{const s=t.length;if(0===s||e.length!==s)return NaN;const r=e.reduce((t,e)=>t+e,0),n=t.reduce((t,s,r)=>t+s*e[r],0)/r;return t.reduce((t,s,r)=>t+e[r]*(s-n)**2,0)/r},d=(t,e)=>{if(e<1||t.length<e)return[];let s=[];for(let r=0;r<=t.length-e;r++){const n=t.slice(r,r+e);s.push(p(n))}return s},g=t=>{let e=[],s=0;for(let r of t)s+=r,e.push(s);return e};class w{static int(t,e){return Math.floor(this.float(t,e))}static float(t,e){return void 0!==e?Math.random()*(e-t)+t:Math.random()*t}static bin(){return this.int(2)}static oct(){return this.int(8)}static dec(){return this.int(10)}static hex(){return((t,e,s)=>{const r=parseInt(t,e);if(Number.isNaN(r))throw new TypeError("Invalid value for the given base");return r.toString(s)})(this.int(16),10,16)}static char(t=!1){const e=t?this.int(65,91):this.int(97,123);return String.fromCharCode(e)}static bool(){return Boolean(this.int(2))}static get color(){return{hex:()=>`#${this.int(16777215).toString(16).padStart(6,"0")}`,hexa:()=>{const[t,e,s,r]=Array.from({length:4},()=>this.int(255).toString(16).padStart(2,"0"));return`#${t}${e}${s}${r}`},rgb:()=>{const[t,e,s]=Array.from({length:3},()=>this.int(255));return`rgb(${t}, ${e}, ${s})`},rgba:()=>{const[t,e,s]=Array.from({length:3},()=>this.int(255));return`rgba(${t}, ${e}, ${s}, ${Math.random().toFixed(2)})`},hsl:()=>`hsl(${this.int(360)}, ${this.int(100)}%, ${this.int(100)}%)`,hsla:()=>`hsla(${this.int(360)}, ${this.int(100)}%, ${this.int(100)}%, ${Math.random().toFixed(2)})`,gray:()=>{const t=this.int(255);return`rgb(${t}, ${t}, ${t})`}}}static get sample(){const t=this;return{int:(e,s,r)=>Array.from({length:e},()=>t.int(s,r)),float:(e,s,r)=>Array.from({length:e},()=>t.float(s,r)),char:(e,s=!1)=>Array.from({length:e},()=>t.char(s)),bool:e=>Array.from({length:e},()=>t.bool()),bin:e=>Array.from({length:e},()=>t.bin()),oct:e=>Array.from({length:e},()=>t.oct()),dec:e=>Array.from({length:e},()=>t.dec()),hex:e=>Array.from({length:e},()=>t.hex()),get color(){return{hex:e=>Array.from({length:e},()=>t.color.hex()),hexa:e=>Array.from({length:e},()=>t.color.hexa()),rgb:e=>Array.from({length:e},()=>t.color.rgb()),rgba:e=>Array.from({length:e},()=>t.color.rgba()),hsl:e=>Array.from({length:e},()=>t.color.hsl()),hsla:e=>Array.from({length:e},()=>t.color.hsla()),gray:e=>Array.from({length:e},()=>t.color.gray())}},choice:(e,s,r)=>Array.from({length:e},()=>t.choice(s,r))}}static shuffle(t){return[...t].sort(()=>.5-Math.random())}static choice(t=[1,2,3],e=new Array(t.length).fill(1/t.length)){const s=g(...e).map(t=>100*t),r=new Array(100);r.fill(t[0],0,s[0]);for(let e=1;e<t.length;e++)r.fill(t[e],s[e-1],s[e]);return r[this.int(r.length)]}}globalThis.Random=w;class y{constructor(t=0,e=0){[this.a,this.b]=((t,e,s)=>{let r,n;return e instanceof t?(r=e.a,n=e.b):"object"==typeof e?"a"in e&&"b"in e?(r=e.a,n=e.b):"a"in e&&"z"in e?(r=e.a,n=Math.sqrt(e.z**2-e.a**2)):"a"in e&&"phi"in e?(r=e.a,n=e.a*Math.tan(e.phi)):"b"in e&&"z"in e?(n=e.b,r=Math.sqrt(e.z**2-e.b**2)):"b"in e&&"phi"in e?(n=s,r=e.b/Math.tan(e.phi)):"z"in e&&"phi"in e&&(r=+e.z*Math.cos(e.phi).toFixed(15),n=+e.z*Math.sin(e.phi).toFixed(15)):"number"==typeof e&&"number"==typeof s&&(r=+e.toFixed(32),n=+s.toFixed(32)),[r,n]})(y,t,e)}get __mapfun__(){return!0}isComplex(){return!0}toString(){let t="";return t=0!==this.a?this.b>=0?`${this.a}+${this.b}*i`:`${this.a}-${Math.abs(this.b)}*i`:this.b>=0?`${this.b}*i`:`-${Math.abs(this.b)}*i`,t}serialize(){return JSON.stringify({type:"complex",data:this})}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));let{data:e,type:s}=t;return"complex"===s&&"a"in e&&"b"in e?new y(e.a,e.b):TypeError("Not a valid complex")}toFixed(t){return this.a=+this.a.toFixed(t),this.b=+this.b.toFixed(t),this}toPrecision(t){return this.a=+this.a.toPrecision(t),this.b=+this.b.toPrecision(t),this}clone(){return new y(this.a,this.b)}get z(){return Math.hypot(this.a,this.b)}get phi(){return Math.atan2(this.b,this.a)}static zero(){return new y(0,0)}static fromPolar(t,e){return new y(+(t*cos(e)).toFixed(13),+(t*sin(e)).toFixed(13))}static get random(){return{int:(t,e)=>new y(...w.sample.int(2,t,e)),float:(t,e)=>new y(...w.sample.float(2,t,e))}}static twiddle(t,e){const s=-2*Math.PI*t/e;return new y(Math.cos(s),Math.sin(s))}get conj(){return new y(this.a,-this.b)}get inv(){return new y(this.a/Math.hypot(this.a,this.b),-this.b/Math.hypot(this.a,this.b))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new y(t[e],0)),this.a+=t[e].a,this.b+=t[e].b;return this}sub(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new y(t[e],0)),this.a-=t[e].a,this.b-=t[e].b;return this}mul(...t){let{z:e,phi:s}=this;for(let r=0;r<t.length;r++)"number"==typeof t[r]&&(t[r]=new y(t[r],0)),e*=t[r].z,s+=t[r].phi;return this.a=e*Math.cos(s),this.b=e*Math.sin(s),this.toFixed(8)}div(...t){let{z:e,phi:s}=this;for(let r=0;r<t.length;r++)"number"==typeof t[r]&&(t[r]=new y(t[r],0)),e/=t[r].z,s-=t[r].phi;return this.a=e*Math.cos(s),this.b=e*Math.sin(s),this.toFixed(8)}modulo(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new y(t[e],0)),this.a%=t[e].a,this.b%=t[e].b;return this}pow(...t){let{z:e,phi:s}=this;for(let r=0;r<t.length;r++)"number"==typeof t[r]&&(t[r]=new y(t[r],0)),e*=Math.exp(t[r].a*Math.log(e)-t[r].b*s),s+=t[r].b*Math.log(e)+t[r].a*s;return this.a=e*Math.cos(s),this.b=e*Math.sin(s),this}get expo(){return[this.z,this.phi]}nthr(t=2){return x({z:this.z**(1/t),phi:this.phi/t})}get sqrt(){return this.nthr(2)}get cbrt(){return this.nthr(3)}get log(){return x(this.z,this.phi)}get cos(){return x(Math.cos(this.a)*Math.cosh(this.b),Math.sin(this.a)*Math.sinh(this.b))}get sin(){return x(Math.sin(this.a)*Math.cosh(this.b),Math.cos(this.a)*Math.sinh(this.b))}get tan(){const t=cos(2*this.a)+cosh(2*this.b);return x(Math.sin(2*this.a)/t,Math.sinh(2*this.b)/t)}}const x=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map((s,r)=>x(t[r],e[r]));if(t.isMatrix?.()&&e.isMatrix?.()){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map((s,r)=>x(t.arr[r],e.arr[r]));return new t.constructor(t.rows,t.cols,...s)}return new y(t,e)},v=(...t)=>{const e=t.pop();return n(t=>t.isComplex?.()?e.isComplex?.()?new t.constructor({z:Math.exp(e.a*Math.log(t.z)-e.b*t.phi),phi:e.b*Math.log(t.z)+e.a*t.phi}):new t.constructor({z:t.z**e,phi:t.phi*e}):e.isComplex?.()?new t.constructor({z:Math.exp(e.a*Math.log(t)),phi:e.b*Math.log(t)}):Math.pow(t,e),...t)},M=(...t)=>n(t=>t.isComplex?.()?new t.constructor({z:t.z**.5,phi:t.phi/2}):t<0?x(0,Math.sqrt(-t)).toFixed(8):+Math.sqrt(t).toFixed(8),...t),_=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.log(t.z),t.phi).toFixed(8):+Math.log(t).toFixed(8),...t),E=(t,e,s)=>{if("number"==typeof e){if("number"==typeof s)switch(t){case"add":return e+s;case"sub":return e-s;case"mul":return e*s;case"div":return e/s;case"modulo":return e%s}return s?.isComplex?.()&&(e=new s.constructor(e,0)),s?.isMatrix?.()&&(e=s.constructor.nums(s.rows,s.cols,e)),e[t](s)}if(e?.isComplex?.()){if("number"==typeof s||s?.isComplex?.())return e.clone()[t](s);if(s?.isMatrix?.())return(e=s.constructor.nums(s.rows,s.cols,e)).clone()[t](s)}if(e?.isMatrix?.())return e.clone()[t](s)},T=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=E("add",s,e[t]);return s},C=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=E("sub",s,e[t]);return s},k=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=E("mul",s,e[t]);return s},S=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=E("div",s,e[t]);return s},A=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=E("modulo",s,e[t]);return s},j=(t,e,s)=>i(t,t=>e!==s?(t-e)/(s-e):0),O=(t,e,s)=>i(t,t=>(s-e)*t+e),I=(t,e,s)=>i(t,t=>Math.min(Math.max(t,e),s)),R=(t,e,s,r,n)=>i(t,t=>O(j(t,e,s),r,n)),z=(t,e,s=!0)=>{if(t instanceof Array&&!(e instanceof Array))return n(t=>z(t,e,s),...t);if(e instanceof Array&&!(t instanceof Array))return n(e=>z(t,e,s),...e);if(t instanceof Array&&e instanceof Array)return t.map((t,r)=>z(t,e[r],s));const r=Math.atan2(t,e);return s?r:180*r/Math.PI},F=t=>t.isComplex?.()?new t.constructor(F(t.a),F(t.b)):t.isMatrix?.()?new t.constructor(t.rows,t.cols,t.arr.flat(1).map(F)):+!t,P=(t,e)=>{if(t.every(t=>t.isComplex?.())){const s=t.map(t=>t.a),r=t.map(t=>t.b);return new t[0].constructor(e(...s),e(...r))}if(t.every(t=>t.isMatrix?.())){if(!t.every(e=>e.rows===t[0].rows&&e.cols===t[0].cols))return TypeError("All matrices must have the same shape");const{rows:s,cols:r}=t[0],n=Array.from({length:s},(s,n)=>Array.from({length:r},(s,r)=>e(...t.map(t=>t.arr[n][r]))));return new t[0].constructor(n)}return null},D=(...t)=>{const e=P(t,D);return null!==e?e:t.reduce((t,e)=>t&e,1)},L=(...t)=>{const e=P(t,L);return null!==e?e:t.reduce((t,e)=>t|e,0)},$=(...t)=>{const e=P(t,$);return null!==e?e:t.reduce((t,e)=>t^e,0)},U=(t,e)=>{for(let e=0;e<t.arr.length;e++)Object.defineProperty(t,e,{value:t.arr[e],writable:!0,configurable:!0,enumerable:!1});for(let s=t.arr.length;s<e;s++)delete t[s]};function N(t,e){var s=[];for(let e=0;e<t.length;e++)s.push(t[e].slice(0));s.splice(0,1);for(let t=0;t<s.length;t++)s[t].splice(e,1);return s}function q(t,e){if(t=t.clone(),e=e.clone(),t.rows!==e.rows)return;let s=t.arr;for(let r=0;r<t.rows;r++)for(let n=t.cols;n<t.cols+e.cols;n++)s[r][n]=e.arr[r][n-t.cols];return t.cols+=e.cols,new t.constructor(t.rows,t.cols,s.flat(1))}function B(t,e){if(t=t.clone(),e=e.clone(),t.cols!==e.cols)return;let s=t.arr;for(let r=t.rows;r<t.rows+e.rows;r++){s[r]=[];for(let n=0;n<t.cols;n++)s[r][n]=e.arr[r-t.rows][n]}return t.rows+=e.rows,new t.constructor(t.rows,t.cols,s.flat(1))}class Z{constructor(t,e,s=[]){[this.rows,this.cols,this.arr]=((t,e,s,r)=>{if(!(e instanceof t)){let t,n,i=[];if(e instanceof Array)i=e,e=i.length,s=i[0].length;else for(t=0;t<e;t++)for(i.push([]),i[t].push(new Array(s)),n=0;n<s;n++)i[t][n]=r[t*s+n],null==r[t*s+n]&&(i[t][n]=0);return[e,s,i]}arr=e.arr,s=(e=e.rows).cols})(Z,t,e,s),U(this)}isMatrix(){return!0}clone(){return new Z(this.rows,this.cols,this.arr.flat(1))}toComplex(){return this.arr=n(t=>t?.isComplex?.()?t:new y(t,0),...this.arr),U(this),this}[Symbol.iterator](){return this.arr[Symbol.iterator]()}get size(){return this.rows*this.cols}get shape(){return[this.rows,this.cols]}at(t=0,e=void 0){if(t<0&&(t+=this.rows),t<0||t>=this.rows)throw new Error("Row index out of bounds");if(void 0===e)return this.arr[t];if(e<0&&(e+=this.cols),e<0||e>=this.cols)throw new Error("Column index out of bounds");return this.arr[t][e]}slice(t=0,e=0,s=this.rows-1,r=this.cols-1){s<0&&(s=this.rows+s),r<0&&(r=this.cols+r);let n=s-t,i=r-e,a=new Array(i);for(let s=0;s<n;s++){a[s]=[];for(let r=0;r<i;r++)a[s][r]=this.arr[s+t][r+e]}return this.arr=a,U(this.rows),this.rows=n,this.cols=i,this}reshape(t,e){if(t*e!==this.rows*this.cols)throw Error("size not matched");const s=this.rows;return Object.assign(this,new Z(t,e,this.arr.flat(1))),U(s),this}get T(){let t=[];for(let e=0;e<this.arr[0].length;e++){t[e]=[];for(let s=0;s<this.arr.length;s++)t[e][s]=this.arr[s][e]}return new Z(this.cols,this.rows,t.flat(1))}get det(){return(t=this).isSquare?1==t.rows?t.arr[0][0]:function t(e){if(2==e.length)return e.flat(1).some(t=>t?.isMatrix?.())?void console.warn("Tensors are not completely supported yet ..."):C(k(e[0][0],e[1][1]),k(e[0][1],e[1][0]));for(var s=0,r=0;r<e.length;r++){const n=T(k(v(-1,r),k(e[0][r],t(N(e,r)))));s=T(s,n)}return s}(t.arr):new Error("is not square matrix");var t}get inv(){return function(t){if(t.row!==t.cols)throw Error('is not a square matrix"');if(0===t.det)throw Error("determinant should not equal 0");const{arr:e}=t;if(e.length===e[0].length){var s=0,r=0,n=0,i=e.length,a=0,o=[],h=[];for(s=0;s<i;s+=1)for(o[o.length]=[],h[h.length]=[],n=0;n<i;n+=1)o[s][n]=s==n?1:0,h[s][n]=e[s][n];for(s=0;s<i;s+=1){if(0==(a=h[s][s])){for(r=s+1;r<i;r+=1)if(0!=h[r][s]){for(n=0;n<i;n++)a=h[s][n],h[s][n]=h[r][n],h[r][n]=a,a=o[s][n],o[s][n]=o[r][n],o[r][n]=a;break}if(0==(a=h[s][s]))return}for(n=0;n<i;n++)h[s][n]=h[s][n]/a,o[s][n]=o[s][n]/a;for(r=0;r<i;r++)if(r!=s)for(a=h[r][s],n=0;n<i;n++)h[r][n]-=a*h[s][n],o[r][n]-=a*o[s][n]}return new t.constructor(o)}}(this)}static eye(t){let e=new Z(t,t);for(let s=0;s<t;s++)for(let r=0;r<t;r++)e.arr[s][r]=s===r?1:0;return e}static zeros(t,e){let s=new Z(t,e);for(let n=0;n<t;n++)for(var r=0;r<e;r++)s.arr[n][r]=0;return s}static ones(t,e){let s=new Z(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=1;return s}static nums(t,e,s){let r=new Z(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)r.arr[n][t]=s;return r}static get random(){return{int:(t,e,s,r)=>new Z(t,e,w.sample.int(t*e,s,r)),float:(t,e,s)=>new Z(t,e,w.sample.float(t*e,s,b))}}get range(){return{map:(t,e,s,r)=>(this.arr=R(this.arr,t,e,s,r),this),norm:(t,e)=>(this.arr=j(this.arr,t,e),this),lerp:(t,e)=>(this.arr=O(this.arr,t,e),this),clamp:(t,e)=>(this.arr=I(this.arr,t,e),this)}}hstack(...t){const e=[this,...t].reduce((t,e)=>q(t,e));return Object.assign(this,e),U(this),this}vstack(...t){const e=[this,...t].reduce((t,e)=>B(t,e));return Object.assign(this,e),U(this),this}hqueue(...t){const e=[this,...t].reverse().reduce((t,e)=>q(t,e));return Object.assign(this,e),U(this),this}vqueue(...t){const e=[this,...t].reverse().reduce((t,e)=>B(t,e));return Object.assign(this,e),U(this),this}forEach(t){return this.arr.flat(1).forEach(t),this}forEachRow(t){return this.arr.forEach(t),this}forEachCol(t){return this.clone().T.forEachRow(t),this}map(t){const e=this.arr.flat(1).map(t);return new Z(this.rows,this.cols,e)}mapRows(t=()=>{}){return this.arr=this.arr.map(t),this}mapCols(t){return this.clone().T.mapRows(t).T}sort(t=()=>{}){const e=this.arr.flat(1).sort(t);return new Z(this.rows,this.cols,e)}shuffle(){return this.sort(()=>.5-Math.random())}sortRows(t=()=>{}){return this.arr=this.arr.map(e=>e.sort(t)),this}shuffleRows(){return this.sortRows(()=>.5-Math.random())}sortCols(t){return this.clone().T.sortRows(t).T}shuffleCols(){return this.sortCols(()=>.5-Math.random())}reduce(t,e){const s=e?this.arr.flat(1).reduce(t,e):this.arr.flat(1).reduce(t);return new Z([[s]])}reduceRows(t,e){const s=e?this.arr.map(s=>s.reduce(t,e)):this.arr.map(e=>e.reduce(t));return new Z(1,this.cols,s)}reduceCols(t,e){return this.T.reduceRows(t,e).T}filterRows(t){const e=this.arr.map(e=>e.some(e=>t(e))),s=[];let r;for(r=0;r<e.length;r++)e[r]&&s.push(this.arr[r]);return new Z(s)}filterCols(t){const e=this.T.filterRows(t);return new Z(e).T}every(t){return this.arr.flat(1).every(t)}everyRow(t){return this.arr.map(e=>e.every(t))}everyCol(t){return this.T.arr.map(e=>e.every(t))}some(t){return this.arr.flat(1).some(t)}someRow(t){return this.arr.map(e=>e.some(t))}someCol(t){return this.T.arr.map(e=>e.some(t))}get isSquare(){return this.rows===this.cols}get isSym(){if(!this.isSquare)return!1;for(let t=0;t<this.rows;t++)for(let e=t+1;e<this.cols;e++)if(this.arr[t][e]!==this.arr[e][t])return!1;return!0}get isAntiSym(){if(!this.isSquare)return!1;const t=this.rows;for(let e=0;e<t;e++){if(0!==this.arr[e][e])return!1;for(let s=e+1;s<t;s++)if(this.arr[e][s]!==-this.arr[s][e])return!1}return!0}get isDiag(){if(!this.isSquare)return!1;const t=this.rows;for(let e=0;e<t;e++)for(let s=e+1;s<t;s++)if(0!==this.arr[e][s]||0!==this.arr[s][e])return!1;return!0}get isOrtho(){return!!this.isSquare&&(this.isDiag&&(1==this.det||-1==this.det))}get isIdemp(){if(!this.isSquare)return!1;const t=this.rows,e=this.arr,s=[];for(let r=0;r<t;r++){s[r]=[];for(let n=0;n<t;n++){let i=0;for(let s=0;s<t;s++)i+=e[r][s]*e[s][n];s[r][n]=i}}for(let r=0;r<t;r++)for(let n=0;n<t;n++)if(s[r][n]!==e[r][n])return!1;return!0}get isUpperTri(){if(!this.isSquare)return!1;const t=this.rows;for(let e=1;e<t;e++)for(let t=0;t<e;t++)if(0!==this.arr[e][t])return!1;return!0}get isLowerTri(){if(!this.isSquare)return!1;const t=this.rows;for(let e=0;e<t-1;e++)for(let s=e+1;s<t;s++)if(0!==this.arr[e][s])return!1;return!0}toPrecision(t){for(let e=0;e<this.cols;e++)for(let s=0;s<this.rows;s++)this.arr[e][s]=+this.arr[e][s].toPrecision(t);return this}toFixed(t){for(let e=0;e<this.cols;e++)for(let s=0;s<this.rows;s++)this.arr[e][s]=+this.arr[e][s].toFixed(t);return this}splice(t,e,s,...r){}getRows(t,e=t+1){return this.slice(t,0,e,this.cols)}getCols(t,e=t+1){return this.slice(0,t,this.rows,e)}#t(t,...e){for(let r=0;r<e.length;r++){("number"==typeof e[r]||e[r]?.isComplex?.())&&(e[r]=Z.nums(this.rows,this.cols,e[r]));for(let n=0;n<this.rows;n++)for(var s=0;s<this.cols;s++)this.arr[n][s]=t(this.arr[n][s],e[r].arr[n][s])}return new Z(this.rows,this.cols,this.arr.flat(1))}add(...t){return this.#t(T,...t)}sub(...t){return this.#t(C,...t)}mul(...t){return this.#t(k,...t)}div(...t){return this.#t(S,...t)}modulo(...t){return this.#t(A,...t)}dot(t){for(var e=[],s=0;s<this.arr.length;s++){e[s]=[];for(var r=0;r<t.arr[0].length;r++){e[s][r]=0;for(var n=0;n<this.arr[0].length;n++)e[s][r]=T(e[s][r],k(this.arr[s][n],t.arr[n][r]))}}return new Z(this.arr.length,t.arr[0].length,e.flat(1))}pow(t){let e=this.clone(),s=this.clone();for(let r=0;r<t-1;r++)s=s.dot(e);return s}sum(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t=T(t,this.arr[e][s]);return t}prod(){let t=1;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t=k(t,this.arr[e][s]);return t}hasComplex(){return this.arr.flat(1/0).some(t=>t instanceof y)}get min(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.min(...this.arr[e]));return Math.min(...t)}get max(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.max(...this.arr[e]));return Math.max(...t)}get minRows(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.min(...this.arr[e]));return t}get maxRows(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.max(...this.arr[e]));return t}get minCols(){return this.hasComplex()&&console.error("Complex numbers are not comparable"),this.T.minRows}get maxCols(){return this.hasComplex()&&console.error("Complex numbers are not comparable"),this.T.maxRows}static fromVector(t){return new Z(t.length,1,t)}serialize(){const t=n(t=>t.serialize?.()||t,...this.arr);return JSON.stringify({type:"matrix",data:{rows:this.rows,cols:this.cols,arr:t}})}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));const{type:e,data:s}=t;if("matrix"!==e)return TypeError("Not a valid Matrix");let{arr:r}=s;return r=n(t=>{if("string"==typeof t){const e=JSON.parse(t),{type:s}=e;if("complex"===s)return y.deserialize(e)}return t},...r),new Z(r)}flip(){return this.flipeH().flipeV()}flipeH(){return this.arr=this.arr.map(t=>[...t].reverse()),U(this),this}flipeV(){return this.arr=this.arr.reverse(),U(this),this}}class V{constructor(t){this.cache={node:t}}isUINode(){return!0}get node(){return this.cache.node}}class W extends Array{constructor(...t){super(...t)}clear(){return this.length=0,this}getItemById(t){return this.find(e=>e.element.id===t)}getItemsByTagName(t){return this.filter(e=>e.element.tagName.toLowerCase()===t.toLowerCase())}getElementsByClassName(t){return this.filter(e=>e.element.classList?.contains(t))}querySelector(t){const e=globalThis?.document?.querySelector(t);return e&&this.find(t=>t.element===e)||null}querySelectorAll(t){const e=globalThis?.document?.querySelectorAll(t);return Array.from(e).map(t=>this.find(e=>e.element===t)).filter(Boolean)}}const H=new W,G={default:{target:null,render:!0,math:{mode:"deg"}},setDefault:function(t){const e=Object.keys(t),s=Object.values(t);for(let t=0;t<e.length;t++)this.default[e[t]]=s[t]},init:()=>{},renderingMode:"spa",isSSC:!1},K={store:new Map,index:0,register:function(t){this.store.set(this.index++,t)},reset(){this.index=0,this.store.clear()}},Y={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(t){}};class J{#e;#s;#r;#n;#i;#a;constructor(t=""){this.#e=new BroadcastChannel(t),this.#s=new Map,this.#r=new Map,this.#n="ziko-channel:"+1e17*Math.random(),this.#i=new Set([this.#n]),this.#a=new Set,this.#e.addEventListener("message",t=>{const{last_sent_event:e,userId:s,eventData:r,rooms:n}=t.data;if(s===this.#n)return;if(n&&n.length&&!n.some(t=>this.#a.has(t)))return;this.#i.add(s),this.#s=new Map(r);const i=this.#r.get(e);i&&i.forEach(({fn:t,rooms:s})=>{s&&0!==s.length&&n&&!n.some(t=>s.includes(t))||t(this.#s.get(e))})})}emit(t,e,s){return this.#s.set(t,e),"string"==typeof s&&(s=[s]),this.#e.postMessage({eventData:Array.from(this.#s.entries()),last_sent_event:t,userId:this.#n,rooms:s&&s.length?s:void 0}),this}on(t,e=console.log,s){return this.#r.has(t)||this.#r.set(t,[]),"string"==typeof s&&(s=[s]),this.#r.get(t).push({fn:e,rooms:s}),this}off(t,e){return this.#r.has(t)?(this.#r.set(t,this.#r.get(t).filter(t=>t.fn!==e)),this):this}once(t,e,s){const r=s=>{e(s),this.off(t,r)};return this.on(t,r,s),this}join(...t){return t.forEach(t=>this.#a.add(t)),this}leave(...t){return t.length?t.forEach(t=>this.#a.delete(t)):this.#a.clear(),this}close(){return this.#e.close(),this}}const X=t=>new J(t);class Q{static RESERVED_KEYS=new Set(["cache","items","set","add","remove","get","clear","onStorageUpdated"]);constructor(t,e,s,r=!0){this.cache={storage:t,globalKey:e,channel:r?X(`Ziko:useStorage-${e}`):null,oldItemKeys:new Set},this.#o(s,r)}get items(){const t=this.cache.storage.getItem(this.cache.globalKey);if(!t)return{};try{return JSON.parse(t)}catch{return{}}}#h(){const t=this.items,e=new Set(Object.keys(t));this.cache.oldItemKeys.forEach(t=>{e.has(t)||(delete this[t],this.cache.oldItemKeys.delete(t))});for(const e in t)Q.RESERVED_KEYS.has(e)||(this[e]=t[e],this.cache.oldItemKeys.add(e))}#o(t,e){e&&this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",()=>this.#h());null!==this.cache.storage.getItem(this.cache.globalKey)?this.#h():void 0!==t?this.set(t):this.#h()}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel&&this.cache.channel.emit("Ziko-Storage-Updated",t),this.#h(),this}add(t){return this.set({...this.items,...t})}remove(...t){const e={...this.items};return t.forEach(t=>delete e[t]),this.set(e)}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.#h(),this}onStorageUpdated(t){return this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",t),this}}var tt={store:new Map,index:0,session_storage:null,register:function(t){},update:function(t,e){}};const et=(t={})=>{const e={methods:{},events:{},style:{},attrs:{}};for(const[s,r]of Object.entries(t))"style"===s?e.style=r:s.startsWith("$")?e.methods[s.slice(1)]=r:/^on[A-Z]/.test(s)?e.events[s]=r:e.attrs[s]=r;return e};var st;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:H,__HYDRATION__:K,__State__:tt,__Config__:G,__CACHE__:Y,__PROVIDERS__:{}},st=__Ziko__,Object.defineProperties(st,{QueryParams:{get:function(){return function(t){const e={};return t.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,t=>{const[s,r]=t.split("=");e[s]=r}),e}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}}));class rt extends V{constructor(){super()}init({element:t,name:e,type:s,render:r,props:n={},items:i=[]}={}){if(this.target=globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body,"string"==typeof t)switch(s){case"html":t=globalThis?.document?.createElement(t);break;case"svg":t=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg",t);break;default:throw Error("Not supported")}else this.target=t?.parentElement;Object.assign(this.cache,{name:e,itemsTarget:this,isInteractive:!1,parent:null,isBody:!1,isRoot:!1,isHidden:!1,isFrozzen:!1,attributes:{},filters:{},temp:{}}),this.events={ptr:null,mouse:null,wheel:null,key:null,drag:null,drop:null,click:null,clipboard:null,focus:null,swipe:null,custom:null},this.observer={resize:null,intersection:null},t&&Object.assign(this.cache,{element:t}),this.items=new W,globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this],t&&r&&this?.render?.(),globalThis.__Ziko__.__UI__.push(this);const a=et(n);this.parsed_props=a,this.style(a.style),this.setAttr(a.attrs);Object.entries(a.events).forEach(([t,e])=>this[t](e.bind(this))),i.length>0&&this.append(...i)}get element(){return this.cache.element}[Symbol.iterator](){return this.items[Symbol.iterator]()}maintain(){for(let t=0;t<this.items.length;t++)Object.defineProperty(this,t,{value:this.items[t],writable:!0,configurable:!0,enumerable:!1})}isInteractive(){return this.cache.isInteractive}isUIElement(){return!0}}function nt(t,...e){e.forEach(e=>function(t,e){const s=Object.getOwnPropertyDescriptors(e);for(const e of Reflect.ownKeys(s)){const r=s[e];"get"in r||"set"in r||"function"!=typeof r.value?Object.defineProperty(Object.getPrototypeOf(t),e,r):"function"==typeof r.value&&(Object.getPrototypeOf(t).hasOwnProperty(e)||Object.defineProperty(Object.getPrototypeOf(t),e,r))}}(t,e))}var it=Object.freeze({__proto__:null,mount:function(t=this.target,e=0){return e>0?(setTimeout(()=>this.mount(t,0),e),this):(this.isBody||(t?.isUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element)),this)},unmount:function(t=0){return t>0?(setTimeout(()=>this.unmount(0),t),this):(this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target.children].includes(this.element)&&this.target.removeChild(this.element),this)}});const at=Symbol.for("ziko.stateGetter");function ot(t){const e={value:t,subscribers:new Set,paused:!1};function s(){return{value:e.value,_subscribe:t=>(e.subscribers.add(t),()=>e.subscribers.delete(t))}}s[at]=!0;return[s,function(t){e.paused||("function"==typeof t&&(t=t(e.value)),Object.is(t,e.value)||(e.value=t,e.subscribers.forEach(t=>t(e.value))))},{pause:()=>{e.paused=!0},resume:()=>{e.paused=!1},clear:()=>{e.subscribers.clear()},force:t=>{"function"==typeof t&&(t=t(e.value)),e.value=t,e.subscribers.forEach(t=>t(e.value))},getSubscribers:()=>new Set(e.subscribers)}]}const ht=t=>"function"==typeof t&&!0===t[at],lt=(t="")=>t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),ct=(t="")=>{if(0===t.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(t)};function ut(t,e){if(globalThis.SVGAElement&&this.element instanceof globalThis.SVGAElement&&(t=ct(t)?lt(t):t),!this?.attr[t]||this?.attr[t]!==e){if(ht(e)){e()._subscribe(e=>this.element?.setAttribute(t,e),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}var mt=Object.freeze({__proto__:null,_set_attrs_:ut,getAttr:function(t){return t=ct(t)?lt(t):t,this.element.attributes[t].value},removeAttr:function(...t){for(let e=0;e<t.length;e++)this.element?.removeAttribute(t[e]);return this},setAttr:function(t,e){if(t instanceof Object){const[s,r]=[Object.keys(t),Object.values(t)];for(let t=0;t<s.length;t++)r[t]instanceof Array&&(e[t]=r[t].join(" ")),ut.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),ut.call(this,t,e);return this},setContentEditable:function(t=!0){return this.setAttr("contenteditable",t),this}});class pt extends V{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const ft=(...t)=>new pt(...t);async function dt(t,e,...s){const r=this.itemsTarget.element,n=this.itemsTarget;if(this.cache.isFrozzen)return console.warn("You can't append new item to frozzen element"),this;for(let i=0;i<s.length;i++){if(["number","string"].includes(typeof s[i])&&(s[i]=ft(s[i])),s[i]instanceof Function&&ht(s[i])){const t=s[i]();s[i]=ft(t.value),t._subscribe(t=>s[i].element.textContent=t,s[i])}if("function"==typeof globalThis?.Node&&s[i]instanceof globalThis?.Node&&(s[i]=new this.constructor(s[i])),s[i]?.isUINode)s[i].cache.parent=this,r?.[t](s[i].element),s[i].target=this.itemsTarget.element,n.items[e](s[i]);else if(s[i]instanceof Promise){const a=await s[i];a.cache.parent=this,r?.[t](a.element),a.target=this.itemsTarget.element,n.items[e](a)}else s[i]instanceof Object&&(s[i]?.style&&this.style(s[i]?.style),s[i]?.attr&&Object.entries(s[i].attr).forEach(t=>this.setAttr(""+t[0],t[1])))}return this.maintain(),this}var gt=Object.freeze({__proto__:null,__addItem__:dt,after:function(t){return t?.isUIElement&&(t=t.element),this.itemsTarget.element?.after(t),this},append:function(...t){return dt.call(this,"append","push",...t),this},before:function(t){return t?.isUIElement&&(t=t.element),this.itemsTarget.element?.before(t),this},clear:function(){return this?.items?.forEach(t=>t.unmount()),this.itemsTarget.element.innerHTML="",this},insertAt:function(t,...e){const s=this.itemsTarget;if(t>=s.items.length)return this.append(...e);for(let r=0;r<e.length;r++)["number","string"].includes(typeof e[r])&&(e[r]=ft(e[r])),s.element?.insertBefore(e[r].element,s.items[t].element),s.items.splice(t,0,e[r]);return s.maintain(),this},prepend:function(...t){return this.__addItem__.call(this,"prepend","unshift",...t),this},remove:function(...t){const e=t=>{"number"==typeof t&&(t=this.items[t]),t?.isUIElement&&this.itemsTarget.element?.removeChild(t.element),this.items=this.items.filter(e=>e!==t)};for(let s=0;s<t.length;s++)e(t[s]);for(let t=0;t<this.items.length;t++)Object.assign(this,{[[t]]:this.items[t]});return this},replaceElementWith:function(t){return this.cache.element.replaceWith(t),this.cache.element=t,this}});var bt=Object.freeze({__proto__:null,at:function(t){return this.items.at(t)},find:function(t){return this.items.filter(t)},forEach:function(t){return this.items.forEach(t),this},map:function(t){return this.items.map(t)}});var wt=Object.freeze({__proto__:null,animate:function(t,{duration:e=1e3,iterations:s=1,easing:r="ease"}={}){return this.element?.animate(t,{duration:e,iterations:s,easing:r}),this},hide:function(){},show:function(){},size:function(t,e){return this.style({width:t,height:e})},style:function(t){if(!this.element?.style)return this;for(let e in t){const s=t[e];if(ht(s)){const t=s();Object.assign(this.element.style,{[e]:t.value}),t._subscribe(t=>{console.log({newValue:t}),Object.assign(this.element.style,{[e]:t})})}else Object.assign(this.element.style,{[e]:s})}return this}});class yt{constructor(t,e){this.cache={category:e,target:t,listeners:{},currentEvent:null,event:null,customEvents:new Set}}get event(){return this.cache.event}get target(){return this.cache.target}get element(){return this.cache.target.element}get currentEvent(){return this.cache.currentEvent}addListener(t,e,{preventDefault:s=!1,paused:r=!1}={}){return this.cache.listeners[t]={callback:s=>{this.cache.event=s,this.cache.listeners[t].preventDefault&&s.preventDefault(),this.cache.listeners[t].paused||(this.cache.currentEvent=t,e.call(this,this))},preventDefault:s,paused:r},this.element.addEventListener(t,this.cache.listeners[t].callback),this}removeListener(t){return this.element.removeEventListener(t,this.cache.listeners[t].callback),this}pause(t){return this.cache.listeners[t].paused=!0,this}resume(t){return this.cache.listeners[t].paused=!1,this}preventDefault(t){return this.cache.listeners[t].preventDefault=!0,this}useDefault(t){return this.cache.listeners[t].preventDefault=!1,this}}class xt extends Event{constructor(t,e){super("clickaway",{bubbles:!0,cancelable:!0}),this.originalEvent=t,this.targetElement=e}}function vt(t){function e(e){if(!t.contains(e.target)){const s=new xt(e,t);t.dispatchEvent(s)}}return globalThis?.document?.addEventListener("click",e),()=>globalThis?.document?.removeEventListener("click",e)}const Mt=(t,e=!1)=>{const s=t.element.getBoundingClientRect(),r=t.event;let n=r?.clientX-s.left|0,i=r?.clientY-s.top|0;if(e){const e=t.element.clientWidth,s=t.element.clientHeight;n=+(n/e*2-1).toFixed(8),i=+(i/s*-2+1).toFixed(8)}return{x:n,y:i}},_t="click",Et={onClick(t){return this.on("click",t,{category:_t})},onDblClick(t){return this.on("dblclick",t,{category:_t})},onClickAway(t){var e,s,r;return e=this,s=_t,r="clickaway",e.exp.events?.[s]?.cache?.customEvents?.has(r)||vt(this.element),this.on("clickaway",t,{category:_t,isCustom:!0})}},Tt="ptr",Ct={onPtrDown(t,e=!1){return this.on("pointerdown",t,{category:Tt,details_setter:t=>{const{x:s,y:r}=Mt(t,e);t.dx=s,t.dy=r,t.isDown=!0,t.isDragging=t.isMoving??!1}})},onPtrMove(t,e=!1){return this.on("pointermove",t,{category:Tt,details_setter:t=>{const{x:s,y:r}=Mt(t,e);t.mx=s,t.my=r,t.isMoving=!0,t.isDragging=t.isDown??!1}})},onPtrUp(t,e=!1){return this.on("pointerup",t,{category:Tt,details_setter:t=>{const{x:s,y:r}=Mt(t,e);t.ux=s,t.uy=r,t.isDown=!1,t.isMoving=!1,t.isDragging=!1}})}},kt="key",St={onKeyDown(t){return this.on("keydown",t,{category:kt,details_setter:t=>{t.kd=t.event.key}})},onKeyPress(t){return this.on("keypress",t,{category:kt,details_setter:t=>{t.kp=t.event.key}})},onKeyUp(t){return this.on("keydown",t,{category:kt,details_setter:t=>{t.ku=t.event.key}})}},At=(t,e)=>{let s=0;return(...r)=>{const n=(new Date).getTime();n-s<e||(s=n,t(...r))}};class jt extends CustomEvent{constructor(t,e,{bubbles:s=!0,cancelable:r=!0}={}){super(t,{detail:e,bubbles:s,cancelable:r})}}function Ot(t,{intersection:e=!0,resize:s=!0,threshold:r=0,throttleResize:n=100,throttleEnterExit:i=0}={}){let a,o;const h=e=>{for(let s of e){const{width:e,height:r}=s.contentRect;t.dispatchEvent(new jt("resizeview",{width:e,height:r,entry:s}))}},l=n>0?At(h,n):h,c=e=>{for(let s of e){const e=s.isIntersecting?"enterview":"exitview";t.dispatchEvent(new jt(e,s))}},u=i>0?At(c,i):c;return e&&(a=new IntersectionObserver(u,{threshold:r}),a.observe(t)),s&&(o=new ResizeObserver(l),o.observe(t)),()=>{a&&(a.unobserve(t),a.disconnect()),o&&(o.unobserve(t),o.disconnect())}}const It="view",Rt={onEnterView(t){return this.exp.events?.[It]||Ot(this.element),this.on("enterview",t,{category:It,isCustom:!0})},onExitView(t){return this.exp.events?.[It]||Ot(this.element),this.on("exitview",t,{category:It,isCustom:!0})},onResizeView(t){return this.exp.events?.[It]||Ot(this.element),this.on("resizeview",t,{category:It,isCustom:!0})}};class zt extends CustomEvent{constructor(t,e){super(t,{detail:e,bubbles:!0,cancelable:!0})}}let Ft=class extends rt{constructor({element:t,name:e="",type:s="html",render:r=__Ziko__.__Config__.default.render,props:n}={}){super(),this.exp={events:{}},nt(this,it,mt,gt,wt,bt,Ct,Et,St,Rt),t&&this.init({element:t,name:e,type:s,render:r,props:n})}on(t,e,{details_setter:s,category:r="global",isCustom:n=!1,preventDefault:i=!1}={}){t instanceof Array&&t.forEach(t=>this.on(t,e,{details_setter:s,category:r,isCustom:n,preventDefault:i})),r&&!this.exp.events.hasOwnProperty(r)&&(this.exp.events[r]=new yt(this,r)),n&&this.exp.events[r].cache.customEvents.add(t);const a=this.exp.events[r];return a.addListener(t,t=>{s&&s(a),e(t)},{preventDefault:i}),this}_off(t,e="global"){return this.exp.events[e].removeListener(t),this}get element(){return this.cache.element}get itemsTarget(){return this.cache.itemsTarget}get itemsTargetElement(){return this.itemsTarget.element}setItemsTarget(t){return this.cache.itemsTarget=t,this.items=t.items,this}isInteractive(){return this.cache.isInteractive}useClient(t){return this.cache.isInteractive||(this.element.setAttribute("data-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.register(()=>this),this.cache.isInteractive=!0),t&&this.element.setAttribute("data-hydration-directive",t),this}get st(){return this.cache.style}get attr(){return this.cache.attributes}get evt(){return this.events}get html(){return this.element.innerHTML}get text(){return this.element.textContent}get isBody(){return this.element===globalThis?.document.body}get parent(){return this.cache.parent}get width(){return this.element.getBoundingClientRect().width}get height(){return this.element.getBoundingClientRect().height}get top(){return this.element.getBoundingClientRect().top}get right(){return this.element.getBoundingClientRect().right}get bottom(){return this.element.getBoundingClientRect().bottom}get left(){return this.element.getBoundingClientRect().left}};const Pt=t=>"object"!=typeof t&&"function"!=typeof t||null===t,Dt=t=>(...e)=>{const s=e[0];return s?.isUIElement?.()||Pt(s)?new t({},...e):new t(s,...e.slice(1))};const Lt=["a","abb","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","ipnut","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],$t=["svg","g","defs","symbol","use","image","switch","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","textPath","altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","linearGradient","radialGradient","pattern","solidColor","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncR","feFuncG","feFuncB","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","animate","animateMotion","animateTransform","set","script","desc","title","metadata","foreignObject"],Ut=["math","annotation","merror","mfrac","mi","mprescripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","semantics","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"],Nt=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return Lt.includes(r)&&(s="html"),$t.includes(r)&&(s="svg"),Ut.includes(r)&&(s="mathml"),(...t)=>0===t.length?new Ft({element:r,name:r,type:s}):["string","number"].includes(typeof t[0])||t[0]instanceof Ft||ht(t[0])||t[0]instanceof HTMLElement?new Ft({element:r,name:r,type:s}).append(...t):new Ft({element:r,type:s,props:t.shift()}).append(...t)}});class qt extends Ft{constructor(...t){super({element:"div",name:"view"}),this.append(...t)}}function Bt(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function Zt(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function Vt(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function Wt(t){return Vt(-t)}class Ht extends Ft{constructor({tag:t="div",orientation:e="h",order:s,w:r="100%",h:n="100%"}={}){super({element:t,name:"Flex"}),this.direction="cols",this.style({display:"flex"})}isFlex(){return!0}responsify(t,e=!0){return this.wrap(e),this.element.clientWidth<t?this.vertical():this.horizontal(),this}setSpaceAround(){return this.style({justifyContent:"space-around"}),this}setSpaceBetween(){return this.style({justifyContent:"space-between"}),this}setBaseline(){return this.style({alignItems:"baseline"}),this}gap(t){return"row"===this.direction?this.style({columnGap:t}):"column"===this.direction&&this.style({rowGap:t}),this}wrap(t="wrap"){return this.style({flexWrap:"string"==typeof t?t:["no-wrap","wrap","wrap-reverse"][+t]}),this}_justifyContent(t="center"){return this.style({justifyContent:t}),this}vertical(t,e,s=1){return Bt.call(this,s),this.style({alignItems:"number"==typeof t?Vt.call(this,t):t,justifyContent:"number"==typeof e?Wt.call(this,e):e}),this}horizontal(t,e,s=1){return Zt.call(this,s),this.style({alignItems:"number"==typeof e?Wt.call(this,e):e,justifyContent:"number"==typeof t?Vt.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}class Gt extends rt{constructor({element:t,name:e,type:s,render:r}){super({element:t,name:e,type:s,render:r})}}class Kt extends Gt{constructor(t,e){super({element:"div",name:"suspense"}),this.setAttr({dataTemp:"suspense"}),this.fallback_ui=t,this.append(t),(async()=>{try{const s=await e();t.unmount(),this.append(s)}catch(t){console.log({error:t})}})()}}class Yt extends Ft{#l=new WeakMap;constructor({activeIndex:t=0}={},...e){super({element:"div"}),this.style({display:"contents"}),this.states={activeIndex:t},this.append(...e),requestAnimationFrame(()=>{this.render()})}get activeItem(){return this.items[this.states.activeIndex]}render(){this.items.forEach((t,e)=>{const s=getComputedStyle(t.element).display;this.#l.set(t,s),e!==this.states.activeIndex&&t.style({display:"none"})})}get DS(){return this.#l}next(t=1){return this.activate(this.states.activeIndex+t)}previous(t=1){return this.activate(this.states.activeIndex-t)}activate(t){if(!this.items.length)return this;const e=this.items.at(this.states.activeIndex);e&&e.style({display:"none"});const s=this.items.length;this.states.activeIndex=(t%s+s)%s;const r=this.items.at(this.states.activeIndex);if(r){const t=this.#l.get(r)||"block";r.style({display:"none"===t?"block":t})}return this}}const Jt=Dt(Yt);class Xt extends Ft{constructor(...t){super({element:document.createDocumentFragment()}),this.append(...t)}isFragment(){return!0}}class Qt extends Xt{constructor({each:t,fallback:e,mapFn:s=()=>{}}={}){super(),this.config={each:t,fallback:e,mapFn:s},this.append(...this.config.each.map((t,e)=>this.config.mapFn(t,e)))}}class te extends Ft{constructor(t,e){super(),this.key=t,this.cases=e,this.init()}init(){Object.values(this.cases).filter(t=>t!=this.current).forEach(t=>t.unmount()),super.init(this.current.element)}get current(){const t=Object.keys(this.cases).find(t=>t==this.key)??"default";return this.cases[t]}updateKey(t){return this.key=t,this.replaceElementWith(this.current.element),this}}class ee extends Ft{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if(globalThis?.DOMParser){const e=(new DOMParser).parseFromString(`<div>${t}</div>`,"text/html");return e.body.firstChild.style.display="contents",e.body.firstChild}}(t)),this.style({display:"contents"})}}class se extends Ft{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if("undefined"!=typeof DOMParser){const e=(new DOMParser).parseFromString(t.trim(),"image/svg+xml").documentElement;if("parsererror"===e.nodeName)throw new Error("Invalid SVG string");if(e.hasAttribute("xmlns"))return e;const{children:s,attributes:r}=e,n=document.createElementNS("http://www.w3.org/2000/svg","svg");for(let{name:t,value:e}of r)n.setAttribute(t,e);return n.append(...s),globalThis.svg=e,globalThis.children=s,globalThis.attributes=r,globalThis.element=n,n}throw new Error("DOMParser is not available in this environment")}(t)),this.style({display:"contents"})}}class re extends Ft{constructor(t,e){super("canvas","canvas"),this.ctx=this.element?.getContext("2d"),this.style({border:"1px red solid"}),this.transformMatrix=new Z([[1,0,0],[0,1,0],[0,0,1]]),this.axisMatrix=new Z([[-10,-10],[10,10]]),requestAnimationFrame(()=>this.resize(t,e),0),this.on("sizeupdated",()=>this.adjust())}get Xmin(){return this.axisMatrix[0][0]}get Ymin(){return this.axisMatrix[0][1]}get Xmax(){return this.axisMatrix[1][0]}get Ymax(){return this.axisMatrix[1][1]}get ImageData(){return this.ctx.getImageData(0,0,c.Width,c.Height)}draw(t=!0){return t?(this.clear(),this.items.forEach(t=>{t.parent=this,t.draw(this.ctx)})):(this.items.at(-1).parent=this,this.items.at(-1).draw(this.ctx)),this.maintain(),this}applyTransformMatrix(){return this.ctx.setTransform(this.transformMatrix[0][0],this.transformMatrix[1][0],this.transformMatrix[0][1],this.transformMatrix[1][1],this.transformMatrix[0][2],this.transformMatrix[1][2]),this}resize(t,e){return this.size(t,e),this.lineWidth(),this.view(this.axisMatrix[0][0],this.axisMatrix[0][1],this.axisMatrix[1][0],this.axisMatrix[1][1]),this.emit("sizeupdated"),this}adjust(){return this.element.width=this.element?.getBoundingClientRect().width,this.element.height=this.element?.getBoundingClientRect().height,this.view(this.axisMatrix[0][0],this.axisMatrix[0][1],this.axisMatrix[1][0],this.axisMatrix[1][1]),this}view(t,e,s,r){return this.transformMatrix[0][0]=this.width/(s-t),this.transformMatrix[1][1]=-this.height/(r-e),this.transformMatrix[0][2]=this.width/2,this.transformMatrix[1][2]=this.height/2,this.axisMatrix=new Z([[t,e],[s,r]]),this.applyTransformMatrix(),this.clear(),this.lineWidth(1),this.draw(),this}reset(){return this.ctx.setTransform(1,0,0,0,0,0),this}append(t){return this.items.push(t),this.draw(!1),this}background(t){this.ctx.fillStyle=t,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.fillRect(0,0,this.width,this.height),this.applyTransformMatrix(),this.draw()}lineWidth(t){return this.ctx.lineWidth=t/this.transformMatrix[0][0],this}getImageData(t=0,e=0,s=this.width,r=this.height){return this.ctx.getImageData(t,e,s,r)}clear(){return this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.width,this.height),this.applyTransformMatrix(),this}clone(){console.log(this.width);const t=new re;return t.items=this.items,t.transformMatrix=this.transformMatrix,t.axisMatrix=this.axisMatrix,Object.assign(t.cache,{...this.cache}),this.size(this.element.style.width,this.element.style.width),this.applyTransformMatrix(),this.draw(),this.adjust(),t}toImage(){return this.img=document?.createElement("img"),this.img.src=this.element?.toDataURL("image/png"),this}toBlob(){this.element.toBlob(function(t){var e=document?.createElement("img"),s=URL.createObjectURL(t);e.onload=function(){URL.revokeObjectURL(s)},e.src=s,console.log(e)})}zoomIn(){}zoomOut(){}undo(t){}redo(t){}stream(){}}class ne extends Ft{constructor(t=360,e=300){super("svg","svg"),this.style({border:"1px black solid"}),this.size(t,e),this.view(-10,-10,10,10)}size(t,e){return this.setAttr({width:t,height:e}),this}view(t,e,s,r){let n=Math.abs(s-t),i=Math.abs(r-e);return this.setAttr("viewBox",[t,e,n,i].join(" ")),this.st.scaleY(-1),this}add(...t){for(let e=0;e<t.length;e++)this.element.append(t[e].element),this.items.push(t[e]);return this.maintain(),this}remove(...t){for(let e=0;e<t.length;e++)this.element?.removeChild(t[e].element),this.items=this.items.filter(e=>!t);return this.maintain(),this}mask(){}toString(){return(new XMLSerializer).serializeToString(this.element)}btoa(){return btoa(this.toString())}toImg(){return"data:image/svg+xml;base64,"+this.btoa()}toImg2(){return"data:image/svg+xml;charset=utf8,"+this.toString().replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("#","%23").replaceAll('"',"'")}}const{PI:ie,sqrt:ae,cos:oe,sin:he,acos:le,pow:ce}=Math,ue=t=>t,me=(t,e=7.5625,s=2.75)=>t<1/s?e*t*t:t<2/s?e*(t-=1.5/s)*t+.75:t<2.5/s?e*(t-=2.25/s)*t+.9375:e*(t-=2.625/s)*t+.984375;class pe{constructor(t,{ease:e=ue,step:s=50,t0:r=0,start:n=!0,duration:i=3e3}={}){this.callback=t,this.state={isRunning:!1,animationId:null,startTime:null,ease:e,step:s,autoStart:n,duration:i},this.t=0,this.tx=0,this.ty=0,this.i=0,this.state.autoStart&&this.start()}#c=()=>{this.t+=this.state.step,this.i++,this.tx=R(this.t,0,this.state.duration,0,1),this.ty=this.state.ease(this.tx),this.callback(this),this.t>=this.state.duration&&(clearInterval(this.state.animationId),this.state.isRunning=!1)};#u(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#c,this.state.step)),this}start(){return this.#u(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#u(!1)}stop(){return this.pause(),this.reset(!1),this}reset(t=!0){return this.t=0,this.tx=0,this.ty=0,this.i=0,t&&this.start(),this}}class fe{constructor(t,e,s=1/0,r){this.ms=e,this.fn=t,this.count=s,this.frame=1,this.id=null,this.running=!1,r&&this.start()}start(){return this.running||(this.running=!0,this.frame=1,this.id=setInterval(()=>{this.frame>this.count?this.stop():(this.fn.call(null,this),this.frame++)},this.ms)),this}stop(){return this.running&&(this.running=!1,clearInterval(this.id),this.id=null),this}isRunning(){return this.running}}class de extends fe{constructor(t=1e3/60){super(t,()=>this._tick()),this.elapsed=0,this._lastTime=performance.now(),this._callbacks=new Set}_tick(){const t=performance.now(),e=t-this._lastTime;this.elapsed+=e,this._lastTime=t;for(const t of this._callbacks)t({elapsed:this.elapsed,delta:e})}onTick(t){return this._callbacks.add(t),()=>this._callbacks.delete(t)}reset(){this.elapsed=0,this._lastTime=performance.now()}pause(){super.stop()}resume(){this._lastTime=performance.now(),super.start()}}class ge{constructor(t=[],{repeat:e=1,loop:s=!1}={}){this.tasks=t,this.repeat=e,this.loop=s,this.stopped=!1,this.running=!1,this.onStart=null,this.onTask=null,this.onEnd=null}async run(){if(this.running)return;this.running=!0,this.stopped=!1,this.onStart&&this.onStart();let t=this.repeat;do{for(const t of this.tasks){if(this.stopped)return;if(Array.isArray(t))await Promise.all(t.map(({fn:t,delay:e=0})=>new Promise(async s=>{e>0&&await new Promise(t=>setTimeout(t,e)),this.onTask&&this.onTask(t),await t(),s()})));else{const{fn:e,delay:s=0}=t;s>0&&await new Promise(t=>setTimeout(t,s)),this.onTask&&this.onTask(e),await e()}}}while(this.loop&&!this.stopped&&(t===1/0||t-- >1));!this.stopped&&this.onEnd&&this.onEnd(),this.running=!1}stop(){this.stopped=!0,this.running=!1}addTask(t){this.tasks.push(t)}clearTasks(){this.tasks=[]}}class be{constructor(t,{step:e=1e3,t0:s=0,t1:r=1/0,autoplay:n=!0}={}){this.callback=t,this.cache={isRunning:!1,id:null,last_tick:null,step:e,t0:s,t1:r,autoplay:n,pauseTime:null,frame:0},n&&(s?this.startAfter(s):this.start(),r!==1/0&&this.stopAfter(r))}get frame(){return this.cache.frame}get elapsed(){return this.cache.elapsed}start(){return this.cache.isRunning||(this.cache.frame=0,this.cache.isRunning=!0,this.cache.last_tick=Date.now(),this.animate()),this}pause(){return this.cache.isRunning&&(clearTimeout(this.cache.id),this.cache.isRunning=!1,this.cache.pauseTime=Date.now()),this}resume(){if(!this.cache.isRunning){if(this.cache.isRunning=!0,this.cache.pauseTime){const t=Date.now()-this.cache.pauseTime;this.cache.last_tick+=t}this.animate()}return this}stop(){return this.pause(),this.cache.frame=0,this}startAfter(t=1e3){return setTimeout(()=>this.start(),t),this}stopAfter(t=1e3){return setTimeout(()=>this.stop(),t),this}animate=()=>{if(this.cache.isRunning){const t=Date.now(),e=t-this.cache.last_tick;e>=this.cache.step&&(this.cache.elapsed=t-(this.cache.t0||0),this.callback(this),this.cache.frame++,this.cache.last_tick=t-e%this.cache.step),this.cache.id=setTimeout(this.animate,0)}}}const we=(t,e=",")=>t.trim().trimEnd().split("\n").map(t=>t.split(e)),ye=(t,e=",")=>{const[s,...r]=we(t,e);return r.map(t=>{const e={};return s.forEach((s,r)=>{e[s]=t[r]}),e})},xe=t=>t instanceof Array?[Object.keys(t[0]),...t.map(t=>Object.values(t))]:[Object.keys(t)],ve=(t,e)=>xe(t).map(t=>t.join(e)).join("\n"),Me=(t,e=",")=>ve(t instanceof Object?t:JSON.parse(t),e),_e=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach(t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=_e(t,`${e} `);s.push(...r)}else s.push(`${e}- ${t}`)});else for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];if("object"==typeof n&&null!==n){s.push(`${e}${r}:`);const t=_e(n,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${n}`)}return s},Ee=(t,e="")=>_e(t,e).join("\n"),Te=(t,e)=>Ee(t instanceof Object?t:JSON.parse(t),e),Ce=(t,e=1)=>{let s="";for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];s+="\n"+" ".repeat(e)+`<${r}>`,s+="object"==typeof n?Ce(n,e+2):`${n}`,s+=`</${r}>`}return s.trim()},ke=t=>(new XMLSerializer).serializeToString(t),Se=t=>btoa(ke(t)),Ae=t=>"data:image/svg+xml;base64,"+Se(t),je=(t,e=0)=>{t=Oe(t);let s="";const r=" ".repeat(e);for(let n in t)if("object"==typeof t[n]){s+=`${r}${n} {\n`;const i=t[n];for(let t in i)"object"==typeof i[t]?s+=je({[t]:i[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}: ${i[t]};\n`;s+=`${r}}\n`}return s};function Oe(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce((e,s)=>(e[s.trim()]=Oe(t[s]),e),Array.isArray(t)?[]:{})}function Ie(t){const e={type:t.nodeName,attributes:{},children:[]};for(let s=0;s<t.attributes.length;s++){const r=t.attributes[s];e.attributes[r.name]=r.value}for(let s=0;s<t.childNodes.length;s++){const r=t.childNodes[s];r.nodeType===Node.ELEMENT_NODE?e.children.push(Ie(r)):r.nodeType===Node.TEXT_NODE&&(e.text=r.textContent.trim())}return e}class Re{constructor({head:t=null,wrapper:e=null,target:s=null}){this.head=t,this.wrapper=e,this.target=s,this.init()}get isZikoApp(){return!0}init(){this.head&&this.setHead(this.head),this.wrapper&&this.setWrapper(this.wrapper),this.target&&this.setTarget(this.target),this.wrapper&&this.target&&this.wrapper.mount(this.target)}setTarget(t){return t instanceof HTMLElement?this.target=t:"string"==typeof t&&(this.target=globalThis?.document?.querySelector(t)),this}setWrapper(t){return t?.isUIElement?this.wrapper=t:"function"==typeof t&&(this.wrapper=t()),this}}function ze(t){return/:\w+/.test(t)}class Fe extends Re{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",ft("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.mount(location.pathname)}clear(){return[...this.routes].forEach(t=>{!ze(t[0])&&t[1]?.isUIElement&&t[1].unmount()}),this}mount(t){const[e,s]=[...this.routes].find(e=>function(t,e){const s=t.split("/"),r=e.split("/");if(s.length!==r.length)return!1;for(let t=0;t<s.length;t++){const e=s[t],n=r[t];if(!e.startsWith(":")&&e!==n)return!1}return!0}(e[0],t));let r;if(ze(e)){const n=function(t,e){const s=t.split("/"),r=e.split("/"),n={};if(s.length!==r.length)return n;for(let t=0;t<s.length;t++){const e=s[t],i=r[t];if(e.startsWith(":"))n[e.slice(1)]=i;else if(e!==i)return{}}return n}(e,t);r=s.call(this,n)}else s?.isUIElement&&s.mount(this.wrapper),"function"==typeof s&&(r=s());return r?.isUIElement&&r.mount(this.wrapper),r instanceof Promise&&r.then(t=>t.mount(this.wrapper)),globalThis.history.pushState({},"",t),this}}const Pe=({head:t,wrapper:e,target:s,routes:r})=>new Fe({head:t,wrapper:e,target:s,routes:r});function De(t,e="./src/pages",s=["js","ts"]){"/"===e.at(-1)&&(e=e.slice(0,-1));const r=t.replace(/\\/g,"/").replace(/\[(\w+)\]/g,"$1/:$1").split("/"),n=e.split("/"),i=r.indexOf(n.at(-1));if(-1!==i){const t=r.slice(i+1),e=r.at(-1),n="index.js"===e||"index.ts"===e,a=s.some(t=>e===`.${t}`||e.endsWith(`.${t}`));if(n)return"/"+(t.length>1?t.slice(0,-1).join("/"):"");if(a)return"/"+t.join("/").replace(/\.(js|ts)$/,"")}return""}const Le=(t,...e)=>{const s=e.map(e=>null===e||["number","string","boolean","bigint","undefined"].includes(typeof e)||e?.__mapfun__?t(e):e instanceof Array?e.map(e=>Le(t,e)):ArrayBuffer.isView(e)?e.map(e=>t(e)):e instanceof Set?new Set(Le(t,...e)):e instanceof Map?new Map([...e].map(e=>[e[0],Le(t,e[1])])):e.isMatrix?.()?new e.constructor(e.rows,e.cols,Le(e.arr.flat(1))):e instanceof Object?Object.fromEntries(Object.entries(e).map(e=>[e[0],Le(t,e[1])])):void 0);return 1==s.length?s[0]:s};class $e{#m;#p=new Map;#f=0;constructor(){const t=new Blob(['\n this.onmessage = function(e) {\n const { id, funStr, args, close } = e.data;\n try {\n const func = new Function("return " + funStr)();\n const result = func(...args);\n postMessage({ id, result });\n } catch (error) {\n postMessage({ id, error: error.message });\n } finally {\n if (close) self.close();\n }\n }\n '],{type:"text/javascript"});this.#m=new Worker(URL.createObjectURL(t)),this.#m.addEventListener("message",t=>{const{id:e,result:s,error:r}=t.data,n=this.#p.get(e);n&&(n(s,r),this.#p.delete(e))})}call(t,e,s=[],r=!0){if("function"!=typeof t)throw new TypeError("func must be a function");const n=++this.#f;return this.#p.set(n,e),this.#m.postMessage({id:n,funStr:t.toString(),args:s,close:r}),this}terminate(){this.#m.terminate()}}class Ue{constructor(t=10){this.events={},this.maxListeners=t}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),this.events[t].length>this.maxListeners&&console.warn(`Warning: Possible memory leak. Event '${t}' has more than ${this.maxListeners} listeners.`),this}once(t,e){const s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s)}off(t,e){const s=this.events[t];if(!s)return this;const r=s.indexOf(e);return-1!==r&&s.splice(r,1),this}emit(t,e){const s=this.events[t];return!!s&&([...s].forEach(s=>{try{s(e)}catch(e){console.error(`Error in listener for '${t}':`,e)}}),!0)}remove(t){return delete this.events[t],this}clear(){return this.events={},this}setMaxListeners(t){return this.maxListeners=t,this}}const Ne=t=>new Ue(t);class qe{#d;#g;#b=null;constructor(t=[],e=()=>{}){this.#d=t,this.#g=e,this.#o()}#w(){return this.#d.some(({query:t})=>globalThis.matchMedia(t).matches)}#o(){this.#d.forEach(({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.#w();s.matches?(e(),this.#b=e):t||this.#b===this.#g||(this.#g(),this.#b=this.#g)};r(),s.addEventListener("change",r)})}}class Be{constructor(t=document.title,e=!0){this.cache={emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.emitter=Ne(),this}setTitle(t){return t!==document.title&&(document.title=t,this.cache.emitter&&this.cache.emitter.emit("ziko:title-changed",t)),this}get current(){return document.title}onChange(t){return this.cache.emitter&&this.cache.emitter.on("ziko:title-changed",t),this}}class Ze{constructor(t,{namespace:e="Ziko",ValidateCssProps:s=!1}={}){this.currentPropsMap=t,this.namespace=e,this.ValidateCssProps=s,this.use(t)}use(t){return this.ValidateCssProps&&function(t){const e=new Set(Object.keys(document.documentElement.style));for(const s in t)if(!e.has(s))throw new Error(`Invalid CSS property: "${s}"`)}(t),this.currentPropsMap=t,this.#h(),this}#h(){const t=globalThis?.document?.documentElement?.style;for(const e in this.currentPropsMap){const s=this.namespace?`--${this.namespace}-${e}`:`--${e}`;t.setProperty(s,this.currentPropsMap[e]),Object.defineProperty(this,e,{value:`var(${s})`,writable:!0,configurable:!0,enumerable:!1})}}}const Ve=t=>Object.fromEntries(new URLSearchParams(globalThis?.location?.search));let{sqrt:We,cos:He,sin:Ge,exp:Ke,log:Ye,cosh:Je,sinh:Xe}=Math;for(const t of Object.getOwnPropertyNames(Math)){const e=Math[t];"function"==typeof e&&(Math[t]=new Proxy(e,{apply(e,s,r){const n=r[0];if("number"==typeof n||0===r.length)return e.apply(s,r);if(n?.isComplex?.()){const{a:t,b:i,z:a,phi:o}=n,h=(t,e)=>new n.constructor(t,e);switch(e.name){case"abs":return n.z;case"sqrt":return h(We(a)*He(o/2),We(a)*Ge(o/2));case"log":return h(Ye(a),o);case"exp":return h(Ke(t)*He(i),Ke(t)*Ge(i));case"cos":return h(He(t)*Je(i),-Ge(t)*Xe(i));case"sin":return h(Ge(t)*Je(i),He(t)*Xe(i));case"tan":{const e=He(2*t)+Je(2*i);return h(Ge(2*t)/e,Xe(2*i)/e)}case"cosh":return h(Je(t)*He(i),Xe(t)*Ge(i));case"sinh":return h(Xe(t)*He(i),Je(t)*Ge(i));case"tanh":{const e=Je(2*t)+He(2*i);return h(Xe(2*t)/e,Ge(2*i)/e)}default:return e.apply(s,r)}}throw new TypeError(`Math.${t} expects only numbers`)}}))}globalThis?.document&&document?.addEventListener("DOMContentLoaded",__Ziko__.__Config__.init()),t.App=({head:t,wrapper:e,target:s})=>new Re({head:t,wrapper:e,target:s}),t.Canvas=(t,e)=>new re(t,e),t.ClickAwayEvent=xt,t.ClickListeners=Et,t.Clock=de,t.CloneElement=t=>new t.__proto__.constructor,t.Complex=y,t.E=s,t.EPSILON=r,t.EventController=yt,t.FileBasedRouting=async function(t){const e=Object.keys(t),s=function(t){if(0===t.length)return"";const e=t.map(t=>t.split("/")),s=Math.min(...e.map(t=>t.length));let r=[];for(let t=0;t<s;t++){const s=e[0][t];if(!e.every(e=>e[t]===s||e[t].startsWith("[")))break;r.push(s)}return r.join("/")+(r.length?"/":"")}(e),r={};for(let n=0;n<e.length;n++){const i=await t[e[n]](),a=await i.default;Object.assign(r,{[De(e[n],s)]:a})}return Pe({target:document.body,routes:{"/":()=>{},...r},wrapper:Nt.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new Ht(e).append(...t)},t.For=({each:t,fallback:e,mapFn:s}={})=>new Qt({each:t,fallback:e,mapFn:s}),t.Fragment=(...t)=>new Xt(...t),t.HTMLWrapper=t=>new ee(t),t.KeyListeners=St,t.Matrix=Z,t.PI=e,t.PtrListeners=Ct,t.Random=w,t.SPA=Pe,t.STATE_GETTER=at,t.SVGWrapper=t=>new se(t),t.Scheduler=(t,{repeat:e=null}={})=>new ge(t,{repeat:e}),t.Suspense=(t,e)=>new Kt(t,e),t.Svg=(t,e)=>new ne(t,e),t.Swap=Jt,t.SwipeEvent=zt,t.Switch=({key:t,cases:e})=>new te(t,e),t.Tick=fe,t.TimeAnimation=pe,t.TimeLoop=be,t.TimeScheduler=ge,t.UICanvas=re,t.UIElement=Ft,t.UIFlex=Ht,t.UIFragment=Xt,t.UIHTMLWrapper=ee,t.UINode=V,t.UISVGWrapper=se,t.UISuspense=Kt,t.UISvg=ne,t.UISwap=Yt,t.UISwitch=te,t.UIView=qt,t.UseRoot=Ze,t.UseThread=$e,t.View=(...t)=>new qt(...t),t.ViewEvent=jt,t.ViewListeners=Rt,t.ZikoApp=Re,t.ZikoSPA=Fe,t.ZikoUIText=pt,t.abs=(...t)=>n(t=>t.isComplex?.()?t.z:Math.abs(t),...t),t.accum_max=t=>{let e=[],s=-1/0;for(let r of t)s=Math.max(s,r),e.push(s);return e},t.accum_min=t=>{let e=[],s=1/0;for(let r of t)s=Math.min(s,r),e.push(s);return e},t.accum_prod=(...t)=>{let e,s=[],r=1,n=t.length;for(e=0;e<n;e++)r=k(r,t[e]),s.push(r);return s},t.accum_product=t=>{let e=[],s=1;for(let r of t)s*=r,e.push(s);return e},t.accum_sum=g,t.acos=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t,r=Math.hypot(e+1,s),n=Math.hypot(e-1,s);return globalThis.Rp=r,globalThis.Rm=n,new t.constructor(Math.acos((r-n)/2),-Math.acosh((r+n)/2)).toFixed(8)}return+Math.acos(t).toFixed(8)},...t),t.acosh=(...t)=>n(t=>t?.isComplex?_(t.clone().add(M(t.clone().mul(t.clone()).sub(1)))):+Math.acosh(t).toFixed(8),...t),t.acot=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t;return new t.constructor(Math.atan(2*e/(e**2+(s-1)*(s+1)))/2,Math.log((e**2+(s-1)**2)/(e**2+(s+1)**2))/4).toFixed(8)}return+(Math.PI/2-Math.atan(t)).toFixed(8)},...t),t.add=T,t.add_class=(t,e)=>t.element.className=t.element.className.replace(/\s+$/gi,"")+" "+e,t.add_vendor_prefix=function(t){const e=t.slice(0,1).toUpperCase()+t.slice(1),s=["Webkit","Moz","O","ms"];for(let t=0,r=s.length;t<r;t++){const r=s[t];if(void 0!==(globalThis?.document?.body).style[r+e])return r+e}return t},t.and=D,t.animation=(t,{ease:e,t0:s,t1:r,start:n,duration:i}={})=>new pe(t,{ease:e,t0:s,t1:r,start:n,duration:i}),t.apply_fun=i,t.arc=t=>1-he(le(t)),t.asin=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t,r=Math.hypot(e+1,s),n=Math.hypot(e-1,s);return new t.constructor(Math.asin((r-n)/2),Math.acosh((r+n)/2)).toFixed(8)}return+Math.asin(t).toFixed(8)},...t),t.asinh=(...t)=>n(t=>t?.isComplex?_(t.clone().add(M(t.clone().mul(t.clone()).add(1)))):+Math.asinh(t).toFixed(8),...t),t.atan=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t;return new t.constructor(Math.atan(2*e/(1-e**2-s**2))/2,Math.log((e**2+(1+s)**2)/(e**2+(1-s)**2))/4).toFixed(8)}return+Math.atan(t).toFixed(8)},...t),t.atan2=z,t.atanh=(...t)=>n(t=>+Math.atanh(t).toFixed(8),...t),t.back=(t,e=1)=>t**2*((e+1)*t-e),t.binomial=(t,e)=>{if(t!==Math.floor(t))return TypeError("n must be an integer");if(e!==Math.floor(e))return TypeError("k must be an integer");if(t<0)return TypeError("n must be non-negative");if(e<0||t<0||e>t)return 0;e>t-e&&(e=t-e);let s,r=1;for(s=0;s<e;s++)r=r*(t-s)/(s+1);return r},t.call_with_optional_props=Dt,t.cbrt=(...t)=>n(t=>t.isComplex?.()?new t.constructor({z:t.z**(1/3),phi:t.phi/3}).toFixed(8):+Math.cbrt(t).toFixed(8),...t),t.ceil=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.ceil(t.a),Math.ceil(t.b)):Math.ceil(t),...t),t.clamp=I,t.clock=t=>new de(t),t.cloneUI=t=>Object.assign(Object.create(Object.getPrototypeOf(t)),t),t.complex=x,t.contraharmonic_mean=(...t)=>{let e,s=0,r=0,n=t.length;for(e=0;e<n;e++)s+=t[e]**2,r+=t[e];return s/r},t.cos=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.cos(t.a)*Math.cosh(t.b),-Math.sin(t.a)*Math.sinh(t.b)).toFixed(8):+Math.cos(t).toFixed(8),...t),t.cosh=(...t)=>n(t=>t?.isComplex?new t.constructor(Math.cosh(t.a)*Math.cos(t.b),Math.sinh(t.a)*Math.sin(t.b)).toFixed(8):+Math.cosh(t).toFixed(8),...t),t.coth=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t,r=Math.sinh(e)**2*Math.cos(s)**2+Math.cosh(e)**2*Math.sin(s)**2;return new t.constructor(Math.cosh(e)*Math.sinh(e)/r,-Math.sin(s)*Math.cos(s)/r).toFixed(8)}return+(1/Math.tanh(t)).toFixed(8)},...t),t.croot=(...t)=>{const e=t.pop();if(!e.isComplex?.())throw Error("croot expect Complex number as root");return n(t=>{"number"==typeof t&&(t=new e.constructor(t,0));const{a:s,b:r}=e,{z:n,phi:i}=t,a=Math.hypot(s,r),o=Math.exp((Math.log(n)*s+i*r)/a),h=(i*s-Math.log(n)*r)/a;return new e.constructor(o*Math.cos(h),o*Math.sin(h)).toFixed(8)},...t)},t.csv2arr=we,t.csv2json=(t,e=",")=>JSON.stringify(ye(t,e)),t.csv2matrix=(t,e=",")=>new Z(we(t,e)),t.csv2object=ye,t.csv2sql=(t,e)=>{const s=t=>t.trim().replace(/[^a-zA-Z0-9_]/g,""),r=t=>"'"+t.trim().replace(/'/g,"''")+"'",n=t.trim().trimEnd().split("\n").filter(t=>t),i=n[0].split(",").map(s);let a="INSERT INTO "+s(e)+" ("+i.join(", ")+") Values ",o=[];for(let t=1;t<n.length;t++){const e=n[t].split(",").map(r);o.push("("+e.join(", ")+")")}return a+o.join(",\n")},t.debounce=(t,e=1e3)=>(...s)=>setTimeout(()=>t(...s),e),t.defineParamsGetter=function(t){Object.defineProperties(t,{QueryParams:{get:function(){return globalThis.location.search.substring(1),Object.fromEntries(new URLSearchParams(location.search))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}})},t.define_wc=function(t,e,s={},{mode:r="open"}={}){globalThis.customElements?.get(t)?console.warn(`Custom element "${t}" is already defined`):-1!==t.search("-")?globalThis.customElements?.define(t,class extends HTMLElement{static get observedAttributes(){return["style",...Object.keys(s)]}constructor(){super(),this.attachShadow({mode:r}),this.props={},this.mask={...s}}connectedCallback(){this.render()}render(){this.shadowRoot.innerHTML="";const t=e(this.props);t instanceof Array?t.forEach(t=>t.mount(this.shadowRoot)):t.mount(this.shadowRoot)}attributeChangedCallback(t,e,s){Object.assign(this.props,{[t]:this.mask[t].type(s)}),this.render()}}):console.warn(`"${t}" is not a valid custom element name`)},t.deg2rad=(...t)=>n(t=>t*Math.PI/180,...t),t.discret=(t,e=5)=>Math.ceil(t*e)/e,t.div=S,t.elastic=t=>-2*ce(2,10*(t-1))*oe(20*ie*t/3*t),t.ema=(t,e)=>{let s=[],r=t[0];s.push(r);for(let n=1;n<t.length;n++)r=e*t[n]+(1-e)*r,s.push(r);return s},t.exp=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.exp(t.a)*Math.cos(t.b),Math.exp(t.a)*Math.sin(t.b)).toFixed(8):+Math.exp(t).toFixed(8),...t),t.floor=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.floor(t.a),Math.floor(t.b)):Math.floor(t),...t),t.fract=(...t)=>n(t=>t.isComplex?.()?new t.constructor(t.a-Math.trunc(t.a),t.b-Math.trunc(t.b)):t-Math.trunc(t),...t),t.geo_mean=(...t)=>t.reduce((t,e)=>t*e)**(1/t.length),t.harmonic_mean=(...t)=>{let e=0,s=0;for(s=0;s<t.length;s++)e+=1/t[s];return t.length/e},t.hypot=(...t)=>{const e=t.find(t=>t.isComplex?.());if(e){const s=t.map(t=>t.isComplex?.()?t:new e.constructor(t,0));return Math.hypot(...s.map(t=>t.z))}return Math.hypot(...t)},t.in_back=(t,e=1.70158,s=e+1)=>s*ce(t,3)-e*t**2,t.in_bounce=(t,e=7.5625,s=2.75)=>1-me(1-t,e,s),t.in_circ=t=>1-ae(1-t**2),t.in_cubic=t=>t**3,t.in_elastic=(t,e=2*ie/3)=>0===t?0:1===t?1:-ce(2,10*t-10)*he((10*t-10.75)*e),t.in_expo=t=>0===t?0:2**(10*t-10),t.in_out_back=(t,e=1.70158,s=1.525*e)=>t<.5?ce(2*t,2)*(2*(s+1)*t-s)/2:(ce(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.in_out_bounce=(t,e=7.5625,s=2.75)=>t<.5?me(1-2*t,e,s)/2:me(2*t-1,e,s)/2,t.in_out_circ=t=>t<.5?(1-ae(1-(2*t)**2))/2:(ae(1-(-2*t+2)**2)+1)/2,t.in_out_cubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.in_out_elastic=(t,e=2*ie/4.5)=>0===t?0:1===t?1:t<.5?-ce(2,20*t-10)*he((20*t-11.125)*e)/2:ce(2,-20*t+10)*he((20*t-11.125)*e)/2+1,t.in_out_expo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.in_out_quad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.in_out_quart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.in_out_quint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.in_out_sin=t=>-(oe(ie*t)-1)/2,t.in_quad=t=>t**2,t.in_quart=t=>t**4,t.in_quint=t=>t**5,t.in_sin=t=>1-oe(t*ie/2),t.interquartile_mean=(...t)=>{let e=t.sort((t,e)=>t-e),s=e[Math.floor(.25*(e.length-1))],r=e[Math.floor(.75*(e.length-1))],n=e.filter(t=>t>=s&&t<=r);return u(n)},t.iqr=t=>l(t)-h(t),t.isStateGetter=ht,t.is_primitive=Pt,t.json2arr=t=>xe(t instanceof Object?t:JSON.parse(t)),t.json2css=je,t.json2csv=Me,t.json2csvFile=(t,e)=>{const s=Me(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=Ce,t.json2xmlFile=(t,e)=>{const s=Ce(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=Te,t.json2ymlFile=(t,e)=>{const s=Te(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=O,t.linear=ue,t.linkStyle=function(t){const e=document?.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),document.head.appendChild(e)},t.ln=_,t.loop=(t,e={})=>new be(t,e),t.map=R,t.mapfun=n,t.matrix=(t,e,s)=>new Z(t,e,s),t.matrix2=(...t)=>new Z(2,2,t),t.matrix3=(...t)=>new Z(3,3,t),t.matrix4=(...t)=>new Z(4,4,t),t.max=(...t)=>Math.max(...t),t.mean=u,t.median=t=>o(t,50),t.midhinge=(...t)=>{let e=t.sort((t,e)=>t-e);return(e[Math.floor(.25*(e.length-1))]+e[Math.floor(.75*(e.length-1))])/2},t.midrange=t=>(Math.min(...t)+Math.max(...t))/2,t.min=(...t)=>Math.min(...t),t.modulo=A,t.mul=k,t.nand=(...t)=>F(D(...t)),t.nor=(...t)=>F(L(...t)),t.norm=j,t.normalize_css_value=t=>"number"==typeof t?t+"px":t,t.not=F,t.nthr=(...t)=>{const e=t.pop();if("number"!=typeof e)throw Error("nthr expects a real number n");return n(t=>t.isComplex?.()?new t.constructor({z:t.z**(1/e),phi:t.phi/e}):t<0?e%2==2?x(0,(-t)**(1/e)).toFixed(8):+(-1*(-t)**(1/e)).toFixed(8):+(t**(1/e)).toFixed(8),...t)},t.or=L,t.out_back=(t,e=1.70158,s=e+1)=>1+s*ce(t-1,3)+e*ce(t-1,2),t.out_bounce=me,t.out_circ=t=>ae(1-(t-1)**2),t.out_cubic=t=>1-(1-t)**3,t.out_elastic=(t,e=2*ie/3)=>0===t?0:1===t?1:ce(2,-10*t)*he((10*t-.75)*e)+1,t.out_expo=t=>1===t?1:1-2**(-10*t),t.out_quad=t=>1-(1-t)**2,t.out_quart=t=>1-(1-t)**4,t.out_quint=t=>1-(1-t)**5,t.out_sin=t=>he(t*ie/2),t.parseXML=function(t){return Ie((new DOMParser).parseFromString(t,"text/xml").documentElement)},t.parse_props=et,t.percentile=o,t.pow=v,t.power_mean=(t,e)=>{let s=0,r=0,n=t.length;for(r=0;r<n;r++)s+=t[r]**e;return(s/n)**(1/e)},t.q1=h,t.q3=l,t.rad2deg=(...t)=>n(t=>t/Math.PI*180,...t),t.register_click_away_event=vt,t.register_swipe_event=function(t,e=5,s=100,r=500){let n=0,i=0,a=0,o=!1;function h(t){n=t.clientX,i=t.clientY,a=performance.now(),o=!0}function l(h){if(!o)return;o=!1;const l=h.clientX-n,c=h.clientY-i;let u=null,m=null;performance.now()-a<=r&&(Math.abs(l)>=e&&Math.abs(c)<=s?(u=l<0?"left":"right",m="swipe"+u):Math.abs(c)>=e&&Math.abs(l)<=s&&(u=c<0?"up":"down",m="swipe"+u)),m&&t.dispatchEvent(new zt(m,{direction:u,distX:l,distY:c,originalEvent:h}))}return t.addEventListener("pointerdown",h,{passive:!0}),t.addEventListener("pointerup",l,{passive:!0}),()=>{t.removeEventListener("pointerdown",h),t.removeEventListener("pointerup",l)}},t.register_view_event=Ot,t.remove_class=(t,e)=>t.element.className=t.element.className.replace(e,""),t.rms=(...t)=>{const e=t.length;return(Math.hypot(...t)/e)**(1/e)},t.rolling_std=(t,e)=>Math.sqrt(d(t,e)),t.rolling_variance=d,t.round=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.round(t.a),Math.round(t.b)):Math.round(t),...t),t.sample_std=(...t)=>Math.sqrt(p(...t)),t.sample_variance=p,t.script=function(t){const e=document?.createElement("script");e.setAttribute("src",t),document.head.appendChild(e)},t.sec=(...t)=>n(t=>(t.isComplex?.(),+(1/Math.cos(t)).toFixed(8)),...t),t.sig=(...t)=>n(t=>1/(1+Math.exp(-t)).toFixed(8),...t),t.sign=(...t)=>n(t=>{if(t.isComplex?.()){const{z:e,phi:s}=t;return 0===e?new t.constructor(0,0):new t.constructor({z:1,phi:s})}return Math.sign(t)},...t),t.sin=(...t)=>n(t=>t?.isComplex?new t.constructor(Math.sin(t.a)*Math.cosh(t.b),Math.cos(t.a)*Math.sinh(t.b)).toFixed(8):+Math.sin(t).toFixed(8),...t),t.sinh=(...t)=>n(t=>t?.isComplex?new t.constructor(Math.sinh(t.a)*Math.cos(t.b),Math.cosh(t.a)*Math.sin(t.b)).toFixed(8):+Math.sinh(t).toFixed(8),...t),t.sleep=t=>new Promise(e=>setTimeout(e,t)),t.sma=(t,e)=>{let s=[];for(let r=0;r<=t.length-e;r++){let n=0;for(let s=0;s<e;s++)n+=t[r+s];s.push(n/e)}return s},t.sqrt=M,t.std=(...t)=>Math.sqrt(m(...t)),t.step=(t,e=5)=>Math.floor(t*e)/e,t.step_fps=t=>1e3/t,t.style=(t,e)=>{t&&Object.assign(t.style,e)},t.sub=C,t.svg2ascii=Se,t.svg2img=(t,e=!0)=>Nt.img(Ae(t)).mount(e),t.svg2imgUrl=Ae,t.svg2str=ke,t.tags=Nt,t.tan=(...t)=>n(t=>{if(t?.isComplex){const e=Math.cos(2*t.a)+Math.cosh(2*t.b);return new t.constructor(Math.sin(2*t.a)/e,Math.sinh(2*t.b)/e).toFixed(8)}return+Math.tan(t).toFixed(8)},...t),t.tanh=(...t)=>n(t=>{if(t?.isComplex){const e=Math.cosh(2*a)+Math.cos(2*b);return new t.constructor(Math.sinh(2*a)/e,Math.sin(2*b)/e).toFixed(8)}return+Math.tanh(t).toFixed(8)},...t),t.text=ft,t.throttle=At,t.tick=(t,e,s=1/0,r=!0)=>new fe(t,e,s,r),t.timeTaken=t=>{console.time("timeTaken");const e=t();return console.timeEnd("timeTaken"),e},t.time_memory_Taken=t=>{const e=Date.now(),s=performance.memory.usedJSHeapSize,r=t();return{elapsedTime:Date.now()-e,usedMemory:performance.memory.usedJSHeapSize-s,result:r}},t.timeout=function(t,e){let s;const r=new Promise(r=>{s=setTimeout(()=>{e&&e(),r()},t)});return{id:s,clear:()=>clearTimeout(s),promise:r}},t.trimmed_mean=(t,e)=>{let s=[...t].sort((t,e)=>t-e).slice(e,t.length-e);return u(...s)},t.trunc=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.trunc(t.a),Math.trunc(t.b)):Math.trunc(t),...t),t.useDerived=function(t,e){let s=t(...e.map(t=>t().value));const r=new Set;return e.forEach(n=>{n()._subscribe(()=>{{const n=t(...e.map(t=>t().value));n!==s&&(s=n,r.forEach(t=>t(s)))}})}),()=>({value:s,isStateGetter:()=>!0,_subscribe:t=>r.add(t)})},t.useEffect=(t,e=[])=>{const s=e.filter(ht);let r;const n=()=>{"function"==typeof r&&r();const e=s.map(t=>t().value);r=t(...e)},i=s.map(t=>t()._subscribe(n));return n(),()=>{i.forEach(t=>{t()}),"function"==typeof r&&(r(),r=void 0)}},t.useEventEmitter=Ne,t.useIPC=X,t.useLocalStorage=(t,e,s=!0)=>new Q(localStorage,t,e,s),t.useMediaQuery=(t,e)=>new qe(t,e),t.useQueryParams=function(){const t=()=>Ve();return[t,(e,s=!0)=>{const r=t(),n="function"==typeof e?e(r):e,i=s?{...r,...n}:n,a=new URLSearchParams(i).toString();window.history.pushState({},"",`${window.location.pathname}${a?`?${a}`:""}`),window.dispatchEvent(new CustomEvent("queryparamschange",{detail:i}))}]},t.useReactive=t=>Le(t=>{const e=ot(t);return{get:e[0],set:e[1]}},t),t.useRoot=(t,e={})=>new Ze(t,e),t.useSessionStorage=(t,e,s=!0)=>new Q(sessionStorage,t,e,s),t.useState=ot,t.useThread=(t,e,s=[],r=!0)=>(new $e).call(t,e,s,r),t.useTitle=(t,e=!0)=>new Be(t,e),t.variance=m,t.wait=t=>new Promise(e=>setTimeout(e,t)),t.waitElm=t=>new Promise(e=>{if(t)return e(t);const s=new MutationObserver(()=>{t&&(e(t),s.disconnect())});s.observe(document?.body,{childList:!0,subtree:!0})}),t.waitForUIElm=t=>new Promise(e=>{if(t.element)return e(t.element);const s=new MutationObserver(()=>{t.element&&(e(t.element),s.disconnect())});s.observe(document?.body,{childList:!0,subtree:!0})}),t.waitForUIElmSync=(t,e=2e3)=>{const s=Date.now();for(;Date.now()-s<e;)if(t.element)return t.element},t.watchQueryParams=function(t){let e=location.search;const s=()=>{const s=location.search;s!==e&&(e=s,t(Ve()))};window.addEventListener("popstate",s);const r=history.pushState;history.pushState=function(...t){r.apply(this,t),s()};const n=history.replaceState;return history.replaceState=function(...t){n.apply(this,t),s()},t(Ve()),()=>{window.removeEventListener("popstate",s)}},t.weighted_mean=(t,e)=>{let s=0,r=0;for(let n=0;n<t.length;n++)s+=t[n]*e[n],r+=e[n];return s/r},t.weighted_std=(t,e)=>Math.sqrt(f(t,e)),t.weighted_variance=f,t.winsorized_mean=(t,e)=>{let s=[...t].sort((t,e)=>t-e),r=s[e],n=s[s.length-e-1];return s=s.map(t=>Math.max(r,Math.min(n,t))),u(s)},t.wma=(t,e)=>{let s=e.length,r=e.reduce((t,e)=>t+e,0),n=[];for(let i=0;i<=t.length-s;i++){let a=0;for(let r=0;r<s;r++)a+=t[i+r]*e[r];n.push(a/r)}return n},t.xnor=(...t)=>F($(...t)),t.xor=$});
9
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Ziko={})}(this,function(t){"use strict";const{PI:e,E:s}=Math,r=Number.EPSILON,n=(t,...e)=>{const s=e.map(e=>{return"object"!=typeof(s=e)&&"function"!=typeof s||null===s||e?.__mapfun__?t(e):e instanceof Array?e.map(e=>n(t,e)):ArrayBuffer.isView(e)?e.map(e=>t(e)):e instanceof Set?new Set(n(t,...e)):e instanceof Map?new Map([...e].map(e=>[e[0],n(t,e[1])])):e.isMatrix?.()?new e.constructor(e.rows,e.cols,n(e.arr.flat(1))):e instanceof Object?Object.fromEntries(Object.entries(e).map(e=>[e[0],n(t,e[1])])):void 0;var s});return 1==s.length?s[0]:s},i=(t,e)=>t.isComplex?.()?new t.constructor(e(t.a),e(t.b)):t.isMatrix?.()?new t.constructor(t.rows,t.cols,t.arr.flat(1).map(e)):(t instanceof Array&&n(e,...t),e(t)),o=(t,e)=>{if(0===t.length)return NaN;let s=t.sort((t,e)=>t-e),r=e/100*(s.length-1),n=Math.floor(r),i=r-n;return n===s.length-1?s[n]:s[n]*(1-i)+s[n+1]*i},h=t=>o(t,25),l=t=>o(t,75),u=(...t)=>t.reduce((t,e)=>t+e)/t.length,m=(...t)=>{const e=t.length;if(0===e)return NaN;const s=u(...t);return t.reduce((t,e)=>t+(e-s)**2,0)/e},p=(...t)=>{const e=t.length;if(e<2)return NaN;const s=u(...t);return t.reduce((t,e)=>t+(e-s)**2,0)/(e-1)},f=(t,e)=>{const s=t.length;if(0===s||e.length!==s)return NaN;const r=e.reduce((t,e)=>t+e,0),n=t.reduce((t,s,r)=>t+s*e[r],0)/r;return t.reduce((t,s,r)=>t+e[r]*(s-n)**2,0)/r},d=(t,e)=>{if(e<1||t.length<e)return[];let s=[];for(let r=0;r<=t.length-e;r++){const n=t.slice(r,r+e);s.push(p(n))}return s},g=t=>{let e=[],s=0;for(let r of t)s+=r,e.push(s);return e};class w{static int(t,e){return Math.floor(this.float(t,e))}static float(t,e){return void 0!==e?Math.random()*(e-t)+t:Math.random()*t}static bin(){return this.int(2)}static oct(){return this.int(8)}static dec(){return this.int(10)}static hex(){return((t,e,s)=>{const r=parseInt(t,e);if(Number.isNaN(r))throw new TypeError("Invalid value for the given base");return r.toString(s)})(this.int(16),10,16)}static char(t=!1){const e=t?this.int(65,91):this.int(97,123);return String.fromCharCode(e)}static bool(){return Boolean(this.int(2))}static get color(){return{hex:()=>`#${this.int(16777215).toString(16).padStart(6,"0")}`,hexa:()=>{const[t,e,s,r]=Array.from({length:4},()=>this.int(255).toString(16).padStart(2,"0"));return`#${t}${e}${s}${r}`},rgb:()=>{const[t,e,s]=Array.from({length:3},()=>this.int(255));return`rgb(${t}, ${e}, ${s})`},rgba:()=>{const[t,e,s]=Array.from({length:3},()=>this.int(255));return`rgba(${t}, ${e}, ${s}, ${Math.random().toFixed(2)})`},hsl:()=>`hsl(${this.int(360)}, ${this.int(100)}%, ${this.int(100)}%)`,hsla:()=>`hsla(${this.int(360)}, ${this.int(100)}%, ${this.int(100)}%, ${Math.random().toFixed(2)})`,gray:()=>{const t=this.int(255);return`rgb(${t}, ${t}, ${t})`}}}static get sample(){const t=this;return{int:(e,s,r)=>Array.from({length:e},()=>t.int(s,r)),float:(e,s,r)=>Array.from({length:e},()=>t.float(s,r)),char:(e,s=!1)=>Array.from({length:e},()=>t.char(s)),bool:e=>Array.from({length:e},()=>t.bool()),bin:e=>Array.from({length:e},()=>t.bin()),oct:e=>Array.from({length:e},()=>t.oct()),dec:e=>Array.from({length:e},()=>t.dec()),hex:e=>Array.from({length:e},()=>t.hex()),get color(){return{hex:e=>Array.from({length:e},()=>t.color.hex()),hexa:e=>Array.from({length:e},()=>t.color.hexa()),rgb:e=>Array.from({length:e},()=>t.color.rgb()),rgba:e=>Array.from({length:e},()=>t.color.rgba()),hsl:e=>Array.from({length:e},()=>t.color.hsl()),hsla:e=>Array.from({length:e},()=>t.color.hsla()),gray:e=>Array.from({length:e},()=>t.color.gray())}},choice:(e,s,r)=>Array.from({length:e},()=>t.choice(s,r))}}static shuffle(t){return[...t].sort(()=>.5-Math.random())}static choice(t=[1,2,3],e=new Array(t.length).fill(1/t.length)){const s=g(...e).map(t=>100*t),r=new Array(100);r.fill(t[0],0,s[0]);for(let e=1;e<t.length;e++)r.fill(t[e],s[e-1],s[e]);return r[this.int(r.length)]}}globalThis.Random=w;class y{constructor(t=0,e=0){[this.a,this.b]=((t,e,s)=>{let r,n;return e instanceof t?(r=e.a,n=e.b):"object"==typeof e?"a"in e&&"b"in e?(r=e.a,n=e.b):"a"in e&&"z"in e?(r=e.a,n=Math.sqrt(e.z**2-e.a**2)):"a"in e&&"phi"in e?(r=e.a,n=e.a*Math.tan(e.phi)):"b"in e&&"z"in e?(n=e.b,r=Math.sqrt(e.z**2-e.b**2)):"b"in e&&"phi"in e?(n=s,r=e.b/Math.tan(e.phi)):"z"in e&&"phi"in e&&(r=+e.z*Math.cos(e.phi).toFixed(15),n=+e.z*Math.sin(e.phi).toFixed(15)):"number"==typeof e&&"number"==typeof s&&(r=+e.toFixed(32),n=+s.toFixed(32)),[r,n]})(y,t,e)}get __mapfun__(){return!0}isComplex(){return!0}toString(){let t="";return t=0!==this.a?this.b>=0?`${this.a}+${this.b}*i`:`${this.a}-${Math.abs(this.b)}*i`:this.b>=0?`${this.b}*i`:`-${Math.abs(this.b)}*i`,t}serialize(){return JSON.stringify({type:"complex",data:this})}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));let{data:e,type:s}=t;return"complex"===s&&"a"in e&&"b"in e?new y(e.a,e.b):TypeError("Not a valid complex")}toFixed(t){return this.a=+this.a.toFixed(t),this.b=+this.b.toFixed(t),this}toPrecision(t){return this.a=+this.a.toPrecision(t),this.b=+this.b.toPrecision(t),this}clone(){return new y(this.a,this.b)}get z(){return Math.hypot(this.a,this.b)}get phi(){return Math.atan2(this.b,this.a)}static zero(){return new y(0,0)}static fromPolar(t,e){return new y(+(t*cos(e)).toFixed(13),+(t*sin(e)).toFixed(13))}static get random(){return{int:(t,e)=>new y(...w.sample.int(2,t,e)),float:(t,e)=>new y(...w.sample.float(2,t,e))}}static twiddle(t,e){const s=-2*Math.PI*t/e;return new y(Math.cos(s),Math.sin(s))}get conj(){return new y(this.a,-this.b)}get inv(){return new y(this.a/Math.hypot(this.a,this.b),-this.b/Math.hypot(this.a,this.b))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new y(t[e],0)),this.a+=t[e].a,this.b+=t[e].b;return this}sub(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new y(t[e],0)),this.a-=t[e].a,this.b-=t[e].b;return this}mul(...t){let{z:e,phi:s}=this;for(let r=0;r<t.length;r++)"number"==typeof t[r]&&(t[r]=new y(t[r],0)),e*=t[r].z,s+=t[r].phi;return this.a=e*Math.cos(s),this.b=e*Math.sin(s),this.toFixed(8)}div(...t){let{z:e,phi:s}=this;for(let r=0;r<t.length;r++)"number"==typeof t[r]&&(t[r]=new y(t[r],0)),e/=t[r].z,s-=t[r].phi;return this.a=e*Math.cos(s),this.b=e*Math.sin(s),this.toFixed(8)}modulo(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new y(t[e],0)),this.a%=t[e].a,this.b%=t[e].b;return this}pow(...t){let{z:e,phi:s}=this;for(let r=0;r<t.length;r++)"number"==typeof t[r]&&(t[r]=new y(t[r],0)),e*=Math.exp(t[r].a*Math.log(e)-t[r].b*s),s+=t[r].b*Math.log(e)+t[r].a*s;return this.a=e*Math.cos(s),this.b=e*Math.sin(s),this}get expo(){return[this.z,this.phi]}nthr(t=2){return x({z:this.z**(1/t),phi:this.phi/t})}get sqrt(){return this.nthr(2)}get cbrt(){return this.nthr(3)}get log(){return x(this.z,this.phi)}get cos(){return x(Math.cos(this.a)*Math.cosh(this.b),Math.sin(this.a)*Math.sinh(this.b))}get sin(){return x(Math.sin(this.a)*Math.cosh(this.b),Math.cos(this.a)*Math.sinh(this.b))}get tan(){const t=cos(2*this.a)+cosh(2*this.b);return x(Math.sin(2*this.a)/t,Math.sinh(2*this.b)/t)}}const x=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map((s,r)=>x(t[r],e[r]));if(t.isMatrix?.()&&e.isMatrix?.()){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map((s,r)=>x(t.arr[r],e.arr[r]));return new t.constructor(t.rows,t.cols,...s)}return new y(t,e)},v=(...t)=>{const e=t.pop();return n(t=>t.isComplex?.()?e.isComplex?.()?new t.constructor({z:Math.exp(e.a*Math.log(t.z)-e.b*t.phi),phi:e.b*Math.log(t.z)+e.a*t.phi}):new t.constructor({z:t.z**e,phi:t.phi*e}):e.isComplex?.()?new t.constructor({z:Math.exp(e.a*Math.log(t)),phi:e.b*Math.log(t)}):Math.pow(t,e),...t)},M=(...t)=>n(t=>t.isComplex?.()?new t.constructor({z:t.z**.5,phi:t.phi/2}):t<0?x(0,Math.sqrt(-t)).toFixed(8):+Math.sqrt(t).toFixed(8),...t),_=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.log(t.z),t.phi).toFixed(8):+Math.log(t).toFixed(8),...t),T=(t,e,s)=>{if("number"==typeof e){if("number"==typeof s)switch(t){case"add":return e+s;case"sub":return e-s;case"mul":return e*s;case"div":return e/s;case"modulo":return e%s}return s?.isComplex?.()&&(e=new s.constructor(e,0)),s?.isMatrix?.()&&(e=s.constructor.nums(s.rows,s.cols,e)),e[t](s)}if(e?.isComplex?.()){if("number"==typeof s||s?.isComplex?.())return e.clone()[t](s);if(s?.isMatrix?.())return(e=s.constructor.nums(s.rows,s.cols,e)).clone()[t](s)}if(e?.isMatrix?.())return e.clone()[t](s)},E=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=T("add",s,e[t]);return s},k=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=T("sub",s,e[t]);return s},C=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=T("mul",s,e[t]);return s},S=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=T("div",s,e[t]);return s},A=(t,...e)=>{let s=t;for(let t=0;t<e.length;t++)s=T("modulo",s,e[t]);return s},j=(t,e,s)=>i(t,t=>e!==s?(t-e)/(s-e):0),O=(t,e,s)=>i(t,t=>(s-e)*t+e),I=(t,e,s)=>i(t,t=>Math.min(Math.max(t,e),s)),R=(t,e,s,r,n)=>i(t,t=>O(j(t,e,s),r,n)),z=(t,e,s=!0)=>{if(t instanceof Array&&!(e instanceof Array))return n(t=>z(t,e,s),...t);if(e instanceof Array&&!(t instanceof Array))return n(e=>z(t,e,s),...e);if(t instanceof Array&&e instanceof Array)return t.map((t,r)=>z(t,e[r],s));const r=Math.atan2(t,e);return s?r:180*r/Math.PI},F=t=>t.isComplex?.()?new t.constructor(F(t.a),F(t.b)):t.isMatrix?.()?new t.constructor(t.rows,t.cols,t.arr.flat(1).map(F)):+!t,P=(t,e)=>{if(t.every(t=>t.isComplex?.())){const s=t.map(t=>t.a),r=t.map(t=>t.b);return new t[0].constructor(e(...s),e(...r))}if(t.every(t=>t.isMatrix?.())){if(!t.every(e=>e.rows===t[0].rows&&e.cols===t[0].cols))return TypeError("All matrices must have the same shape");const{rows:s,cols:r}=t[0],n=Array.from({length:s},(s,n)=>Array.from({length:r},(s,r)=>e(...t.map(t=>t.arr[n][r]))));return new t[0].constructor(n)}return null},D=(...t)=>{const e=P(t,D);return null!==e?e:t.reduce((t,e)=>t&e,1)},L=(...t)=>{const e=P(t,L);return null!==e?e:t.reduce((t,e)=>t|e,0)},$=(...t)=>{const e=P(t,$);return null!==e?e:t.reduce((t,e)=>t^e,0)},U=(t,e)=>{for(let e=0;e<t.arr.length;e++)Object.defineProperty(t,e,{value:t.arr[e],writable:!0,configurable:!0,enumerable:!1});for(let s=t.arr.length;s<e;s++)delete t[s]};function N(t,e){var s=[];for(let e=0;e<t.length;e++)s.push(t[e].slice(0));s.splice(0,1);for(let t=0;t<s.length;t++)s[t].splice(e,1);return s}function q(t,e){if(t=t.clone(),e=e.clone(),t.rows!==e.rows)return;let s=t.arr;for(let r=0;r<t.rows;r++)for(let n=t.cols;n<t.cols+e.cols;n++)s[r][n]=e.arr[r][n-t.cols];return t.cols+=e.cols,new t.constructor(t.rows,t.cols,s.flat(1))}function B(t,e){if(t=t.clone(),e=e.clone(),t.cols!==e.cols)return;let s=t.arr;for(let r=t.rows;r<t.rows+e.rows;r++){s[r]=[];for(let n=0;n<t.cols;n++)s[r][n]=e.arr[r-t.rows][n]}return t.rows+=e.rows,new t.constructor(t.rows,t.cols,s.flat(1))}class Z{constructor(t,e,s=[]){[this.rows,this.cols,this.arr]=((t,e,s,r)=>{if(!(e instanceof t)){let t,n,i=[];if(e instanceof Array)i=e,e=i.length,s=i[0].length;else for(t=0;t<e;t++)for(i.push([]),i[t].push(new Array(s)),n=0;n<s;n++)i[t][n]=r[t*s+n],null==r[t*s+n]&&(i[t][n]=0);return[e,s,i]}arr=e.arr,s=(e=e.rows).cols})(Z,t,e,s),U(this)}isMatrix(){return!0}clone(){return new Z(this.rows,this.cols,this.arr.flat(1))}toComplex(){return this.arr=n(t=>t?.isComplex?.()?t:new y(t,0),...this.arr),U(this),this}[Symbol.iterator](){return this.arr[Symbol.iterator]()}get size(){return this.rows*this.cols}get shape(){return[this.rows,this.cols]}at(t=0,e=void 0){if(t<0&&(t+=this.rows),t<0||t>=this.rows)throw new Error("Row index out of bounds");if(void 0===e)return this.arr[t];if(e<0&&(e+=this.cols),e<0||e>=this.cols)throw new Error("Column index out of bounds");return this.arr[t][e]}slice(t=0,e=0,s=this.rows-1,r=this.cols-1){s<0&&(s=this.rows+s),r<0&&(r=this.cols+r);let n=s-t,i=r-e,a=new Array(i);for(let s=0;s<n;s++){a[s]=[];for(let r=0;r<i;r++)a[s][r]=this.arr[s+t][r+e]}return this.arr=a,U(this.rows),this.rows=n,this.cols=i,this}reshape(t,e){if(t*e!==this.rows*this.cols)throw Error("size not matched");const s=this.rows;return Object.assign(this,new Z(t,e,this.arr.flat(1))),U(s),this}get T(){let t=[];for(let e=0;e<this.arr[0].length;e++){t[e]=[];for(let s=0;s<this.arr.length;s++)t[e][s]=this.arr[s][e]}return new Z(this.cols,this.rows,t.flat(1))}get det(){return(t=this).isSquare?1==t.rows?t.arr[0][0]:function t(e){if(2==e.length)return e.flat(1).some(t=>t?.isMatrix?.())?void console.warn("Tensors are not completely supported yet ..."):k(C(e[0][0],e[1][1]),C(e[0][1],e[1][0]));for(var s=0,r=0;r<e.length;r++){const n=E(C(v(-1,r),C(e[0][r],t(N(e,r)))));s=E(s,n)}return s}(t.arr):new Error("is not square matrix");var t}get inv(){return function(t){if(t.row!==t.cols)throw Error('is not a square matrix"');if(0===t.det)throw Error("determinant should not equal 0");const{arr:e}=t;if(e.length===e[0].length){var s=0,r=0,n=0,i=e.length,a=0,o=[],h=[];for(s=0;s<i;s+=1)for(o[o.length]=[],h[h.length]=[],n=0;n<i;n+=1)o[s][n]=s==n?1:0,h[s][n]=e[s][n];for(s=0;s<i;s+=1){if(0==(a=h[s][s])){for(r=s+1;r<i;r+=1)if(0!=h[r][s]){for(n=0;n<i;n++)a=h[s][n],h[s][n]=h[r][n],h[r][n]=a,a=o[s][n],o[s][n]=o[r][n],o[r][n]=a;break}if(0==(a=h[s][s]))return}for(n=0;n<i;n++)h[s][n]=h[s][n]/a,o[s][n]=o[s][n]/a;for(r=0;r<i;r++)if(r!=s)for(a=h[r][s],n=0;n<i;n++)h[r][n]-=a*h[s][n],o[r][n]-=a*o[s][n]}return new t.constructor(o)}}(this)}static eye(t){let e=new Z(t,t);for(let s=0;s<t;s++)for(let r=0;r<t;r++)e.arr[s][r]=s===r?1:0;return e}static zeros(t,e){let s=new Z(t,e);for(let n=0;n<t;n++)for(var r=0;r<e;r++)s.arr[n][r]=0;return s}static ones(t,e){let s=new Z(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=1;return s}static nums(t,e,s){let r=new Z(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)r.arr[n][t]=s;return r}static get random(){return{int:(t,e,s,r)=>new Z(t,e,w.sample.int(t*e,s,r)),float:(t,e,s)=>new Z(t,e,w.sample.float(t*e,s,b))}}get range(){return{map:(t,e,s,r)=>(this.arr=R(this.arr,t,e,s,r),this),norm:(t,e)=>(this.arr=j(this.arr,t,e),this),lerp:(t,e)=>(this.arr=O(this.arr,t,e),this),clamp:(t,e)=>(this.arr=I(this.arr,t,e),this)}}hstack(...t){const e=[this,...t].reduce((t,e)=>q(t,e));return Object.assign(this,e),U(this),this}vstack(...t){const e=[this,...t].reduce((t,e)=>B(t,e));return Object.assign(this,e),U(this),this}hqueue(...t){const e=[this,...t].reverse().reduce((t,e)=>q(t,e));return Object.assign(this,e),U(this),this}vqueue(...t){const e=[this,...t].reverse().reduce((t,e)=>B(t,e));return Object.assign(this,e),U(this),this}forEach(t){return this.arr.flat(1).forEach(t),this}forEachRow(t){return this.arr.forEach(t),this}forEachCol(t){return this.clone().T.forEachRow(t),this}map(t){const e=this.arr.flat(1).map(t);return new Z(this.rows,this.cols,e)}mapRows(t=()=>{}){return this.arr=this.arr.map(t),this}mapCols(t){return this.clone().T.mapRows(t).T}sort(t=()=>{}){const e=this.arr.flat(1).sort(t);return new Z(this.rows,this.cols,e)}shuffle(){return this.sort(()=>.5-Math.random())}sortRows(t=()=>{}){return this.arr=this.arr.map(e=>e.sort(t)),this}shuffleRows(){return this.sortRows(()=>.5-Math.random())}sortCols(t){return this.clone().T.sortRows(t).T}shuffleCols(){return this.sortCols(()=>.5-Math.random())}reduce(t,e){const s=e?this.arr.flat(1).reduce(t,e):this.arr.flat(1).reduce(t);return new Z([[s]])}reduceRows(t,e){const s=e?this.arr.map(s=>s.reduce(t,e)):this.arr.map(e=>e.reduce(t));return new Z(1,this.cols,s)}reduceCols(t,e){return this.T.reduceRows(t,e).T}filterRows(t){const e=this.arr.map(e=>e.some(e=>t(e))),s=[];let r;for(r=0;r<e.length;r++)e[r]&&s.push(this.arr[r]);return new Z(s)}filterCols(t){const e=this.T.filterRows(t);return new Z(e).T}every(t){return this.arr.flat(1).every(t)}everyRow(t){return this.arr.map(e=>e.every(t))}everyCol(t){return this.T.arr.map(e=>e.every(t))}some(t){return this.arr.flat(1).some(t)}someRow(t){return this.arr.map(e=>e.some(t))}someCol(t){return this.T.arr.map(e=>e.some(t))}get isSquare(){return this.rows===this.cols}get isSym(){if(!this.isSquare)return!1;for(let t=0;t<this.rows;t++)for(let e=t+1;e<this.cols;e++)if(this.arr[t][e]!==this.arr[e][t])return!1;return!0}get isAntiSym(){if(!this.isSquare)return!1;const t=this.rows;for(let e=0;e<t;e++){if(0!==this.arr[e][e])return!1;for(let s=e+1;s<t;s++)if(this.arr[e][s]!==-this.arr[s][e])return!1}return!0}get isDiag(){if(!this.isSquare)return!1;const t=this.rows;for(let e=0;e<t;e++)for(let s=e+1;s<t;s++)if(0!==this.arr[e][s]||0!==this.arr[s][e])return!1;return!0}get isOrtho(){return!!this.isSquare&&(this.isDiag&&(1==this.det||-1==this.det))}get isIdemp(){if(!this.isSquare)return!1;const t=this.rows,e=this.arr,s=[];for(let r=0;r<t;r++){s[r]=[];for(let n=0;n<t;n++){let i=0;for(let s=0;s<t;s++)i+=e[r][s]*e[s][n];s[r][n]=i}}for(let r=0;r<t;r++)for(let n=0;n<t;n++)if(s[r][n]!==e[r][n])return!1;return!0}get isUpperTri(){if(!this.isSquare)return!1;const t=this.rows;for(let e=1;e<t;e++)for(let t=0;t<e;t++)if(0!==this.arr[e][t])return!1;return!0}get isLowerTri(){if(!this.isSquare)return!1;const t=this.rows;for(let e=0;e<t-1;e++)for(let s=e+1;s<t;s++)if(0!==this.arr[e][s])return!1;return!0}toPrecision(t){for(let e=0;e<this.cols;e++)for(let s=0;s<this.rows;s++)this.arr[e][s]=+this.arr[e][s].toPrecision(t);return this}toFixed(t){for(let e=0;e<this.cols;e++)for(let s=0;s<this.rows;s++)this.arr[e][s]=+this.arr[e][s].toFixed(t);return this}splice(t,e,s,...r){}getRows(t,e=t+1){return this.slice(t,0,e,this.cols)}getCols(t,e=t+1){return this.slice(0,t,this.rows,e)}#t(t,...e){for(let r=0;r<e.length;r++){("number"==typeof e[r]||e[r]?.isComplex?.())&&(e[r]=Z.nums(this.rows,this.cols,e[r]));for(let n=0;n<this.rows;n++)for(var s=0;s<this.cols;s++)this.arr[n][s]=t(this.arr[n][s],e[r].arr[n][s])}return new Z(this.rows,this.cols,this.arr.flat(1))}add(...t){return this.#t(E,...t)}sub(...t){return this.#t(k,...t)}mul(...t){return this.#t(C,...t)}div(...t){return this.#t(S,...t)}modulo(...t){return this.#t(A,...t)}dot(t){for(var e=[],s=0;s<this.arr.length;s++){e[s]=[];for(var r=0;r<t.arr[0].length;r++){e[s][r]=0;for(var n=0;n<this.arr[0].length;n++)e[s][r]=E(e[s][r],C(this.arr[s][n],t.arr[n][r]))}}return new Z(this.arr.length,t.arr[0].length,e.flat(1))}pow(t){let e=this.clone(),s=this.clone();for(let r=0;r<t-1;r++)s=s.dot(e);return s}sum(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t=E(t,this.arr[e][s]);return t}prod(){let t=1;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t=C(t,this.arr[e][s]);return t}hasComplex(){return this.arr.flat(1/0).some(t=>t instanceof y)}get min(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.min(...this.arr[e]));return Math.min(...t)}get max(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.max(...this.arr[e]));return Math.max(...t)}get minRows(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.min(...this.arr[e]));return t}get maxRows(){this.hasComplex()&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Math.max(...this.arr[e]));return t}get minCols(){return this.hasComplex()&&console.error("Complex numbers are not comparable"),this.T.minRows}get maxCols(){return this.hasComplex()&&console.error("Complex numbers are not comparable"),this.T.maxRows}static fromVector(t){return new Z(t.length,1,t)}serialize(){const t=n(t=>t.serialize?.()||t,...this.arr);return JSON.stringify({type:"matrix",data:{rows:this.rows,cols:this.cols,arr:t}})}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));const{type:e,data:s}=t;if("matrix"!==e)return TypeError("Not a valid Matrix");let{arr:r}=s;return r=n(t=>{if("string"==typeof t){const e=JSON.parse(t),{type:s}=e;if("complex"===s)return y.deserialize(e)}return t},...r),new Z(r)}flip(){return this.flipeH().flipeV()}flipeH(){return this.arr=this.arr.map(t=>[...t].reverse()),U(this),this}flipeV(){return this.arr=this.arr.reverse(),U(this),this}}class V{constructor(t){this.cache={node:t}}isUINode(){return!0}get node(){return this.cache.node}}class W extends Array{constructor(...t){super(...t)}clear(){return this.length=0,this}getItemById(t){return this.find(e=>e.element.id===t)}getItemsByTagName(t){return this.filter(e=>e.element.tagName.toLowerCase()===t.toLowerCase())}getElementsByClassName(t){return this.filter(e=>e.element.classList?.contains(t))}querySelector(t){const e=globalThis?.document?.querySelector(t);return e&&this.find(t=>t.element===e)||null}querySelectorAll(t){const e=globalThis?.document?.querySelectorAll(t);return Array.from(e).map(t=>this.find(e=>e.element===t)).filter(Boolean)}}const H=new W,G={default:{target:null,render:!0,math:{mode:"deg"}},setDefault:function(t){const e=Object.keys(t),s=Object.values(t);for(let t=0;t<e.length;t++)this.default[e[t]]=s[t]},init:()=>{},renderingMode:"spa",isSSC:!1},K={store:new Map,index:0,register:function(t){this.store.set(this.index++,t)},reset(){this.index=0,this.store.clear()}},Y={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(t){}};class J{#e;#s;#r;#n;#i;#a;constructor(t=""){this.#e=new BroadcastChannel(t),this.#s=new Map,this.#r=new Map,this.#n="ziko-channel:"+1e17*Math.random(),this.#i=new Set([this.#n]),this.#a=new Set,this.#e.addEventListener("message",t=>{const{last_sent_event:e,userId:s,eventData:r,rooms:n}=t.data;if(s===this.#n)return;if(n&&n.length&&!n.some(t=>this.#a.has(t)))return;this.#i.add(s),this.#s=new Map(r);const i=this.#r.get(e);i&&i.forEach(({fn:t,rooms:s})=>{s&&0!==s.length&&n&&!n.some(t=>s.includes(t))||t(this.#s.get(e))})})}emit(t,e,s){return this.#s.set(t,e),"string"==typeof s&&(s=[s]),this.#e.postMessage({eventData:Array.from(this.#s.entries()),last_sent_event:t,userId:this.#n,rooms:s&&s.length?s:void 0}),this}on(t,e=console.log,s){return this.#r.has(t)||this.#r.set(t,[]),"string"==typeof s&&(s=[s]),this.#r.get(t).push({fn:e,rooms:s}),this}off(t,e){return this.#r.has(t)?(this.#r.set(t,this.#r.get(t).filter(t=>t.fn!==e)),this):this}once(t,e,s){const r=s=>{e(s),this.off(t,r)};return this.on(t,r,s),this}join(...t){return t.forEach(t=>this.#a.add(t)),this}leave(...t){return t.length?t.forEach(t=>this.#a.delete(t)):this.#a.clear(),this}close(){return this.#e.close(),this}}const X=t=>new J(t);class Q{static RESERVED_KEYS=new Set(["cache","items","set","add","remove","get","clear","onStorageUpdated"]);constructor(t,e,s,r=!0){this.cache={storage:t,globalKey:e,channel:r?X(`Ziko:useStorage-${e}`):null,oldItemKeys:new Set},this.#o(s,r)}get items(){const t=this.cache.storage.getItem(this.cache.globalKey);if(!t)return{};try{return JSON.parse(t)}catch{return{}}}#h(){const t=this.items,e=new Set(Object.keys(t));this.cache.oldItemKeys.forEach(t=>{e.has(t)||(delete this[t],this.cache.oldItemKeys.delete(t))});for(const e in t)Q.RESERVED_KEYS.has(e)||(this[e]=t[e],this.cache.oldItemKeys.add(e))}#o(t,e){e&&this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",()=>this.#h());null!==this.cache.storage.getItem(this.cache.globalKey)?this.#h():void 0!==t?this.set(t):this.#h()}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel&&this.cache.channel.emit("Ziko-Storage-Updated",t),this.#h(),this}add(t){return this.set({...this.items,...t})}remove(...t){const e={...this.items};return t.forEach(t=>delete e[t]),this.set(e)}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.#h(),this}onStorageUpdated(t){return this.cache.channel&&this.cache.channel.on("Ziko-Storage-Updated",t),this}}var tt={store:new Map,index:0,session_storage:null,register:function(t){},update:function(t,e){}};const et=(t={})=>{const e={methods:{},events:{},style:{},attrs:{}};for(const[s,r]of Object.entries(t))"style"===s?e.style=r:s.startsWith("$")?e.methods[s.slice(1)]=r:/^on[A-Z]/.test(s)?e.events[s]=r:e.attrs[s]=r;return e};var st;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:H,__HYDRATION__:K,__State__:tt,__Config__:G,__CACHE__:Y,__PROVIDERS__:{}},st=__Ziko__,Object.defineProperties(st,{QueryParams:{get:function(){return function(t){const e={};return t.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi,t=>{const[s,r]=t.split("=");e[s]=r}),e}(globalThis.location.search.substring(1))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}}));class rt extends V{constructor(){super()}init({element:t,name:e,type:s,render:r,props:n={},items:i=[]}={}){if(this.target=globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body,"string"==typeof t)switch(s){case"html":t=globalThis?.document?.createElement(t);break;case"svg":t=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg",t);break;default:throw Error("Not supported")}else this.target=t?.parentElement;Object.assign(this.cache,{name:e,itemsTarget:this,isInteractive:!1,parent:null,isBody:!1,isRoot:!1,isHidden:!1,isFrozzen:!1,attributes:{},filters:{},temp:{}}),this.events={ptr:null,mouse:null,wheel:null,key:null,drag:null,drop:null,click:null,clipboard:null,focus:null,swipe:null,custom:null},this.observer={resize:null,intersection:null},t&&Object.assign(this.cache,{element:t}),this.items=new W,globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this],t&&r&&this?.render?.(),globalThis.__Ziko__.__UI__.push(this);const a=et(n);this.parsed_props=a,this.style(a.style),this.setAttr(a.attrs);Object.entries(a.events).forEach(([t,e])=>this[t](e.bind(this))),i.length>0&&this.append(...i)}get element(){return this.cache.element}[Symbol.iterator](){return this.items[Symbol.iterator]()}maintain(){for(let t=0;t<this.items.length;t++)Object.defineProperty(this,t,{value:this.items[t],writable:!0,configurable:!0,enumerable:!1})}isInteractive(){return this.cache.isInteractive}isUIElement(){return!0}}function nt(t,...e){e.forEach(e=>function(t,e){const s=Object.getOwnPropertyDescriptors(e);for(const e of Reflect.ownKeys(s)){const r=s[e];"get"in r||"set"in r||"function"!=typeof r.value?Object.defineProperty(Object.getPrototypeOf(t),e,r):"function"==typeof r.value&&(Object.getPrototypeOf(t).hasOwnProperty(e)||Object.defineProperty(Object.getPrototypeOf(t),e,r))}}(t,e))}var it=Object.freeze({__proto__:null,mount:function(t=this.target,e=0){return e>0?(setTimeout(()=>this.mount(t,0),e),this):(this.isBody||(t?.isUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element)),this)},unmount:function(t=0){return t>0?(setTimeout(()=>this.unmount(0),t),this):(this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target.children].includes(this.element)&&this.target.removeChild(this.element),this)}});const at=Symbol.for("ziko/hooks/STATE_GETTER");function ot(t){const e={value:t,subscribers:new Set,paused:!1};function s(){return{value:e.value,_subscribe:t=>(e.subscribers.add(t),()=>e.subscribers.delete(t))}}s[at]=!0;return[s,function(t){e.paused||("function"==typeof t&&(t=t(e.value)),Object.is(t,e.value)||(e.value=t,e.subscribers.forEach(t=>t(e.value))))},{pause:()=>{e.paused=!0},resume:()=>{e.paused=!1},clear:()=>{e.subscribers.clear()},force:t=>{"function"==typeof t&&(t=t(e.value)),e.value=t,e.subscribers.forEach(t=>t(e.value))},getSubscribers:()=>new Set(e.subscribers)}]}const ht=t=>"function"==typeof t&&!0===t[at],lt=(t="")=>t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),ct=(t="")=>{if(0===t.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(t)};function ut(t,e){if(globalThis.SVGAElement&&this.element instanceof globalThis.SVGAElement&&(t=ct(t)?lt(t):t),!this?.attr[t]||this?.attr[t]!==e){if(ht(e)){e()._subscribe(e=>this.element?.setAttribute(t,e),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}var mt=Object.freeze({__proto__:null,_set_attrs_:ut,getAttr:function(t){return t=ct(t)?lt(t):t,this.element.attributes[t].value},removeAttr:function(...t){for(let e=0;e<t.length;e++)this.element?.removeAttribute(t[e]);return this},setAttr:function(t,e){if(t instanceof Object){const[s,r]=[Object.keys(t),Object.values(t)];for(let t=0;t<s.length;t++)r[t]instanceof Array&&(e[t]=r[t].join(" ")),ut.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),ut.call(this,t,e);return this},setContentEditable:function(t=!0){return this.setAttr("contenteditable",t),this}});class pt extends V{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const ft=(...t)=>new pt(...t);async function dt(t,e,...s){const r=this.itemsTarget.element,n=this.itemsTarget;if(this.cache.isFrozzen)return console.warn("You can't append new item to frozzen element"),this;for(let i=0;i<s.length;i++){if(["number","string"].includes(typeof s[i])&&(s[i]=ft(s[i])),s[i]instanceof Function&&ht(s[i])){console.log({s:s[i]()});const t=s[i]();s[i]=ft(t.value),t._subscribe(t=>s[i].element.textContent=t,s[i])}if("function"==typeof globalThis?.Node&&s[i]instanceof globalThis?.Node&&(s[i]=new this.constructor(s[i])),s[i]?.isUINode)s[i].cache.parent=this,r?.[t](s[i].element),s[i].target=this.itemsTarget.element,n.items[e](s[i]);else if(s[i]instanceof Promise){const a=await s[i];a.cache.parent=this,r?.[t](a.element),a.target=this.itemsTarget.element,n.items[e](a)}else s[i]instanceof Object&&(s[i]?.style&&this.style(s[i]?.style),s[i]?.attr&&Object.entries(s[i].attr).forEach(t=>this.setAttr(""+t[0],t[1])))}return this.maintain(),this}var gt=Object.freeze({__proto__:null,__addItem__:dt,after:function(t){return t?.isUIElement&&(t=t.element),this.itemsTarget.element?.after(t),this},append:function(...t){return dt.call(this,"append","push",...t),this},before:function(t){return t?.isUIElement&&(t=t.element),this.itemsTarget.element?.before(t),this},clear:function(){return this?.items?.forEach(t=>t.unmount()),this.itemsTarget.element.innerHTML="",this},insertAt:function(t,...e){const s=this.itemsTarget;if(t>=s.items.length)return this.append(...e);for(let r=0;r<e.length;r++)["number","string"].includes(typeof e[r])&&(e[r]=ft(e[r])),s.element?.insertBefore(e[r].element,s.items[t].element),s.items.splice(t,0,e[r]);return s.maintain(),this},prepend:function(...t){return this.__addItem__.call(this,"prepend","unshift",...t),this},remove:function(...t){const e=t=>{"number"==typeof t&&(t=this.items[t]),t?.isUIElement&&this.itemsTarget.element?.removeChild(t.element),this.items=this.items.filter(e=>e!==t)};for(let s=0;s<t.length;s++)e(t[s]);for(let t=0;t<this.items.length;t++)Object.assign(this,{[[t]]:this.items[t]});return this},replaceElementWith:function(t){return this.cache.element.replaceWith(t),this.cache.element=t,this}});var bt=Object.freeze({__proto__:null,at:function(t){return this.items.at(t)},find:function(t){return this.items.filter(t)},forEach:function(t){return this.items.forEach(t),this},map:function(t){return this.items.map(t)}});var wt=Object.freeze({__proto__:null,animate:function(t,{duration:e=1e3,iterations:s=1,easing:r="ease"}={}){return this.element?.animate(t,{duration:e,iterations:s,easing:r}),this},hide:function(){},show:function(){},size:function(t,e){return this.style({width:t,height:e})},style:function(t){if(!this.element?.style)return this;for(let e in t){const s=t[e];if(ht(s)){const t=s();Object.assign(this.element.style,{[e]:t.value}),t._subscribe(t=>{console.log({newValue:t}),Object.assign(this.element.style,{[e]:t})})}else Object.assign(this.element.style,{[e]:s})}return this}});class yt{constructor(t,e){this.cache={category:e,target:t,listeners:{},currentEvent:null,event:null,customEvents:new Set}}get event(){return this.cache.event}get target(){return this.cache.target}get element(){return this.cache.target.element}get currentEvent(){return this.cache.currentEvent}addListener(t,e,{preventDefault:s=!1,paused:r=!1}={}){return this.cache.listeners[t]={callback:s=>{this.cache.event=s,this.cache.listeners[t].preventDefault&&s.preventDefault(),this.cache.listeners[t].paused||(this.cache.currentEvent=t,e.call(this,this))},preventDefault:s,paused:r},this.element.addEventListener(t,this.cache.listeners[t].callback),this}removeListener(t){return this.element.removeEventListener(t,this.cache.listeners[t].callback),this}pause(t){return this.cache.listeners[t].paused=!0,this}resume(t){return this.cache.listeners[t].paused=!1,this}preventDefault(t){return this.cache.listeners[t].preventDefault=!0,this}useDefault(t){return this.cache.listeners[t].preventDefault=!1,this}}class xt extends Event{constructor(t,e){super("clickaway",{bubbles:!0,cancelable:!0}),this.originalEvent=t,this.targetElement=e}}function vt(t){function e(e){if(!t.contains(e.target)){const s=new xt(e,t);t.dispatchEvent(s)}}return globalThis?.document?.addEventListener("click",e),()=>globalThis?.document?.removeEventListener("click",e)}const Mt=(t,e=!1)=>{const s=t.element.getBoundingClientRect(),r=t.event;let n=r?.clientX-s.left|0,i=r?.clientY-s.top|0;if(e){const e=t.element.clientWidth,s=t.element.clientHeight;n=+(n/e*2-1).toFixed(8),i=+(i/s*-2+1).toFixed(8)}return{x:n,y:i}},_t="click",Tt={onClick(t){return this.on("click",t,{category:_t})},onDblClick(t){return this.on("dblclick",t,{category:_t})},onClickAway(t){var e,s,r;return e=this,s=_t,r="clickaway",e.exp.events?.[s]?.cache?.customEvents?.has(r)||vt(this.element),this.on("clickaway",t,{category:_t,isCustom:!0})}},Et="ptr",kt={onPtrDown(t,e=!1){return this.on("pointerdown",t,{category:Et,details_setter:t=>{const{x:s,y:r}=Mt(t,e);t.dx=s,t.dy=r,t.isDown=!0,t.isDragging=t.isMoving??!1}})},onPtrMove(t,e=!1){return this.on("pointermove",t,{category:Et,details_setter:t=>{const{x:s,y:r}=Mt(t,e);t.mx=s,t.my=r,t.isMoving=!0,t.isDragging=t.isDown??!1}})},onPtrUp(t,e=!1){return this.on("pointerup",t,{category:Et,details_setter:t=>{const{x:s,y:r}=Mt(t,e);t.ux=s,t.uy=r,t.isDown=!1,t.isMoving=!1,t.isDragging=!1}})}},Ct="key",St={onKeyDown(t){return this.on("keydown",t,{category:Ct,details_setter:t=>{t.kd=t.event.key}})},onKeyPress(t){return this.on("keypress",t,{category:Ct,details_setter:t=>{t.kp=t.event.key}})},onKeyUp(t){return this.on("keydown",t,{category:Ct,details_setter:t=>{t.ku=t.event.key}})}},At=(t,e)=>{let s=0;return(...r)=>{const n=(new Date).getTime();n-s<e||(s=n,t(...r))}};class jt extends CustomEvent{constructor(t,e,{bubbles:s=!0,cancelable:r=!0}={}){super(t,{detail:e,bubbles:s,cancelable:r})}}function Ot(t,{intersection:e=!0,resize:s=!0,threshold:r=0,throttleResize:n=100,throttleEnterExit:i=0}={}){let a,o;const h=e=>{for(let s of e){const{width:e,height:r}=s.contentRect;t.dispatchEvent(new jt("resizeview",{width:e,height:r,entry:s}))}},l=n>0?At(h,n):h,c=e=>{for(let s of e){const e=s.isIntersecting?"enterview":"exitview";t.dispatchEvent(new jt(e,s))}},u=i>0?At(c,i):c;return e&&(a=new IntersectionObserver(u,{threshold:r}),a.observe(t)),s&&(o=new ResizeObserver(l),o.observe(t)),()=>{a&&(a.unobserve(t),a.disconnect()),o&&(o.unobserve(t),o.disconnect())}}const It="view",Rt={onEnterView(t){return this.exp.events?.[It]||Ot(this.element),this.on("enterview",t,{category:It,isCustom:!0})},onExitView(t){return this.exp.events?.[It]||Ot(this.element),this.on("exitview",t,{category:It,isCustom:!0})},onResizeView(t){return this.exp.events?.[It]||Ot(this.element),this.on("resizeview",t,{category:It,isCustom:!0})}};class zt extends CustomEvent{constructor(t,e){super(t,{detail:e,bubbles:!0,cancelable:!0})}}let Ft=class extends rt{constructor({element:t,name:e="",type:s="html",render:r=__Ziko__.__Config__.default.render,props:n}={}){super(),this.exp={events:{}},nt(this,it,mt,gt,wt,bt,kt,Tt,St,Rt),t&&this.init({element:t,name:e,type:s,render:r,props:n})}on(t,e,{details_setter:s,category:r="global",isCustom:n=!1,preventDefault:i=!1}={}){t instanceof Array&&t.forEach(t=>this.on(t,e,{details_setter:s,category:r,isCustom:n,preventDefault:i})),r&&!this.exp.events.hasOwnProperty(r)&&(this.exp.events[r]=new yt(this,r)),n&&this.exp.events[r].cache.customEvents.add(t);const a=this.exp.events[r];return a.addListener(t,t=>{s&&s(a),e(t)},{preventDefault:i}),this}_off(t,e="global"){return this.exp.events[e].removeListener(t),this}get element(){return this.cache.element}get itemsTarget(){return this.cache.itemsTarget}get itemsTargetElement(){return this.itemsTarget.element}setItemsTarget(t){return this.cache.itemsTarget=t,this.items=t.items,this}isInteractive(){return this.cache.isInteractive}useClient(t){return this.cache.isInteractive||(this.element.setAttribute("data-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.register(()=>this),this.cache.isInteractive=!0),t&&this.element.setAttribute("data-hydration-directive",t),this}get st(){return this.cache.style}get attr(){return this.cache.attributes}get evt(){return this.events}get html(){return this.element.innerHTML}get text(){return this.element.textContent}get isBody(){return this.element===globalThis?.document.body}get parent(){return this.cache.parent}get width(){return this.element.getBoundingClientRect().width}get height(){return this.element.getBoundingClientRect().height}get top(){return this.element.getBoundingClientRect().top}get right(){return this.element.getBoundingClientRect().right}get bottom(){return this.element.getBoundingClientRect().bottom}get left(){return this.element.getBoundingClientRect().left}};const Pt=t=>"object"!=typeof t&&"function"!=typeof t||null===t,Dt=t=>(...e)=>{const s=e[0];return s?.isUIElement?.()||Pt(s)?new t({},...e):new t(s,...e.slice(1))};const Lt=["a","abb","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","ipnut","ins","kbd","label","legend","li","main","map","mark","menu","meter","nav","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","small","source","span","strong","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],$t=["svg","g","defs","symbol","use","image","switch","rect","circle","ellipse","line","polyline","polygon","path","text","tspan","textPath","altGlyph","altGlyphDef","altGlyphItem","glyph","glyphRef","linearGradient","radialGradient","pattern","solidColor","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncR","feFuncG","feFuncB","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","animate","animateMotion","animateTransform","set","script","desc","title","metadata","foreignObject"],Ut=["math","annotation","merror","mfrac","mi","mprescripts","mn","mo","mover","mpadded","mphantom","mprescripts","mroot","mrow","ms","semantics","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"],Nt=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return Lt.includes(r)&&(s="html"),$t.includes(r)&&(s="svg"),Ut.includes(r)&&(s="mathml"),(...t)=>0===t.length?new Ft({element:r,name:r,type:s}):["string","number"].includes(typeof t[0])||t[0]instanceof Ft||ht(t[0])||t[0]instanceof HTMLElement?new Ft({element:r,name:r,type:s}).append(...t):new Ft({element:r,type:s,props:t.shift()}).append(...t)}});class qt extends Ft{constructor(...t){super({element:"div",name:"view"}),this.append(...t)}}function Bt(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function Zt(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function Vt(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function Wt(t){return Vt(-t)}class Ht extends Ft{constructor({tag:t="div",orientation:e="h",order:s,w:r="100%",h:n="100%"}={}){super({element:t,name:"Flex"}),this.direction="cols",this.style({display:"flex"})}isFlex(){return!0}responsify(t,e=!0){return this.wrap(e),this.element.clientWidth<t?this.vertical():this.horizontal(),this}setSpaceAround(){return this.style({justifyContent:"space-around"}),this}setSpaceBetween(){return this.style({justifyContent:"space-between"}),this}setBaseline(){return this.style({alignItems:"baseline"}),this}gap(t){return"row"===this.direction?this.style({columnGap:t}):"column"===this.direction&&this.style({rowGap:t}),this}wrap(t="wrap"){return this.style({flexWrap:"string"==typeof t?t:["no-wrap","wrap","wrap-reverse"][+t]}),this}_justifyContent(t="center"){return this.style({justifyContent:t}),this}vertical(t,e,s=1){return Bt.call(this,s),this.style({alignItems:"number"==typeof t?Vt.call(this,t):t,justifyContent:"number"==typeof e?Wt.call(this,e):e}),this}horizontal(t,e,s=1){return Zt.call(this,s),this.style({alignItems:"number"==typeof e?Wt.call(this,e):e,justifyContent:"number"==typeof t?Vt.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}class Gt extends rt{constructor({element:t,name:e,type:s,render:r}){super({element:t,name:e,type:s,render:r})}}class Kt extends Gt{constructor(t,e){super({element:"div",name:"suspense"}),this.setAttr({dataTemp:"suspense"}),this.fallback_ui=t,this.append(t),(async()=>{try{const s=await e();t.unmount(),this.append(s)}catch(t){console.log({error:t})}})()}}class Yt extends Ft{#l=new WeakMap;constructor({activeIndex:t=0}={},...e){super({element:"div"}),this.style({display:"contents"}),this.states={activeIndex:t},this.append(...e),requestAnimationFrame(()=>{this.render()})}get activeItem(){return this.items[this.states.activeIndex]}render(){this.items.forEach((t,e)=>{const s=getComputedStyle(t.element).display;this.#l.set(t,s),e!==this.states.activeIndex&&t.style({display:"none"})})}get DS(){return this.#l}next(t=1){return this.activate(this.states.activeIndex+t)}previous(t=1){return this.activate(this.states.activeIndex-t)}activate(t){if(!this.items.length)return this;const e=this.items.at(this.states.activeIndex);e&&e.style({display:"none"});const s=this.items.length;this.states.activeIndex=(t%s+s)%s;const r=this.items.at(this.states.activeIndex);if(r){const t=this.#l.get(r)||"block";r.style({display:"none"===t?"block":t})}return this}}const Jt=Dt(Yt);class Xt extends Ft{constructor(...t){super({element:document.createDocumentFragment()}),this.append(...t)}isFragment(){return!0}}class Qt extends Xt{constructor({each:t,fallback:e,mapFn:s=()=>{}}={}){super(),this.config={each:t,fallback:e,mapFn:s},this.append(...this.config.each.map((t,e)=>this.config.mapFn(t,e)))}}class te extends Ft{constructor(t,e){super(),this.key=t,this.cases=e,this.init()}init(){Object.values(this.cases).filter(t=>t!=this.current).forEach(t=>t.unmount()),super.init(this.current.element)}get current(){const t=Object.keys(this.cases).find(t=>t==this.key)??"default";return this.cases[t]}updateKey(t){return this.key=t,this.replaceElementWith(this.current.element),this}}class ee extends Ft{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if(globalThis?.DOMParser){const e=(new DOMParser).parseFromString(`<div>${t}</div>`,"text/html");return e.body.firstChild.style.display="contents",e.body.firstChild}}(t)),this.style({display:"contents"})}}class se extends Ft{constructor(t){super({element:"div",name:"html_wrappper"}),this.element.append(function(t){if("undefined"!=typeof DOMParser){const e=(new DOMParser).parseFromString(t.trim(),"image/svg+xml").documentElement;if("parsererror"===e.nodeName)throw new Error("Invalid SVG string");if(e.hasAttribute("xmlns"))return e;const{children:s,attributes:r}=e,n=document.createElementNS("http://www.w3.org/2000/svg","svg");for(let{name:t,value:e}of r)n.setAttribute(t,e);return n.append(...s),globalThis.svg=e,globalThis.children=s,globalThis.attributes=r,globalThis.element=n,n}throw new Error("DOMParser is not available in this environment")}(t)),this.style({display:"contents"})}}class re extends Ft{constructor(t,e){super("canvas","canvas"),this.ctx=this.element?.getContext("2d"),this.style({border:"1px red solid"}),this.transformMatrix=new Z([[1,0,0],[0,1,0],[0,0,1]]),this.axisMatrix=new Z([[-10,-10],[10,10]]),requestAnimationFrame(()=>this.resize(t,e),0),this.on("sizeupdated",()=>this.adjust())}get Xmin(){return this.axisMatrix[0][0]}get Ymin(){return this.axisMatrix[0][1]}get Xmax(){return this.axisMatrix[1][0]}get Ymax(){return this.axisMatrix[1][1]}get ImageData(){return this.ctx.getImageData(0,0,c.Width,c.Height)}draw(t=!0){return t?(this.clear(),this.items.forEach(t=>{t.parent=this,t.draw(this.ctx)})):(this.items.at(-1).parent=this,this.items.at(-1).draw(this.ctx)),this.maintain(),this}applyTransformMatrix(){return this.ctx.setTransform(this.transformMatrix[0][0],this.transformMatrix[1][0],this.transformMatrix[0][1],this.transformMatrix[1][1],this.transformMatrix[0][2],this.transformMatrix[1][2]),this}resize(t,e){return this.size(t,e),this.lineWidth(),this.view(this.axisMatrix[0][0],this.axisMatrix[0][1],this.axisMatrix[1][0],this.axisMatrix[1][1]),this.emit("sizeupdated"),this}adjust(){return this.element.width=this.element?.getBoundingClientRect().width,this.element.height=this.element?.getBoundingClientRect().height,this.view(this.axisMatrix[0][0],this.axisMatrix[0][1],this.axisMatrix[1][0],this.axisMatrix[1][1]),this}view(t,e,s,r){return this.transformMatrix[0][0]=this.width/(s-t),this.transformMatrix[1][1]=-this.height/(r-e),this.transformMatrix[0][2]=this.width/2,this.transformMatrix[1][2]=this.height/2,this.axisMatrix=new Z([[t,e],[s,r]]),this.applyTransformMatrix(),this.clear(),this.lineWidth(1),this.draw(),this}reset(){return this.ctx.setTransform(1,0,0,0,0,0),this}append(t){return this.items.push(t),this.draw(!1),this}background(t){this.ctx.fillStyle=t,this.ctx.setTransform(1,0,0,1,0,0),this.ctx.fillRect(0,0,this.width,this.height),this.applyTransformMatrix(),this.draw()}lineWidth(t){return this.ctx.lineWidth=t/this.transformMatrix[0][0],this}getImageData(t=0,e=0,s=this.width,r=this.height){return this.ctx.getImageData(t,e,s,r)}clear(){return this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.width,this.height),this.applyTransformMatrix(),this}clone(){console.log(this.width);const t=new re;return t.items=this.items,t.transformMatrix=this.transformMatrix,t.axisMatrix=this.axisMatrix,Object.assign(t.cache,{...this.cache}),this.size(this.element.style.width,this.element.style.width),this.applyTransformMatrix(),this.draw(),this.adjust(),t}toImage(){return this.img=document?.createElement("img"),this.img.src=this.element?.toDataURL("image/png"),this}toBlob(){this.element.toBlob(function(t){var e=document?.createElement("img"),s=URL.createObjectURL(t);e.onload=function(){URL.revokeObjectURL(s)},e.src=s,console.log(e)})}zoomIn(){}zoomOut(){}undo(t){}redo(t){}stream(){}}class ne extends Ft{constructor(t=360,e=300){super("svg","svg"),this.style({border:"1px black solid"}),this.size(t,e),this.view(-10,-10,10,10)}size(t,e){return this.setAttr({width:t,height:e}),this}view(t,e,s,r){let n=Math.abs(s-t),i=Math.abs(r-e);return this.setAttr("viewBox",[t,e,n,i].join(" ")),this.st.scaleY(-1),this}add(...t){for(let e=0;e<t.length;e++)this.element.append(t[e].element),this.items.push(t[e]);return this.maintain(),this}remove(...t){for(let e=0;e<t.length;e++)this.element?.removeChild(t[e].element),this.items=this.items.filter(e=>!t);return this.maintain(),this}mask(){}toString(){return(new XMLSerializer).serializeToString(this.element)}btoa(){return btoa(this.toString())}toImg(){return"data:image/svg+xml;base64,"+this.btoa()}toImg2(){return"data:image/svg+xml;charset=utf8,"+this.toString().replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("#","%23").replaceAll('"',"'")}}const{PI:ie,sqrt:ae,cos:oe,sin:he,acos:le,pow:ce}=Math,ue=t=>t,me=(t,e=7.5625,s=2.75)=>t<1/s?e*t*t:t<2/s?e*(t-=1.5/s)*t+.75:t<2.5/s?e*(t-=2.25/s)*t+.9375:e*(t-=2.625/s)*t+.984375;class pe{constructor(t,{ease:e=ue,step:s=50,t0:r=0,start:n=!0,duration:i=3e3}={}){this.callback=t,this.state={isRunning:!1,animationId:null,startTime:null,ease:e,step:s,autoStart:n,duration:i},this.t=0,this.tx=0,this.ty=0,this.i=0,this.state.autoStart&&this.start()}#c=()=>{this.t+=this.state.step,this.i++,this.tx=R(this.t,0,this.state.duration,0,1),this.ty=this.state.ease(this.tx),this.callback(this),this.t>=this.state.duration&&(clearInterval(this.state.animationId),this.state.isRunning=!1)};#u(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#c,this.state.step)),this}start(){return this.#u(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#u(!1)}stop(){return this.pause(),this.reset(!1),this}reset(t=!0){return this.t=0,this.tx=0,this.ty=0,this.i=0,t&&this.start(),this}}class fe{constructor(t,e,s=1/0,r){this.ms=e,this.fn=t,this.count=s,this.frame=1,this.id=null,this.running=!1,r&&this.start()}start(){return this.running||(this.running=!0,this.frame=1,this.id=setInterval(()=>{this.frame>this.count?this.stop():(this.fn.call(null,this),this.frame++)},this.ms)),this}stop(){return this.running&&(this.running=!1,clearInterval(this.id),this.id=null),this}isRunning(){return this.running}}class de extends fe{constructor(t=1e3/60){super(t,()=>this._tick()),this.elapsed=0,this._lastTime=performance.now(),this._callbacks=new Set}_tick(){const t=performance.now(),e=t-this._lastTime;this.elapsed+=e,this._lastTime=t;for(const t of this._callbacks)t({elapsed:this.elapsed,delta:e})}onTick(t){return this._callbacks.add(t),()=>this._callbacks.delete(t)}reset(){this.elapsed=0,this._lastTime=performance.now()}pause(){super.stop()}resume(){this._lastTime=performance.now(),super.start()}}class ge{constructor(t=[],{repeat:e=1,loop:s=!1}={}){this.tasks=t,this.repeat=e,this.loop=s,this.stopped=!1,this.running=!1,this.onStart=null,this.onTask=null,this.onEnd=null}async run(){if(this.running)return;this.running=!0,this.stopped=!1,this.onStart&&this.onStart();let t=this.repeat;do{for(const t of this.tasks){if(this.stopped)return;if(Array.isArray(t))await Promise.all(t.map(({fn:t,delay:e=0})=>new Promise(async s=>{e>0&&await new Promise(t=>setTimeout(t,e)),this.onTask&&this.onTask(t),await t(),s()})));else{const{fn:e,delay:s=0}=t;s>0&&await new Promise(t=>setTimeout(t,s)),this.onTask&&this.onTask(e),await e()}}}while(this.loop&&!this.stopped&&(t===1/0||t-- >1));!this.stopped&&this.onEnd&&this.onEnd(),this.running=!1}stop(){this.stopped=!0,this.running=!1}addTask(t){this.tasks.push(t)}clearTasks(){this.tasks=[]}}class be{constructor(t,{step:e=1e3,t0:s=0,t1:r=1/0,autoplay:n=!0}={}){this.callback=t,this.cache={isRunning:!1,id:null,last_tick:null,step:e,t0:s,t1:r,autoplay:n,pauseTime:null,frame:0},n&&(s?this.startAfter(s):this.start(),r!==1/0&&this.stopAfter(r))}get frame(){return this.cache.frame}get elapsed(){return this.cache.elapsed}start(){return this.cache.isRunning||(this.cache.frame=0,this.cache.isRunning=!0,this.cache.last_tick=Date.now(),this.animate()),this}pause(){return this.cache.isRunning&&(clearTimeout(this.cache.id),this.cache.isRunning=!1,this.cache.pauseTime=Date.now()),this}resume(){if(!this.cache.isRunning){if(this.cache.isRunning=!0,this.cache.pauseTime){const t=Date.now()-this.cache.pauseTime;this.cache.last_tick+=t}this.animate()}return this}stop(){return this.pause(),this.cache.frame=0,this}startAfter(t=1e3){return setTimeout(()=>this.start(),t),this}stopAfter(t=1e3){return setTimeout(()=>this.stop(),t),this}animate=()=>{if(this.cache.isRunning){const t=Date.now(),e=t-this.cache.last_tick;e>=this.cache.step&&(this.cache.elapsed=t-(this.cache.t0||0),this.callback(this),this.cache.frame++,this.cache.last_tick=t-e%this.cache.step),this.cache.id=setTimeout(this.animate,0)}}}const we=(t,e=",")=>t.trim().trimEnd().split("\n").map(t=>t.split(e)),ye=(t,e=",")=>{const[s,...r]=we(t,e);return r.map(t=>{const e={};return s.forEach((s,r)=>{e[s]=t[r]}),e})},xe=t=>t instanceof Array?[Object.keys(t[0]),...t.map(t=>Object.values(t))]:[Object.keys(t)],ve=(t,e)=>xe(t).map(t=>t.join(e)).join("\n"),Me=(t,e=",")=>ve(t instanceof Object?t:JSON.parse(t),e),_e=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach(t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=_e(t,`${e} `);s.push(...r)}else s.push(`${e}- ${t}`)});else for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];if("object"==typeof n&&null!==n){s.push(`${e}${r}:`);const t=_e(n,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${n}`)}return s},Te=(t,e="")=>_e(t,e).join("\n"),Ee=(t,e)=>Te(t instanceof Object?t:JSON.parse(t),e),ke=(t,e=1)=>{let s="";for(const r in t)if(t.hasOwnProperty(r)){const n=t[r];s+="\n"+" ".repeat(e)+`<${r}>`,s+="object"==typeof n?ke(n,e+2):`${n}`,s+=`</${r}>`}return s.trim()},Ce=t=>(new XMLSerializer).serializeToString(t),Se=t=>btoa(Ce(t)),Ae=t=>"data:image/svg+xml;base64,"+Se(t),je=(t,e=0)=>{t=Oe(t);let s="";const r=" ".repeat(e);for(let n in t)if("object"==typeof t[n]){s+=`${r}${n} {\n`;const i=t[n];for(let t in i)"object"==typeof i[t]?s+=je({[t]:i[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}: ${i[t]};\n`;s+=`${r}}\n`}return s};function Oe(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce((e,s)=>(e[s.trim()]=Oe(t[s]),e),Array.isArray(t)?[]:{})}function Ie(t){const e={type:t.nodeName,attributes:{},children:[]};for(let s=0;s<t.attributes.length;s++){const r=t.attributes[s];e.attributes[r.name]=r.value}for(let s=0;s<t.childNodes.length;s++){const r=t.childNodes[s];r.nodeType===Node.ELEMENT_NODE?e.children.push(Ie(r)):r.nodeType===Node.TEXT_NODE&&(e.text=r.textContent.trim())}return e}class Re{constructor({head:t=null,wrapper:e=null,target:s=null}){this.head=t,this.wrapper=e,this.target=s,this.init()}get isZikoApp(){return!0}init(){this.head&&this.setHead(this.head),this.wrapper&&this.setWrapper(this.wrapper),this.target&&this.setTarget(this.target),this.wrapper&&this.target&&this.wrapper.mount(this.target)}setTarget(t){return t instanceof HTMLElement?this.target=t:"string"==typeof t&&(this.target=globalThis?.document?.querySelector(t)),this}setWrapper(t){return t?.isUIElement?this.wrapper=t:"function"==typeof t&&(this.wrapper=t()),this}}function ze(t){return/:\w+/.test(t)}class Fe extends Re{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",ft("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.mount(location.pathname)}clear(){return[...this.routes].forEach(t=>{!ze(t[0])&&t[1]?.isUIElement&&t[1].unmount()}),this}mount(t){const[e,s]=[...this.routes].find(e=>function(t,e){const s=t.split("/"),r=e.split("/");if(s.length!==r.length)return!1;for(let t=0;t<s.length;t++){const e=s[t],n=r[t];if(!e.startsWith(":")&&e!==n)return!1}return!0}(e[0],t));let r;if(ze(e)){const n=function(t,e){const s=t.split("/"),r=e.split("/"),n={};if(s.length!==r.length)return n;for(let t=0;t<s.length;t++){const e=s[t],i=r[t];if(e.startsWith(":"))n[e.slice(1)]=i;else if(e!==i)return{}}return n}(e,t);r=s.call(this,n)}else s?.isUIElement&&s.mount(this.wrapper),"function"==typeof s&&(r=s());return r?.isUIElement&&r.mount(this.wrapper),r instanceof Promise&&r.then(t=>t.mount(this.wrapper)),globalThis.history.pushState({},"",t),this}}const Pe=({head:t,wrapper:e,target:s,routes:r})=>new Fe({head:t,wrapper:e,target:s,routes:r});function De(t,e="./src/pages",s=["js","ts"]){"/"===e.at(-1)&&(e=e.slice(0,-1));const r=t.replace(/\\/g,"/").replace(/\[(\w+)\]/g,"$1/:$1").split("/"),n=e.split("/"),i=r.indexOf(n.at(-1));if(-1!==i){const t=r.slice(i+1),e=r.at(-1),n="index.js"===e||"index.ts"===e,a=s.some(t=>e===`.${t}`||e.endsWith(`.${t}`));if(n)return"/"+(t.length>1?t.slice(0,-1).join("/"):"");if(a)return"/"+t.join("/").replace(/\.(js|ts)$/,"")}return""}const Le=(t,...e)=>{const s=e.map(e=>null===e||["number","string","boolean","bigint","undefined"].includes(typeof e)||e?.__mapfun__?t(e):e instanceof Array?e.map(e=>Le(t,e)):ArrayBuffer.isView(e)?e.map(e=>t(e)):e instanceof Set?new Set(Le(t,...e)):e instanceof Map?new Map([...e].map(e=>[e[0],Le(t,e[1])])):e.isMatrix?.()?new e.constructor(e.rows,e.cols,Le(e.arr.flat(1))):e instanceof Object?Object.fromEntries(Object.entries(e).map(e=>[e[0],Le(t,e[1])])):void 0);return 1==s.length?s[0]:s};class $e{#m;#p=new Map;#f=0;constructor(){const t=new Blob(['\n this.onmessage = function(e) {\n const { id, funStr, args, close } = e.data;\n try {\n const func = new Function("return " + funStr)();\n const result = func(...args);\n postMessage({ id, result });\n } catch (error) {\n postMessage({ id, error: error.message });\n } finally {\n if (close) self.close();\n }\n }\n '],{type:"text/javascript"});this.#m=new Worker(URL.createObjectURL(t)),this.#m.addEventListener("message",t=>{const{id:e,result:s,error:r}=t.data,n=this.#p.get(e);n&&(n(s,r),this.#p.delete(e))})}call(t,e,s=[],r=!0){if("function"!=typeof t)throw new TypeError("func must be a function");const n=++this.#f;return this.#p.set(n,e),this.#m.postMessage({id:n,funStr:t.toString(),args:s,close:r}),this}terminate(){this.#m.terminate()}}class Ue{constructor(t=10){this.events={},this.maxListeners=t}on(t,e){return this.events[t]||(this.events[t]=[]),this.events[t].push(e),this.events[t].length>this.maxListeners&&console.warn(`Warning: Possible memory leak. Event '${t}' has more than ${this.maxListeners} listeners.`),this}once(t,e){const s=(...r)=>{this.off(t,s),e(...r)};return this.on(t,s)}off(t,e){const s=this.events[t];if(!s)return this;const r=s.indexOf(e);return-1!==r&&s.splice(r,1),this}emit(t,e){const s=this.events[t];return!!s&&([...s].forEach(s=>{try{s(e)}catch(e){console.error(`Error in listener for '${t}':`,e)}}),!0)}remove(t){return delete this.events[t],this}clear(){return this.events={},this}setMaxListeners(t){return this.maxListeners=t,this}}const Ne=t=>new Ue(t);class qe{#d;#g;#b=null;constructor(t=[],e=()=>{}){this.#d=t,this.#g=e,this.#o()}#w(){return this.#d.some(({query:t})=>globalThis.matchMedia(t).matches)}#o(){this.#d.forEach(({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.#w();s.matches?(e(),this.#b=e):t||this.#b===this.#g||(this.#g(),this.#b=this.#g)};r(),s.addEventListener("change",r)})}}class Be{constructor(t=document.title,e=!0){this.cache={emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.emitter=Ne(),this}setTitle(t){return t!==document.title&&(document.title=t,this.cache.emitter&&this.cache.emitter.emit("ziko:title-changed",t)),this}get current(){return document.title}onChange(t){return this.cache.emitter&&this.cache.emitter.on("ziko:title-changed",t),this}}class Ze{constructor(t,{namespace:e="Ziko",ValidateCssProps:s=!1}={}){this.currentPropsMap=t,this.namespace=e,this.ValidateCssProps=s,this.use(t)}use(t){return this.ValidateCssProps&&function(t){const e=new Set(Object.keys(document.documentElement.style));for(const s in t)if(!e.has(s))throw new Error(`Invalid CSS property: "${s}"`)}(t),this.currentPropsMap=t,this.#h(),this}#h(){const t=globalThis?.document?.documentElement?.style;for(const e in this.currentPropsMap){const s=this.namespace?`--${this.namespace}-${e}`:`--${e}`;t.setProperty(s,this.currentPropsMap[e]),Object.defineProperty(this,e,{value:`var(${s})`,writable:!0,configurable:!0,enumerable:!1})}}}const Ve=t=>Object.fromEntries(new URLSearchParams(globalThis?.location?.search));let{sqrt:We,cos:He,sin:Ge,exp:Ke,log:Ye,cosh:Je,sinh:Xe}=Math;for(const t of Object.getOwnPropertyNames(Math)){const e=Math[t];"function"==typeof e&&(Math[t]=new Proxy(e,{apply(e,s,r){const n=r[0];if("number"==typeof n||0===r.length)return e.apply(s,r);if(n?.isComplex?.()){const{a:t,b:i,z:a,phi:o}=n,h=(t,e)=>new n.constructor(t,e);switch(e.name){case"abs":return n.z;case"sqrt":return h(We(a)*He(o/2),We(a)*Ge(o/2));case"log":return h(Ye(a),o);case"exp":return h(Ke(t)*He(i),Ke(t)*Ge(i));case"cos":return h(He(t)*Je(i),-Ge(t)*Xe(i));case"sin":return h(Ge(t)*Je(i),He(t)*Xe(i));case"tan":{const e=He(2*t)+Je(2*i);return h(Ge(2*t)/e,Xe(2*i)/e)}case"cosh":return h(Je(t)*He(i),Xe(t)*Ge(i));case"sinh":return h(Xe(t)*He(i),Je(t)*Ge(i));case"tanh":{const e=Je(2*t)+He(2*i);return h(Xe(2*t)/e,Ge(2*i)/e)}default:return e.apply(s,r)}}throw new TypeError(`Math.${t} expects only numbers`)}}))}globalThis?.document&&document?.addEventListener("DOMContentLoaded",__Ziko__.__Config__.init()),t.App=({head:t,wrapper:e,target:s})=>new Re({head:t,wrapper:e,target:s}),t.Canvas=(t,e)=>new re(t,e),t.ClickAwayEvent=xt,t.ClickListeners=Tt,t.Clock=de,t.CloneElement=t=>new t.__proto__.constructor,t.Complex=y,t.E=s,t.EPSILON=r,t.EventController=yt,t.FileBasedRouting=async function(t){const e=Object.keys(t),s=function(t){if(0===t.length)return"";const e=t.map(t=>t.split("/")),s=Math.min(...e.map(t=>t.length));let r=[];for(let t=0;t<s;t++){const s=e[0][t];if(!e.every(e=>e[t]===s||e[t].startsWith("[")))break;r.push(s)}return r.join("/")+(r.length?"/":"")}(e),r={};for(let n=0;n<e.length;n++){const i=await t[e[n]](),a=await i.default;Object.assign(r,{[De(e[n],s)]:a})}return Pe({target:document.body,routes:{"/":()=>{},...r},wrapper:Nt.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new Ht(e).append(...t)},t.For=({each:t,fallback:e,mapFn:s}={})=>new Qt({each:t,fallback:e,mapFn:s}),t.Fragment=(...t)=>new Xt(...t),t.HTMLWrapper=t=>new ee(t),t.KeyListeners=St,t.Matrix=Z,t.PI=e,t.PtrListeners=kt,t.Random=w,t.SPA=Pe,t.SVGWrapper=t=>new se(t),t.Scheduler=(t,{repeat:e=null}={})=>new ge(t,{repeat:e}),t.Suspense=(t,e)=>new Kt(t,e),t.Svg=(t,e)=>new ne(t,e),t.Swap=Jt,t.SwipeEvent=zt,t.Switch=({key:t,cases:e})=>new te(t,e),t.Tick=fe,t.TimeAnimation=pe,t.TimeLoop=be,t.TimeScheduler=ge,t.UICanvas=re,t.UIElement=Ft,t.UIFlex=Ht,t.UIFragment=Xt,t.UIHTMLWrapper=ee,t.UINode=V,t.UISVGWrapper=se,t.UISuspense=Kt,t.UISvg=ne,t.UISwap=Yt,t.UISwitch=te,t.UIView=qt,t.UseRoot=Ze,t.UseThread=$e,t.View=(...t)=>new qt(...t),t.ViewEvent=jt,t.ViewListeners=Rt,t.ZikoApp=Re,t.ZikoSPA=Fe,t.ZikoUIText=pt,t.abs=(...t)=>n(t=>t.isComplex?.()?t.z:Math.abs(t),...t),t.accum_max=t=>{let e=[],s=-1/0;for(let r of t)s=Math.max(s,r),e.push(s);return e},t.accum_min=t=>{let e=[],s=1/0;for(let r of t)s=Math.min(s,r),e.push(s);return e},t.accum_prod=(...t)=>{let e,s=[],r=1,n=t.length;for(e=0;e<n;e++)r=C(r,t[e]),s.push(r);return s},t.accum_product=t=>{let e=[],s=1;for(let r of t)s*=r,e.push(s);return e},t.accum_sum=g,t.acos=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t,r=Math.hypot(e+1,s),n=Math.hypot(e-1,s);return globalThis.Rp=r,globalThis.Rm=n,new t.constructor(Math.acos((r-n)/2),-Math.acosh((r+n)/2)).toFixed(8)}return+Math.acos(t).toFixed(8)},...t),t.acosh=(...t)=>n(t=>t?.isComplex?_(t.clone().add(M(t.clone().mul(t.clone()).sub(1)))):+Math.acosh(t).toFixed(8),...t),t.acot=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t;return new t.constructor(Math.atan(2*e/(e**2+(s-1)*(s+1)))/2,Math.log((e**2+(s-1)**2)/(e**2+(s+1)**2))/4).toFixed(8)}return+(Math.PI/2-Math.atan(t)).toFixed(8)},...t),t.add=E,t.add_class=(t,e)=>t.element.className=t.element.className.replace(/\s+$/gi,"")+" "+e,t.add_vendor_prefix=function(t){const e=t.slice(0,1).toUpperCase()+t.slice(1),s=["Webkit","Moz","O","ms"];for(let t=0,r=s.length;t<r;t++){const r=s[t];if(void 0!==(globalThis?.document?.body).style[r+e])return r+e}return t},t.and=D,t.animation=(t,{ease:e,t0:s,t1:r,start:n,duration:i}={})=>new pe(t,{ease:e,t0:s,t1:r,start:n,duration:i}),t.apply_fun=i,t.arc=t=>1-he(le(t)),t.asin=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t,r=Math.hypot(e+1,s),n=Math.hypot(e-1,s);return new t.constructor(Math.asin((r-n)/2),Math.acosh((r+n)/2)).toFixed(8)}return+Math.asin(t).toFixed(8)},...t),t.asinh=(...t)=>n(t=>t?.isComplex?_(t.clone().add(M(t.clone().mul(t.clone()).add(1)))):+Math.asinh(t).toFixed(8),...t),t.atan=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t;return new t.constructor(Math.atan(2*e/(1-e**2-s**2))/2,Math.log((e**2+(1+s)**2)/(e**2+(1-s)**2))/4).toFixed(8)}return+Math.atan(t).toFixed(8)},...t),t.atan2=z,t.atanh=(...t)=>n(t=>+Math.atanh(t).toFixed(8),...t),t.back=(t,e=1)=>t**2*((e+1)*t-e),t.binomial=(t,e)=>{if(t!==Math.floor(t))return TypeError("n must be an integer");if(e!==Math.floor(e))return TypeError("k must be an integer");if(t<0)return TypeError("n must be non-negative");if(e<0||t<0||e>t)return 0;e>t-e&&(e=t-e);let s,r=1;for(s=0;s<e;s++)r=r*(t-s)/(s+1);return r},t.call_with_optional_props=Dt,t.cbrt=(...t)=>n(t=>t.isComplex?.()?new t.constructor({z:t.z**(1/3),phi:t.phi/3}).toFixed(8):+Math.cbrt(t).toFixed(8),...t),t.ceil=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.ceil(t.a),Math.ceil(t.b)):Math.ceil(t),...t),t.clamp=I,t.clock=t=>new de(t),t.cloneUI=t=>Object.assign(Object.create(Object.getPrototypeOf(t)),t),t.complex=x,t.contraharmonic_mean=(...t)=>{let e,s=0,r=0,n=t.length;for(e=0;e<n;e++)s+=t[e]**2,r+=t[e];return s/r},t.cos=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.cos(t.a)*Math.cosh(t.b),-Math.sin(t.a)*Math.sinh(t.b)).toFixed(8):+Math.cos(t).toFixed(8),...t),t.cosh=(...t)=>n(t=>t?.isComplex?new t.constructor(Math.cosh(t.a)*Math.cos(t.b),Math.sinh(t.a)*Math.sin(t.b)).toFixed(8):+Math.cosh(t).toFixed(8),...t),t.coth=(...t)=>n(t=>{if(t?.isComplex){const{a:e,b:s}=t,r=Math.sinh(e)**2*Math.cos(s)**2+Math.cosh(e)**2*Math.sin(s)**2;return new t.constructor(Math.cosh(e)*Math.sinh(e)/r,-Math.sin(s)*Math.cos(s)/r).toFixed(8)}return+(1/Math.tanh(t)).toFixed(8)},...t),t.croot=(...t)=>{const e=t.pop();if(!e.isComplex?.())throw Error("croot expect Complex number as root");return n(t=>{"number"==typeof t&&(t=new e.constructor(t,0));const{a:s,b:r}=e,{z:n,phi:i}=t,a=Math.hypot(s,r),o=Math.exp((Math.log(n)*s+i*r)/a),h=(i*s-Math.log(n)*r)/a;return new e.constructor(o*Math.cos(h),o*Math.sin(h)).toFixed(8)},...t)},t.csv2arr=we,t.csv2json=(t,e=",")=>JSON.stringify(ye(t,e)),t.csv2matrix=(t,e=",")=>new Z(we(t,e)),t.csv2object=ye,t.csv2sql=(t,e)=>{const s=t=>t.trim().replace(/[^a-zA-Z0-9_]/g,""),r=t=>"'"+t.trim().replace(/'/g,"''")+"'",n=t.trim().trimEnd().split("\n").filter(t=>t),i=n[0].split(",").map(s);let a="INSERT INTO "+s(e)+" ("+i.join(", ")+") Values ",o=[];for(let t=1;t<n.length;t++){const e=n[t].split(",").map(r);o.push("("+e.join(", ")+")")}return a+o.join(",\n")},t.debounce=(t,e=1e3)=>(...s)=>setTimeout(()=>t(...s),e),t.defineParamsGetter=function(t){Object.defineProperties(t,{QueryParams:{get:function(){return globalThis.location.search.substring(1),Object.fromEntries(new URLSearchParams(location.search))},configurable:!1,enumerable:!0},HashParams:{get:function(){return globalThis.location.hash.substring(1).split("#")},configurable:!1,enumerable:!0}})},t.define_wc=function(t,e,s={},{mode:r="open"}={}){globalThis.customElements?.get(t)?console.warn(`Custom element "${t}" is already defined`):-1!==t.search("-")?globalThis.customElements?.define(t,class extends HTMLElement{static get observedAttributes(){return["style",...Object.keys(s)]}constructor(){super(),this.attachShadow({mode:r}),this.props={},this.mask={...s}}connectedCallback(){this.render()}render(){this.shadowRoot.innerHTML="";const t=e(this.props);t instanceof Array?t.forEach(t=>t.mount(this.shadowRoot)):t.mount(this.shadowRoot)}attributeChangedCallback(t,e,s){Object.assign(this.props,{[t]:this.mask[t].type(s)}),this.render()}}):console.warn(`"${t}" is not a valid custom element name`)},t.deg2rad=(...t)=>n(t=>t*Math.PI/180,...t),t.discret=(t,e=5)=>Math.ceil(t*e)/e,t.div=S,t.elastic=t=>-2*ce(2,10*(t-1))*oe(20*ie*t/3*t),t.ema=(t,e)=>{let s=[],r=t[0];s.push(r);for(let n=1;n<t.length;n++)r=e*t[n]+(1-e)*r,s.push(r);return s},t.exp=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.exp(t.a)*Math.cos(t.b),Math.exp(t.a)*Math.sin(t.b)).toFixed(8):+Math.exp(t).toFixed(8),...t),t.floor=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.floor(t.a),Math.floor(t.b)):Math.floor(t),...t),t.fract=(...t)=>n(t=>t.isComplex?.()?new t.constructor(t.a-Math.trunc(t.a),t.b-Math.trunc(t.b)):t-Math.trunc(t),...t),t.geo_mean=(...t)=>t.reduce((t,e)=>t*e)**(1/t.length),t.harmonic_mean=(...t)=>{let e=0,s=0;for(s=0;s<t.length;s++)e+=1/t[s];return t.length/e},t.hypot=(...t)=>{const e=t.find(t=>t.isComplex?.());if(e){const s=t.map(t=>t.isComplex?.()?t:new e.constructor(t,0));return Math.hypot(...s.map(t=>t.z))}return Math.hypot(...t)},t.in_back=(t,e=1.70158,s=e+1)=>s*ce(t,3)-e*t**2,t.in_bounce=(t,e=7.5625,s=2.75)=>1-me(1-t,e,s),t.in_circ=t=>1-ae(1-t**2),t.in_cubic=t=>t**3,t.in_elastic=(t,e=2*ie/3)=>0===t?0:1===t?1:-ce(2,10*t-10)*he((10*t-10.75)*e),t.in_expo=t=>0===t?0:2**(10*t-10),t.in_out_back=(t,e=1.70158,s=1.525*e)=>t<.5?ce(2*t,2)*(2*(s+1)*t-s)/2:(ce(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.in_out_bounce=(t,e=7.5625,s=2.75)=>t<.5?me(1-2*t,e,s)/2:me(2*t-1,e,s)/2,t.in_out_circ=t=>t<.5?(1-ae(1-(2*t)**2))/2:(ae(1-(-2*t+2)**2)+1)/2,t.in_out_cubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.in_out_elastic=(t,e=2*ie/4.5)=>0===t?0:1===t?1:t<.5?-ce(2,20*t-10)*he((20*t-11.125)*e)/2:ce(2,-20*t+10)*he((20*t-11.125)*e)/2+1,t.in_out_expo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.in_out_quad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.in_out_quart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.in_out_quint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.in_out_sin=t=>-(oe(ie*t)-1)/2,t.in_quad=t=>t**2,t.in_quart=t=>t**4,t.in_quint=t=>t**5,t.in_sin=t=>1-oe(t*ie/2),t.interquartile_mean=(...t)=>{let e=t.sort((t,e)=>t-e),s=e[Math.floor(.25*(e.length-1))],r=e[Math.floor(.75*(e.length-1))],n=e.filter(t=>t>=s&&t<=r);return u(n)},t.iqr=t=>l(t)-h(t),t.isStateGetter=ht,t.is_primitive=Pt,t.json2arr=t=>xe(t instanceof Object?t:JSON.parse(t)),t.json2css=je,t.json2csv=Me,t.json2csvFile=(t,e)=>{const s=Me(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=ke,t.json2xmlFile=(t,e)=>{const s=ke(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=Ee,t.json2ymlFile=(t,e)=>{const s=Ee(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=O,t.linear=ue,t.linkStyle=function(t){const e=document?.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),document.head.appendChild(e)},t.ln=_,t.loop=(t,e={})=>new be(t,e),t.map=R,t.mapfun=n,t.matrix=(t,e,s)=>new Z(t,e,s),t.matrix2=(...t)=>new Z(2,2,t),t.matrix3=(...t)=>new Z(3,3,t),t.matrix4=(...t)=>new Z(4,4,t),t.max=(...t)=>Math.max(...t),t.mean=u,t.median=t=>o(t,50),t.midhinge=(...t)=>{let e=t.sort((t,e)=>t-e);return(e[Math.floor(.25*(e.length-1))]+e[Math.floor(.75*(e.length-1))])/2},t.midrange=t=>(Math.min(...t)+Math.max(...t))/2,t.min=(...t)=>Math.min(...t),t.modulo=A,t.mul=C,t.nand=(...t)=>F(D(...t)),t.nor=(...t)=>F(L(...t)),t.norm=j,t.normalize_css_value=t=>"number"==typeof t?t+"px":t,t.not=F,t.nthr=(...t)=>{const e=t.pop();if("number"!=typeof e)throw Error("nthr expects a real number n");return n(t=>t.isComplex?.()?new t.constructor({z:t.z**(1/e),phi:t.phi/e}):t<0?e%2==2?x(0,(-t)**(1/e)).toFixed(8):+(-1*(-t)**(1/e)).toFixed(8):+(t**(1/e)).toFixed(8),...t)},t.or=L,t.out_back=(t,e=1.70158,s=e+1)=>1+s*ce(t-1,3)+e*ce(t-1,2),t.out_bounce=me,t.out_circ=t=>ae(1-(t-1)**2),t.out_cubic=t=>1-(1-t)**3,t.out_elastic=(t,e=2*ie/3)=>0===t?0:1===t?1:ce(2,-10*t)*he((10*t-.75)*e)+1,t.out_expo=t=>1===t?1:1-2**(-10*t),t.out_quad=t=>1-(1-t)**2,t.out_quart=t=>1-(1-t)**4,t.out_quint=t=>1-(1-t)**5,t.out_sin=t=>he(t*ie/2),t.parseXML=function(t){return Ie((new DOMParser).parseFromString(t,"text/xml").documentElement)},t.parse_props=et,t.percentile=o,t.pow=v,t.power_mean=(t,e)=>{let s=0,r=0,n=t.length;for(r=0;r<n;r++)s+=t[r]**e;return(s/n)**(1/e)},t.q1=h,t.q3=l,t.rad2deg=(...t)=>n(t=>t/Math.PI*180,...t),t.register_click_away_event=vt,t.register_swipe_event=function(t,e=5,s=100,r=500){let n=0,i=0,a=0,o=!1;function h(t){n=t.clientX,i=t.clientY,a=performance.now(),o=!0}function l(h){if(!o)return;o=!1;const l=h.clientX-n,c=h.clientY-i;let u=null,m=null;performance.now()-a<=r&&(Math.abs(l)>=e&&Math.abs(c)<=s?(u=l<0?"left":"right",m="swipe"+u):Math.abs(c)>=e&&Math.abs(l)<=s&&(u=c<0?"up":"down",m="swipe"+u)),m&&t.dispatchEvent(new zt(m,{direction:u,distX:l,distY:c,originalEvent:h}))}return t.addEventListener("pointerdown",h,{passive:!0}),t.addEventListener("pointerup",l,{passive:!0}),()=>{t.removeEventListener("pointerdown",h),t.removeEventListener("pointerup",l)}},t.register_view_event=Ot,t.remove_class=(t,e)=>t.element.className=t.element.className.replace(e,""),t.rms=(...t)=>{const e=t.length;return(Math.hypot(...t)/e)**(1/e)},t.rolling_std=(t,e)=>Math.sqrt(d(t,e)),t.rolling_variance=d,t.round=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.round(t.a),Math.round(t.b)):Math.round(t),...t),t.sample_std=(...t)=>Math.sqrt(p(...t)),t.sample_variance=p,t.script=function(t){const e=document?.createElement("script");e.setAttribute("src",t),document.head.appendChild(e)},t.sec=(...t)=>n(t=>(t.isComplex?.(),+(1/Math.cos(t)).toFixed(8)),...t),t.sig=(...t)=>n(t=>1/(1+Math.exp(-t)).toFixed(8),...t),t.sign=(...t)=>n(t=>{if(t.isComplex?.()){const{z:e,phi:s}=t;return 0===e?new t.constructor(0,0):new t.constructor({z:1,phi:s})}return Math.sign(t)},...t),t.sin=(...t)=>n(t=>t?.isComplex?new t.constructor(Math.sin(t.a)*Math.cosh(t.b),Math.cos(t.a)*Math.sinh(t.b)).toFixed(8):+Math.sin(t).toFixed(8),...t),t.sinh=(...t)=>n(t=>t?.isComplex?new t.constructor(Math.sinh(t.a)*Math.cos(t.b),Math.cosh(t.a)*Math.sin(t.b)).toFixed(8):+Math.sinh(t).toFixed(8),...t),t.sleep=t=>new Promise(e=>setTimeout(e,t)),t.sma=(t,e)=>{let s=[];for(let r=0;r<=t.length-e;r++){let n=0;for(let s=0;s<e;s++)n+=t[r+s];s.push(n/e)}return s},t.sqrt=M,t.std=(...t)=>Math.sqrt(m(...t)),t.step=(t,e=5)=>Math.floor(t*e)/e,t.step_fps=t=>1e3/t,t.style=(t,e)=>{t&&Object.assign(t.style,e)},t.sub=k,t.svg2ascii=Se,t.svg2img=(t,e=!0)=>Nt.img(Ae(t)).mount(e),t.svg2imgUrl=Ae,t.svg2str=Ce,t.tags=Nt,t.tan=(...t)=>n(t=>{if(t?.isComplex){const e=Math.cos(2*t.a)+Math.cosh(2*t.b);return new t.constructor(Math.sin(2*t.a)/e,Math.sinh(2*t.b)/e).toFixed(8)}return+Math.tan(t).toFixed(8)},...t),t.tanh=(...t)=>n(t=>{if(t?.isComplex){const e=Math.cosh(2*a)+Math.cos(2*b);return new t.constructor(Math.sinh(2*a)/e,Math.sin(2*b)/e).toFixed(8)}return+Math.tanh(t).toFixed(8)},...t),t.text=ft,t.throttle=At,t.tick=(t,e,s=1/0,r=!0)=>new fe(t,e,s,r),t.timeTaken=t=>{console.time("timeTaken");const e=t();return console.timeEnd("timeTaken"),e},t.time_memory_Taken=t=>{const e=Date.now(),s=performance.memory.usedJSHeapSize,r=t();return{elapsedTime:Date.now()-e,usedMemory:performance.memory.usedJSHeapSize-s,result:r}},t.timeout=function(t,e){let s;const r=new Promise(r=>{s=setTimeout(()=>{e&&e(),r()},t)});return{id:s,clear:()=>clearTimeout(s),promise:r}},t.trimmed_mean=(t,e)=>{let s=[...t].sort((t,e)=>t-e).slice(e,t.length-e);return u(...s)},t.trunc=(...t)=>n(t=>t.isComplex?.()?new t.constructor(Math.trunc(t.a),Math.trunc(t.b)):Math.trunc(t),...t),t.useDerived=function(t,e){let s=t(...e.map(t=>t().value));const r=new Set,n=()=>({value:s,_subscribe:t=>(r.add(t),()=>r.delete(t))});return n[at]=!0,n},t.useEffect=(t,e=[])=>{const s=e.filter(ht);let r;const n=()=>{"function"==typeof r&&r();const e=s.map(t=>t().value);r=t(...e)},i=s.map(t=>t()._subscribe(n));return n(),()=>{i.forEach(t=>{t()}),"function"==typeof r&&(r(),r=void 0)}},t.useEventEmitter=Ne,t.useIPC=X,t.useLocalStorage=(t,e,s=!0)=>new Q(localStorage,t,e,s),t.useMediaQuery=(t,e)=>new qe(t,e),t.useQueryParams=function(){const t=()=>Ve();return[t,(e,s=!0)=>{const r=t(),n="function"==typeof e?e(r):e,i=s?{...r,...n}:n,a=new URLSearchParams(i).toString();window.history.pushState({},"",`${window.location.pathname}${a?`?${a}`:""}`),window.dispatchEvent(new CustomEvent("queryparamschange",{detail:i}))}]},t.useReactive=t=>Le(t=>{const e=ot(t);return{get:e[0],set:e[1]}},t),t.useRoot=(t,e={})=>new Ze(t,e),t.useSessionStorage=(t,e,s=!0)=>new Q(sessionStorage,t,e,s),t.useState=ot,t.useThread=(t,e,s=[],r=!0)=>(new $e).call(t,e,s,r),t.useTitle=(t,e=!0)=>new Be(t,e),t.variance=m,t.wait=t=>new Promise(e=>setTimeout(e,t)),t.waitElm=t=>new Promise(e=>{if(t)return e(t);const s=new MutationObserver(()=>{t&&(e(t),s.disconnect())});s.observe(document?.body,{childList:!0,subtree:!0})}),t.waitForUIElm=t=>new Promise(e=>{if(t.element)return e(t.element);const s=new MutationObserver(()=>{t.element&&(e(t.element),s.disconnect())});s.observe(document?.body,{childList:!0,subtree:!0})}),t.waitForUIElmSync=(t,e=2e3)=>{const s=Date.now();for(;Date.now()-s<e;)if(t.element)return t.element},t.watchQueryParams=function(t){let e=location.search;const s=()=>{const s=location.search;s!==e&&(e=s,t(Ve()))};window.addEventListener("popstate",s);const r=history.pushState;history.pushState=function(...t){r.apply(this,t),s()};const n=history.replaceState;return history.replaceState=function(...t){n.apply(this,t),s()},t(Ve()),()=>{window.removeEventListener("popstate",s)}},t.weighted_mean=(t,e)=>{let s=0,r=0;for(let n=0;n<t.length;n++)s+=t[n]*e[n],r+=e[n];return s/r},t.weighted_std=(t,e)=>Math.sqrt(f(t,e)),t.weighted_variance=f,t.winsorized_mean=(t,e)=>{let s=[...t].sort((t,e)=>t-e),r=s[e],n=s[s.length-e-1];return s=s.map(t=>Math.max(r,Math.min(n,t))),u(s)},t.wma=(t,e)=>{let s=e.length,r=e.reduce((t,e)=>t+e,0),n=[];for(let i=0;i<=t.length-s;i++){let a=0;for(let r=0;r<s;r++)a+=t[i+r]*e[r];n.push(a/r)}return n},t.xnor=(...t)=>F($(...t)),t.xor=$});
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sun Aug 09 2026 11:06:22 GMT+0100 (UTC+01:00)
5
+ Date : Wed Aug 26 2026 10:48:40 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -2430,11 +2430,10 @@ var LifecycleMethods = /*#__PURE__*/Object.freeze({
2430
2430
  unmount: unmount
2431
2431
  });
2432
2432
 
2433
+ const STATE_GETTER = Symbol.for("ziko/hooks/STATE_GETTER");
2434
+
2433
2435
  // import { __init__global__ } from "../__ziko__/index.js";
2434
2436
 
2435
- // if (!globalThis.__Ziko__) __init__global__();
2436
-
2437
- const STATE_GETTER = Symbol.for("ziko.stateGetter");
2438
2437
 
2439
2438
  function useState(initialValue) {
2440
2439
  const state = {
@@ -2638,6 +2637,7 @@ async function __addItem__(adder, pusher, ...ele) {
2638
2637
  // Fix Items Latter
2639
2638
  if (ele[i] instanceof Function) {
2640
2639
  if (isStateGetter(ele[i])) {
2640
+ console.log({s : ele[i]()});
2641
2641
  const getter = ele[i]();
2642
2642
  ele[i] = text(getter.value);
2643
2643
  getter._subscribe(
@@ -5033,23 +5033,29 @@ function useDerived(deriveFn, sources) {
5033
5033
  let value = deriveFn(...sources.map(s => s().value));
5034
5034
  const subscribers = new Set();
5035
5035
 
5036
- sources.forEach(source => {
5037
- const srcValue = source();
5038
- srcValue._subscribe(() => {
5039
- {
5040
- const newVal = deriveFn(...sources.map(s => s().value));
5041
- if (newVal !== value) {
5042
- value = newVal;
5043
- subscribers.forEach(fn => fn(value));
5044
- }
5045
- }
5046
- });
5047
- });
5048
- return () => ({
5036
+ // const unsubscribers = sources.map(source => {
5037
+ // const srcValue = source();
5038
+
5039
+ // return srcValue._subscribe(() => {
5040
+ // const newVal = deriveFn(...sources.map(s => s().value));
5041
+
5042
+ // if (!Object.is(newVal, value)) {
5043
+ // value = newVal;
5044
+ // subscribers.forEach(fn => fn(value));
5045
+ // }
5046
+ // });
5047
+ // });
5048
+
5049
+ const getter = () => ({
5049
5050
  value,
5050
- isStateGetter : () => true,
5051
- _subscribe: (fn) => subscribers.add(fn)
5052
- })
5051
+ _subscribe: (fn) => {
5052
+ subscribers.add(fn);
5053
+ return () => subscribers.delete(fn);
5054
+ },
5055
+ });
5056
+
5057
+ getter[STATE_GETTER] = true;
5058
+ return getter
5053
5059
  }
5054
5060
 
5055
5061
  const mapfun=(fun,...X)=>{
@@ -5567,4 +5573,4 @@ if(globalThis?.document){
5567
5573
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5568
5574
  }
5569
5575
 
5570
- export { App, Canvas, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, For, Fragment, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, STATE_GETTER, SVGWrapper, Scheduler, Suspense, Svg, Swap, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UICanvas, UIElement$1 as UIElement, UIFlex, UIFragment, UIHTMLWrapper, UINode, UISVGWrapper, UISuspense, UISvg, UISwap, UISwitch, UIView, UseRoot, UseThread, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUIText, abs, accum_max, accum_min, accum_prod, accum_product, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arc, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cbrt, ceil, clamp, clock, cloneUI, complex, contraharmonic_mean, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, ema, exp$1 as exp, floor, fract, geo_mean, harmonic_mean, hypot, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, interquartile_mean, iqr, isStateGetter, is_primitive, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, ln, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, midhinge, midrange, min, modulo, mul, nand, nor, norm, normalize_css_value, not, nthr, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, parseXML, parse_props, percentile, pow$1 as pow, power_mean, q1, q3, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, rms, rolling_std, rolling_variance, round, sample_std, sample_variance, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sma, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trimmed_mean, trunc, useDerived, useEffect, useEventEmitter, useIPC, useLocalStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, weighted_mean, weighted_std, weighted_variance, winsorized_mean, wma, xnor, xor };
5576
+ export { App, Canvas, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, For, Fragment, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, SVGWrapper, Scheduler, Suspense, Svg, Swap, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UICanvas, UIElement$1 as UIElement, UIFlex, UIFragment, UIHTMLWrapper, UINode, UISVGWrapper, UISuspense, UISvg, UISwap, UISwitch, UIView, UseRoot, UseThread, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUIText, abs, accum_max, accum_min, accum_prod, accum_product, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arc, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cbrt, ceil, clamp, clock, cloneUI, complex, contraharmonic_mean, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, ema, exp$1 as exp, floor, fract, geo_mean, harmonic_mean, hypot, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, interquartile_mean, iqr, isStateGetter, is_primitive, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, ln, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, midhinge, midrange, min, modulo, mul, nand, nor, norm, normalize_css_value, not, nthr, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, parseXML, parse_props, percentile, pow$1 as pow, power_mean, q1, q3, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, rms, rolling_std, rolling_variance, round, sample_std, sample_variance, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sma, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trimmed_mean, trunc, useDerived, useEffect, useEventEmitter, useIPC, useLocalStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, weighted_mean, weighted_std, weighted_variance, winsorized_mean, wma, xnor, xor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "1.8.0",
3
+ "version": "1.10.0",
4
4
  "description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
5
5
  "keywords": [
6
6
  "front-end",
@@ -81,6 +81,7 @@ export async function __addItem__(adder, pusher, ...ele) {
81
81
  // Fix Items Latter
82
82
  if (ele[i] instanceof Function) {
83
83
  if (isStateGetter(ele[i])) {
84
+ console.log({s : ele[i]()})
84
85
  const getter = ele[i]();
85
86
  ele[i] = text(getter.value);
86
87
  getter._subscribe(
@@ -1,23 +1,30 @@
1
+ import { STATE_GETTER } from '../symbols/index.js';
2
+
1
3
  export function useDerived(deriveFn, sources) {
2
4
  let value = deriveFn(...sources.map(s => s().value));
3
5
  const subscribers = new Set();
4
- let paused = false;
5
6
 
6
- sources.forEach(source => {
7
- const srcValue = source();
8
- srcValue._subscribe(() => {
9
- if (!paused) {
10
- const newVal = deriveFn(...sources.map(s => s().value));
11
- if (newVal !== value) {
12
- value = newVal;
13
- subscribers.forEach(fn => fn(value));
14
- }
15
- }
16
- });
17
- });
18
- return () => ({
7
+ // const unsubscribers = sources.map(source => {
8
+ // const srcValue = source();
9
+
10
+ // return srcValue._subscribe(() => {
11
+ // const newVal = deriveFn(...sources.map(s => s().value));
12
+
13
+ // if (!Object.is(newVal, value)) {
14
+ // value = newVal;
15
+ // subscribers.forEach(fn => fn(value));
16
+ // }
17
+ // });
18
+ // });
19
+
20
+ const getter = () => ({
19
21
  value,
20
- isStateGetter : () => true,
21
- _subscribe: (fn) => subscribers.add(fn)
22
- })
22
+ _subscribe: (fn) => {
23
+ subscribers.add(fn);
24
+ return () => subscribers.delete(fn);
25
+ },
26
+ });
27
+
28
+ getter[STATE_GETTER] = true;
29
+ return getter
23
30
  }
@@ -2,7 +2,9 @@
2
2
 
3
3
  // if (!globalThis.__Ziko__) __init__global__();
4
4
 
5
- export const STATE_GETTER = Symbol.for("ziko.stateGetter");
5
+ // export const STATE_GETTER = Symbol.for("ziko.stateGetter");
6
+
7
+ import {STATE_GETTER} from '../symbols/index.js'
6
8
 
7
9
  export function useState(initialValue) {
8
10
  const state = {
@@ -1,23 +1,50 @@
1
+ // file-based-router/index.js
2
+
1
3
  import {
2
4
  get_root,
3
5
  normalize_path,
4
6
  routes_matcher,
5
7
  is_dynamic,
6
8
  dynamic_routes_parser,
9
+ sort_routes,
7
10
  renderer as ziko_renderer
8
- } from "../utils/index.js"
9
- export async function createSPAFileBasedRouter({
11
+ } from "../utils/index.js";
12
+
13
+ /**
14
+ * Environment-independent file-based router core
15
+ */
16
+ export async function createFileBasedRouter({
10
17
  pages = {},
11
- target = globalThis?.document?.body,
18
+ url = typeof location !== 'undefined' ? location.pathname : '/',
19
+ target = typeof document !== 'undefined' ? document.body : null,
12
20
  extensions = ['js', 'ts'],
13
21
  renderer = ziko_renderer,
14
22
  wrapper,
23
+ base = '/',
15
24
  } = {}) {
16
- if(!(target instanceof HTMLElement) && target?.element instanceof HTMLElement) target = target?.element;
17
- if (!(target instanceof HTMLElement)) {
18
- throw new Error("Invalid mount target: must be HTMLElement or UIElement");
25
+ // Normalize target element safely for UI frameworks/DOM wrapper objects
26
+ let mountTarget = target;
27
+ if (target && typeof target === 'object' && 'element' in target) {
28
+ mountTarget = target.element;
29
+ }
30
+
31
+ // 1. Normalize base path
32
+ let cleanBase = base === '.' ? '' : base.replace(/\/$/, '');
33
+ if (cleanBase && !cleanBase.startsWith('/')) {
34
+ cleanBase = '/' + cleanBase;
19
35
  }
20
- let path = decodeURIComponent(globalThis.location.pathname.replace(/\/$/, ''));
36
+
37
+ // 2. Normalize and extract current URL path
38
+ let rawPath = decodeURIComponent(url.replace(/\/$/, '')) || '/';
39
+
40
+ // Strip base prefix if matched
41
+ if (cleanBase && rawPath.startsWith(cleanBase)) {
42
+ rawPath = rawPath.slice(cleanBase.length) || '/';
43
+ }
44
+
45
+ let currentPath = rawPath.startsWith('/') ? rawPath : '/' + rawPath;
46
+
47
+ // 3. Normalize route masks
21
48
  const routes = Object.keys(pages);
22
49
  const root = get_root(routes);
23
50
 
@@ -25,21 +52,43 @@ export async function createSPAFileBasedRouter({
25
52
  for (const route of routes) {
26
53
  const module = await pages[route]();
27
54
  const modComponent = await module.default;
28
- pairs[normalize_path(route, root, extensions)] = modComponent;
55
+ const normalizedKey = normalize_path(route, root, extensions);
56
+ pairs[normalizedKey] = modComponent;
29
57
  }
30
58
 
59
+ // 4. Sort routes by precedence (Static -> Dynamic -> Catch-All -> Optional Catch-All)
60
+ const sortedRouteKeys = sort_routes(Object.keys(pairs));
61
+
31
62
  let mask = null;
32
63
  let component = null;
33
64
 
34
- for (const [routePath, comp] of Object.entries(pairs)) {
35
- if (routes_matcher(routePath, `/${path}`)) {
65
+ for (const routePath of sortedRouteKeys) {
66
+ if (routes_matcher(routePath, currentPath)) {
36
67
  mask = routePath;
37
- component = comp;
68
+ component = pairs[routePath];
38
69
  break;
39
70
  }
40
71
  }
41
- if (mask === null) return; // no route matched
42
- const params = is_dynamic(mask) ? dynamic_routes_parser(mask, path) : undefined;
43
- renderer(target, component, params, wrapper)
72
+
73
+ if (mask === null) {
74
+ return { mask: null, component: null, params: {}, matched: false };
75
+ }
76
+
77
+ const params = is_dynamic(mask) ? dynamic_routes_parser(mask, currentPath) : {};
78
+
79
+ // Execute renderer if a valid mount target is available
80
+ if (mountTarget && typeof renderer === 'function') {
81
+ await renderer(mountTarget, component, params, wrapper);
82
+ }
83
+
84
+ // Return router state for SSR/static build environments
85
+ return {
86
+ mask,
87
+ component,
88
+ params,
89
+ matched: true
90
+ };
44
91
  }
45
92
 
93
+ // Backward-compatible alias for SPA usage
94
+ export const createSPAFileBasedRouter = createFileBasedRouter;
@@ -3,9 +3,33 @@ export function dynamic_routes_parser(mask, route) {
3
3
  const routeSegments = route.split("/").filter(Boolean);
4
4
  const params = {};
5
5
  let i = 0, j = 0;
6
+
6
7
  while (i < maskSegments.length && j < routeSegments.length) {
7
8
  const maskSegment = maskSegments[i];
8
- const routeSegment = routeSegments[j];
9
+
10
+ // Handle [[...slug]]
11
+ if (maskSegment.startsWith("[[...") && maskSegment.endsWith("]]")) {
12
+ const paramName = maskSegment.slice(5, -2);
13
+ const remainingMaskSegments = maskSegments.length - i - 1;
14
+ if (remainingMaskSegments === 0) {
15
+ params[paramName] = routeSegments.slice(j).join("/");
16
+ break;
17
+ }
18
+ let requiredSegments = 0;
19
+ for (let k = i + 1; k < maskSegments.length; k++) {
20
+ if (!maskSegments[k].endsWith("]+")) requiredSegments++;
21
+ }
22
+ const remainingRouteSegments = routeSegments.length - j;
23
+ const segmentsToConsume = remainingRouteSegments - requiredSegments;
24
+ if (segmentsToConsume >= 0) {
25
+ params[paramName] = routeSegments.slice(j, j + segmentsToConsume).join("/");
26
+ j += segmentsToConsume;
27
+ } else return {};
28
+ i++;
29
+ continue;
30
+ }
31
+
32
+ // Handle [...slug]
9
33
  if (maskSegment.startsWith("[...") && maskSegment.endsWith("]")) {
10
34
  const paramName = maskSegment.slice(4, -1);
11
35
  const remainingMaskSegments = maskSegments.length - i - 1;
@@ -20,32 +44,42 @@ export function dynamic_routes_parser(mask, route) {
20
44
  const remainingRouteSegments = routeSegments.length - j;
21
45
  const segmentsToConsume = remainingRouteSegments - requiredSegments;
22
46
  if (segmentsToConsume >= 1) {
23
- params[paramName] = routeSegments
24
- .slice(j, j + segmentsToConsume)
25
- .join("/");
47
+ params[paramName] = routeSegments.slice(j, j + segmentsToConsume).join("/");
26
48
  j += segmentsToConsume;
27
- }
28
- else return {};
49
+ } else return {};
29
50
  i++;
30
51
  continue;
31
52
  }
53
+
32
54
  if (maskSegment.startsWith("[") && maskSegment.endsWith("]+")) {
33
55
  const paramName = maskSegment.slice(1, -2);
34
- if (routeSegment) {
35
- params[paramName] = routeSegment;
56
+ if (routeSegments[j]) {
57
+ params[paramName] = routeSegments[j];
36
58
  j++;
37
59
  }
38
60
  i++;
39
61
  continue;
40
62
  }
63
+
41
64
  if (maskSegment.startsWith("[") && maskSegment.endsWith("]")) {
42
65
  const paramName = maskSegment.slice(1, -1);
43
- params[paramName] = routeSegment;
44
- }
45
- else if (maskSegment !== routeSegment) return {};
66
+ params[paramName] = routeSegments[j];
67
+ } else if (maskSegment !== routeSegments[j]) return {};
68
+
46
69
  i++;
47
70
  j++;
48
71
  }
72
+
73
+ // Set default empty string for remaining uncaptured optional catch-alls
74
+ while (i < maskSegments.length) {
75
+ const maskSegment = maskSegments[i];
76
+ if (maskSegment.startsWith("[[...") && maskSegment.endsWith("]]")) {
77
+ const paramName = maskSegment.slice(5, -2);
78
+ if (!(paramName in params)) params[paramName] = "";
79
+ }
80
+ i++;
81
+ }
82
+
49
83
  return params;
50
84
  }
51
85
 
@@ -1,16 +1,24 @@
1
1
  export function get_root(paths) {
2
2
  if (paths.length === 0) return '';
3
- const splitPaths = paths.map(path => path.split('/'));
4
- const minLength = Math.min(...splitPaths.map(parts => parts.length));
3
+
4
+ // Strip trailing file names (e.g. /index.js or /about.js) to compare directory structures only
5
+ const dirPaths = paths.map(path => {
6
+ const parts = path.split('/');
7
+ parts.pop(); // Remove the filename
8
+ return parts;
9
+ });
10
+
11
+ const minLength = Math.min(...dirPaths.map(parts => parts.length));
5
12
  let commonParts = [];
13
+
6
14
  for (let i = 0; i < minLength; i++) {
7
- const part = splitPaths[0][i];
8
- if (splitPaths.every(parts => parts[i] === part || parts[i].startsWith('['))) {
15
+ const part = dirPaths[0][i];
16
+ if (dirPaths.every(parts => parts[i] === part || parts[i].startsWith('['))) {
9
17
  commonParts.push(part);
10
18
  }
11
19
  else break;
12
-
13
20
  }
21
+
14
22
  const root = commonParts.join('/') + (commonParts.length ? '/' : '');
15
23
  return root;
16
24
  }
@@ -1,21 +1,32 @@
1
1
  export function normalize_path(inputPath, root = './src/pages', extensions = ['js', 'ts', 'jsx', 'tsx']) {
2
- if(root.at(-1)==="/") root = root.slice(0, -1)
3
- const normalizedPath = inputPath.replace(/\\/g, '/')
4
- // .replace(/\[(\w+)\]/g, '$1/:$1');
5
- const parts = normalizedPath.split('/');
6
- const rootParts = root.split('/');
7
- const rootIndex = parts.indexOf(rootParts[rootParts.length - 1]);
8
- if (rootIndex !== -1) {
9
- const subsequentParts = parts.slice(rootIndex + 1);
10
- const lastPart = subsequentParts[subsequentParts.length - 1];
11
- const isIndexFile = extensions.some(ext => lastPart === `index.${ext}`);
12
- const hasValidExtension = lastPart && extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
13
- if (isIndexFile) return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
14
- // if (hasValidExtension) return '/' + subsequentParts.join('/').replace(/\.(js|ts)$/, '');
15
- if (hasValidExtension) {
16
- const regex = new RegExp(`\\.(${extensions.join('|')})$`);
17
- return '/' + subsequentParts.join('/').replace(regex, '');
18
- }
2
+ let cleanRoot = root.endsWith('/') ? root.slice(0, -1) : root;
3
+ const normalizedPath = inputPath.replace(/\\/g, '/');
4
+
5
+ // 1. Extract path relative to root
6
+ let relativePath = normalizedPath;
7
+ if (cleanRoot && normalizedPath.includes(cleanRoot)) {
8
+ relativePath = normalizedPath.split(cleanRoot).pop();
19
9
  }
20
- return '';
21
- }
10
+
11
+ // 2. Split directory parts & strip route groups like (auth)
12
+ const rawParts = relativePath.split('/').filter(Boolean).filter(p => !/^\([^)]+\)$/.test(p));
13
+ if (rawParts.length === 0) return '/';
14
+
15
+ const lastPart = rawParts[rawParts.length - 1];
16
+ const extRegex = new RegExp(`\\.(${extensions.join('|')})$`);
17
+
18
+ const isIndexFile = extensions.some(ext => lastPart === `index.${ext}`);
19
+ const fileNameWithoutExt = lastPart.replace(extRegex, '');
20
+
21
+ // Remove original file name from directory segments
22
+ rawParts.pop();
23
+
24
+ // 3. Handle flat dot notation without breaking [..slug] or [[..slug]]
25
+ if (!isIndexFile) {
26
+ // Splits by '.' ONLY if the dot is outside of bracketed patterns like [...] or [[...]]
27
+ const dotSegments = fileNameWithoutExt.split(/\.(?![^\[]*\])/);
28
+ rawParts.push(...dotSegments);
29
+ }
30
+
31
+ return '/' + rawParts.join('/');
32
+ }
@@ -1,7 +1,34 @@
1
1
  export function is_dynamic(path) {
2
- const DynamicPattern = /(:\w+|\[\.\.\.\w+\]|\[\w+\]\+?)/;
2
+ const DynamicPattern = /(:\w+|\[\[\.\.\.\w+\]\]|\[\.\.\.\w+\]|\[\w+\]\+?)/;
3
3
  return DynamicPattern.test(path);
4
4
  }
5
+ export function sort_routes(routeKeys) {
6
+ return [...routeKeys].sort((a, b) => {
7
+ const aIsOptionalCatchAll = a.includes('[[...');
8
+ const bIsOptionalCatchAll = b.includes('[[...');
9
+
10
+ const aIsCatchAll = a.includes('[...') && !aIsOptionalCatchAll;
11
+ const bIsCatchAll = b.includes('[...') && !bIsOptionalCatchAll;
12
+
13
+ const aIsDynamic = is_dynamic(a);
14
+ const bIsDynamic = is_dynamic(b);
15
+
16
+ // 1. Optional catch-alls [[...slug]] ALWAYS go last
17
+ if (aIsOptionalCatchAll && !bIsOptionalCatchAll) return 1;
18
+ if (!aIsOptionalCatchAll && bIsOptionalCatchAll) return -1;
19
+
20
+ // 2. Catch-alls [...slug] go right before optional catch-alls
21
+ if (aIsCatchAll && !bIsCatchAll) return 1;
22
+ if (!aIsCatchAll && bIsCatchAll) return -1;
23
+
24
+ // 3. Static routes go before standard dynamic routes ([id])
25
+ if (!aIsDynamic && bIsDynamic) return -1;
26
+ if (aIsDynamic && !bIsDynamic) return 1;
27
+
28
+ // 4. Deeper/longer routes take precedence over shorter ones
29
+ return b.length - a.length;
30
+ });
31
+ }
5
32
  export function routes_grouper(routeMap) {
6
33
  const grouped = {
7
34
  static: {},
@@ -2,18 +2,33 @@ export function routes_matcher(mask, route) {
2
2
  const maskSegments = mask.split("/").filter(Boolean);
3
3
  const routeSegments = route.split("/").filter(Boolean);
4
4
  let i = 0, j = 0;
5
+
5
6
  while (i < maskSegments.length && j < routeSegments.length) {
6
7
  const maskSegment = maskSegments[i];
7
- const routeSegment = routeSegments[j];
8
+
9
+ // Optional Catch-all [[...slug]]
10
+ if (maskSegment.startsWith("[[...") && maskSegment.endsWith("]]")) {
11
+ const remainingMaskSegments = maskSegments.length - i - 1;
12
+ if (remainingMaskSegments === 0) return true;
13
+ let requiredSegments = 0;
14
+ for (let k = i + 1; k < maskSegments.length; k++) {
15
+ if (!maskSegments[k].endsWith("]+")) requiredSegments++;
16
+ }
17
+ const remainingRouteSegments = routeSegments.length - j;
18
+ const segmentsToConsume = remainingRouteSegments - requiredSegments;
19
+ if (segmentsToConsume < 0) return false;
20
+ j += segmentsToConsume;
21
+ i++;
22
+ continue;
23
+ }
24
+
25
+ // Required Catch-all [...slug]
8
26
  if (maskSegment.startsWith("[...") && maskSegment.endsWith("]")) {
9
27
  const remainingMaskSegments = maskSegments.length - i - 1;
10
28
  if (remainingMaskSegments === 0) return true;
11
- // Calculate minimum required route segments for remaining mask
12
29
  let requiredSegments = 0;
13
30
  for (let k = i + 1; k < maskSegments.length; k++) {
14
- if (!maskSegments[k].endsWith("]+")) {
15
- requiredSegments++;
16
- }
31
+ if (!maskSegments[k].endsWith("]+")) requiredSegments++;
17
32
  }
18
33
  const remainingRouteSegments = routeSegments.length - j;
19
34
  if (remainingRouteSegments < requiredSegments) return false;
@@ -23,32 +38,40 @@ export function routes_matcher(mask, route) {
23
38
  i++;
24
39
  continue;
25
40
  }
41
+
26
42
  if (maskSegment.startsWith("[") && maskSegment.endsWith("]+")) {
27
- if (routeSegment) j++;
43
+ if (routeSegments[j]) j++;
28
44
  i++;
29
45
  continue;
30
46
  }
47
+
31
48
  if (maskSegment.startsWith("[") && maskSegment.endsWith("]")) {
32
49
  i++;
33
50
  j++;
34
51
  continue;
35
52
  }
36
- if (maskSegment !== routeSegment) return false;
53
+
54
+ if (maskSegment !== routeSegments[j]) return false;
37
55
  i++;
38
56
  j++;
39
57
  }
58
+
40
59
  while (i < maskSegments.length) {
41
60
  const seg = maskSegments[i];
61
+ // [[...slug]] and [param]+ can match empty segments at the end
62
+ if (seg.startsWith("[[...") && seg.endsWith("]]")) {
63
+ i++;
64
+ continue;
65
+ }
42
66
  if (seg.endsWith("]+")) {
43
67
  i++;
44
68
  continue;
45
69
  }
46
70
  return false;
47
71
  }
72
+
48
73
  return i === maskSegments.length && j === routeSegments.length;
49
74
  }
50
-
51
-
52
75
  // // DEMO
53
76
  // console.log("=== EXISTING TESTS ===");
54
77
  // console.log(routes_matcher("/user/[id]+", "/user")); // true
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Runtime brand identifying a ZikoJS `mapfun` function.
3
+ *
4
+ * Used for runtime type detection without importing the `mapfun`
5
+ * implementation, helping prevent circular dependencies.
6
+ */
7
+ export declare const MAPFUN: unique symbol;
8
+
9
+ /**
10
+ * Runtime brand identifying a ZikoJS `Complex` instance.
11
+ *
12
+ * Used for nominal runtime type detection without importing the
13
+ * `Complex` class directly.
14
+ */
15
+ export declare const COMPLEX: unique symbol;
16
+
17
+ /**
18
+ * Runtime brand identifying a ZikoJS `Matrix` instance.
19
+ *
20
+ * Used for nominal runtime type detection without importing the
21
+ * `Matrix` class directly.
22
+ */
23
+ export declare const MATRIX: unique symbol;
24
+
25
+ /**
26
+ * Runtime brand identifying a ZikoJS `UIElement` instance.
27
+ *
28
+ * Used to detect UI elements without creating a dependency on the
29
+ * `UIElement` implementation.
30
+ */
31
+ export declare const UIELEMENT: unique symbol;
32
+
33
+ /**
34
+ * Runtime brand identifying a ZikoJS state getter.
35
+ *
36
+ * Used by hooks and UI components to recognize state getters without
37
+ * importing the state implementation.
38
+ */
39
+ export declare const STATE_GETTER: unique symbol;
@@ -0,0 +1,5 @@
1
+ export const MAPFUN = Symbol.for('ziko/math/MAPFUN');
2
+ export const COMPLEX = Symbol.for('ziko/math/COMPLEX');
3
+ export const MATRIX = Symbol.for('ziko/math/MATRIX');
4
+ export const UIELEMENT = Symbol.for('ziko/dom/UIELEMENT');
5
+ export const STATE_GETTER = Symbol.for("ziko/hooks/STATE_GETTER");