yvee 0.0.7 → 0.0.8

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/index.d.ts CHANGED
@@ -2,6 +2,7 @@ declare const isFN: (v: any) => v is Function;
2
2
  declare const isAsync: (v: any) => v is Function;
3
3
  declare const isPromise: (v: any) => v is Function;
4
4
  declare const isNumber: (value: any) => boolean;
5
+ declare const isObject: (val: any) => val is Record<string, any>;
5
6
  declare const isPlainObject: (value: any) => boolean;
6
7
  declare const isArraybuff: (val: any) => val is string | ArrayBuffer | Uint8Array<ArrayBufferLike>;
7
8
  declare const isClassOrId: (k: string) => boolean;
@@ -32,13 +33,35 @@ declare const is_isNull: typeof isNull;
32
33
  declare const is_isNum: typeof isNum;
33
34
  declare const is_isNumber: typeof isNumber;
34
35
  declare const is_isObj: typeof isObj;
36
+ declare const is_isObject: typeof isObject;
35
37
  declare const is_isPlainObject: typeof isPlainObject;
36
38
  declare const is_isPromise: typeof isPromise;
37
39
  declare const is_isStr: typeof isStr;
38
40
  declare const is_isUndefined: typeof isUndefined;
39
41
  declare const is_isWindow: typeof isWindow;
40
42
  declare namespace is {
41
- export { is_isArr as isArr, is_isArraybuff as isArraybuff, is_isAsync as isAsync, is_isBool as isBool, is_isClassOrId as isClassOrId, is_isDefined as isDefined, is_isFN as isFN, is_isInt as isInt, is_isNotNull as isNotNull, is_isNotWindow as isNotWindow, is_isNull as isNull, is_isNum as isNum, is_isNumber as isNumber, is_isObj as isObj, is_isPlainObject as isPlainObject, is_isPromise as isPromise, is_isStr as isStr, is_isUndefined as isUndefined, is_isWindow as isWindow };
43
+ export {
44
+ is_isArr as isArr,
45
+ is_isArraybuff as isArraybuff,
46
+ is_isAsync as isAsync,
47
+ is_isBool as isBool,
48
+ is_isClassOrId as isClassOrId,
49
+ is_isDefined as isDefined,
50
+ is_isFN as isFN,
51
+ is_isInt as isInt,
52
+ is_isNotNull as isNotNull,
53
+ is_isNotWindow as isNotWindow,
54
+ is_isNull as isNull,
55
+ is_isNum as isNum,
56
+ is_isNumber as isNumber,
57
+ is_isObj as isObj,
58
+ is_isObject as isObject,
59
+ is_isPlainObject as isPlainObject,
60
+ is_isPromise as isPromise,
61
+ is_isStr as isStr,
62
+ is_isUndefined as isUndefined,
63
+ is_isWindow as isWindow,
64
+ };
42
65
  }
43
66
 
44
67
  type V = string | number | boolean;
@@ -216,18 +239,36 @@ declare class Storage$1<T extends MinStorage> {
216
239
  get(path: string): [T | undefined, Record<string, string>];
217
240
  }
218
241
 
242
+ declare class Time {
243
+ date: Date;
244
+ constructor(dateMS?: number);
245
+ delta(date2?: number | null, _Date?: boolean): number | Date;
246
+ timed(time?: {
247
+ year?: number;
248
+ month?: number;
249
+ day?: number;
250
+ hour?: number;
251
+ minute?: number;
252
+ second?: number;
253
+ }): Date;
254
+ static delta(date1: number, date2?: number | null): number;
255
+ static local(date: number): string;
256
+ static get now(): number;
257
+ }
258
+
219
259
  declare class __ {
220
260
  static rand(min?: number, max?: number): number;
221
261
  static fill(count: number, fill?: any): any[];
222
262
  static new({ dom, id, inner, }: {
223
- dom: keyof HTMLElementTagNameMap;
263
+ dom: keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap;
224
264
  id?: string;
225
265
  inner?: any;
226
266
  }): HTMLElement;
227
267
  static randFrom(arr: any[] | Object): any;
268
+ static randArray<T>(arr?: T[], length?: number, unique?: boolean): T[];
228
269
  static randomAZ: () => string;
229
270
  static makeID: (length: number) => string;
230
- static class(a: obj$1<any>, classes: string[]): void;
271
+ static class(a: obj$1<any>, ...classes: string[]): void;
231
272
  static get O(): {
232
273
  vals: {
233
274
  <T>(o: {
@@ -262,8 +303,10 @@ declare class __ {
262
303
  static format(val: any): Formatteer;
263
304
  }
264
305
  declare class returner {
265
- static arr(val: any): any[];
306
+ static arr<T = string>(val?: any): T[];
266
307
  static num(val: any, iferr?: any): number;
308
+ static str(val: any): string;
309
+ static arr2obj(val: any[], switched?: boolean): any;
267
310
  }
268
311
  declare class Formatteer {
269
312
  val: any;
@@ -304,6 +347,13 @@ declare class OZ {
304
347
  RPS(oz?: this): this;
305
348
  }
306
349
 
350
+ declare class ATTR {
351
+ attr: attr;
352
+ constructor(attr?: attr);
353
+ get(catt: CATT, attr?: attr, pre?: string): void;
354
+ unload<T>(x: string): T | undefined;
355
+ }
356
+
307
357
  declare class eStream {
308
358
  stream: EventSource;
309
359
  url: string;
@@ -414,10 +464,11 @@ declare class Eget<T extends Elements = HTMLElement> {
414
464
  type fn<E, T> = (e?: E) => T;
415
465
  declare class Elem<T extends Elements = HTMLElement> extends Eget<T> {
416
466
  constructor(e: T, query?: string);
417
- add(...className: string[]): this;
467
+ add(...className: string[]): () => void;
418
468
  remove(...className: string[]): this;
419
- toggle(className: string | fn<any, string>, force?: boolean): this;
420
- has(e: any | null): boolean;
469
+ toggle(className: string | fn<any, string>, force?: boolean): boolean;
470
+ hasNode(e: Node): boolean;
471
+ has(...classes: string[]): boolean;
421
472
  insert(position: InsertPosition): {
422
473
  HTML: (...text: string[]) => Elem<T>;
423
474
  element: (...elem: HTMLElement[]) => Elem<T>;
@@ -438,8 +489,8 @@ interface CLI {
438
489
  id?: string;
439
490
  class?: string;
440
491
  }
441
- declare function $<T extends Elements = HTMLElement>(query: CLI): Elem<T> | undefined;
442
- declare function $<T extends Elements = HTMLElement>(query: string): Elem<T> | undefined;
492
+ declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: CLI, parent?: P): Elem<T> | undefined;
493
+ declare function $<T extends Elements = HTMLElement, P extends Elements = HTMLElement>(query: string, parent?: P): Elem<T> | undefined;
443
494
  declare function $<T extends Elements = HTMLElement>(element: T): Elem<T>;
444
495
  type _$<T extends Elements = HTMLElement> = Elem<T> | undefined;
445
496
  type $E<T extends Elements = HTMLElement> = Elem<T>;
@@ -564,7 +615,7 @@ interface headAttrPlus {
564
615
  bodyattr?: obj$1<V>;
565
616
  data?: Record<string, any> | (() => Promise<Record<string, any>> | Record<string, any>);
566
617
  }
567
- type headFN<T = {}> = (a: Record<string, any> & T) => Promise<headAttr> | headAttr;
618
+ type headFN<T = Record<string, any>> = (a: renderConfig & T) => Promise<headAttr> | headAttr;
568
619
  type ND<T = Record<string, any>> = (a: renderConfig & T) => Dom | Promise<Dom>;
569
620
  declare function Render<T = Record<string, any>>(DOM: ND<T>, head?: headAttr | headFN<T>, cfg?: headAttrPlus): Promise<({ path, data, status }: serverRender) => Promise<string>>;
570
621
  declare function Render<T = Record<string, any>>(DOM: ND<T>, App: Yvee): Promise<({ path, data, status }: serverRender) => Promise<string>>;
@@ -613,13 +664,15 @@ type statefulValue<T extends any[]> = {
613
664
  [K in keyof T]: T[K] extends Stateful<infer U> ? U : T[K];
614
665
  };
615
666
  declare class Stateful<T> extends EventTarget {
616
- private options?;
667
+ private options;
668
+ private deep;
669
+ private verify;
617
670
  private hooks;
618
671
  private states;
619
672
  private _value;
620
673
  private listening;
621
674
  private end?;
622
- constructor(value: T, options?: AddEventListenerOptions | undefined);
675
+ constructor(value: T, options?: AddEventListenerOptions, deep?: boolean, verify?: boolean);
623
676
  get value(): T;
624
677
  set value(newValue: T);
625
678
  get listen(): () => void;
@@ -627,6 +680,10 @@ declare class Stateful<T> extends EventTarget {
627
680
  hook<T extends any[]>(callback: hookFN<T>): (id: string) => () => void;
628
681
  }
629
682
  declare function State<T>(value: T, options?: AddEventListenerOptions): Stateful<T>;
683
+ /**
684
+ * Quick State checking - skip checking of Object keys:values as it will only be compared as a===b
685
+ */
686
+ declare function QState<T>(value: T, verify?: boolean): Stateful<T>;
630
687
 
631
688
  type X2 = V | V[];
632
689
  type X3 = X2 | Stateful<X2> | null | undefined;
@@ -652,11 +709,11 @@ interface baseAttr {
652
709
  on?: events<any>;
653
710
  id?: string;
654
711
  class?: XU4 | Stateful<X2>;
655
- ref?: Ref;
712
+ ref?: Ref<any>;
656
713
  }
657
714
  declare class Dom {
658
715
  tag: string;
659
- private attr;
716
+ attr: ATTR;
660
717
  private ctx;
661
718
  constructor(tag: string, attr?: attr, ...ctx: ctx[]);
662
719
  __(pid?: idm): {
@@ -675,6 +732,7 @@ declare global {
675
732
  type attr = baseAttr | obj<X3>;
676
733
  type ctx = V | Dom | Stateful<V | Dom> | ctx[];
677
734
  type obj<T> = Record<string, T>;
735
+ type dom = Dom;
678
736
  type DomFN<T = {}> = (a: attr & T, ...D: ctx[]) => Dom;
679
737
  const BASE_STRING: string;
680
738
  namespace JSX {
@@ -862,4 +920,5 @@ interface serverRender {
862
920
  }
863
921
  declare const IfClient: <T>(fn: () => T) => T | undefined;
864
922
 
865
- export { $, type $E, Dom, IfClient, Meta, Pager, Ref, Render, Routes, State, StateHook, Stateful, Yvee, type _$, __, addCSS, cssLoader, doc, dom, eventStream, frag, type headAttr, local, log, pushHistory, type renderConfig, resolvePath, type serverRender, session, useRef, websocket };
923
+ export { $, Dom, IfClient, Meta, Pager, QState, Ref, Render, Routes, State, StateHook, Stateful, Time, Yvee, __, addCSS, cssLoader, doc, dom, eventStream, frag, local, log, pushHistory, resolvePath, session, useRef, websocket };
924
+ export type { $E, Elements, _$, headAttr, renderConfig, serverRender };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var Yr=Object.defineProperty;var Lr=(t,r)=>{for(var n in r)Yr(t,n,{get:r[n],enumerable:!0,configurable:!0,set:(i)=>r[n]=()=>i})};var At={};Lr(At,{isWindow:()=>B,isUndefined:()=>qr,isStr:()=>tt,isPromise:()=>Cr,isPlainObject:()=>D,isObj:()=>$,isNumber:()=>Z,isNum:()=>St,isNull:()=>gt,isNotWindow:()=>T,isNotNull:()=>Xr,isInt:()=>Rt,isFN:()=>w,isDefined:()=>Br,isClassOrId:()=>Fr,isBool:()=>v,isAsync:()=>Pr,isArraybuff:()=>Zr,isArr:()=>m});var w=(t)=>typeof t==="function",Pr=(t)=>t.constructor.name==="AsyncFunction",Cr=(t)=>!!t&&typeof t.then==="function",Z=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},D=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},Zr=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Fr=(t)=>{return t.startsWith(".")||t.startsWith("#")},v=(t)=>typeof t==="boolean",tt=(t)=>typeof t==="string",m=(t)=>Array.isArray(t),$=(t)=>typeof t==="object",St=(t)=>typeof t==="number",gt=(t)=>t===null,Xr=(t)=>t===null,qr=(t)=>typeof t==="undefined",Br=(t)=>typeof t!=="undefined",Rt=(t)=>{return Number.isInteger(Number(t))},B=typeof window!=="undefined",T=typeof window==="undefined";function ct(t,r){g(r).forEach(([n,i])=>{Nt(t,n,{value:i,writable:!1,configurable:!1,enumerable:!0})})}var Ht=(t)=>{return m(t)?t:[t]};class E{static set i(t){console.info(...Ht(t))}static set e(t){console.error(...Ht(t))}static set w(t){console.info(...Ht(t))}}class H{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??x(5),t?.includes("-")){let[r,n]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=r,this._c=Z(n)?parseInt(n):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Ir=(t)=>Array.from({length:t},(r,n)=>n),_t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Ot="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),kt=(t)=>{return JSON.parse(t)};var j=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},x=(t)=>{let r=_t+Ot,n=Ir(10).join("");return Array.from({length:t},(i,o)=>r+(o?n:"")).reduce((i,o)=>{return i+=o.charAt(Math.floor(Math.random()*o.length))},"")},Ur=(t=6,r)=>{if(!r)return Math.floor(Math.random()*t);return Math.round(Math.random()*(r-t)+t)},vt=()=>{let t=[..._t,...Ot],r=Ur(0,t.length);return t[r]};var tr=(t,r)=>{let n=r==="/"?"":r;if(r.startsWith("#"))return t+r;return r.startsWith("/")?t+n:r};class a extends Map{obj(t){t&&g(t).forEach(([r,n])=>this.set(r,n))}map(t){t.forEach((r,n)=>{if(r instanceof a)this.set(n,r);else if(m(r)){if(this.lacks(n))this.set(n,[]);this.get(n).push(...r)}else if($(r))this.ass(n,r);else this.set(n,r)})}ass(t,r){if(!this.has(t))this.set(t,{});p(this.get(t),r)}lacks(t){return!this.has(t)}init(t,r){return this.has(t)?this.get(t):this.set(t,r).get(t)}}var{values:A,keys:W,entries:g}=Object;var{defineProperty:Nt,assign:p}=Object,rr=(t,r)=>Object.hasOwn(t,r),R=(t)=>{return Object.keys(t).length},dt=(t,r)=>{if(!r.has(t))r.set(t,new a);return r.get(t)},rt=(t,r)=>{if(!r.has(t))r.set(t,[]);return r.get(t)},Dt=(t,r)=>{let n={added:{},removed:{},modified:{}},i=W(t),o=W(r);for(let e of o){let f=t[e],s=r[e];if(!(e in t))n.added[e]=s;else if(m(f)&&m(s)){if(S(f)!==S(s))n.modified[e]={old:f,new:s}}else if($(f)&&$(s)&&!gt(f)&&!gt(s)){let u=Dt(f,s);if(R(u.added)||R(u.removed)||R(u.modified))n.modified[e]={old:f,new:s}}else if(f!==s)n.modified[e]={old:f,new:s}}for(let e of i)if(!(e in r))n.removed[e]=t[e];return n};function nr(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}var ir=(t)=>{return A(t).some((r)=>{return R(r)})};var I=(t,r)=>{return{name:t,content:r}},Jr=(t,r)=>{return{property:t,content:r}},Wr=(t,r)=>{return{"http-equiv":t,content:r}};class nt{metas=[];constructor(t){t&&this.metas.push(I("description",t))}author(t){return this.meta=I("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=I("keywords",t.join(", ")),this}viewport(t){let r=g(t).map(([n,i])=>[j(n),String(i)].join("="));return this.meta=I("viewport",r.join(", ")),this}httpEquiv(t){return g(t).forEach(([r,n])=>{this.meta=Wr(j(r),String(n))}),this}robots(...t){return this.meta=I("robots",t.join(", ")),this}themeColor(t){return this.meta=I("theme-color",t),this}openGraph(t){return g(t).forEach(([r,n])=>{this.meta=Jr("og:"+r,String(n))}),this}twitter(t){return g(t).forEach(([r,n])=>{this.meta=I("twitter:"+r,String(n))}),this}push(t){this.metas.unshift(...t)}set meta(t){this.metas.push(t)}}class jt{title;description;base;meta;link;script;css}var Qr=["charset","name","property","http-equiv"],or=(t,r)=>{r.forEach((n)=>{for(let i of Qr)if(i in n){let o=n[i];t[`${i}_${i==="charset"?"":o}`]=n}})},Gr=(t,r)=>{r.forEach((n)=>{if("href"in n){let i=n.href;t[`${i}`]=n}})};class Q{_head;idm;constructor(t){this._head=new a(t)}set head(t){g(t).forEach(([r,n])=>{if(r==="title"||r==="base"){if(n!==void 0)this._head.set(r,n);return}if(n instanceof nt)return or(this._head.init("meta",{}),n.metas);if(!m(n))return;switch(r){case"meta":return or(this._head.init("meta",{}),n);case"link":return Gr(this._head.init("link",{}),n);case"script":if(n.length){this._head.init(r,[]);let i=n.map((o)=>{if(!o.yid&&this.idm)o.yid="sc"+this.idm.mid;return o});this._head.get(r).push(...i)}return}})}get head(){return this._head}set id(t){this.idm=new H(t)}}var it=(t)=>{return g(t??{}).reduce((r,[n,i])=>{return r.push(v(i)&&i?n:`${n}="${i}"`),r},[""]).join(" ")},er=(t)=>{let r=new Set;if(!t)return"";let n=[...t].reduce((i,[o,e])=>{if(o==="meta"||o==="link")e=A(e);if(tt(e)){if(o==="title")r.add(`<${o}>${e}</${o}>`);else i.add(`<${o}>${e}</${o}>`);return i}if(!m(e))return i;if(o==="base"){let s=e.slice(-1);if(s)return r.add(`<${o}${it(s[0])}>`),i}return e.map((s)=>{if(o==="script"){let u={...s},h="";if("importmap"in u)u.type="importmap",h=JSON.stringify(u.importmap),delete u.importmap;else if("body"in u)h=u.body,delete u.body;return`<${o}${it(u)}>${h}</${o}>`}return`<${o}${it(s)}>`}).forEach((s)=>{if(s.includes('type="module"'))r.add(s);else if(s.includes("<meta"))r.add(s);else i.add(s)}),i},new Set);return[...r,...n].join("")};class ot{lang="en";htmlHead;head;constructor(){this.htmlHead=new a,this.head=(t={})=>{let r=new Q(this.htmlHead),{css:n,description:i,...o}=t;if(i)r.head={meta:[{name:"description",content:i}]};if(n){let f=(m(n)?n:[n]).map((s)=>({rel:"preload stylesheet",href:s,as:"style"}));r.head={link:[...f]}}r.head=o,this.htmlHead=r.head}}}var Mt=(t)=>{if(T)return;return new Promise((r,n)=>{let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";g(t).forEach(([o,e])=>{i.setAttribute(o,e)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load CSS")),document.head.appendChild(i)})},sr=(t)=>{if(T)return;return new Promise((r,n)=>{let i=document.createElement("script"),o="";if("importmap"in t)t.type="importmap",o=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)o=t.body,delete t.body;if(o)i.textContent=o;g(t).forEach(([e,f])=>{i.setAttribute(e,f)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load Script")),document.head.appendChild(i),requestAnimationFrame(()=>r("Script executed"))})},Kr=()=>{let r=document.querySelector("#d-css")?.sheet;if(r)return r;let n=document.createElement("style");return n.id="d-css",document.head.appendChild(n),n.sheet},zr=(t,r)=>{for(let n=0;n<t.cssRules.length;n++)if(t.cssRules[n].selectorText===r)return!0;return!1},Vr=(t)=>Object.entries(t).map(([r,n])=>`${j(r)}: ${n};`).join(" ");function Nr(t,r={}){if(T)return;let n=Kr();if(!n)return;if(!zr(n,t))n.insertRule(`${t} { ${Vr(r)} }`,n.cssRules.length)}var Yt=(t,r=!1)=>{if(Z(t))return[+t,Rt(t)?"int":"float"];if(r&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},G=(t)=>{let r=t.startsWith("/")?t:"/"+t,n=r.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[i,o]=n.reduce(([e,f],s)=>{if(s.includes("<")){let u=s.match(/(?<=<)[^/].*?(?=>|$)/g);if(u?.length){let[h,l]=u[0].split(":");if(h&&l)e.push(h),f.push(l)}}else e.push(s===">"?"/":s);return[e,f]},[[],[]]);if(r.endsWith("/")&&r.length>1)i.push("/");return{parsed:i,args:o}};class pt{storage;constructor(){this.storage=new a}cache(t,r){if(this.storage.lacks(t))this.storage.set(t,r());return this.storage.get(t)}}var fr=["int","float","file","uuid","string"],Tt=(t,r)=>{let n={},i=[],{parsed:o}=G(t),{parsed:e,args:f}=G(r);if(o.length===e.length)e.map((s,u)=>{let h=Yt(o[u],o.length-1===u);if(s===h[0])return h[0];if(fr.includes(h[1]))return i.push(h[0]),h[1];return s}),f.forEach((s,u)=>{n[s]=i[u]});return n};class K{_storage;CC;constructor(){this._storage=new a,this.CC=new pt}set(t){let{parsed:r,path:n}=t,i=S(r);if(!this._storage.get(i))this._storage.set(i,t);else throw`path: ${n} already used.`}get(t){let{parsed:r}=this.CC.cache(t,()=>G(t)),n={},i=this._storage.get(S(r));if(!i&&t!=="/")for(let o of this._storage.keys()){let e=[],f=kt(o);if(r.length===f.length){let s=f.map((l,b)=>{let c=Yt(r[b],r.length-1===b);if(l===c[0])return c[0];if(fr.includes(c[1]))return e.push(c[0]),c[1];return l}),u=S(s);if(this._storage.has(u)){i=this._storage.get(u),i?.args.forEach((l,b)=>{n[l]=e[b]});break}}}return[i,n]}}class et{path="";parsed=[];args=[];constructor(t){ct(this,{path:t,...G(t)})}}class ur{static rand(t=6,r){if(r)return Math.floor(Math.random()*(r-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,r=null){return Array(t).fill(r)}static new({dom:t,id:r,inner:n}){let i=document.createElement(t);if(r)i.id=r;if(n)i.innerHTML=n;return i}static randFrom(t){if(Array.isArray(t)){let r=t.length,n=this.rand(0,r-1);return t[n]}else if(typeof t=="object"){let r=W(t),n=r.length,i=this.rand(0,n-1);return r[i]}}static randomAZ=vt;static makeID=x;static class(t,r){let n=r;if(t?.class)n.push(...m(t.class)?t.class:[t.class]);t.class=r}static get O(){return{vals:A,keys:W,items:g,has:rr,ass:p,len:(t={})=>W(t).length}}static get is(){return At}static get return(){return hr}static sleep=(t=1000)=>new Promise((r)=>setTimeout(r,t));static get screen(){let{innerWidth:t}=window,r={xs:t<=480,sm:t>=480,smd:t>=624,md:t>=768,lg:t>=1024,xl:t>=1280,xxl:t>=1536},n=g(r).reverse();for(let i=0;i<n.length;i++){let[o,e]=n[i];if(e)return o}return}bytes(t){if(t===0)return"0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,i)).toFixed(2))+" "+n[i]}static format(t){return new ar(t)}}class hr{static arr(t){return m(t)?t:[t]}static num(t,r=0){let n=parseFloat(t);return isNaN(n)?r:n}}class ar{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}var Lt={},U={};class lr{stream;url;constructor(t,r){if(this.url=t,t in Lt)this.stream=Lt[t];else this.stream=new EventSource(t,{withCredentials:r}),Lt[t]=this.stream,U[this.url]={}}on(t){let r=this.stream;return g(t).forEach(([n,i])=>{if(n in U[this.url])U[this.url][n].forEach((o)=>{this.stream.removeEventListener(n,o)}),U[this.url][n]=[];if(r.addEventListener(n,i),!(n in U[this.url]))U[this.url][n]=[];U[this.url][n].push(i)}),this}}function mr(t,r=!0){return new lr(t,r)}class gr{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(Z(this.value))return parseInt(this.value);else return null}get float(){if(Z(this.value))return parseFloat(this.value);else return null}get bool(){if(this.value==="true")return!0;else if(this.value=="false")return!1;else return null}get json(){if(this.value)return JSON.parse(this.value);return null}}class z{key;state;storage;constructor(t,r="local",n){if(this.storage=r=="local"?localStorage:sessionStorage,typeof t=="object"){let[i,o]=g(t)[0];if(this.key=i,this.state=o,n){let e=this.as[n];this.state.value=e}V((e)=>{this.set=e},[this.state],{id:this.key})}else this.key=t,this.state=null}get as(){return new gr(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}set set(t){let r=$(t)?S(t):String(t);this.storage.setItem(this.key,r)}get remove(){this.storage.removeItem(this.key);return}}var cr={get:(t)=>new z(t,"local"),init:(t,r)=>new z(t,"local",r)};var dr={get:(t)=>new z(t,"session")};class bt extends et{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class pr extends et{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Pt extends ot{storage=new K;errorStorage=new K;wssStorage=new K;route;error;wss;base;constructor(t=""){super();this.base=t?t.startsWith("/")?t:`/${t}`:"",this.route=(r)=>{let n=this._base(r);return(i)=>{return i.route=n,this.storage.set(new bt(n,x(5),i)),i}},this.wss=(r)=>{let n=this._base(r);return(i)=>{return i.route=n,this.wssStorage.set(new pr(n,x(5),i)),i}},this.error=(...r)=>{return(n)=>{if(r.length)r.forEach((i)=>{this.errorStorage.set(new bt(i.toString(),x(5),n))});else this.errorStorage.set(new bt("404",x(5),n));return n}}}_base(t){return tr(this.base,t)}async getPath(t){return this.storage.get(t)}async loadError(t){return this.errorStorage.get(t.toString())}async loadWSS(t){return this.wssStorage.get(t)}}var st=new a,N=(t)=>{if(T)return;let r=st.get(t);if(r?.isConnected)return r;st.delete(t);let n=document.getElementById(t);if(!n)return;return st.set(t,n),n};function Tr(){let t=[];return st.forEach((r,n)=>{if(!r.isConnected)t.push(n),st.delete(n)}),t}function V(t,r,{id:n="stateHook",init:i}={}){if(T)return()=>{};let o=[],e=()=>r.map((s)=>s.value),f=()=>{t(...e())};if(r.forEach((s)=>{o.push(s.hook(f)(n))}),i)f();return()=>{o.forEach((s)=>s())}}var br=(t)=>{t.forEach((r)=>r())};var _r=(t,r)=>{for(let[n,i]of t){let o=N(n);if(!o){t.delete(n);continue}i.forEach((e)=>{e.call(o,r)})}};class Y extends EventTarget{options;hooks=new a;states=new a;_value;listening=!1;end;constructor(t,r){super();this.options=r;this._value=t}get value(){return this._value}set value(t){if(D(this._value)||m(this._value)){let r=Dt(this._value,t);if(!ir(r))return}else if(this._value instanceof Set){if(!nr(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(r)=>{if(br(this.hooks),_r(this.states,r.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,r){return(n)=>{if(dt(n,this.states).set(r,t),!T&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(n))this.states.get(n)?.delete(r)}}}hook(t){return(r)=>{if(this.hooks.set(r,t),!T&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(r))this.hooks.delete(r)}}}}function M(t,r){return new Y(t,r)}var _=(t)=>{if(m(t))return t.filter((r)=>r!==void 0).join(" ");else if($(t)){if(D(t))return S(t)}else if(w(t))return _(t());else if(t!==void 0&&t!==null)return v(t)?t?"":"false":String(t);return""};function Or(t,r){switch(r??t){case"style":return function(n){this.style.setProperty(t,n)};default:return function(n){this.setAttribute(t,n)}}}class Ct{attr;constructor(t={}){this.attr=t}get(t,r=this.attr,n){let i=(o,e)=>{if(m(e))t.attr_push(o,_(e));else if(e instanceof Y){let f=n?`${n}_${o}`:o;t.states.push(e.call(Or(o,n),f)),i(o,e.value)}else if($(e)){if(D(e)&&!n)this.get(t,e,o)}else t.attr_push(o,_(e),n)};g(r).forEach(([o,e])=>{if(o==="ref"){if(e instanceof ft)t.events.obj({element(){e.element=this}})}else if(["on"].includes(o))$(r.on)&&t.events.obj(r.on);else i(o,e)})}}class F{xid;IDM;map=new a;states=[];events=new a;OZ;constructor(t,r=new H,n){this.xid=t;this.IDM=r;this.OZ=n??new yt}attr_push(t,r,n){let i=n??t;if(!this.map.has(i))this.map.set(i,[]);let o=n?`${j(t)}:${r};`:r;this.map.get(i).push(o)}get attr(){let t=[""];return this.map.forEach((r,n)=>{let i=r.join("");t.push(i?`${n}="${i}"`:n)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}var kr=(t,r,n)=>{return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}},ut={};class yt{events=new a;states=new a;winStates=new a;windowEvents=new a;resetST=new a;resetEV=new a;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:r,events:n,states:i}=t;if(r){if(n.size)this.events.set(r,n);if(i.length)this.states.set(r,i)}return this}push(t){return t.events.forEach((r,n)=>{r.forEach((i,o)=>{dt(n,this.events).set(o,i)})}),t.states.forEach((r,n)=>{rt(n,this.states).push(...r)}),this}get stage(){return this.events.forEach((t,r)=>{this.events.delete(r);let n=N(r);if(!n){this.events.delete(r);return}t.forEach((i,o)=>{switch(o){case"ready":case"element":i.apply(n,[n]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let e=o.replace(/^win/,"");this.windowEvents.init(e,new a).set(r,i);break;case"state":let[f,s,u]=i.apply(n,[n]),h=m(s)?s:[s],l=()=>h.map((c)=>c.value),b=()=>f(...l());if(u)b();h.forEach((c)=>rt(r,this.resetST).push(c.call(b,r+"_state")(r)));break;default:rt(r,this.resetEV).push(kr(n,o,i))}})}),this.processWindowEvents,this.states.forEach((t,r)=>{this.states.delete(r),t.forEach((n)=>{rt(r,this.resetST).push(n(r))})}),this}get processWindowEvents(){let t=(r,n)=>{let i=0,o=!1,e=(s)=>{if(i=window.scrollY,!o)window.requestAnimationFrame(()=>{n.forEach((u,h)=>{let l=N(h);if(l)u.call(l,s);else this.windowEvents.get(r)?.delete(h)}),o=!1}),o=!0},f=(s)=>{n.forEach((u,h)=>{let l=N(h);if(l)u.call(l,s);else this.windowEvents.get(r)?.delete(h)})};return window.addEventListener(r,r==="scroll"?e:f),()=>{window.removeEventListener(r,r==="scroll"?e:f)}};return this.windowEvents.forEach((r,n)=>{if(r.size){if(!ut[n])ut[n]=t(n,r)}else if(ut[n])ut[n](),delete ut[n]}),this}reset(t){return t.forEach((r)=>{this.windowEvents.forEach((n,i)=>{if(n.has(r))n.delete(r)}),this.resetEV.get(r)?.forEach((n)=>{n()}),this.resetST.get(r)?.forEach((n)=>{n()}),this.resetST.delete(r),this.resetEV.delete(r)}),this}RPS(t){if(t){let r=Tr();this.reset(r);let n=t.keys;if(n.length)this.reset(n).push(t).stage}return this}}var L=new yt;var vr=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],tn=(t)=>vr.includes(t);function rn(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var xt=(t,r)=>{if(m(t))return t.map((n)=>xt(n,r)).join("");else if(t instanceof O){let n=t.__(r.IDM),{ctx:i,oz:o}=n;return r.OZ.push(o),i}else if($(t))return S(t);else if(w(t))return xt(t(),r);else if(t!==void 0&&t!==null)return rn(t);return""},wt=(t,r)=>{let n=new H(r),i=new F(n.id,n);return{ctx:xt(t,i),catt:i}};function nn(t){let r=this.id;if(r){let{ctx:n,catt:i}=wt(t,r);if(this.innerHTML!==n)this.innerHTML=n,L.RPS(i.OZ)}}var ht=(t,r,n,i=[])=>{if(m(t))t.forEach((o)=>{ht(o,t.length,n,i)});else if(t instanceof Y)if(r>1)ht(X("div",{},t),r,n,i);else{let o=t.value,e=o instanceof O?"dom":"ctx",{ctx:f,catt:s}=wt(o,n.xid+"-0");n.xid=s.xid,i.push(f),n.OZ.push(s.OZ),n.states.push(t.call(nn,e))}else i.push(xt(t,n))};class Zt{tag;ctx;closing;constructor(t,r){this.tag=t;this.ctx=r;let n=tn(t);this.closing=n?"":`</${t}>`}process(t,r=this.ctx,n=[]){return r.forEach((i)=>{ht(i,r.length,t,n)}),n.join("")}get(t){let r=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${r}${this.closing}`}}class O{tag;constructor(t,r={},...n){this.tag=t;ct(this,{attr:new Ct(r),ctx:new Zt(t,n)})}__(t=new H){let r=t.mid,n=new F(r,t);return this.attr.get(n),{ctx:this.ctx.get(n),oz:n.OZ.set(n),id:n.id}}}function X(t,r={},...n){if(w(t))return t(r??{},...n);return new O(t,r??{},n)}var on=(t,...r)=>r;class Ft{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,r={}){return this.e.animate(t,r)}get slide(){let t=({x:r=0,y:n=0},i={})=>{p(this.opt,i);let o=[[r,n],[0,0]].map(([e,f])=>({transform:`translateX(${e}rem) translateY(${f}rem)`}));return this.e.animate(o,this.opt),this};return{left:(r={})=>{return t({x:-2},r)},right:(r={})=>{return t({x:2},r)},up:(r={})=>{return t({y:2},r)},down:(r={})=>{return t({y:-2},r)}}}fade(t={}){p(this.opt,t);let r=[0,1].map((n)=>({opacity:n}));return this.e.animate(r,this.opt),this}shake(t="Y",r={}){p(this.opt,r);let n=[0,5,-5,5,0].map((i)=>({transform:`translate${t}(${i}px)`}));return this.e.animate(n,this.opt),this}color(t=[],r={}){p(this.opt,r);let n=Array.isArray(t)?t.map((i)=>({color:i})):{color:t};return this.e.animate(n,this.opt),this}bg(t=[],r={}){p(this.opt,r);let n=Array.isArray(t)?t.map((i)=>({backgroundColor:i})):{backgroundColor:t};return this.e.animate(n,this.opt),this}bounce(t=1,r={}){p(this.opt,r);let n=[0.5,t,1].map((i)=>({transform:`scale(${i})`}));return this.e.animate(n),this}}class Bt{e;query;constructor(t,r){this.e=t;this.query=r}get a(){return new Ft(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((r)=>r)}return[]}get attr(){let t=this.e;return{has:(r)=>{return t.hasAttribute(r)},get:(r)=>{return t.getAttribute(r)},del:(r)=>{return t.removeAttribute(r),this},set:(r)=>{for(let n in r){let i=r[n];if(r[n]!==void 0)t.setAttribute(n,_(i))}return this}}}get children(){return Array.from(this.e.children).map((t)=>d(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new P(t);return}get parent(){let t=this.e.parentElement;if(t)return new P(t);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,r=this;return{set:(n,i=0)=>{let o=t,e=()=>{g(n).forEach(([f,s])=>{if(f in o){if(o[f]!==s)o[f]=s}else if(s!==null)t.setProperty(f,String(s))})};if(w(i))r.on("transitionend",i);if(St(i))setTimeout(e,i);else e();return r},get:(n)=>{let i=j(String(n));return t.getPropertyValue(i)},del:(...n)=>{n.forEach((i)=>{let o=j(String(i));t.removeProperty(o)})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:r,oz:n}=Xt(t,qt(this.id));this.e.insertAdjacentHTML("beforeend",r),L.RPS(n)}set appendfirst(t){let{ctx:r,oz:n}=Xt(t,qt(this.id));this.e.insertAdjacentHTML("afterbegin",r),L.RPS(n)}set inner(t){let{ctx:r,oz:n}=Xt(t,qt(this.id));this.e.innerHTML=r,L.RPS(n)}set disabled(t){let r=this.e;if("disabled"in r)r.disabled=t}set id(t){this.e.id=t}set value(t){let r=this.e;r.value=t}}var Xt=(t,r)=>{let{ctx:n,catt:i}=wt(t,r);return{ctx:n,oz:i.OZ}},qt=(t)=>t?`${t}-0`:t;class P extends Bt{constructor(t,r){super(t,r)}add(...t){return this.e.classList.add(...t.map((r)=>r.replace(/[^\w-]/,""))),this}remove(...t){return this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,""))),this}toggle(t,r){let n=typeof t!="string"?t.apply(this):t,i=this.e.classList;return n.split(" ").forEach((o)=>{i.toggle(o,r)}),this}has(t){return this.e.contains(t)}insert(t){return{HTML:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentHTML(t,n)}),this},element:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentElement(t,n)}),this},text:function(...r){return r.forEach((n)=>{this.e.insertAdjacentText(t,n)}),this}}}is(t){let r=this.e.classList.value.split(" "),n=this.e.tagName.toLocaleLowerCase(),i=!0,o=!0;if(t.dom)o=t.dom==n?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{i=i?r.includes(e):!1});else i=i?r.includes(t.class):!1;return i&&o}on(t,r,n=!1){let i=!1;if(t.indexOf("touch")>-1)i=!0;return this.e.addEventListener(t,r,{capture:n,passive:i}),this}remove_on(t,r,n=!1){return this.e.removeEventListener(t,r,n),this}timed(t,r=250){return setTimeout(()=>t(this),r),this}animate(t,r,n){let i={duration:300,easing:"ease",fill:"forwards"};if(w(r))n=r;else p(i,r);let o=this.e.animate(t,i);if(n)o.finished.then(n);return this}}function d(t){if(tt(t)){let r=document.querySelector(t);if(r)return new P(r,t);return}else if(D(t)){let[[r,n]]=g(t),o=`${r==="id"?"#":"."}${n}`,e=document.querySelector(o);if(e)return new P(e,o);return}else return new P(t)}class ft{state=new Y(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new P(t);else this.state.value=void 0}get $(){return this.state.value}}var en=()=>{return new ft};class It{lang;head="";constructor(t,r){if(this.lang=t,r)this.head=er(r)}body(t,r,n){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${r??x(5)}"${n?" "+n:""}>${t}</body>`,"</html>"].join("")}}class $t extends jt{path;args;id;status;lang;import;_data={};static route="/";constructor(t,r={},n,i=200){super();this.path=t;this.args=r;this.id=n;this.status=i}async loader(){if(this.import)try{let t=await this.import;if(t.default)this.import=await t.default({...this.args,...this.data});else this.import=void 0}catch(t){return E.e=["import",{error:"loader"}],this.import=void 0,[]}if(this.body){let t=await this.body();return m(t)?t:[t]}if(this.import){let t=this.import;return m(t)?t:[t]}return[]}getHeadAttr(t={},...r){let n=new Q;if(R(t))n.head=t;n.id=this.id;let i=n.head;return r.forEach((o)=>{i.map(o)}),sn(n,this),i}set data(t){p(this._data,t)}get data(){return this._data}}class Ut extends $t{head(){this.title=`error ${this.status}`}body(){return X("div",{},this.path+" not found...")}}function sn(t,r){let{link:n,script:i,meta:o,title:e,base:f,description:s,css:u}=r;if(t.head={title:e,base:f,meta:o,link:n,script:i},s)t.head={meta:[{name:"description",content:s}]};if(u){let l=(m(u)?u:[u]).map((b)=>({rel:"preload stylesheet",href:b,as:"style"}));t.head={link:[...l]}}}function yr(t){let r=[];if(t?.length){let{href:n,target:i}=t[0],o=d("base");if(o){if(o.attr.get("href")!==n)o.attr.set({href:n,target:i})}else{let e=d(document.createElement("base"));e.attr.set({href:n,target:i}),document.head.append(e.e)}}return r}var xr=new a;async function wr(t,r={},n=!1){let i=at.value,o={};if(d("link")?.all.forEach((e)=>{let f=d(e),s=f.attr.get("href");if(s){let u=f.attr.get("rt");if(n){let h=xr.get(i);if(h){if(!h.has(s))o[s]=f.unload}else o[s]=f.unload}else if(u){if(u===t)o[s]=f.unload}}}),r&&R(r))for(let e of A(r)){let f=e.href;if(!(f in o))try{let s=void 0;if(!n){if(s=d(`link[href='${f}']`),s)s.attr.set({rt:t});e.rt=t;let u=xr.init(i,new Set);if(!u.has(f))u.add(f)}if(!s)await Mt(e)}catch(s){E.e=["link error",{error:"yvee @ link"}]}else delete o[f]}return A(o)}var fn=["charset","name","property","http-equiv"];function $r(t){let r={};if(d("meta")?.all.forEach((n)=>{let i=n.attributes;for(let o of fn)if(o in i){let e=i[o].value;r[`${o}_${o==="charset"?"":e}`]=n}}),t)g(t).forEach(([n,i])=>{if(n in r)d(r[n]).attr.set(i),delete r[n];else{let o=d(document.createElement("meta"));o.attr.set(i),document.head.append(o.e)}});return A(r).map((n)=>d(n).unload)}var Er=new a;async function Sr(t,r,n=!1){let i=at.value,o={};if(d("script[yid]")?.all.forEach((e)=>{let f=d(e),s=f.attr.get("yid");if(s){let u=f.attr.get("rt");if(n){let h=Er.get(i);if(h){if(!h.has(s))o[s]=f.unload}else o[s]=f.unload}else if(u){if(u===t)o[s]=f.unload}}}),r){for(let e of r)if("yid"in e)if(e.yid in o)delete o[e.yid];else try{if(!n){e.rt=t;let f=e.yid,s=Er.init(i,new Set);if(!s.has(f))s.add(f)}await sr(e)}catch(f){E.e=["script error",{error:"yvee @ script"}]}}return A(o)}async function Rr(t,r){let n=[];if(T)return[];let i=t.get("title")??"",{pushState:o}=this.config;if(o){let e=this.path.value,f=this.lastPath.value;if(f!==e)if(!f.startsWith(e))q(e,i);else if(e===this.base)q(e,i);else q(e,i)}if(this.isYvee)document.documentElement.lang=r,document.title=i,n.push(...yr(t.get("base"))),n.push(...$r(t.get("meta")));return n.push(...await wr(this.id,t.get("link"),this.isYvee)),n.push(...await Sr(this.id,t.get("script"),this.isYvee)),n}function q(t,r){if(T)return;let{pathname:n,hash:i}=window.location,o=n+i;if(t&&o!==t)history.pushState({},r??"",t)}class Jt{path;args;static route="/";isConnected=M(!1);data={};constructor(t,r={}){this.path=t;this.args=r;this.data=r}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(t){if(this.isConnected.value)this.ws.send(t);else throw new Error(`websocket path ${this.path} not connected`)}}var k=new a;class Wt{yvee;constructor(t){this.yvee=t}async load(t){if(T)return;if(!k.has(t)){let[n,i]=await this.yvee.loadWSS(t);if(!n)return;let{cls:o,path:e,id:f}=n,s=new o(e,i).connect;return k.set(t,s),s}let r=k.get(t);return r.reconnect,r}unload(t){if(T)return;if(k.has(t)){let r=k.get(t);if(!r)return;r.disconnect,k.delete(t)}}}var Qt=new a;function un(t,r,n,i){let{on:o,top:e,topRef:f,...s}=t,u={...o??{},click(h){h.preventDefault();let l=d(this),b=l.path;i.value=n.value,n.value=b;let c=l.hash;if(c){let J=d(c),y=window.scrollY;if(J)y+=J.rect.top;if(f)y-=f?.value?.e.offsetHeight||0;if(e)if(typeof e==="number")y-=e;else y-=e();window.scrollTo({top:y,behavior:"smooth"}),q(b+c)}else if(i.value===n.value)window.scrollTo({top:l.rect.top||0,behavior:"smooth"}),q(window.location.pathname)}};return X("a",{...s,on:{...u}},...r)}function hn(t,r,n){let{classes:i}=t.config,{on:o,...e}=r,f={...r.on??{},...n&&{popstate(s){let h=s.target.location.pathname;t.path.value=h}},...{element(s){t.mainElement=this}}};return X("div",{...e,...i&&{class:i},on:f},t.root)}async function an(t,r){let[n,i]=await this.loadError(r??0);if(n){let{cls:o,id:e}=n;return new o(t,i,e,r)}else{let o=new Ut(t,i,x(5));return o.title=`error ${r}`,o}}function Gt(){if(B)return parseInt(d('meta[name="error"]')?.attr.get("content")??"200");return 200}class lt extends Pt{config;hook;root=M([]);socket;id=x(4);path=M("");lastPath=M("");loading=M(!1);mainElement;A;Main;load;matchPath;isYvee=!1;constructor(t={},r={}){super(t.base??"");this.config=t;if(this.socket=new Wt(this),t.id)this.id=t.id;this.A=(n,...i)=>{if(this.base){if(!n.href.startsWith(this.base))n.href=this._base(n.href)}return un(n,i,this.path,this.lastPath)},this.Main=(n)=>{if(R(r))if(!n.on)n.on=r;else p(n.on,r);return hn(this,n,this.isYvee)},this.load=async(n,i={})=>{if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,i),this.hooker()}catch(o){E.e=["render error",{error:"Pager loader"}]}}return this},this.matchPath=(n)=>{let i=this._base(n),o=this.path.value,e=this.base;if(o===i)return!0;else{let f=o.replace(e,""),s=i.replace(e,"");if(s){if(f.startsWith(s))return!0}else if(!o)return!0}return!1}}hooker(){let t={},r={},n=this.path.value;if(this.hook)this.hook();this.hook=V(async(i)=>{if(r[n]=window.scrollY,t[n]=this.mainElement?.scrollTop??0,(await this.render(i,404)).done){let o=r[i]??0;if(o)window.scrollTo({top:o,behavior:"instant"});let e=t[i]??0;if(e)this.mainElement?.scrollTo({top:e,behavior:"instant"});n=i}},[this.path],{id:"router"})}async class(t,r,n=!1){let[i,o]=await this.getPath(t);if(i&&!n){let{cls:e,id:f}=i;return new e(t,o,f)}else return await an.call(this,t,404)}async fetch(t){if(t)try{if(t.fetch){let r=await t.fetch();if(D(r)&&R(r))t.data=r}}catch(r){E.e=["class fetch",{error:"fetch"}]}}async processHead(t,r={}){return t?await this.processClassHead(t,r):await this.processDefaultHead(r)}async processClassHead(t,r){if(t.head)await t.head();return t.getHeadAttr(r,this.htmlHead)}async processDefaultHead(t){let r=new Q;if(R(t))r.head=t;return r.head.map(this.htmlHead),r.head}async render(t,r=404,n={},i={},o=!0,e=!1){let f=await this.class(t,r??Gt(),e);f.data=n,await this.fetch(f);let s=await this.processHead(f,i);if(T)Qt.set(this.id,s);if(!f)return{lang:this.lang,heads:s,done:!1};let u=[];if(this.loading.value=!0,this.isYvee)u=await f.loader();let h=[];if(o)h=await Rr.call(this,s,f?.lang||this.lang);if(!this.isYvee)u=await f.loader(),h.forEach((l)=>l());if(this.isYvee)h.forEach((l)=>l());if(u.length)this.root.value=u;else await this.render(t,r,n,i,o,!0);return this.loading.value=!1,{heads:s,lang:f.lang??this.lang,done:!0}}}var at=M("");class Et extends lt{config;isYvee=!0;unload=!0;constructor(t={},r={}){super(t,r);this.config=t;this.path=at,this.load=async(n,i={})=>{if(B)n=mn()||this._base(n??"/");if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,i),this.hooker()}catch(o){E.e=["render error",{error:"Yvee loader"}]}}return this}}}var ln=(t)=>{return(r)=>{t(r)}};function mn(){if(B)return d('meta[name="yvee"]')?.attr.get("content")??"/";return""}var Ar=(t,r,n,i=!1)=>{let o=[];if(o.push({charset:"utf-8"}),o.push({name:"viewport",content:"width=device-width, initial-scale=1.0"}),n)switch(n){case 404:o.push({name:"error",content:n.toString()});break;default:break}if(i)o.push({name:"yvee",content:r});if(t.meta)if(m(t.meta))t.meta.unshift(...o);else t.meta.push(o);else t.meta=o},Hr=async(t,r,n={},i=[])=>{let o=await r(n),e=m(o)?o:[o],f=new F(t,new H(t));return e.forEach((s)=>{ht(s,e.length,f,i)}),f.OZ.set(f),f.OZ};async function gn(t,r,n={}){let{bodyattr:i={},id:o,route:e,base:f="",index:s,data:u}=n;if(B){let h={},l=document.body.id;if(r)if(r instanceof Et)await r.load();else{if(u)if(w(u))h=await u();else h=u;let c=window.location.pathname;if(p(h,{path:c,status:Gt()}),e){if(e.length>1&&e.slice(-1)!=="/")c=c.replace(/^\/|\/$/g,"");p(h,Tt(c,e))}}let b=await Hr(l,t,h);L.push(b),requestAnimationFrame(()=>{L.stage})}return async({path:h,data:l={},status:b=200})=>{let c=x(4),J=new a,y={};if(o)c=o;if(i.id)c=i.id.toString();let Kt="en";if(r instanceof Et){let{base:C,path:mt,id:Dr,lang:jr}=r;if(y.base=[{href:C==="/"?C:`${C}/`,target:"_blank"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];mt.value=h,Ar(y,h,b,!0);let{heads:Vt}=await r.render(h,b,l,y,!1);Qt.values().forEach((Mr)=>{p(Vt.init("link",{}),Mr.get("link")??{})}),c=Dr,J=Vt,Kt=jr}else{let C=h==="/"?h:`${h}/`;if(s)C=`${s}/`;if(f)C=`${f}${C}`;if(y.base=[{href:C,target:"_self"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];if(e)p(l,Tt(h,e));p(l,{status:b,path:h,base:f}),p(y,w(r)?await r(l):r),Ar(y,h,b);let mt=new ot;mt.head(y),J=mt.htmlHead}let zt=[];return await Hr(c,t,l,zt),new It(Kt,J).body(zt.join(""),c,it(i))}}var Fs=(t,r)=>{return`${t.replace(/\/+$/,"")}/${r.replace(/^\.\/+/,"")}`},Xs=(t)=>{if(T)return;return t()};export{Jt as websocket,en as useRef,dr as session,Fs as resolvePath,q as pushHistory,E as log,cr as local,on as frag,mr as eventStream,X as dom,$t as doc,Mt as cssLoader,Nr as addCSS,ur as __,Et as Yvee,Y as Stateful,V as StateHook,M as State,ln as Routes,gn as Render,ft as Ref,lt as Pager,nt as Meta,Xs as IfClient,O as Dom,d as $};
1
+ var Pr=Object.defineProperty;var Lr=(t,r)=>{for(var n in r)Pr(t,n,{get:r[n],enumerable:!0,configurable:!0,set:(o)=>r[n]=()=>o})};var At={};Lr(At,{isWindow:()=>q,isUndefined:()=>Ir,isStr:()=>v,isPromise:()=>Zr,isPlainObject:()=>H,isObject:()=>Fr,isObj:()=>E,isNumber:()=>Z,isNum:()=>St,isNull:()=>lt,isNotWindow:()=>p,isNotNull:()=>qr,isInt:()=>Rt,isFN:()=>w,isDefined:()=>Ur,isClassOrId:()=>Xr,isBool:()=>k,isAsync:()=>Cr,isArraybuff:()=>Br,isArr:()=>g});var w=(t)=>typeof t==="function",Cr=(t)=>t.constructor.name==="AsyncFunction",Zr=(t)=>!!t&&typeof t.then==="function",Z=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},Fr=(t)=>{return t&&typeof t==="object"&&!Array.isArray(t)},H=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype&&!Array.isArray(t)},Br=(t)=>{return t instanceof Uint8Array||t instanceof ArrayBuffer||typeof t==="string"},Xr=(t)=>{return t.startsWith(".")||t.startsWith("#")},k=(t)=>typeof t==="boolean",v=(t)=>typeof t==="string",g=(t)=>Array.isArray(t),E=(t)=>typeof t==="object",St=(t)=>typeof t==="number",lt=(t)=>t===null,qr=(t)=>t===null,Ir=(t)=>typeof t==="undefined",Ur=(t)=>typeof t!=="undefined",Rt=(t)=>{return Number.isInteger(Number(t))},q=typeof window!=="undefined",p=typeof window==="undefined";function ct(t,r){l(r).forEach(([n,o])=>{Ot(t,n,{value:o,writable:!1,configurable:!1,enumerable:!0})})}var Dt=(t)=>{return g(t)?t:[t]};class ${static set i(t){console.info(...Dt(t))}static set e(t){console.error(...Dt(t))}static set w(t){console.warn(...Dt(t))}}class D{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??x(5),t?.includes("-")){let[r,n]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=r,this._c=Z(n)?parseInt(n):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var Jr=(t)=>Array.from({length:t},(r,n)=>n),kt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",vt="abcdefghijklmnopqrstuvwxyz";var S=(t)=>JSON.stringify(t),tr=(t)=>{return JSON.parse(t)};var M=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},x=(t)=>{let r=kt+vt,n=Jr(10).join("");return Array.from({length:t},(o,i)=>r+(i?n:"")).reduce((o,i)=>{return o+=i.charAt(Math.floor(Math.random()*i.length))},"")},Wr=(t=6,r)=>{if(!r)return Math.floor(Math.random()*t);return Math.round(Math.random()*(r-t)+t)},rr=()=>{let t=[...kt,...vt],r=Wr(0,t.length);return t[r]};var nr=(t,r)=>{let n=r==="/"?"":r;if(r.startsWith("#"))return t+r;return r.startsWith("/")?t+n:r};class a extends Map{obj(t){t&&l(t).forEach(([r,n])=>this.set(r,n))}map(t){t.forEach((r,n)=>{if(r instanceof a)this.set(n,r);else if(g(r)){if(this.lacks(n))this.set(n,[]);this.get(n).push(...r)}else if(E(r))this.ass(n,r);else this.set(n,r)})}ass(t,r){if(!this.has(t))this.set(t,{});d(this.get(t),r)}lacks(t){return!this.has(t)}init(t,r){return this.has(t)?this.get(t):this.set(t,r).get(t)}}var{values:A,keys:W,entries:l}=Object;var{defineProperty:Ot,assign:d}=Object,or=(t,r)=>Object.hasOwn(t,r),R=(t)=>{return Object.keys(t).length},dt=(t,r)=>{if(!r.has(t))r.set(t,new a);return r.get(t)},tt=(t,r)=>{if(!r.has(t))r.set(t,[]);return r.get(t)},Ht=(t,r)=>{let n={added:{},removed:{},modified:{}},o=W(t),i=W(r);for(let e of i){let f=t[e],s=r[e];if(!(e in t))n.added[e]=s;else if(g(f)&&g(s)){if(S(f)!==S(s))n.modified[e]={old:f,new:s}}else if(E(f)&&E(s)&&!lt(f)&&!lt(s)){let u=Ht(f,s);if(R(u.added)||R(u.removed)||R(u.modified))n.modified[e]={old:f,new:s}}else if(f!==s)n.modified[e]={old:f,new:s}}for(let e of o)if(!(e in r))n.removed[e]=t[e];return n};function ir(t,r){if(t.size!==r.size)return!1;for(let n of t)if(!r.has(n))return!1;return!0}var er=(t)=>{return A(t).some((r)=>{return R(r)})};var I=(t,r)=>{return{name:t,content:r}},Gr=(t,r)=>{return{property:t,content:r}},Qr=(t,r)=>{return{"http-equiv":t,content:r}};class rt{metas=[];constructor(t){t&&this.metas.push(I("description",t))}author(t){return this.meta=I("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=I("keywords",t.join(", ")),this}viewport(t){let r=l(t).map(([n,o])=>[M(n),String(o)].join("="));return this.meta=I("viewport",r.join(", ")),this}httpEquiv(t){return l(t).forEach(([r,n])=>{this.meta=Qr(M(r),String(n))}),this}robots(...t){return this.meta=I("robots",t.join(", ")),this}themeColor(t){return this.meta=I("theme-color",t),this}openGraph(t){return l(t).forEach(([r,n])=>{this.meta=Gr("og:"+r,String(n))}),this}twitter(t){return l(t).forEach(([r,n])=>{this.meta=I("twitter:"+r,String(n))}),this}push(t){this.metas.unshift(...t)}set meta(t){this.metas.push(t)}}class Mt{title;description;base;meta;link;script;css}var Kr=["charset","name","property","http-equiv"],sr=(t,r)=>{r.forEach((n)=>{for(let o of Kr)if(o in n){let i=n[o];t[`${o}_${o==="charset"?"":i}`]=n}})},zr=(t,r)=>{r.forEach((n)=>{if("href"in n){let o=n.href;t[`${o}`]=n}})};class G{_head;idm;constructor(t){this._head=new a(t)}set head(t){l(t).forEach(([r,n])=>{if(r==="title"||r==="base"){if(n!==void 0)this._head.set(r,n);return}if(n instanceof rt)return sr(this._head.init("meta",{}),n.metas);if(!g(n))return;switch(r){case"meta":return sr(this._head.init("meta",{}),n);case"link":return zr(this._head.init("link",{}),n);case"script":if(n.length){this._head.init(r,[]);let o=n.map((i)=>{if(!i.yid&&this.idm)i.yid="sc"+this.idm.mid;return i});this._head.get(r).push(...o)}return}})}get head(){return this._head}set id(t){this.idm=new D(t)}}var nt=(t)=>{return l(t??{}).reduce((r,[n,o])=>{return r.push(k(o)&&o?n:`${n}="${o}"`),r},[""]).join(" ")},fr=(t)=>{let r=new Set;if(!t)return"";let n=[...t].reduce((o,[i,e])=>{if(i==="meta"||i==="link")e=A(e);if(v(e)){if(i==="title")r.add(`<${i}>${e}</${i}>`);else o.add(`<${i}>${e}</${i}>`);return o}if(!g(e))return o;if(i==="base"){let s=e.slice(-1);if(s)return r.add(`<${i}${nt(s[0])}>`),o}return e.map((s)=>{if(i==="script"){let u={...s},h="";if("importmap"in u)u.type="importmap",h=JSON.stringify(u.importmap),delete u.importmap;else if("body"in u)h=u.body,delete u.body;return`<${i}${nt(u)}>${h}</${i}>`}return`<${i}${nt(s)}>`}).forEach((s)=>{if(s.includes('type="module"'))r.add(s);else if(s.includes("<meta"))r.add(s);else o.add(s)}),o},new Set);return[...r,...n].join("")};class ot{lang="en";htmlHead;head;constructor(){this.htmlHead=new a,this.head=(t={})=>{let r=new G(this.htmlHead),{css:n,description:o,...i}=t;if(o)r.head={meta:[{name:"description",content:o}]};if(n){let f=(g(n)?n:[n]).map((s)=>({rel:"preload stylesheet",href:s,as:"style"}));r.head={link:[...f]}}r.head=i,this.htmlHead=r.head}}}var jt=(t)=>{if(p)return;return new Promise((r,n)=>{let o=null;if(t.href)o=document.querySelector(`link[href="${t.href}"]`);if(o){r(o);return}let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";l(t).forEach(([e,f])=>{i.setAttribute(e,f)}),i.onload=()=>r(i),i.onerror=()=>n(new Error("Failed to load CSS")),document.head.appendChild(i)})},ur=(t)=>{if(p)return;return new Promise((r,n)=>{let o=document.createElement("script"),i="";if("importmap"in t)t.type="importmap",i=JSON.stringify(t.importmap),delete t.importmap;else if("body"in t)i=t.body,delete t.body;if(i)o.textContent=i;l(t).forEach(([e,f])=>{o.setAttribute(e,f)}),o.onload=()=>r(o),o.onerror=()=>n(new Error("Failed to load Script")),document.head.appendChild(o),requestAnimationFrame(()=>r("Script executed"))})},Nr=()=>{let r=document.querySelector("#d-css")?.sheet;if(r)return r;let n=document.createElement("style");return n.id="d-css",document.head.appendChild(n),n.sheet},Vr=(t,r)=>{for(let n=0;n<t.cssRules.length;n++)if(t.cssRules[n].selectorText===r)return!0;return!1},_r=(t)=>Object.entries(t).map(([r,n])=>`${M(r)}: ${n};`).join(" ");function Or(t,r={}){if(p)return;let n=Nr();if(!n)return;if(!Vr(n,t))n.insertRule(`${t} { ${_r(r)} }`,n.cssRules.length)}var Yt=(t,r=!1)=>{if(Z(t))return[+t,Rt(t)?"int":"float"];if(r&&/\.\w+$/.test(t))return[t,"file"];if(t==="/")return[t,"-"];if(t.length===36&&t.match(/\-/g)?.length===4)return[t,"uuid"];return[t,"string"]},Q=(t)=>{let r=t.startsWith("/")?t:"/"+t,n=r.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[o,i]=n.reduce(([e,f],s)=>{if(s.includes("<")){let u=s.match(/(?<=<)[^/].*?(?=>|$)/g);if(u?.length){let[h,m]=u[0].split(":");if(h)e.push(h),f.push(m||"_")}}else e.push(s===">"?"/":s);return[e,f]},[[],[]]);if(r.endsWith("/")&&r.length>1)o.push("/");return{parsed:o,args:i}};class pt{storage;constructor(){this.storage=new a}cache(t,r){if(this.storage.lacks(t))this.storage.set(t,r());return this.storage.get(t)}}var hr=["int","float","file","uuid","string"],Tt=(t,r)=>{let n={},o=[],{parsed:i}=Q(t),{parsed:e,args:f}=Q(r);if(i.length===e.length)e.map((s,u)=>{let h=Yt(i[u],i.length-1===u);if(s===h[0])return h[0];if(hr.includes(h[1]))return o.push(h[0]),h[1];return s}),f.forEach((s,u)=>{n[s]=o[u]});return n};class K{_storage;CC;constructor(){this._storage=new a,this.CC=new pt}set(t){let{parsed:r,path:n}=t,o=S(r);if(!this._storage.get(o))this._storage.set(o,t);else throw`path: ${n} already used.`}get(t){let{parsed:r}=this.CC.cache(t,()=>Q(t)),n={},o=this._storage.get(S(r));if(!o&&t!=="/")for(let i of this._storage.keys()){let e=[],f=tr(i);if(r.length===f.length){let s=f.map((m,b)=>{let T=Yt(r[b],r.length-1===b);if(m===T[0])return T[0];if(hr.includes(T[1]))return e.push(T[0]),T[1];return m}),u=S(s);if(this._storage.has(u)){o=this._storage.get(u),o?.args.forEach((m,b)=>{n[m]=e[b]});break}}}return[o,n]}}class it{path="";parsed=[];args=[];constructor(t){ct(this,{path:t,...Q(t)})}}class Pt{date;constructor(t){this.date=t?new Date(t):new Date}delta(t=null,r=!1){let n=Pt.delta(this.date.getTime(),t);return r?new Date(n):n}timed(t){if(!t)return this.date;return[["year","FullYear"],["month","Month"],["day","Date"],["hour","Hours"],["minute","Minutes"],["second","Seconds"]].reduce((n,[o,i])=>{let e=t[o];return e?new Date(n[`set${i}`](n[`get${i}`]()+e)):n},new Date(this.date))}static delta(t,r=null){return r?r-t:t-Date.now()}static local(t){return new Date(t).toLocaleString()}static get now(){return Date.now()}}class Lt{static rand(t=6,r){if(r)return Math.floor(Math.random()*(r-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,r=null){return Array(t).fill(r)}static new({dom:t,id:r,inner:n}){let o=document.createElement(t);if(r)o.id=r;if(n)o.innerHTML=n;return o}static randFrom(t){if(Array.isArray(t)){let r=t.length,n=this.rand(0,r-1);return t[n]}else if(typeof t=="object"){let r=W(t),n=r.length,o=this.rand(0,n-1);return r[o]}}static randArray(t=[],r=1,n=!1){let o=[],i=n?new Set:null;while((n?i.size:o.length)<r){let e=t[Lt.rand(0,t.length-1)];n?i.add(e):o.push(e)}return n?[...i]:o}static randomAZ=rr;static makeID=x;static class(t,...r){let n=r;if(t?.class)n.push(...g(t.class)?t.class:[t.class]);t.class=r}static get O(){return{vals:A,keys:W,items:l,has:or,ass:d,len:(t={})=>W(t).length}}static get is(){return At}static get return(){return ar}static sleep=(t=1000)=>new Promise((r)=>setTimeout(r,t));static get screen(){let{innerWidth:t}=window,r={xs:t<=480,sm:t>=480,smd:t>=624,md:t>=768,lg:t>=1024,xl:t>=1280,xxl:t>=1536},n=l(r).reverse();for(let o=0;o<n.length;o++){let[i,e]=n[o];if(e)return i}return}bytes(t){if(t===0)return"0 Bytes";let r=1024,n=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(t)/Math.log(r));return parseFloat((t/Math.pow(r,o)).toFixed(2))+" "+n[o]}static format(t){return new mr(t)}}class ar{static arr(t){return t?g(t)?t:[t]:[]}static num(t,r=0){let n=parseFloat(t);return isNaN(n)?r:n}static str(t){return String(t)}static arr2obj(t,r=!1){return t.reduce((n,o,i)=>{if(r)n[o]=i;else n[i]=o;return n},{})}}class mr{val;constructor(t){this.val=t}get px(){return`${this.val}px`}get rem(){return`${this.val}rem`}get pr(){return`${this.val}%`}}var Ct={},U={};class gr{stream;url;constructor(t,r){if(this.url=t,t in Ct)this.stream=Ct[t];else this.stream=new EventSource(t,{withCredentials:r}),Ct[t]=this.stream,U[this.url]={}}on(t){let r=this.stream;return l(t).forEach(([n,o])=>{if(n in U[this.url])U[this.url][n].forEach((i)=>{this.stream.removeEventListener(n,i)}),U[this.url][n]=[];if(r.addEventListener(n,o),!(n in U[this.url]))U[this.url][n]=[];U[this.url][n].push(o)}),this}}function lr(t,r=!0){return new gr(t,r)}class cr{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(Z(this.value))return parseInt(this.value);else return null}get float(){if(Z(this.value))return parseFloat(this.value);else return null}get bool(){if(this.value==="true")return!0;else if(this.value=="false")return!1;else return null}get json(){if(this.value)return JSON.parse(this.value);return null}}class z{key;state;storage;constructor(t,r="local",n){if(this.storage=r=="local"?localStorage:sessionStorage,typeof t=="object"){let[o,i]=l(t)[0];if(this.key=o,this.state=i,n){let e=this.as[n];this.state.value=e}N((e)=>{this.set=e},[this.state],{id:this.key})}else this.key=t,this.state=null}get as(){return new cr(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}set set(t){let r=E(t)?S(t):String(t);this.storage.setItem(this.key,r)}get remove(){this.storage.removeItem(this.key);return}}var dr={get:(t)=>new z(t,"local"),init:(t,r)=>new z(t,"local",r)};var pr={get:(t)=>new z(t,"session")};class bt extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Tr extends it{id;cls;constructor(t,r,n){super(t);this.id=r;this.cls=n}}class Zt extends ot{storage=new K;errorStorage=new K;wssStorage=new K;route;error;wss;base;constructor(t=""){super();this.base=t?t.startsWith("/")?t:`/${t}`:"",this.route=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.storage.set(new bt(n,x(5),o)),o}},this.wss=(r)=>{let n=this._base(r);return(o)=>{return o.route=n,this.wssStorage.set(new Tr(n,x(5),o)),o}},this.error=(...r)=>{return(n)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new bt(o.toString(),x(5),n))});else this.errorStorage.set(new bt("404",x(5),n));return n}}}_base(t){return nr(this.base,t)}async getPath(t){return this.storage.get(t)}async loadError(t){return this.errorStorage.get(t.toString())}async loadWSS(t){return this.wssStorage.get(t)}}var et=new a,V=(t)=>{if(p)return;let r=et.get(t);if(r?.isConnected)return r;et.delete(t);let n=document.getElementById(t);if(!n)return;return et.set(t,n),n};function br(){let t=[];return et.forEach((r,n)=>{if(!r.isConnected)t.push(n),et.delete(n)}),t}function N(t,r,{id:n="stateHook",init:o}={}){if(p)return()=>{};let i=[],e=()=>r.map((s)=>s.value),f=()=>{t(...e())};if(r.forEach((s)=>{i.push(s.hook(f)(n))}),o)f();return()=>{i.forEach((s)=>s())}}var yr=(t)=>{t.forEach((r)=>r())};var kr=(t,r)=>{for(let[n,o]of t){let i=V(n);if(!i){t.delete(n);continue}o.forEach((e)=>{e.call(i,r)})}};class j extends EventTarget{options;deep;verify;hooks=new a;states=new a;_value;listening=!1;end;constructor(t,r={},n=!0,o=!0){super();this.options=r;this.deep=n;this.verify=o;this._value=t}get value(){return this._value}set value(t){if(!this.verify){this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(!this.deep){if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}));return}if(H(this._value)||g(this._value)){let r=Ht(this._value,t);if(!er(r))return}else if(this._value instanceof Set){if(!ir(this._value,t))return}else if(this._value===t)return;this._value=t,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let t=(r)=>{if(yr(this.hooks),kr(this.states,r.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",t,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",t,this.options),this.end=void 0,this.listening=!1}}call(t,r){return(n)=>{if(dt(n,this.states).set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(n))this.states.get(n)?.delete(r)}}}hook(t){return(r)=>{if(this.hooks.set(r,t),!p&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(r))this.hooks.delete(r)}}}}function Y(t,r={}){return new j(t,r,!0)}function vr(t,r=!1){return new j(t,{},!1,r)}var _=(t)=>{if(g(t))return t.filter((r)=>r!==void 0).join(" ");else if(E(t)){if(H(t))return S(t)}else if(w(t))return _(t());else if(t!==void 0&&t!==null)return k(t)?t?"":"false":String(t);return""};function tn(t,r){switch(r??t){case"style":return function(n){this.style.setProperty(t,n)};default:return function(n){this.setAttribute(t,n)}}}class Ft{attr;constructor(t={}){this.attr=t}get(t,r=this.attr,n){let o=(i,e)=>{if(g(e))t.attr_push(i,_(e));else if(e instanceof j){let f=n?`${n}_${i}`:i;t.states.push(e.call(tn(i,n),f)),o(i,e.value)}else if(E(e)){if(H(e)&&!n)this.get(t,e,i)}else t.attr_push(i,_(e),n)};l(r).forEach(([i,e])=>{if(i==="ref"){if(e instanceof st)t.events.obj({element(){e.element=this}})}else if(["on"].includes(i))E(r.on)&&t.events.obj(r.on);else o(i,e)})}unload(t){let r=void 0;if(t in this.attr)r=this.attr[t],delete this.attr[t];return r}}class F{xid;IDM;map=new a;states=[];events=new a;OZ;constructor(t,r=new D,n){this.xid=t;this.IDM=r;this.OZ=n??new yt}attr_push(t,r,n){let o=n??t;if(!this.map.has(o))this.map.set(o,[]);let i=n?`${M(t)}:${r};`:r;this.map.get(o).push(i)}get attr(){let t=[""];return this.map.forEach((r,n)=>{let o=r.join("");t.push(o?`${n}="${o}"`:n)}),t.join(" ")}set id(t){if(!this.map.has("id"))this.map.set("id",[t])}get id(){return this.map.get("id")?.join("")}}var rn=(t,r,n)=>{return t.addEventListener(r,n),()=>{t.removeEventListener(r,n)}},ft={};class yt{events=new a;states=new a;winStates=new a;windowEvents=new a;resetST=new a;resetEV=new a;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:r,events:n,states:o}=t;if(r){if(n.size)this.events.set(r,n);if(o.length)this.states.set(r,o)}return this}push(t){return t.events.forEach((r,n)=>{r.forEach((o,i)=>{dt(n,this.events).set(i,o)})}),t.states.forEach((r,n)=>{tt(n,this.states).push(...r)}),this}get stage(){return this.events.forEach((t,r)=>{this.events.delete(r);let n=V(r);if(!n){this.events.delete(r);return}t.forEach((o,i)=>{switch(i){case"ready":case"element":o.apply(n,[n]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let e=i.replace(/^win/,"");this.windowEvents.init(e,new a).set(r,o);break;case"state":let[f,s,u]=o.apply(n,[n]),h=g(s)?s:[s];if(!h.length)break;let m=()=>h.map((T)=>T.value),b=()=>f(...m());if(u)b();h.forEach((T)=>tt(r,this.resetST).push(T.call(b,r+"_state")(r)));break;default:tt(r,this.resetEV).push(rn(n,i,o))}})}),this.processWindowEvents,this.states.forEach((t,r)=>{this.states.delete(r),t.forEach((n)=>{tt(r,this.resetST).push(n(r))})}),this}get processWindowEvents(){let t=(r,n)=>{let o=0,i=!1,e=(s)=>{if(o=window.scrollY,!i)window.requestAnimationFrame(()=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)}),i=!1}),i=!0},f=(s)=>{n.forEach((u,h)=>{let m=V(h);if(m)u.call(m,s);else this.windowEvents.get(r)?.delete(h)})};return window.addEventListener(r,r==="scroll"?e:f),()=>{window.removeEventListener(r,r==="scroll"?e:f)}};return this.windowEvents.forEach((r,n)=>{if(r.size){if(!ft[n])ft[n]=t(n,r)}else if(ft[n])ft[n](),delete ft[n]}),this}reset(t){return t.forEach((r)=>{this.windowEvents.forEach((n,o)=>{if(n.has(r))n.delete(r)}),this.resetEV.get(r)?.forEach((n)=>{n()}),this.resetST.get(r)?.forEach((n)=>{n()}),this.resetST.delete(r),this.resetEV.delete(r)}),this}RPS(t){if(t){let r=br();this.reset(r);let n=t.keys;if(n.length)this.reset(n).push(t).stage}return this}}var P=new yt;var nn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],on=(t)=>nn.includes(t);function en(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var xt=(t,r)=>{if(g(t))return t.map((n)=>xt(n,r)).join("");else if(t instanceof ht){let n=t.__(r.IDM),{ctx:o,oz:i}=n;return r.OZ.push(i),o}else if(E(t))return S(t);else if(w(t))return xt(t(),r);else if(t!==void 0&&t!==null)return en(t);return""},wt=(t,r)=>{let n=new D(r),o=new F(n.id,n);return{ctx:xt(t,o),catt:o}};function sn(t){let r=this.id;if(r){let{ctx:n,catt:o}=wt(t,r);if(this.innerHTML!==n)this.innerHTML=n,P.RPS(o.OZ)}}var ut=(t,r,n,o=[])=>{if(g(t))t.forEach((i)=>{ut(i,t.length,n,o)});else if(t instanceof j)if(r>1)ut(B("div",{},t),r,n,o);else{let i=t.value,e=i instanceof ht?"dom":"ctx",{ctx:f,catt:s}=wt(i,n.xid+"-0");n.xid=s.xid,o.push(f),n.OZ.push(s.OZ),n.states.push(t.call(sn,e))}else o.push(xt(t,n))};class Bt{tag;ctx;closing;constructor(t,r){this.tag=t;this.ctx=r;let n=on(t);this.closing=n?"":`</${t}>`}process(t,r=this.ctx,n=[]){return r.forEach((o)=>{ut(o,r.length,t,n)}),n.join("")}get(t){let r=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${r}${this.closing}`}}class ht{tag;constructor(t,r={},...n){this.tag=t;ct(this,{attr:new Ft(r),ctx:new Bt(t,n)})}__(t=new D){let r=t.mid,n=new F(r,t);return this.attr.get(n),{ctx:this.ctx.get(n),oz:n.OZ.set(n),id:n.id}}}function B(t,r={},...n){if(w(t))return $.i=t,t(r??{},...n);return new ht(t,r??{},n)}var fn=(t,...r)=>r;class Xt{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,r={}){return this.e.animate(t,r)}get slide(){let t=({x:r=0,y:n=0},o={})=>{d(this.opt,o);let i=[[r,n],[0,0]].map(([e,f])=>({transform:`translateX(${e}rem) translateY(${f}rem)`}));return this.e.animate(i,this.opt),this};return{left:(r={})=>{return t({x:-2},r)},right:(r={})=>{return t({x:2},r)},up:(r={})=>{return t({y:2},r)},down:(r={})=>{return t({y:-2},r)}}}fade(t={}){d(this.opt,t);let r=[0,1].map((n)=>({opacity:n}));return this.e.animate(r,this.opt),this}shake(t="Y",r={}){d(this.opt,r);let n=[0,5,-5,5,0].map((o)=>({transform:`translate${t}(${o}px)`}));return this.e.animate(n,this.opt),this}color(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({color:o})):{color:t};return this.e.animate(n,this.opt),this}bg(t=[],r={}){d(this.opt,r);let n=Array.isArray(t)?t.map((o)=>({backgroundColor:o})):{backgroundColor:t};return this.e.animate(n,this.opt),this}bounce(t=1,r={}){d(this.opt,r);let n=[0.5,t,1].map((o)=>({transform:`scale(${o})`}));return this.e.animate(n),this}}class Ut{e;query;constructor(t,r){this.e=t;this.query=r}get a(){return new Xt(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((r)=>r)}return[]}get attr(){let t=this.e;return{has:(r)=>{return t.hasAttribute(r)},get:(r)=>{return t.getAttribute(r)},del:(r)=>{return t.removeAttribute(r),this},set:(r)=>{for(let n in r){let o=r[n];if(r[n]!==void 0)t.setAttribute(n,_(o))}return this}}}get children(){return Array.from(this.e.children).map((t)=>c(t))}get click(){return this.e.click(),this}get delete(){return this.e.remove(),this}get disabled(){return this.e.disabled??!1}get focus(){return this.e.focus(),this}get href(){return this.e?.href??""}get id(){return this.e.id}get inner(){return this.e.innerHTML}get offsetParent(){let t=this.e.offsetParent;if(t)return new L(t);return}get parent(){let t=this.e.parentElement;if(t)return new L(t);return}get hash(){return this.e?.hash??""}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let t=this.e.style,r=this;return{set:(n,o=0)=>{let i=t,e=()=>{l(n).forEach(([f,s])=>{if(f in i){if(i[f]!==s)i[f]=s}else if(s!==null)t.setProperty(f,String(s))})};if(w(o))r.on("transitionend",o);if(St(o))setTimeout(e,o);else e();return r},get:(n)=>{let o=M(String(n));return t.getPropertyValue(o)},del:(...n)=>{n.forEach((o)=>{let i=M(String(o));t.removeProperty(i)})}}}get submit(){let t=this.e;if("submit"in t)return t.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("beforeend",r),P.RPS(n)}set appendfirst(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.insertAdjacentHTML("afterbegin",r),P.RPS(n)}set inner(t){let{ctx:r,oz:n}=qt(t,It(this.id));this.e.innerHTML=r,P.RPS(n)}set disabled(t){let r=this.e;if("disabled"in r)r.disabled=t}set id(t){this.e.id=t}set value(t){let r=this.e;r.value=t}}var qt=(t,r)=>{let{ctx:n,catt:o}=wt(t,r);return{ctx:n,oz:o.OZ}},It=(t)=>t?`${t}-0`:t;class L extends Ut{constructor(t,r){super(t,r)}add(...t){return this.e.classList.add(...t.map((r)=>r.replace(/[^\w-]/,""))),()=>{this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,"")))}}remove(...t){return this.e.classList.remove(...t.map((r)=>r.replace(/[^\w-]/,""))),this}toggle(t,r){let n=typeof t!="string"?t.apply(this):t;return this.e.classList.toggle(n,r)}hasNode(t){return this.e.contains(t)}has(...t){let r=this.e.classList;return t.every((n)=>r.contains(n))}insert(t){return{HTML:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentHTML(t,n)}),this},element:(...r)=>{return r.forEach((n)=>{this.e.insertAdjacentElement(t,n)}),this},text:function(...r){return r.forEach((n)=>{this.e.insertAdjacentText(t,n)}),this}}}is(t){let r=this.e.classList,n=this.e.tagName.toLocaleLowerCase(),o=!0,i=!0;if(t.dom)i=t.dom==n?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{o=o?r.contains(e):!1});else o=o?r.contains(t.class):!1;return o&&i}on(t,r,n=!1){let o=!1;if(t.indexOf("touch")>-1)o=!0;return this.e.addEventListener(t,r,{capture:n,passive:o}),this}remove_on(t,r,n=!1){return this.e.removeEventListener(t,r,n),this}timed(t,r=250){return setTimeout(()=>t(this),r),this}animate(t,r,n){let o={duration:300,easing:"ease",fill:"forwards"};if(w(r))n=r;else d(o,r);let i=this.e.animate(t,o);if(n)i.finished.then(n);return this}}function c(t,r){let n=r?r:document;if(v(t)){let o=n.querySelector(t);if(o)return new L(o,t);return}else if(H(t)){let[[o,i]]=l(t),f=`${o==="id"?"#":"."}${i}`,s=n.querySelector(f);if(s)return new L(s,f);return}else return new L(t)}class st{state=new j(void 0);constructor(){}get element(){return this.state.value?.e}set element(t){if(t)this.state.value=new L(t);else this.state.value=void 0}get $(){return this.state.value}}var un=()=>{return new st};class Jt{lang;head="";constructor(t,r){if(this.lang=t,r)this.head=fr(r)}body(t,r,n){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${r??x(5)}"${n?" "+n:""}>${t}</body>`,"</html>"].join("")}}class $t extends Mt{path;args;id;status;lang;import;_data={};static route="/";constructor(t,r={},n,o=200){super();this.path=t;this.args=r;this.id=n;this.status=o}async loader(){if(this.import)try{let t=await this.import;if(t.default)this.import=await t.default({...this.args,...this.data});else this.import=void 0}catch(t){return $.e=["import",{error:"loader"}],this.import=void 0,[]}if(this.body){let t=await this.body();return g(t)?t:[t]}if(this.import){let t=this.import;return g(t)?t:[t]}return[]}getHeadAttr(t={},...r){let n=new G;if(R(t))n.head=t;n.id=this.id;let o=n.head;return r.forEach((i)=>{o.map(i)}),hn(n,this),o}set data(t){d(this._data,t)}get data(){return this._data}}class Wt extends $t{head(){this.title=`error ${this.status}`}body(){return B("div",{},this.path+" not found...")}}function hn(t,r){let{link:n,script:o,meta:i,title:e,base:f,description:s,css:u}=r;if(t.head={title:e,base:f,meta:i,link:n,script:o},s)t.head={meta:[{name:"description",content:s}]};if(u){let m=(g(u)?u:[u]).map((b)=>({rel:"preload stylesheet",href:b,as:"style"}));t.head={link:[...m]}}}function xr(t){let r=[];if(t?.length){let{href:n,target:o}=t[0],i=c("base");if(i){if(i.attr.get("href")!==n)i.attr.set({href:n,target:o})}else{let e=c(document.createElement("base"));e.attr.set({href:n,target:o}),document.head.append(e.e)}}return r}var wr=new a;async function $r(t,r={},n=!1){let o=at.value,i={};if(c("link")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("href");if(s){let u=f.attr.get("rt");if(n){let h=wr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r&&R(r))for(let e of A(r)){let f=e.href;if(!(f in i))try{let s=void 0;if(!n){if(s=c(`link[href='${f}']`),s)s.attr.set({rt:t});e.rt=t;let u=wr.init(o,new Set);if(!u.has(f))u.add(f)}if(!s)await jt(e)}catch(s){$.e=["link error",{error:"yvee @ link"}]}else delete i[f]}return A(i)}var an=["charset","name","property","http-equiv"];function Er(t){let r={};if(c("meta")?.all.forEach((n)=>{let o=n.attributes;for(let i of an)if(i in o){let e=o[i].value;r[`${i}_${i==="charset"?"":e}`]=n}}),t)l(t).forEach(([n,o])=>{if(n in r)c(r[n]).attr.set(o),delete r[n];else{let i=c(document.createElement("meta"));i.attr.set(o),document.head.append(i.e)}});return A(r).map((n)=>c(n).unload)}var Sr=new a;async function Rr(t,r,n=!1){let o=at.value,i={};if(c("script[yid]")?.all.forEach((e)=>{let f=c(e),s=f.attr.get("yid");if(s){let u=f.attr.get("rt");if(n){let h=Sr.get(o);if(h){if(!h.has(s))i[s]=f.unload}else i[s]=f.unload}else if(u){if(u===t)i[s]=f.unload}}}),r){for(let e of r)if("yid"in e)if(e.yid in i)delete i[e.yid];else try{if(!n){e.rt=t;let f=e.yid,s=Sr.init(o,new Set);if(!s.has(f))s.add(f)}await ur(e)}catch(f){$.e=["script error",{error:"yvee @ script"}]}}return A(i)}async function Ar(t,r){let n=[];if(p)return[];let o=t.get("title")??"",{pushState:i}=this.config;if(i){let e=this.path.value,f=this.lastPath.value;if(f!==e)if(!f.startsWith(e))X(e,o);else if(e===this.base)X(e,o);else X(e,o)}if(o&&(document.title=o),this.isYvee)document.documentElement.lang=r,n.push(...xr(t.get("base"))),n.push(...Er(t.get("meta")));return n.push(...await $r(this.id,t.get("link"),this.isYvee)),n.push(...await Rr(this.id,t.get("script"),this.isYvee)),n}function X(t,r){if(p)return;let{pathname:n,hash:o}=window.location,i=n+o;if(t&&i!==t)history.pushState({},r??"",t)}class Gt{path;args;static route="/";isConnected=Y(!1);data={};constructor(t,r={}){this.path=t;this.args=r;this.data=r}open(t){}message(t){}close(t){}error(t){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(t)=>{this.isConnected.value=!0,await this.open.call(this,t)},this.ws.onmessage=async(t)=>{await this.message.call(this,t)},this.ws.onclose=async(t)=>{this.isConnected.value=!1,await this.close.call(this,t)},this.ws.onerror=async(t)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,t)},this}get reconnect(){if(this.state>=2)this.connect;return this}get disconnect(){if(this.state<=1)this.ws.close();return this}get state(){return this.ws?.readyState??3}set send(t){if(this.isConnected.value)this.ws.send(t);else throw new Error(`websocket path ${this.path} not connected`)}}var O=new a;class Qt{yvee;constructor(t){this.yvee=t}async load(t){if(p)return;if(!O.has(t)){let[n,o]=await this.yvee.loadWSS(t);if(!n)return;let{cls:i,path:e,id:f}=n,s=new i(e,o).connect;return O.set(t,s),s}let r=O.get(t);return r.reconnect,r}unload(t){if(p)return;if(O.has(t)){let r=O.get(t);if(!r)return;r.disconnect,O.delete(t)}}}var Kt=new a;function mn(t,r,n,o){let{on:i,top:e,topRef:f,...s}=t,u={...i??{},click(h){h.preventDefault();let m=c(this),b=m.path;o.value=n.value,n.value=b;let T=m.hash;if(T){let J=c(T),y=window.scrollY;if(J)y+=J.rect.top;if(f)y-=f?.value?.e.offsetHeight||0;if(e)if(typeof e==="number")y-=e;else y-=e();window.scrollTo({top:y,behavior:"smooth"}),X(b+T)}else if(o.value===n.value)window.scrollTo({top:m.rect.top||0,behavior:"smooth"}),X(window.location.pathname)}};return B("a",{...s,on:{...u}},...r)}function gn(t,r,n){let{classes:o}=t.config,{on:i,...e}=r,f={...r.on??{},...n&&{popstate(s){let h=s.target.location.pathname;t.path.value=h}},...{element(s){t.mainElement=this}}};return B("div",{...e,...o&&{class:o},on:f},t.root)}async function ln(t,r){let[n,o]=await this.loadError(r??0);if(n){let{cls:i,id:e}=n;return new i(t,o,e,r)}else{let i=new Wt(t,o,x(5));return i.title=`error ${r}`,i}}function zt(){if(q)return parseInt(c('meta[name="error"]')?.attr.get("content")??"200");return 200}class mt extends Zt{config;hook;root=Y([]);socket;id=x(4);path=Y("");lastPath=Y("");loading=Y(!1);mainElement;A;Main;load;matchPath;isYvee=!1;constructor(t={},r={}){super(t.base??"");this.config=t;if(this.socket=new Qt(this),t.id)this.id=t.id;this.A=(n,...o)=>{if(this.base){if(!n.href.startsWith(this.base))n.href=this._base(n.href)}return mn(n,o,this.path,this.lastPath)},this.Main=(n)=>{if(R(r))if(!n.on)n.on=r;else d(n.on,r);return gn(this,n,this.isYvee)},this.load=async(n,o={})=>{if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Pager loader"}]}}return this},this.matchPath=(n)=>{let o=this._base(n),i=this.path.value,e=this.base;if(i===o)return!0;else{let f=i.replace(e,""),s=o.replace(e,"");if(s){if(f.startsWith(s))return!0}else if(!i)return!0}return!1}}hooker(){let t={},r={},n=this.path.value;if(this.hook)this.hook();this.hook=N(async(o)=>{if(r[n]=window.scrollY,t[n]=this.mainElement?.scrollTop??0,(await this.render(o,404)).done){let i=r[o]??0;if(i)window.scrollTo({top:i,behavior:"instant"});let e=t[o]??0;if(e)this.mainElement?.scrollTo({top:e,behavior:"instant"});n=o}},[this.path],{id:"router"})}async class(t,r,n=!1){let[o,i]=await this.getPath(t);if(o&&!n){let{cls:e,id:f}=o;return new e(t,i,f)}else return await ln.call(this,t,404)}async fetch(t){if(t)try{if(t.fetch){let r=await t.fetch();if(H(r)&&R(r))t.data=r}}catch(r){$.e=["class fetch",{error:"fetch"}]}}async processHead(t,r={}){return t?await this.processClassHead(t,r):await this.processDefaultHead(r)}async processClassHead(t,r){if(t.head)await t.head();return t.getHeadAttr(r,this.htmlHead)}async processDefaultHead(t){let r=new G;if(R(t))r.head=t;return r.head.map(this.htmlHead),r.head}async render(t,r=404,n={},o={},i=!0,e=!1){let f=await this.class(t,r??zt(),e);f.data=n,await this.fetch(f);let s=await this.processHead(f,o);if(p)Kt.set(this.id,s);if(!f)return{lang:this.lang,heads:s,done:!1};let u=[];if(this.loading.value=!0,this.isYvee)u=await f.loader();let h=[];if(i)h=await Ar.call(this,s,f?.lang||this.lang);if(!this.isYvee)u=await f.loader(),h.forEach((m)=>m());if(this.isYvee)h.forEach((m)=>m());if(u.length)this.root.value=u;else await this.render(t,r,n,o,i,!0);return this.loading.value=!1,{heads:s,lang:f.lang??this.lang,done:!0}}}var at=Y("");class Et extends mt{config;isYvee=!0;unload=!0;constructor(t={},r={}){super(t,r);this.config=t;this.path=at,this.load=async(n,o={})=>{if(q)n=dn()||this._base(n??"/");if(this.hook)this.hook();if(n){this.path.value=n,this.lastPath.value=n;try{await this.render(n,404,o),this.hooker()}catch(i){$.e=["render error",{error:"Yvee loader"}]}}return this}}}var cn=(t)=>{return(r)=>{t(r)}};function dn(){if(q)return c('meta[name="yvee"]')?.attr.get("content")??"/";return""}var Dr=(t,r,n,o=!1)=>{let i=[];if(i.push({charset:"utf-8"}),i.push({name:"viewport",content:"width=device-width, initial-scale=1.0"}),n)switch(n){case 404:i.push({name:"error",content:n.toString()});break;default:break}if(o)i.push({name:"yvee",content:r});if(t.meta)if(g(t.meta))t.meta.unshift(...i);else t.meta.push(i);else t.meta=i},Hr=async(t,r,n={},o=[])=>{let i=await r(n),e=g(i)?i:[i],f=new F(t,new D(t));return e.forEach((s)=>{ut(s,e.length,f,o)}),f.OZ.set(f),f.OZ};async function pn(t,r,n={}){let{bodyattr:o={},id:i,route:e,base:f="",index:s,data:u}=n;if(q){let h={},m=window.location.pathname,b=document.body.id;if(r)if(r instanceof Et)await r.load();else{if(u)if(w(u))h=await u();else h=u;if(e){if(e.length>1&&e.slice(-1)!=="/")m=m.replace(/^\/|\/$/g,"");d(h,Tt(m,e))}d(h,{path:m,status:zt()})}let T=await Hr(b,t,h);P.push(T),requestAnimationFrame(()=>{P.stage})}return async({path:h,data:m={},status:b=200})=>{let T=x(4),J=new a,y={};if(i)T=i;if(o.id)T=o.id.toString();let Nt="en";if(r instanceof Et){let{base:C,path:gt,id:Mr,lang:jr}=r;if(y.base=[{href:C==="/"?C:`${C}/`,target:"_blank"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];gt.value=h,Dr(y,h,b,!0);let{heads:_t}=await r.render(h,b,m,y,!1);Kt.values().forEach((Yr)=>{d(_t.init("link",{}),Yr.get("link")??{})}),T=Mr,J=_t,Nt=jr}else{let C=h==="/"?h:`${h}/`;if(s)C=`${s}/`;if(f)C=`${f}${C}`;if(y.base=[{href:C,target:"_self"}],y.script)y.script.push({type:"module",src:"./index.js"});else y.script=[{type:"module",src:"./index.js"}];if(e)d(m,Tt(h,e));d(m,{status:b,path:h,base:f}),d(y,w(r)?await r(m):r),Dr(y,h,b);let gt=new ot;gt.head(y),J=gt.htmlHead}let Vt=[];return await Hr(T,t,m,Vt),new Jt(Nt,J).body(Vt.join(""),T,nt(o))}}var Us=(t,r)=>{return`${t.replace(/\/+$/,"")}/${r.replace(/^\.\/+/,"")}`},Js=(t)=>{if(p)return;return t()};export{Gt as websocket,un as useRef,pr as session,Us as resolvePath,X as pushHistory,$ as log,dr as local,fn as frag,lr as eventStream,B as dom,$t as doc,jt as cssLoader,Or as addCSS,Lt as __,Et as Yvee,Pt as Time,j as Stateful,N as StateHook,Y as State,cn as Routes,pn as Render,st as Ref,vr as QState,mt as Pager,rt as Meta,Js as IfClient,c as $};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yvee",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Yvee JS framework",
5
5
  "author": "Marky <markjotep@gmail.com>",
6
6
  "license": "MIT",
@@ -27,8 +27,8 @@
27
27
  "homepage": "https://github.com/MARKjotep/yvee#readme",
28
28
  "dependencies": {},
29
29
  "devDependencies": {
30
- "rollup": "^4.34.8",
31
- "rollup-plugin-dts": "^6.1.1"
30
+ "rollup": "^4.46.2",
31
+ "rollup-plugin-dts": "^6.2.1"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "typescript": "^5.7.3"