yvee 0.0.4 → 0.0.5
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 +38 -38
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -143,7 +143,7 @@ type CSSinT$1 = {
|
|
|
143
143
|
type headType = Mapper<keyof head, any>;
|
|
144
144
|
declare class htmlHead {
|
|
145
145
|
lang: string;
|
|
146
|
-
htmlHead: headType;
|
|
146
|
+
protected htmlHead: headType;
|
|
147
147
|
head: (heads?: headAttr) => void;
|
|
148
148
|
constructor();
|
|
149
149
|
}
|
|
@@ -237,15 +237,6 @@ declare class OZ {
|
|
|
237
237
|
RPS(oz?: this): this;
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
declare class CTX {
|
|
241
|
-
tag: string;
|
|
242
|
-
ctx: ctx[];
|
|
243
|
-
closing: string;
|
|
244
|
-
constructor(tag: string, ctx: ctx[]);
|
|
245
|
-
private process;
|
|
246
|
-
get(catt: CATT): string;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
240
|
declare class eStream {
|
|
250
241
|
stream: EventSource;
|
|
251
242
|
url: string;
|
|
@@ -344,36 +335,41 @@ interface yveeCfg {
|
|
|
344
335
|
}
|
|
345
336
|
declare class Router extends minClient {
|
|
346
337
|
private isYRA;
|
|
347
|
-
|
|
338
|
+
protected unload: boolean;
|
|
339
|
+
protected hook?: () => void;
|
|
340
|
+
protected root: Stateful<ctx[]>;
|
|
341
|
+
protected socket: socket;
|
|
348
342
|
id: string;
|
|
349
|
-
root: Stateful<ctx[]>;
|
|
350
343
|
path: Stateful<string>;
|
|
351
|
-
socket: socket;
|
|
352
|
-
element: Stateful<HTMLElement | null>;
|
|
353
344
|
A: (a: attr & {
|
|
354
345
|
href: string;
|
|
355
346
|
}, ...D: ctx[]) => Dom;
|
|
356
|
-
Main: (a: attr
|
|
347
|
+
Main: (a: attr & {
|
|
348
|
+
load?: string;
|
|
349
|
+
}) => Dom;
|
|
357
350
|
load: (path?: string, data?: obj<string>) => Promise<this>;
|
|
358
351
|
constructor(ImportMeta: ImportMeta, config?: yveeCfg, isYRA?: boolean);
|
|
359
|
-
hooker(): void;
|
|
360
|
-
class(this: Router, _path: string, _error: number, isError?: boolean): Promise<doc<{}>>;
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}>;
|
|
364
|
-
fetch(CL?: doc<{}>): Promise<void>;
|
|
365
|
-
}
|
|
366
|
-
declare class Yvee extends Router {
|
|
367
|
-
constructor(ImportMeta: ImportMeta, { classes, pushState }?: yveeCfg);
|
|
368
|
-
processHead(CL?: doc<{}>, head?: headAttr): Promise<headType>;
|
|
352
|
+
protected hooker(): void;
|
|
353
|
+
protected class(this: Router, _path: string, _error: number, isError?: boolean): Promise<doc<{}>>;
|
|
354
|
+
protected fetch(CL?: doc<{}>): Promise<void>;
|
|
355
|
+
protected processHead(CL?: doc<{}>, head?: headAttr): Promise<headType>;
|
|
369
356
|
private processClassHead;
|
|
370
357
|
private processDefaultHead;
|
|
371
|
-
render(_path
|
|
358
|
+
protected render(_path: string, _error?: number, data?: obj<string>, head?: headAttr, isClient?: boolean, isError?: boolean): Promise<{
|
|
372
359
|
lang: string;
|
|
373
360
|
heads: headType;
|
|
374
361
|
done: boolean;
|
|
375
362
|
}>;
|
|
376
|
-
|
|
363
|
+
}
|
|
364
|
+
declare class Yvee extends Router {
|
|
365
|
+
protected unload: boolean;
|
|
366
|
+
constructor(ImportMeta: ImportMeta, { classes, pushState }?: yveeCfg);
|
|
367
|
+
html({ path, data, status, attr, }: {
|
|
368
|
+
path: string;
|
|
369
|
+
data?: Record<string, string>;
|
|
370
|
+
status?: number;
|
|
371
|
+
attr?: string;
|
|
372
|
+
}): Promise<string>;
|
|
377
373
|
}
|
|
378
374
|
|
|
379
375
|
declare class ClientPath extends MinStorage {
|
|
@@ -387,11 +383,11 @@ declare class SocketPath extends MinStorage {
|
|
|
387
383
|
constructor(path: string, id: string, cls: typeof websocket<{}>);
|
|
388
384
|
}
|
|
389
385
|
declare class minClient extends htmlHead {
|
|
390
|
-
ImportMeta: ImportMeta;
|
|
391
|
-
config: yveeCfg;
|
|
392
|
-
storage: Storage$1<ClientPath>;
|
|
393
|
-
errorStorage: Storage$1<ClientPath>;
|
|
394
|
-
wssStorage: Storage$1<SocketPath>;
|
|
386
|
+
protected ImportMeta: ImportMeta;
|
|
387
|
+
protected config: yveeCfg;
|
|
388
|
+
protected storage: Storage$1<ClientPath>;
|
|
389
|
+
protected errorStorage: Storage$1<ClientPath>;
|
|
390
|
+
protected wssStorage: Storage$1<SocketPath>;
|
|
395
391
|
/** --------------------
|
|
396
392
|
* string | int | float | file | uuid
|
|
397
393
|
* - /url/\<string:hell>
|
|
@@ -400,9 +396,9 @@ declare class minClient extends htmlHead {
|
|
|
400
396
|
error: (...codes: number[]) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
401
397
|
wss: (path: string) => <Q extends typeof websocket<{}>>(f: Q) => Q;
|
|
402
398
|
constructor(ImportMeta: ImportMeta, config: yveeCfg);
|
|
403
|
-
getPath(path: string): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
404
|
-
loadError(code: number): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
405
|
-
loadWSS(path: string): Promise<[SocketPath | undefined, Record<string, string>]>;
|
|
399
|
+
protected getPath(path: string): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
400
|
+
protected loadError(code: number): Promise<[ClientPath | undefined, Record<string, string>]>;
|
|
401
|
+
protected loadWSS(path: string): Promise<[SocketPath | undefined, Record<string, string>]>;
|
|
406
402
|
}
|
|
407
403
|
|
|
408
404
|
type Elements = HTMLElementTagNameMap[keyof HTMLElementTagNameMap];
|
|
@@ -436,7 +432,6 @@ declare class Stateful<T> extends EventTarget {
|
|
|
436
432
|
declare function State<T>(value: T): Stateful<T>;
|
|
437
433
|
|
|
438
434
|
type X2 = V | V[];
|
|
439
|
-
type ctx = V | Dom | Stateful<V | Dom> | ctx[];
|
|
440
435
|
type X3 = X2 | Stateful<X2>;
|
|
441
436
|
type CSSinT = {
|
|
442
437
|
[P in keyof CSSStyleDeclaration]?: X3;
|
|
@@ -463,7 +458,7 @@ interface baseAttr {
|
|
|
463
458
|
declare class Dom {
|
|
464
459
|
tag: string;
|
|
465
460
|
private attr;
|
|
466
|
-
ctx
|
|
461
|
+
private ctx;
|
|
467
462
|
constructor(tag: string, attr?: attr, ...ctx: ctx[]);
|
|
468
463
|
__(pid?: idm): {
|
|
469
464
|
ctx: string;
|
|
@@ -583,6 +578,7 @@ declare global {
|
|
|
583
578
|
[P in keyof GlobalEventHandlersEventMap]?: (this: Elements, e: GlobalEventHandlersEventMap[P]) => void;
|
|
584
579
|
} & c_events;
|
|
585
580
|
type attr = baseAttr | obj<X3>;
|
|
581
|
+
type ctx = V | Dom | Stateful<V | Dom> | ctx[];
|
|
586
582
|
type obj<T> = Record<string, T>;
|
|
587
583
|
type DomFN<T extends {}> = (a: attr & T, ...D: ctx[]) => Dom;
|
|
588
584
|
namespace JSX {
|
|
@@ -755,5 +751,9 @@ declare global {
|
|
|
755
751
|
}
|
|
756
752
|
}
|
|
757
753
|
declare const resolvePath: (base: string, relative: string) => string;
|
|
754
|
+
type RouteType = (path: string) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
755
|
+
declare const Routes: (fn: (route: RouteType) => void) => (route: RouteType) => void;
|
|
756
|
+
type ErrorType = (...codes: number[]) => <Q extends typeof doc<{}>>(f: Q) => Q;
|
|
757
|
+
declare const Errors: (fn: (error: ErrorType) => void) => (error: ErrorType) => void;
|
|
758
758
|
|
|
759
|
-
export { $, $$, ColorScheme, Dom, Meta, Router, State, Stateful, Yvee, type _$, __, addCSS, cssLoader,
|
|
759
|
+
export { $, $$, ColorScheme, Dom, Errors, Meta, Router, Routes, State, Stateful, Yvee, type _$, __, addCSS, cssLoader, doc, dom, eventStream, frag, type headAttr, local, minClient, resolvePath, session, stateHook, websocket };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Sn=function(n,t,r,i){var o=arguments.length,s=o<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,r):i,e;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")s=Reflect.decorate(n,t,r,i);else for(var f=n.length-1;f>=0;f--)if(e=n[f])s=(o<3?e(s):o>3?e(t,r,s):e(t,r))||s;return o>3&&s&&Object.defineProperty(t,r,s),s};var Mn=(n,t)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(n,t)};var $=(n)=>typeof n==="function";var U=(n)=>{return!isNaN(parseFloat(n))&&isFinite(n)},ln=(n)=>{return typeof n==="object"&&n!==null&&!Array.isArray(n)},a=(n)=>{return typeof n==="object"&&n!==null&&Object.getPrototypeOf(n)===Object.prototype};var k=(n)=>typeof n==="boolean",v=(n)=>typeof n==="string",l=(n)=>Array.isArray(n),F=(n)=>typeof n==="object",Gn=(n)=>typeof n==="number",N=(n)=>n===null,An=(n)=>typeof n==="undefined",Kn=(n)=>{return Number.isInteger(Number(n))},Tn=typeof window!=="undefined",b=typeof window==="undefined";function nn(n,t){m(t).forEach(([r,i])=>{In(n,r,{value:i,writable:!1,configurable:!1,enumerable:!0})})}class A{static set p(n){if(Array.isArray(n))console.log(...n);else console.log(n)}}class c{_c=0;_id="";constructor(n){if(this._c=0,this._id=n??x(5),n?.includes("-")){let[t,r]=[n.split("-").slice(0,-1).join("-"),n.split("-").slice(-1)[0]];this._id=t,this._c=U(r)?parseInt(r):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var _t=new RegExp(/(\d+)(\d*)/,"m"),lt=(n)=>Array.from({length:n},(t,r)=>r),Tt="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ht="abcdefghijklmnopqrstuvwxyz",bt=lt(10).join("");var j=(n)=>JSON.stringify(n),wn=(n)=>{return JSON.parse(n)},B=(n)=>{if(n.startsWith("webkit"))n="-"+n;return n.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},x=(n)=>{let t=Tt+ht;return Array.from({length:n},(r,i)=>t+(i?bt:"")).reduce((r,i)=>{return r+=i.charAt(Math.floor(Math.random()*i.length))},"")};class u extends Map{obj(n){n&&m(n).forEach(([t,r])=>this.set(t,r))}map(n){n.forEach((t,r)=>{if(t instanceof u)this.set(r,t);else if(l(t)){if(this.lacks(r))this.set(r,[]);this.get(r).push(...t)}else if(F(t))this.ass(r,t);else this.set(r,t)})}ass(n,t){if(!this.has(n))this.set(n,{});y(this.get(n),t)}lacks(n){return!this.has(n)}init(n,t){return this.has(n)?this.get(n):this.set(n,t).get(n)}}var{values:E,keys:K,entries:m}=Object;var{hasOwn:Wn,freeze:Pn,defineProperty:In,assign:y}=Object,q=(n)=>{return Object.keys(n).length},tn=(n,t)=>{if(!t.has(n))t.set(n,new u);return t.get(n)},R=(n,t)=>{if(!t.has(n))t.set(n,[]);return t.get(n)},hn=(n,t)=>{let r={added:{},removed:{},modified:{}},i=K(n),o=K(t);for(let s of o){let e=n[s],f=t[s];if(!(s in n))r.added[s]=f;else if(l(e)&&l(f)){if(j(e)!==j(f))r.modified[s]={old:e,new:f}}else if(F(e)&&F(f)&&!N(e)&&!N(f)){let g=hn(e,f);if(q(g.added)||q(g.removed)||q(g.modified))r.modified[s]={old:e,new:f}}else if(e!==f)r.modified[s]={old:e,new:f}}for(let s of i)if(!(s in t))r.removed[s]=n[s];return r};function zn(n,t){if(n.size!==t.size)return!1;for(let r of n)if(!t.has(r))return!1;return!0}var Nn=(n)=>{return E(n).some((t)=>{return q(t)})};function Rn(n){let t;return class extends n{constructor(...r){if(t)return t;super(...r);Pn(this),t=this}}}var D=(n,t)=>{return{name:n,content:t}},ct=(n,t)=>{return{property:n,content:t}},xt=(n,t)=>{return{"http-equiv":n,content:t}};class rn{metas=[];constructor(n){n&&this.metas.push(D("description",n))}author(n){return this.meta=D("author",n),this}charset(n){return this.meta={charset:n},this}keywords(...n){return this.meta=D("keywords",n.join(", ")),this}viewport(n){let t=m(n).map(([r,i])=>[B(r),String(i)].join("="));return this.meta=D("viewport",t.join(", ")),this}httpEquiv(n){return m(n).forEach(([t,r])=>{this.meta=xt(B(t),String(r))}),this}robots(...n){return this.meta=D("robots",n.join(", ")),this}themeColor(n){return this.meta=D("theme-color",n),this}openGraph(n){return m(n).forEach(([t,r])=>{this.meta=ct("og:"+t,String(r))}),this}twitter(n){return m(n).forEach(([t,r])=>{this.meta=D("twitter:"+t,String(r))}),this}and(n){return this}set meta(n){this.metas.push(n)}}class bn{title;description;base;meta;link;script;css}var yt=["charset","name","property","http-equiv"],dn=(n,t)=>{t.forEach((r)=>{for(let i of yt)if(i in r){let o=r[i];n[`${i}_${i==="charset"?"":o}`]=r}})},pt=(n,t)=>{t.forEach((r)=>{if("href"in r){let i=r.href;n[`${i}`]=r}})};class I{_head;idm;constructor(n){this._head=new u(n)}set head(n){m(n).forEach(([t,r])=>{if(t==="title"||t==="base"){if(r!==void 0)this._head.set(t,r);return}if(r instanceof rn)return dn(this._head.init("meta",{}),r.metas);if(!l(r))return;switch(t){case"meta":return dn(this._head.init("meta",{}),r);case"link":return pt(this._head.init("link",{}),r);case"script":if(r.length){this._head.init(t,[]);let i=r.map((o)=>{if(!o.yid&&this.idm)o.yid="sc"+this.idm.mid;return o});this._head.get(t).push(...i)}return}})}get head(){return this._head}set id(n){this.idm=new c(n)}}var Ln=(n)=>{return m(n).reduce((t,[r,i])=>{return t.push(k(i)&&i?r:`${r}="${i}"`),t},[""]).join(" ")},Vn=(n)=>{if(!n)return"";return[...n].reduce((t,[r,i])=>{if(r==="meta"||r==="link")i=E(i);if(v(i))return t.push(`<${r}>${i}</${r}>`),t;if(!l(i))return t;let o=i.map((s)=>{if(r==="script"){let e={...s};if("yid"in e)return"";let f="";if("importmap"in e)e.type="importmap",f=JSON.stringify(e.importmap),delete e.importmap;else if("body"in e)f=e.body,delete e.body;return`<${r}${Ln(e)}>${f}</${r}>`}return`<${r}${Ln(s)}>`});return t.push(...o),t},[]).join("")};class cn{lang="en";htmlHead=new u;head;constructor(){this.head=(n={})=>{let t=new I(this.htmlHead);t.head=n,this.htmlHead=t.head}}}var xn=(n)=>{if(b)return;return new Promise((t,r)=>{let i=document.createElement("link");if(n.rel!=="stylesheet")n.rel="stylesheet",n.as="style";m(n).forEach(([o,s])=>{i.setAttribute(o,s)}),i.onload=()=>t(i),i.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(i)})},Et=()=>{let t=document.querySelector("#d-css")?.sheet;if(t)return t;let r=document.createElement("style");return r.id="d-css",document.head.appendChild(r),r.sheet},$t=(n,t)=>{for(let r=0;r<n.cssRules.length;r++)if(n.cssRules[r].selectorText===t)return!0;return!1},jt=(n)=>Object.entries(n).map(([t,r])=>`${B(t)}: ${r};`).join(" ");function qt(n,t={}){if(b)return;let r=Et();if(!r)return;if(!$t(r,n))r.insertRule(`${n} { ${jt(t)} }`,r.cssRules.length)}var On=(n,t)=>{let r=t;if(n?.class)r.push(...l(n.class)?n.class:[n.class]);return delete n.class,r.filter((i)=>i)};var Cn=(n,t=!1)=>{if(U(n))return[+n,Kn(n)?"int":"float"];if(t&&/\.\w+$/.test(n))return[n,"file"];if(n==="/")return[n,"-"];if(n.length===36&&n.match(/\-/g)?.length===4)return[n,"uuid"];return[n,"string"]},on=(n)=>{let t=n.startsWith("/")?n:"/"+n,r=t.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[i,o]=r.reduce(([s,e],f)=>{if(f.includes("<")){let g=f.match(/(?<=<)[^/].*?(?=>|$)/g);if(g?.length){let[h,p]=g[0].split(":");if(h&&p)s.push(h),e.push(p)}}else s.push(f===">"?"/":f);return[s,e]},[[],[]]);if(t.endsWith("/")&&t.length>1)i.push("/");return{parsed:i,args:o}};class sn{storage=new u;cache(n,t){if(this.storage.lacks(n))this.storage.set(n,t());return this.storage.get(n)}}var Ft=["int","float","file","uuid","string"],Ht=new sn;class w{_storage=new u;set(n){let{parsed:t,path:r}=n,i=j(t);if(!this._storage.get(i))this._storage.set(i,n);else throw`path: ${r} already used.`}get(n){let{parsed:t}=Ht.cache(n,()=>on(n)),r={},i=this._storage.get(j(t));if(!i&&n!=="/")for(let o of this._storage.keys()){let s=[],e=wn(o);if(t.length===e.length){let f=e.map((p,H)=>{let Z=Cn(t[H],t.length-1===H);if(p===Z[0])return Z[0];if(Ft.includes(Z[1]))return s.push(Z[0]),Z[1];return p}),g=j(f);if(this._storage.has(g)){i=this._storage.get(g),i?.args.forEach((p,H)=>{r[p]=s[H]});break}}}return[i,r]}}class d{path="";parsed=[];args=[];constructor(n){nn(this,{path:n,...on(n)})}}class _n{static rand(n=6,t){if(t)return Math.floor(Math.random()*(t-n+1)+n);return Math.floor(Math.random()*n)+1-1}static fill(n,t=null){return Array(n).fill(t)}static new({dom:n,id:t,inner:r}){let i=document.createElement(n);if(t)i.id=t;if(r)i.innerHTML=r;return i}static randFrom(n){if(Array.isArray(n)){let t=n.length,r=this.rand(0,t-1);return n[r]}else if(typeof n=="object"){let t=K(n),r=t.length,i=this.rand(0,r-1);return t[i]}}static makeID=x;static reClass=On;static get O(){return{vals:E,keys:K,items:m,has:Wn,ass:y,len:(n={})=>K(n).length}}}var yn={},S={};class an{stream;url;constructor(n,t){if(this.url=n,n in yn)this.stream=yn[n];else this.stream=new EventSource(n,{withCredentials:t}),yn[n]=this.stream,S[this.url]={}}on(n){let t=this.stream;return m(n).forEach(([r,i])=>{if(r in S[this.url])S[this.url][r].forEach((o)=>{this.stream.removeEventListener(r,o)}),S[this.url][r]=[];if(t.addEventListener(r,i),!(r in S[this.url]))S[this.url][r]=[];S[this.url][r].push(i)}),this}}function kn(n,t=!0){return new an(n,t)}class vn{value;constructor(n){this.value=n}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(U(this.value))return parseInt(this.value);else return null}get float(){if(U(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 L{key;func;storage;constructor(n,t="local"){if(typeof n=="object"){let[r,i]=m(n)[0];this.key=r,this.func=i}else this.key=n,this.func=null;this.storage=t=="local"?localStorage:sessionStorage}get as(){return new vn(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}get save(){if(this.func)this.set=this.func();return}set set(n){if(typeof n=="object")this.storage.setItem(this.key,JSON.stringify(n));else this.storage.setItem(this.key,String(n))}get remove(){this.storage.removeItem(this.key);return}}var V={get:(n)=>new L(n)};var nt={get:(n)=>new L(n,"session")};class en extends d{id;cls;constructor(n,t,r){super(n);this.id=t;this.cls=r}}class tt extends d{id;cls;constructor(n,t,r){super(n);this.id=t;this.cls=r}}class fn extends cn{ImportMeta;config;storage=new w;errorStorage=new w;wssStorage=new w;route;error;wss;constructor(n,t){super();this.ImportMeta=n;this.config=t;this.route=(r)=>{return(i)=>{return this.storage.set(new en(r,x(5),i)),i}},this.wss=(r)=>{return(i)=>{return this.wssStorage.set(new tt(r,x(5),i)),i}},this.error=(...r)=>{return(i)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new en(o.toString(),x(5),i))});else this.errorStorage.set(new en("404",x(5),i));return i}}}async getPath(n){return this.storage.get(n)}async loadError(n){return this.errorStorage.get(n.toString())}async loadWSS(n){return this.wssStorage.get(n)}}var O=new u,C=(n)=>{if(b)return;let t=O.get(n);if(t?.isConnected)return t;O.delete(n);let r=document.getElementById(n);if(!r)return;return O.set(n,r),r};function rt(){let n=[];return O.forEach((t,r)=>{if(!t.isConnected)n.push(r),O.delete(r)}),n}function W(n,t,{id:r="state",init:i}={}){let o=[],s=()=>t.map((f)=>f.value),e=()=>{n(...s())};if(t.forEach((f)=>{o.push(f.hook(e)(r))}),i)e();return()=>{o.forEach((f)=>f())}}var it=(n)=>{n.forEach((t)=>t())};var Zt=(n,t)=>{for(let[r,i]of n){let o=C(r);if(!o){n.delete(r);continue}i.forEach((s)=>{s.call(o,t)})}};class M extends EventTarget{options;hooks=new u;states=new u;_value;listening=!1;end;constructor(n,t){super();this.options=t;this._value=n}get value(){return this._value}set value(n){if(N(n)||An(n))return;if(a(this._value)||l(this._value)){let t=hn(this._value,n);if(!Nn(t))return}else if(this._value instanceof Set){if(!zn(this._value,n))return}else if(this._value===n)return;this._value=n,this.dispatchEvent(new CustomEvent("updated",{detail:this._value}))}get listen(){let n=(t)=>{if(it(this.hooks),Zt(this.states,t.detail),!this.states.size&&!this.hooks.size)this.end?.()};if(!this.listening)this.addEventListener("updated",n,this.options),this.listening=!0;return()=>{this.listening&&this.removeEventListener("updated",n,this.options),this.end=void 0,this.listening=!1}}call(n,t){return(r)=>{if(tn(r,this.states).set(t,n),!b&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(r))this.states.get(r)?.delete(t)}}}hook(n){return(t)=>{if(this.hooks.set(t,n),!b&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(t))this.hooks.delete(t)}}}}function J(n){return new M(n)}var pn=(n)=>{if(l(n))return n.join(" ");else if(F(n)){if(ln(n))return j(n)}else if($(n))return pn(n());else if(n!==void 0&&n!==null)return k(n)?n?"":"false":String(n);return""};function Jt(n,t){switch(t??n){case"style":return function(r){this.style.setProperty(n,r)};default:return function(r){this.setAttribute(n,r)}}}class En{attr;constructor(n={}){this.attr=n}get(n,t=this.attr,r){let i=(o,s)=>{if(l(s))n.attr_push(o,pn(s));else if(s instanceof M){let e=r?`${r}_${o}`:o;n.states.push(s.call(Jt(o,r),e)),i(o,s.value)}else if(F(s)){if(ln(s)&&!r)this.get(n,s,o)}else n.attr_push(o,pn(s),r)};m(t).forEach(([o,s])=>{if(["on"].includes(o))F(t.on)&&n.events.obj(t.on);else i(o,s)})}}class P{xid;IDM;map=new u;states=[];events=new u;OZ;constructor(n,t=new c,r){this.xid=n;this.IDM=t;this.OZ=r??new un}attr_push(n,t,r){let i=r??n;if(!this.map.has(i))this.map.set(i,[]);let o=r?`${B(n)}:${t};`:t;this.map.get(i).push(o)}get attr(){let n=[""];return this.map.forEach((t,r)=>{let i=t.join("");n.push(i?`${r}="${i}"`:r)}),n.join(" ")}set id(n){if(!this.map.has("id"))this.map.set("id",[n])}get id(){return this.map.get("id")?.join("")}}var Xt=(n,t,r)=>{return n.addEventListener(t,r),()=>{n.removeEventListener(t,r)}},_={};class un{events=new u;states=new u;winStates=new u;windowEvents=new u;resetST=new u;resetEV=new u;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(n){let{id:t,events:r,states:i}=n;if(t){if(r.size)this.events.set(t,r);if(i.length)this.states.set(t,i)}return this}push(n){return n.events.forEach((t,r)=>{t.forEach((i,o)=>{tn(r,this.events).set(o,i)})}),n.states.forEach((t,r)=>{R(r,this.states).push(...t)}),this}get stage(){return this.events.forEach((n,t)=>{this.events.delete(t);let r=C(t);if(!r){this.events.delete(t);return}n.forEach((i,o)=>{switch(o){case"ready":i.apply(r,[r]);break;case"resize":case"beforeunload":case"popstate":case"winscroll":case"winload":case"winfocus":case"winblur":let s=o.replace(/^win/,"");this.windowEvents.init(s,new u).set(t,i);break;case"watch":let[e,f,g]=i.apply(r,[r]),h=l(f)?f:[f],p=()=>h.map((Z)=>Z.value),H=()=>e(...p());if(g)H();h.forEach((Z)=>R(t,this.resetST).push(Z.call(H,t+"_watch")(t)));break;default:R(t,this.resetEV).push(Xt(r,o,i))}})}),this.processWindowEvents,this.states.forEach((n,t)=>{this.states.delete(t),n.forEach((r)=>{R(t,this.resetST).push(r(t))})}),this}get processWindowEvents(){let n=(t,r)=>{let i=(o)=>{r.forEach((s,e)=>{let f=C(e);if(f)s.call(f,o);else this.windowEvents.get(t)?.delete(e)})};return window.addEventListener(t,i),()=>{window.removeEventListener(t,i)}};return this.windowEvents.forEach((t,r)=>{if(t.size){if(!_[r])_[r]=n(r,t)}else if(_[r])_[r](),delete _[r]}),this}reset(n){return n.forEach((t)=>{this.windowEvents.forEach((r,i)=>{if(r.has(t))r.delete(t)}),this.resetEV.get(t)?.forEach((r)=>{r()}),this.resetST.get(t)?.forEach((r)=>{r()}),this.resetST.delete(t),this.resetEV.delete(t)}),this}RPS(n){if(n){let t=rt();this.reset(t);let r=n.keys;if(r.length)this.reset(r).push(n).stage}return this}}var X=new un;var Qt=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Yt=(n)=>Qt.includes(n);function Ut(n){return String(n).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var mn=(n,t)=>{if(l(n))return n.map((r)=>mn(r,t)).join("");else if(n instanceof Q){let r=n.__(t.IDM),{ctx:i,oz:o}=r;return t.OZ.push(o),i}else if(F(n))return j(n);else if($(n))return mn(n(),t);else if(n!==void 0&&n!==null)return Ut(n);return""},ot=(n,t)=>{let r=new c(n),i=new P(r.id,r);return{ctx:mn(t,i),catt:i}};function Bt(n){let t=this.id;if(t){let{ctx:r,catt:i}=ot(t,n);if(this.innerHTML!==r)this.innerHTML=r,X.RPS(i.OZ)}}var $n=(n,t,r,i=[])=>{if(l(n))n.forEach((o)=>{$n(o,n.length,r,i)});else if(n instanceof M)if(t>1)$n(Y("div",{},n),t,r,i);else{let o=n.value,s=o instanceof Q?"dom":"ctx",{ctx:e,catt:f}=ot(r.xid+"-0",o);r.xid=f.xid,i.push(e),r.OZ.push(f.OZ),r.states.push(n.call(Bt,s))}else i.push(mn(n,r))};class jn{tag;ctx;closing;constructor(n,t){this.tag=n;this.ctx=t;let r=Yt(n);this.closing=r?"":`</${n}>`}process(n,t=this.ctx,r=[]){return t.forEach((i)=>{$n(i,t.length,n,r)}),r.join("")}get(n){let t=this.process(n);if(n.events.size||n.states.length)n.id=n.xid;return`<${this.tag}${n.attr}>${t}${this.closing}`}}class Q{tag;constructor(n,t={},...r){this.tag=n;nn(this,{attr:new En(t),ctx:new jn(n,r)})}__(n=new c){let t=n.mid,r=new P(t,n);return this.attr.get(r),{ctx:this.ctx.get(r),oz:r.OZ.set(r),id:r.id}}}function Y(n,t={},...r){if($(n))return n(t??{},...r);return new Q(n,t??{},r)}var Dt=(n,...t)=>t;class qn{e;opt;constructor(n){this.e=n;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(n,t={}){return this.e.animate(n,t)}get slide(){let n=({x:t=0,y:r=0},i={})=>{y(this.opt,i);let o=[[t,r],[0,0]].map(([s,e])=>({transform:`translateX(${s}rem) translateY(${e}rem)`}));return this.e.animate(o,this.opt),this};return{left:(t={})=>{return n({x:-2},t)},right:(t={})=>{return n({x:2},t)},up:(t={})=>{return n({y:2},t)},down:(t={})=>{return n({y:-2},t)}}}fade(n={}){y(this.opt,n);let t=[0,1].map((r)=>({opacity:r}));return this.e.animate(t,this.opt),this}shake(n="Y",t={}){y(this.opt,t);let r=[0,5,-5,5,0].map((i)=>({transform:`translate${n}(${i}px)`}));return this.e.animate(r,this.opt),this}color(n=[],t={}){y(this.opt,t);let r=Array.isArray(n)?n.map((i)=>({color:i})):{color:n};return this.e.animate(r,this.opt),this}bg(n=[],t={}){y(this.opt,t);let r=Array.isArray(n)?n.map((i)=>({backgroundColor:i})):{backgroundColor:n};return this.e.animate(r,this.opt),this}bounce(n=1,t={}){y(this.opt,t);let r=[0.5,n,1].map((i)=>({transform:`scale(${i})`}));return this.e.animate(r),this}}class Zn{e;query;constructor(n,t){this.e=n;this.query=t}get a(){return new qn(this)}get all(){if(this.query){let n=document.querySelectorAll(this.query);if(n.length)return Array.from(n).map((t)=>t)}return[]}get attr(){let n=this.e;return{has:(t)=>{return n.hasAttribute(t)},get:(t)=>{return n.getAttribute(t)},del:(t)=>{return n.removeAttribute(t),this},set:(t)=>{for(let r in t){let i=t[r];if(t[r]!==void 0)n.setAttribute(r,i?i:"")}return this}}}get children(){return Array.from(this.e.children).map((n)=>T(n))}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 n=this.e.offsetParent;if(n)return new G(n);return}get parent(){let n=this.e.parentElement;if(n)return new G(n);return}get path(){return this.e?.pathname??""}get rect(){return this.e.getBoundingClientRect()}get remove_element(){return this.e.remove(),this}get style(){let n=this.e.style,t=this;return{set:(r,i=0)=>{let o=n,s=()=>{m(r).forEach(([e,f])=>{if(e in o){if(o[e]!==f)o[e]=f}else if(f!==null)n.setProperty(e,String(f))})};if($(i))t.on("transitionend",i);if(Gn(i))setTimeout(s,i);else s();return t},get:(r)=>{return n.getPropertyValue(r.toString())},del:(...r)=>{r.forEach((i)=>{n.removeProperty(i.toString())})}}}get submit(){let n=this.e;if("submit"in n)return n.submit();return!1}get tag(){return this.e.tagName.toLowerCase()}get value(){return this.e.value??""}get unload(){return()=>{this.e.remove()}}set append(n){let{ctx:t,oz:r}=Fn(n,Hn(this.id));this.e.insertAdjacentHTML("beforeend",t),X.RPS(r)}set appendfirst(n){let{ctx:t,oz:r}=Fn(n,Hn(this.id));this.e.insertAdjacentHTML("afterbegin",t),X.RPS(r)}set inner(n){let{ctx:t,oz:r}=Fn(n,Hn(this.id));this.e.innerHTML=t,X.RPS(r)}set disabled(n){let t=this.e;if("disabled"in t)t.disabled=n}set id(n){this.e.id=n}set value(n){let t=this.e;t.value=n}}var Fn=(n,t)=>{if(n instanceof Q)return n.__(new c(t));return{ctx:n,oz:void 0}},Hn=(n)=>n?`${n}-0`:n;class G extends Zn{constructor(n,t){super(n,t)}add(...n){return this.e.classList.add(...n.map((t)=>t.replace(/[^\w-]/,""))),this}remove(...n){return this.e.classList.remove(...n.map((t)=>t.replace(/[^\w-]/,""))),this}toggle(n,t){let r=typeof n!="string"?n.apply(this):n,i=this.e.classList;return r.split(" ").forEach((o)=>{i.toggle(o,t)}),this}has(n){return this.e.contains(n)}insert(n){return{HTML:(...t)=>{return t.forEach((r)=>{this.e.insertAdjacentHTML(n,r)}),this},element:(...t)=>{return t.forEach((r)=>{this.e.insertAdjacentElement(n,r)}),this},text:function(...t){return t.forEach((r)=>{this.e.insertAdjacentText(n,r)}),this}}}is(n){let t=this.e.classList.value.split(" "),r=this.e.tagName.toLocaleLowerCase(),i=!0,o=!0;if(n.dom)o=n.dom==r?!0:!1;if(n.class)if(Array.isArray(n.class))n.class.forEach((s)=>{i=i?t.includes(s):!1});else i=i?t.includes(n.class):!1;return i&&o}on(n,t,r=!1){let i=!1;if(n.indexOf("touch")>-1)i=!0;return this.e.addEventListener(n,t,{capture:r,passive:i}),this}remove_on(n,t,r=!1){return this.e.removeEventListener(n,t,r),this}timed(n,t=250){return setTimeout(()=>n(this),t),this}animate(n,t,r){let i={duration:300,easing:"ease",fill:"forwards"};if($(t))r=t;else y(i,t);let o=this.e.animate(n,i);if(r)o.finished.then(r);return this}}function T(n){if(v(n)){let t=document.querySelector(n);if(t)return new G(t,n);return}else return new G(n)}class gn extends bn{path;args;id;status;lang;import;_data={};constructor(n,t={},r,i=200){super();this.path=n;this.args=t;this.id=r;this.status=i}async loader(){if(this.import)try{let n=await this.import;if(n.default)this.import=await n.default({...this.args,...this.data});else this.import=void 0}catch(n){A.p=n,this.import=void 0}if(this.body){let n=await this.body();return l(n)?n:[n]}if(this.import){let n=this.import;return l(n)?n:[n]}return[]}getHeadAttr(n={},...t){let r=new I;if(q(n))r.head=n;r.id=this.id;let i=r.head;return t.forEach((o)=>{i.map(o)}),St(r,this),i}set data(n){y(this._data,n)}get data(){return this._data}}class Jn extends gn{head(){this.title=`error ${this.status}`}body(){return Y("div",{},this.path+" not found...")}}function St(n,t){let{link:r,script:i,meta:o,title:s,base:e,description:f,css:g}=t;if(n.head={title:s,base:e,meta:o,link:r,script:i},f)n.head={meta:[{name:"description",content:f}]};if(g){let p=(l(g)?g:[g]).map((H)=>({rel:`${b?"preload ":""}stylesheet`,href:H,as:"style"}));if(n.head.lacks("link"));n.head={link:[...p]}}}function st(n){let t=[];if(n?.length){let{href:r,target:i}=n[0],o=T("base");if(o)o.attr.set({href:r,target:i});else{let s=T(document.createElement("base"));s.attr.set({href:r,target:i}),document.head.append(s.e)}}else{let r=T("base")?.unload;r&&t.push(r)}return t}async function et(n){let t={};if(T("link")?.all.forEach((r)=>{let i=T(r),o=i.attr.get("href");if(o)t[o]=i.unload}),n&&q(n))for(let r of E(n)){let i=r.href;if(!(i in t))await xn(r);else delete t[i]}return E(t)}var Mt=["charset","name","property","http-equiv"];function ft(n){let t={};if(T("meta")?.all.forEach((r)=>{let i=r.attributes;for(let o of Mt)if(o in i){let s=i[o].value;t[`${o}_${o==="charset"?"":s}`]=r}}),n)m(n).forEach(([r,i])=>{if(r in t)T(t[r]).attr.set(i),delete t[r];else{let o=T(document.createElement("meta"));o.attr.set(i),document.head.append(o.e)}});return E(t).map((r)=>T(r).unload)}async function ut(n){let t={};if(T("script[yid]")?.all.forEach((r)=>{let i=T(r),o=i.attr.get("yid");if(o)t[o]=i.unload}),n){for(let r of n)if("yid"in r)if(r.yid in t)delete t[r.yid];else await Gt(r)}return E(t)}var Gt=(n)=>{return new Promise((t,r)=>{let i=T(document.createElement("script")),o="";if("importmap"in n)n.type="importmap",o=JSON.stringify(n.importmap),delete n.importmap;else if("body"in n)o=n.body,delete n.body;if(o)i.inner=o;i.attr.set(n),i.e.onload=()=>t(i.e),i.e.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(i.e)})};async function mt(n,t){let r=[];if(b)return[];let i=n.get("title")??"",{pushState:o}=this.config,s=this.path.value;if(o)Xn(s,i);return document.documentElement.lang=t,document.title=i,r.push(...st(n.get("base"))),r.push(...ft(n.get("meta"))),r.push(...await et(n.get("link"))),r.push(...await ut(n.get("script"))),r}function Xn(n,t){let r=window.location.pathname;if(n&&r!==n)history.pushState({},t??"",n)}class Qn{lang;head="";constructor(n,t){if(this.lang=n,t)this.head=Vn(t)}body(n,t){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${t??x(5)}">${n}</body>`,"</html>"].join("")}}class Yn{path;args;isConnected=J(!1);data={};constructor(n,t={}){this.path=n;this.args=t}open(n){}message(n){}close(n){}error(n){}get connect(){if(this.ws&&this.ws.readyState<=1)return this;return this.ws=new WebSocket(this.path),this.ws.onopen=async(n)=>{this.isConnected.value=!0,await this.open.call(this,n)},this.ws.onmessage=async(n)=>{await this.message.call(this,n)},this.ws.onclose=async(n)=>{this.isConnected.value=!1,await this.close.call(this,n)},this.ws.onerror=async(n)=>{this.isConnected.value=this.ws.readyState<=1,await this.error.call(this,n)},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(n){this.ws.send(n)}}var z=new u;class Un{yra;constructor(n){this.yra=n}async load(n){if(!z.has(n)){let[r,i]=await this.yra.loadWSS(n);if(!r)return;let{cls:o,path:s,id:e}=r,f=new o(s,i).connect;return z.set(n,f),f}let t=z.get(n);return t.reconnect,t}unload(n){if(z.has(n)){let t=z.get(n);if(!t)return;t.disconnect,z.delete(n)}}}function At(n,t,r){let i={...n.on??{},click(o){o.preventDefault(),r.value=T(this).path}};return delete n.on,Y("a",{...n,on:{...i}},...t)}function Kt(n,t,r){let{classes:i}=n.config,o={...t.on??{},ready(){n.element.value=this,t.render&&n.render(t.render)},...r&&{popstate(g){let h=g.target;n.path.value=h.location.pathname}}},{render:s,on:e,...f}=t;return Y("div",{...f,...i&&{class:i},on:o},n.root)}class Bn extends fn{isYRA;hook;id=x(4);root=J([]);path=J("");socket;element=J(null);A;Main;load;constructor(n,t={},r=!1){super(n,t);this.isYRA=r;this.socket=new Un(this),this.A=(i,...o)=>{return At(i,o,this.path)},this.Main=(i)=>{return Kt(this,i,r)},this.load=async(i,o={})=>{if(this.hook)this.hook();if(i)this.path.value=i,await this.render(i,404,o),this.hooker();return this}}hooker(){let n={},t=this.path.value;if(this.hook)this.hook();this.hook=W(async(r)=>{if(n[t]=window.scrollY,(await this.render(r,404)).done)window.scrollTo({top:n[r]??0,behavior:"instant"}),t=r},[this.path],{id:"router"})}async class(n,t,r=!1){let[i,o]=await this.getPath(n);if(i&&!r){let{cls:s,path:e,id:f}=i;return new s(e,o,f)}else return It.call(this,n,t)}async render(n,t=404,r={}){let i=await this.class(n,t,!1);if(i.data=r,await this.fetch(i),i.head)await i.head();if(!i)return{done:!1};return this.root.value=await i.loader(),{done:!0}}async fetch(n){if(n)try{if(n.fetch){let t=await n.fetch();if(a(t)&&q(t))n.data=t}}catch(t){A.p=t}}}async function It(n,t){let[r,i]=await this.loadError(t??0);if(r){let{cls:o,id:s}=r;return new o(n,i,s,t)}else{let o=new Jn(n,i,x(5));return o.title=`error ${t}`,o}}class gt extends Bn{constructor(n,{classes:t,pushState:r=!0}={}){super(n,{classes:t,pushState:r},!0);this.head({meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]}),this.load=async(i,o={})=>{if(this.hook)this.hook();if(i)this.path.value=i;if(Tn)this.render(i,404,o).then(()=>{if(i&&this.config.pushState)Xn(i,document.title);wt.call(this,this.Main({})),this.hooker()});return this}}async processHead(n,t={}){return n?await this.processClassHead(n,t):await this.processDefaultHead(t)}async processClassHead(n,t){if(n.head)await n.head();return n.getHeadAttr(t,this.htmlHead)}async processDefaultHead(n){let t=new I;if(q(n))t.head=n;return t.head.map(this.htmlHead),t.head}async render(n=location.pathname,t,r={},i={},o=!0,s=!1){if(b)this.path.value=n;let e=await this.class(n,t??Wt(),s);e.data=r,await this.fetch(e);let f=await this.processHead(e,i);if(!e)return{lang:this.lang,heads:f,done:!1};let g=[];if(o)g=await mt.call(this,f,e?.lang||this.lang);let h=await e.loader();if(h.length)this.root.value=h;else await this.render(n,t,r,i,o,!0);if(o)g.forEach((p)=>p());return{heads:f,lang:e.lang??this.lang,done:!0}}async html(n,t={},r){let i={script:[{type:"module",src:this.ImportMeta.file}]};Pt(i,r);let{lang:o,heads:s}=await this.render(n,r,t,i,!1),{ctx:e}=this.Main({}).__(new c(this.id));return new Qn(o,s).body(e,this.id)}}function wt(n){let t=document.body.id,{oz:r,id:i}=n.__(new c(t));if(this.id=i||this.id,!r)return;X.push(r),requestAnimationFrame(()=>{X.stage})}function Wt(){if(Tn)return parseInt(T('meta[name="error-code"]')?.attr.get("content")??"404");return 404}var Pt=(n,t)=>{switch(t){case 404:n.meta=[{name:"error-code",content:t.toString()}];return;default:return}};class Dn{state;body;click;constructor({toggle:n=[],initialState:t=!1}={}){this.state=J(t);let r=this.state;this.click=function(){r.value=!r.value},this.loader(n)}loader(n){if(typeof window==="undefined")return;let t=V.get("LOCAL_SCHEME"),r=this.isDark,i=t.as.bool,o=V.get({IS_DARK:()=>this.state.value});if(i!=null&&i!==r)this.state.value=!i,o.save,t.set=r;if(o.as.bool!==null)this.state.value=o.as.bool;let s=this.toggle,e=document.documentElement.classList;if(s(e,this.state.value,n),W(async(f)=>{s(e,f,n),o.save},[this.state],{id:"colorScheme"}),this.isMatchMediaSupported)window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(f)=>{let h=(f.matches?"dark":"light")==="dark";this.state.value=h,t.set=h})}get isMatchMediaSupported(){return window.matchMedia&&typeof window.matchMedia==="function"}get isDark(){return window.matchMedia("(prefers-color-scheme: dark)").matches}toggle(n,t,r){if(t)n.add(...r);else n.remove(...r)}}Dn=Sn([Rn,Mn("design:paramtypes",[Object])],Dn);var Vs=(n,t)=>{return`${n.replace(/\/+$/,"")}/${t.replace(/^\.\/+/,"")}`};export{Yn as websocket,W as stateHook,nt as session,Vs as resolvePath,fn as minClient,V as local,Dt as frag,kn as eventStream,Y as dom,gn as doc,xn as cssLoader,qt as addCSS,_n as __,gt as Yvee,M as Stateful,J as State,Bn as Router,rn as Meta,Q as Dom,Dn as ColorScheme,A as $$,T as $};
|
|
1
|
+
var Ft=function(t,n,r,i){var o=arguments.length,e=o<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,r):i,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")e=Reflect.decorate(t,n,r,i);else for(var u=t.length-1;u>=0;u--)if(s=t[u])e=(o<3?s(e):o>3?s(n,r,e):s(n,r))||e;return o>3&&e&&Object.defineProperty(n,r,e),e};var Zt=(t,n)=>{if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(t,n)};var x=(t)=>typeof t==="function";var R=(t)=>{return!isNaN(parseFloat(t))&&isFinite(t)},at=(t)=>{return typeof t==="object"&&t!==null&&!Array.isArray(t)},k=(t)=>{return typeof t==="object"&&t!==null&&Object.getPrototypeOf(t)===Object.prototype};var v=(t)=>typeof t==="boolean",tt=(t)=>typeof t==="string",a=(t)=>Array.isArray(t),w=(t)=>typeof t==="object",It=(t)=>typeof t==="number",C=(t)=>t===null,Xt=(t)=>typeof t==="undefined",Jt=(t)=>{return Number.isInteger(Number(t))},gt=typeof window!=="undefined",c=typeof window==="undefined";function nt(t,n){h(n).forEach(([r,i])=>{Ut(t,r,{value:i,writable:!1,configurable:!1,enumerable:!0})})}class H{static set p(t){if(Array.isArray(t))console.log(...t);else console.log(t)}}class d{_c=0;_id="";constructor(t){if(this._c=0,this._id=t??p(5),t?.includes("-")){let[n,r]=[t.split("-").slice(0,-1).join("-"),t.split("-").slice(-1)[0]];this._id=n,this._c=R(r)?parseInt(r):0}}get id(){return this._id+"-"+this._c}get mid(){return this._id+"-"+ ++this._c}}var vn=new RegExp(/(\d+)(\d*)/,"m"),dn=(t)=>Array.from({length:t},(n,r)=>r),pn="ABCDEFGHIJKLMNOPQRSTUVWXYZ",Tn="abcdefghijklmnopqrstuvwxyz",bn=dn(10).join("");var E=(t)=>JSON.stringify(t),Qt=(t)=>{return JSON.parse(t)},S=(t)=>{if(t.startsWith("webkit"))t="-"+t;return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()},p=(t)=>{let n=pn+Tn;return Array.from({length:t},(r,i)=>n+(i?bn:"")).reduce((r,i)=>{return r+=i.charAt(Math.floor(Math.random()*i.length))},"")};class f extends Map{obj(t){t&&h(t).forEach(([n,r])=>this.set(n,r))}map(t){t.forEach((n,r)=>{if(n instanceof f)this.set(r,n);else if(a(n)){if(this.lacks(r))this.set(r,[]);this.get(r).push(...n)}else if(w(n))this.ass(r,n);else this.set(r,n)})}ass(t,n){if(!this.has(t))this.set(t,{});T(this.get(t),n)}lacks(t){return!this.has(t)}init(t,n){return this.has(t)?this.get(t):this.set(t,n).get(t)}}var{values:y,keys:J,entries:h}=Object;var{hasOwn:Yt,freeze:Wt,defineProperty:Ut,assign:T}=Object,$=(t)=>{return Object.keys(t).length},rt=(t,n)=>{if(!n.has(t))n.set(t,new f);return n.get(t)},G=(t,n)=>{if(!n.has(t))n.set(t,[]);return n.get(t)},lt=(t,n)=>{let r={added:{},removed:{},modified:{}},i=J(t),o=J(n);for(let e of o){let s=t[e],u=n[e];if(!(e in t))r.added[e]=u;else if(a(s)&&a(u)){if(E(s)!==E(u))r.modified[e]={old:s,new:u}}else if(w(s)&&w(u)&&!C(s)&&!C(u)){let m=lt(s,u);if($(m.added)||$(m.removed)||$(m.modified))r.modified[e]={old:s,new:u}}else if(s!==u)r.modified[e]={old:s,new:u}}for(let e of i)if(!(e in n))r.removed[e]=t[e];return r};function Bt(t,n){if(t.size!==n.size)return!1;for(let r of t)if(!n.has(r))return!1;return!0}var Ct=(t)=>{return y(t).some((n)=>{return $(n)})};function Gt(t){let n;return class extends t{constructor(...r){if(n)return n;super(...r);Wt(this),n=this}}}var F=(t,n)=>{return{name:t,content:n}},yn=(t,n)=>{return{property:t,content:n}},xn=(t,n)=>{return{"http-equiv":t,content:n}};class it{metas=[];constructor(t){t&&this.metas.push(F("description",t))}author(t){return this.meta=F("author",t),this}charset(t){return this.meta={charset:t},this}keywords(...t){return this.meta=F("keywords",t.join(", ")),this}viewport(t){let n=h(t).map(([r,i])=>[S(r),String(i)].join("="));return this.meta=F("viewport",n.join(", ")),this}httpEquiv(t){return h(t).forEach(([n,r])=>{this.meta=xn(S(n),String(r))}),this}robots(...t){return this.meta=F("robots",t.join(", ")),this}themeColor(t){return this.meta=F("theme-color",t),this}openGraph(t){return h(t).forEach(([n,r])=>{this.meta=yn("og:"+n,String(r))}),this}twitter(t){return h(t).forEach(([n,r])=>{this.meta=F("twitter:"+n,String(r))}),this}and(t){return this}set meta(t){this.metas.push(t)}}class ct{title;description;base;meta;link;script;css}var En=["charset","name","property","http-equiv"],Pt=(t,n)=>{n.forEach((r)=>{for(let i of En)if(i in r){let o=r[i];t[`${i}_${i==="charset"?"":o}`]=r}})},$n=(t,n)=>{n.forEach((r)=>{if("href"in r){let i=r.href;t[`${i}`]=r}})};class U{_head;idm;constructor(t){this._head=new f(t)}set head(t){h(t).forEach(([n,r])=>{if(n==="title"||n==="base"){if(r!==void 0)this._head.set(n,r);return}if(r instanceof it)return Pt(this._head.init("meta",{}),r.metas);if(!a(r))return;switch(n){case"meta":return Pt(this._head.init("meta",{}),r);case"link":return $n(this._head.init("link",{}),r);case"script":if(r.length){this._head.init(n,[]);let i=r.map((o)=>{if(!o.yid&&this.idm)o.yid="sc"+this.idm.mid;return o});this._head.get(n).push(...i)}return}})}get head(){return this._head}set id(t){this.idm=new d(t)}}var zt=(t)=>{return h(t).reduce((n,[r,i])=>{return n.push(v(i)&&i?r:`${r}="${i}"`),n},[""]).join(" ")},Kt=(t)=>{if(!t)return"";return[...t].reduce((n,[r,i])=>{if(r==="meta"||r==="link")i=y(i);if(tt(i))return n.push(`<${r}>${i}</${r}>`),n;if(!a(i))return n;let o=i.map((e)=>{if(r==="script"){let s={...e};if("yid"in s)return"";let u="";if("importmap"in s)s.type="importmap",u=JSON.stringify(s.importmap),delete s.importmap;else if("body"in s)u=s.body,delete s.body;return`<${r}${zt(s)}>${u}</${r}>`}return`<${r}${zt(e)}>`});return n.push(...o),n},[]).join("")};class dt{lang="en";htmlHead=new f;head;constructor(){this.head=(t={})=>{let n=new U(this.htmlHead);n.head=t,this.htmlHead=n.head}}}var pt=(t)=>{if(c)return;return new Promise((n,r)=>{let i=document.createElement("link");if(t.rel!=="stylesheet")t.rel="stylesheet",t.as="style";h(t).forEach(([o,e])=>{i.setAttribute(o,e)}),i.onload=()=>n(i),i.onerror=()=>r(new Error("Failed to load CSS")),document.head.appendChild(i)})},Nt=(t)=>{return new Promise((n,r)=>{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.innerHTML=o;h(t).forEach(([e,s])=>{i.setAttribute(e,s)}),i.onload=()=>n(i),i.onerror=()=>r(new Error("Failed to load Script")),document.head.appendChild(i)})},wn=()=>{let n=document.querySelector("#d-css")?.sheet;if(n)return n;let r=document.createElement("style");return r.id="d-css",document.head.appendChild(r),r.sheet},Hn=(t,n)=>{for(let r=0;r<t.cssRules.length;r++)if(t.cssRules[r].selectorText===n)return!0;return!1},jn=(t)=>Object.entries(t).map(([n,r])=>`${S(n)}: ${r};`).join(" ");function Dn(t,n={}){if(c)return;let r=wn();if(!r)return;if(!Hn(r,t))r.insertRule(`${t} { ${jn(n)} }`,r.cssRules.length)}var Vt=(t,n)=>{let r=n;if(t?.class)r.push(...a(t.class)?t.class:[t.class]);return delete t.class,r.filter((i)=>i)};var Ot=(t,n=!1)=>{if(R(t))return[+t,Jt(t)?"int":"float"];if(n&&/\.\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"]},ot=(t)=>{let n=t.startsWith("/")?t:"/"+t,r=n.match(/(?<=\/)[^/].*?(?=\/|$)/g)??["/"],[i,o]=r.reduce(([e,s],u)=>{if(u.includes("<")){let m=u.match(/(?<=<)[^/].*?(?=>|$)/g);if(m?.length){let[l,b]=m[0].split(":");if(l&&b)e.push(l),s.push(b)}}else e.push(u===">"?"/":u);return[e,s]},[[],[]]);if(n.endsWith("/")&&n.length>1)i.push("/");return{parsed:i,args:o}};class et{storage=new f;cache(t,n){if(this.storage.lacks(t))this.storage.set(t,n());return this.storage.get(t)}}var An=["int","float","file","uuid","string"],qn=new et;class Q{_storage=new f;set(t){let{parsed:n,path:r}=t,i=E(n);if(!this._storage.get(i))this._storage.set(i,t);else throw`path: ${r} already used.`}get(t){let{parsed:n}=qn.cache(t,()=>ot(t)),r={},i=this._storage.get(E(n));if(!i&&t!=="/")for(let o of this._storage.keys()){let e=[],s=Qt(o);if(n.length===s.length){let u=s.map((b,j)=>{let D=Ot(n[j],n.length-1===j);if(b===D[0])return D[0];if(An.includes(D[1]))return e.push(D[0]),D[1];return b}),m=E(u);if(this._storage.has(m)){i=this._storage.get(m),i?.args.forEach((b,j)=>{r[b]=e[j]});break}}}return[i,r]}}class P{path="";parsed=[];args=[];constructor(t){nt(this,{path:t,...ot(t)})}}class _t{static rand(t=6,n){if(n)return Math.floor(Math.random()*(n-t+1)+t);return Math.floor(Math.random()*t)+1-1}static fill(t,n=null){return Array(t).fill(n)}static new({dom:t,id:n,inner:r}){let i=document.createElement(t);if(n)i.id=n;if(r)i.innerHTML=r;return i}static randFrom(t){if(Array.isArray(t)){let n=t.length,r=this.rand(0,n-1);return t[r]}else if(typeof t=="object"){let n=J(t),r=n.length,i=this.rand(0,r-1);return n[i]}}static makeID=p;static reClass=Vt;static get O(){return{vals:y,keys:J,items:h,has:Yt,ass:T,len:(t={})=>J(t).length}}}var Tt={},Z={};class kt{stream;url;constructor(t,n){if(this.url=t,t in Tt)this.stream=Tt[t];else this.stream=new EventSource(t,{withCredentials:n}),Tt[t]=this.stream,Z[this.url]={}}on(t){let n=this.stream;return h(t).forEach(([r,i])=>{if(r in Z[this.url])Z[this.url][r].forEach((o)=>{this.stream.removeEventListener(r,o)}),Z[this.url][r]=[];if(n.addEventListener(r,i),!(r in Z[this.url]))Z[this.url][r]=[];Z[this.url][r].push(i)}),this}}function vt(t,n=!0){return new kt(t,n)}class tn{value;constructor(t){this.value=t}get str(){return String(this.value).toString()=="null"?null:String(this.value).toString()}get int(){if(R(this.value))return parseInt(this.value);else return null}get float(){if(R(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;func;storage;constructor(t,n="local"){if(typeof t=="object"){let[r,i]=h(t)[0];this.key=r,this.func=i}else this.key=t,this.func=null;this.storage=n=="local"?localStorage:sessionStorage}get as(){return new tn(this.storage.getItem(this.key))}get value(){return this.storage.getItem(this.key)}get save(){if(this.func)this.set=this.func();return}set set(t){if(typeof t=="object")this.storage.setItem(this.key,JSON.stringify(t));else this.storage.setItem(this.key,String(t))}get remove(){this.storage.removeItem(this.key);return}}var K={get:(t)=>new z(t)};var nn={get:(t)=>new z(t,"session")};class st extends P{id;cls;constructor(t,n,r){super(t);this.id=n;this.cls=r}}class rn extends P{id;cls;constructor(t,n,r){super(t);this.id=n;this.cls=r}}class ut extends dt{ImportMeta;config;storage=new Q;errorStorage=new Q;wssStorage=new Q;route;error;wss;constructor(t,n){super();this.ImportMeta=t;this.config=n;this.route=(r)=>{return(i)=>{return this.storage.set(new st(r,p(5),i)),i}},this.wss=(r)=>{return(i)=>{return this.wssStorage.set(new rn(r,p(5),i)),i}},this.error=(...r)=>{return(i)=>{if(r.length)r.forEach((o)=>{this.errorStorage.set(new st(o.toString(),p(5),i))});else this.errorStorage.set(new st("404",p(5),i));return i}}}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 N=new f,V=(t)=>{if(c)return;let n=N.get(t);if(n?.isConnected)return n;N.delete(t);let r=document.getElementById(t);if(!r)return;return N.set(t,r),r};function on(){let t=[];return N.forEach((n,r)=>{if(!n.isConnected)t.push(r),N.delete(r)}),t}function Y(t,n,{id:r="state",init:i}={}){let o=[],e=()=>n.map((u)=>u.value),s=()=>{t(...e())};if(n.forEach((u)=>{o.push(u.hook(s)(r))}),i)s();return()=>{o.forEach((u)=>u())}}var en=(t)=>{t.forEach((n)=>n())};var Ln=(t,n)=>{for(let[r,i]of t){let o=V(r);if(!o){t.delete(r);continue}i.forEach((e)=>{e.call(o,n)})}};class I extends EventTarget{options;hooks=new f;states=new f;_value;listening=!1;end;constructor(t,n){super();this.options=n;this._value=t}get value(){return this._value}set value(t){if(C(t)||Xt(t))return;if(k(this._value)||a(this._value)){let n=lt(this._value,t);if(!Ct(n))return}else if(this._value instanceof Set){if(!Bt(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=(n)=>{if(en(this.hooks),Ln(this.states,n.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,n){return(r)=>{if(rt(r,this.states).set(n,t),!c&&!this.listening)this.end=this.listen;return()=>{if(this.states.has(r))this.states.get(r)?.delete(n)}}}hook(t){return(n)=>{if(this.hooks.set(n,t),!c&&!this.listening)this.end=this.listen;return()=>{if(this.hooks.has(n))this.hooks.delete(n)}}}}function A(t){return new I(t)}var bt=(t)=>{if(a(t))return t.join(" ");else if(w(t)){if(at(t))return E(t)}else if(x(t))return bt(t());else if(t!==void 0&&t!==null)return v(t)?t?"":"false":String(t);return""};function Mn(t,n){switch(n??t){case"style":return function(r){this.style.setProperty(t,r)};default:return function(r){this.setAttribute(t,r)}}}class yt{attr;constructor(t={}){this.attr=t}get(t,n=this.attr,r){let i=(o,e)=>{if(a(e))t.attr_push(o,bt(e));else if(e instanceof I){let s=r?`${r}_${o}`:o;t.states.push(e.call(Mn(o,r),s)),i(o,e.value)}else if(w(e)){if(at(e)&&!r)this.get(t,e,o)}else t.attr_push(o,bt(e),r)};h(n).forEach(([o,e])=>{if(["on"].includes(o))w(n.on)&&t.events.obj(n.on);else i(o,e)})}}class W{xid;IDM;map=new f;states=[];events=new f;OZ;constructor(t,n=new d,r){this.xid=t;this.IDM=n;this.OZ=r??new ft}attr_push(t,n,r){let i=r??t;if(!this.map.has(i))this.map.set(i,[]);let o=r?`${S(t)}:${n};`:n;this.map.get(i).push(o)}get attr(){let t=[""];return this.map.forEach((n,r)=>{let i=n.join("");t.push(i?`${r}="${i}"`:r)}),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,n,r)=>{return t.addEventListener(n,r),()=>{t.removeEventListener(n,r)}},O={};class ft{events=new f;states=new f;winStates=new f;windowEvents=new f;resetST=new f;resetEV=new f;constructor(){}get keys(){return[...new Set([...this.states.keys(),...this.events.keys()])]}set(t){let{id:n,events:r,states:i}=t;if(n){if(r.size)this.events.set(n,r);if(i.length)this.states.set(n,i)}return this}push(t){return t.events.forEach((n,r)=>{n.forEach((i,o)=>{rt(r,this.events).set(o,i)})}),t.states.forEach((n,r)=>{G(r,this.states).push(...n)}),this}get stage(){return this.events.forEach((t,n)=>{this.events.delete(n);let r=V(n);if(!r){this.events.delete(n);return}t.forEach((i,o)=>{switch(o){case"ready":i.apply(r,[r]);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 f).set(n,i);break;case"watch":let[s,u,m]=i.apply(r,[r]),l=a(u)?u:[u],b=()=>l.map((D)=>D.value),j=()=>s(...b());if(m)j();l.forEach((D)=>G(n,this.resetST).push(D.call(j,n+"_watch")(n)));break;default:G(n,this.resetEV).push(Rn(r,o,i))}})}),this.processWindowEvents,this.states.forEach((t,n)=>{this.states.delete(n),t.forEach((r)=>{G(n,this.resetST).push(r(n))})}),this}get processWindowEvents(){let t=(n,r)=>{let i=(o)=>{r.forEach((e,s)=>{let u=V(s);if(u)e.call(u,o);else this.windowEvents.get(n)?.delete(s)})};return window.addEventListener(n,i),()=>{window.removeEventListener(n,i)}};return this.windowEvents.forEach((n,r)=>{if(n.size){if(!O[r])O[r]=t(r,n)}else if(O[r])O[r](),delete O[r]}),this}reset(t){return t.forEach((n)=>{this.windowEvents.forEach((r,i)=>{if(r.has(n))r.delete(n)}),this.resetEV.get(n)?.forEach((r)=>{r()}),this.resetST.get(n)?.forEach((r)=>{r()}),this.resetST.delete(n),this.resetEV.delete(n)}),this}RPS(t){if(t){let n=on();this.reset(n);let r=t.keys;if(r.length)this.reset(r).push(t).stage}return this}}var q=new ft;var Sn=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],Fn=(t)=>Sn.includes(t);function Zn(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var mt=(t,n)=>{if(a(t))return t.map((r)=>mt(r,n)).join("");else if(t instanceof L){let r=t.__(n.IDM),{ctx:i,oz:o}=r;return n.OZ.push(o),i}else if(w(t))return E(t);else if(x(t))return mt(t(),n);else if(t!==void 0&&t!==null)return Zn(t);return""},sn=(t,n)=>{let r=new d(t),i=new W(r.id,r);return{ctx:mt(n,i),catt:i}};function In(t){let n=this.id;if(n){let{ctx:r,catt:i}=sn(n,t);if(this.innerHTML!==r)this.innerHTML=r,q.RPS(i.OZ)}}var xt=(t,n,r,i=[])=>{if(a(t))t.forEach((o)=>{xt(o,t.length,r,i)});else if(t instanceof I)if(n>1)xt(M("div",{},t),n,r,i);else{let o=t.value,e=o instanceof L?"dom":"ctx",{ctx:s,catt:u}=sn(r.xid+"-0",o);r.xid=u.xid,i.push(s),r.OZ.push(u.OZ),r.states.push(t.call(In,e))}else i.push(mt(t,r))};class Et{tag;ctx;closing;constructor(t,n){this.tag=t;this.ctx=n;let r=Fn(t);this.closing=r?"":`</${t}>`}process(t,n=this.ctx,r=[]){return n.forEach((i)=>{xt(i,n.length,t,r)}),r.join("")}get(t){let n=this.process(t);if(t.events.size||t.states.length)t.id=t.xid;return`<${this.tag}${t.attr}>${n}${this.closing}`}}class L{tag;constructor(t,n={},...r){this.tag=t;nt(this,{attr:new yt(n),ctx:new Et(t,r)})}__(t=new d){let n=t.mid,r=new W(n,t);return this.attr.get(r),{ctx:this.ctx.get(r),oz:r.OZ.set(r),id:r.id}}}function M(t,n={},...r){if(x(t))return t(n??{},...r);return new L(t,n??{},r)}var Xn=(t,...n)=>n;class $t{e;opt;constructor(t){this.e=t;this.opt={duration:500,easing:"ease-in-out",fill:"forwards"}}animate(t,n={}){return this.e.animate(t,n)}get slide(){let t=({x:n=0,y:r=0},i={})=>{T(this.opt,i);let o=[[n,r],[0,0]].map(([e,s])=>({transform:`translateX(${e}rem) translateY(${s}rem)`}));return this.e.animate(o,this.opt),this};return{left:(n={})=>{return t({x:-2},n)},right:(n={})=>{return t({x:2},n)},up:(n={})=>{return t({y:2},n)},down:(n={})=>{return t({y:-2},n)}}}fade(t={}){T(this.opt,t);let n=[0,1].map((r)=>({opacity:r}));return this.e.animate(n,this.opt),this}shake(t="Y",n={}){T(this.opt,n);let r=[0,5,-5,5,0].map((i)=>({transform:`translate${t}(${i}px)`}));return this.e.animate(r,this.opt),this}color(t=[],n={}){T(this.opt,n);let r=Array.isArray(t)?t.map((i)=>({color:i})):{color:t};return this.e.animate(r,this.opt),this}bg(t=[],n={}){T(this.opt,n);let r=Array.isArray(t)?t.map((i)=>({backgroundColor:i})):{backgroundColor:t};return this.e.animate(r,this.opt),this}bounce(t=1,n={}){T(this.opt,n);let r=[0.5,t,1].map((i)=>({transform:`scale(${i})`}));return this.e.animate(r),this}}class jt{e;query;constructor(t,n){this.e=t;this.query=n}get a(){return new $t(this)}get all(){if(this.query){let t=document.querySelectorAll(this.query);if(t.length)return Array.from(t).map((n)=>n)}return[]}get attr(){let t=this.e;return{has:(n)=>{return t.hasAttribute(n)},get:(n)=>{return t.getAttribute(n)},del:(n)=>{return t.removeAttribute(n),this},set:(n)=>{for(let r in n){let i=n[r];if(n[r]!==void 0)t.setAttribute(r,i?i:"")}return this}}}get children(){return Array.from(this.e.children).map((t)=>g(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 X(t);return}get parent(){let t=this.e.parentElement;if(t)return new X(t);return}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,n=this;return{set:(r,i=0)=>{let o=t,e=()=>{h(r).forEach(([s,u])=>{if(s in o){if(o[s]!==u)o[s]=u}else if(u!==null)t.setProperty(s,String(u))})};if(x(i))n.on("transitionend",i);if(It(i))setTimeout(e,i);else e();return n},get:(r)=>{return t.getPropertyValue(r.toString())},del:(...r)=>{r.forEach((i)=>{t.removeProperty(i.toString())})}}}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:n,oz:r}=wt(t,Ht(this.id));this.e.insertAdjacentHTML("beforeend",n),q.RPS(r)}set appendfirst(t){let{ctx:n,oz:r}=wt(t,Ht(this.id));this.e.insertAdjacentHTML("afterbegin",n),q.RPS(r)}set inner(t){let{ctx:n,oz:r}=wt(t,Ht(this.id));this.e.innerHTML=n,q.RPS(r)}set disabled(t){let n=this.e;if("disabled"in n)n.disabled=t}set id(t){this.e.id=t}set value(t){let n=this.e;n.value=t}}var wt=(t,n)=>{if(t instanceof L)return t.__(new d(n));return{ctx:t,oz:void 0}},Ht=(t)=>t?`${t}-0`:t;class X extends jt{constructor(t,n){super(t,n)}add(...t){return this.e.classList.add(...t.map((n)=>n.replace(/[^\w-]/,""))),this}remove(...t){return this.e.classList.remove(...t.map((n)=>n.replace(/[^\w-]/,""))),this}toggle(t,n){let r=typeof t!="string"?t.apply(this):t,i=this.e.classList;return r.split(" ").forEach((o)=>{i.toggle(o,n)}),this}has(t){return this.e.contains(t)}insert(t){return{HTML:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentHTML(t,r)}),this},element:(...n)=>{return n.forEach((r)=>{this.e.insertAdjacentElement(t,r)}),this},text:function(...n){return n.forEach((r)=>{this.e.insertAdjacentText(t,r)}),this}}}is(t){let n=this.e.classList.value.split(" "),r=this.e.tagName.toLocaleLowerCase(),i=!0,o=!0;if(t.dom)o=t.dom==r?!0:!1;if(t.class)if(Array.isArray(t.class))t.class.forEach((e)=>{i=i?n.includes(e):!1});else i=i?n.includes(t.class):!1;return i&&o}on(t,n,r=!1){let i=!1;if(t.indexOf("touch")>-1)i=!0;return this.e.addEventListener(t,n,{capture:r,passive:i}),this}remove_on(t,n,r=!1){return this.e.removeEventListener(t,n,r),this}timed(t,n=250){return setTimeout(()=>t(this),n),this}animate(t,n,r){let i={duration:300,easing:"ease",fill:"forwards"};if(x(n))r=n;else T(i,n);let o=this.e.animate(t,i);if(r)o.finished.then(r);return this}}function g(t){if(tt(t)){let n=document.querySelector(t);if(n)return new X(n,t);return}else return new X(t)}class ht extends ct{path;args;id;status;lang;import;_data={};constructor(t,n={},r,i=200){super();this.path=t;this.args=n;this.id=r;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){H.p=t,this.import=void 0}if(this.body){let t=await this.body();return a(t)?t:[t]}if(this.import){let t=this.import;return a(t)?t:[t]}return[]}getHeadAttr(t={},...n){let r=new U;if($(t))r.head=t;r.id=this.id;let i=r.head;return n.forEach((o)=>{i.map(o)}),Jn(r,this),i}set data(t){T(this._data,t)}get data(){return this._data}}class Dt extends ht{head(){this.title=`error ${this.status}`}body(){return M("div",{},this.path+" not found...")}}function Jn(t,n){let{link:r,script:i,meta:o,title:e,base:s,description:u,css:m}=n;if(t.head={title:e,base:s,meta:o,link:r,script:i},u)t.head={meta:[{name:"description",content:u}]};if(m){let b=(a(m)?m:[m]).map((j)=>({rel:`${c?"preload ":""}stylesheet`,href:j,as:"style"}));if(t.head.lacks("link"));t.head={link:[...b]}}}function un(t){let n=[];if(t?.length){let{href:r,target:i}=t[0],o=g("base");if(o)o.attr.set({href:r,target:i});else{let e=g(document.createElement("base"));e.attr.set({href:r,target:i}),document.head.append(e.e)}}else{let r=g("base")?.unload;r&&n.push(r)}return n}var fn=new f;async function mn(t,n=!1){let r=_.value,i={};if(g("link")?.all.forEach((o)=>{let e=g(o),s=e.attr.get("href");if(s){let u=e.attr.get("rt");if(n){let m=fn.get(r);if(m){if(!m.has(s))i[s]=e.unload}else i[s]=e.unload}else if(u)i[s]=e.unload}}),t&&$(t))for(let o of y(t)){let e=o.href;if(!(e in i))try{if(!n){o.rt=!0;let s=fn.init(r,new Set);if(!s.has(e))s.add(e)}await pt(o)}catch(s){H.p=s}else delete i[e]}return y(i)}var Un=["charset","name","property","http-equiv"];function hn(t){let n={};if(g("meta")?.all.forEach((r)=>{let i=r.attributes;for(let o of Un)if(o in i){let e=i[o].value;n[`${o}_${o==="charset"?"":e}`]=r}}),t)h(t).forEach(([r,i])=>{if(r in n)g(n[r]).attr.set(i),delete n[r];else{let o=g(document.createElement("meta"));o.attr.set(i),document.head.append(o.e)}});return y(n).map((r)=>g(r).unload)}var an=new f;async function gn(t,n=!1){let r=_.value,i={};if(g("script[yid]")?.all.forEach((o)=>{let e=g(o),s=e.attr.get("yid");if(s){let u=e.attr.get("rt");if(n){let m=an.get(r);if(m){if(!m.has(s))i[s]=e.unload}else i[s]=e.unload}else if(u)i[s]=e.unload}}),t){for(let o of t)if("yid"in o)if(o.yid in i)delete i[o.yid];else try{if(!n){o.rt=!0;let e=o.yid,s=an.init(r,new Set);if(!s.has(e))s.add(e)}await Nt(o)}catch(e){H.p=e}}return y(i)}async function ln(t,n,r=!1){let i=[];if(c)return[];let o=t.get("title")??"";if(r){let{pushState:s}=this.config,u=this.path.value;if(s)At(u,o);document.documentElement.lang=n,document.title=o}let e=this.path.value;if(r)i.push(...un(t.get("base"))),i.push(...hn(t.get("meta")));return i.push(...await mn(t.get("link"),r)),i.push(...await gn(t.get("script"),r)),i}function At(t,n){let r=window.location.pathname;if(t&&r!==t)history.pushState({},n??"",t)}class qt{lang;head="";constructor(t,n){if(this.lang=t,n)this.head=Kt(n)}body(t,n,r){return[`<!DOCTYPE html><html lang="${this.lang}">`,`<head>${this.head}</head>`,`<body id="${n??p(5)}"${r?" "+r:""}>${t}</body>`,"</html>"].join("")}}class Lt{path;args;isConnected=A(!1);data={};constructor(t,n={}){this.path=t;this.args=n}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){this.ws.send(t)}}var B=new f;class Mt{yra;constructor(t){this.yra=t}async load(t){if(!B.has(t)){let[r,i]=await this.yra.loadWSS(t);if(!r)return;let{cls:o,path:e,id:s}=r,u=new o(e,i).connect;return B.set(t,u),u}let n=B.get(t);return n.reconnect,n}unload(t){if(B.has(t)){let n=B.get(t);if(!n)return;n.disconnect,B.delete(t)}}}function Qn(t,n,r){let i={...t.on??{},click(o){o.preventDefault(),r.value=g(this).path}};return delete t.on,M("a",{...t,on:{...i}},...n)}function Yn(t,n,r){let{classes:i}=t.config,{load:o,on:e,...s}=n,u={...n.on??{},...!r&&o&&{ready(m){t.load(o)}},...r&&{popstate(m){let l=m.target;t.path.value=l.location.pathname}}};return M("div",{...s,...i&&{class:i},on:u},t.root)}class Rt extends ut{isYRA;unload=!1;hook;root=A([]);socket;id=p(4);path=A("");A;Main;load;constructor(t,n={},r=!1){super(t,n);this.isYRA=r;this.socket=new Mt(this),this.A=(i,...o)=>{return Qn(i,o,this.path)},this.Main=(i)=>{return Yn(this,i,r)},this.load=async(i,o={})=>{if(this.hook)this.hook();if(i)this.path.value=i,await this.render(i,404,o),this.hooker();return this}}hooker(){let t={},n=this.path.value;if(this.hook)this.hook();this.hook=Y(async(r)=>{if(t[n]=window.scrollY,(await this.render(r,404)).done)window.scrollTo({top:t[r]??0,behavior:"instant"}),n=r},[this.path],{id:"router"})}async class(t,n,r=!1){let[i,o]=await this.getPath(t);if(i&&!r){let{cls:e,path:s,id:u}=i;return new e(s,o,u)}else return Wn.call(this,t,n)}async fetch(t){if(t)try{if(t.fetch){let n=await t.fetch();if(k(n)&&$(n))t.data=n}}catch(n){H.p=n}}async processHead(t,n={}){return t?await this.processClassHead(t,n):await this.processDefaultHead(n)}async processClassHead(t,n){if(t.head)await t.head();return t.getHeadAttr(n,this.htmlHead)}async processDefaultHead(t){let n=new U;if($(t))n.head=t;return n.head.map(this.htmlHead),n.head}async render(t,n=404,r={},i={},o=!0,e=!1){if(c)this.path.value=t;let s=await this.class(t,n??Cn(),e);s.data=r,await this.fetch(s);let u=await this.processHead(s,i);if(!s)return{lang:this.lang,heads:u,done:!1};let m=await s.loader();if(o){let l=await ln.call(this,u,s?.lang||this.lang,this.unload);if(o)l.forEach((b)=>b())}if(m.length)this.root.value=m;else await this.render(t,n,r,i,o,!0);return{heads:u,lang:s.lang??this.lang,done:!0}}}async function Wn(t,n){let[r,i]=await this.loadError(n??0);if(r){let{cls:o,id:e}=r;return new o(t,i,e,n)}else{let o=new Dt(t,i,p(5));return o.title=`error ${n}`,o}}var _=A("");class cn extends Rt{unload=!0;constructor(t,{classes:n,pushState:r=!0}={}){super(t,{classes:n,pushState:r},!0);this.path=_,this.head({meta:[{charset:"utf-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}]}),this.load=async(i=location.pathname,o={})=>{if(this.hook)this.hook();if(i)this.path.value=i;if(gt)this.render(i,404,o).then(()=>{if(i&&this.config.pushState)At(i,document.title);Bn.call(this,this.Main({})),this.hooker()});return this}}async html({path:t,data:n={},status:r=200,attr:i=""}){let o={script:[{type:"module",src:this.ImportMeta.file}]};Gn(o,r);let{lang:e,heads:s}=await this.render(t,r,n,o,!1),{ctx:u}=this.Main({}).__(new d(this.id));return new qt(e,s).body(u,this.id,i)}}function Bn(t){let n=document.body.id,{oz:r,id:i}=t.__(new d(n));if(this.id=i||this.id,!r)return;q.push(r),requestAnimationFrame(()=>{q.stage})}function Cn(){if(gt)return parseInt(g('meta[name="error-code"]')?.attr.get("content")??"404");return 404}var Gn=(t,n)=>{switch(n){case 404:t.meta=[{name:"error-code",content:n.toString()}];return;default:return}};class St{state;body;click;constructor({toggle:t=[],initialState:n=!1}={}){this.state=A(n);let r=this.state;this.click=function(){r.value=!r.value},this.loader(t)}loader(t){if(typeof window==="undefined")return;let n=K.get("LOCAL_SCHEME"),r=this.isDark,i=n.as.bool,o=K.get({IS_DARK:()=>this.state.value});if(i!=null&&i!==r)this.state.value=!i,o.save,n.set=r;if(o.as.bool!==null)this.state.value=o.as.bool;let e=this.toggle,s=document.documentElement.classList;if(e(s,this.state.value,t),Y(async(u)=>{e(s,u,t),o.save},[this.state],{id:"colorScheme"}),this.isMatchMediaSupported)window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(u)=>{let l=(u.matches?"dark":"light")==="dark";this.state.value=l,n.set=l})}get isMatchMediaSupported(){return window.matchMedia&&typeof window.matchMedia==="function"}get isDark(){return window.matchMedia("(prefers-color-scheme: dark)").matches}toggle(t,n,r){if(n)t.add(...r);else t.remove(...r)}}St=Ft([Gt,Zt("design:paramtypes",[Object])],St);var Ve=(t,n)=>{return`${t.replace(/\/+$/,"")}/${n.replace(/^\.\/+/,"")}`},Oe=(t)=>{return(n)=>{t(n)}},_e=(t)=>{return(n)=>{t(n)}};export{Lt as websocket,Y as stateHook,nn as session,Ve as resolvePath,ut as minClient,K as local,Xn as frag,vt as eventStream,M as dom,ht as doc,pt as cssLoader,Dn as addCSS,_t as __,cn as Yvee,I as Stateful,A as State,Oe as Routes,Rt as Router,it as Meta,_e as Errors,L as Dom,St as ColorScheme,H as $$,g as $};
|