ziko 0.44.0 → 0.45.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 24 2025 12:13:24 GMT+0100 (UTC+01:00)
5
+ Date : Sat Aug 30 2025 10:47:14 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
@@ -1074,7 +1074,7 @@ class UINode {
1074
1074
  }
1075
1075
  }
1076
1076
 
1077
- globalThis.node = (node) => new UINode(node);
1077
+ // globalThis.node = (node) => new UINode(node);
1078
1078
 
1079
1079
  function register_to_class(target, ...mixins){
1080
1080
  mixins.forEach(n => _register_to_class_(target, n));
@@ -1146,28 +1146,34 @@ function defineParamsGetter$1(target ){
1146
1146
  });
1147
1147
  }
1148
1148
 
1149
- const __UI__={
1150
- __all__(){
1151
- return Object.values(this)
1152
- .filter(Array.isArray)
1153
- .flat();
1154
- },
1155
- querySelectorAll(){
1156
- return this.__all__().filter(n=>n)
1157
- },
1158
- getElementByIndex(index){
1159
- return this.__all__().find(n=>n.ui_index===index);
1160
- },
1161
- getElementById(id){
1162
- return null;
1163
- },
1164
- getElementsByClass(){
1165
-
1166
- },
1167
- getElementsByTagName(){
1168
-
1149
+ class UIStore extends Array {
1150
+ constructor(...args) {
1151
+ super(...args);
1169
1152
  }
1170
- };
1153
+ getItemById(id) {
1154
+ return this.find(n => n.element.id === id);
1155
+ }
1156
+ getItemsByTagName(tag) {
1157
+ return this.filter(n => n.element.tagName.toLowerCase() === tag.toLowerCase());
1158
+ }
1159
+ getElementsByClassName(className) {
1160
+ return this.filter(n => n.element.classList?.contains(className));
1161
+ }
1162
+ querySelector(selector) {
1163
+ const el = globalThis?.document?.querySelector(selector);
1164
+ if (!el) return null;
1165
+ return this.find(ui => ui.element === el) || null;
1166
+ }
1167
+ querySelectorAll(selector) {
1168
+ const els = globalThis?.document?.querySelectorAll(selector);
1169
+ return Array.from(els)
1170
+ .map(el => this.find(ui => ui.element === el))
1171
+ .filter(Boolean);
1172
+ }
1173
+ }
1174
+
1175
+ // create the singleton
1176
+ const __UI__ = new UIStore();
1171
1177
 
1172
1178
  const __Config__ = {
1173
1179
  default:{
@@ -1190,10 +1196,10 @@ const __Config__ = {
1190
1196
  };
1191
1197
 
1192
1198
  const __HYDRATION__ = {
1193
- map : new Map(),
1199
+ store : new Map(),
1194
1200
  index : 0,
1195
- increment : function(){
1196
- return this.index ++
1201
+ register: function(component){
1202
+ this.store.set(this.index++, component);
1197
1203
  }
1198
1204
  };
1199
1205
 
@@ -1201,6 +1207,9 @@ const __CACHE__ = {
1201
1207
  ui_index : 0,
1202
1208
  get_ui_index:function(){
1203
1209
  return this.ui_index ++
1210
+ },
1211
+ register_ui: function(UIElement){
1212
+
1204
1213
  }
1205
1214
  };
1206
1215
 
@@ -1209,7 +1218,7 @@ const __State__ = {
1209
1218
  index : undefined?.data?.__Ziko__?.__State__?.index ?? 0,
1210
1219
  register: function(state){
1211
1220
  console.log({
1212
- hmr : undefined?.data.__Ziko__.__State__.index,
1221
+ // hmr : import.meta.hot?.data.__Ziko__.__State__.index,
1213
1222
  index : this.index
1214
1223
  });
1215
1224
  this.store.set(this.index++, state);
@@ -1223,7 +1232,6 @@ function __init__global__(){
1223
1232
  __UI__,
1224
1233
  __HYDRATION__,
1225
1234
  __State__,
1226
- // __HYDRATION_MAP__,
1227
1235
  __Config__,
1228
1236
  __CACHE__,
1229
1237
  };
@@ -2871,7 +2879,7 @@ const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQ
2871
2879
 
2872
2880
  __init__global__();
2873
2881
  class UIElement extends UINode{
2874
- constructor({element, name ='', type="html", useDefaultStyle=false}={}){
2882
+ constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
2875
2883
  super();
2876
2884
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
2877
2885
  if(typeof element === "string") {
@@ -2922,8 +2930,8 @@ class UIElement extends UINode{
2922
2930
  resize:null,
2923
2931
  intersection:null
2924
2932
  };
2925
- if(element)Object.assign(this.cache,{element});
2926
- this.uuid = `${this.cache.name}-${Random.string(16)}`;
2933
+ if(element) Object.assign(this.cache,{element});
2934
+ // this.uuid = `${this.cache.name}-${Random.string(16)}`
2927
2935
  this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
2928
2936
  useDefaultStyle && this.style({
2929
2937
  position: "relative",
@@ -2933,9 +2941,9 @@ class UIElement extends UINode{
2933
2941
  width : "auto",
2934
2942
  height : "auto"
2935
2943
  });
2936
- this.items = [];
2944
+ this.items = new UIStore();
2937
2945
  globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
2938
- element && globalThis.__Ziko__.__Config__.default.render && this?.render?.();
2946
+ element && render && this?.render?.();
2939
2947
  if(
2940
2948
  // globalThis.__Ziko__.__Config__.renderingMode !== "spa"
2941
2949
  // &&
@@ -2944,9 +2952,9 @@ class UIElement extends UINode{
2944
2952
  this.isInteractive()
2945
2953
  ){
2946
2954
  this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
2947
- globalThis.__Ziko__.__HYDRATION__.map.set(globalThis.__Ziko__.__HYDRATION__.index, ()=>this);
2948
- globalThis.__Ziko__.__HYDRATION__.increment();
2955
+ globalThis.__Ziko__.__HYDRATION__.register(() => this);
2949
2956
  }
2957
+ globalThis.__Ziko__.__UI__.push(this);
2950
2958
  }
2951
2959
  get element(){
2952
2960
  return this.cache.element;
@@ -2997,14 +3005,13 @@ class UIElement extends UINode{
2997
3005
  return this.element.getBoundingClientRect().left;
2998
3006
  }
2999
3007
  clone(render=false) {
3000
- const UI = new this.constructor();
3001
- UI.__proto__=this.__proto__;
3002
- if(this.items.length){
3003
- const items = [...this.items].map(n=>n.clone());
3004
- UI.append(...items);
3005
- }
3006
- else UI.element=this.element.cloneNode(true);
3007
- return UI.render(render);
3008
+ // UI.__proto__=this.__proto__;
3009
+ // if(this.items.length){
3010
+ // const items = [...this.items].map(n=>n.clone());
3011
+ // UI.append(...items);
3012
+ // }
3013
+ // else UI.element=this.element.cloneNode(true);
3014
+ // return UI.render(render);
3008
3015
  }
3009
3016
  [Symbol.iterator]() {
3010
3017
  return this.items[Symbol.iterator]();
@@ -3023,14 +3030,14 @@ class UIElement extends UINode{
3023
3030
  this.cache.isFrozzen=freeze;
3024
3031
  return this;
3025
3032
  }
3026
- setTarget(tg) {
3027
- if(this.isBody) return ;
3028
- if (tg?.isZikoUIElement) tg = tg.element;
3029
- this.unrender();
3030
- this.target = tg;
3031
- this.render();
3032
- return this;
3033
- }
3033
+ // setTarget(tg) {
3034
+ // if(this.isBody) return ;
3035
+ // if (tg?.isZikoUIElement) tg = tg.element;
3036
+ // this.unrender();
3037
+ // this.target = tg;
3038
+ // this.render();
3039
+ // return this;
3040
+ // }
3034
3041
  describe(label){
3035
3042
  if(label)this.setAttr("aria-label",label);
3036
3043
  }
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Thu Aug 28 2025 17:39:15 GMT+0100 (UTC+01:00)
5
+ Date : Sat Aug 30 2025 10:47:14 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
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 24 2025 12:13:24 GMT+0100 (UTC+01:00)
4
+ Date : Sat Aug 30 2025 10:47:14 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,{PI:i,cos:n,sin:a,tan:o,acos:h,asin:l,atan:u,cosh:m,sinh:p,tanh:f,acosh:d,asinh:g,atanh:b,log:w}=Math;let y={cos:n,sin:a,tan:o,sinc:t=>a(i*t)/(i*t),sec:t=>1/n(t),csc:t=>1/a(t),cot:t=>1/o(t),acos:h,asin:l,atan:u,acot:t=>i/2-u(t),cosh:m,sinh:p,tanh:f,coth:t=>.5*w((1+t)/(1-t)),acosh:d,asinh:g,atanh:b};y=new Proxy(y,{get(t,e){if(e in t)return s=>+t[e](s).toFixed(15)}});class v{}const x=(t,...e)=>{const s=e.map((e=>{if(null===e)return t(null);if(["number","string","boolean","bigint","undefined"].includes(typeof e))return t(e);if(e instanceof Array)return e.map((e=>x(t,e)));if(ArrayBuffer.isView(e))return e.map((e=>t(e)));if(e instanceof Set)return new Set(x(t,...e));if(e instanceof Map)return new Map([...e].map((e=>[e[0],x(t,e[1])])));if(e instanceof Es)return new Es(e.rows,e.cols,x(e.arr.flat(1)));if(e instanceof Ts){const[s,r,i,n]=[e.a,e.b,e.z,e.phi];switch(t){case Math.log:return As(js(i),n);case Math.exp:return As(Ms(s)*Ds(r),Ms(s)*Ps(r));case Math.abs:return i;case Math.sqrt:return As(Ss(i)*Ds(n/2),Ss(i)*Ps(n/2));case y.cos:return As(Ds(s)*Ls(r),-Ps(s)*$s(r));case y.sin:return As(Ps(s)*Ls(r),Ds(s)*$s(r));case y.tan:{const t=Ds(2*s)+Ls(2*r);return As(Ps(2*s)/t,$s(2*r)/t)}case y.cosh:return As(Ls(s)*Ds(r),$s(s)*Ps(r));case y.sinh:return As($s(s)*Ds(r),Ls(s)*Ps(r));case y.tanh:{const t=Ls(2*s)+Ds(2*r);return As($s(2*s)/t,Ps(2*r)/t)}default:return t(e)}}else if(e instanceof Object)return Object.fromEntries(Object.entries(e).map((e=>[e[0],x(t,e[1])])))}));return 1==s.length?s[0]:s},_=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t+e;if(e instanceof Ts)return As(t+e.a,e.b);if(e instanceof Es)return Es.nums(e.rows,e.cols,t).add(e);if(e instanceof Array)return e.map((e=>O(e,t)))}else{if(t instanceof Ts||t instanceof Es)return e instanceof Array?e.map((e=>t.clone.add(e))):t.clone.add(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>O(t,e)));if(t.length===e.length)return t.map(((t,s)=>O(t,e[s])))}}},E=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t-e;if(e instanceof Ts)return As(t-e.a,-e.b);if(e instanceof Es)return Es.nums(e.rows,e.cols,t).sub(e);if(e instanceof Array)return e.map((e=>S(e,t)))}else{if(t instanceof Ts||t instanceof Es)return e instanceof Array?e.map((e=>t.clone.sub(e))):t.clone.sub(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>S(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>S(t,e[s])))}}},k=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t*e;if(e instanceof Ts)return As(t*e.a,t*e.b);if(e instanceof Es)return Es.nums(e.rows,e.cols,t).mul(e);if(e instanceof Array)return e.map((e=>C(t,e)))}else{if(t instanceof Ts||t instanceof Es)return e instanceof Array?e.map((e=>t.clone.mul(e))):t.clone.mul(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>C(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>C(t,e[s])))}}},T=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t/e;if(e instanceof Ts)return As(t/e.a,t/e.b);if(e instanceof Es)return Es.nums(e.rows,e.cols,t).div(e);if(e instanceof Array)return e.map((e=>I(t,e)))}else{if(t instanceof Ts||t instanceof Es)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>I(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>I(t,e[s])))}}},A=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t%e;if(e instanceof Ts)return As(t%e.a,t%e.b);if(e instanceof Es)return Es.nums(e.rows,e.cols,t).modulo(e);if(e instanceof Array)return e.map((e=>I(t,e)))}else{if(t instanceof Ts||t instanceof Es)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array&&!(e instanceof Array))return t.map((t=>O(t,e)))}},O=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=_(s,e[t]);return s},S=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=E(s,e[t]);return s},C=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=k(s,e[t]);return s},I=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=T(s,e[t]);return s},M=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=A(s,e[t]);return s},j=t=>new Array(t).fill(0),D=t=>new Array(t).fill(1),P=(t,e)=>new Array(e).fill(t),R=(t,e,s)=>{if("number"==typeof t)return e!==s?(t-e)/(s-e):0;if(t instanceof Es)return new Es(t.rows,t.cols,R(t.arr.flat(1),e,s));if(t instanceof Ts)return new Ts(R(t.a,e,s),R(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>R(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=R(t[s])}}},L=(t,e,s)=>{if("number"==typeof t)return(s-e)*t+e;if(t instanceof Es)return new Es(t.rows,t.cols,L(t.arr.flat(1),e,s));if(t instanceof Ts)return new Ts(L(t.a,e,s),L(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>L(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=L(t[s])}}},$=(t,e,s,r,i)=>{if("number"==typeof t)return L(R(t,e,s),r,i);if(t instanceof Es)return new Es(t.rows,t.cols,$(t.arr.flat(1),e,s,r,i));if(t instanceof Ts)return new Ts($(t.a,s,r,i),$(t.b,e,s,r,i));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>$(t,e,s,r,i)));{let n=new Array(t.length);for(let a=0;a<t.length;a++)n[a]=$(t[a],e,s,r,i)}}},z=(t,e,s)=>{const[r,i]=[V(e,s),Y(e,s)];if("number"==typeof t)return V(Y(t,r),i);if(t instanceof Es)return new Es(t.rows,t.cols,z(t.arr.flat(1),r,i));if(t instanceof Ts)return new Ts(z(t.a,r,i),z(t.b,r,i));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>z(t,r,i)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=z(t[s],r,i)}}},B=(t,e,s,r=!1)=>{let i=[];if(t<e)for(let n=t;r?n<=e:n<e;n+=s)i.push(10*n/10);else for(let n=t;r?n>=e:n>e;n-=s)i.push(10*n/10);return i},N=(t,e,s=Os(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[a,o]=[t,e].sort(((t,e)=>e-t));var i=[];let h;h=r?(a-o)/(s-1):(a-o)/s;for(var n=0;n<s;n++)t<e?i.push(o+h*n):i.push(a-h*n);return i}if([t,e].some((t=>t instanceof Ts))){const i=As(t),n=As(e);s=s||Math.abs(i.a-n.a)+1;const a=N(i.a,n.a,s,r),o=N(i.b,n.b,s,r);let h=new Array(s).fill(null);return h=h.map(((t,e)=>As(a[e],o[e]))),h}}},Z=(t,e,r=e-t+1,i=s,n=!0)=>N(t,e,r,n).map((t=>Cs(i,t))),H=(t,e,s=Os(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[i,n]=[t,e].sort(((t,e)=>e-t));let a;a=Is(i/n,r?s-1:s);const o=[n];for(let t=1;t<s;t++)o.push(o[t-1]*a);return t<e?o:o.reverse()}if([t,e].some((t=>t instanceof Ts))){const i=As(t),n=As(e);let a;s=s||Math.abs(i.a-n.a)+1,a=Is(n.div(i),r?s-1:s);const o=[i];for(let t=1;t<s;t++)o.push(C(o[t-1],a));return o}}},F=(...t)=>mapfun((t=>t*Math.PI/180),...t),U=(...t)=>mapfun((t=>t/Math.PI*180),...t),W=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e+=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(W(...t[s])):t[s]instanceof Object&&e.push(W(...Object.values(t[s])));return 1===e.length?e[0]:e},q=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e*=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(q(...t[s])):t[s]instanceof Object&&e.push(q(...Object.values(t[s])));return 1===e.length?e[0]:e},V=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.min(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(V(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>t[1]-e[1]))[0]]));return 1===e.length?e[0]:e},Y=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.max(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(V(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>e[1]-t[1]))[0]]));return 1===e.length?e[0]:e},G=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t.reduce(((t,e)=>[...t,t[t.length-1]+e]),[0]);return e.shift(),e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(G(...t[s])):t[s]instanceof Object&&e.push(null);return 1===e.length?e[0]:e},X=(t,e,s)=>{const[r,i]=[Math.min(e,s),Math.max(e,s)];return t>=r&&t<=i},K=(t,e,s=1e-4)=>Math.abs(t-e)<=s,Q=(t,e)=>t.reduce(((t,s)=>[...t,...e.map((t=>[s,t]))]),[]),J=(t,e)=>{let s,r=1;if(t==zs(t)&&e==zs(e)){for(s=2;s<=t&&s<=e;++s)t%s==0&&e%s==0&&(r=s);return r}console.log("error")},tt=(t,e)=>{let s;if(t==zs(t)&&e==zs(e)){for(s=t>e?t:e;s%t!=0||s%e!=0;)++s;return s}console.log("error")},et={add:O,sub:S,mul:C,div:I,modulo:M,zeros:j,ones:D,nums:P,norm:R,lerp:L,map:$,clamp:z,arange:B,linspace:N,logspace:Z,geomspace:H,sum:W,prod:q,accum:G,cartesianProduct:Q,ppcm:tt,pgcd:J,deg2rad:F,rad2deg:U,inRange:X,isApproximatlyEqual:K},st={_mode:Number,_map:function(t,e,s){return e instanceof Es?new Es(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof Ts?new Ts(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},dec2base(t,e){return this._mode=e<=10?Number:String,"number"==typeof t?this._mode((t>>>0).toString(e)):this._map(this.dec2base,t,e)},dec2bin(t){return this.dec2base(t,2)},dec2oct(t){return this.dec2base(t,8)},dec2hex(t){return this.dec2base(t,16)},bin2base(t,e){return this.dec2base(this.bin2dec(t),e)},bin2dec(t){return this._mode("0b"+t)},bin2oct(t){return this.bin2base(t,8)},bin2hex(t){return this.bin2base(t,16)},oct2dec(t){return this._mode("0o"+t)},oct2bin(t){return this.dec2bin(this.oct2dec(t))},oct2hex(t){return this.dec2hex(this.oct2dec(t))},oct2base(t,e){return this.dec2base(this.oct2dec(t),e)},hex2dec(t){return this._mode("0x"+t)},hex2bin(t){return this.dec2bin(this.hex2dec(t))},hex2oct(t){return this.dec2oct(this.hex2dec(t))},hex2base(t,e){return this.dec2base(this.hex2dec(t),e)},IEEE32toDec(t){let e=t.split(" ").join("").padEnd(32,"0"),s=e[0],r=2**(+("0b"+e.slice(1,9))-127);return(-1)**s*(1+e.slice(9,32).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r},IEEE64toDec(t){let e=t.split(" ").join("").padEnd(64,"0"),s=e[0],r=2**(+("0b"+e.slice(1,12))-1023);return(-1)**s*(1+e.slice(13,64).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r}},rt={_mode:Number,_map:function(t,e,s){return e instanceof Es?new Es(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof Ts?new Ts(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},not:function(t){return["number","boolean"].includes(typeof t)?rt._mode(!t):this._map(this.not,t)},and:function(t,...e){return["number","boolean"].includes(typeof t)?rt._mode(e.reduce(((t,e)=>t&e),t)):this._map(this.and,t,e)},or:function(t,...e){return["number","boolean"].includes(typeof t)?rt._mode(e.reduce(((t,e)=>t|e),t)):this._map(this.or,t,e)},nand:function(t,...e){return this.not(this.and(t,e))},nor:function(t,...e){return this.not(this.or(t,e))},xor:function(t,...e){let s=[t,...e];return["number","boolean"].includes(typeof t)?this._mode(1===s.reduce(((t,e)=>(1==+e&&(t+=1),t)),0)):this._map(this.xor,t,e)},xnor:function(t,...e){return rt.not(rt.xor(t,e))}};class it{static withDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,i)=>{this.withDiscount(t.slice(i),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}static withoutDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,i)=>{this.withoutDiscount(t.slice(i+1),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}}class nt{static float(t=1,e){return e?Math.random()*(e-t)+t:t*Math.random()}static int(t,e){return Math.floor(this.float(t,e))}static char(t){t=t??this.bool();const e=String.fromCharCode(this.int(97,120));return t?e.toUpperCase():e}static bool(){return[!1,!0][Math.floor(2*Math.random())]}static string(t,e){return t instanceof Array?new Array(this.int(...t)).fill(0).map((()=>this.char(e))).join(""):new Array(t).fill(0).map((()=>this.char(e))).join("")}static bin(){return this.int(2)}static oct(){return this.int(8)}static dec(){return this.int(8)}static hex(){return this.int(16)}static choice(t=[1,2,3],e=new Array(t.length).fill(1/t.length)){let s=new Array(100);e=et.accum(...e).map((t=>100*t)),s.fill(t[0],0,e[0]);for(let r=1;r<t.length;r++)s.fill(t[r],e[r-1],e[r]);return s[this.int(s.length-1)]}static shuffleArr(t){return t.sort((()=>.5-Math.random()))}static shuffleMatrix(t){const{rows:e,cols:s,arr:r}=t;return ks(e,s,r.flat().sort((()=>.5-Math.random())))}static floats(t,e,s){return new Array(t).fill(0).map((()=>this.float(e,s)))}static ints(t,e,s){return new Array(t).fill(0).map((()=>this.int(e,s)))}static bools(t){return new Array(t).fill(0).map((()=>this.bool()))}static bins(t){return new Array(t).fill(0).map((()=>this.int(2)))}static octs(t){return new Array(t).fill(0).map((()=>this.int(8)))}static decs(t){return new Array(t).fill(0).map((()=>this.int(10)))}static hexs(t){return new Array(t).fill(0).map((()=>this.int(16)))}static choices(t,e,s){return new Array(t).fill(0).map((()=>this.choice(e,s)))}static perm(...t){return t.permS[this.int(t.length)]}static color(){return"#"+st.dec2hex(this.float(16777216)).padStart(6,0)}static colors(t){return new Array(t).fill(null).map((()=>this.color()))}static complex(t=[0,1],e=[0,1]){return t instanceof Array?new Ts(this.float(t[0],t[1]),this.float(e[0],e[1])):new Ts(...this.floats(2,t,e))}static complexInt(t=[0,1],e=[0,1]){return new Ts(this.int(t[0],t[1]),this.int(e[0],e[1]))}static complexBin(){return new Ts(...this.bins(2))}static complexOct(){return new Ts(...this.octs(2))}static complexDec(){return new Ts(...this.decs(10))}static complexHex(){return new Ts(...this.octs(2))}static complexes(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complex(e,s)))}static complexesInt(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complexInt(e,s)))}static complexesBin(t){return new Array(t).fill(0).map((()=>this.complexBin()))}static complexesOct(t){return new Array(t).fill(0).map((()=>this.complexOct()))}static complexesDec(t){return new Array(t).fill(0).map((()=>this.complexDec()))}static complexesHex(t){return new Array(t).fill(0).map((()=>this.complexHex()))}static matrix(t,e,s,r){return ks(t,e,this.floats(t*e,s,r))}static matrixInt(t,e,s,r){return ks(t,e,this.ints(t*e,s,r))}static matrixBin(t,e){return ks(t,e,this.bins(t*e))}static matrixOct(t,e){return ks(t,e,this.octs(t*e))}static matrixDec(t,e){return ks(t,e,this.decs(t*e))}static matrixHex(t,e){return ks(t,e,this.hex(t*e))}static matrixColor(t,e){return ks(t,e,this.colors(t*e))}static matrixComplex(t,e,s,r){return ks(t,e,this.complexes(t*e,s,r))}static matrixComplexInt(t,e,s,r){return ks(t,e,this.complexesInt(t*e,s,r))}static matrixComplexBin(t,e){return ks(t,e,this.complexesBin(t*e))}static matrixComplexOct(t,e){return ks(t,e,this.complexesBin(t*e))}static matrixComplexDec(t,e){return ks(t,e,this.complexesBin(t*e))}static matrixComplexHex(t,e){return ks(t,e,this.complexesBin(t*e))}}const at=t=>{const e=new XMLHttpRequest;if(e.open("GET",t,!1),e.send(),200===e.status)return e.responseText;throw new Error(`Failed to fetch data from ${t}. Status: ${e.status}`)};globalThis.fetchdom=async function(t="https://github.com/zakarialaoui10"){const e=await fetch(t),s=await e.text();return(new DOMParser).parseFromString(s,"text/xml").documentElement},globalThis.fetchdomSync=function(t="https://github.com/zakarialaoui10"){const e=at(t);return(new DOMParser).parseFromString(e,"text/xml").documentElement};const ot=(t,e=",")=>t.trim().trimEnd().split("\n").map((t=>t.split(e))),ht=(t,e=",")=>{const[s,...r]=ot(t,e);return r.map((t=>{const e={};return s.forEach(((s,r)=>{e[s]=t[r]})),e}))},ct=t=>t instanceof Array?[Object.keys(t[0]),...t.map((t=>Object.values(t)))]:[Object.keys(t)],lt=(t,e)=>ct(t).map((t=>t.join(e))).join("\n"),ut=(t,e=",")=>lt(t instanceof Object?t:JSON.parse(t),e),mt=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach((t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=mt(t,`${e} `);s.push(...r)}else s.push(`${e}- ${t}`)}));else for(const r in t)if(t.hasOwnProperty(r)){const i=t[r];if("object"==typeof i&&null!==i){s.push(`${e}${r}:`);const t=mt(i,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${i}`)}return s},pt=(t,e="")=>mt(t,e).join("\n"),ft=(t,e)=>pt(t instanceof Object?t:JSON.parse(t),e),dt=(t,e=1)=>{let s="";for(const r in t)if(t.hasOwnProperty(r)){const i=t[r];s+="\n"+" ".repeat(e)+`<${r}>`,s+="object"==typeof i?dt(i,e+2):`${i}`,s+=`</${r}>`}return s.trim()};class gt{constructor(t){this.cache={node:t}}isZikoUINode(){return!0}get node(){return this.cache.node}}function bt(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)))}function wt(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?Object.defineProperty(t,e,r):"function"==typeof r.value?t[e]=r.value.bind(t):t[e]=r.value}}(t,e)))}globalThis.node=t=>new gt(t);const yt={__all__(){return Object.values(this).filter(Array.isArray).flat()},querySelectorAll(){return this.__all__().filter((t=>t))},getElementByIndex(t){return this.__all__().find((e=>e.ui_index===t))},getElementById:t=>null,getElementsByClass(){},getElementsByTagName(){}},vt={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},xt={map:new Map,index:0,increment:function(){return this.index++}},_t={ui_index:0,get_ui_index:function(){return this.ui_index++}},Et={store:new Map,index:0,register:function(t){console.log({hmr:undefined,index:this.index}),this.store.set(this.index++,t)}};function kt(){var t;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:yt,__HYDRATION__:xt,__State__:Et,__Config__:vt,__CACHE__:_t},t=__Ziko__,Object.defineProperties(t,{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}}))}function Tt(t){const{store:e,index:s}=__Ziko__.__State__;__Ziko__.__State__.register({value:t,subscribers:new Set,paused:!1});const r=e.get(s);return[function(){return{value:r.value,isStateGetter:()=>!0,_subscribe:t=>r.subscribers.add(t)}},function(t){r.paused||("function"==typeof t&&(t=t(r.value)),t!==r.value&&(r.value=t,r.subscribers.forEach((t=>t(r.value)))))},{pause:()=>{r.paused=!0},resume:()=>{r.paused=!1},clear:()=>{r.subscribers.clear()},force:t=>{"function"==typeof t&&(t=t(r.value)),r.value=t,r.subscribers.forEach((t=>t(r.value)))},getSubscribers:()=>new Set(r.subscribers)}]}globalThis.__Ziko__||kt();const At=t=>"function"==typeof t&&t?.()?.isStateGetter?.(),Ot=(t="")=>t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase())),St=(t="")=>{if(0===t.length)return!1;return/^[a-z][a-zA-Z0-9]*$/.test(t)},Ct={setAttr(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(" ")),It.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),It.call(this,t,e);return this},removeAttr(...t){for(let e=0;e<t.length;e++)this.element?.removeAttribute(t[e]);return this},getAttr(t){return t=St(t)?Ot(t):t,this.element.attributes[t].value},setContentEditable(t=!0){return this.setAttr("contenteditable",t),this}};function It(t,e){if("svg"!==this.element?.tagName&&(t=St(t)?Ot(t):t),!this?.attr[t]||this?.attr[t]!==e){if(At(e)){e()._subscribe((e=>this.element?.setAttribute(t,e)),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}class Mt extends gt{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const jt=(...t)=>new Mt(...t),Dt={append(...t){return Pt.call(this,"append","push",...t),this},prepend(...t){return this.__addItem__.call(this,"prepend","unshift",...t),this},insertAt(t,...e){if(t>=this.element.children.length)this.append(...e);else for(let s=0;s<e.length;s++)["number","string"].includes(typeof e[s])&&(e[s]=jt(e[s])),this.element?.insertBefore(e[s].element,this.items[t].element),this.items.splice(t,0,e[s]);return this},remove(...t){const e=t=>{"number"==typeof t&&(t=this.items[t]),t?.isZikoUIElement&&this.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},clear(){return this?.items?.forEach((t=>t.unrender())),this.element.innerHTML="",this},render(t=this.target){if(!this.isBody)return t?.isZikoUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element),this},unrender(){return this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target?.children].includes(this.element)&&this.target.removeChild(this.element),this},renderAfter(t=1){return setTimeout((()=>this.render()),t),this},unrenderAfter(t=1){return setTimeout((()=>this.unrender()),t),this},after(t){return t?.isZikoUIElement&&(t=t.element),this.element?.after(t),this},before(t){return t?.isZikoUIElement&&(t=t.element),this.element?.before(t),this}};async function Pt(t,e,...s){if(this.cache.isFrozzen)return console.warn("You can't append new item to frozzen element"),this;for(let r=0;r<s.length;r++){if(["number","string"].includes(typeof s[r])&&(s[r]=jt(s[r])),s[r]instanceof Function){const t=s[r]();t.isStateGetter&&(s[r]=jt(t.value),t._subscribe((t=>s[r].element.textContent=t),s[r]))}if("function"==typeof globalThis?.Node&&s[r]instanceof globalThis?.Node&&(s[r]=new this.constructor(s[r])),s[r]?.isZikoUINode)s[r].cache.parent=this,this.element?.[t](s[r].element),s[r].target=this.element,this.items[e](s[r]);else if(s[r]instanceof Promise){const i=await s[r];i.cache.parent=this,this.element?.[t](i.element),i.target=this.element,this.items[e](i)}else s[r]instanceof Object&&(s[r]?.style&&this.style(s[r]?.style),s[r]?.attr&&Object.entries(s[r].attr).forEach((t=>this.setAttr(""+t[0],t[1]))))}return this.maintain(),this}const Rt={Click:["Click","DblClick"],Ptr:["PtrMove","PtrDown","PtrUp","PtrLeave","PtrEnter","PtrOut","PtrCancel"],Mouse:["MouseMove","MouseDown","MouseUp","MouseEnter","MouseLeave","MouseOut"],Key:["KeyDown","KeyPress","KeyUp"],Clipboard:["Copy","Cut","Paste"],Focus:["focus","blur"],Drag:["Drag","DragStart","DragEnd","Drop"],Wheel:["Wheel"]},Lt=(t="")=>t.startsWith("Ptr")?`pointer${t.split("Ptr")[1].toLowerCase()}`:t.toLowerCase();function $t(t,e,s,r,i){this.cache.currentEvent=e,this.cache.event=t,s?.call(this),r?.hasOwnProperty("prototype")?r?.call(this):r?.call(null,this),this.cache.preventDefault[e]&&t.preventDefault(),this.cache.stopPropagation[e]&&t.stopPropagation(),this.cache.stopImmediatePropagation[e]&&t.stopImmediatePropagation(),this.cache.stream.enabled[e]&&i&&this.cache.stream.history[e].push(i),this.cache.callbacks[e]?.map((t=>t(this)))}class zt{constructor(t=null,e=[],s,r){this.target=t,this.cache={currentEvent:null,event:null,options:{},preventDefault:{},stopPropagation:{},stopImmediatePropagation:{},event_flow:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{},__controllers__:{}},e&&this._register_events(e,s,r)}_register_events(t,e,s,r=!0){const i=t?.map((t=>Lt(t)));return i?.forEach(((i,n)=>{Object.assign(this.cache.preventDefault,{[i]:!1}),Object.assign(this.cache.options,{[i]:{}}),Object.assign(this.cache.paused,{[i]:!1}),Object.assign(this.cache.stream.enabled,{[i]:!1}),Object.assign(this.cache.stream.clear,{[i]:!1}),Object.assign(this.cache.stream.history,{[i]:[]}),Object.assign(this.cache.__controllers__,{[i]:t=>$t.call(this,t,i,e,s)}),r&&Object.assign(this,{[`on${t[n]}`]:(...t)=>this.__onEvent(i,this.cache.options[i],{},...t)})})),this}get targetElement(){return this.target?.element}get isParent(){return this.target?.element===this.event.srcElement}get item(){return this.target.find((t=>t.element==this.event?.srcElement))?.[0]}get currentEvent(){return this.cache.currentEvent}get event(){return this.cache.event}setTarget(t){return this.target=t,this}__handle(t,e,s,r){return this.targetElement?.addEventListener(t,e,s),this}__onEvent(t,e,s,...r){if(0===r.length){if(console.log("00"),!this.cache.callbacks[t])return this;console.log("Call"),this.cache.callbacks[t].map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=r.map((t=>e=>t.call(this,e)));return this.__handle(t,this.cache.__controllers__[t],e,s),this}#t(t,e,s){"default"===s&&Object.assign(this.cache[t],{...this.cache[t],...e});const r="default"===s?this.cache[t]:Object.fromEntries(Object.keys(this.cache.preventDefault).map((t=>[t,s])));return Object.assign(this.cache[t],{...r,...e}),this}preventDefault(t={},e="default"){return this.#t("preventDefault",t,e),this}stopPropagation(t={},e="default"){return this.#t("stopPropagation",t,e),this}stopImmediatePropagation(t={},e="default"){return this.#t("stopImmediatePropagation",t,e),this}setEventOptions(t,e){return this.pause({[t]:!0},"default"),Object.assign(this.cache.options[Lt(t)],e),this.resume({[t]:!0},"default"),this}pause(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!0);return this}resume(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!1);return this}stream(t={},e="default"){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(){return this}dispose(t={},e="default"){return this.pause(t,e),this}}class Bt extends zt{constructor(t,e){super(t,Rt.Click,Nt,e)}}function Nt(){"click"===this.currentEvent?this.dx=0:this.dx=1}const Zt=(t,e)=>new Bt(t,e);class Ht extends zt{constructor(t,e){super(t,Rt.Clipboard,Ft,e)}}function Ft(){}const Ut=(t,e)=>new Ht(t,e);class Wt extends zt{constructor(t,e,s){super(t,e,qt,s)}_register_events(t){return super._register_events(t,null,null,!1),this}emit(t,e={}){const s=new Event(t);return this.targetElement.dispatchEvent(s),this}on(t,...e){return this.cache.options.hasOwnProperty(t)||this._register_events([t]),this.__onEvent(t,this.cache.options[t],{},...e),this}}function qt(){}class Vt extends zt{constructor(t,e){super(t,Rt.Drag,Yt,e)}}function Yt(){}const Gt=(t,e)=>new Vt(t,e);class Xt extends zt{constructor(t,e){super(t,Rt.Focus,Kt,e)}}function Kt(){}const Qt=(t,e)=>new Xt(t,e);let Jt=class extends zt{constructor(t,e){super(t,Rt.Hash,te,e)}};function te(){}class ee extends zt{constructor(t,e){super(t,Rt.Key,se,e)}}function se(){switch(this.currentEvent){case"keydown":this.kd=this.event.key;break;case"keypress":this.kp=this.event.key;break;case"keyup":this.ku=this.event.key}}const re=(t,e)=>new ee(t,e);class ie extends zt{constructor(t,e){super(t,Rt.Mouse,ne,e)}}function ne(){}const ae=(t,e)=>new ie(t,e);class oe extends zt{constructor(t,e){super(t,Rt.Ptr,he,e),this.isDown=!1}}function he(){switch(this.currentEvent){case"pointerdown":this.dx=parseInt(this.event.offsetX),this.dy=parseInt(this.event.offsetY),this.isDown=!0;break;case"pointermove":this.mx=parseInt(this.event.offsetX),this.my=parseInt(this.event.offsetY),this.isMoving=!0;break;case"pointerup":{this.ux=parseInt(this.event.offsetX),this.uy=parseInt(this.event.offsetY),this.isDown=!1,console.log(this.target.width);const t=(this.ux-this.dx)/this.target.width,e=(this.dy-this.uy)/this.target.height,s=t<0?"left":t>0?"right":"none",r=e<0?"bottom":e>0?"top":"none";this.swippe={h:s,v:r,delta_x:t,delta_y:e}}}}const ce=(t,e)=>new oe(t,e);class le extends zt{constructor(t,e){super(t,Rt.Touch,ue,e)}}function ue(){}class me extends zt{constructor(t,e){super(t,Rt.Wheel,pe,e)}}function pe(){}const fe=(t,e)=>new me(t,e),de={ptr:ce,mouse:ae,key:re,click:Zt,drag:Gt,clipboard:Ut,focus:Qt,wheel:fe},ge={};Object.entries(Rt).forEach((([t,e])=>{e.forEach((e=>{const s=`on${e}`;ge[s]=function(...e){return this.events[t]||(this.events[t]=de[t.toLowerCase()](this)),this.events[t][s](...e),this}}))}));const be={at(t){return this.items.at(t)},forEach(t){return this.items.forEach(t),this},map(t){return this.items.map(t)},find(t){return this.items.filter(t)}},we={style(t){for(let e in t){const s=t[e];if(At(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},size(t,e){return this.style({width:t,height:e})},hide(){},show(){},animate(t,{duration:e=1e3,iterations:s=1,easing:r="ease"}={}){return this.element?.animate(t,{duration:e,iterations:s,easing:r}),this}};function ye(t,e,s,r){return this.event=t,this.cache.preventDefault[e]&&t.preventDefault(),console.log({setter:s}),s&&s(),this.cache.stream.enabled[e]&&r&&this.cache.stream.history[e].push(r),this.cache.callbacks[e].map((t=>t(this))),this}class ve{constructor(t){this.target=null,this.setTarget(t),this.__dispose=this.dispose.bind(this)}get targetElement(){return this.target.element}setTarget(t){return this.target=t,this}__handle(t,e,s){const r="drag"===t?t:`${this.cache.prefixe}${t}`;return this.dispose(s),this.targetElement?.addEventListener(r,e),this}__onEvent(t,e,...s){if(0===s.length){if(!(this.cache.callbacks.length>1))return this;this.cache.callbacks.map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=s.map((t=>e=>t.call(this,e)));return this.__handle(t,this.__controller[t],e),this}preventDefault(t={}){return Object.assign(this.cache.preventDefault,t),this}pause(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!0);return this}resume(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!1);return this}dispose(t={}){return this.pause(t),this}stream(t={}){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.clear).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.cache.stream.history[e]=[]);return this}}function xe(t){ye.call(this,t,"input",null,null)}function _e(t){ye.call(this,t,"change",null,null)}class Ee extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{input:!1,change:!1},paused:{input:!1,change:!1},stream:{enabled:{input:!1,change:!1},clear:{input:!1,change:!1},history:{input:[],change:[]}},callbacks:{input:[],change:[]}},this.__controller={input:xe.bind(this),change:_e.bind(this)}}get value(){return this.target.value}onInput(...t){return this.__onEvent("input",{},...t),this}onChange(...t){return this.__onEvent("change",{},...t),this}}function ke(t){ye.call(this,t,"hashchange",null,null)}class Te extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{hashchange:!1},paused:{hashchange:!1},stream:{enabled:{hashchange:!1},clear:{hashchange:!1},history:{hashchange:[]}},callbacks:{hashchange:[]}},this.__controller={hashchange:ke.bind(this)}}onChange(...t){return this.__onEvent("hashchange",{},...t),this}}const Ae=t=>function(e){ye.call(this,e,t,null,null)};class Oe extends ve{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{}},this.__controller={}}#e(t){return this.cache.preventDefault[t]=!1,this.cache.paused[t]=!1,this.cache.stream.enabled=!1,this.cache.stream.clear=!1,this.cache.stream.history=[],this.cache.callbacks[t]=[],this.__controller[t]=Ae(t).bind(this),this}on(t,...e){return this.__controller[t]||this.#e(t),this.__onEvent(t,{},...e),this}emit(t,e={}){this.__controller[t]||this.#e(t),this.detail=e;const s=new Event(t);return this.targetElement.dispatchEvent(s),this}}const Se=t=>new Oe(t);class Ce extends ve{constructor(t,e=.3,s=.3){super(t);const{removeListener:r,setWidthThreshold:i,setHeightThreshold:n}=function(t,e=.5,s=.5,r,i){let n=L(e,0,r),a=L(s,0,i),o=0,h=0,c=0,l=0;const u=t=>{o=t.clientX,h=t.clientY},m=t=>{c=t.clientX,l=t.clientY,p()};function p(){const t=c-o,e=l-h;(Math.abs(t)>n||Math.abs(e)>a)&&f(t,e)}function f(e,s){const o=globalThis?.CustomEvent?new CustomEvent("swipe",{detail:{deltaX:Os(e)<n?0:Ns(e)*R(Os(e),0,r),deltaY:Os(s)<a?0:Ns(s)*R(Os(s),0,i),direction:{x:Os(e)<n?"none":e>0?"right":"left",y:Os(s)<a?"none":s>0?"down":"up"}}}):null;t?.dispatchEvent(o)}function d(t){n=L(t,0,r)}function g(t){a=L(t,0,i)}return t?.addEventListener("pointerdown",u),t?.addEventListener("pointerup",m),{removeListener(){t?.removeEventListener("pointerdown",u),t?.removeEventListener("pointerup",m),console.log("Swipe event listeners removed")},setWidthThreshold:d,setHeightThreshold:g}}(this.target?.element,e,s,this.target.width,this.target.height);this.cache={width_threshold:e,height_threshold:s,removeListener:r,setWidthThreshold:i,setHeightThreshold:n,legacyTouchAction:globalThis?.document?.body?.style?.touchAction,prefixe:"",preventDefault:{swipe:!1},paused:{swipe:!1},stream:{enabled:{swipe:!1},clear:{swipe:!1},history:{swipe:[]}},callbacks:{swipe:[]}},this.__controller={swipe:Ie.bind(this)}}onSwipe(...t){return Object.assign(globalThis?.document?.body?.style,{touchAction:"none"}),this.__onEvent("swipe",{},...t),this}updateThresholds(t=this.cache.width_threshold,e=this.cache.height_threshold){return void 0!==t&&this.cache.setWidthThreshold(t),void 0!==e&&this.cache.setHeightThreshold(e),this}destroy(){return this.cache.removeListener(),Object.assign(globalThis?.document?.body?.style,{touchAction:this.cache.legacyTouchAction}),this}}function Ie(t){ye.call(this,t,"swipe",null,null)}const Me=(t,e,s)=>new Ce(t,e,s);class je{constructor(t,e){this.target=t,this.observer=null,this.cache={options:e||{attributes:!0,childList:!0,subtree:!0},streamingEnabled:!0,lastMutation:null,mutationHistory:{}},this.observeCallback=(t,e)=>{if(this.cache.streamingEnabled)for(const e of t)switch(e.type){case"attributes":this.cache.mutationHistory.attributes.push(e.target.getAttribute(e.attributeName));break;case"childList":this.cache.mutationHistory.childList.push(e);break;case"subtree":this.cache.mutationHistory.subtree.push(e)}this.callback&&this.callback(t,e)}}observe(t){if(!this.observer){if(!globalThis.MutationObserver)return void console.log("MutationObserver Nor Supported");this.observer=new MutationObserver(this.cache.observeCallback),this.observer.observe(this.target.element,this.cache.options),this.callback=([e])=>t.call(e,this),this.cache.streamingEnabled=!0}}pause(t){this.observer&&(this.observer.disconnect(),t&&this.observer.observe(this.target,t))}reset(t){this.observer&&(this.observer.disconnect(),this.observer.observe(this.target,t||this.cache.options))}clear(){return this.observer&&(this.observer.disconnect(),this.observer=null,this.cache.mutationHistory={attributes:[],childList:[],subtree:[]}),this.cache.streamingEnabled=!1,this}getMutationHistory(){return this.cache.mutationHistory}enableStreaming(){return this.cache.streamingEnabled=!0,this}disableStreaming(){return this.cache.streamingEnabled=!1,this}}class De extends je{constructor(t,e){super(t,{attributes:!0,childList:!1,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)this.cache.lastMutation={name:e.attributeName,value:e.target.getAttribute(e.attributeName)},this.cache.streamingEnabled&&this.cache.mutationHistory.attributes.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.attributes=[],e&&this.observe(e)}get history(){return this.cache.mutationHistory.attributes}}const Pe=(t,e)=>new De(t,e);class Re extends je{constructor(t,e){super(t,{attributes:!1,childList:!0,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)e.addedNodes?this.cache.lastMutation={type:"add",item:this.target.find((t=>t.element===e.addedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}:e.addedNodes&&(this.cache.lastMutation={type:"remove",item:this.target.find((t=>t.element===e.removedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}),this.cache.streamingEnabled&&this.cache.mutationHistory.children.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.children=[],e&&this.observe(e)}get item(){return this.cache.lastMutation.item}get history(){return this.cache.mutationHistory.children}}const Le=(t,e)=>new Re(t,e);class $e{constructor(t,e,{threshold:s=0,margin:r=0}={}){this.target=t,this.config={threshold:s,margin:r},globalThis.IntersectionObserver?this.observer=new IntersectionObserver((t=>{this.entrie=t[0],e(this)}),{threshold:this.threshold}):console.log("IntersectionObserver Not Supported")}get ratio(){return this.entrie.intersectionRatio}get isIntersecting(){return this.entrie.isIntersecting}setThreshould(t){return this.config.threshold=t,this}setMargin(t){return t="number"==typeof t?t+"px":t,this.config.margin=t,this}start(){return this.observer.observe(this.target.element),this}stop(){return this}}const ze=(t,e,s)=>new $e(t,e,s);class Be{constructor(t,e){this.target=t,this.contentRect=null,this.observer=new ResizeObserver((()=>{e(this)}))}get BoundingRect(){return this.target.element.getBoundingClientRect()}get width(){return this.BoundingRect.width}get height(){return this.BoundingRect.height}get top(){return this.BoundingRect.top}get bottom(){return this.BoundingRect.bottom}get right(){return this.BoundingRect.right}get left(){return this.BoundingRect.left}get x(){return this.BoundingRect.x}get y(){return this.BoundingRect.y}start(){return this.observer.observe(this.target.element),this}stop(){return this.observer.unobserve(this.target.element),this}}const Ne=(t,e)=>new Be(t,e);class Ze{constructor(t=(t=>console.log({x:t.x,y:t.y}))){this.cache={},this.previousX=globalThis?.screenX,this.previousY=globalThis?.screenY}update(){Object.assign(this.cache,{screenXLeft:globalThis?.screenX,screenXRight:globalThis?.screen.availWidth-globalThis?.screenX,screenYTop:globalThis?.screenY,screenYBottom:globalThis?.screen.availHeight-globalThis?.screenY-globalThis?.outerHeight,screenCenterX:globalThis?.screen.availWidth/2,screenCenterY:globalThis?.screen.availHeight/2,windowCenterX:globalThis?.outerWidth/2+globalThis?.screenX,windowCenterY:globalThis?.outerHeight/2+globalThis?.screenY,deltaCenterX:globalThis?.screen.availWidth/2-globalThis?.outerWidth/2+globalThis?.screenX,deltaCenterY:null})}get x0(){return $(globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get y0(){return-$(globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}get x1(){return $(globalThis?.screenX+globalThis?.outerWidth,0,globalThis.screen.availWidth,-1,1)}get y1(){return-$(globalThis?.screenY+globalThis?.outerHeight,0,globalThis.screen.availHeight,-1,1)}get cx(){return $(globalThis?.outerWidth/2+globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get cy(){return-$(globalThis?.outerHeight/2+globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}}class He{constructor(){this.events={},this.maxListeners=10}on(t,e){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.`)}once(t,e){const s=r=>{this.off(t,s),e(r)};this.on(t,s)}off(t,e){const s=this.events[t];if(s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}emit(t,e){const s=this.events[t];s&&s.forEach((t=>{t(e)}))}clear(t){t?delete this.events[t]:this.events={}}setMaxListener(t,e){this.maxListeners=e}removeAllListeners(t){t?this.events[t]=[]:this.events={}}}const Fe=()=>new He;class Ue{constructor(t,e=!0){this.#e(),this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}#e(){return this.__FavIcon__=document.querySelector("link[rel*='icon']")||document?.createElement("link"),this.__FavIcon__.type="image/x-icon",this.__FavIcon__.rel="shortcut icon",this}set(t){return t!==this.__FavIcon__.href&&(this.__FavIcon__.href=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:favicon-changed")),this}get current(){return document.__FavIcon__.href}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:favicon-changed",t),this}useEventEmitter(){return this.cache.Emitter=Fe(),this}}const We=(t,e)=>new Ue(t,e);class qe{constructor({viewport:t,charset:e,description:s,author:r,keywords:i}){this.document=globalThis?.document,this.meta={},this.init({viewport:t,charset:e,description:s,author:r,keywords:i})}init({viewport:t,charset:e,description:s,author:r,keywords:i}){t&&this.setViewport(t),e&&this.setCharset(e),s&&this.describe(s),r&&this.setAuthor(r),i&&this.setKeywords(i)}set(t,e){const s="charset"===(t=t.toLowerCase()),r=s?document.querySelector("meta[charset]"):document.querySelector(`meta[name=${t}]`);return this.meta=r??document?.createElement("meta"),s?this.meta.setAttribute("charset",e):(this.meta.setAttribute("name",t),this.meta.setAttribute("content",e)),r||this.document.head.append(this.meta),this}setCharset(t="utf-8"){return this.set("charset",t),this}describe(t){return this.set("description",t),this}setViewport(t="width=device-width, initial-scale=1.0"){return this.set("viewport",t),this}setKeywords(...t){return t=[...new Set(t)].join(", "),this.set("keywords",t),this}setAuthor(t){return this.set("author",t),this}}const Ve=({viewport:t,charset:e,description:s,author:r,keywords:i})=>new qe({viewport:t,charset:e,description:s,author:r,keywords:i});class Ye{constructor(t=document.title,e=!0){this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.Emitter=Fe(),this}set(t){return t!==document.title&&(document.title=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:title-changed")),this}get current(){return document.title}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:title-changed",t),this}}const Ge=(t,e)=>new Ye(t,e);class Xe{constructor({title:t,lang:e,icon:s,meta:r,noscript:i}){this.html=globalThis?.document?.documentElement,this.head=globalThis?.document?.head,t&&Ge(t),e&&this.setLang(e),s&&We(s),r&&Ve(r),i&&this.setNoScript()}setLang(t){this.html.setAttribute("lang",t)}setNoScript(t){}}const Ke=({title:t,lang:e,icon:s,meta:r,noscript:i})=>new Xe({title:t,lang:e,icon:s,meta:r,noscript:i});class Qe{constructor(t=[],e=(()=>{})){this.mediaQueryRules=t,this.fallback=e,this.lastCalledCallback=null,this.init()}init(){this.mediaQueryRules.forEach((({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.mediaQueryRules.some((({query:t})=>globalThis.matchMedia(t).matches));s.matches?(e(),this.lastCalledCallback=e):t||this.lastCalledCallback===this.fallback||(this.fallback(),this.lastCalledCallback=this.fallback)};r(),s.addListener(r)}))}}kt();class Je extends gt{constructor({element:t,name:e="",type:s="html",useDefaultStyle:r=!1}={}){if(super(),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);default:throw Error("Not supported")}else this.target=t?.parentElement;((t,...e)=>{"function"==typeof t?bt(t,...e):wt(t,...e)})(this,Ct,Dt,we,be,ge),Object.assign(this.cache,{name:e,isInteractive:[!0,!1][Math.floor(2*Math.random())],parent:null,isBody:!1,isRoot:!1,isHidden:!1,isFrozzen:!1,legacyParent:null,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.uuid=`${this.cache.name}-${nt.string(16)}`,this.ui_index=globalThis.__Ziko__.__CACHE__.get_ui_index(),r&&this.style({position:"relative",boxSizing:"border-box",margin:0,padding:0,width:"auto",height:"auto"}),this.items=[],globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this],t&&globalThis.__Ziko__.__Config__.default.render&&this?.render?.(),this.isInteractive()&&(this.setAttr("ziko-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.map.set(globalThis.__Ziko__.__HYDRATION__.index,(()=>this)),globalThis.__Ziko__.__HYDRATION__.increment())}get element(){return this.cache.element}isInteractive(){return this.cache.isInteractive}isZikoUIElement(){return!0}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}clone(t=!1){const e=new this.constructor;if(e.__proto__=this.__proto__,this.items.length){const t=[...this.items].map((t=>t.clone()));e.append(...t)}else e.element=this.element.cloneNode(!0);return e.render(t)}[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})}freeze(t){return this.cache.isFrozzen=t,this}setTarget(t){if(!this.isBody)return t?.isZikoUIElement&&(t=t.element),this.unrender(),this.target=t,this.render(),this}describe(t){t&&this.setAttr("aria-label",t)}get children(){return[...this.element.children]}get cloneElement(){return this.element.cloneNode(!0)}setClasses(...t){return this.setAttr("class",t.join(" ")),this}get classes(){const t=this.element.getAttribute("class");return null===t?[]:t.split(" ")}addClass(){}setId(t){return this.setAttr("id",t),this}get id(){return this.element.getAttribute("id")}onSwipe(t,e,...s){return this.events.swipe||(this.events.swipe=Me(this,t,e)),this.events.swipe.onSwipe(...s),this}on(t,...e){return this.events.custom||(this.events.custom=Se(this)),this.events.custom.on(t,...e),this}emit(t,e={}){return this.events.custom||(this.events.custom=Se(this)),this.events.custom.emit(t,e),this}watchAttr(t){return this.observer.attr||(this.observer.attr=Pe(this,t)),this}watchChildren(t){return this.observer.children||(this.observer.children=Le(this,t)),this}watchSize(t){return this.observer.resize||(this.observer.resize=Ne(this,t)),this.observer.resize.start(),this}watchIntersection(t,e){return this.observer.intersection||(this.observer.intersection=ze(this,t,e)),this.observer.intersection.start(),this}}const ts=["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","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],es=["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"],ss=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return ts.includes(r)&&(s="html"),es.includes(r)&&(s="svg"),(...t)=>["string","number"].includes(typeof t[0])||t[0]instanceof Je||"function"==typeof t[0]&&t[0]().isStateGetter()?new Je({element:r,name:r,type:s}).append(...t):new Je({element:r}).setAttr(t.shift()).append(...t)}});class rs extends Je{constructor(t="div",e="100%",s="100%"){super({element:t,name:"Flex"}),this.direction="cols","number"==typeof e&&(e+="%"),"number"==typeof s&&(s+="%"),this.style({width:e,height:s}),this.style({display:"flex"})}get isFlex(){return!0}resp(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 is.call(this,s),this.style({alignItems:"number"==typeof t?as.call(this,t):t,justifyContent:"number"==typeof e?os.call(this,e):e}),this}horizontal(t,e,s=1){return ns.call(this,s),this.style({alignItems:"number"==typeof e?os.call(this,e):e,justifyContent:"number"==typeof t?as.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}function is(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function ns(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function as(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function os(t){return as(-t)}class hs extends Je{constructor(t="div",e="50vw",s="50vh"){super({element:t,name:"Grid"}),this.direction="cols","number"==typeof e&&(e+="%"),"number"==typeof s&&(s+="%"),this.style({border:"1px solid black",width:e,height:s}),this.style({display:"grid"})}get isGird(){return!0}columns(t){let e="";for(let s=0;s<t;s++)e=e.concat(" auto");return this.#s(e),this}#s(t="auto auto"){return this.style({gridTemplateColumns:t}),this}gap(t=10,e=t){return"number"==typeof t&&(t+="px"),"number"==typeof e&&(e+="px"),this.style({gridColumnGap:t,gridRowGap:e}),this}}class cs extends Je{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.unrender(),this.append(s)}catch(t){console.log({error:t})}})()}}class ls extends Je{constructor(t,e){super({element:"div",name:""}),this.element.append("svg"===e?function(t){if(globalThis?.DOMParser){return(new DOMParser).parseFromString(t.replace(/\s+/g," ").trim(),"image/svg+xml").documentElement}}(t):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))}}class us extends ls{constructor(t){super(t,"html")}}class ms extends ls{constructor(t){super(t,"svg")}}class ps extends Je{constructor(t,e){super("canvas","canvas"),this.ctx=this.element?.getContext("2d"),this.style({border:"1px red solid"}),this.transformMatrix=new Es([[1,0,0],[0,1,0],[0,0,1]]),this.axisMatrix=new Es([[-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 Es([[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 ps;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 fs extends Je{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 i=Math.abs(s-t),n=Math.abs(r-e);return this.setAttr("viewBox",[t,e,i,n].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 ds=t=>(new XMLSerializer).serializeToString(t),gs=t=>btoa(ds(t)),bs=t=>"data:image/svg+xml;base64,"+gs(t),ws=t=>JSON.stringify(x((t=>["number","string","boolean","bigint"].includes(typeof t)?String(t):t instanceof Ts||t instanceof Es?t.toString():t instanceof Array?vs(t):void 0),t),null," ").replace(/"([^"]+)":/g,"$1:").replace(/: "([^"]+)"/g,": $1"),ys=t=>{if(!Array.isArray(t))return 0;let e=1;for(const s of t)if(Array.isArray(s)){const t=ys(s);t+1>e&&(e=t+1)}return e},vs=t=>{let e=0;return function t(s){let r=ys(s),i=0;return s.some((t=>Array.isArray(t)))&&(e++,i=1),"["+s.map(((r,i)=>["number","string","boolean","bigint"].includes(typeof r)?String(r):r instanceof Ts?r.toString():r instanceof Array?`\n${" ".repeat(e)}${t(r)}${i===s.length-1?"\n":""}`:r instanceof Object?ws(r):void 0))+`${" ".repeat((r+e+1)*i)}]`}(t)},xs=(t,e=0)=>{t=_s(t);let s="";const r=" ".repeat(e);for(let i in t)if("object"==typeof t[i]){s+=`${r}${i} {\n`;const n=t[i];for(let t in n)"object"==typeof n[t]?s+=xs({[t]:n[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}: ${n[t]};\n`;s+=`${r}}\n`}return s};function _s(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce(((e,s)=>(e[s.trim()]=_s(t[s]),e)),Array.isArray(t)?[]:{})}class Es extends v{constructor(t,e,s=[]){if(super(),t instanceof Es)this.arr=t.arr,this.rows=t.rows,this.cols=t.cols;else{let r,i,n=[];if(arguments[0]instanceof Array)t=arguments[0].length,e=arguments[0][0].length,n=arguments[0];else for(r=0;r<t;r++)for(n.push([]),n[r].push(new Array(e)),i=0;i<e;i++)n[r][i]=s[r*e+i],null==s[r*e+i]&&(n[r][i]=0);this.rows=t,this.cols=e,this.arr=n}this.#r()}toString(){return vs(this.arr)}at(t=0,e=void 0){return t<0&&(t=this.rows+t),null==e?this.arr[t]:(e<0&&(e=this.cols+e),this.arr[t][e])}reshape(t,e){if(t*e==this.rows*this.cols)return new Es(t,e,this.arr.flat(1));console.error("Err")}static eye(t){let e=new Es(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}get clone(){return new Es(this.rows,this.cols,this.arr.flat(1))}get size(){return this.rows*this.cols}get shape(){return[this.rows,this.cols]}get reel(){return new Es(this.cols,this.rows,this.arr.flat(1).reel)}get imag(){return new Es(this.cols,this.rows,this.arr.flat(1).imag)}[Symbol.iterator](){return this.arr[Symbol.iterator]()}#r(){for(let t=0;t<this.arr.length;t++)Object.defineProperty(this,t,{value:this.arr[t],writable:!0,configurable:!0,enumerable:!1})}get(t=0,e=0){return-1==e?this.arr[t]:-1==t?this.arr.map((t=>t[e])):this.arr[t][e]}set(t=0,e=0,s){if(-1==e)return this.arr[t]=s;if(-1==t){for(let t=0;t<this.cols;t++)this.arr[t][e]=s[t]||0;return this.arr}return this.arr[t][e]=s}get isSquare(){return this.rows/this.cols==1}get isSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==Es.sub(e,t).max&&0==Es.sub(e,t).min}get isAntiSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==Es.add(e,t).max&&0==Es.add(e,t).min}get isDiag(){if(!this.isSquare)return!1;const t=this.T,e=this.clone,s=Es.mul(e,t),r=Es.dot(t,e);return 0==Es.sub(s,r).max&&0==Es.sub(s,r).min}get isOrtho(){return!!this.isSquare&&(this.isDiag&&(1==this.det||-1==this.det))}get isIdemp(){if(!this.isSquare)return!1;const t=this.clone,e=Es.dot(t,t);return 0==Es.sub(e,t).max&&0==Es.sub(e,t).min}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 Es(this.cols,this.rows,t.flat(1))}get det(){if(!this.isSquare)return new Error("is not square matrix");if(1==this.rows)return this.arr[0][0];function t(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}return function e(s){if(2==s.length)return s.flat(1).some((t=>t instanceof Es))?void console.warn("Tensors are not completely supported yet ..."):et.sub(et.mul(s[0][0],s[1][1]),et.mul(s[0][1],s[1][0]));for(var r=0,i=0;i<s.length;i++){const n=et.add(et.mul(Cs(-1,i),et.mul(s[0][i],e(t(s,i)))));r=et.add(r,n)}return r}(this.arr)}get inv(){if(!this.isSquare)return new Error("is not square matrix");if(0===this.det)return"determinat = 0 !!!";let t=function(t){if(t.length!==t[0].length)return;var e=0,s=0,r=0,i=t.length,n=0,a=[],o=[];for(e=0;e<i;e+=1)for(a[a.length]=[],o[o.length]=[],r=0;r<i;r+=1)a[e][r]=e==r?1:0,o[e][r]=t[e][r];for(e=0;e<i;e+=1){if(0==(n=o[e][e])){for(s=e+1;s<i;s+=1)if(0!=o[s][e]){for(r=0;r<i;r++)n=o[e][r],o[e][r]=o[s][r],o[s][r]=n,n=a[e][r],a[e][r]=a[s][r],a[s][r]=n;break}if(0==(n=o[e][e]))return}for(r=0;r<i;r++)o[e][r]=o[e][r]/n,a[e][r]=a[e][r]/n;for(s=0;s<i;s++)if(s!=e)for(n=o[s][e],r=0;r<i;r++)o[s][r]-=n*o[e][r],a[s][r]-=n*a[e][r]}return a}(this.arr);return new Es(this.rows,this.cols,t.flat(1))}static zeros(t,e){let s=new Es(t,e);for(let i=0;i<t;i++)for(var r=0;r<e;r++)s.arr[i][r]=0;return s}static ones(t,e){let s=new Es(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 Es(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.arr[i][t]=s;return r}static get rand(){return{int:(t,e,s,r)=>{let i=new Es(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.arr[n][t]=nt.randInt(s,r);return i},bin:(t,e)=>{let s=new Es(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randBin;return s},hex:(t,e)=>{let s=new Es(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randHex;return s},choices:(t,e,s,r)=>{let i=new Es(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.arr[n][t]=nt.choice(s,r);return i},permutation:(t,e,s)=>{}}}static rands(t,e,s=1,r){let i=new Es(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.arr[n][t]=nt.rand(s,r);return i}map(t,e,s,r){return et.map(this,t,e,s,r)}lerp(t,e){return et.lerp(this,t,e)}norm(t,e){return et.norm(this,t,e)}clamp(t,e){return et.clamp(this,t,e)}static map(t,e,s,r,i){return et.map(t,e,s,r,i)}static lerp(t,e,s){return et.lerp(t,e,s)}static norm(t,e,s){return et.norm(t,e,s)}static clamp(t,e,s){return et.clamp(ks,e,s)}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}get toBin(){let t=this.arr.flat(1).toBin;return new Es(this.rows,this.cols,t)}get toOct(){let t=this.arr.flat(1).toOct;return new Es(this.rows,this.cols,t)}get toHex(){let t=this.arr.flat(1).toHex;return new Es(this.rows,this.cols,t)}max2min(){let t=this.arr.flat(1).max2min;return new Es(this.rows,this.cols,t)}min2max(){let t=this.arr.flat(1).min2max;return new Es(this.rows,this.cols,t)}sortRows(t=void 0){let e=this.arr.map((e=>e.sort(t))).flat(1);return new Es(this.rows,this.cols,e)}sortCols(t=void 0){let e=this.T.arr.map((e=>e.sort(t))).flat(1);return new Es(this.rows,this.cols,e).T}filterByRows(t){var e=this.arr.map((e=>e.map((e=>+(""+e).includes(t))))).map((t=>!!Logic.or(...t))),s=this.arr.filter(((t,s)=>!0===e[s]));return 0===s.length&&s.push([]),console.log(s),new Es(s)}filterByCols(t){return new Es(this.T.arr.filter((e=>e.includes(t))))}sortAll(t=void 0){let e=this.arr.flat(1).sort(t);return new Es(this.rows,this.cols,e)}count(t){return this.arr.flat(1).count(t)}toBase(t){let e=this.arr.flat(1).toBase(t);return new Es(this.rows,this.cols,e)}#i(t){if(this.rows!==t.rows)return;let e=this.arr;for(let s=0;s<this.rows;s++)for(let r=this.cols;r<this.cols+t.cols;r++)e[s][r]=t.arr[s][r-this.cols];return this.cols+=t.cols,new Es(this.rows,this.cols,e.flat(1))}hstack(...t){const e=[this,...t].reduce(((t,e)=>t.#i(e)));return Object.assign(this,e),this}static hstack(t,...e){return t.clone.hstack(...e)}#n(t){if(this.cols!==t.cols)return;let e=this.arr;for(let s=this.rows;s<this.rows+t.rows;s++){e[s]=[];for(let r=0;r<this.cols;r++)e[s][r]=t.arr[s-this.rows][r]}return this.rows+=t.rows,new Es(this.rows,this.cols,e.flat(1))}vstack(...t){const e=[this,...t].reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static vstack(t,...e){return t.clone.vstack(...e)}hqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#i(e)));return Object.assign(this,e),this}vqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static hqueue(t,...e){return t.clone.hqueue(...e)}static vqueue(t,...e){return t.clone.vqueue(...e)}slice(t=0,e=0,s=this.rows-1,r=this.cols-1){let i=s-t,n=r-e,a=new Array(n);for(let s=0;s<i;s++){a[s]=[];for(let r=0;r<n;r++)a[s][r]=this.arr[s+t][r+e]}return new Es(i,n,a.flat(1))}static slice(t,e=0,s=0,r=this.rows-1,i=this.cols-1){return t.slice(e,s,r,i)}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)}static getRows(t,e,s=e+1){return t.slice(e,0,s,t.cols)}static getCols(t,e,s=e+1){return t.slice(0,e,t.rows,s)}add(...t){for(let s=0;s<t.length;s++){("number"==typeof t[s]||t[s]instanceof Ts)&&(t[s]=Es.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.add(this.arr[r][e],t[s].arr[r][e])}return new Es(this.rows,this.cols,this.arr.flat(1))}sub(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=Es.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.sub(this.arr[r][e],t[s].arr[r][e])}return new Es(this.rows,this.cols,this.arr.flat(1))}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}mul(...t){for(let r=0;r<t.length;r++){"number"==typeof t[r]&&(t[r]=Es.nums(this.rows,this.cols,t[r]));for(var e=0;e<this.rows;e++)for(var s=0;s<this.cols;s++)this.arr[e][s]=et.mul(this.arr[e][s],t[r].arr[e][s])}return new Es(this.rows,this.cols,this.arr.flat(1))}div(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=Es.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.div(this.arr[r][e],t[s].arr[r][e])}return new Es(this.rows,this.cols,this.arr.flat(1))}static div(t,...e){return t.clone.div(...e)}static mul(t,...e){return t.clone.mul(...e)}modulo(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=Es.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.modulo(this.arr[r][e],t[s].arr[r][e])}return new Es(this.rows,this.cols,this.arr.flat(1))}static modulo(t,...e){return t.clone.modulo(...e)}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 i=0;i<this.arr[0].length;i++)e[s][r]=et.add(e[s][r],et.mul(this.arr[s][i],t.arr[i][r]))}}return new Es(this.arr.length,t.arr[0].length,e.flat(1))}static dot(t,e){return t.dot(e)}pow(t){let e=this.clone,s=this.clone;for(let r=0;r<t-1;r++)s=s.dot(e);return s}static pow(t,e){return t.clone.pow(e)}get somme(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t+=this.arr[e][s];return t}get DoesItContainComplexNumbers(){return this.arr.flat(1/0).some((t=>t instanceof Ts))}get min(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return V(...t)}get max(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Y(...this.arr[e]));return Y(...t)}get minRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return t}get maxRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(Y(...this.arr[e]));return t}get minCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.minRows}get maxCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.maxRows}static fromVector(t){return new Es(t.length,1,t)}get toArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t.push(this.arr[e][s]);return t}get print(){let t="[";for(let e=0;e<this.arr.length;e++)t+=(0!=e?" ":"")+` [${this.arr[e].map((t=>" "+t.toString()+" "))}],\n`;console.log(t.substring(0,t.length-2)+" ]"),document.write(t.substring(0,t.length-2)+" ]")}get table(){console.table(this.arr)}get serialize(){return JSON.stringify(this)}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));let e=new Es(t.rows,t.cols);return e.arr=t.arr,e}toTable(){var t=new DocumentFragment,e=new Array(this.rows).fill(null).map((()=>document?.createElement("tr"))),s=this.arr.map((t=>t.map((()=>document?.createElement("td")))));for(let t=0;t<s.length;t++)for(let r=0;r<s[0].length;r++)s[t][r].innerHTML=this.arr[t][r],e[t].appendChild(s[t][r]);return e.map((e=>t.appendChild(e))),t}toGrid(t,e={}){let s=Grid();return s.append(...this.map(t).arr.flat(1).map((t=>t.style(e)))),s.Columns(this.cols),s}sortTable(t=0,{type:e="num",order:s="asc"}={}){var r=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e}))))),i=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e})))));"num"===e?"asc"===s?r[t].sort(((t,e)=>t.x-e.x)):"desc"===s?r[t].sort(((t,e)=>e.x-t.x)):"toggle"===s&&(r[t][0].x>r[t][1].x?r[t].sort(((t,e)=>e.x-t.x)):r[t].sort(((t,e)=>t.x-e.x))):"alpha"===e&&("asc"===s?r[t].sort(((t,e)=>(""+t.x).localeCompare(""+e.x))):"desc"===s&&r[t].sort(((t,e)=>(""+e.x).localeCompare(""+t.x)))),s=r[t].map((t=>t.y));for(let e=0;e<r.length;e++)e!==t&&r[e].map(((t,e)=>t.y=s[e]));for(let e=0;e<r.length;e++)e!==t&&i[e].map(((t,i)=>t.x=r[e][s[i]].x));i[t]=r[t];var n=i.map((t=>t.map((t=>t.x))));return new Es(n).T}}const ks=(t,e,s)=>new Es(t,e,s);class Ts extends v{constructor(t=0,e=0){super(),t instanceof Ts?(this.a=t.a,this.b=t.b):"object"==typeof t?"a"in e&&"b"in t?(this.a=t.a,this.b=t.b):"a"in e&&"z"in t?(this.a=t.a,this.b=Ss(t.z**2-t.a**2)):"a"in e&&"phi"in t?(this.a=t.a,this.b=t.a*Rs(t.phi)):"b"in e&&"z"in t?(this.b=t.b,this.a=Ss(t.z**2-t.b**2)):"b"in e&&"phi"in t?(this.b=e,this.a=t.b/Rs(t.phi)):"z"in e&&"phi"in t&&(this.a=t.z*Ds(t.phi),this.a=t.z*Ps(t.phi)):"number"==typeof t&&"number"==typeof e&&(this.a=+t.toFixed(32),this.b=+e.toFixed(32))}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}get clone(){return new Ts(this.a,this.b)}get z(){return Zs(this.a,this.b)}get phi(){return Bs(this.b,this.a)}static Zero(){return new Ts(0,0)}get conj(){return new Ts(this.a,-this.b)}get inv(){return new Ts(this.a/(Cs(this.a,2)+Cs(this.b,2)),-this.b/(Cs(this.a,2)+Cs(this.b,2)))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Ts(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a+=+W(...e).toFixed(15),this.b+=+W(...s).toFixed(15),this}sub(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Ts(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a-=+W(...e).toFixed(15),this.b-=+W(...s).toFixed(15),this}mul(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Ts(t[e],0));let e=+q(this.z,...t.map((t=>t.z))).toFixed(15),s=+W(this.phi,...t.map((t=>t.phi))).toFixed(15);return this.a=+(e*Ds(s).toFixed(15)).toFixed(14),this.b=+(e*Ps(s).toFixed(15)).toFixed(14),this}div(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new Ts(t[e],0));let e=+(this.z/q(...t.map((t=>t.z)))).toFixed(15),s=+(this.phi-W(...t.map((t=>t.phi)))).toFixed(15);return this.a=+(e*Ds(s).toFixed(15)).toFixed(15),this.b=+(e*Ps(s).toFixed(15)).toFixed(15),this}pow(t){if(zs(t)===t&&t>0){let e=+(this.z**t).toFixed(15),s=+(this.phi*t).toFixed(15);this.a=+(e*Ds(s).toFixed(15)).toFixed(15),this.b=+(e*Ps(s).toFixed(15)).toFixed(15)}return this}static fromExpo(t,e){return new Ts(+(t*Ds(e)).toFixed(13),+(t*Ps(e)).toFixed(13))}get expo(){return[this.z,this.phi]}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}static mul(t,...e){return t.clone.mul(...e)}static div(t,...e){return t.clone.div(...e)}static pow(t,e){return t.clone.pow(e)}static xpowZ(t){return As(t**this.a*Ds(this.b*js(t)),t**this.a*Ps(this.b*js(t)))}sqrtn(t=2){return As(Is(this.z,t)*Ds(this.phi/t),Is(this.z,t)*Ps(this.phi/t))}get sqrt(){return this.sqrtn(2)}get log(){return As(this.z,this.phi)}get cos(){return As(Ds(this.a)*Ls(this.b),Ps(this.a)*$s(this.b))}get sin(){return As(Ps(this.a)*Ls(this.b),Ds(this.a)*$s(this.b))}get tan(){const t=Ds(2*this.a)+Ls(2*this.b);return As(Ps(2*this.a)/t,$s(2*this.b)/t)}printInConsole(){let t=this.a+" + "+this.b+" * i";return console.log(t),t}print(){}UI(){return"<span>"+this.a+" + i * "+this.b+"</span>"}}const As=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map(((s,r)=>As(t[r],e[r])));if(t instanceof Es&&e instanceof Es){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map(((s,r)=>As(t.arr[r],e.arr[r])));return new Es(t.rows,t.cols,...s)}return new Ts(t,e)},Os=(...t)=>x(Math.abs,...t),Ss=(...t)=>x(Math.sqrt,...t),Cs=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,e):e instanceof Ts?Ts.fromExpo(t**e.a,e.b*js(t)):x((e=>Cs(t,e)),...e);if(t instanceof Ts)return"number"==typeof e?Ts.fromExpo(t.z**e,t.phi*e):e instanceof Ts?Ts.fromExpo(t.z**e.a*Ms(-t.phi*e.b),js(t.z)*e.b+e.a*t.phi):x((e=>Cs(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return x((t=>Cs(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(x((e=>Cs(t[r],e)),...e));return s}}},Is=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,1/e):x((e=>Is(t,e)),...e);if(t instanceof Ts)return"number"==typeof e?Ts.fromExpo(Is(t.z,e),t.phi/e):x((e=>Is(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return x((t=>Is(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(x((e=>Is(t[r],e)),...e));return s}}},Ms=(...t)=>x(Math.exp,...t),js=(...t)=>x(Math.log,...t),Ds=(...t)=>x(y.cos,...t),Ps=(...t)=>x(y.sin,...t),Rs=(...t)=>x(y.tan,...t),Ls=(...t)=>x(y.cosh,...t),$s=(...t)=>x(y.sinh,...t),zs=(...t)=>x(Math.floor,...t),Bs=(t,e,s=!0)=>{if("number"==typeof t)return"number"==typeof e?s?Math.atan2(t,e):180*Math.atan2(t,e)/Math.PI:x((e=>Bs(t,e,s)),...e);if(t instanceof Array){if("number"==typeof e)return x((t=>Bs(t,e,s)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(x((e=>Cs(t[r],e)),...e));return s}}},Ns=(...t)=>x(Math.sign,...t),Zs=(...t)=>t.every((t=>"number"==typeof t))?Math.hypot(...t):t.every((t=>t instanceof Array))?x(Math.hypot,...t):void 0,{PI:Hs,sqrt:Fs,cos:Us,sin:Ws,acos:qs,pow:Vs}=Math,Ys=t=>t,Gs=(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 Xs{constructor(t,{ease:e=Ys,step:s=50,t0:r=0,start:i=!0,duration:n=3e3}={}){this.callback=t,this.state={isRunning:!1,animationId:null,startTime:null,ease:e,step:s,autoStart:i,duration:n},this.t=0,this.tx=0,this.ty=0,this.i=0,this.state.autoStart&&this.start()}#a=()=>{this.t+=this.state.step,this.i++,this.tx=$(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)};#o(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#a,this.state.step)),this}start(){return this.#o(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#o(!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 Ks{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 Qs extends Ks{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 Js{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 tr{constructor(t,{step:e=1e3,t0:s=0,t1:r=1/0,autoplay:i=!0}={}){this.callback=t,this.cache={isRunning:!1,id:null,last_tick:null,step:e,t0:s,t1:r,autoplay:i,pauseTime:null,frame:0},i&&(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)}}}class er{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.render(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?.isZikoUIElement?this.wrapper=t:"function"==typeof t&&(this.wrapper=t()),this}setHead(t){return this.head=t instanceof Xe?t:Ke(t),this}}function sr(t){return/:\w+/.test(t)}class rr extends er{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",jt("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.render(location.pathname)}clear(){return[...this.routes].forEach((t=>{!sr(t[0])&&t[1]?.isZikoUIElement&&t[1].unrender()})),this}render(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],i=r[t];if(!e.startsWith(":")&&e!==i)return!1}return!0}(e[0],t)));let r;if(sr(e)){const i=function(t,e){const s=t.split("/"),r=e.split("/"),i={};if(s.length!==r.length)return i;for(let t=0;t<s.length;t++){const e=s[t],n=r[t];if(e.startsWith(":"))i[e.slice(1)]=n;else if(e!==n)return{}}return i}(e,t);r=s.call(this,i)}else s?.isZikoUIElement&&s.render(this.wrapper),"function"==typeof s&&(r=s());return r?.isZikoUIElement&&r.render(this.wrapper),r instanceof Promise&&r.then((t=>t.render(this.wrapper))),globalThis.history.pushState({},"",t),this}}const ir=({head:t,wrapper:e,target:s,routes:r})=>new rr({head:t,wrapper:e,target:s,routes:r});function nr(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("/"),i=e.split("/"),n=r.indexOf(i[i.length-1]);if(-1!==n){const t=r.slice(n+1),e=t[t.length-1],i="index.js"===e||"index.ts"===e,a=s.some((t=>e===`.${t}`||e.endsWith(`.${t}`)));if(i)return"/"+(t.length>1?t.slice(0,-1).join("/"):"");if(a)return"/"+t.join("/").replace(/\.(js|ts)$/,"")}return""}class ar{constructor(t=""){this.channel=new BroadcastChannel(t),this.EVENTS_DATAS_PAIRS=new Map,this.EVENTS_HANDLERS_PAIRS=new Map,this.LAST_RECEIVED_EVENT="",this.UUID="ziko-channel"+nt.string(10),this.SUBSCRIBERS=new Set([this.UUID])}get broadcast(){return this}emit(t,e){return this.EVENTS_DATAS_PAIRS.set(t,e),this.#h(t),this}on(t,e=console.log){return this.EVENTS_HANDLERS_PAIRS.set(t,e),this.#c(),this}#c(){return this.channel.onmessage=t=>{this.LAST_RECEIVED_EVENT=t.data.last_sended_event;const e=t.data.userId;this.SUBSCRIBERS.add(e);const s=t.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT),r=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);s&&r&&r(s)},this}#h(t){return this.channel.postMessage({EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,last_sended_event:t,userId:this.UUID}),this}close(){return this.channel.close(),this}}const or=t=>new ar(t);class hr{#l;constructor(){this.#l=function(t){try{let e=new Function("return "+t.data.fun)()();postMessage({result:e})}catch(t){postMessage({error:t.message})}finally{t.data.close&&self.close()}}.toString(),this.blob=new Blob(["this.onmessage = "+this.#l],{type:"text/javascript"}),this.worker=new Worker(window.URL.createObjectURL(this.blob))}call(t,e,s=!0){return this.worker.postMessage({fun:t.toString(),close:s}),this.worker.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data.result)},this}}class cr{constructor(t,{namespace:e="Ziko",register:s,ValidateCssProps:r=!1}={}){this.currentPropsMap=t,this.namespace=e,this.ValidateCssProps=r,this.use(t)}use(t){return this.ValidateCssProps&&function(t){const e=new Set(Object.keys(document.documentElement.style));for(let s in t)if(!e.has(s))throw new Error(`Invalid CSS property: "${s}"`)}(t),this.currentPropsMap=t,this.#r(),this}#r(){const t=globalThis?.document?.documentElement?.style;for(let 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})}}}class lr{constructor(t,e,s){this.cache={storage:t,globalKey:e,channel:or(`Ziko:useStorage-${e}`),oldItemKeys:new Set},this.#e(s),this.#r()}get items(){return JSON.parse(this.cache.storage[this.cache.globalKey]??null)}#r(){for(let t in this.items)Object.assign(this,{[[t]]:this.items[t]})}#e(t){this.cache.channel=or(`Ziko:useStorage-${this.cache.globalKey}`),this.cache.channel.on("Ziko-Storage-Updated",(()=>this.#r())),t&&(this.cache.storage[this.cache.globalKey]?(Object.keys(this.items).forEach((t=>this.cache.oldItemKeys.add(t))),console.group("Ziko:useStorage"),console.warn(`Storage key '${this.cache.globalKey}' already exists. we will not overwrite it.`),console.info("%cWe'll keep the existing data.","background-color:#2222dd; color:gold;"),console.group("")):this.set(t))}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel.emit("Ziko-Storage-Updated",{}),Object.keys(t).forEach((t=>this.cache.oldItemKeys.add(t))),this.#r(),this}add(t){const e={...this.items,...t};return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(e)),this.#r(),this}remove(...t){const e={...this.items};for(let s=0;s<t.length;s++)delete e[t[s]],delete this[t[s]];return this.set(e),this}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.#r(),this}}let{sqrt:ur,cos:mr,sin:pr,exp:fr,log:dr,cosh:gr,sinh:br}=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 i=r[0];if("number"==typeof i||0===r.length)return e.apply(s,r);if(i?.isComplex?.()){const{a:t,b:n,z:a,phi:o}=i,h=(t,e)=>new i.constructor(t,e);switch(e.name){case"abs":return i.z;case"sqrt":return h(ur(a)*mr(o/2),ur(a)*pr(o/2));case"log":return h(dr(a),o);case"exp":return h(fr(t)*mr(n),fr(t)*pr(n));case"cos":return h(mr(t)*gr(n),-pr(t)*br(n));case"sin":return h(pr(t)*gr(n),mr(t)*br(n));case"tan":{const e=mr(2*t)+gr(2*n);return h(pr(2*t)/e,br(2*n)/e)}case"cosh":return h(gr(t)*mr(n),br(t)*pr(n));case"sinh":return h(br(t)*mr(n),gr(t)*pr(n));case"tanh":{const e=gr(2*t)+mr(2*n);return h(br(2*t)/e,pr(2*n)/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 er({head:t,wrapper:e,target:s}),t.Arc=t=>1-Ws(qs(t)),t.Back=(t,e=1)=>t**2*((e+1)*t-e),t.Base=st,t.Canvas=(t,e)=>new ps(t,e),t.Clock=Qs,t.Combinaison=it,t.Complex=Ts,t.Discret=(t,e=5)=>Math.ceil(t*e)/e,t.E=s,t.EPSILON=r,t.Elastic=t=>-2*Vs(2,10*(t-1))*Us(20*Hs*t/3*t),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 i=0;i<e.length;i++){const n=await t[e[i]](),a=await n.default;Object.assign(r,{[nr(e[i],s)]:a})}return ir({target:document.body,routes:{"/":()=>{},...r},wrapper:ss.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new rs(e).append(...t)},t.Grid=(...t)=>new hs("div").append(...t),t.HTMLWrapper=t=>new us(t),t.InBack=(t,e=1.70158,s=e+1)=>s*Vs(t,3)-e*t**2,t.InBounce=(t,e=7.5625,s=2.75)=>1-Gs(1-t,e,s),t.InCirc=t=>1-Fs(1-t**2),t.InCubic=t=>t**3,t.InElastic=(t,e=2*Hs/3)=>0===t?0:1===t?1:-Vs(2,10*t-10)*Ws((10*t-10.75)*e),t.InExpo=t=>0===t?0:2**(10*t-10),t.InOutBack=(t,e=1.70158,s=1.525*e)=>t<.5?Vs(2*t,2)*(2*(s+1)*t-s)/2:(Vs(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.InOutBounce=(t,e=7.5625,s=2.75)=>t<.5?Gs(1-2*t,e,s)/2:Gs(2*t-1,e,s)/2,t.InOutCirc=t=>t<.5?(1-Fs(1-(2*t)**2))/2:(Fs(1-(-2*t+2)**2)+1)/2,t.InOutCubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.InOutElastic=(t,e=2*Hs/4.5)=>0===t?0:1===t?1:t<.5?-Vs(2,20*t-10)*Ws((20*t-11.125)*e)/2:Vs(2,-20*t+10)*Ws((20*t-11.125)*e)/2+1,t.InOutExpo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.InOutQuad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.InOutQuart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.InOutQuint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.InOutSin=t=>-(Us(Hs*t)-1)/2,t.InQuad=t=>t**2,t.InQuart=t=>t**4,t.InQuint=t=>t**5,t.InSin=t=>1-Us(t*Hs/2),t.Linear=Ys,t.Logic=rt,t.Matrix=Es,t.OutBack=(t,e=1.70158,s=e+1)=>1+s*Vs(t-1,3)+e*Vs(t-1,2),t.OutBounce=Gs,t.OutCirc=t=>Fs(1-(t-1)**2),t.OutCubic=t=>1-(1-t)**3,t.OutElastic=(t,e=2*Hs/3)=>0===t?0:1===t?1:Vs(2,-10*t)*Ws((10*t-.75)*e)+1,t.OutExpo=t=>1===t?1:1-2**(-10*t),t.OutQuad=t=>1-(1-t)**2,t.OutQuart=t=>1-(1-t)**4,t.OutQuint=t=>1-(1-t)**5,t.OutSin=t=>Ws(t*Hs/2),t.PI=e,t.Permutation=class{static withDiscount(t,e=t.length){if(1===e)return t.map((t=>[t]));const s=[];let r;return r=this.withDiscount(t,e-1),t.forEach((t=>{r.forEach((e=>{s.push([t].concat(e))}))})),s}static withoutDiscount(t){if(1===t.length)return t.map((t=>[t]));const e=[],s=this.withoutDiscount(t.slice(1)),r=t[0];for(let t=0;t<s.length;t++){const i=s[t];for(let t=0;t<=i.length;t++){const s=i.slice(0,t),n=i.slice(t);e.push(s.concat([r],n))}}return e}},t.Random=nt,t.SPA=ir,t.SVGWrapper=t=>new ms(t),t.Scheduler=(t,{repeat:e=null}={})=>new Js(t,{repeat:e}),t.Step=(t,e=5)=>Math.floor(t*e)/e,t.Suspense=(t,e)=>new cs(t,e),t.Svg=(t,e)=>new fs(t,e),t.Tick=Ks,t.TimeAnimation=Xs,t.TimeLoop=tr,t.TimeScheduler=Js,t.UIElement=Je,t.UINode=gt,t.Utils=et,t.ZikoApp=er,t.ZikoCustomEvent=Oe,t.ZikoEventClick=Bt,t.ZikoEventClipboard=Ht,t.ZikoEventCustom=Wt,t.ZikoEventDrag=Vt,t.ZikoEventFocus=Xt,t.ZikoEventInput=Ee,t.ZikoEventKey=ee,t.ZikoEventMouse=ie,t.ZikoEventPointer=oe,t.ZikoEventSwipe=Ce,t.ZikoEventTouch=le,t.ZikoEventWheel=me,t.ZikoHead=Xe,t.ZikoMutationObserver=je,t.ZikoSPA=rr,t.ZikoUICanvas=ps,t.ZikoUIFlex=rs,t.ZikoUIGrid=hs,t.ZikoUIHTMLWrapper=us,t.ZikoUISVGWrapper=ms,t.ZikoUISuspense=cs,t.ZikoUISvg=fs,t.ZikoUIText=Mt,t.ZikoUIXMLWrapper=ls,t.ZikoUseRoot=cr,t.__ZikoEvent__=zt,t.abs=Os,t.accum=G,t.acos=(...t)=>x(y.acos,...t),t.acosh=(...t)=>x(y.acosh,...t),t.acot=(...t)=>x(y.acot,...t),t.add=O,t.animation=(t,{ease:e,t0:s,t1:r,start:i,duration:n}={})=>new Xs(t,{ease:e,t0:s,t1:r,start:i,duration:n}),t.arange=B,t.arr2str=vs,t.asin=(...t)=>x(y.asin,...t),t.asinh=(...t)=>x(y.asinh,...t),t.atan=(...t)=>x(y.atan,...t),t.atan2=Bs,t.atanh=(...t)=>x(y.atanh,...t),t.bindClickEvent=Zt,t.bindClipboardEvent=Ut,t.bindCustomEvent=(t,e,s)=>new Wt(t,e,s),t.bindDragEvent=Gt,t.bindFocusEvent=Qt,t.bindHashEvent=(t,e)=>new Jt(t,e),t.bindKeyEvent=re,t.bindMouseEvent=ae,t.bindPointerEvent=ce,t.bindTouchEvent=(t,e)=>new le(t,e),t.bindWheelEvent=fe,t.cartesianProduct=Q,t.ceil=(...t)=>x(Math.ceil,...t),t.clamp=z,t.clock=t=>new Qs(t),t.combinaison=(t,e,s=!1)=>it[s?"withDiscount":"withoutDiscount"](t,e),t.complex=As,t.cos=Ds,t.cosh=Ls,t.cot=(...t)=>x(y.cot,...t),t.coth=(...t)=>x(y.coth,...t),t.csc=(...t)=>x(y.csc,...t),t.csv2arr=ot,t.csv2json=(t,e=",")=>JSON.stringify(ht(t,e)),t.csv2matrix=(t,e=",")=>new Es(ot(t,e)),t.csv2object=ht,t.csv2sql=(t,e)=>{const s=t.trim().trimEnd().split("\n").filter((t=>t));let r=`INSERT INTO ${e} (${s[0].split(",").join(", ")}) Values `,i=[];for(let t=1;t<s.length;t++){const e=s[t].split(",");i.push(`(${e})`)}return r+i.join(",\n")},t.debounce=(t,e=1e3)=>(...s)=>setTimeout((()=>t(...s)),e),t.defineParamsGetter=function(t){Object.defineProperties(t,{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}})},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="",this.UIElement=e(this.props).render(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=F,t.div=I,t.e=Ms,t.fact=(...t)=>x((t=>{let e,s=1;if(0==t)s=1;else if(t>0)for(e=1;e<=t;e++)s*=e;else s=NaN;return s}),...t),t.floor=zs,t.geomspace=H,t.getEvent=Lt,t.hypot=Zs,t.inRange=X,t.isApproximatlyEqual=K,t.isStateGetter=At,t.json2arr=t=>ct(t instanceof Object?t:JSON.parse(t)),t.json2css=xs,t.json2csv=ut,t.json2csvFile=(t,e)=>{const s=ut(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=dt,t.json2xmlFile=(t,e)=>{const s=dt(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=ft,t.json2ymlFile=(t,e)=>{const s=ft(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=L,t.linspace=N,t.ln=js,t.logspace=Z,t.loop=(t,e={})=>new tr(t,e),t.map=$,t.mapfun=x,t.matrix=ks,t.matrix2=(...t)=>new Es(2,2,t),t.matrix3=(...t)=>new Es(3,3,t),t.matrix4=(...t)=>new Es(4,4,t),t.max=Y,t.min=V,t.modulo=M,t.mul=C,t.norm=R,t.nums=P,t.obj2str=ws,t.ones=D,t.pgcd=J,t.pow=Cs,t.powerSet=t=>{const e=[],s=2**t.length;for(let r=0;r<s;r+=1){const s=[];for(let e=0;e<t.length;e+=1)r&1<<e&&s.push(t[e]);e.push(s)}return e},t.ppcm=tt,t.preload=at,t.prod=q,t.rad2deg=U,t.round=(...t)=>x(Math.round,...t),t.sec=(...t)=>x(y.sec,...t),t.sig=(...t)=>x((t=>1/(1+Ms(-t))),...t),t.sign=Ns,t.sin=Ps,t.sinc=(...t)=>x(y.sinc,...t),t.sinh=$s,t.sleep=t=>new Promise((e=>setTimeout(e,t))),t.sqrt=Ss,t.sqrtn=Is,t.step_fps=t=>1e3/t,t.sub=S,t.subSet=null,t.sum=W,t.svg2ascii=gs,t.svg2img=(t,e=!0)=>ss.img(bs(t)).render(e),t.svg2imgUrl=bs,t.svg2str=ds,t.tags=ss,t.tan=Rs,t.tanh=(...t)=>x(y.tanh,...t),t.text=jt,t.throttle=(t,e)=>{let s=0;return(...r)=>{const i=(new Date).getTime();i-s<e||(s=i,t(...r))}},t.tick=(t,e,s=1/0,r=!0)=>new Ks(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.useChannel=or,t.useCustomEvent=Se,t.useDerived=function(t,e){let s=t(...e.map((t=>t().value)));const r=new Set;return e.forEach((i=>{i()._subscribe((()=>{{const i=t(...e.map((t=>t().value)));i!==s&&(s=i,r.forEach((t=>t(s))))}}))})),()=>({value:s,isStateGetter:()=>!0,_subscribe:t=>r.add(t)})},t.useEventEmitter=Fe,t.useFavIcon=We,t.useHashEvent=t=>new Te(t),t.useHead=Ke,t.useInputEvent=t=>new Ee(t),t.useLocaleStorage=(t,e)=>new lr(localStorage,t,e),t.useMediaQuery=(t,e)=>new Qe(t,e),t.useMeta=Ve,t.useReactive=t=>x((t=>{const e=Tt(t);return{get:e[0],set:e[1]}}),t),t.useRoot=(t,{namespace:e,register:s,ValidateCssProps:r}={})=>new cr(t,{namespace:e,register:s,ValidateCssProps:r}),t.useSessionStorage=(t,e)=>new lr(sessionStorage,t,e),t.useState=Tt,t.useSuccesifKeys=(t,e=[],s=(()=>{}))=>{t.cache.stream.enabled.down=!0;const r=e.length,i=t.cache.stream.history.down.slice(-r).map((t=>t.key));e.join("")===i.join("")&&(t.event.preventDefault(),s.call(t,t))},t.useSwipeEvent=Me,t.useThread=(t,e,s)=>{const r=new hr;return t&&r.call(t,e,s),r},t.useTitle=Ge,t.wait=t=>new Promise((e=>setTimeout(e,t))),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.watch=(t,e={},s=null)=>{const r=new je(t,e);return s&&r.observe(s),r},t.watchAttr=Pe,t.watchChildren=Le,t.watchIntersection=ze,t.watchScreen=t=>new Ze(t),t.watchSize=Ne,t.zeros=j}));
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,{PI:i,cos:n,sin:a,tan:o,acos:h,asin:l,atan:u,cosh:m,sinh:p,tanh:f,acosh:d,asinh:g,atanh:b,log:w}=Math;let y={cos:n,sin:a,tan:o,sinc:t=>a(i*t)/(i*t),sec:t=>1/n(t),csc:t=>1/a(t),cot:t=>1/o(t),acos:h,asin:l,atan:u,acot:t=>i/2-u(t),cosh:m,sinh:p,tanh:f,coth:t=>.5*w((1+t)/(1-t)),acosh:d,asinh:g,atanh:b};y=new Proxy(y,{get(t,e){if(e in t)return s=>+t[e](s).toFixed(15)}});class v{}const x=(t,...e)=>{const s=e.map((e=>{if(null===e)return t(null);if(["number","string","boolean","bigint","undefined"].includes(typeof e))return t(e);if(e instanceof Array)return e.map((e=>x(t,e)));if(ArrayBuffer.isView(e))return e.map((e=>t(e)));if(e instanceof Set)return new Set(x(t,...e));if(e instanceof Map)return new Map([...e].map((e=>[e[0],x(t,e[1])])));if(e instanceof ks)return new ks(e.rows,e.cols,x(e.arr.flat(1)));if(e instanceof As){const[s,r,i,n]=[e.a,e.b,e.z,e.phi];switch(t){case Math.log:return Os(Ds(i),n);case Math.exp:return Os(js(s)*Ps(r),js(s)*Rs(r));case Math.abs:return i;case Math.sqrt:return Os(Cs(i)*Ps(n/2),Cs(i)*Rs(n/2));case y.cos:return Os(Ps(s)*zs(r),-Rs(s)*$s(r));case y.sin:return Os(Rs(s)*zs(r),Ps(s)*$s(r));case y.tan:{const t=Ps(2*s)+zs(2*r);return Os(Rs(2*s)/t,$s(2*r)/t)}case y.cosh:return Os(zs(s)*Ps(r),$s(s)*Rs(r));case y.sinh:return Os($s(s)*Ps(r),zs(s)*Rs(r));case y.tanh:{const t=zs(2*s)+Ps(2*r);return Os($s(2*s)/t,Rs(2*r)/t)}default:return t(e)}}else if(e instanceof Object)return Object.fromEntries(Object.entries(e).map((e=>[e[0],x(t,e[1])])))}));return 1==s.length?s[0]:s},_=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t+e;if(e instanceof As)return Os(t+e.a,e.b);if(e instanceof ks)return ks.nums(e.rows,e.cols,t).add(e);if(e instanceof Array)return e.map((e=>O(e,t)))}else{if(t instanceof As||t instanceof ks)return e instanceof Array?e.map((e=>t.clone.add(e))):t.clone.add(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>O(t,e)));if(t.length===e.length)return t.map(((t,s)=>O(t,e[s])))}}},E=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t-e;if(e instanceof As)return Os(t-e.a,-e.b);if(e instanceof ks)return ks.nums(e.rows,e.cols,t).sub(e);if(e instanceof Array)return e.map((e=>S(e,t)))}else{if(t instanceof As||t instanceof ks)return e instanceof Array?e.map((e=>t.clone.sub(e))):t.clone.sub(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>S(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>S(t,e[s])))}}},k=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t*e;if(e instanceof As)return Os(t*e.a,t*e.b);if(e instanceof ks)return ks.nums(e.rows,e.cols,t).mul(e);if(e instanceof Array)return e.map((e=>C(t,e)))}else{if(t instanceof As||t instanceof ks)return e instanceof Array?e.map((e=>t.clone.mul(e))):t.clone.mul(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>C(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>C(t,e[s])))}}},T=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t/e;if(e instanceof As)return Os(t/e.a,t/e.b);if(e instanceof ks)return ks.nums(e.rows,e.cols,t).div(e);if(e instanceof Array)return e.map((e=>I(t,e)))}else{if(t instanceof As||t instanceof ks)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array){if(!(e instanceof Array))return t.map((t=>I(t,e)));if(e instanceof Array&&t.length===e.length)return t.map(((t,s)=>I(t,e[s])))}}},A=(t,e)=>{if("number"==typeof t){if("number"==typeof e)return t%e;if(e instanceof As)return Os(t%e.a,t%e.b);if(e instanceof ks)return ks.nums(e.rows,e.cols,t).modulo(e);if(e instanceof Array)return e.map((e=>I(t,e)))}else{if(t instanceof As||t instanceof ks)return e instanceof Array?e.map((e=>t.clone.div(e))):t.clone.div(e);if(t instanceof Array&&!(e instanceof Array))return t.map((t=>O(t,e)))}},O=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=_(s,e[t]);return s},S=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=E(s,e[t]);return s},C=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=k(s,e[t]);return s},I=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=T(s,e[t]);return s},M=(t,...e)=>{var s=t;for(let t=0;t<e.length;t++)s=A(s,e[t]);return s},j=t=>new Array(t).fill(0),D=t=>new Array(t).fill(1),P=(t,e)=>new Array(e).fill(t),R=(t,e,s)=>{if("number"==typeof t)return e!==s?(t-e)/(s-e):0;if(t instanceof ks)return new ks(t.rows,t.cols,R(t.arr.flat(1),e,s));if(t instanceof As)return new As(R(t.a,e,s),R(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>R(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=R(t[s])}}},L=(t,e,s)=>{if("number"==typeof t)return(s-e)*t+e;if(t instanceof ks)return new ks(t.rows,t.cols,L(t.arr.flat(1),e,s));if(t instanceof As)return new As(L(t.a,e,s),L(t.b,e,s));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>L(t,e,s)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=L(t[s])}}},z=(t,e,s,r,i)=>{if("number"==typeof t)return L(R(t,e,s),r,i);if(t instanceof ks)return new ks(t.rows,t.cols,z(t.arr.flat(1),e,s,r,i));if(t instanceof As)return new As(z(t.a,s,r,i),z(t.b,e,s,r,i));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>z(t,e,s,r,i)));{let n=new Array(t.length);for(let a=0;a<t.length;a++)n[a]=z(t[a],e,s,r,i)}}},$=(t,e,s)=>{const[r,i]=[V(e,s),G(e,s)];if("number"==typeof t)return V(G(t,r),i);if(t instanceof ks)return new ks(t.rows,t.cols,$(t.arr.flat(1),r,i));if(t instanceof As)return new As($(t.a,r,i),$(t.b,r,i));if(t instanceof Array){if(t.every((t=>typeof("number"===t))))return t.map((t=>$(t,r,i)));{let e=new Array(t.length);for(let s=0;s<t.length;s++)e[s]=$(t[s],r,i)}}},B=(t,e,s,r=!1)=>{let i=[];if(t<e)for(let n=t;r?n<=e:n<e;n+=s)i.push(10*n/10);else for(let n=t;r?n>=e:n>e;n-=s)i.push(10*n/10);return i},N=(t,e,s=Ss(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[a,o]=[t,e].sort(((t,e)=>e-t));var i=[];let h;h=r?(a-o)/(s-1):(a-o)/s;for(var n=0;n<s;n++)t<e?i.push(o+h*n):i.push(a-h*n);return i}if([t,e].some((t=>t instanceof As))){const i=Os(t),n=Os(e);s=s||Math.abs(i.a-n.a)+1;const a=N(i.a,n.a,s,r),o=N(i.b,n.b,s,r);let h=new Array(s).fill(null);return h=h.map(((t,e)=>Os(a[e],o[e]))),h}}},Z=(t,e,r=e-t+1,i=s,n=!0)=>N(t,e,r,n).map((t=>Is(i,t))),F=(t,e,s=Ss(e-t)+1,r=!0)=>{if(Math.floor(s)===s){if([t,e].every((t=>"number"==typeof t))){const[i,n]=[t,e].sort(((t,e)=>e-t));let a;a=Ms(i/n,r?s-1:s);const o=[n];for(let t=1;t<s;t++)o.push(o[t-1]*a);return t<e?o:o.reverse()}if([t,e].some((t=>t instanceof As))){const i=Os(t),n=Os(e);let a;s=s||Math.abs(i.a-n.a)+1,a=Ms(n.div(i),r?s-1:s);const o=[i];for(let t=1;t<s;t++)o.push(C(o[t-1],a));return o}}},H=(...t)=>mapfun((t=>t*Math.PI/180),...t),U=(...t)=>mapfun((t=>t/Math.PI*180),...t),q=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e+=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(q(...t[s])):t[s]instanceof Object&&e.push(q(...Object.values(t[s])));return 1===e.length?e[0]:e},W=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t[0];for(let s=1;s<t.length;s++)e*=t[s];return e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(W(...t[s])):t[s]instanceof Object&&e.push(W(...Object.values(t[s])));return 1===e.length?e[0]:e},V=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.min(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(V(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>t[1]-e[1]))[0]]));return 1===e.length?e[0]:e},G=(...t)=>{if(t.every((t=>"number"==typeof t)))return Math.max(...t);const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(V(...t[s])):t[s]instanceof Object&&e.push(Object.fromEntries([Object.entries(t[s]).sort(((t,e)=>e[1]-t[1]))[0]]));return 1===e.length?e[0]:e},X=(...t)=>{if(t.every((t=>"number"==typeof t))){let e=t.reduce(((t,e)=>[...t,t[t.length-1]+e]),[0]);return e.shift(),e}const e=[];for(let s=0;s<t.length;s++)t[s]instanceof Array?e.push(X(...t[s])):t[s]instanceof Object&&e.push(null);return 1===e.length?e[0]:e},Y=(t,e,s)=>{const[r,i]=[Math.min(e,s),Math.max(e,s)];return t>=r&&t<=i},K=(t,e,s=1e-4)=>Math.abs(t-e)<=s,Q=(t,e)=>t.reduce(((t,s)=>[...t,...e.map((t=>[s,t]))]),[]),J=(t,e)=>{let s,r=1;if(t==Bs(t)&&e==Bs(e)){for(s=2;s<=t&&s<=e;++s)t%s==0&&e%s==0&&(r=s);return r}console.log("error")},tt=(t,e)=>{let s;if(t==Bs(t)&&e==Bs(e)){for(s=t>e?t:e;s%t!=0||s%e!=0;)++s;return s}console.log("error")},et={add:O,sub:S,mul:C,div:I,modulo:M,zeros:j,ones:D,nums:P,norm:R,lerp:L,map:z,clamp:$,arange:B,linspace:N,logspace:Z,geomspace:F,sum:q,prod:W,accum:X,cartesianProduct:Q,ppcm:tt,pgcd:J,deg2rad:H,rad2deg:U,inRange:Y,isApproximatlyEqual:K},st={_mode:Number,_map:function(t,e,s){return e instanceof ks?new ks(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof As?new As(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},dec2base(t,e){return this._mode=e<=10?Number:String,"number"==typeof t?this._mode((t>>>0).toString(e)):this._map(this.dec2base,t,e)},dec2bin(t){return this.dec2base(t,2)},dec2oct(t){return this.dec2base(t,8)},dec2hex(t){return this.dec2base(t,16)},bin2base(t,e){return this.dec2base(this.bin2dec(t),e)},bin2dec(t){return this._mode("0b"+t)},bin2oct(t){return this.bin2base(t,8)},bin2hex(t){return this.bin2base(t,16)},oct2dec(t){return this._mode("0o"+t)},oct2bin(t){return this.dec2bin(this.oct2dec(t))},oct2hex(t){return this.dec2hex(this.oct2dec(t))},oct2base(t,e){return this.dec2base(this.oct2dec(t),e)},hex2dec(t){return this._mode("0x"+t)},hex2bin(t){return this.dec2bin(this.hex2dec(t))},hex2oct(t){return this.dec2oct(this.hex2dec(t))},hex2base(t,e){return this.dec2base(this.hex2dec(t),e)},IEEE32toDec(t){let e=t.split(" ").join("").padEnd(32,"0"),s=e[0],r=2**(+("0b"+e.slice(1,9))-127);return(-1)**s*(1+e.slice(9,32).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r},IEEE64toDec(t){let e=t.split(" ").join("").padEnd(64,"0"),s=e[0],r=2**(+("0b"+e.slice(1,12))-1023);return(-1)**s*(1+e.slice(13,64).split("").map((t=>+t)).map(((t,e)=>t*2**(-e-1))).reduce(((t,e)=>t+e),0))*r}},rt={_mode:Number,_map:function(t,e,s){return e instanceof ks?new ks(e.rows,e.cols,e.arr.flat(1).map((e=>t(e,s)))):e instanceof As?new As(t(e.a,s),t(e.b,s)):e instanceof Array?e.map((e=>t(e,s))):void 0},not:function(t){return["number","boolean"].includes(typeof t)?rt._mode(!t):this._map(this.not,t)},and:function(t,...e){return["number","boolean"].includes(typeof t)?rt._mode(e.reduce(((t,e)=>t&e),t)):this._map(this.and,t,e)},or:function(t,...e){return["number","boolean"].includes(typeof t)?rt._mode(e.reduce(((t,e)=>t|e),t)):this._map(this.or,t,e)},nand:function(t,...e){return this.not(this.and(t,e))},nor:function(t,...e){return this.not(this.or(t,e))},xor:function(t,...e){let s=[t,...e];return["number","boolean"].includes(typeof t)?this._mode(1===s.reduce(((t,e)=>(1==+e&&(t+=1),t)),0)):this._map(this.xor,t,e)},xnor:function(t,...e){return rt.not(rt.xor(t,e))}};class it{static withDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,i)=>{this.withDiscount(t.slice(i),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}static withoutDiscount(t,e){if(1===e)return t.map((t=>[t]));const s=[];return t.forEach(((r,i)=>{this.withoutDiscount(t.slice(i+1),e-1).forEach((t=>{s.push([r].concat(t))}))})),s}}class nt{static float(t=1,e){return e?Math.random()*(e-t)+t:t*Math.random()}static int(t,e){return Math.floor(this.float(t,e))}static char(t){t=t??this.bool();const e=String.fromCharCode(this.int(97,120));return t?e.toUpperCase():e}static bool(){return[!1,!0][Math.floor(2*Math.random())]}static string(t,e){return t instanceof Array?new Array(this.int(...t)).fill(0).map((()=>this.char(e))).join(""):new Array(t).fill(0).map((()=>this.char(e))).join("")}static bin(){return this.int(2)}static oct(){return this.int(8)}static dec(){return this.int(8)}static hex(){return this.int(16)}static choice(t=[1,2,3],e=new Array(t.length).fill(1/t.length)){let s=new Array(100);e=et.accum(...e).map((t=>100*t)),s.fill(t[0],0,e[0]);for(let r=1;r<t.length;r++)s.fill(t[r],e[r-1],e[r]);return s[this.int(s.length-1)]}static shuffleArr(t){return t.sort((()=>.5-Math.random()))}static shuffleMatrix(t){const{rows:e,cols:s,arr:r}=t;return Ts(e,s,r.flat().sort((()=>.5-Math.random())))}static floats(t,e,s){return new Array(t).fill(0).map((()=>this.float(e,s)))}static ints(t,e,s){return new Array(t).fill(0).map((()=>this.int(e,s)))}static bools(t){return new Array(t).fill(0).map((()=>this.bool()))}static bins(t){return new Array(t).fill(0).map((()=>this.int(2)))}static octs(t){return new Array(t).fill(0).map((()=>this.int(8)))}static decs(t){return new Array(t).fill(0).map((()=>this.int(10)))}static hexs(t){return new Array(t).fill(0).map((()=>this.int(16)))}static choices(t,e,s){return new Array(t).fill(0).map((()=>this.choice(e,s)))}static perm(...t){return t.permS[this.int(t.length)]}static color(){return"#"+st.dec2hex(this.float(16777216)).padStart(6,0)}static colors(t){return new Array(t).fill(null).map((()=>this.color()))}static complex(t=[0,1],e=[0,1]){return t instanceof Array?new As(this.float(t[0],t[1]),this.float(e[0],e[1])):new As(...this.floats(2,t,e))}static complexInt(t=[0,1],e=[0,1]){return new As(this.int(t[0],t[1]),this.int(e[0],e[1]))}static complexBin(){return new As(...this.bins(2))}static complexOct(){return new As(...this.octs(2))}static complexDec(){return new As(...this.decs(10))}static complexHex(){return new As(...this.octs(2))}static complexes(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complex(e,s)))}static complexesInt(t,e=0,s=1){return new Array(t).fill(0).map((()=>this.complexInt(e,s)))}static complexesBin(t){return new Array(t).fill(0).map((()=>this.complexBin()))}static complexesOct(t){return new Array(t).fill(0).map((()=>this.complexOct()))}static complexesDec(t){return new Array(t).fill(0).map((()=>this.complexDec()))}static complexesHex(t){return new Array(t).fill(0).map((()=>this.complexHex()))}static matrix(t,e,s,r){return Ts(t,e,this.floats(t*e,s,r))}static matrixInt(t,e,s,r){return Ts(t,e,this.ints(t*e,s,r))}static matrixBin(t,e){return Ts(t,e,this.bins(t*e))}static matrixOct(t,e){return Ts(t,e,this.octs(t*e))}static matrixDec(t,e){return Ts(t,e,this.decs(t*e))}static matrixHex(t,e){return Ts(t,e,this.hex(t*e))}static matrixColor(t,e){return Ts(t,e,this.colors(t*e))}static matrixComplex(t,e,s,r){return Ts(t,e,this.complexes(t*e,s,r))}static matrixComplexInt(t,e,s,r){return Ts(t,e,this.complexesInt(t*e,s,r))}static matrixComplexBin(t,e){return Ts(t,e,this.complexesBin(t*e))}static matrixComplexOct(t,e){return Ts(t,e,this.complexesBin(t*e))}static matrixComplexDec(t,e){return Ts(t,e,this.complexesBin(t*e))}static matrixComplexHex(t,e){return Ts(t,e,this.complexesBin(t*e))}}const at=t=>{const e=new XMLHttpRequest;if(e.open("GET",t,!1),e.send(),200===e.status)return e.responseText;throw new Error(`Failed to fetch data from ${t}. Status: ${e.status}`)};globalThis.fetchdom=async function(t="https://github.com/zakarialaoui10"){const e=await fetch(t),s=await e.text();return(new DOMParser).parseFromString(s,"text/xml").documentElement},globalThis.fetchdomSync=function(t="https://github.com/zakarialaoui10"){const e=at(t);return(new DOMParser).parseFromString(e,"text/xml").documentElement};const ot=(t,e=",")=>t.trim().trimEnd().split("\n").map((t=>t.split(e))),ht=(t,e=",")=>{const[s,...r]=ot(t,e);return r.map((t=>{const e={};return s.forEach(((s,r)=>{e[s]=t[r]})),e}))},ct=t=>t instanceof Array?[Object.keys(t[0]),...t.map((t=>Object.values(t)))]:[Object.keys(t)],lt=(t,e)=>ct(t).map((t=>t.join(e))).join("\n"),ut=(t,e=",")=>lt(t instanceof Object?t:JSON.parse(t),e),mt=(t,e)=>{const s=[];if(Array.isArray(t))t.forEach((t=>{if("object"==typeof t&&null!==t){s.push(`${e}-`);const r=mt(t,`${e} `);s.push(...r)}else s.push(`${e}- ${t}`)}));else for(const r in t)if(t.hasOwnProperty(r)){const i=t[r];if("object"==typeof i&&null!==i){s.push(`${e}${r}:`);const t=mt(i,`${e} `);s.push(...t)}else s.push(`${e}${r}: ${i}`)}return s},pt=(t,e="")=>mt(t,e).join("\n"),ft=(t,e)=>pt(t instanceof Object?t:JSON.parse(t),e),dt=(t,e=1)=>{let s="";for(const r in t)if(t.hasOwnProperty(r)){const i=t[r];s+="\n"+" ".repeat(e)+`<${r}>`,s+="object"==typeof i?dt(i,e+2):`${i}`,s+=`</${r}>`}return s.trim()};class gt{constructor(t){this.cache={node:t}}isZikoUINode(){return!0}get node(){return this.cache.node}}function bt(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)))}function wt(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?Object.defineProperty(t,e,r):"function"==typeof r.value?t[e]=r.value.bind(t):t[e]=r.value}}(t,e)))}class yt extends Array{constructor(...t){super(...t)}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 vt=new yt,xt={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},_t={store:new Map,index:0,register:function(t){this.store.set(this.index++,t)}},Et={ui_index:0,get_ui_index:function(){return this.ui_index++},register_ui:function(t){}},kt={store:new Map,index:0,register:function(t){console.log({index:this.index}),this.store.set(this.index++,t)}};function Tt(){var t;globalThis?.__Ziko__||(globalThis.__Ziko__={__UI__:vt,__HYDRATION__:_t,__State__:kt,__Config__:xt,__CACHE__:Et},t=__Ziko__,Object.defineProperties(t,{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}}))}function At(t){const{store:e,index:s}=__Ziko__.__State__;__Ziko__.__State__.register({value:t,subscribers:new Set,paused:!1});const r=e.get(s);return[function(){return{value:r.value,isStateGetter:()=>!0,_subscribe:t=>r.subscribers.add(t)}},function(t){r.paused||("function"==typeof t&&(t=t(r.value)),t!==r.value&&(r.value=t,r.subscribers.forEach((t=>t(r.value)))))},{pause:()=>{r.paused=!0},resume:()=>{r.paused=!1},clear:()=>{r.subscribers.clear()},force:t=>{"function"==typeof t&&(t=t(r.value)),r.value=t,r.subscribers.forEach((t=>t(r.value)))},getSubscribers:()=>new Set(r.subscribers)}]}globalThis.__Ziko__||Tt();const Ot=t=>"function"==typeof t&&t?.()?.isStateGetter?.(),St=(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)},It={setAttr(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(" ")),Mt.call(this,s[t],r[t])}else e instanceof Array&&(e=e.join(" ")),Mt.call(this,t,e);return this},removeAttr(...t){for(let e=0;e<t.length;e++)this.element?.removeAttribute(t[e]);return this},getAttr(t){return t=Ct(t)?St(t):t,this.element.attributes[t].value},setContentEditable(t=!0){return this.setAttr("contenteditable",t),this}};function Mt(t,e){if("svg"!==this.element?.tagName&&(t=Ct(t)?St(t):t),!this?.attr[t]||this?.attr[t]!==e){if(Ot(e)){e()._subscribe((e=>this.element?.setAttribute(t,e)),this)}else this.element?.setAttribute(t,e);Object.assign(this.cache.attributes,{[t]:e})}}class jt extends gt{constructor(...t){super("span","text",!1,...t),this.element=globalThis?.document?.createTextNode(...t)}isText(){return!0}}const Dt=(...t)=>new jt(...t),Pt={append(...t){return Rt.call(this,"append","push",...t),this},prepend(...t){return this.__addItem__.call(this,"prepend","unshift",...t),this},insertAt(t,...e){if(t>=this.element.children.length)this.append(...e);else for(let s=0;s<e.length;s++)["number","string"].includes(typeof e[s])&&(e[s]=Dt(e[s])),this.element?.insertBefore(e[s].element,this.items[t].element),this.items.splice(t,0,e[s]);return this},remove(...t){const e=t=>{"number"==typeof t&&(t=this.items[t]),t?.isZikoUIElement&&this.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},clear(){return this?.items?.forEach((t=>t.unrender())),this.element.innerHTML="",this},render(t=this.target){if(!this.isBody)return t?.isZikoUIElement&&(t=t.element),this.target=t,this.target?.appendChild(this.element),this},unrender(){return this.cache.parent?this.cache.parent.remove(this):this.target?.children?.length&&[...this.target?.children].includes(this.element)&&this.target.removeChild(this.element),this},renderAfter(t=1){return setTimeout((()=>this.render()),t),this},unrenderAfter(t=1){return setTimeout((()=>this.unrender()),t),this},after(t){return t?.isZikoUIElement&&(t=t.element),this.element?.after(t),this},before(t){return t?.isZikoUIElement&&(t=t.element),this.element?.before(t),this}};async function Rt(t,e,...s){if(this.cache.isFrozzen)return console.warn("You can't append new item to frozzen element"),this;for(let r=0;r<s.length;r++){if(["number","string"].includes(typeof s[r])&&(s[r]=Dt(s[r])),s[r]instanceof Function){const t=s[r]();t.isStateGetter&&(s[r]=Dt(t.value),t._subscribe((t=>s[r].element.textContent=t),s[r]))}if("function"==typeof globalThis?.Node&&s[r]instanceof globalThis?.Node&&(s[r]=new this.constructor(s[r])),s[r]?.isZikoUINode)s[r].cache.parent=this,this.element?.[t](s[r].element),s[r].target=this.element,this.items[e](s[r]);else if(s[r]instanceof Promise){const i=await s[r];i.cache.parent=this,this.element?.[t](i.element),i.target=this.element,this.items[e](i)}else s[r]instanceof Object&&(s[r]?.style&&this.style(s[r]?.style),s[r]?.attr&&Object.entries(s[r].attr).forEach((t=>this.setAttr(""+t[0],t[1]))))}return this.maintain(),this}const Lt={Click:["Click","DblClick"],Ptr:["PtrMove","PtrDown","PtrUp","PtrLeave","PtrEnter","PtrOut","PtrCancel"],Mouse:["MouseMove","MouseDown","MouseUp","MouseEnter","MouseLeave","MouseOut"],Key:["KeyDown","KeyPress","KeyUp"],Clipboard:["Copy","Cut","Paste"],Focus:["focus","blur"],Drag:["Drag","DragStart","DragEnd","Drop"],Wheel:["Wheel"]},zt=(t="")=>t.startsWith("Ptr")?`pointer${t.split("Ptr")[1].toLowerCase()}`:t.toLowerCase();function $t(t,e,s,r,i){this.cache.currentEvent=e,this.cache.event=t,s?.call(this),r?.hasOwnProperty("prototype")?r?.call(this):r?.call(null,this),this.cache.preventDefault[e]&&t.preventDefault(),this.cache.stopPropagation[e]&&t.stopPropagation(),this.cache.stopImmediatePropagation[e]&&t.stopImmediatePropagation(),this.cache.stream.enabled[e]&&i&&this.cache.stream.history[e].push(i),this.cache.callbacks[e]?.map((t=>t(this)))}class Bt{constructor(t=null,e=[],s,r){this.target=t,this.cache={currentEvent:null,event:null,options:{},preventDefault:{},stopPropagation:{},stopImmediatePropagation:{},event_flow:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{},__controllers__:{}},e&&this._register_events(e,s,r)}_register_events(t,e,s,r=!0){const i=t?.map((t=>zt(t)));return i?.forEach(((i,n)=>{Object.assign(this.cache.preventDefault,{[i]:!1}),Object.assign(this.cache.options,{[i]:{}}),Object.assign(this.cache.paused,{[i]:!1}),Object.assign(this.cache.stream.enabled,{[i]:!1}),Object.assign(this.cache.stream.clear,{[i]:!1}),Object.assign(this.cache.stream.history,{[i]:[]}),Object.assign(this.cache.__controllers__,{[i]:t=>$t.call(this,t,i,e,s)}),r&&Object.assign(this,{[`on${t[n]}`]:(...t)=>this.__onEvent(i,this.cache.options[i],{},...t)})})),this}get targetElement(){return this.target?.element}get isParent(){return this.target?.element===this.event.srcElement}get item(){return this.target.find((t=>t.element==this.event?.srcElement))?.[0]}get currentEvent(){return this.cache.currentEvent}get event(){return this.cache.event}setTarget(t){return this.target=t,this}__handle(t,e,s,r){return this.targetElement?.addEventListener(t,e,s),this}__onEvent(t,e,s,...r){if(0===r.length){if(console.log("00"),!this.cache.callbacks[t])return this;console.log("Call"),this.cache.callbacks[t].map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=r.map((t=>e=>t.call(this,e)));return this.__handle(t,this.cache.__controllers__[t],e,s),this}#t(t,e,s){"default"===s&&Object.assign(this.cache[t],{...this.cache[t],...e});const r="default"===s?this.cache[t]:Object.fromEntries(Object.keys(this.cache.preventDefault).map((t=>[t,s])));return Object.assign(this.cache[t],{...r,...e}),this}preventDefault(t={},e="default"){return this.#t("preventDefault",t,e),this}stopPropagation(t={},e="default"){return this.#t("stopPropagation",t,e),this}stopImmediatePropagation(t={},e="default"){return this.#t("stopImmediatePropagation",t,e),this}setEventOptions(t,e){return this.pause({[t]:!0},"default"),Object.assign(this.cache.options[zt(t)],e),this.resume({[t]:!0},"default"),this}pause(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!0);return this}resume(t={},e="default"){t={..."default"===e?this.cache.stream.enabled:Object.entries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(e,this.cache.__controllers__[e],this.cache.options[e]),this.cache.paused[e]=!1);return this}stream(t={},e="default"){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,e]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(){return this}dispose(t={},e="default"){return this.pause(t,e),this}}class Nt extends Bt{constructor(t,e){super(t,Lt.Click,Zt,e)}}function Zt(){"click"===this.currentEvent?this.dx=0:this.dx=1}const Ft=(t,e)=>new Nt(t,e);class Ht extends Bt{constructor(t,e){super(t,Lt.Clipboard,Ut,e)}}function Ut(){}const qt=(t,e)=>new Ht(t,e);class Wt extends Bt{constructor(t,e,s){super(t,e,Vt,s)}_register_events(t){return super._register_events(t,null,null,!1),this}emit(t,e={}){const s=new Event(t);return this.targetElement.dispatchEvent(s),this}on(t,...e){return this.cache.options.hasOwnProperty(t)||this._register_events([t]),this.__onEvent(t,this.cache.options[t],{},...e),this}}function Vt(){}class Gt extends Bt{constructor(t,e){super(t,Lt.Drag,Xt,e)}}function Xt(){}const Yt=(t,e)=>new Gt(t,e);class Kt extends Bt{constructor(t,e){super(t,Lt.Focus,Qt,e)}}function Qt(){}const Jt=(t,e)=>new Kt(t,e);let te=class extends Bt{constructor(t,e){super(t,Lt.Hash,ee,e)}};function ee(){}class se extends Bt{constructor(t,e){super(t,Lt.Key,re,e)}}function re(){switch(this.currentEvent){case"keydown":this.kd=this.event.key;break;case"keypress":this.kp=this.event.key;break;case"keyup":this.ku=this.event.key}}const ie=(t,e)=>new se(t,e);class ne extends Bt{constructor(t,e){super(t,Lt.Mouse,ae,e)}}function ae(){}const oe=(t,e)=>new ne(t,e);class he extends Bt{constructor(t,e){super(t,Lt.Ptr,ce,e),this.isDown=!1}}function ce(){switch(this.currentEvent){case"pointerdown":this.dx=parseInt(this.event.offsetX),this.dy=parseInt(this.event.offsetY),this.isDown=!0;break;case"pointermove":this.mx=parseInt(this.event.offsetX),this.my=parseInt(this.event.offsetY),this.isMoving=!0;break;case"pointerup":{this.ux=parseInt(this.event.offsetX),this.uy=parseInt(this.event.offsetY),this.isDown=!1,console.log(this.target.width);const t=(this.ux-this.dx)/this.target.width,e=(this.dy-this.uy)/this.target.height,s=t<0?"left":t>0?"right":"none",r=e<0?"bottom":e>0?"top":"none";this.swippe={h:s,v:r,delta_x:t,delta_y:e}}}}const le=(t,e)=>new he(t,e);class ue extends Bt{constructor(t,e){super(t,Lt.Touch,me,e)}}function me(){}class pe extends Bt{constructor(t,e){super(t,Lt.Wheel,fe,e)}}function fe(){}const de=(t,e)=>new pe(t,e),ge={ptr:le,mouse:oe,key:ie,click:Ft,drag:Yt,clipboard:qt,focus:Jt,wheel:de},be={};Object.entries(Lt).forEach((([t,e])=>{e.forEach((e=>{const s=`on${e}`;be[s]=function(...e){return this.events[t]||(this.events[t]=ge[t.toLowerCase()](this)),this.events[t][s](...e),this}}))}));const we={at(t){return this.items.at(t)},forEach(t){return this.items.forEach(t),this},map(t){return this.items.map(t)},find(t){return this.items.filter(t)}},ye={style(t){for(let e in t){const s=t[e];if(Ot(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},size(t,e){return this.style({width:t,height:e})},hide(){},show(){},animate(t,{duration:e=1e3,iterations:s=1,easing:r="ease"}={}){return this.element?.animate(t,{duration:e,iterations:s,easing:r}),this}};function ve(t,e,s,r){return this.event=t,this.cache.preventDefault[e]&&t.preventDefault(),console.log({setter:s}),s&&s(),this.cache.stream.enabled[e]&&r&&this.cache.stream.history[e].push(r),this.cache.callbacks[e].map((t=>t(this))),this}class xe{constructor(t){this.target=null,this.setTarget(t),this.__dispose=this.dispose.bind(this)}get targetElement(){return this.target.element}setTarget(t){return this.target=t,this}__handle(t,e,s){const r="drag"===t?t:`${this.cache.prefixe}${t}`;return this.dispose(s),this.targetElement?.addEventListener(r,e),this}__onEvent(t,e,...s){if(0===s.length){if(!(this.cache.callbacks.length>1))return this;this.cache.callbacks.map((t=>e=>t.call(this,e)))}else this.cache.callbacks[t]=s.map((t=>e=>t.call(this,e)));return this.__handle(t,this.__controller[t],e),this}preventDefault(t={}){return Object.assign(this.cache.preventDefault,t),this}pause(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.removeEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!0);return this}resume(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.targetElement?.addEventListener(`${this.cache.prefixe}${e}`,this.__controller[`${this.cache.prefixe}${e}`]),this.cache.paused[`${this.cache.prefixe}${e}`]=!1);return this}dispose(t={}){return this.pause(t),this}stream(t={}){this.cache.stream.t0=Date.now();return t={...Object.fromEntries(Object.keys(this.cache.stream.enabled).map((t=>[t,!0]))),...t},Object.assign(this.cache.stream.enabled,t),this}clear(t={}){t={...Object.fromEntries(Object.keys(this.cache.stream.clear).map((t=>[t,!0]))),...t};for(let e in t)t[e]&&(this.cache.stream.history[e]=[]);return this}}function _e(t){ve.call(this,t,"input",null,null)}function Ee(t){ve.call(this,t,"change",null,null)}class ke extends xe{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{input:!1,change:!1},paused:{input:!1,change:!1},stream:{enabled:{input:!1,change:!1},clear:{input:!1,change:!1},history:{input:[],change:[]}},callbacks:{input:[],change:[]}},this.__controller={input:_e.bind(this),change:Ee.bind(this)}}get value(){return this.target.value}onInput(...t){return this.__onEvent("input",{},...t),this}onChange(...t){return this.__onEvent("change",{},...t),this}}function Te(t){ve.call(this,t,"hashchange",null,null)}class Ae extends xe{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{hashchange:!1},paused:{hashchange:!1},stream:{enabled:{hashchange:!1},clear:{hashchange:!1},history:{hashchange:[]}},callbacks:{hashchange:[]}},this.__controller={hashchange:Te.bind(this)}}onChange(...t){return this.__onEvent("hashchange",{},...t),this}}const Oe=t=>function(e){ve.call(this,e,t,null,null)};class Se extends xe{constructor(t){super(t),this.event=null,this.cache={prefixe:"",preventDefault:{},paused:{},stream:{enabled:{},clear:{},history:{}},callbacks:{}},this.__controller={}}#e(t){return this.cache.preventDefault[t]=!1,this.cache.paused[t]=!1,this.cache.stream.enabled=!1,this.cache.stream.clear=!1,this.cache.stream.history=[],this.cache.callbacks[t]=[],this.__controller[t]=Oe(t).bind(this),this}on(t,...e){return this.__controller[t]||this.#e(t),this.__onEvent(t,{},...e),this}emit(t,e={}){this.__controller[t]||this.#e(t),this.detail=e;const s=new Event(t);return this.targetElement.dispatchEvent(s),this}}const Ce=t=>new Se(t);class Ie extends xe{constructor(t,e=.3,s=.3){super(t);const{removeListener:r,setWidthThreshold:i,setHeightThreshold:n}=function(t,e=.5,s=.5,r,i){let n=L(e,0,r),a=L(s,0,i),o=0,h=0,c=0,l=0;const u=t=>{o=t.clientX,h=t.clientY},m=t=>{c=t.clientX,l=t.clientY,p()};function p(){const t=c-o,e=l-h;(Math.abs(t)>n||Math.abs(e)>a)&&f(t,e)}function f(e,s){const o=globalThis?.CustomEvent?new CustomEvent("swipe",{detail:{deltaX:Ss(e)<n?0:Zs(e)*R(Ss(e),0,r),deltaY:Ss(s)<a?0:Zs(s)*R(Ss(s),0,i),direction:{x:Ss(e)<n?"none":e>0?"right":"left",y:Ss(s)<a?"none":s>0?"down":"up"}}}):null;t?.dispatchEvent(o)}function d(t){n=L(t,0,r)}function g(t){a=L(t,0,i)}return t?.addEventListener("pointerdown",u),t?.addEventListener("pointerup",m),{removeListener(){t?.removeEventListener("pointerdown",u),t?.removeEventListener("pointerup",m),console.log("Swipe event listeners removed")},setWidthThreshold:d,setHeightThreshold:g}}(this.target?.element,e,s,this.target.width,this.target.height);this.cache={width_threshold:e,height_threshold:s,removeListener:r,setWidthThreshold:i,setHeightThreshold:n,legacyTouchAction:globalThis?.document?.body?.style?.touchAction,prefixe:"",preventDefault:{swipe:!1},paused:{swipe:!1},stream:{enabled:{swipe:!1},clear:{swipe:!1},history:{swipe:[]}},callbacks:{swipe:[]}},this.__controller={swipe:Me.bind(this)}}onSwipe(...t){return Object.assign(globalThis?.document?.body?.style,{touchAction:"none"}),this.__onEvent("swipe",{},...t),this}updateThresholds(t=this.cache.width_threshold,e=this.cache.height_threshold){return void 0!==t&&this.cache.setWidthThreshold(t),void 0!==e&&this.cache.setHeightThreshold(e),this}destroy(){return this.cache.removeListener(),Object.assign(globalThis?.document?.body?.style,{touchAction:this.cache.legacyTouchAction}),this}}function Me(t){ve.call(this,t,"swipe",null,null)}const je=(t,e,s)=>new Ie(t,e,s);class De{constructor(t,e){this.target=t,this.observer=null,this.cache={options:e||{attributes:!0,childList:!0,subtree:!0},streamingEnabled:!0,lastMutation:null,mutationHistory:{}},this.observeCallback=(t,e)=>{if(this.cache.streamingEnabled)for(const e of t)switch(e.type){case"attributes":this.cache.mutationHistory.attributes.push(e.target.getAttribute(e.attributeName));break;case"childList":this.cache.mutationHistory.childList.push(e);break;case"subtree":this.cache.mutationHistory.subtree.push(e)}this.callback&&this.callback(t,e)}}observe(t){if(!this.observer){if(!globalThis.MutationObserver)return void console.log("MutationObserver Nor Supported");this.observer=new MutationObserver(this.cache.observeCallback),this.observer.observe(this.target.element,this.cache.options),this.callback=([e])=>t.call(e,this),this.cache.streamingEnabled=!0}}pause(t){this.observer&&(this.observer.disconnect(),t&&this.observer.observe(this.target,t))}reset(t){this.observer&&(this.observer.disconnect(),this.observer.observe(this.target,t||this.cache.options))}clear(){return this.observer&&(this.observer.disconnect(),this.observer=null,this.cache.mutationHistory={attributes:[],childList:[],subtree:[]}),this.cache.streamingEnabled=!1,this}getMutationHistory(){return this.cache.mutationHistory}enableStreaming(){return this.cache.streamingEnabled=!0,this}disableStreaming(){return this.cache.streamingEnabled=!1,this}}class Pe extends De{constructor(t,e){super(t,{attributes:!0,childList:!1,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)this.cache.lastMutation={name:e.attributeName,value:e.target.getAttribute(e.attributeName)},this.cache.streamingEnabled&&this.cache.mutationHistory.attributes.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.attributes=[],e&&this.observe(e)}get history(){return this.cache.mutationHistory.attributes}}const Re=(t,e)=>new Pe(t,e);class Le extends De{constructor(t,e){super(t,{attributes:!1,childList:!0,subtree:!1}),Object.assign(this.cache,{observeCallback:(t,e)=>{for(const e of t)e.addedNodes?this.cache.lastMutation={type:"add",item:this.target.find((t=>t.element===e.addedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}:e.addedNodes&&(this.cache.lastMutation={type:"remove",item:this.target.find((t=>t.element===e.removedNodes[0]))[0],previous:this.target.find((t=>t.element===e.previousSibling))[0]}),this.cache.streamingEnabled&&this.cache.mutationHistory.children.push(this.cache.lastMutation);this.callback&&this.callback(t,e)}}),this.cache.mutationHistory.children=[],e&&this.observe(e)}get item(){return this.cache.lastMutation.item}get history(){return this.cache.mutationHistory.children}}const ze=(t,e)=>new Le(t,e);class $e{constructor(t,e,{threshold:s=0,margin:r=0}={}){this.target=t,this.config={threshold:s,margin:r},globalThis.IntersectionObserver?this.observer=new IntersectionObserver((t=>{this.entrie=t[0],e(this)}),{threshold:this.threshold}):console.log("IntersectionObserver Not Supported")}get ratio(){return this.entrie.intersectionRatio}get isIntersecting(){return this.entrie.isIntersecting}setThreshould(t){return this.config.threshold=t,this}setMargin(t){return t="number"==typeof t?t+"px":t,this.config.margin=t,this}start(){return this.observer.observe(this.target.element),this}stop(){return this}}const Be=(t,e,s)=>new $e(t,e,s);class Ne{constructor(t,e){this.target=t,this.contentRect=null,this.observer=new ResizeObserver((()=>{e(this)}))}get BoundingRect(){return this.target.element.getBoundingClientRect()}get width(){return this.BoundingRect.width}get height(){return this.BoundingRect.height}get top(){return this.BoundingRect.top}get bottom(){return this.BoundingRect.bottom}get right(){return this.BoundingRect.right}get left(){return this.BoundingRect.left}get x(){return this.BoundingRect.x}get y(){return this.BoundingRect.y}start(){return this.observer.observe(this.target.element),this}stop(){return this.observer.unobserve(this.target.element),this}}const Ze=(t,e)=>new Ne(t,e);class Fe{constructor(t=(t=>console.log({x:t.x,y:t.y}))){this.cache={},this.previousX=globalThis?.screenX,this.previousY=globalThis?.screenY}update(){Object.assign(this.cache,{screenXLeft:globalThis?.screenX,screenXRight:globalThis?.screen.availWidth-globalThis?.screenX,screenYTop:globalThis?.screenY,screenYBottom:globalThis?.screen.availHeight-globalThis?.screenY-globalThis?.outerHeight,screenCenterX:globalThis?.screen.availWidth/2,screenCenterY:globalThis?.screen.availHeight/2,windowCenterX:globalThis?.outerWidth/2+globalThis?.screenX,windowCenterY:globalThis?.outerHeight/2+globalThis?.screenY,deltaCenterX:globalThis?.screen.availWidth/2-globalThis?.outerWidth/2+globalThis?.screenX,deltaCenterY:null})}get x0(){return z(globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get y0(){return-z(globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}get x1(){return z(globalThis?.screenX+globalThis?.outerWidth,0,globalThis.screen.availWidth,-1,1)}get y1(){return-z(globalThis?.screenY+globalThis?.outerHeight,0,globalThis.screen.availHeight,-1,1)}get cx(){return z(globalThis?.outerWidth/2+globalThis?.screenX,0,globalThis.screen.availWidth,-1,1)}get cy(){return-z(globalThis?.outerHeight/2+globalThis?.screenY,0,globalThis.screen.availHeight,-1,1)}}class He{constructor(){this.events={},this.maxListeners=10}on(t,e){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.`)}once(t,e){const s=r=>{this.off(t,s),e(r)};this.on(t,s)}off(t,e){const s=this.events[t];if(s){const t=s.indexOf(e);-1!==t&&s.splice(t,1)}}emit(t,e){const s=this.events[t];s&&s.forEach((t=>{t(e)}))}clear(t){t?delete this.events[t]:this.events={}}setMaxListener(t,e){this.maxListeners=e}removeAllListeners(t){t?this.events[t]=[]:this.events={}}}const Ue=()=>new He;class qe{constructor(t,e=!0){this.#e(),this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}#e(){return this.__FavIcon__=document.querySelector("link[rel*='icon']")||document?.createElement("link"),this.__FavIcon__.type="image/x-icon",this.__FavIcon__.rel="shortcut icon",this}set(t){return t!==this.__FavIcon__.href&&(this.__FavIcon__.href=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:favicon-changed")),this}get current(){return document.__FavIcon__.href}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:favicon-changed",t),this}useEventEmitter(){return this.cache.Emitter=Ue(),this}}const We=(t,e)=>new qe(t,e);class Ve{constructor({viewport:t,charset:e,description:s,author:r,keywords:i}){this.document=globalThis?.document,this.meta={},this.init({viewport:t,charset:e,description:s,author:r,keywords:i})}init({viewport:t,charset:e,description:s,author:r,keywords:i}){t&&this.setViewport(t),e&&this.setCharset(e),s&&this.describe(s),r&&this.setAuthor(r),i&&this.setKeywords(i)}set(t,e){const s="charset"===(t=t.toLowerCase()),r=s?document.querySelector("meta[charset]"):document.querySelector(`meta[name=${t}]`);return this.meta=r??document?.createElement("meta"),s?this.meta.setAttribute("charset",e):(this.meta.setAttribute("name",t),this.meta.setAttribute("content",e)),r||this.document.head.append(this.meta),this}setCharset(t="utf-8"){return this.set("charset",t),this}describe(t){return this.set("description",t),this}setViewport(t="width=device-width, initial-scale=1.0"){return this.set("viewport",t),this}setKeywords(...t){return t=[...new Set(t)].join(", "),this.set("keywords",t),this}setAuthor(t){return this.set("author",t),this}}const Ge=({viewport:t,charset:e,description:s,author:r,keywords:i})=>new Ve({viewport:t,charset:e,description:s,author:r,keywords:i});class Xe{constructor(t=document.title,e=!0){this.cache={Emitter:null},e&&this.useEventEmitter(),this.set(t)}useEventEmitter(){return this.cache.Emitter=Ue(),this}set(t){return t!==document.title&&(document.title=t,this.cache.Emitter&&this.cache.Emitter.emit("ziko:title-changed")),this}get current(){return document.title}onChange(t){return this.cache.Emitter&&this.cache.Emitter.on("ziko:title-changed",t),this}}const Ye=(t,e)=>new Xe(t,e);class Ke{constructor({title:t,lang:e,icon:s,meta:r,noscript:i}){this.html=globalThis?.document?.documentElement,this.head=globalThis?.document?.head,t&&Ye(t),e&&this.setLang(e),s&&We(s),r&&Ge(r),i&&this.setNoScript()}setLang(t){this.html.setAttribute("lang",t)}setNoScript(t){}}const Qe=({title:t,lang:e,icon:s,meta:r,noscript:i})=>new Ke({title:t,lang:e,icon:s,meta:r,noscript:i});class Je{constructor(t=[],e=(()=>{})){this.mediaQueryRules=t,this.fallback=e,this.lastCalledCallback=null,this.init()}init(){this.mediaQueryRules.forEach((({query:t,callback:e})=>{const s=globalThis.matchMedia(t),r=()=>{const t=this.mediaQueryRules.some((({query:t})=>globalThis.matchMedia(t).matches));s.matches?(e(),this.lastCalledCallback=e):t||this.lastCalledCallback===this.fallback||(this.fallback(),this.lastCalledCallback=this.fallback)};r(),s.addListener(r)}))}}Tt();class ts extends gt{constructor({element:t,name:e="",type:s="html",render:r=__Ziko__.__Config__.default.render,useDefaultStyle:i=!1}={}){if(super(),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);default:throw Error("Not supported")}else this.target=t?.parentElement;((t,...e)=>{"function"==typeof t?bt(t,...e):wt(t,...e)})(this,It,Pt,ye,we,be),Object.assign(this.cache,{name:e,isInteractive:[!0,!1][Math.floor(2*Math.random())],parent:null,isBody:!1,isRoot:!1,isHidden:!1,isFrozzen:!1,legacyParent:null,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.ui_index=globalThis.__Ziko__.__CACHE__.get_ui_index(),i&&this.style({position:"relative",boxSizing:"border-box",margin:0,padding:0,width:"auto",height:"auto"}),this.items=new yt,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?.(),this.isInteractive()&&(this.setAttr("ziko-hydration-index",globalThis.__Ziko__.__HYDRATION__.index),globalThis.__Ziko__.__HYDRATION__.register((()=>this))),globalThis.__Ziko__.__UI__.push(this)}get element(){return this.cache.element}isInteractive(){return this.cache.isInteractive}isZikoUIElement(){return!0}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}clone(t=!1){}[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})}freeze(t){return this.cache.isFrozzen=t,this}describe(t){t&&this.setAttr("aria-label",t)}get children(){return[...this.element.children]}get cloneElement(){return this.element.cloneNode(!0)}setClasses(...t){return this.setAttr("class",t.join(" ")),this}get classes(){const t=this.element.getAttribute("class");return null===t?[]:t.split(" ")}addClass(){}setId(t){return this.setAttr("id",t),this}get id(){return this.element.getAttribute("id")}onSwipe(t,e,...s){return this.events.swipe||(this.events.swipe=je(this,t,e)),this.events.swipe.onSwipe(...s),this}on(t,...e){return this.events.custom||(this.events.custom=Ce(this)),this.events.custom.on(t,...e),this}emit(t,e={}){return this.events.custom||(this.events.custom=Ce(this)),this.events.custom.emit(t,e),this}watchAttr(t){return this.observer.attr||(this.observer.attr=Re(this,t)),this}watchChildren(t){return this.observer.children||(this.observer.children=ze(this,t)),this}watchSize(t){return this.observer.resize||(this.observer.resize=Ze(this,t)),this.observer.resize.start(),this}watchIntersection(t,e){return this.observer.intersection||(this.observer.intersection=Be(this,t,e)),this.observer.intersection.start(),this}}const es=["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","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"],ss=["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"],rs=new Proxy({},{get(t,e){if("string"!=typeof e)return;let s,r=e.replaceAll("_","-").toLowerCase();return es.includes(r)&&(s="html"),ss.includes(r)&&(s="svg"),(...t)=>["string","number"].includes(typeof t[0])||t[0]instanceof ts||"function"==typeof t[0]&&t[0]().isStateGetter()?new ts({element:r,name:r,type:s}).append(...t):new ts({element:r}).setAttr(t.shift()).append(...t)}});class is extends ts{constructor(t="div",e="100%",s="100%"){super({element:t,name:"Flex"}),this.direction="cols","number"==typeof e&&(e+="%"),"number"==typeof s&&(s+="%"),this.style({width:e,height:s}),this.style({display:"flex"})}get isFlex(){return!0}resp(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 ns.call(this,s),this.style({alignItems:"number"==typeof t?os.call(this,t):t,justifyContent:"number"==typeof e?hs.call(this,e):e}),this}horizontal(t,e,s=1){return as.call(this,s),this.style({alignItems:"number"==typeof e?hs.call(this,e):e,justifyContent:"number"==typeof t?os.call(this,t):t}),this}show(){return this.isHidden=!1,this.style({display:"flex"}),this}}function ns(t){return 1==t?this.style({flexDirection:"column"}):-1==t&&this.style({flexDirection:"column-reverse"}),this}function as(t){return 1==t?this.style({flexDirection:"row"}):-1==t&&this.style({flexDirection:"row-reverse"}),this}function os(t){return"number"==typeof t&&(t=["flex-start","center","flex-end"][t+1]),t}function hs(t){return os(-t)}class cs extends ts{constructor(t="div",e="50vw",s="50vh"){super({element:t,name:"Grid"}),this.direction="cols","number"==typeof e&&(e+="%"),"number"==typeof s&&(s+="%"),this.style({border:"1px solid black",width:e,height:s}),this.style({display:"grid"})}get isGird(){return!0}columns(t){let e="";for(let s=0;s<t;s++)e=e.concat(" auto");return this.#s(e),this}#s(t="auto auto"){return this.style({gridTemplateColumns:t}),this}gap(t=10,e=t){return"number"==typeof t&&(t+="px"),"number"==typeof e&&(e+="px"),this.style({gridColumnGap:t,gridRowGap:e}),this}}class ls extends ts{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.unrender(),this.append(s)}catch(t){console.log({error:t})}})()}}class us extends ts{constructor(t,e){super({element:"div",name:""}),this.element.append("svg"===e?function(t){if(globalThis?.DOMParser){return(new DOMParser).parseFromString(t.replace(/\s+/g," ").trim(),"image/svg+xml").documentElement}}(t):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))}}class ms extends us{constructor(t){super(t,"html")}}class ps extends us{constructor(t){super(t,"svg")}}class fs extends ts{constructor(t,e){super("canvas","canvas"),this.ctx=this.element?.getContext("2d"),this.style({border:"1px red solid"}),this.transformMatrix=new ks([[1,0,0],[0,1,0],[0,0,1]]),this.axisMatrix=new ks([[-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 ks([[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 fs;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 ds extends ts{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 i=Math.abs(s-t),n=Math.abs(r-e);return this.setAttr("viewBox",[t,e,i,n].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 gs=t=>(new XMLSerializer).serializeToString(t),bs=t=>btoa(gs(t)),ws=t=>"data:image/svg+xml;base64,"+bs(t),ys=t=>JSON.stringify(x((t=>["number","string","boolean","bigint"].includes(typeof t)?String(t):t instanceof As||t instanceof ks?t.toString():t instanceof Array?xs(t):void 0),t),null," ").replace(/"([^"]+)":/g,"$1:").replace(/: "([^"]+)"/g,": $1"),vs=t=>{if(!Array.isArray(t))return 0;let e=1;for(const s of t)if(Array.isArray(s)){const t=vs(s);t+1>e&&(e=t+1)}return e},xs=t=>{let e=0;return function t(s){let r=vs(s),i=0;return s.some((t=>Array.isArray(t)))&&(e++,i=1),"["+s.map(((r,i)=>["number","string","boolean","bigint"].includes(typeof r)?String(r):r instanceof As?r.toString():r instanceof Array?`\n${" ".repeat(e)}${t(r)}${i===s.length-1?"\n":""}`:r instanceof Object?ys(r):void 0))+`${" ".repeat((r+e+1)*i)}]`}(t)},_s=(t,e=0)=>{t=Es(t);let s="";const r=" ".repeat(e);for(let i in t)if("object"==typeof t[i]){s+=`${r}${i} {\n`;const n=t[i];for(let t in n)"object"==typeof n[t]?s+=_s({[t]:n[t]},e+1):s+=`${r} ${t.replace(/[A-Z]/g,(t=>"-"+t.toLowerCase()))}: ${n[t]};\n`;s+=`${r}}\n`}return s};function Es(t){return"object"!=typeof t||null===t?t:Object.keys(t).reduce(((e,s)=>(e[s.trim()]=Es(t[s]),e)),Array.isArray(t)?[]:{})}class ks extends v{constructor(t,e,s=[]){if(super(),t instanceof ks)this.arr=t.arr,this.rows=t.rows,this.cols=t.cols;else{let r,i,n=[];if(arguments[0]instanceof Array)t=arguments[0].length,e=arguments[0][0].length,n=arguments[0];else for(r=0;r<t;r++)for(n.push([]),n[r].push(new Array(e)),i=0;i<e;i++)n[r][i]=s[r*e+i],null==s[r*e+i]&&(n[r][i]=0);this.rows=t,this.cols=e,this.arr=n}this.#r()}toString(){return xs(this.arr)}at(t=0,e=void 0){return t<0&&(t=this.rows+t),null==e?this.arr[t]:(e<0&&(e=this.cols+e),this.arr[t][e])}reshape(t,e){if(t*e==this.rows*this.cols)return new ks(t,e,this.arr.flat(1));console.error("Err")}static eye(t){let e=new ks(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}get clone(){return new ks(this.rows,this.cols,this.arr.flat(1))}get size(){return this.rows*this.cols}get shape(){return[this.rows,this.cols]}get reel(){return new ks(this.cols,this.rows,this.arr.flat(1).reel)}get imag(){return new ks(this.cols,this.rows,this.arr.flat(1).imag)}[Symbol.iterator](){return this.arr[Symbol.iterator]()}#r(){for(let t=0;t<this.arr.length;t++)Object.defineProperty(this,t,{value:this.arr[t],writable:!0,configurable:!0,enumerable:!1})}get(t=0,e=0){return-1==e?this.arr[t]:-1==t?this.arr.map((t=>t[e])):this.arr[t][e]}set(t=0,e=0,s){if(-1==e)return this.arr[t]=s;if(-1==t){for(let t=0;t<this.cols;t++)this.arr[t][e]=s[t]||0;return this.arr}return this.arr[t][e]=s}get isSquare(){return this.rows/this.cols==1}get isSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==ks.sub(e,t).max&&0==ks.sub(e,t).min}get isAntiSym(){if(!this.isSquare)return!1;const t=this.T,e=this.clone;return 0==ks.add(e,t).max&&0==ks.add(e,t).min}get isDiag(){if(!this.isSquare)return!1;const t=this.T,e=this.clone,s=ks.mul(e,t),r=ks.dot(t,e);return 0==ks.sub(s,r).max&&0==ks.sub(s,r).min}get isOrtho(){return!!this.isSquare&&(this.isDiag&&(1==this.det||-1==this.det))}get isIdemp(){if(!this.isSquare)return!1;const t=this.clone,e=ks.dot(t,t);return 0==ks.sub(e,t).max&&0==ks.sub(e,t).min}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 ks(this.cols,this.rows,t.flat(1))}get det(){if(!this.isSquare)return new Error("is not square matrix");if(1==this.rows)return this.arr[0][0];function t(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}return function e(s){if(2==s.length)return s.flat(1).some((t=>t instanceof ks))?void console.warn("Tensors are not completely supported yet ..."):et.sub(et.mul(s[0][0],s[1][1]),et.mul(s[0][1],s[1][0]));for(var r=0,i=0;i<s.length;i++){const n=et.add(et.mul(Is(-1,i),et.mul(s[0][i],e(t(s,i)))));r=et.add(r,n)}return r}(this.arr)}get inv(){if(!this.isSquare)return new Error("is not square matrix");if(0===this.det)return"determinat = 0 !!!";let t=function(t){if(t.length!==t[0].length)return;var e=0,s=0,r=0,i=t.length,n=0,a=[],o=[];for(e=0;e<i;e+=1)for(a[a.length]=[],o[o.length]=[],r=0;r<i;r+=1)a[e][r]=e==r?1:0,o[e][r]=t[e][r];for(e=0;e<i;e+=1){if(0==(n=o[e][e])){for(s=e+1;s<i;s+=1)if(0!=o[s][e]){for(r=0;r<i;r++)n=o[e][r],o[e][r]=o[s][r],o[s][r]=n,n=a[e][r],a[e][r]=a[s][r],a[s][r]=n;break}if(0==(n=o[e][e]))return}for(r=0;r<i;r++)o[e][r]=o[e][r]/n,a[e][r]=a[e][r]/n;for(s=0;s<i;s++)if(s!=e)for(n=o[s][e],r=0;r<i;r++)o[s][r]-=n*o[e][r],a[s][r]-=n*a[e][r]}return a}(this.arr);return new ks(this.rows,this.cols,t.flat(1))}static zeros(t,e){let s=new ks(t,e);for(let i=0;i<t;i++)for(var r=0;r<e;r++)s.arr[i][r]=0;return s}static ones(t,e){let s=new ks(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 ks(t,e);for(let i=0;i<t;i++)for(let t=0;t<e;t++)r.arr[i][t]=s;return r}static get rand(){return{int:(t,e,s,r)=>{let i=new ks(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.arr[n][t]=nt.randInt(s,r);return i},bin:(t,e)=>{let s=new ks(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randBin;return s},hex:(t,e)=>{let s=new ks(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.arr[r][t]=nt.randHex;return s},choices:(t,e,s,r)=>{let i=new ks(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.arr[n][t]=nt.choice(s,r);return i},permutation:(t,e,s)=>{}}}static rands(t,e,s=1,r){let i=new ks(t,e);for(let n=0;n<t;n++)for(let t=0;t<e;t++)i.arr[n][t]=nt.rand(s,r);return i}map(t,e,s,r){return et.map(this,t,e,s,r)}lerp(t,e){return et.lerp(this,t,e)}norm(t,e){return et.norm(this,t,e)}clamp(t,e){return et.clamp(this,t,e)}static map(t,e,s,r,i){return et.map(t,e,s,r,i)}static lerp(t,e,s){return et.lerp(t,e,s)}static norm(t,e,s){return et.norm(t,e,s)}static clamp(t,e,s){return et.clamp(Ts,e,s)}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}get toBin(){let t=this.arr.flat(1).toBin;return new ks(this.rows,this.cols,t)}get toOct(){let t=this.arr.flat(1).toOct;return new ks(this.rows,this.cols,t)}get toHex(){let t=this.arr.flat(1).toHex;return new ks(this.rows,this.cols,t)}max2min(){let t=this.arr.flat(1).max2min;return new ks(this.rows,this.cols,t)}min2max(){let t=this.arr.flat(1).min2max;return new ks(this.rows,this.cols,t)}sortRows(t=void 0){let e=this.arr.map((e=>e.sort(t))).flat(1);return new ks(this.rows,this.cols,e)}sortCols(t=void 0){let e=this.T.arr.map((e=>e.sort(t))).flat(1);return new ks(this.rows,this.cols,e).T}filterByRows(t){var e=this.arr.map((e=>e.map((e=>+(""+e).includes(t))))).map((t=>!!Logic.or(...t))),s=this.arr.filter(((t,s)=>!0===e[s]));return 0===s.length&&s.push([]),console.log(s),new ks(s)}filterByCols(t){return new ks(this.T.arr.filter((e=>e.includes(t))))}sortAll(t=void 0){let e=this.arr.flat(1).sort(t);return new ks(this.rows,this.cols,e)}count(t){return this.arr.flat(1).count(t)}toBase(t){let e=this.arr.flat(1).toBase(t);return new ks(this.rows,this.cols,e)}#i(t){if(this.rows!==t.rows)return;let e=this.arr;for(let s=0;s<this.rows;s++)for(let r=this.cols;r<this.cols+t.cols;r++)e[s][r]=t.arr[s][r-this.cols];return this.cols+=t.cols,new ks(this.rows,this.cols,e.flat(1))}hstack(...t){const e=[this,...t].reduce(((t,e)=>t.#i(e)));return Object.assign(this,e),this}static hstack(t,...e){return t.clone.hstack(...e)}#n(t){if(this.cols!==t.cols)return;let e=this.arr;for(let s=this.rows;s<this.rows+t.rows;s++){e[s]=[];for(let r=0;r<this.cols;r++)e[s][r]=t.arr[s-this.rows][r]}return this.rows+=t.rows,new ks(this.rows,this.cols,e.flat(1))}vstack(...t){const e=[this,...t].reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static vstack(t,...e){return t.clone.vstack(...e)}hqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#i(e)));return Object.assign(this,e),this}vqueue(...t){const e=[this,...t].reverse().reduce(((t,e)=>t.#n(e)));return Object.assign(this,e),this}static hqueue(t,...e){return t.clone.hqueue(...e)}static vqueue(t,...e){return t.clone.vqueue(...e)}slice(t=0,e=0,s=this.rows-1,r=this.cols-1){let i=s-t,n=r-e,a=new Array(n);for(let s=0;s<i;s++){a[s]=[];for(let r=0;r<n;r++)a[s][r]=this.arr[s+t][r+e]}return new ks(i,n,a.flat(1))}static slice(t,e=0,s=0,r=this.rows-1,i=this.cols-1){return t.slice(e,s,r,i)}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)}static getRows(t,e,s=e+1){return t.slice(e,0,s,t.cols)}static getCols(t,e,s=e+1){return t.slice(0,e,t.rows,s)}add(...t){for(let s=0;s<t.length;s++){("number"==typeof t[s]||t[s]instanceof As)&&(t[s]=ks.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.add(this.arr[r][e],t[s].arr[r][e])}return new ks(this.rows,this.cols,this.arr.flat(1))}sub(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ks.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.sub(this.arr[r][e],t[s].arr[r][e])}return new ks(this.rows,this.cols,this.arr.flat(1))}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}mul(...t){for(let r=0;r<t.length;r++){"number"==typeof t[r]&&(t[r]=ks.nums(this.rows,this.cols,t[r]));for(var e=0;e<this.rows;e++)for(var s=0;s<this.cols;s++)this.arr[e][s]=et.mul(this.arr[e][s],t[r].arr[e][s])}return new ks(this.rows,this.cols,this.arr.flat(1))}div(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ks.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.div(this.arr[r][e],t[s].arr[r][e])}return new ks(this.rows,this.cols,this.arr.flat(1))}static div(t,...e){return t.clone.div(...e)}static mul(t,...e){return t.clone.mul(...e)}modulo(...t){for(let s=0;s<t.length;s++){"number"==typeof t[s]&&(t[s]=ks.nums(this.rows,this.cols,t[s]));for(let r=0;r<this.rows;r++)for(var e=0;e<this.cols;e++)this.arr[r][e]=et.modulo(this.arr[r][e],t[s].arr[r][e])}return new ks(this.rows,this.cols,this.arr.flat(1))}static modulo(t,...e){return t.clone.modulo(...e)}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 i=0;i<this.arr[0].length;i++)e[s][r]=et.add(e[s][r],et.mul(this.arr[s][i],t.arr[i][r]))}}return new ks(this.arr.length,t.arr[0].length,e.flat(1))}static dot(t,e){return t.dot(e)}pow(t){let e=this.clone,s=this.clone;for(let r=0;r<t-1;r++)s=s.dot(e);return s}static pow(t,e){return t.clone.pow(e)}get somme(){let t=0;for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t+=this.arr[e][s];return t}get DoesItContainComplexNumbers(){return this.arr.flat(1/0).some((t=>t instanceof As))}get min(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return V(...t)}get max(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(G(...this.arr[e]));return G(...t)}get minRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(V(...this.arr[e]));return t}get maxRows(){this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable");let t=[];for(let e=0;e<this.rows;e++)t.push(G(...this.arr[e]));return t}get minCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.minRows}get maxCols(){return this.DoesItContainComplexNumbers&&console.error("Complex numbers are not comparable"),this.T.maxRows}static fromVector(t){return new ks(t.length,1,t)}get toArray(){let t=[];for(let e=0;e<this.rows;e++)for(let s=0;s<this.cols;s++)t.push(this.arr[e][s]);return t}get print(){let t="[";for(let e=0;e<this.arr.length;e++)t+=(0!=e?" ":"")+` [${this.arr[e].map((t=>" "+t.toString()+" "))}],\n`;console.log(t.substring(0,t.length-2)+" ]"),document.write(t.substring(0,t.length-2)+" ]")}get table(){console.table(this.arr)}get serialize(){return JSON.stringify(this)}static deserialize(t){"string"==typeof t&&(t=JSON.parse(t));let e=new ks(t.rows,t.cols);return e.arr=t.arr,e}toTable(){var t=new DocumentFragment,e=new Array(this.rows).fill(null).map((()=>document?.createElement("tr"))),s=this.arr.map((t=>t.map((()=>document?.createElement("td")))));for(let t=0;t<s.length;t++)for(let r=0;r<s[0].length;r++)s[t][r].innerHTML=this.arr[t][r],e[t].appendChild(s[t][r]);return e.map((e=>t.appendChild(e))),t}toGrid(t,e={}){let s=Grid();return s.append(...this.map(t).arr.flat(1).map((t=>t.style(e)))),s.Columns(this.cols),s}sortTable(t=0,{type:e="num",order:s="asc"}={}){var r=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e}))))),i=this.T.arr.map((t=>t.map(((t,e)=>Object.assign({},{x:t,y:e})))));"num"===e?"asc"===s?r[t].sort(((t,e)=>t.x-e.x)):"desc"===s?r[t].sort(((t,e)=>e.x-t.x)):"toggle"===s&&(r[t][0].x>r[t][1].x?r[t].sort(((t,e)=>e.x-t.x)):r[t].sort(((t,e)=>t.x-e.x))):"alpha"===e&&("asc"===s?r[t].sort(((t,e)=>(""+t.x).localeCompare(""+e.x))):"desc"===s&&r[t].sort(((t,e)=>(""+e.x).localeCompare(""+t.x)))),s=r[t].map((t=>t.y));for(let e=0;e<r.length;e++)e!==t&&r[e].map(((t,e)=>t.y=s[e]));for(let e=0;e<r.length;e++)e!==t&&i[e].map(((t,i)=>t.x=r[e][s[i]].x));i[t]=r[t];var n=i.map((t=>t.map((t=>t.x))));return new ks(n).T}}const Ts=(t,e,s)=>new ks(t,e,s);class As extends v{constructor(t=0,e=0){super(),t instanceof As?(this.a=t.a,this.b=t.b):"object"==typeof t?"a"in e&&"b"in t?(this.a=t.a,this.b=t.b):"a"in e&&"z"in t?(this.a=t.a,this.b=Cs(t.z**2-t.a**2)):"a"in e&&"phi"in t?(this.a=t.a,this.b=t.a*Ls(t.phi)):"b"in e&&"z"in t?(this.b=t.b,this.a=Cs(t.z**2-t.b**2)):"b"in e&&"phi"in t?(this.b=e,this.a=t.b/Ls(t.phi)):"z"in e&&"phi"in t&&(this.a=t.z*Ps(t.phi),this.a=t.z*Rs(t.phi)):"number"==typeof t&&"number"==typeof e&&(this.a=+t.toFixed(32),this.b=+e.toFixed(32))}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}get clone(){return new As(this.a,this.b)}get z(){return Fs(this.a,this.b)}get phi(){return Ns(this.b,this.a)}static Zero(){return new As(0,0)}get conj(){return new As(this.a,-this.b)}get inv(){return new As(this.a/(Is(this.a,2)+Is(this.b,2)),-this.b/(Is(this.a,2)+Is(this.b,2)))}add(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new As(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a+=+q(...e).toFixed(15),this.b+=+q(...s).toFixed(15),this}sub(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new As(t[e],0));let e=t.map((t=>t.a)),s=t.map((t=>t.b));return this.a-=+q(...e).toFixed(15),this.b-=+q(...s).toFixed(15),this}mul(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new As(t[e],0));let e=+W(this.z,...t.map((t=>t.z))).toFixed(15),s=+q(this.phi,...t.map((t=>t.phi))).toFixed(15);return this.a=+(e*Ps(s).toFixed(15)).toFixed(14),this.b=+(e*Rs(s).toFixed(15)).toFixed(14),this}div(...t){for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(t[e]=new As(t[e],0));let e=+(this.z/W(...t.map((t=>t.z)))).toFixed(15),s=+(this.phi-q(...t.map((t=>t.phi)))).toFixed(15);return this.a=+(e*Ps(s).toFixed(15)).toFixed(15),this.b=+(e*Rs(s).toFixed(15)).toFixed(15),this}pow(t){if(Bs(t)===t&&t>0){let e=+(this.z**t).toFixed(15),s=+(this.phi*t).toFixed(15);this.a=+(e*Ps(s).toFixed(15)).toFixed(15),this.b=+(e*Rs(s).toFixed(15)).toFixed(15)}return this}static fromExpo(t,e){return new As(+(t*Ps(e)).toFixed(13),+(t*Rs(e)).toFixed(13))}get expo(){return[this.z,this.phi]}static add(t,...e){return t.clone.add(...e)}static sub(t,...e){return t.clone.sub(...e)}static mul(t,...e){return t.clone.mul(...e)}static div(t,...e){return t.clone.div(...e)}static pow(t,e){return t.clone.pow(e)}static xpowZ(t){return Os(t**this.a*Ps(this.b*Ds(t)),t**this.a*Rs(this.b*Ds(t)))}sqrtn(t=2){return Os(Ms(this.z,t)*Ps(this.phi/t),Ms(this.z,t)*Rs(this.phi/t))}get sqrt(){return this.sqrtn(2)}get log(){return Os(this.z,this.phi)}get cos(){return Os(Ps(this.a)*zs(this.b),Rs(this.a)*$s(this.b))}get sin(){return Os(Rs(this.a)*zs(this.b),Ps(this.a)*$s(this.b))}get tan(){const t=Ps(2*this.a)+zs(2*this.b);return Os(Rs(2*this.a)/t,$s(2*this.b)/t)}printInConsole(){let t=this.a+" + "+this.b+" * i";return console.log(t),t}print(){}UI(){return"<span>"+this.a+" + i * "+this.b+"</span>"}}const Os=(t,e)=>{if((t instanceof Array||ArrayBuffer.isView(t))&&(e instanceof Array||ArrayBuffer.isView(t)))return t.map(((s,r)=>Os(t[r],e[r])));if(t instanceof ks&&e instanceof ks){if(t.shape[0]!==e.shape[0]||t.shape[1]!==e.shape[1])return Error(0);const s=t.arr.map(((s,r)=>Os(t.arr[r],e.arr[r])));return new ks(t.rows,t.cols,...s)}return new As(t,e)},Ss=(...t)=>x(Math.abs,...t),Cs=(...t)=>x(Math.sqrt,...t),Is=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,e):e instanceof As?As.fromExpo(t**e.a,e.b*Ds(t)):x((e=>Is(t,e)),...e);if(t instanceof As)return"number"==typeof e?As.fromExpo(t.z**e,t.phi*e):e instanceof As?As.fromExpo(t.z**e.a*js(-t.phi*e.b),Ds(t.z)*e.b+e.a*t.phi):x((e=>Is(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return x((t=>Is(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(x((e=>Is(t[r],e)),...e));return s}}},Ms=(t,e)=>{if("number"==typeof t)return"number"==typeof e?Math.pow(t,1/e):x((e=>Ms(t,e)),...e);if(t instanceof As)return"number"==typeof e?As.fromExpo(Ms(t.z,e),t.phi/e):x((e=>Ms(t,e)),...e);if(t instanceof Array){if("number"==typeof e)return x((t=>Ms(t,e)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(x((e=>Ms(t[r],e)),...e));return s}}},js=(...t)=>x(Math.exp,...t),Ds=(...t)=>x(Math.log,...t),Ps=(...t)=>x(y.cos,...t),Rs=(...t)=>x(y.sin,...t),Ls=(...t)=>x(y.tan,...t),zs=(...t)=>x(y.cosh,...t),$s=(...t)=>x(y.sinh,...t),Bs=(...t)=>x(Math.floor,...t),Ns=(t,e,s=!0)=>{if("number"==typeof t)return"number"==typeof e?s?Math.atan2(t,e):180*Math.atan2(t,e)/Math.PI:x((e=>Ns(t,e,s)),...e);if(t instanceof Array){if("number"==typeof e)return x((t=>Ns(t,e,s)),...t);if(e instanceof Array){const s=[];for(let r=0;r<t.length;r++)s.push(x((e=>Is(t[r],e)),...e));return s}}},Zs=(...t)=>x(Math.sign,...t),Fs=(...t)=>t.every((t=>"number"==typeof t))?Math.hypot(...t):t.every((t=>t instanceof Array))?x(Math.hypot,...t):void 0,{PI:Hs,sqrt:Us,cos:qs,sin:Ws,acos:Vs,pow:Gs}=Math,Xs=t=>t,Ys=(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 Ks{constructor(t,{ease:e=Xs,step:s=50,t0:r=0,start:i=!0,duration:n=3e3}={}){this.callback=t,this.state={isRunning:!1,animationId:null,startTime:null,ease:e,step:s,autoStart:i,duration:n},this.t=0,this.tx=0,this.ty=0,this.i=0,this.state.autoStart&&this.start()}#a=()=>{this.t+=this.state.step,this.i++,this.tx=z(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)};#o(t=!0){return this.state.isRunning||(t&&this.reset(!1),this.state.isRunning=!0,this.state.startTime=Date.now(),this.state.animationId=setInterval(this.#a,this.state.step)),this}start(){return this.#o(!0)}pause(){return this.state.isRunning&&(clearInterval(this.state.animationId),this.state.isRunning=!1),this}resume(){return this.#o(!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 Qs{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 Js extends Qs{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 tr{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 er{constructor(t,{step:e=1e3,t0:s=0,t1:r=1/0,autoplay:i=!0}={}){this.callback=t,this.cache={isRunning:!1,id:null,last_tick:null,step:e,t0:s,t1:r,autoplay:i,pauseTime:null,frame:0},i&&(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)}}}class sr{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.render(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?.isZikoUIElement?this.wrapper=t:"function"==typeof t&&(this.wrapper=t()),this}setHead(t){return this.head=t instanceof Ke?t:Qe(t),this}}function rr(t){return/:\w+/.test(t)}class ir extends sr{constructor({head:t,wrapper:e,target:s,routes:r}){super({head:t,wrapper:e,target:s}),this.routes=new Map([["404",Dt("Error 404")],...Object.entries(r)]),this.clear(),globalThis.onpopstate=this.render(location.pathname)}clear(){return[...this.routes].forEach((t=>{!rr(t[0])&&t[1]?.isZikoUIElement&&t[1].unrender()})),this}render(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],i=r[t];if(!e.startsWith(":")&&e!==i)return!1}return!0}(e[0],t)));let r;if(rr(e)){const i=function(t,e){const s=t.split("/"),r=e.split("/"),i={};if(s.length!==r.length)return i;for(let t=0;t<s.length;t++){const e=s[t],n=r[t];if(e.startsWith(":"))i[e.slice(1)]=n;else if(e!==n)return{}}return i}(e,t);r=s.call(this,i)}else s?.isZikoUIElement&&s.render(this.wrapper),"function"==typeof s&&(r=s());return r?.isZikoUIElement&&r.render(this.wrapper),r instanceof Promise&&r.then((t=>t.render(this.wrapper))),globalThis.history.pushState({},"",t),this}}const nr=({head:t,wrapper:e,target:s,routes:r})=>new ir({head:t,wrapper:e,target:s,routes:r});function ar(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("/"),i=e.split("/"),n=r.indexOf(i[i.length-1]);if(-1!==n){const t=r.slice(n+1),e=t[t.length-1],i="index.js"===e||"index.ts"===e,a=s.some((t=>e===`.${t}`||e.endsWith(`.${t}`)));if(i)return"/"+(t.length>1?t.slice(0,-1).join("/"):"");if(a)return"/"+t.join("/").replace(/\.(js|ts)$/,"")}return""}class or{constructor(t=""){this.channel=new BroadcastChannel(t),this.EVENTS_DATAS_PAIRS=new Map,this.EVENTS_HANDLERS_PAIRS=new Map,this.LAST_RECEIVED_EVENT="",this.UUID="ziko-channel"+nt.string(10),this.SUBSCRIBERS=new Set([this.UUID])}get broadcast(){return this}emit(t,e){return this.EVENTS_DATAS_PAIRS.set(t,e),this.#h(t),this}on(t,e=console.log){return this.EVENTS_HANDLERS_PAIRS.set(t,e),this.#c(),this}#c(){return this.channel.onmessage=t=>{this.LAST_RECEIVED_EVENT=t.data.last_sended_event;const e=t.data.userId;this.SUBSCRIBERS.add(e);const s=t.data.EVENTS_DATAS_PAIRS.get(this.LAST_RECEIVED_EVENT),r=this.EVENTS_HANDLERS_PAIRS.get(this.LAST_RECEIVED_EVENT);s&&r&&r(s)},this}#h(t){return this.channel.postMessage({EVENTS_DATAS_PAIRS:this.EVENTS_DATAS_PAIRS,last_sended_event:t,userId:this.UUID}),this}close(){return this.channel.close(),this}}const hr=t=>new or(t);class cr{#l;constructor(){this.#l=function(t){try{let e=new Function("return "+t.data.fun)()();postMessage({result:e})}catch(t){postMessage({error:t.message})}finally{t.data.close&&self.close()}}.toString(),this.blob=new Blob(["this.onmessage = "+this.#l],{type:"text/javascript"}),this.worker=new Worker(window.URL.createObjectURL(this.blob))}call(t,e,s=!0){return this.worker.postMessage({fun:t.toString(),close:s}),this.worker.onmessage=function(t){t.data.error?console.error(t.data.error):e(t.data.result)},this}}class lr{constructor(t,{namespace:e="Ziko",register:s,ValidateCssProps:r=!1}={}){this.currentPropsMap=t,this.namespace=e,this.ValidateCssProps=r,this.use(t)}use(t){return this.ValidateCssProps&&function(t){const e=new Set(Object.keys(document.documentElement.style));for(let s in t)if(!e.has(s))throw new Error(`Invalid CSS property: "${s}"`)}(t),this.currentPropsMap=t,this.#r(),this}#r(){const t=globalThis?.document?.documentElement?.style;for(let 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})}}}class ur{constructor(t,e,s){this.cache={storage:t,globalKey:e,channel:hr(`Ziko:useStorage-${e}`),oldItemKeys:new Set},this.#e(s),this.#r()}get items(){return JSON.parse(this.cache.storage[this.cache.globalKey]??null)}#r(){for(let t in this.items)Object.assign(this,{[[t]]:this.items[t]})}#e(t){this.cache.channel=hr(`Ziko:useStorage-${this.cache.globalKey}`),this.cache.channel.on("Ziko-Storage-Updated",(()=>this.#r())),t&&(this.cache.storage[this.cache.globalKey]?(Object.keys(this.items).forEach((t=>this.cache.oldItemKeys.add(t))),console.group("Ziko:useStorage"),console.warn(`Storage key '${this.cache.globalKey}' already exists. we will not overwrite it.`),console.info("%cWe'll keep the existing data.","background-color:#2222dd; color:gold;"),console.group("")):this.set(t))}set(t){return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(t)),this.cache.channel.emit("Ziko-Storage-Updated",{}),Object.keys(t).forEach((t=>this.cache.oldItemKeys.add(t))),this.#r(),this}add(t){const e={...this.items,...t};return this.cache.storage.setItem(this.cache.globalKey,JSON.stringify(e)),this.#r(),this}remove(...t){const e={...this.items};for(let s=0;s<t.length;s++)delete e[t[s]],delete this[t[s]];return this.set(e),this}get(t){return this.items[t]}clear(){return this.cache.storage.removeItem(this.cache.globalKey),this.#r(),this}}let{sqrt:mr,cos:pr,sin:fr,exp:dr,log:gr,cosh:br,sinh:wr}=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 i=r[0];if("number"==typeof i||0===r.length)return e.apply(s,r);if(i?.isComplex?.()){const{a:t,b:n,z:a,phi:o}=i,h=(t,e)=>new i.constructor(t,e);switch(e.name){case"abs":return i.z;case"sqrt":return h(mr(a)*pr(o/2),mr(a)*fr(o/2));case"log":return h(gr(a),o);case"exp":return h(dr(t)*pr(n),dr(t)*fr(n));case"cos":return h(pr(t)*br(n),-fr(t)*wr(n));case"sin":return h(fr(t)*br(n),pr(t)*wr(n));case"tan":{const e=pr(2*t)+br(2*n);return h(fr(2*t)/e,wr(2*n)/e)}case"cosh":return h(br(t)*pr(n),wr(t)*fr(n));case"sinh":return h(wr(t)*pr(n),br(t)*fr(n));case"tanh":{const e=br(2*t)+pr(2*n);return h(wr(2*t)/e,fr(2*n)/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 sr({head:t,wrapper:e,target:s}),t.Arc=t=>1-Ws(Vs(t)),t.Back=(t,e=1)=>t**2*((e+1)*t-e),t.Base=st,t.Canvas=(t,e)=>new fs(t,e),t.Clock=Js,t.Combinaison=it,t.Complex=As,t.Discret=(t,e=5)=>Math.ceil(t*e)/e,t.E=s,t.EPSILON=r,t.Elastic=t=>-2*Gs(2,10*(t-1))*qs(20*Hs*t/3*t),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 i=0;i<e.length;i++){const n=await t[e[i]](),a=await n.default;Object.assign(r,{[ar(e[i],s)]:a})}return nr({target:document.body,routes:{"/":()=>{},...r},wrapper:rs.section()})},t.Flex=(...t)=>{let e="div";return"string"==typeof t[0]&&(e=t[0],t.pop()),new is(e).append(...t)},t.Grid=(...t)=>new cs("div").append(...t),t.HTMLWrapper=t=>new ms(t),t.InBack=(t,e=1.70158,s=e+1)=>s*Gs(t,3)-e*t**2,t.InBounce=(t,e=7.5625,s=2.75)=>1-Ys(1-t,e,s),t.InCirc=t=>1-Us(1-t**2),t.InCubic=t=>t**3,t.InElastic=(t,e=2*Hs/3)=>0===t?0:1===t?1:-Gs(2,10*t-10)*Ws((10*t-10.75)*e),t.InExpo=t=>0===t?0:2**(10*t-10),t.InOutBack=(t,e=1.70158,s=1.525*e)=>t<.5?Gs(2*t,2)*(2*(s+1)*t-s)/2:(Gs(2*t-2,2)*((s+1)*(2*t-2)+s)+2)/2,t.InOutBounce=(t,e=7.5625,s=2.75)=>t<.5?Ys(1-2*t,e,s)/2:Ys(2*t-1,e,s)/2,t.InOutCirc=t=>t<.5?(1-Us(1-(2*t)**2))/2:(Us(1-(-2*t+2)**2)+1)/2,t.InOutCubic=t=>t<.5?4*t**3:1-(-2*t+2)**3/2,t.InOutElastic=(t,e=2*Hs/4.5)=>0===t?0:1===t?1:t<.5?-Gs(2,20*t-10)*Ws((20*t-11.125)*e)/2:Gs(2,-20*t+10)*Ws((20*t-11.125)*e)/2+1,t.InOutExpo=t=>0===t?0:1===t?1:t<.5?2**(20*t-10)/2:(2-2**(-20*t+10))/2,t.InOutQuad=t=>t<.5?2*t**2:1-(-2*t+2)**2/2,t.InOutQuart=t=>t<.5?8*t**4:1-(-2*t+2)**4/2,t.InOutQuint=t=>t<.5?16*t**5:1-(-2*t+2)**5/2,t.InOutSin=t=>-(qs(Hs*t)-1)/2,t.InQuad=t=>t**2,t.InQuart=t=>t**4,t.InQuint=t=>t**5,t.InSin=t=>1-qs(t*Hs/2),t.Linear=Xs,t.Logic=rt,t.Matrix=ks,t.OutBack=(t,e=1.70158,s=e+1)=>1+s*Gs(t-1,3)+e*Gs(t-1,2),t.OutBounce=Ys,t.OutCirc=t=>Us(1-(t-1)**2),t.OutCubic=t=>1-(1-t)**3,t.OutElastic=(t,e=2*Hs/3)=>0===t?0:1===t?1:Gs(2,-10*t)*Ws((10*t-.75)*e)+1,t.OutExpo=t=>1===t?1:1-2**(-10*t),t.OutQuad=t=>1-(1-t)**2,t.OutQuart=t=>1-(1-t)**4,t.OutQuint=t=>1-(1-t)**5,t.OutSin=t=>Ws(t*Hs/2),t.PI=e,t.Permutation=class{static withDiscount(t,e=t.length){if(1===e)return t.map((t=>[t]));const s=[];let r;return r=this.withDiscount(t,e-1),t.forEach((t=>{r.forEach((e=>{s.push([t].concat(e))}))})),s}static withoutDiscount(t){if(1===t.length)return t.map((t=>[t]));const e=[],s=this.withoutDiscount(t.slice(1)),r=t[0];for(let t=0;t<s.length;t++){const i=s[t];for(let t=0;t<=i.length;t++){const s=i.slice(0,t),n=i.slice(t);e.push(s.concat([r],n))}}return e}},t.Random=nt,t.SPA=nr,t.SVGWrapper=t=>new ps(t),t.Scheduler=(t,{repeat:e=null}={})=>new tr(t,{repeat:e}),t.Step=(t,e=5)=>Math.floor(t*e)/e,t.Suspense=(t,e)=>new ls(t,e),t.Svg=(t,e)=>new ds(t,e),t.Tick=Qs,t.TimeAnimation=Ks,t.TimeLoop=er,t.TimeScheduler=tr,t.UIElement=ts,t.UINode=gt,t.Utils=et,t.ZikoApp=sr,t.ZikoCustomEvent=Se,t.ZikoEventClick=Nt,t.ZikoEventClipboard=Ht,t.ZikoEventCustom=Wt,t.ZikoEventDrag=Gt,t.ZikoEventFocus=Kt,t.ZikoEventInput=ke,t.ZikoEventKey=se,t.ZikoEventMouse=ne,t.ZikoEventPointer=he,t.ZikoEventSwipe=Ie,t.ZikoEventTouch=ue,t.ZikoEventWheel=pe,t.ZikoHead=Ke,t.ZikoMutationObserver=De,t.ZikoSPA=ir,t.ZikoUICanvas=fs,t.ZikoUIFlex=is,t.ZikoUIGrid=cs,t.ZikoUIHTMLWrapper=ms,t.ZikoUISVGWrapper=ps,t.ZikoUISuspense=ls,t.ZikoUISvg=ds,t.ZikoUIText=jt,t.ZikoUIXMLWrapper=us,t.ZikoUseRoot=lr,t.__ZikoEvent__=Bt,t.abs=Ss,t.accum=X,t.acos=(...t)=>x(y.acos,...t),t.acosh=(...t)=>x(y.acosh,...t),t.acot=(...t)=>x(y.acot,...t),t.add=O,t.animation=(t,{ease:e,t0:s,t1:r,start:i,duration:n}={})=>new Ks(t,{ease:e,t0:s,t1:r,start:i,duration:n}),t.arange=B,t.arr2str=xs,t.asin=(...t)=>x(y.asin,...t),t.asinh=(...t)=>x(y.asinh,...t),t.atan=(...t)=>x(y.atan,...t),t.atan2=Ns,t.atanh=(...t)=>x(y.atanh,...t),t.bindClickEvent=Ft,t.bindClipboardEvent=qt,t.bindCustomEvent=(t,e,s)=>new Wt(t,e,s),t.bindDragEvent=Yt,t.bindFocusEvent=Jt,t.bindHashEvent=(t,e)=>new te(t,e),t.bindKeyEvent=ie,t.bindMouseEvent=oe,t.bindPointerEvent=le,t.bindTouchEvent=(t,e)=>new ue(t,e),t.bindWheelEvent=de,t.cartesianProduct=Q,t.ceil=(...t)=>x(Math.ceil,...t),t.clamp=$,t.clock=t=>new Js(t),t.combinaison=(t,e,s=!1)=>it[s?"withDiscount":"withoutDiscount"](t,e),t.complex=Os,t.cos=Ps,t.cosh=zs,t.cot=(...t)=>x(y.cot,...t),t.coth=(...t)=>x(y.coth,...t),t.csc=(...t)=>x(y.csc,...t),t.csv2arr=ot,t.csv2json=(t,e=",")=>JSON.stringify(ht(t,e)),t.csv2matrix=(t,e=",")=>new ks(ot(t,e)),t.csv2object=ht,t.csv2sql=(t,e)=>{const s=t.trim().trimEnd().split("\n").filter((t=>t));let r=`INSERT INTO ${e} (${s[0].split(",").join(", ")}) Values `,i=[];for(let t=1;t<s.length;t++){const e=s[t].split(",");i.push(`(${e})`)}return r+i.join(",\n")},t.debounce=(t,e=1e3)=>(...s)=>setTimeout((()=>t(...s)),e),t.defineParamsGetter=function(t){Object.defineProperties(t,{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}})},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="",this.UIElement=e(this.props).render(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=H,t.div=I,t.e=js,t.fact=(...t)=>x((t=>{let e,s=1;if(0==t)s=1;else if(t>0)for(e=1;e<=t;e++)s*=e;else s=NaN;return s}),...t),t.floor=Bs,t.geomspace=F,t.getEvent=zt,t.hypot=Fs,t.inRange=Y,t.isApproximatlyEqual=K,t.isStateGetter=Ot,t.json2arr=t=>ct(t instanceof Object?t:JSON.parse(t)),t.json2css=_s,t.json2csv=ut,t.json2csvFile=(t,e)=>{const s=ut(t,e),r=new Blob([s],{type:"text/csv;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2xml=dt,t.json2xmlFile=(t,e)=>{const s=dt(t,e),r=new Blob([s],{type:"text/xml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.json2yml=ft,t.json2ymlFile=(t,e)=>{const s=ft(t,e),r=new Blob([s],{type:"text/yml;charset=utf-8;"});return{str:s,blob:r,url:URL.createObjectURL(r)}},t.lerp=L,t.linspace=N,t.ln=Ds,t.logspace=Z,t.loop=(t,e={})=>new er(t,e),t.map=z,t.mapfun=x,t.matrix=Ts,t.matrix2=(...t)=>new ks(2,2,t),t.matrix3=(...t)=>new ks(3,3,t),t.matrix4=(...t)=>new ks(4,4,t),t.max=G,t.min=V,t.modulo=M,t.mul=C,t.norm=R,t.nums=P,t.obj2str=ys,t.ones=D,t.pgcd=J,t.pow=Is,t.powerSet=t=>{const e=[],s=2**t.length;for(let r=0;r<s;r+=1){const s=[];for(let e=0;e<t.length;e+=1)r&1<<e&&s.push(t[e]);e.push(s)}return e},t.ppcm=tt,t.preload=at,t.prod=W,t.rad2deg=U,t.round=(...t)=>x(Math.round,...t),t.sec=(...t)=>x(y.sec,...t),t.sig=(...t)=>x((t=>1/(1+js(-t))),...t),t.sign=Zs,t.sin=Rs,t.sinc=(...t)=>x(y.sinc,...t),t.sinh=$s,t.sleep=t=>new Promise((e=>setTimeout(e,t))),t.sqrt=Cs,t.sqrtn=Ms,t.step_fps=t=>1e3/t,t.sub=S,t.subSet=null,t.sum=q,t.svg2ascii=bs,t.svg2img=(t,e=!0)=>rs.img(ws(t)).render(e),t.svg2imgUrl=ws,t.svg2str=gs,t.tags=rs,t.tan=Ls,t.tanh=(...t)=>x(y.tanh,...t),t.text=Dt,t.throttle=(t,e)=>{let s=0;return(...r)=>{const i=(new Date).getTime();i-s<e||(s=i,t(...r))}},t.tick=(t,e,s=1/0,r=!0)=>new Qs(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.useChannel=hr,t.useCustomEvent=Ce,t.useDerived=function(t,e){let s=t(...e.map((t=>t().value)));const r=new Set;return e.forEach((i=>{i()._subscribe((()=>{{const i=t(...e.map((t=>t().value)));i!==s&&(s=i,r.forEach((t=>t(s))))}}))})),()=>({value:s,isStateGetter:()=>!0,_subscribe:t=>r.add(t)})},t.useEventEmitter=Ue,t.useFavIcon=We,t.useHashEvent=t=>new Ae(t),t.useHead=Qe,t.useInputEvent=t=>new ke(t),t.useLocaleStorage=(t,e)=>new ur(localStorage,t,e),t.useMediaQuery=(t,e)=>new Je(t,e),t.useMeta=Ge,t.useReactive=t=>x((t=>{const e=At(t);return{get:e[0],set:e[1]}}),t),t.useRoot=(t,{namespace:e,register:s,ValidateCssProps:r}={})=>new lr(t,{namespace:e,register:s,ValidateCssProps:r}),t.useSessionStorage=(t,e)=>new ur(sessionStorage,t,e),t.useState=At,t.useSuccesifKeys=(t,e=[],s=(()=>{}))=>{t.cache.stream.enabled.down=!0;const r=e.length,i=t.cache.stream.history.down.slice(-r).map((t=>t.key));e.join("")===i.join("")&&(t.event.preventDefault(),s.call(t,t))},t.useSwipeEvent=je,t.useThread=(t,e,s)=>{const r=new cr;return t&&r.call(t,e,s),r},t.useTitle=Ye,t.wait=t=>new Promise((e=>setTimeout(e,t))),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.watch=(t,e={},s=null)=>{const r=new De(t,e);return s&&r.observe(s),r},t.watchAttr=Re,t.watchChildren=ze,t.watchIntersection=Be,t.watchScreen=t=>new Fe(t),t.watchSize=Ze,t.zeros=j}));
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Thu Aug 28 2025 17:39:15 GMT+0100 (UTC+01:00)
5
+ Date : Sat Aug 30 2025 10:47:14 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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "0.44.0",
3
+ "version": "0.45.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",
@@ -0,0 +1,38 @@
1
+ class ClickAwayEvent extends Event {
2
+ constructor(originalEvent, targetElement) {
3
+ super("clickaway", { bubbles: true, cancelable: true });
4
+ this.originalEvent = originalEvent;
5
+ this.targetElement = targetElement;
6
+ }
7
+ }
8
+
9
+ function register_click_away_event(element) {
10
+ function handler(e) {
11
+ if (!element.contains(e.target)) {
12
+ const clickAwayEvent = new ClickAwayEvent(e, element);
13
+ element.dispatchEvent(clickAwayEvent);
14
+ }
15
+ }
16
+
17
+ globalThis?.document?.addEventListener("click", handler);
18
+
19
+ return () => globalThis?.document?.removeEventListener("click", handler);
20
+
21
+ }
22
+
23
+ export{
24
+ ClickAwayEvent,
25
+ register_click_away_event
26
+ }
27
+
28
+ // // Example usage
29
+ // const box = document.querySelector("#my-box");
30
+
31
+ // const stop = listenClickAway(box);
32
+
33
+ // box.addEventListener("clickaway", (e) => {
34
+ // console.log("Clicked outside box!", e);
35
+ // });
36
+
37
+ // // later, you can stop listening:
38
+ // // stop();
@@ -0,0 +1 @@
1
+ export * from './click-away.js'
@@ -0,0 +1,58 @@
1
+ class SwipeEvent extends Event {
2
+ constructor(type, direction, distX, distY, originalEvent) {
3
+ super(type, { bubbles: true, cancelable: true });
4
+ this.direction = direction; // "left" | "right" | "up" | "down"
5
+ this.distX = distX;
6
+ this.distY = distY;
7
+ this.originalEvent = originalEvent;
8
+ }
9
+ }
10
+
11
+ function register_swipe_event(element, threshold = 50, restraint = 100, allowedTime = 500) {
12
+ let startX, startY, startTime, isPointerDown = false;
13
+ function onPointerDown(e) {
14
+ startX = e.clientX;
15
+ startY = e.clientY;
16
+ startTime = Date.now();
17
+ isPointerDown = true;
18
+ }
19
+ function onPointerUp(e) {
20
+ if (!isPointerDown) return;
21
+ isPointerDown = false;
22
+
23
+ const distX = e.clientX - startX;
24
+ const distY = e.clientY - startY;
25
+ const elapsedTime = Date.now() - startTime;
26
+ let direction = null;
27
+ let eventName = null;
28
+
29
+ if (elapsedTime <= allowedTime) {
30
+ if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {
31
+ direction = distX < 0 ? "left" : "right";
32
+ eventName = "swipe" + direction;
33
+ } else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {
34
+ direction = distY < 0 ? "up" : "down";
35
+ eventName = "swipe" + direction;
36
+ }
37
+ }
38
+
39
+ if (eventName && direction) {
40
+ element.dispatchEvent(
41
+ new SwipeEvent(eventName, direction, distX, distY, e),
42
+ );
43
+ }
44
+ }
45
+
46
+ element.addEventListener("pointerdown", onPointerDown, false);
47
+ element.addEventListener("pointerup", onPointerUp, false);
48
+
49
+ return () => {
50
+ element.removeEventListener("pointerdown", onPointerDown, false);
51
+ element.removeEventListener("pointerup", onPointerUp, false);
52
+ };
53
+ }
54
+
55
+ export{
56
+ SwipeEvent,
57
+ register_swipe_event
58
+ }
@@ -0,0 +1,43 @@
1
+ class ViewEvent extends Event {
2
+ constructor(type, detail) {
3
+ super(type, { bubbles: true, cancelable: true });
4
+ this.detail = detail;
5
+ }
6
+ }
7
+
8
+ function register_view_event(element, { intersection = true, resize = true, threshold = 0 } = {}) {
9
+ let intersectionObserver, resizeObserver;
10
+ if (intersection) {
11
+ intersectionObserver = new IntersectionObserver(entries => {
12
+ for (let entry of entries) {
13
+ const type = entry.isIntersecting ? "enterView" : "exitView";
14
+ element.dispatchEvent(new ViewEvent(type, entry));
15
+ }
16
+ }, { threshold });
17
+ intersectionObserver.observe(element);
18
+ }
19
+ if (resize) {
20
+ resizeObserver = new ResizeObserver(entries => {
21
+ for (let entry of entries) {
22
+ const { width, height } = entry.contentRect;
23
+ element.dispatchEvent(new ViewEvent("resizeView", { width, height, entry }));
24
+ }
25
+ });
26
+ resizeObserver.observe(element);
27
+ }
28
+ return () => {
29
+ if (intersectionObserver) {
30
+ intersectionObserver.unobserve(element);
31
+ intersectionObserver.disconnect();
32
+ }
33
+ if (resizeObserver) {
34
+ resizeObserver.unobserve(element);
35
+ resizeObserver.disconnect();
36
+ }
37
+ };
38
+ }
39
+
40
+ export{
41
+ ViewEvent,
42
+ register_view_event
43
+ }
@@ -13,3 +13,5 @@ export * from "./wheel.js";
13
13
  export * from "./__ZikoEvent__.js";
14
14
  export * from "./utils.js";
15
15
 
16
+
17
+ export * from './custom-event.js'