@devwaren/vanilla-ts 1.0.12 → 1.0.14
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.cjs +12 -9
- package/dist/index.js +11 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Qt=Object.create;var B=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,en=Object.prototype.hasOwnProperty;var de=(n,e)=>()=>(n&&(e=n(n=0)),e);var Je=(n,e)=>{for(var t in e)B(n,t,{get:e[t],enumerable:!0})},Ze=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Jt(e))!en.call(n,r)&&r!==t&&B(n,r,{get:()=>e[r],enumerable:!(s=Xt(e,r))||s.enumerable});return n};var v=(n,e,t)=>(t=n!=null?Qt(Zt(n)):{},Ze(e||!n||!n.__esModule?B(t,"default",{value:n,enumerable:!0}):t,n)),tn=n=>Ze(B({},"__esModule",{value:!0}),n);function bt(n,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=b.FILE_DIR_TYPE),t&&(e.type=t),n){if(typeof n!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!St.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${St.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=n,new qe(e)}var A,vt,D,b,$e,Rt,wn,St,En,Tn,Sn,_n,_t,Pt,qe,Lt=de(()=>{"use strict";A=require("fs/promises"),vt=require("stream"),D=require("path"),b={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},$e={root:".",fileFilter:n=>!0,directoryFilter:n=>!0,type:b.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze($e);Rt="READDIRP_RECURSIVE_ERROR",wn=new Set(["ENOENT","EPERM","EACCES","ELOOP",Rt]),St=[b.DIR_TYPE,b.EVERYTHING_TYPE,b.FILE_DIR_TYPE,b.FILE_TYPE],En=new Set([b.DIR_TYPE,b.EVERYTHING_TYPE,b.FILE_DIR_TYPE]),Tn=new Set([b.EVERYTHING_TYPE,b.FILE_DIR_TYPE,b.FILE_TYPE]),Sn=n=>wn.has(n.code),_n=process.platform==="win32",_t=n=>!0,Pt=n=>{if(n===void 0)return _t;if(typeof n=="function")return n;if(typeof n=="string"){let e=n.trim();return t=>t.basename===e}if(Array.isArray(n)){let e=n.map(t=>t.trim());return t=>e.some(s=>t.basename===s)}return _t},qe=class extends vt.Readable{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...$e,...e},{root:s,type:r}=t;this._fileFilter=Pt(t.fileFilter),this._directoryFilter=Pt(t.directoryFilter);let i=t.lstat?A.lstat:A.stat;_n?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=t.depth??$e.depth,this._wantsDir=r?En.has(r):!1,this._wantsFile=r?Tn.has(r):!1,this._wantsEverything=r===b.EVERYTHING_TYPE,this._root=(0,D.resolve)(s),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(s,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,s=t&&t.files;if(s&&s.length>0){let{path:r,depth:i}=t,a=s.splice(0,e).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let u=await this._getEntryType(c);u==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),e--)):(u==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(e,t){let s;try{s=await(0,A.readdir)(e,this._rdOptions)}catch(r){this._onError(r)}return{files:s,depth:t,path:e}}async _formatEntry(e,t){let s,r=this._isDirent?e.name:e;try{let i=(0,D.resolve)((0,D.join)(t,r));s={path:(0,D.relative)(this._root,i),fullPath:i,basename:r},s[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(i){this._onError(i);return}return s}_onError(e){Sn(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let t=e[this._statsProp];if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t&&t.isSymbolicLink()){let s=e.fullPath;try{let r=await(0,A.realpath)(s),i=await(0,A.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(s.startsWith(r)&&s.substr(a,1)===D.sep){let o=new Error(`Circular symlink detected: "${s}" points to "${r}"`);return o.code=Rt,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}}});function xt(n,e,t,s,r){let i=(a,o)=>{t(n),r(a,o,{watchedPath:n}),o&&n!==o&&re(g.resolve(n,o),H,g.join(n,o))};try{return(0,O.watch)(n,{persistent:e.persistent},i)}catch(a){s(a);return}}var O,x,g,Mt,Pn,Ye,At,ie,oe,Ke,vn,Rn,bn,Dt,w,L,Ln,xn,H,te,k,Mn,An,Dn,Ue,j,Cn,U,Ct,ne,re,Fn,je,Hn,se,Ft=de(()=>{"use strict";O=require("fs"),x=require("fs/promises"),g=v(require("path"),1),Mt=require("os"),Pn="data",Ye="end",At="close",ie=()=>{},oe=process.platform,Ke=oe==="win32",vn=oe==="darwin",Rn=oe==="linux",bn=oe==="freebsd",Dt=(0,Mt.type)()==="OS400",w={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},L=w,Ln="watch",xn={lstat:x.lstat,stat:x.stat},H="listeners",te="errHandlers",k="rawEmitters",Mn=[H,te,k],An=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Dn=n=>An.has(g.extname(n).slice(1).toLowerCase()),Ue=(n,e)=>{n instanceof Set?n.forEach(e):e(n)},j=(n,e,t)=>{let s=n[e];s instanceof Set||(n[e]=s=new Set([s])),s.add(t)},Cn=n=>e=>{let t=n[e];t instanceof Set?t.clear():delete n[e]},U=(n,e,t)=>{let s=n[e];s instanceof Set?s.delete(t):s===t&&delete n[e]},Ct=n=>n instanceof Set?n.size===0:!n,ne=new Map;re=(n,e,t,s,r)=>{let i=ne.get(n);i&&Ue(i[e],a=>{a(t,s,r)})},Fn=(n,e,t,s)=>{let{listener:r,errHandler:i,rawEmitter:a}=s,o=ne.get(e),c;if(!t.persistent)return c=xt(n,t,r,i,a),c?c.close.bind(c):void 0;if(o)j(o,H,r),j(o,te,i),j(o,k,a);else{if(c=xt(n,t,re.bind(null,e,H),i,re.bind(null,e,k)),!c)return;c.on(L.ERROR,async u=>{let l=re.bind(null,e,te);if(o&&(o.watcherUnusable=!0),Ke&&u.code==="EPERM")try{await(await(0,x.open)(n,"r")).close(),l(u)}catch{}else l(u)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},ne.set(e,o)}return()=>{U(o,H,r),U(o,te,i),U(o,k,a),Ct(o.listeners)&&(o.watcher.close(),ne.delete(e),Mn.forEach(Cn(o)),o.watcher=void 0,Object.freeze(o))}},je=new Map,Hn=(n,e,t,s)=>{let{listener:r,rawEmitter:i}=s,a=je.get(e),o=a&&a.options;return o&&(o.persistent<t.persistent||o.interval>t.interval)&&((0,O.unwatchFile)(e),a=void 0),a?(j(a,H,r),j(a,k,i)):(a={listeners:r,rawEmitters:i,options:t,watcher:(0,O.watchFile)(e,t,(c,u)=>{Ue(a.rawEmitters,d=>{d(L.CHANGE,e,{curr:c,prev:u})});let l=c.mtimeMs;(c.size!==u.size||l>u.mtimeMs||l===0)&&Ue(a.listeners,d=>d(n,c))})},je.set(e,a)),()=>{U(a,H,r),U(a,k,i),Ct(a.listeners)&&(je.delete(e),(0,O.unwatchFile)(e),a.options=a.watcher=void 0,Object.freeze(a))}},se=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let s=this.fsw.options,r=g.dirname(e),i=g.basename(e);this.fsw._getWatchedDir(r).add(i);let o=g.resolve(e),c={persistent:s.persistent};t||(t=ie);let u;if(s.usePolling){let l=s.interval!==s.binaryInterval;c.interval=l&&Dn(i)?s.binaryInterval:s.interval,u=Hn(e,o,c,{listener:t,rawEmitter:this.fsw._emitRaw})}else u=Fn(e,o,c,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return u}_handleFile(e,t,s){if(this.fsw.closed)return;let r=g.dirname(e),i=g.basename(e),a=this.fsw._getWatchedDir(r),o=t;if(a.has(i))return;let c=async(l,d)=>{if(this.fsw._throttle(Ln,e,5)){if(!d||d.mtimeMs===0)try{let f=await(0,x.stat)(e);if(this.fsw.closed)return;let h=f.atimeMs,S=f.mtimeMs;if((!h||h<=S||S!==o.mtimeMs)&&this.fsw._emit(L.CHANGE,e,f),(vn||Rn||bn)&&o.ino!==f.ino){this.fsw._closeFile(l),o=f;let P=this._watchWithNodeFs(e,c);P&&this.fsw._addPathCloser(l,P)}else o=f}catch{this.fsw._remove(r,i)}else if(a.has(i)){let f=d.atimeMs,h=d.mtimeMs;(!f||f<=h||h!==o.mtimeMs)&&this.fsw._emit(L.CHANGE,e,d),o=d}}},u=this._watchWithNodeFs(e,c);if(!(s&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(L.ADD,e,0))return;this.fsw._emit(L.ADD,e,t)}return u}async _handleSymlink(e,t,s,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,x.realpath)(s)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(L.CHANGE,s,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(L.ADD,s,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,s,r,i,a,o){if(e=g.join(e,""),o=this.fsw._throttle("readdir",e,1e3),!o)return;let c=this.fsw._getWatchedDir(s.path),u=new Set,l=this.fsw._readdirp(e,{fileFilter:d=>s.filterPath(d),directoryFilter:d=>s.filterDir(d)});if(l)return l.on(Pn,async d=>{if(this.fsw.closed){l=void 0;return}let f=d.path,h=g.join(e,f);if(u.add(f),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,e,h,f))){if(this.fsw.closed){l=void 0;return}(f===r||!r&&!c.has(f))&&(this.fsw._incrReadyCount(),h=g.join(i,g.relative(i,h)),this._addToNodeFs(h,t,s,a+1))}}).on(L.ERROR,this._boundHandleError),new Promise((d,f)=>{if(!l)return f();l.once(Ye,()=>{if(this.fsw.closed){l=void 0;return}let h=o?o.clear():!1;d(void 0),c.getChildren().filter(S=>S!==e&&!u.has(S)).forEach(S=>{this.fsw._remove(e,S)}),l=void 0,h&&this._handleRead(e,!1,s,r,i,a,o)})})}async _handleDir(e,t,s,r,i,a,o){let c=this.fsw._getWatchedDir(g.dirname(e)),u=c.has(g.basename(e));!(s&&this.fsw.options.ignoreInitial)&&!i&&!u&&this.fsw._emit(L.ADD_DIR,e,t),c.add(g.basename(e)),this.fsw._getWatchedDir(e);let l,d,f=this.fsw.options.depth;if((f==null||r<=f)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(e,s,a,i,e,r,l),this.fsw.closed))return;d=this._watchWithNodeFs(e,(h,S)=>{S&&S.mtimeMs===0||this._handleRead(h,!1,a,i,e,r,l)})}return d}async _addToNodeFs(e,t,s,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(e);s&&(o.filterPath=c=>s.filterPath(c),o.filterDir=c=>s.filterDir(c));try{let c=await xn[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let u=this.fsw.options.followSymlinks,l;if(c.isDirectory()){let d=g.resolve(e),f=u?await(0,x.realpath)(e):e;if(this.fsw.closed||(l=await this._handleDir(o.watchPath,c,t,r,i,o,f),this.fsw.closed))return;d!==f&&f!==void 0&&this.fsw._symlinkPaths.set(d,f)}else if(c.isSymbolicLink()){let d=u?await(0,x.realpath)(e):e;if(this.fsw.closed)return;let f=g.dirname(o.watchPath);if(this.fsw._getWatchedDir(f).add(o.watchPath),this.fsw._emit(L.ADD,o.watchPath,c),l=await this._handleDir(f,c,t,r,e,o,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(g.resolve(e),d)}else l=this._handleFile(o.watchPath,c,t);return a(),l&&this.fsw._addPathCloser(e,l),!1}catch(c){if(this.fsw._handleError(c))return a(),e}}}});var Ut={};Je(Ut,{FSWatcher:()=>Y,WatchHelper:()=>ce,default:()=>Gn,watch:()=>jt});function ae(n){return Array.isArray(n)?n:[n]}function $n(n){return typeof n=="function"?n:typeof n=="string"?e=>n===e:n instanceof RegExp?e=>n.test(e):typeof n=="object"&&n!==null?e=>{if(n.path===e)return!0;if(n.recursive){let t=m.relative(n.path,e);return t?!t.startsWith("..")&&!m.isAbsolute(t):!1}return!1}:()=>!1}function qn(n){if(typeof n!="string")throw new Error("string expected");n=m.normalize(n),n=n.replace(/\\/g,"/");let e=!1;n.startsWith("//")&&(e=!0);let t=/\/\//;for(;n.match(t);)n=n.replace(t,"/");return e&&(n="/"+n),n}function Ot(n,e,t){let s=qn(e);for(let r=0;r<n.length;r++){let i=n[r];if(i(s,t))return!0}return!1}function jn(n,e){if(n==null)throw new TypeError("anymatch: specify first argument");let s=ae(n).map(r=>$n(r));return e==null?(r,i)=>Ot(s,r,i):Ot(s,e)}function jt(n,e={}){let t=new Y(e);return t.add(n),t}var zt,le,Wt,m,Be,On,$t,In,kn,Nn,Ht,zn,Wn,Ge,It,kt,qt,Nt,Un,Yn,Ve,Kn,Bn,ce,Y,Gn,Yt=de(()=>{"use strict";zt=require("fs"),le=require("fs/promises"),Wt=require("events"),m=v(require("path"),1);Lt();Ft();Be="/",On="//",$t=".",In="..",kn="string",Nn=/\\/g,Ht=/\/\//,zn=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Wn=/^\.[/\\]/;Ge=n=>typeof n=="object"&&n!==null&&!(n instanceof RegExp);It=n=>{let e=ae(n).flat();if(!e.every(t=>typeof t===kn))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(qt)},kt=n=>{let e=n.replace(Nn,Be),t=!1;for(e.startsWith(On)&&(t=!0);e.match(Ht);)e=e.replace(Ht,Be);return t&&(e=Be+e),e},qt=n=>kt(m.normalize(kt(n))),Nt=(n="")=>e=>typeof e=="string"?qt(m.isAbsolute(e)?e:m.join(n,e)):e,Un=(n,e)=>m.isAbsolute(n)?n:m.join(e,n),Yn=Object.freeze(new Set),Ve=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==$t&&e!==In&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let s=this.path;try{await(0,le.readdir)(s)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(s),m.basename(s))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=ie,this.items=Yn,Object.freeze(this)}},Kn="stat",Bn="lstat",ce=class{constructor(e,t,s){this.fsw=s;let r=e;this.path=e=e.replace(Wn,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=t,this.statMethod=t?Kn:Bn}entryPath(e){return m.join(this.watchPath,m.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let s=this.entryPath(e);return this.fsw._isntIgnored(s,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Y=class extends Wt.EventEmitter{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,s={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?ae(e.ignored):ae([]),awaitWriteFinish:t===!0?s:typeof t=="object"?{...s,...t}:!1};Dt&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=ie,this._readyEmitted=!0,process.nextTick(()=>this.emit(w.READY)))},this._emitRaw=(...c)=>this.emit(w.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new se(this),Object.freeze(r)}_addIgnoredPath(e){if(Ge(e)){for(let t of this._ignoredPaths)if(Ge(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e=="string")for(let t of this._ignoredPaths)Ge(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,s){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=It(e);return r&&(i=i.map(a=>Un(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!s,void 0,0,t);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(t||o))})}),this}unwatch(e){if(this.closed)return this;let t=It(e),{cwd:s}=this.options;return t.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(s&&(r=m.join(s,r)),r=m.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(s=>{let r=s();r instanceof Promise&&e.push(r)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,s)=>{let i=(this.options.cwd?m.relative(this.options.cwd,s):s)||$t;e[i]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==w.ERROR&&this.emit(w.ALL,e,...t)}async _emit(e,t,s){if(this.closed)return;let r=this.options;Ke&&(t=m.normalize(t)),r.cwd&&(t=m.relative(r.cwd,t));let i=[t];s!=null&&i.push(s);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(t)))return o.lastChange=new Date,this;if(r.atomic){if(e===w.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,u)=>{this.emit(...c),this.emit(w.ALL,...c),this._pendingUnlinks.delete(u)})},typeof r.atomic=="number"?r.atomic:100),this;e===w.ADD&&this._pendingUnlinks.has(t)&&(e=w.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===w.ADD||e===w.CHANGE)&&this._readyEmitted){let c=(u,l)=>{u?(e=w.ERROR,i[0]=u,this.emitWithAll(e,i)):l&&(i.length>1?i[1]=l:i.push(l),this.emitWithAll(e,i))};return this._awaitWriteFinish(t,a.stabilityThreshold,e,c),this}if(e===w.CHANGE&&!this._throttle(w.CHANGE,t,50))return this;if(r.alwaysStat&&s===void 0&&(e===w.ADD||e===w.ADD_DIR||e===w.CHANGE)){let c=r.cwd?m.join(r.cwd,t):t,u;try{u=await(0,le.stat)(c)}catch{}if(!u||this.closed)return;i.push(u)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!=="ENOENT"&&t!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||t!=="EPERM"&&t!=="EACCES")&&this.emit(w.ERROR,e),e||this.closed}_throttle(e,t,s){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw new Error("invalid throttle");let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let u=r.get(t),l=u?u.count:0;return r.delete(t),clearTimeout(a),u&&clearTimeout(u.timeoutObject),l};a=setTimeout(o,s);let c={timeoutObject:a,clear:o,count:0};return r.set(t,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,s,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=e;this.options.cwd&&!m.isAbsolute(e)&&(c=m.join(this.options.cwd,e));let u=new Date,l=this._pendingWrites;function d(f){(0,zt.stat)(c,(h,S)=>{if(h||!l.has(e)){h&&h.code!=="ENOENT"&&r(h);return}let P=Number(new Date);f&&S.size!==f.size&&(l.get(e).lastChange=P);let E=l.get(e);P-E.lastChange>=t?(l.delete(e),r(void 0,S)):o=setTimeout(d,a,S)})}l.has(e)||(l.set(e,{lastChange:u,cancelWait:()=>(l.delete(e),clearTimeout(o),s)}),o=setTimeout(d,a))}_isIgnored(e,t){if(this.options.atomic&&zn.test(e))return!0;if(!this._userIgnored){let{cwd:s}=this.options,i=(this.options.ignored||[]).map(Nt(s)),o=[...[...this._ignoredPaths].map(Nt(s)),...i];this._userIgnored=jn(o,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new ce(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=m.resolve(e);return this._watched.has(t)||this._watched.set(t,new Ve(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,s){let r=m.join(e,t),i=m.resolve(r);if(s=s??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!s&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(f=>this._remove(r,f));let c=this._getWatchedDir(e),u=c.has(t);c.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let l=r;if(this.options.cwd&&(l=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(l)&&this._pendingWrites.get(l).cancelWait()===w.ADD)return;this._watched.delete(r),this._watched.delete(i);let d=s?w.UNLINK_DIR:w.UNLINK;u&&!this._isIgnored(r)&&this._emit(d,r),this._closePath(r)}_closePath(e){this._closeFile(e);let t=m.dirname(e);this._getWatchedDir(t).remove(m.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(s=>s()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let s=this._closers.get(e);s||(s=[],this._closers.set(e,s)),s.push(t)}_readdirp(e,t){if(this.closed)return;let s={type:w.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=bt(e,s);return this._streams.add(r),r.once(At,()=>{r=void 0}),r.once(Ye,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};Gn={watch:jt,FSWatcher:Y}});var Vn={};Je(Vn,{TSFilebasedRouter:()=>Kt,TSRouter:()=>ee,createClientFunc:()=>rt,createSignal:()=>ke,createTSServerFunc:()=>nt,html:()=>he,initializeRoute:()=>Bt,loadPyFiles:()=>Ce,mapper:()=>tt,renderChildRoutes:()=>Ae,useAnchor:()=>$,useAnchorSingle:()=>ve,useInitialDOM:()=>_e,useTSAuth:()=>Le,useTSCollection:()=>be,useTSComponent:()=>W,useTSElementEach:()=>X,useTSElements:()=>Te,useTSEvent:()=>ge,useTSEventAll:()=>we,useTSExtractParams:()=>ye,useTSLazy:()=>Fe,useTSMetaData:()=>Re,useTSNavigate:()=>xe,useTSNoReload:()=>Ie,useTSOutlet:()=>Me,useTSParams:()=>z,useTSPurifier:()=>pe,useTSQuery:()=>Z,useTSReactor:()=>Ne,useTSSSRHydration:()=>He,useTSSelect:()=>I,useTSloadBrython:()=>De});module.exports=tn(Vn);var et=v(require("dompurify"),1),fe=null;function nn(){return typeof window>"u"?null:(fe||(fe=(0,et.default)(window)),fe)}var rn=["div","span","p","a","button","ul","li","img","input","form","label","h1","h2","h3","h4","h5","h6","section","main","article","svg","path","circle","rect","line","polyline","polygon","g"],sn=["class","id","href","src","alt","title","type","value","name","placeholder","target","rel","data-click","data-change","data-select","data-effect","data-hover","data-submit","data-key","data-event","data-component","data-stagger","data-input"];function on(n){return/^(https?:\/\/|\/|#)/i.test(n.trim())}function an(n){if(typeof window>"u")return n;let e=document.createElement("template");return e.innerHTML=n,e.content.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(s=>{let r=s.name.toLowerCase();if(r.startsWith("on")||r.startsWith("xlink")||r.startsWith("xml")){t.removeAttribute(s.name);return}(r==="href"||r==="src")&&!on(s.value)&&t.setAttribute(r,"#")}),t.tagName==="A"&&t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer")}),e.innerHTML}function he(n,...e){let t=nn(),s=n.reduce((i,a,o)=>{let c=o<e.length?String(e[o]??""):"";return i+a+c},"");if(!t)return s;let r=t.sanitize(s,{ALLOWED_TAGS:rn,ALLOWED_ATTR:sn,RETURN_DOM:!1});return an(r)}var tt=(n,e)=>n.reduce((t,s,r)=>t+e(s,r),"");function nt(n){return n}function rt(n){return new Proxy({},{get(e,t){return async s=>n(t,s)}})}var me=v(require("dompurify"),1),pe=(n,e)=>{let s={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof n=="string"?me.default.sanitize(n,s):me.default.sanitize(n.innerHTML,s)};var ge=(n,e,t)=>{if(!(typeof window>"u"||typeof document>"u"))if(typeof n=="string"){let s=document.getElementById(n);s?s.addEventListener(e,t):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(e,t):n===document?document.addEventListener(e,t):console.warn("Invalid target parameter provided.")};var st=require("zustand/vanilla"),it=v(require("dompurify"),1);function V(n){return it.default.sanitize(n??"")}function G(n,e){let t=Object.keys(n),s=Object.keys(e);if(t.length!==s.length)return!1;for(let r of t)if(n[r]!==e[r])return!1;return!0}function cn(n,e){let t=[],s=n.replace(/:[^/]+/g,o=>(t.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${s}$`),i=e.match(r),a={};return i&&t.forEach((o,c)=>{a[o]=V(i[c+1]??"")}),a}function ln(n){let e={},t=new URLSearchParams(n);for(let[s,r]of t.entries())e[s]=V(r);return e}var z=(0,st.createStore)((n,e)=>({params:{},query:{},setFromPattern:t=>{let s=window.location.pathname,r=cn(t,s),i=ln(window.location.search),a=e();(!G(a.params,r)||!G(a.query,i))&&n({params:r,query:i})},setFromPatternValues:(t,s)=>{let r={};t.forEach((a,o)=>{r[a]=V(s[o]??"")});let i=e();G(i.params,r)||n({params:r})},setQuery:t=>{let s={};for(let i in t)s[i]=V(t[i]);let r=e();G(r.query,s)||n({query:s})},getParam:t=>e().params[t],getQuery:t=>e().query[t]}));function ye(n){let e=z.getState();e.setFromPattern(n);let t=e.params,s=e.query;return{...t,...s}}var we=(n,e,t)=>{let s=document.querySelectorAll(n);return s.forEach(r=>{r.addEventListener(e,t)}),()=>{s.forEach(r=>{r.removeEventListener(e,t)})}};var ut=require("motion"),dt=v(require("dompurify"),1),Ee=typeof window<"u"&&typeof document<"u",ot=["div","span","p","a","button","ul","li","img","input","form","label","h1","h2","h3","h4","h5","h6","section","main","article"],at=["class","id","href","src","alt","title","type","value","name","placeholder","data-click","data-change","data-select","data-effect","data-hover","data-submit","data-key","data-event","data-component","data-stagger","data-input","data-children","data-slot","target","rel"],ct=Ee?(0,dt.default)(window):{sanitize:(n,e)=>n};function un(n){return/^(https?:\/\/|\/|#)/i.test(n.trim())}function dn(n){Ee&&n.querySelectorAll("*").forEach(e=>{[...e.attributes].forEach(t=>{let s=t.name.toLowerCase();if(s.startsWith("on")){e.removeAttribute(t.name);return}(s==="href"||s==="src")&&!un(t.value)&&e.setAttribute(s,"#")}),e.tagName==="A"&&e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")})}function lt(n){let e={},t={},s=400,r=0,i="ease-in-out",a=0,o=!1,c,u;return n.split(/\s+/).forEach(l=>{l==="fade-in"&&(e.opacity=0,t.opacity=1),l==="fade-out"&&(e.opacity=1,t.opacity=0),l==="slide-up"&&(e.y=20,t.y=0),l==="slide-down"&&(e.y=-20,t.y=0),l==="slide-left"&&(e.x=20,t.x=0),l==="slide-right"&&(e.x=-20,t.x=0),l.startsWith("duration-")&&(s=+l.replace("duration-","")),l.startsWith("delay-")&&(r=+l.replace("delay-","")),(l==="linear"||l.startsWith("ease"))&&(i=l),l==="infinite"&&(a=1/0),l==="replay"&&(o=!0),l.startsWith("parallax-y-")&&(c=+l.replace("parallax-y-","")),l.startsWith("parallax-x-")&&(u=+l.replace("parallax-x-",""))}),{from:e,to:t,duration:s,easing:i,delay:r,repeat:a,replay:o,parallaxY:c,parallaxX:u}}function fn(n,e){n.querySelectorAll("[data-component]").forEach(t=>{let s=t.dataset.component;e[s]?.(t)})}var Te=(n,e,t={},s)=>{if(!Ee||!n)return{html:ct.sanitize(e,{ALLOWED_TAGS:ot,ALLOWED_ATTR:at,...s})};let r=ct.sanitize(e,{ALLOWED_TAGS:ot,ALLOWED_ATTR:at,...s});n.innerHTML=r,dn(n);let i=l=>{let d=l.target.closest("[data-click]");d&&t[d.dataset.click]?.(d)};n.addEventListener("click",i),n.querySelectorAll("[data-input]").forEach(l=>{let d=l.dataset.input;t[d]?.(l),l.addEventListener("input",()=>{t[d]?.(l)})}),fn(n,t);let a=[];n.querySelectorAll("[data-effect]").forEach(l=>{let d=lt(l.dataset.effect||"");(d.parallaxX||d.parallaxY)&&a.push({el:l,...d})});let o=!1,c=()=>{o||(o=!0,requestAnimationFrame(()=>{let l=window.scrollY;a.forEach(({el:d,parallaxX:f,parallaxY:h})=>{d.style.transform=`translate3d(${(f||0)*l}px, ${(h||0)*l}px, 0)`}),o=!1}))};window.addEventListener("scroll",c);let u=new IntersectionObserver(l=>{l.forEach(d=>{let f=d.target,h=lt(f.dataset.effect||"");d.isIntersecting?(Object.assign(f.style,h.from),setTimeout(()=>{(0,ut.animate)(f,h.to,{duration:h.duration/1e3,easing:h.easing,repeat:h.repeat})},h.delay),h.replay||u.unobserve(f)):h.replay&&Object.assign(f.style,h.from)})});return n.querySelectorAll("[data-effect]").forEach(l=>u.observe(l)),{cleanup(){u.disconnect(),window.removeEventListener("scroll",c),n.removeEventListener("click",i)}}};var Se=v(require("dompurify"),1),Q=null,_e=(n,e)=>{if(typeof document>"u")return;let t=document.getElementById(n);if(!t)return;Se.default.addHook("uponSanitizeAttribute",(a,o)=>{let c=(o.attrName||"").toLowerCase(),u=(o.attrValue??"").toString().trim();if(c.startsWith("on")){o.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(u)){o.keepAttr=!1;return}if(c==="class"){let d=u.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let h=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return h===""||/^https?:\/\//i.test(h)||/^\/(?!\/)/.test(h)||/^\.{0,2}\//.test(h)}return!0}return!1});o.attrValue=d.join(" ");return}if(c==="style"){o.keepAttr=!1;return}});let s=t.cloneNode(!0),r=Se.default.sanitize(s.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(r.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(Q!==null&&i!==Q){let a=document.createElement("div");e(a);let c=new DOMParser().parseFromString(Q,"text/html");for(;t.firstChild;)t.removeChild(t.firstChild);c.body.childNodes.forEach(u=>t.appendChild(u.cloneNode(!0)))}else{for(Q=i;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(r),e(t)}};var Pe=v(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let e=n.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var ve=(n,e,t,s="",r=null)=>{if(!n)return;let i=Pe.default.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Pe.default.sanitize(t,{USE_PROFILES:{html:!1}});n.setAttribute("href",i),n.setAttribute("aria-label",a),s&&(n.className=s.trim()),r&&n.replaceChildren(r),typeof window<"u"&&n.addEventListener("click",o=>{o.preventDefault();let u=o.currentTarget.getAttribute("href");if(u){let l=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:l},"",u),dispatchEvent(new PopStateEvent("popstate"))}})};var M=v(require("dompurify"),1);var ft=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",t="'none'",s="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",u=!1)=>{let l=()=>{try{let d=document.querySelector('meta[http-equiv="Content-Security-Policy"]');d||(d=document.createElement("meta"),d.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(d));let f=u?`report-uri ${c};`:"";d.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${e}; object-src ${t}; font-src ${s}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${f}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l):l()};var Re=(n,e)=>{let t={name:M.default.sanitize(n.name||""),title:M.default.sanitize(n.title||""),description:M.default.sanitize(n.description||"Default description"),author:M.default.sanitize(n.author||""),favicon:n.favicon},s=p=>{t.name=M.default.sanitize(p),P("name",t.name)},r=p=>{t.title=M.default.sanitize(p),document.title=t.title},i=p=>{t.description=M.default.sanitize(p),P("description",t.description)},a=p=>{t.author=M.default.sanitize(p),P("author",t.author)},o=p=>{t.favicon=M.default.sanitize(p);let T=document.querySelector('link[rel="icon"]');T||(T=document.createElement("link"),T.rel="icon",document.head.appendChild(T)),T.href=t.favicon},c=()=>t.name,u=()=>t.title,l=()=>t.description,d=()=>t.author,f=()=>t.favicon,h=()=>t,S=(p,T)=>{let R=document.createElement("meta");R.setAttribute("name",p),R.setAttribute("content",T),document.head.appendChild(R)},P=(p,T)=>{let R=document.querySelector(`meta[name="${p}"]`);R?R.setAttribute("content",T):S(p,T)},E=()=>{t.title&&(document.title=t.title),t.name&&P("name",t.name),t.description&&P("description",t.description),t.author&&P("author",t.author),t.favicon&&o(t.favicon)};return e&&ft(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),E(),{setName:s,setTitle:r,setDescription:i,setAuthor:a,setFavicon:o,getName:c,getTitle:u,getDescription:l,getAuthor:d,getFavicon:f,getAllMetaData:h,appendMetaTagsToHead:E}};var ht=v(require("dompurify"),1),W=(n,e,t,s,r)=>{let i=`#${n}`,a=e.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${n}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${n}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=ht.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),t(o,s,r)};var be=(n,e,t,s=[])=>{let r=new Set;n.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=e.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=t[a],u=Array.isArray(s)?s[a]:void 0;typeof c=="function"?W(i,e,c,u):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var I=(n,e)=>{let s=(e??document).querySelectorAll(n);if(s.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${n}'`),null;if(n.startsWith("#")&&s.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${n}'. Found ${s.length} elements with this ID.`);return s[0]}return s.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${n}'. Returning the first one.`),s[0]};var mt=require("jwt-decode"),Le=(n,e)=>{let t=localStorage.getItem("token");if(!t)return window.location.href=e,null;try{let s=(0,mt.jwtDecode)(t),r=Date.now()/1e3;return s.exp&&s.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=e),null}catch(s){return console.error("Invalid token:",s),window.location.href=e,null}};var X=(n,e,t)=>{n.forEach(s=>{e.forEach(r=>{s.addEventListener(r,i=>{t(s,i)})})})};var xe=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Me=(n,e)=>{let t=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!t)return;let s=window.location.pathname.replace(/\/$/,"");for(let r of e){let i=r.path.replace(/\/$/,"");if(s===i||s.startsWith(`${i}/`)){r.component(t);break}}};function Ae(n,e){let t=window.location.pathname.replace(/\/$/,"");e.routes.forEach(s=>{s.children?.length&&s.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(t===i||t.startsWith(`${i}/`)){let a=n.querySelector(`#${r.outlet}`)||n.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var De=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",t=s=>new Promise((r,i)=>{let a=document.createElement("script");a.src=s,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${s}`)),document.head.appendChild(a)});await t(n),await t(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Ce=n=>new Promise((e,t)=>{let s=document.createElement("script");s.type="text/python",s.src=`/src/python/${n}`,s.onload=()=>e(),s.onerror=()=>t(new Error(`Failed to load ${n}`)),document.body.appendChild(s)});function Fe(n){let e=null;return async(t,s)=>{try{if(!e){let r=await n();e=r.default||r}if(typeof e=="function")return e(t,s);if(e instanceof HTMLElement){let r=e.cloneNode(!0);return t?.appendChild(r),r}if(typeof e=="object"&&e!==null&&"render"in e&&typeof e.render=="function")return e.render(t,s);console.warn("useTSLazy: Unsupported module type",e)}catch(r){console.error("useTSLazy failed:",r)}}}var He=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};var pt=require("lodash-es"),Oe=n=>n;typeof window<"u"&&typeof document<"u"&&(Oe=n=>{let e=document.createElement("div");return e.innerText=n,e.innerHTML});var hn=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(t=>{if(!t||t.dataset.anchorEnhanced==="true")return;t.dataset.anchorEnhanced="true";let s=t.getAttribute("class")||"";t.setAttribute("class",Oe(s));let r=t.getAttribute("aria-label");r&&t.setAttribute("aria-label",Oe(r));let i=t.querySelector(":scope > *");i&&(t.innerHTML="",t.appendChild(i));let a=t.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}t.addEventListener("click",o=>{o.preventDefault();let c=t.getAttribute("href")||"";try{let u=new URL(c,window.location.href);window.history.pushState({},"",u.pathname+u.search+u.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(u){console.error("Invalid URL in anchor:",c,u)}})}})},mn=(0,pt.debounce)(hn,50),$=n=>{mn(n)};var Ie=n=>{if(!n)return;let e=I("a",n);$(e)};var gt=n=>{let e=n,t=[];return[()=>e,a=>{e=typeof a=="function"?a(e):a,t.forEach(o=>o(e))},a=>{t.push(a),a(e)}]};function yt(n,e,t){let s=()=>{n.textContent=e().toString(),t?.(e())};s();let r=e.set;r&&(e.set=i=>{r(i),s()})}function ke(n){let[e,t,s]=gt(n),r=[],i=(()=>e());return i.set=a=>{t(a),r.forEach(o=>o(i()))},i.bind=a=>yt(a,i),i.subscribe=a=>{r.push(a),a(i())},i}function Ne(n,e){let t={deps:e.map(r=>typeof r=="function"?r():r)},s=n();typeof s=="function"&&(t.cleanup=s),e.forEach((r,i)=>{typeof r=="function"&&"bind"in r&&r.subscribe?.(()=>{let o=r(),c=t.deps[i];if(o!==c){t.cleanup?.(),t.deps[i]=o;let u=n();typeof u=="function"&&(t.cleanup=u)}})})}var y={params:{},query:{}},ze=new Set;function pn(){return{params:{...y.params},query:{...y.query}}}function q(n,e){let t=Object.keys(n),s=Object.keys(e);if(t.length!==s.length)return!1;for(let r of t)if(n[r]!==e[r])return!1;return!0}function F(){let n=pn();ze.forEach(e=>e(n))}function gn(n){let e={};if(!n)return e;let t=n.startsWith("?")?n.slice(1):n;for(let s of t.split("&")){if(!s)continue;let[r,i]=s.split("=");r&&(e[decodeURIComponent(r)]=decodeURIComponent(i||""))}return e}function yn(n){let e=new URLSearchParams;for(let s in n){let r=n[s];r!=null&&r!==""&&e.set(s,r)}let t=e.toString();return t?`?${t}`:""}function J(){if(typeof window>"u")return;let n=window.location.pathname,e=window.location.hash,t=yn(y.query);history.replaceState({},"",n+t+e)}var Z={getState(){return{params:y.params,query:y.query,getParam:n=>y.params[n],getQuery:n=>y.query[n],setFromPattern(n){if(typeof window>"u")return;let e=n.match(/:([^/]+)/g)?.map(r=>r.slice(1))||[],t=window.location.pathname.split("/").filter(Boolean),s={};e.forEach((r,i)=>{s[r]=t[i]}),q(y.params,s)||(y.params=s,F())},setFromPatternValues(n,e){let t={};n.forEach((s,r)=>{t[s]=e[r]}),q(y.params,t)||(y.params=t,F())},setQuery(n){let e={...y.query,...n};q(y.query,e)||(y.query=e,J(),F())},replaceQuery(n){q(y.query,n)||(y.query={...n},J(),F())},removeQuery(n){if(!(n in y.query))return;let e={...y.query};delete e[n],y.query=e,J(),F()},clearQuery(){Object.keys(y.query).length!==0&&(y.query={},J(),F())},setQueryFromURL(n){let e=gn(n);q(y.query,e)||(y.query=e,F())},subscribe(n){return ze.add(n),()=>ze.delete(n)}}}};typeof window<"u"&&window.addEventListener("popstate",()=>{Z.getState().setQueryFromURL(window.location.search)});var We=v(require("dompurify"),1);var Et=require("zustand/vanilla"),Tt=v(require("dompurify"),1),C=(0,Et.createStore)(n=>({params:{},query:{},setParams:e=>n(()=>({params:wt(e)})),setQuery:e=>n(()=>({query:wt(e)}))}));function wt(n){let e={};for(let t in n)e[t]=Tt.default.sanitize(n[t]);return e}var ee=class{routes=[];expectedParams;apiFetcher;constructor(e,t,s){this.routes=e,this.expectedParams=new Set(t),this.apiFetcher=s,window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,t=window.location.search,s=this.parseQueryParams(t);if(e.startsWith("/api")&&this.apiFetcher){let a=e.replace("/api/","").split("/")[0],o=Object.fromEntries(new URLSearchParams(t));this.apiFetcher(a,o).then(c=>console.log("API response:",c)).catch(c=>console.error("API error:",c));return}let r=this.findMatchingRoute(e,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);C.getState().setParams(i),C.getState().setQuery(s);let a=document.createElement("div");if(r.element?.(a,i,s),r.children){let o=e.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,s)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);C.getState().setParams(a),C.getState().setQuery(s);let o=document.createElement("div");i.element?.(o,a,s)}}}renderChildren(e,t,s,r,i){if(!e||e.length===0){let o=s.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(t,e);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},u=this.filterAndSanitizeParams(c);if(C.getState().setParams(u),C.getState().setQuery(i),a.element?.(o,u,i),s.appendChild(o),a.children){let l=t.slice(a.path.length);this.renderChildren(a.children,l,o,u,i)}}}parseQueryParams(e){let t={},s=new URLSearchParams(e);for(let[r,i]of s.entries())this.expectedParams.has(r)&&(t[r]=We.default.sanitize(i));return t}findMatchingRoute(e,t,s={}){for(let r of t){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,d=>(o.push(d.substring(1)),"([^\\s/]+)")),u=new RegExp(`^${c}(?:/|$)`),l=e.match(u);if(l){let d={...s};if(o.forEach((f,h)=>{d[f]=l[h+1]??""}),r.children){let f=e.slice(l[0].length),h=this.findMatchingRoute(f,r.children,d);if(h)return h}return{...r,params:d}}}}}filterAndSanitizeParams(e){if(!e)return{};let t={};for(let s in e)this.expectedParams.has(s)&&(t[s]=We.default.sanitize(e[s]??""));return t}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Kt=()=>({name:"ts-filebased-router",async buildStart(){let n=await import("fs/promises"),e=await import("path"),t=await Promise.resolve().then(()=>(Yt(),Ut)),s=e.resolve("src/pages"),r=e.resolve("src/gen"),i=e.resolve("src/routes"),a=e.join(r,"tsrouter.gen.ts"),o=e.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production",u=async E=>n.mkdir(E,{recursive:!0}).catch(()=>{}),l=E=>E.charAt(0).toUpperCase()+E.slice(1),d=E=>{let p="/"+e.relative(s,E).replace(/\\/g,"/");return p=p.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",p.replace(/\[\.\.\.(.+?)\]/g,"*").replace(/\[(.+?)\]/g,":$1")},f=E=>E.replace(/^\//,"").split("/").map(p=>p.startsWith(":")?l(p.slice(1)):p.replace(/\b\w/g,T=>T.toUpperCase()).replace(/[-_]/g,"")).filter(Boolean).join("")||"Index",h=async E=>{let p=await n.readdir(E,{withFileTypes:!0}),T=[];for(let R of p){let N=e.join(E,R.name);R.isDirectory()?T.push(...await h(N)):R.isFile()&&R.name.endsWith(".ts")&&T.push({file:N,route:d(N),name:f(d(N))})}return T},S=async()=>{let E=await h(s),p=E.find(_=>_.route==="/notfound"),T=E.filter(_=>_.route!=="/notfound");for(let _ of E)if(!(await n.readFile(_.file,"utf-8")).trim()){let K=_.route.includes(":"),Xe=K?_.route.split("/").filter(ue=>ue.startsWith(":")).map(ue=>ue.slice(1)):[],Vt=K?`const { ${Xe.join(", ")} } = useTSExtractParams("${_.route}");`:"";await n.writeFile(_.file,`import { html, useTSElements, useTSMetaData${K?", useTSExtractParams":""} } from "@devwaren/vanilla-ts";
|
|
1
|
+
"use strict";var Qt=Object.create;var B=Object.defineProperty;var Xt=Object.getOwnPropertyDescriptor;var Jt=Object.getOwnPropertyNames;var Zt=Object.getPrototypeOf,en=Object.prototype.hasOwnProperty;var de=(n,e)=>()=>(n&&(e=n(n=0)),e);var Je=(n,e)=>{for(var t in e)B(n,t,{get:e[t],enumerable:!0})},Ze=(n,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Jt(e))!en.call(n,r)&&r!==t&&B(n,r,{get:()=>e[r],enumerable:!(s=Xt(e,r))||s.enumerable});return n};var v=(n,e,t)=>(t=n!=null?Qt(Zt(n)):{},Ze(e||!n||!n.__esModule?B(t,"default",{value:n,enumerable:!0}):t,n)),tn=n=>Ze(B({},"__esModule",{value:!0}),n);function bt(n,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=b.FILE_DIR_TYPE),t&&(e.type=t),n){if(typeof n!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!St.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${St.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=n,new qe(e)}var A,vt,D,b,$e,Rt,wn,St,En,Tn,Sn,_n,_t,Pt,qe,Lt=de(()=>{"use strict";A=require("fs/promises"),vt=require("stream"),D=require("path"),b={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},$e={root:".",fileFilter:n=>!0,directoryFilter:n=>!0,type:b.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze($e);Rt="READDIRP_RECURSIVE_ERROR",wn=new Set(["ENOENT","EPERM","EACCES","ELOOP",Rt]),St=[b.DIR_TYPE,b.EVERYTHING_TYPE,b.FILE_DIR_TYPE,b.FILE_TYPE],En=new Set([b.DIR_TYPE,b.EVERYTHING_TYPE,b.FILE_DIR_TYPE]),Tn=new Set([b.EVERYTHING_TYPE,b.FILE_DIR_TYPE,b.FILE_TYPE]),Sn=n=>wn.has(n.code),_n=process.platform==="win32",_t=n=>!0,Pt=n=>{if(n===void 0)return _t;if(typeof n=="function")return n;if(typeof n=="string"){let e=n.trim();return t=>t.basename===e}if(Array.isArray(n)){let e=n.map(t=>t.trim());return t=>e.some(s=>t.basename===s)}return _t},qe=class extends vt.Readable{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...$e,...e},{root:s,type:r}=t;this._fileFilter=Pt(t.fileFilter),this._directoryFilter=Pt(t.directoryFilter);let i=t.lstat?A.lstat:A.stat;_n?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=t.depth??$e.depth,this._wantsDir=r?En.has(r):!1,this._wantsFile=r?Tn.has(r):!1,this._wantsEverything=r===b.EVERYTHING_TYPE,this._root=(0,D.resolve)(s),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(s,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,s=t&&t.files;if(s&&s.length>0){let{path:r,depth:i}=t,a=s.splice(0,e).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let u=await this._getEntryType(c);u==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),e--)):(u==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(e,t){let s;try{s=await(0,A.readdir)(e,this._rdOptions)}catch(r){this._onError(r)}return{files:s,depth:t,path:e}}async _formatEntry(e,t){let s,r=this._isDirent?e.name:e;try{let i=(0,D.resolve)((0,D.join)(t,r));s={path:(0,D.relative)(this._root,i),fullPath:i,basename:r},s[this._statsProp]=this._isDirent?e:await this._stat(i)}catch(i){this._onError(i);return}return s}_onError(e){Sn(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let t=e[this._statsProp];if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t&&t.isSymbolicLink()){let s=e.fullPath;try{let r=await(0,A.realpath)(s),i=await(0,A.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(s.startsWith(r)&&s.substr(a,1)===D.sep){let o=new Error(`Circular symlink detected: "${s}" points to "${r}"`);return o.code=Rt,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}}});function xt(n,e,t,s,r){let i=(a,o)=>{t(n),r(a,o,{watchedPath:n}),o&&n!==o&&re(g.resolve(n,o),H,g.join(n,o))};try{return(0,O.watch)(n,{persistent:e.persistent},i)}catch(a){s(a);return}}var O,x,g,Mt,Pn,Ye,At,ie,oe,Ke,vn,Rn,bn,Dt,w,L,Ln,xn,H,te,N,Mn,An,Dn,Ue,j,Cn,U,Ct,ne,re,Fn,je,Hn,se,Ft=de(()=>{"use strict";O=require("fs"),x=require("fs/promises"),g=v(require("path"),1),Mt=require("os"),Pn="data",Ye="end",At="close",ie=()=>{},oe=process.platform,Ke=oe==="win32",vn=oe==="darwin",Rn=oe==="linux",bn=oe==="freebsd",Dt=(0,Mt.type)()==="OS400",w={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},L=w,Ln="watch",xn={lstat:x.lstat,stat:x.stat},H="listeners",te="errHandlers",N="rawEmitters",Mn=[H,te,N],An=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Dn=n=>An.has(g.extname(n).slice(1).toLowerCase()),Ue=(n,e)=>{n instanceof Set?n.forEach(e):e(n)},j=(n,e,t)=>{let s=n[e];s instanceof Set||(n[e]=s=new Set([s])),s.add(t)},Cn=n=>e=>{let t=n[e];t instanceof Set?t.clear():delete n[e]},U=(n,e,t)=>{let s=n[e];s instanceof Set?s.delete(t):s===t&&delete n[e]},Ct=n=>n instanceof Set?n.size===0:!n,ne=new Map;re=(n,e,t,s,r)=>{let i=ne.get(n);i&&Ue(i[e],a=>{a(t,s,r)})},Fn=(n,e,t,s)=>{let{listener:r,errHandler:i,rawEmitter:a}=s,o=ne.get(e),c;if(!t.persistent)return c=xt(n,t,r,i,a),c?c.close.bind(c):void 0;if(o)j(o,H,r),j(o,te,i),j(o,N,a);else{if(c=xt(n,t,re.bind(null,e,H),i,re.bind(null,e,N)),!c)return;c.on(L.ERROR,async u=>{let l=re.bind(null,e,te);if(o&&(o.watcherUnusable=!0),Ke&&u.code==="EPERM")try{await(await(0,x.open)(n,"r")).close(),l(u)}catch{}else l(u)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},ne.set(e,o)}return()=>{U(o,H,r),U(o,te,i),U(o,N,a),Ct(o.listeners)&&(o.watcher.close(),ne.delete(e),Mn.forEach(Cn(o)),o.watcher=void 0,Object.freeze(o))}},je=new Map,Hn=(n,e,t,s)=>{let{listener:r,rawEmitter:i}=s,a=je.get(e),o=a&&a.options;return o&&(o.persistent<t.persistent||o.interval>t.interval)&&((0,O.unwatchFile)(e),a=void 0),a?(j(a,H,r),j(a,N,i)):(a={listeners:r,rawEmitters:i,options:t,watcher:(0,O.watchFile)(e,t,(c,u)=>{Ue(a.rawEmitters,d=>{d(L.CHANGE,e,{curr:c,prev:u})});let l=c.mtimeMs;(c.size!==u.size||l>u.mtimeMs||l===0)&&Ue(a.listeners,d=>d(n,c))})},je.set(e,a)),()=>{U(a,H,r),U(a,N,i),Ct(a.listeners)&&(je.delete(e),(0,O.unwatchFile)(e),a.options=a.watcher=void 0,Object.freeze(a))}},se=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let s=this.fsw.options,r=g.dirname(e),i=g.basename(e);this.fsw._getWatchedDir(r).add(i);let o=g.resolve(e),c={persistent:s.persistent};t||(t=ie);let u;if(s.usePolling){let l=s.interval!==s.binaryInterval;c.interval=l&&Dn(i)?s.binaryInterval:s.interval,u=Hn(e,o,c,{listener:t,rawEmitter:this.fsw._emitRaw})}else u=Fn(e,o,c,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return u}_handleFile(e,t,s){if(this.fsw.closed)return;let r=g.dirname(e),i=g.basename(e),a=this.fsw._getWatchedDir(r),o=t;if(a.has(i))return;let c=async(l,d)=>{if(this.fsw._throttle(Ln,e,5)){if(!d||d.mtimeMs===0)try{let f=await(0,x.stat)(e);if(this.fsw.closed)return;let h=f.atimeMs,S=f.mtimeMs;if((!h||h<=S||S!==o.mtimeMs)&&this.fsw._emit(L.CHANGE,e,f),(vn||Rn||bn)&&o.ino!==f.ino){this.fsw._closeFile(l),o=f;let P=this._watchWithNodeFs(e,c);P&&this.fsw._addPathCloser(l,P)}else o=f}catch{this.fsw._remove(r,i)}else if(a.has(i)){let f=d.atimeMs,h=d.mtimeMs;(!f||f<=h||h!==o.mtimeMs)&&this.fsw._emit(L.CHANGE,e,d),o=d}}},u=this._watchWithNodeFs(e,c);if(!(s&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(L.ADD,e,0))return;this.fsw._emit(L.ADD,e,t)}return u}async _handleSymlink(e,t,s,r){if(this.fsw.closed)return;let i=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,x.realpath)(s)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(L.CHANGE,s,e.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(L.ADD,s,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(e,t,s,r,i,a,o){if(e=g.join(e,""),o=this.fsw._throttle("readdir",e,1e3),!o)return;let c=this.fsw._getWatchedDir(s.path),u=new Set,l=this.fsw._readdirp(e,{fileFilter:d=>s.filterPath(d),directoryFilter:d=>s.filterDir(d)});if(l)return l.on(Pn,async d=>{if(this.fsw.closed){l=void 0;return}let f=d.path,h=g.join(e,f);if(u.add(f),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,e,h,f))){if(this.fsw.closed){l=void 0;return}(f===r||!r&&!c.has(f))&&(this.fsw._incrReadyCount(),h=g.join(i,g.relative(i,h)),this._addToNodeFs(h,t,s,a+1))}}).on(L.ERROR,this._boundHandleError),new Promise((d,f)=>{if(!l)return f();l.once(Ye,()=>{if(this.fsw.closed){l=void 0;return}let h=o?o.clear():!1;d(void 0),c.getChildren().filter(S=>S!==e&&!u.has(S)).forEach(S=>{this.fsw._remove(e,S)}),l=void 0,h&&this._handleRead(e,!1,s,r,i,a,o)})})}async _handleDir(e,t,s,r,i,a,o){let c=this.fsw._getWatchedDir(g.dirname(e)),u=c.has(g.basename(e));!(s&&this.fsw.options.ignoreInitial)&&!i&&!u&&this.fsw._emit(L.ADD_DIR,e,t),c.add(g.basename(e)),this.fsw._getWatchedDir(e);let l,d,f=this.fsw.options.depth;if((f==null||r<=f)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(e,s,a,i,e,r,l),this.fsw.closed))return;d=this._watchWithNodeFs(e,(h,S)=>{S&&S.mtimeMs===0||this._handleRead(h,!1,a,i,e,r,l)})}return d}async _addToNodeFs(e,t,s,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(e);s&&(o.filterPath=c=>s.filterPath(c),o.filterDir=c=>s.filterDir(c));try{let c=await xn[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let u=this.fsw.options.followSymlinks,l;if(c.isDirectory()){let d=g.resolve(e),f=u?await(0,x.realpath)(e):e;if(this.fsw.closed||(l=await this._handleDir(o.watchPath,c,t,r,i,o,f),this.fsw.closed))return;d!==f&&f!==void 0&&this.fsw._symlinkPaths.set(d,f)}else if(c.isSymbolicLink()){let d=u?await(0,x.realpath)(e):e;if(this.fsw.closed)return;let f=g.dirname(o.watchPath);if(this.fsw._getWatchedDir(f).add(o.watchPath),this.fsw._emit(L.ADD,o.watchPath,c),l=await this._handleDir(f,c,t,r,e,o,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(g.resolve(e),d)}else l=this._handleFile(o.watchPath,c,t);return a(),l&&this.fsw._addPathCloser(e,l),!1}catch(c){if(this.fsw._handleError(c))return a(),e}}}});var Ut={};Je(Ut,{FSWatcher:()=>Y,WatchHelper:()=>ce,default:()=>Gn,watch:()=>jt});function ae(n){return Array.isArray(n)?n:[n]}function $n(n){return typeof n=="function"?n:typeof n=="string"?e=>n===e:n instanceof RegExp?e=>n.test(e):typeof n=="object"&&n!==null?e=>{if(n.path===e)return!0;if(n.recursive){let t=m.relative(n.path,e);return t?!t.startsWith("..")&&!m.isAbsolute(t):!1}return!1}:()=>!1}function qn(n){if(typeof n!="string")throw new Error("string expected");n=m.normalize(n),n=n.replace(/\\/g,"/");let e=!1;n.startsWith("//")&&(e=!0);let t=/\/\//;for(;n.match(t);)n=n.replace(t,"/");return e&&(n="/"+n),n}function Ot(n,e,t){let s=qn(e);for(let r=0;r<n.length;r++){let i=n[r];if(i(s,t))return!0}return!1}function jn(n,e){if(n==null)throw new TypeError("anymatch: specify first argument");let s=ae(n).map(r=>$n(r));return e==null?(r,i)=>Ot(s,r,i):Ot(s,e)}function jt(n,e={}){let t=new Y(e);return t.add(n),t}var zt,le,Wt,m,Be,On,$t,In,kn,Nn,Ht,zn,Wn,Ge,It,kt,qt,Nt,Un,Yn,Ve,Kn,Bn,ce,Y,Gn,Yt=de(()=>{"use strict";zt=require("fs"),le=require("fs/promises"),Wt=require("events"),m=v(require("path"),1);Lt();Ft();Be="/",On="//",$t=".",In="..",kn="string",Nn=/\\/g,Ht=/\/\//,zn=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,Wn=/^\.[/\\]/;Ge=n=>typeof n=="object"&&n!==null&&!(n instanceof RegExp);It=n=>{let e=ae(n).flat();if(!e.every(t=>typeof t===kn))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(qt)},kt=n=>{let e=n.replace(Nn,Be),t=!1;for(e.startsWith(On)&&(t=!0);e.match(Ht);)e=e.replace(Ht,Be);return t&&(e=Be+e),e},qt=n=>kt(m.normalize(kt(n))),Nt=(n="")=>e=>typeof e=="string"?qt(m.isAbsolute(e)?e:m.join(n,e)):e,Un=(n,e)=>m.isAbsolute(n)?n:m.join(e,n),Yn=Object.freeze(new Set),Ve=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==$t&&e!==In&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let s=this.path;try{await(0,le.readdir)(s)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(s),m.basename(s))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=ie,this.items=Yn,Object.freeze(this)}},Kn="stat",Bn="lstat",ce=class{constructor(e,t,s){this.fsw=s;let r=e;this.path=e=e.replace(Wn,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=t,this.statMethod=t?Kn:Bn}entryPath(e){return m.join(this.watchPath,m.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let s=this.entryPath(e);return this.fsw._isntIgnored(s,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},Y=class extends Wt.EventEmitter{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,s={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?ae(e.ignored):ae([]),awaitWriteFinish:t===!0?s:typeof t=="object"?{...s,...t}:!1};Dt&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=ie,this._readyEmitted=!0,process.nextTick(()=>this.emit(w.READY)))},this._emitRaw=(...c)=>this.emit(w.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new se(this),Object.freeze(r)}_addIgnoredPath(e){if(Ge(e)){for(let t of this._ignoredPaths)if(Ge(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e=="string")for(let t of this._ignoredPaths)Ge(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,s){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=It(e);return r&&(i=i.map(a=>Un(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!s,void 0,0,t);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(t||o))})}),this}unwatch(e){if(this.closed)return this;let t=It(e),{cwd:s}=this.options;return t.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(s&&(r=m.join(s,r)),r=m.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(s=>{let r=s();r instanceof Promise&&e.push(r)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,s)=>{let i=(this.options.cwd?m.relative(this.options.cwd,s):s)||$t;e[i]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==w.ERROR&&this.emit(w.ALL,e,...t)}async _emit(e,t,s){if(this.closed)return;let r=this.options;Ke&&(t=m.normalize(t)),r.cwd&&(t=m.relative(r.cwd,t));let i=[t];s!=null&&i.push(s);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(t)))return o.lastChange=new Date,this;if(r.atomic){if(e===w.UNLINK)return this._pendingUnlinks.set(t,[e,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,u)=>{this.emit(...c),this.emit(w.ALL,...c),this._pendingUnlinks.delete(u)})},typeof r.atomic=="number"?r.atomic:100),this;e===w.ADD&&this._pendingUnlinks.has(t)&&(e=w.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===w.ADD||e===w.CHANGE)&&this._readyEmitted){let c=(u,l)=>{u?(e=w.ERROR,i[0]=u,this.emitWithAll(e,i)):l&&(i.length>1?i[1]=l:i.push(l),this.emitWithAll(e,i))};return this._awaitWriteFinish(t,a.stabilityThreshold,e,c),this}if(e===w.CHANGE&&!this._throttle(w.CHANGE,t,50))return this;if(r.alwaysStat&&s===void 0&&(e===w.ADD||e===w.ADD_DIR||e===w.CHANGE)){let c=r.cwd?m.join(r.cwd,t):t,u;try{u=await(0,le.stat)(c)}catch{}if(!u||this.closed)return;i.push(u)}return this.emitWithAll(e,i),this}_handleError(e){let t=e&&e.code;return e&&t!=="ENOENT"&&t!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||t!=="EPERM"&&t!=="EACCES")&&this.emit(w.ERROR,e),e||this.closed}_throttle(e,t,s){this._throttled.has(e)||this._throttled.set(e,new Map);let r=this._throttled.get(e);if(!r)throw new Error("invalid throttle");let i=r.get(t);if(i)return i.count++,!1;let a,o=()=>{let u=r.get(t),l=u?u.count:0;return r.delete(t),clearTimeout(a),u&&clearTimeout(u.timeoutObject),l};a=setTimeout(o,s);let c={timeoutObject:a,clear:o,count:0};return r.set(t,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,s,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=e;this.options.cwd&&!m.isAbsolute(e)&&(c=m.join(this.options.cwd,e));let u=new Date,l=this._pendingWrites;function d(f){(0,zt.stat)(c,(h,S)=>{if(h||!l.has(e)){h&&h.code!=="ENOENT"&&r(h);return}let P=Number(new Date);f&&S.size!==f.size&&(l.get(e).lastChange=P);let E=l.get(e);P-E.lastChange>=t?(l.delete(e),r(void 0,S)):o=setTimeout(d,a,S)})}l.has(e)||(l.set(e,{lastChange:u,cancelWait:()=>(l.delete(e),clearTimeout(o),s)}),o=setTimeout(d,a))}_isIgnored(e,t){if(this.options.atomic&&zn.test(e))return!0;if(!this._userIgnored){let{cwd:s}=this.options,i=(this.options.ignored||[]).map(Nt(s)),o=[...[...this._ignoredPaths].map(Nt(s)),...i];this._userIgnored=jn(o,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new ce(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=m.resolve(e);return this._watched.has(t)||this._watched.set(t,new Ve(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,s){let r=m.join(e,t),i=m.resolve(r);if(s=s??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!s&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(r).getChildren().forEach(f=>this._remove(r,f));let c=this._getWatchedDir(e),u=c.has(t);c.remove(t),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let l=r;if(this.options.cwd&&(l=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(l)&&this._pendingWrites.get(l).cancelWait()===w.ADD)return;this._watched.delete(r),this._watched.delete(i);let d=s?w.UNLINK_DIR:w.UNLINK;u&&!this._isIgnored(r)&&this._emit(d,r),this._closePath(r)}_closePath(e){this._closeFile(e);let t=m.dirname(e);this._getWatchedDir(t).remove(m.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(s=>s()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let s=this._closers.get(e);s||(s=[],this._closers.set(e,s)),s.push(t)}_readdirp(e,t){if(this.closed)return;let s={type:w.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},r=bt(e,s);return this._streams.add(r),r.once(At,()=>{r=void 0}),r.once(Ye,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};Gn={watch:jt,FSWatcher:Y}});var Vn={};Je(Vn,{TSFilebasedRouter:()=>Kt,TSRouter:()=>ee,createClientFunc:()=>rt,createSignal:()=>ke,createTSServerFunc:()=>nt,html:()=>he,initializeRoute:()=>Bt,loadPyFiles:()=>Ce,mapper:()=>tt,renderChildRoutes:()=>Ae,useAnchor:()=>$,useAnchorSingle:()=>ve,useInitialDOM:()=>_e,useTSAuth:()=>Le,useTSCollection:()=>be,useTSComponent:()=>W,useTSElementEach:()=>X,useTSElements:()=>Te,useTSEvent:()=>ge,useTSEventAll:()=>we,useTSExtractParams:()=>ye,useTSLazy:()=>Fe,useTSMetaData:()=>Re,useTSNavigate:()=>xe,useTSNoReload:()=>Ie,useTSOutlet:()=>Me,useTSParams:()=>z,useTSPurifier:()=>pe,useTSQuery:()=>Z,useTSReactor:()=>Ne,useTSSSRHydration:()=>He,useTSSelect:()=>k,useTSloadBrython:()=>De});module.exports=tn(Vn);var et=v(require("dompurify"),1),fe=null;function nn(){return typeof window>"u"?null:(fe||(fe=(0,et.default)(window)),fe)}var rn=["div","span","p","a","button","ul","li","img","input","form","label","h1","h2","h3","h4","h5","h6","section","main","article","svg","path","circle","rect","line","polyline","polygon","g"],sn=["class","id","href","src","alt","title","type","value","name","placeholder","target","rel","data-click","data-change","data-select","data-effect","data-hover","data-submit","data-key","data-event","data-component","data-stagger","data-input"];function on(n){return/^(https?:\/\/|\/|#)/i.test(n.trim())}function an(n){if(typeof window>"u")return n;let e=document.createElement("template");return e.innerHTML=n,e.content.querySelectorAll("*").forEach(t=>{[...t.attributes].forEach(s=>{let r=s.name.toLowerCase();if(r.startsWith("on")||r.startsWith("xlink")||r.startsWith("xml")){t.removeAttribute(s.name);return}(r==="href"||r==="src")&&!on(s.value)&&t.setAttribute(r,"#")}),t.tagName==="A"&&t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer")}),e.innerHTML}function he(n,...e){let t=nn(),s=n.reduce((i,a,o)=>{let c=o<e.length?String(e[o]??""):"";return i+a+c},"");if(!t)return s;let r=t.sanitize(s,{ALLOWED_TAGS:rn,ALLOWED_ATTR:sn,RETURN_DOM:!1});return an(r)}var tt=(n,e)=>n.reduce((t,s,r)=>t+e(s,r),"");function nt(n){return n}function rt(n){return new Proxy({},{get(e,t){return async s=>n(t,s)}})}var me=v(require("dompurify"),1),pe=(n,e)=>{let s={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof n=="string"?me.default.sanitize(n,s):me.default.sanitize(n.innerHTML,s)};var ge=(n,e,t)=>{if(!(typeof window>"u"||typeof document>"u"))if(typeof n=="string"){let s=document.getElementById(n);s?s.addEventListener(e,t):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(e,t):n===document?document.addEventListener(e,t):console.warn("Invalid target parameter provided.")};var st=require("zustand/vanilla"),it=v(require("dompurify"),1);function V(n){return it.default.sanitize(n??"")}function G(n,e){let t=Object.keys(n),s=Object.keys(e);if(t.length!==s.length)return!1;for(let r of t)if(n[r]!==e[r])return!1;return!0}function cn(n,e){let t=[],s=n.replace(/:[^/]+/g,o=>(t.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${s}$`),i=e.match(r),a={};return i&&t.forEach((o,c)=>{a[o]=V(i[c+1]??"")}),a}function ln(n){let e={},t=new URLSearchParams(n);for(let[s,r]of t.entries())e[s]=V(r);return e}var z=(0,st.createStore)((n,e)=>({params:{},query:{},setFromPattern:t=>{let s=window.location.pathname,r=cn(t,s),i=ln(window.location.search),a=e();(!G(a.params,r)||!G(a.query,i))&&n({params:r,query:i})},setFromPatternValues:(t,s)=>{let r={};t.forEach((a,o)=>{r[a]=V(s[o]??"")});let i=e();G(i.params,r)||n({params:r})},setQuery:t=>{let s={};for(let i in t)s[i]=V(t[i]);let r=e();G(r.query,s)||n({query:s})},getParam:t=>e().params[t],getQuery:t=>e().query[t]}));function ye(n){let e=z.getState();e.setFromPattern(n);let t=e.params,s=e.query;return{...t,...s}}var we=(n,e,t)=>{let s=document.querySelectorAll(n);return s.forEach(r=>{r.addEventListener(e,t)}),()=>{s.forEach(r=>{r.removeEventListener(e,t)})}};var ut=require("motion"),dt=v(require("dompurify"),1),Ee=typeof window<"u"&&typeof document<"u",ot=["div","span","p","a","button","ul","li","img","input","form","label","h1","h2","h3","h4","h5","h6","section","main","article"],at=["class","id","href","src","alt","title","type","value","name","placeholder","data-click","data-change","data-select","data-effect","data-hover","data-submit","data-key","data-event","data-component","data-stagger","data-input","data-children","data-slot","target","rel"],ct=Ee?(0,dt.default)(window):{sanitize:(n,e)=>n};function un(n){return/^(https?:\/\/|\/|#)/i.test(n.trim())}function dn(n){Ee&&n.querySelectorAll("*").forEach(e=>{[...e.attributes].forEach(t=>{let s=t.name.toLowerCase();if(s.startsWith("on")){e.removeAttribute(t.name);return}(s==="href"||s==="src")&&!un(t.value)&&e.setAttribute(s,"#")}),e.tagName==="A"&&e.getAttribute("target")==="_blank"&&e.setAttribute("rel","noopener noreferrer")})}function lt(n){let e={},t={},s=400,r=0,i="ease-in-out",a=0,o=!1,c,u;return n.split(/\s+/).forEach(l=>{l==="fade-in"&&(e.opacity=0,t.opacity=1),l==="fade-out"&&(e.opacity=1,t.opacity=0),l==="slide-up"&&(e.y=20,t.y=0),l==="slide-down"&&(e.y=-20,t.y=0),l==="slide-left"&&(e.x=20,t.x=0),l==="slide-right"&&(e.x=-20,t.x=0),l.startsWith("duration-")&&(s=+l.replace("duration-","")),l.startsWith("delay-")&&(r=+l.replace("delay-","")),(l==="linear"||l.startsWith("ease"))&&(i=l),l==="infinite"&&(a=1/0),l==="replay"&&(o=!0),l.startsWith("parallax-y-")&&(c=+l.replace("parallax-y-","")),l.startsWith("parallax-x-")&&(u=+l.replace("parallax-x-",""))}),{from:e,to:t,duration:s,easing:i,delay:r,repeat:a,replay:o,parallaxY:c,parallaxX:u}}function fn(n,e){n.querySelectorAll("[data-component]").forEach(t=>{let s=t.dataset.component;e[s]?.(t)})}var Te=(n,e,t={},s)=>{if(!Ee||!n)return{html:ct.sanitize(e,{ALLOWED_TAGS:ot,ALLOWED_ATTR:at,...s})};let r=ct.sanitize(e,{ALLOWED_TAGS:ot,ALLOWED_ATTR:at,...s});n.innerHTML=r,dn(n);let i=l=>{let d=l.target.closest("[data-click]");d&&t[d.dataset.click]?.(d)};n.addEventListener("click",i),n.querySelectorAll("[data-input]").forEach(l=>{let d=l.dataset.input;t[d]?.(l),l.addEventListener("input",()=>{t[d]?.(l)})}),fn(n,t);let a=[];n.querySelectorAll("[data-effect]").forEach(l=>{let d=lt(l.dataset.effect||"");(d.parallaxX||d.parallaxY)&&a.push({el:l,...d})});let o=!1,c=()=>{o||(o=!0,requestAnimationFrame(()=>{let l=window.scrollY;a.forEach(({el:d,parallaxX:f,parallaxY:h})=>{d.style.transform=`translate3d(${(f||0)*l}px, ${(h||0)*l}px, 0)`}),o=!1}))};window.addEventListener("scroll",c);let u=new IntersectionObserver(l=>{l.forEach(d=>{let f=d.target,h=lt(f.dataset.effect||"");d.isIntersecting?(Object.assign(f.style,h.from),setTimeout(()=>{(0,ut.animate)(f,h.to,{duration:h.duration/1e3,easing:h.easing,repeat:h.repeat})},h.delay),h.replay||u.unobserve(f)):h.replay&&Object.assign(f.style,h.from)})});return n.querySelectorAll("[data-effect]").forEach(l=>u.observe(l)),{cleanup(){u.disconnect(),window.removeEventListener("scroll",c),n.removeEventListener("click",i)}}};var Se=v(require("dompurify"),1),Q=null,_e=(n,e)=>{if(typeof document>"u")return;let t=document.getElementById(n);if(!t)return;Se.default.addHook("uponSanitizeAttribute",(a,o)=>{let c=(o.attrName||"").toLowerCase(),u=(o.attrValue??"").toString().trim();if(c.startsWith("on")){o.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(u)){o.keepAttr=!1;return}if(c==="class"){let d=u.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let h=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return h===""||/^https?:\/\//i.test(h)||/^\/(?!\/)/.test(h)||/^\.{0,2}\//.test(h)}return!0}return!1});o.attrValue=d.join(" ");return}if(c==="style"){o.keepAttr=!1;return}});let s=t.cloneNode(!0),r=Se.default.sanitize(s.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(r.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(Q!==null&&i!==Q){let a=document.createElement("div");e(a);let c=new DOMParser().parseFromString(Q,"text/html");for(;t.firstChild;)t.removeChild(t.firstChild);c.body.childNodes.forEach(u=>t.appendChild(u.cloneNode(!0)))}else{for(Q=i;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(r),e(t)}};var Pe=v(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let e=n.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var ve=(n,e,t,s="",r=null)=>{if(!n)return;let i=Pe.default.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Pe.default.sanitize(t,{USE_PROFILES:{html:!1}});n.setAttribute("href",i),n.setAttribute("aria-label",a),s&&(n.className=s.trim()),r&&n.replaceChildren(r),typeof window<"u"&&n.addEventListener("click",o=>{o.preventDefault();let u=o.currentTarget.getAttribute("href");if(u){let l=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:l},"",u),dispatchEvent(new PopStateEvent("popstate"))}})};var M=v(require("dompurify"),1);var ft=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",t="'none'",s="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",u=!1)=>{let l=()=>{try{let d=document.querySelector('meta[http-equiv="Content-Security-Policy"]');d||(d=document.createElement("meta"),d.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(d));let f=u?`report-uri ${c};`:"";d.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${e}; object-src ${t}; font-src ${s}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${f}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l):l()};var Re=(n,e)=>{let t={name:M.default.sanitize(n.name||""),title:M.default.sanitize(n.title||""),description:M.default.sanitize(n.description||"Default description"),author:M.default.sanitize(n.author||""),favicon:n.favicon},s=p=>{t.name=M.default.sanitize(p),P("name",t.name)},r=p=>{t.title=M.default.sanitize(p),document.title=t.title},i=p=>{t.description=M.default.sanitize(p),P("description",t.description)},a=p=>{t.author=M.default.sanitize(p),P("author",t.author)},o=p=>{t.favicon=M.default.sanitize(p);let T=document.querySelector('link[rel="icon"]');T||(T=document.createElement("link"),T.rel="icon",document.head.appendChild(T)),T.href=t.favicon},c=()=>t.name,u=()=>t.title,l=()=>t.description,d=()=>t.author,f=()=>t.favicon,h=()=>t,S=(p,T)=>{let R=document.createElement("meta");R.setAttribute("name",p),R.setAttribute("content",T),document.head.appendChild(R)},P=(p,T)=>{let R=document.querySelector(`meta[name="${p}"]`);R?R.setAttribute("content",T):S(p,T)},E=()=>{t.title&&(document.title=t.title),t.name&&P("name",t.name),t.description&&P("description",t.description),t.author&&P("author",t.author),t.favicon&&o(t.favicon)};return e&&ft(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),E(),{setName:s,setTitle:r,setDescription:i,setAuthor:a,setFavicon:o,getName:c,getTitle:u,getDescription:l,getAuthor:d,getFavicon:f,getAllMetaData:h,appendMetaTagsToHead:E}};var ht=v(require("dompurify"),1),W=(n,e,t,s,r)=>{let i=`#${n}`,a=e.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${n}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${n}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=ht.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),t(o,s,r)};var be=(n,e,t,s=[])=>{let r=new Set;n.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=e.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=t[a],u=Array.isArray(s)?s[a]:void 0;typeof c=="function"?W(i,e,c,u):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var k=(n,e)=>{let s=(e??document).querySelectorAll(n);if(s.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${n}'`),null;if(n.startsWith("#")&&s.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${n}'. Found ${s.length} elements with this ID.`);return s[0]}return s.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${n}'. Returning the first one.`),s[0]};var mt=require("jwt-decode"),Le=(n,e)=>{let t=localStorage.getItem("token");if(!t)return window.location.href=e,null;try{let s=(0,mt.jwtDecode)(t),r=Date.now()/1e3;return s.exp&&s.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=e),null}catch(s){return console.error("Invalid token:",s),window.location.href=e,null}};var X=(n,e,t)=>{n.forEach(s=>{e.forEach(r=>{s.addEventListener(r,i=>{t(s,i)})})})};var xe=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Me=(n,e)=>{let t=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!t)return;let s=window.location.pathname.replace(/\/$/,"");for(let r of e){let i=r.path.replace(/\/$/,"");if(s===i||s.startsWith(`${i}/`)){r.component(t);break}}};function Ae(n,e){let t=window.location.pathname.replace(/\/$/,"");e.routes.forEach(s=>{s.children?.length&&s.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(t===i||t.startsWith(`${i}/`)){let a=n.querySelector(`#${r.outlet}`)||n.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var De=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",t=s=>new Promise((r,i)=>{let a=document.createElement("script");a.src=s,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${s}`)),document.head.appendChild(a)});await t(n),await t(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Ce=n=>new Promise((e,t)=>{let s=document.createElement("script");s.type="text/python",s.src=`/src/python/${n}`,s.onload=()=>e(),s.onerror=()=>t(new Error(`Failed to load ${n}`)),document.body.appendChild(s)});function Fe(n){let e=null;return async(t,s)=>{try{if(!e){let r=await n();e=r.default||r}if(typeof e=="function")return e(t,s);if(e instanceof HTMLElement){let r=e.cloneNode(!0);return t?.appendChild(r),r}if(typeof e=="object"&&e!==null&&"render"in e&&typeof e.render=="function")return e.render(t,s);console.warn("useTSLazy: Unsupported module type",e)}catch(r){console.error("useTSLazy failed:",r)}}}var He=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};var pt=require("lodash-es"),Oe=n=>n;typeof window<"u"&&typeof document<"u"&&(Oe=n=>{let e=document.createElement("div");return e.innerText=n,e.innerHTML});var hn=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(t=>{if(!t||t.dataset.anchorEnhanced==="true")return;t.dataset.anchorEnhanced="true";let s=t.getAttribute("class")||"";t.setAttribute("class",Oe(s));let r=t.getAttribute("aria-label");r&&t.setAttribute("aria-label",Oe(r));let i=t.querySelector(":scope > *");i&&(t.innerHTML="",t.appendChild(i));let a=t.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}t.addEventListener("click",o=>{o.preventDefault();let c=t.getAttribute("href")||"";try{let u=new URL(c,window.location.href);window.history.pushState({},"",u.pathname+u.search+u.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(u){console.error("Invalid URL in anchor:",c,u)}})}})},mn=(0,pt.debounce)(hn,50),$=n=>{mn(n)};var Ie=n=>{if(!n)return;let e=k("a",n);$(e)};var gt=n=>{let e=n,t=[];return[()=>e,a=>{e=typeof a=="function"?a(e):a,t.forEach(o=>o(e))},a=>{t.push(a),a(e)}]};function yt(n,e,t){let s=()=>{n.textContent=e().toString(),t?.(e())};s();let r=e.set;r&&(e.set=i=>{r(i),s()})}function ke(n){let[e,t,s]=gt(n),r=[],i=(()=>e());return i.set=a=>{t(a),r.forEach(o=>o(i()))},i.bind=a=>yt(a,i),i.subscribe=a=>{r.push(a),a(i())},i}function Ne(n,e){let t={deps:e.map(r=>typeof r=="function"?r():r)},s=n();typeof s=="function"&&(t.cleanup=s),e.forEach((r,i)=>{typeof r=="function"&&"bind"in r&&r.subscribe?.(()=>{let o=r(),c=t.deps[i];if(o!==c){t.cleanup?.(),t.deps[i]=o;let u=n();typeof u=="function"&&(t.cleanup=u)}})})}var y={params:{},query:{}},ze=new Set;function pn(){return{params:{...y.params},query:{...y.query}}}function q(n,e){let t=Object.keys(n),s=Object.keys(e);if(t.length!==s.length)return!1;for(let r of t)if(n[r]!==e[r])return!1;return!0}function F(){let n=pn();ze.forEach(e=>e(n))}function gn(n){let e={};if(!n)return e;let t=n.startsWith("?")?n.slice(1):n;for(let s of t.split("&")){if(!s)continue;let[r,i]=s.split("=");r&&(e[decodeURIComponent(r)]=decodeURIComponent(i||""))}return e}function yn(n){let e=new URLSearchParams;for(let s in n){let r=n[s];r!=null&&r!==""&&e.set(s,r)}let t=e.toString();return t?`?${t}`:""}function J(){if(typeof window>"u")return;let n=window.location.pathname,e=window.location.hash,t=yn(y.query);history.replaceState({},"",n+t+e)}var Z={getState(){return{params:y.params,query:y.query,getParam:n=>y.params[n],getQuery:n=>y.query[n],setFromPattern(n){if(typeof window>"u")return;let e=n.match(/:([^/]+)/g)?.map(r=>r.slice(1))||[],t=window.location.pathname.split("/").filter(Boolean),s={};e.forEach((r,i)=>{s[r]=t[i]}),q(y.params,s)||(y.params=s,F())},setFromPatternValues(n,e){let t={};n.forEach((s,r)=>{t[s]=e[r]}),q(y.params,t)||(y.params=t,F())},setQuery(n){let e={...y.query,...n};q(y.query,e)||(y.query=e,J(),F())},replaceQuery(n){q(y.query,n)||(y.query={...n},J(),F())},removeQuery(n){if(!(n in y.query))return;let e={...y.query};delete e[n],y.query=e,J(),F()},clearQuery(){Object.keys(y.query).length!==0&&(y.query={},J(),F())},setQueryFromURL(n){let e=gn(n);q(y.query,e)||(y.query=e,F())},subscribe(n){return ze.add(n),()=>ze.delete(n)}}}};typeof window<"u"&&window.addEventListener("popstate",()=>{Z.getState().setQueryFromURL(window.location.search)});var We=v(require("dompurify"),1);var Et=require("zustand/vanilla"),Tt=v(require("dompurify"),1),C=(0,Et.createStore)(n=>({params:{},query:{},setParams:e=>n(()=>({params:wt(e)})),setQuery:e=>n(()=>({query:wt(e)}))}));function wt(n){let e={};for(let t in n)e[t]=Tt.default.sanitize(n[t]);return e}var ee=class{routes=[];expectedParams;apiFetcher;constructor(e,t,s){this.routes=e,this.expectedParams=new Set(t),this.apiFetcher=s,window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,t=window.location.search,s=this.parseQueryParams(t);if(e.startsWith("/api")&&this.apiFetcher){let a=e.replace("/api/","").split("/")[0],o=Object.fromEntries(new URLSearchParams(t));this.apiFetcher(a,o).then(c=>console.log("API response:",c)).catch(c=>console.error("API error:",c));return}let r=this.findMatchingRoute(e,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);C.getState().setParams(i),C.getState().setQuery(s);let a=document.createElement("div");if(r.element?.(a,i,s),r.children){let o=e.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,s)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);C.getState().setParams(a),C.getState().setQuery(s);let o=document.createElement("div");i.element?.(o,a,s)}}}renderChildren(e,t,s,r,i){if(!e||e.length===0){let o=s.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(t,e);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},u=this.filterAndSanitizeParams(c);if(C.getState().setParams(u),C.getState().setQuery(i),a.element?.(o,u,i),s.appendChild(o),a.children){let l=t.slice(a.path.length);this.renderChildren(a.children,l,o,u,i)}}}parseQueryParams(e){let t={},s=new URLSearchParams(e);for(let[r,i]of s.entries())this.expectedParams.has(r)&&(t[r]=We.default.sanitize(i));return t}findMatchingRoute(e,t,s={}){for(let r of t){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,d=>(o.push(d.substring(1)),"([^\\s/]+)")),u=new RegExp(`^${c}(?:/|$)`),l=e.match(u);if(l){let d={...s};if(o.forEach((f,h)=>{d[f]=l[h+1]??""}),r.children){let f=e.slice(l[0].length),h=this.findMatchingRoute(f,r.children,d);if(h)return h}return{...r,params:d}}}}}filterAndSanitizeParams(e){if(!e)return{};let t={};for(let s in e)this.expectedParams.has(s)&&(t[s]=We.default.sanitize(e[s]??""));return t}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Kt=()=>({name:"ts-filebased-router",async buildStart(){let n=await import("fs/promises"),e=await import("path"),t=await Promise.resolve().then(()=>(Yt(),Ut)),s=e.resolve("src/pages"),r=e.resolve("src/gen"),i=e.resolve("src/routes"),a=e.join(r,"tsrouter.gen.ts"),o=e.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production",u=async E=>n.mkdir(E,{recursive:!0}).catch(()=>{}),l=E=>E.charAt(0).toUpperCase()+E.slice(1),d=E=>{let p="/"+e.relative(s,E).replace(/\\/g,"/");return p=p.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",p.replace(/\[\.\.\.(.+?)\]/g,"*").replace(/\[(.+?)\]/g,":$1")},f=E=>E.replace(/^\//,"").split("/").map(p=>p.startsWith(":")?l(p.slice(1)):p.replace(/\b\w/g,T=>T.toUpperCase()).replace(/[-_]/g,"")).filter(Boolean).join("")||"Index",h=async E=>{let p=await n.readdir(E,{withFileTypes:!0}),T=[];for(let R of p){let I=e.join(E,R.name);R.isDirectory()?T.push(...await h(I)):R.isFile()&&R.name.endsWith(".ts")&&T.push({file:I,route:d(I),name:f(d(I))})}return T},S=async()=>{let E=await h(s),p=E.find(_=>_.route==="/notfound"),T=E.filter(_=>_.route!=="/notfound");for(let _ of E)if(!(await n.readFile(_.file,"utf-8")).trim()){let K=_.route.includes(":"),Xe=K?_.route.split("/").filter(ue=>ue.startsWith(":")).map(ue=>ue.slice(1)):[],Vt=K?`const { ${Xe.join(", ")} } = useTSExtractParams("${_.route}");`:"";await n.writeFile(_.file,`import { html, useTSElements, useTSMetaData${K?", useTSExtractParams":""} } from "@devwaren/vanilla-ts";
|
|
2
2
|
|
|
3
3
|
export default function ${_.name}(DOM: HTMLElement) {
|
|
4
4
|
useTSMetaData({
|
|
@@ -15,24 +15,27 @@ export default function ${_.name}(DOM: HTMLElement) {
|
|
|
15
15
|
</div>
|
|
16
16
|
\`);
|
|
17
17
|
};
|
|
18
|
-
`,"utf-8")}let R=
|
|
18
|
+
`,"utf-8")}let R=p?`export const NotFound = async (DOM: HTMLElement) => {
|
|
19
|
+
const mod = await import("../pages/${e.relative(s,p.file).replace(/\\/g,"/").replace(/\\.ts$/,"")}") as Module;
|
|
20
|
+
return mod.default(DOM);
|
|
21
|
+
};`:"export const NotFound = (DOM: HTMLElement) =>\n useTSElements(DOM, html`<h1>404 - Page Not Found</h1>`);",I=T.map(_=>{let Qe="../pages/"+e.relative(s,_.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`{ path: "${_.route}", name: "${_.name}", component: () => import("${Qe}") as Promise<Module> }`}).join(`,
|
|
19
22
|
`),Gt=`// AUTO-GENERATED ROUTER
|
|
20
23
|
import { useTSElements, useTSParams, html } from "@devwaren/vanilla-ts";
|
|
21
24
|
|
|
25
|
+
// -----------------------------
|
|
26
|
+
// Types for all routes
|
|
27
|
+
// -----------------------------
|
|
22
28
|
type Cleanup = undefined | (() => void);
|
|
23
29
|
type RenderResult = Cleanup | Promise<Cleanup> | string;
|
|
24
30
|
type Component = (DOM: HTMLElement) => RenderResult;
|
|
25
31
|
type Module = { default: Component };
|
|
26
32
|
|
|
27
33
|
// -----------------------------
|
|
28
|
-
${
|
|
29
|
-
const mod = await import("../pages/${e.relative(s,p.file).replace(/\\/g,"/").replace(/\\.ts$/,"")}") as Module;
|
|
30
|
-
return mod.default(DOM);
|
|
31
|
-
};`:"export const NotFound = (DOM: HTMLElement) =>\n useTSElements(DOM, html`<h1>404 - Page Not Found</h1>`);"}
|
|
34
|
+
${R}
|
|
32
35
|
|
|
33
36
|
// -----------------------------
|
|
34
|
-
export const routeTree: { path: string; name: string; component: () => Promise<Module
|
|
35
|
-
${
|
|
37
|
+
export const routeTree: { path: string; name: string; component: () => Promise<Module> }[] = [
|
|
38
|
+
${I}
|
|
36
39
|
];
|
|
37
40
|
|
|
38
41
|
// -----------------------------
|
|
@@ -100,7 +103,7 @@ export async function createRouter(DOM: HTMLElement) {
|
|
|
100
103
|
|
|
101
104
|
const query: Record<string, string> = {};
|
|
102
105
|
url.searchParams.forEach((v, k) => {
|
|
103
|
-
query[k] = v; // no return
|
|
106
|
+
query[k] = v; // \u2705 no return
|
|
104
107
|
});
|
|
105
108
|
useTSParams.getState().setQuery(query);
|
|
106
109
|
|
package/dist/index.js
CHANGED
|
@@ -15,24 +15,27 @@ export default function ${T.name}(DOM: HTMLElement) {
|
|
|
15
15
|
</div>
|
|
16
16
|
\`);
|
|
17
17
|
};
|
|
18
|
-
`,"utf-8")}let S=
|
|
18
|
+
`,"utf-8")}let S=m?`export const NotFound = async (DOM: HTMLElement) => {
|
|
19
|
+
const mod = await import("../pages/${e.relative(r,m.file).replace(/\\/g,"/").replace(/\\.ts$/,"")}") as Module;
|
|
20
|
+
return mod.default(DOM);
|
|
21
|
+
};`:"export const NotFound = (DOM: HTMLElement) =>\n useTSElements(DOM, html`<h1>404 - Page Not Found</h1>`);",R=g.map(T=>{let W="../pages/"+e.relative(r,T.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`{ path: "${T.route}", name: "${T.name}", component: () => import("${W}") as Promise<Module> }`}).join(`,
|
|
19
22
|
`),Me=`// AUTO-GENERATED ROUTER
|
|
20
23
|
import { useTSElements, useTSParams, html } from "@devwaren/vanilla-ts";
|
|
21
24
|
|
|
25
|
+
// -----------------------------
|
|
26
|
+
// Types for all routes
|
|
27
|
+
// -----------------------------
|
|
22
28
|
type Cleanup = undefined | (() => void);
|
|
23
29
|
type RenderResult = Cleanup | Promise<Cleanup> | string;
|
|
24
30
|
type Component = (DOM: HTMLElement) => RenderResult;
|
|
25
31
|
type Module = { default: Component };
|
|
26
32
|
|
|
27
33
|
// -----------------------------
|
|
28
|
-
${
|
|
29
|
-
const mod = await import("../pages/${e.relative(r,m.file).replace(/\\/g,"/").replace(/\\.ts$/,"")}") as Module;
|
|
30
|
-
return mod.default(DOM);
|
|
31
|
-
};`:"export const NotFound = (DOM: HTMLElement) =>\n useTSElements(DOM, html`<h1>404 - Page Not Found</h1>`);"}
|
|
34
|
+
${S}
|
|
32
35
|
|
|
33
36
|
// -----------------------------
|
|
34
|
-
export const routeTree: { path: string; name: string; component: () => Promise<Module
|
|
35
|
-
${
|
|
37
|
+
export const routeTree: { path: string; name: string; component: () => Promise<Module> }[] = [
|
|
38
|
+
${R}
|
|
36
39
|
];
|
|
37
40
|
|
|
38
41
|
// -----------------------------
|
|
@@ -100,7 +103,7 @@ export async function createRouter(DOM: HTMLElement) {
|
|
|
100
103
|
|
|
101
104
|
const query: Record<string, string> = {};
|
|
102
105
|
url.searchParams.forEach((v, k) => {
|
|
103
|
-
query[k] = v; // no return
|
|
106
|
+
query[k] = v; // \u2705 no return
|
|
104
107
|
});
|
|
105
108
|
useTSParams.getState().setQuery(query);
|
|
106
109
|
|