@devwareng/vanilla-ts 1.4.23 → 1.4.25

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.
@@ -0,0 +1,6 @@
1
+ import{stat as Ht}from"fs";import{stat as jt,readdir as Yt}from"fs/promises";import{EventEmitter as Ut}from"events";import*as d from"path";import{stat as ft,lstat as G,readdir as dt,realpath as ut}from"fs/promises";import{Readable as _t}from"stream";import{resolve as K,relative as mt,join as wt,sep as pt}from"path";var y={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},W={root:".",fileFilter:r=>!0,directoryFilter:r=>!0,type:y.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(W);var q="READDIRP_RECURSIVE_ERROR",yt=new Set(["ENOENT","EPERM","EACCES","ELOOP",q]),V=[y.DIR_TYPE,y.EVERYTHING_TYPE,y.FILE_DIR_TYPE,y.FILE_TYPE],Et=new Set([y.DIR_TYPE,y.EVERYTHING_TYPE,y.FILE_DIR_TYPE]),Pt=new Set([y.EVERYTHING_TYPE,y.FILE_DIR_TYPE,y.FILE_TYPE]),gt=r=>yt.has(r.code),Rt=process.platform==="win32",B=r=>!0,$=r=>{if(r===void 0)return B;if(typeof r=="function")return r;if(typeof r=="string"){let t=r.trim();return s=>s.basename===t}if(Array.isArray(r)){let t=r.map(s=>s.trim());return s=>t.some(i=>s.basename===i)}return B},L=class extends _t{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let s={...W,...t},{root:i,type:e}=s;this._fileFilter=$(s.fileFilter),this._directoryFilter=$(s.directoryFilter);let n=s.lstat?G:ft;Rt?this._stat=h=>n(h,{bigint:!0}):this._stat=n,this._maxDepth=s.depth??W.depth,this._wantsDir=e?Et.has(e):!1,this._wantsFile=e?Pt.has(e):!1,this._wantsEverything=e===y.EVERYTHING_TYPE,this._root=K(i),this._isDirent=!s.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let s=this.parent,i=s&&s.files;if(i&&i.length>0){let{path:e,depth:n}=s,h=i.splice(0,t).map(a=>this._formatEntry(a,e)),o=await Promise.all(h);for(let a of o){if(!a)continue;if(this.destroyed)return;let l=await this._getEntryType(a);l==="directory"&&this._directoryFilter(a)?(n<=this._maxDepth&&this.parents.push(this._exploreDir(a.fullPath,n+1)),this._wantsDir&&(this.push(a),t--)):(l==="file"||this._includeAsFile(a))&&this._fileFilter(a)&&this._wantsFile&&(this.push(a),t--)}}else{let e=this.parents.pop();if(!e){this.push(null);break}if(this.parent=await e,this.destroyed)return}}}catch(s){this.destroy(s)}finally{this.reading=!1}}}async _exploreDir(t,s){let i;try{i=await dt(t,this._rdOptions)}catch(e){this._onError(e)}return{files:i,depth:s,path:t}}async _formatEntry(t,s){let i,e=this._isDirent?t.name:t;try{let n=K(wt(s,e));i={path:mt(this._root,n),fullPath:n,basename:e},i[this._statsProp]=this._isDirent?t:await this._stat(n)}catch(n){this._onError(n);return}return i}_onError(t){gt(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let s=t[this._statsProp];if(s.isFile())return"file";if(s.isDirectory())return"directory";if(s&&s.isSymbolicLink()){let i=t.fullPath;try{let e=await ut(i),n=await G(e);if(n.isFile())return"file";if(n.isDirectory()){let h=e.length;if(i.startsWith(e)&&i.substr(h,1)===pt){let o=new Error(`Circular symlink detected: "${i}" points to "${e}"`);return o.code=q,this._onError(o)}return"directory"}}catch(e){return this._onError(e),""}}}_includeAsFile(t){let s=t&&t[this._statsProp];return s&&this._wantsEverything&&!s.isDirectory()}};function J(r,t={}){let s=t.entryType||t.type;if(s==="both"&&(s=y.FILE_DIR_TYPE),s&&(t.type=s),r){if(typeof r!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(s&&!V.includes(s))throw new Error(`readdirp: Invalid type passed. Use one of ${V.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=r,new L(t)}import{watchFile as Dt,unwatchFile as Q,watch as bt}from"fs";import{open as It,stat as Z,lstat as Tt,realpath as k}from"fs/promises";import*as _ from"path";import{type as xt}from"os";var vt="data",z="end",tt="close",F=()=>{};var A=process.platform,M=A==="win32",Ft=A==="darwin",At=A==="linux",St=A==="freebsd",st=xt()==="OS400",m={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},E=m,Nt="watch",Wt={lstat:Tt,stat:Z},P="listeners",I="errHandlers",g="rawEmitters",Lt=[P,I,g],kt=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"]),Ct=r=>kt.has(_.extname(r).slice(1).toLowerCase()),O=(r,t)=>{r instanceof Set?r.forEach(t):t(r)},D=(r,t,s)=>{let i=r[t];i instanceof Set||(r[t]=i=new Set([i])),i.add(s)},Ot=r=>t=>{let s=r[t];s instanceof Set?s.clear():delete r[t]},b=(r,t,s)=>{let i=r[t];i instanceof Set?i.delete(s):i===s&&delete r[t]},et=r=>r instanceof Set?r.size===0:!r,T=new Map;function X(r,t,s,i,e){let n=(h,o)=>{s(r),e(h,o,{watchedPath:r}),o&&r!==o&&x(_.resolve(r,o),P,_.join(r,o))};try{return bt(r,{persistent:t.persistent},n)}catch(h){i(h);return}}var x=(r,t,s,i,e)=>{let n=T.get(r);n&&O(n[t],h=>{h(s,i,e)})},zt=(r,t,s,i)=>{let{listener:e,errHandler:n,rawEmitter:h}=i,o=T.get(t),a;if(!s.persistent)return a=X(r,s,e,n,h),a?a.close.bind(a):void 0;if(o)D(o,P,e),D(o,I,n),D(o,g,h);else{if(a=X(r,s,x.bind(null,t,P),n,x.bind(null,t,g)),!a)return;a.on(E.ERROR,async l=>{let c=x.bind(null,t,I);if(o&&(o.watcherUnusable=!0),M&&l.code==="EPERM")try{await(await It(r,"r")).close(),c(l)}catch{}else c(l)}),o={listeners:e,errHandlers:n,rawEmitters:h,watcher:a},T.set(t,o)}return()=>{b(o,P,e),b(o,I,n),b(o,g,h),et(o.listeners)&&(o.watcher.close(),T.delete(t),Lt.forEach(Ot(o)),o.watcher=void 0,Object.freeze(o))}},C=new Map,Mt=(r,t,s,i)=>{let{listener:e,rawEmitter:n}=i,h=C.get(t),o=h&&h.options;return o&&(o.persistent<s.persistent||o.interval>s.interval)&&(Q(t),h=void 0),h?(D(h,P,e),D(h,g,n)):(h={listeners:e,rawEmitters:n,options:s,watcher:Dt(t,s,(a,l)=>{O(h.rawEmitters,f=>{f(E.CHANGE,t,{curr:a,prev:l})});let c=a.mtimeMs;(a.size!==l.size||c>l.mtimeMs||c===0)&&O(h.listeners,f=>f(r,a))})},C.set(t,h)),()=>{b(h,P,e),b(h,g,n),et(h.listeners)&&(C.delete(t),Q(t),h.options=h.watcher=void 0,Object.freeze(h))}},v=class{constructor(t){this.fsw=t,this._boundHandleError=s=>t._handleError(s)}_watchWithNodeFs(t,s){let i=this.fsw.options,e=_.dirname(t),n=_.basename(t);this.fsw._getWatchedDir(e).add(n);let o=_.resolve(t),a={persistent:i.persistent};s||(s=F);let l;if(i.usePolling){let c=i.interval!==i.binaryInterval;a.interval=c&&Ct(n)?i.binaryInterval:i.interval,l=Mt(t,o,a,{listener:s,rawEmitter:this.fsw._emitRaw})}else l=zt(t,o,a,{listener:s,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,s,i){if(this.fsw.closed)return;let e=_.dirname(t),n=_.basename(t),h=this.fsw._getWatchedDir(e),o=s;if(h.has(n))return;let a=async(c,f)=>{if(this.fsw._throttle(Nt,t,5)){if(!f||f.mtimeMs===0)try{let u=await Z(t);if(this.fsw.closed)return;let w=u.atimeMs,p=u.mtimeMs;if((!w||w<=p||p!==o.mtimeMs)&&this.fsw._emit(E.CHANGE,t,u),(Ft||At||St)&&o.ino!==u.ino){this.fsw._closeFile(c),o=u;let R=this._watchWithNodeFs(t,a);R&&this.fsw._addPathCloser(c,R)}else o=u}catch{this.fsw._remove(e,n)}else if(h.has(n)){let u=f.atimeMs,w=f.mtimeMs;(!u||u<=w||w!==o.mtimeMs)&&this.fsw._emit(E.CHANGE,t,f),o=f}}},l=this._watchWithNodeFs(t,a);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(E.ADD,t,0))return;this.fsw._emit(E.ADD,t,s)}return l}async _handleSymlink(t,s,i,e){if(this.fsw.closed)return;let n=t.fullPath,h=this.fsw._getWatchedDir(s);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await k(i)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(h.has(e)?this.fsw._symlinkPaths.get(n)!==o&&(this.fsw._symlinkPaths.set(n,o),this.fsw._emit(E.CHANGE,i,t.stats)):(h.add(e),this.fsw._symlinkPaths.set(n,o),this.fsw._emit(E.ADD,i,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(n))return!0;this.fsw._symlinkPaths.set(n,!0)}_handleRead(t,s,i,e,n,h,o){if(t=_.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let a=this.fsw._getWatchedDir(i.path),l=new Set,c=this.fsw._readdirp(t,{fileFilter:f=>i.filterPath(f),directoryFilter:f=>i.filterDir(f)});if(c)return c.on(vt,async f=>{if(this.fsw.closed){c=void 0;return}let u=f.path,w=_.join(t,u);if(l.add(u),!(f.stats.isSymbolicLink()&&await this._handleSymlink(f,t,w,u))){if(this.fsw.closed){c=void 0;return}(u===e||!e&&!a.has(u))&&(this.fsw._incrReadyCount(),w=_.join(n,_.relative(n,w)),this._addToNodeFs(w,s,i,h+1))}}).on(E.ERROR,this._boundHandleError),new Promise((f,u)=>{if(!c)return u();c.once(z,()=>{if(this.fsw.closed){c=void 0;return}let w=o?o.clear():!1;f(void 0),a.getChildren().filter(p=>p!==t&&!l.has(p)).forEach(p=>{this.fsw._remove(t,p)}),c=void 0,w&&this._handleRead(t,!1,i,e,n,h,o)})})}async _handleDir(t,s,i,e,n,h,o){let a=this.fsw._getWatchedDir(_.dirname(t)),l=a.has(_.basename(t));!(i&&this.fsw.options.ignoreInitial)&&!n&&!l&&this.fsw._emit(E.ADD_DIR,t,s),a.add(_.basename(t)),this.fsw._getWatchedDir(t);let c,f,u=this.fsw.options.depth;if((u==null||e<=u)&&!this.fsw._symlinkPaths.has(o)){if(!n&&(await this._handleRead(t,i,h,n,t,e,c),this.fsw.closed))return;f=this._watchWithNodeFs(t,(w,p)=>{p&&p.mtimeMs===0||this._handleRead(w,!1,h,n,t,e,c)})}return f}async _addToNodeFs(t,s,i,e,n){let h=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return h(),!1;let o=this.fsw._getWatchHelpers(t);i&&(o.filterPath=a=>i.filterPath(a),o.filterDir=a=>i.filterDir(a));try{let a=await Wt[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,a))return h(),!1;let l=this.fsw.options.followSymlinks,c;if(a.isDirectory()){let f=_.resolve(t),u=l?await k(t):t;if(this.fsw.closed||(c=await this._handleDir(o.watchPath,a,s,e,n,o,u),this.fsw.closed))return;f!==u&&u!==void 0&&this.fsw._symlinkPaths.set(f,u)}else if(a.isSymbolicLink()){let f=l?await k(t):t;if(this.fsw.closed)return;let u=_.dirname(o.watchPath);if(this.fsw._getWatchedDir(u).add(o.watchPath),this.fsw._emit(E.ADD,o.watchPath,a),c=await this._handleDir(u,a,s,e,t,o,f),this.fsw.closed)return;f!==void 0&&this.fsw._symlinkPaths.set(_.resolve(t),f)}else c=this._handleFile(o.watchPath,a,s);return h(),c&&this.fsw._addPathCloser(t,c),!1}catch(a){if(this.fsw._handleError(a))return h(),t}}};var H="/",Gt="//",ht=".",Kt="..",Vt="string",Bt=/\\/g,it=/\/\//,$t=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,qt=/^\.[/\\]/;function S(r){return Array.isArray(r)?r:[r]}var j=r=>typeof r=="object"&&r!==null&&!(r instanceof RegExp);function Jt(r){return typeof r=="function"?r:typeof r=="string"?t=>r===t:r instanceof RegExp?t=>r.test(t):typeof r=="object"&&r!==null?t=>{if(r.path===t)return!0;if(r.recursive){let s=d.relative(r.path,t);return s?!s.startsWith("..")&&!d.isAbsolute(s):!1}return!1}:()=>!1}function Qt(r){if(typeof r!="string")throw new Error("string expected");r=d.normalize(r),r=r.replace(/\\/g,"/");let t=!1;r.startsWith("//")&&(t=!0);let s=/\/\//;for(;r.match(s);)r=r.replace(s,"/");return t&&(r="/"+r),r}function rt(r,t,s){let i=Qt(t);for(let e=0;e<r.length;e++){let n=r[e];if(n(i,s))return!0}return!1}function Xt(r,t){if(r==null)throw new TypeError("anymatch: specify first argument");let i=S(r).map(e=>Jt(e));return t==null?(e,n)=>rt(i,e,n):rt(i,t)}var nt=r=>{let t=S(r).flat();if(!t.every(s=>typeof s===Vt))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(ct)},ot=r=>{let t=r.replace(Bt,H),s=!1;for(t.startsWith(Gt)&&(s=!0);t.match(it);)t=t.replace(it,H);return s&&(t=H+t),t},ct=r=>ot(d.normalize(ot(r))),at=(r="")=>t=>typeof t=="string"?ct(d.isAbsolute(t)?t:d.join(r,t)):t,Zt=(r,t)=>d.isAbsolute(r)?r:d.join(t,r),ts=Object.freeze(new Set),Y=class{constructor(t,s){this.path=t,this._removeWatcher=s,this.items=new Set}add(t){let{items:s}=this;s&&t!==ht&&t!==Kt&&s.add(t)}async remove(t){let{items:s}=this;if(!s||(s.delete(t),s.size>0))return;let i=this.path;try{await Yt(i)}catch{this._removeWatcher&&this._removeWatcher(d.dirname(i),d.basename(i))}}has(t){let{items:s}=this;if(s)return s.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=F,this.items=ts,Object.freeze(this)}},ss="stat",es="lstat",U=class{constructor(t,s,i){this.fsw=i;let e=t;this.path=t=t.replace(qt,""),this.watchPath=e,this.fullWatchPath=d.resolve(e),this.dirParts=[],this.dirParts.forEach(n=>{n.length>1&&n.pop()}),this.followSymlinks=s,this.statMethod=s?ss:es}entryPath(t){return d.join(this.watchPath,d.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:s}=t;if(s&&s.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,s)&&this.fsw._hasReadPermissions(s)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},N=class extends Ut{constructor(t={}){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 s=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},e={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?S(t.ignored):S([]),awaitWriteFinish:s===!0?i:typeof s=="object"?{...i,...s}:!1};st&&(e.usePolling=!0),e.atomic===void 0&&(e.atomic=!e.usePolling);let n=process.env.CHOKIDAR_USEPOLLING;if(n!==void 0){let a=n.toLowerCase();a==="false"||a==="0"?e.usePolling=!1:a==="true"||a==="1"?e.usePolling=!0:e.usePolling=!!a}let h=process.env.CHOKIDAR_INTERVAL;h&&(e.interval=Number.parseInt(h,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=F,this._readyEmitted=!0,process.nextTick(()=>this.emit(m.READY)))},this._emitRaw=(...a)=>this.emit(m.RAW,...a),this._boundRemove=this._remove.bind(this),this.options=e,this._nodeFsHandler=new v(this),Object.freeze(e)}_addIgnoredPath(t){if(j(t)){for(let s of this._ignoredPaths)if(j(s)&&s.path===t.path&&s.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let s of this._ignoredPaths)j(s)&&s.path===t&&this._ignoredPaths.delete(s)}add(t,s,i){let{cwd:e}=this.options;this.closed=!1,this._closePromise=void 0;let n=nt(t);return e&&(n=n.map(h=>Zt(h,e))),n.forEach(h=>{this._removeIgnoredPath(h)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=n.length,Promise.all(n.map(async h=>{let o=await this._nodeFsHandler._addToNodeFs(h,!i,void 0,0,s);return o&&this._emitReady(),o})).then(h=>{this.closed||h.forEach(o=>{o&&this.add(d.dirname(o),d.basename(s||o))})}),this}unwatch(t){if(this.closed)return this;let s=nt(t),{cwd:i}=this.options;return s.forEach(e=>{!d.isAbsolute(e)&&!this._closers.has(e)&&(i&&(e=d.join(i,e)),e=d.resolve(e)),this._closePath(e),this._addIgnoredPath(e),this._watched.has(e)&&this._addIgnoredPath({path:e,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(s=>s.forEach(i=>{let e=i();e instanceof Promise&&t.push(e)})),this._streams.forEach(s=>s.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(s=>s.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((s,i)=>{let n=(this.options.cwd?d.relative(this.options.cwd,i):i)||ht;t[n]=s.getChildren().sort()}),t}emitWithAll(t,s){this.emit(t,...s),t!==m.ERROR&&this.emit(m.ALL,t,...s)}async _emit(t,s,i){if(this.closed)return;let e=this.options;M&&(s=d.normalize(s)),e.cwd&&(s=d.relative(e.cwd,s));let n=[s];i!=null&&n.push(i);let h=e.awaitWriteFinish,o;if(h&&(o=this._pendingWrites.get(s)))return o.lastChange=new Date,this;if(e.atomic){if(t===m.UNLINK)return this._pendingUnlinks.set(s,[t,...n]),setTimeout(()=>{this._pendingUnlinks.forEach((a,l)=>{this.emit(...a),this.emit(m.ALL,...a),this._pendingUnlinks.delete(l)})},typeof e.atomic=="number"?e.atomic:100),this;t===m.ADD&&this._pendingUnlinks.has(s)&&(t=m.CHANGE,this._pendingUnlinks.delete(s))}if(h&&(t===m.ADD||t===m.CHANGE)&&this._readyEmitted){let a=(l,c)=>{l?(t=m.ERROR,n[0]=l,this.emitWithAll(t,n)):c&&(n.length>1?n[1]=c:n.push(c),this.emitWithAll(t,n))};return this._awaitWriteFinish(s,h.stabilityThreshold,t,a),this}if(t===m.CHANGE&&!this._throttle(m.CHANGE,s,50))return this;if(e.alwaysStat&&i===void 0&&(t===m.ADD||t===m.ADD_DIR||t===m.CHANGE)){let a=e.cwd?d.join(e.cwd,s):s,l;try{l=await jt(a)}catch{}if(!l||this.closed)return;n.push(l)}return this.emitWithAll(t,n),this}_handleError(t){let s=t&&t.code;return t&&s!=="ENOENT"&&s!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||s!=="EPERM"&&s!=="EACCES")&&this.emit(m.ERROR,t),t||this.closed}_throttle(t,s,i){this._throttled.has(t)||this._throttled.set(t,new Map);let e=this._throttled.get(t);if(!e)throw new Error("invalid throttle");let n=e.get(s);if(n)return n.count++,!1;let h,o=()=>{let l=e.get(s),c=l?l.count:0;return e.delete(s),clearTimeout(h),l&&clearTimeout(l.timeoutObject),c};h=setTimeout(o,i);let a={timeoutObject:h,clear:o,count:0};return e.set(s,a),a}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,s,i,e){let n=this.options.awaitWriteFinish;if(typeof n!="object")return;let h=n.pollInterval,o,a=t;this.options.cwd&&!d.isAbsolute(t)&&(a=d.join(this.options.cwd,t));let l=new Date,c=this._pendingWrites;function f(u){Ht(a,(w,p)=>{if(w||!c.has(t)){w&&w.code!=="ENOENT"&&e(w);return}let R=Number(new Date);u&&p.size!==u.size&&(c.get(t).lastChange=R);let lt=c.get(t);R-lt.lastChange>=s?(c.delete(t),e(void 0,p)):o=setTimeout(f,h,p)})}c.has(t)||(c.set(t,{lastChange:l,cancelWait:()=>(c.delete(t),clearTimeout(o),i)}),o=setTimeout(f,h))}_isIgnored(t,s){if(this.options.atomic&&$t.test(t))return!0;if(!this._userIgnored){let{cwd:i}=this.options,n=(this.options.ignored||[]).map(at(i)),o=[...[...this._ignoredPaths].map(at(i)),...n];this._userIgnored=Xt(o,void 0)}return this._userIgnored(t,s)}_isntIgnored(t,s){return!this._isIgnored(t,s)}_getWatchHelpers(t){return new U(t,this.options.followSymlinks,this)}_getWatchedDir(t){let s=d.resolve(t);return this._watched.has(s)||this._watched.set(s,new Y(s,this._boundRemove)),this._watched.get(s)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,s,i){let e=d.join(t,s),n=d.resolve(e);if(i=i??(this._watched.has(e)||this._watched.has(n)),!this._throttle("remove",e,100))return;!i&&this._watched.size===1&&this.add(t,s,!0),this._getWatchedDir(e).getChildren().forEach(u=>this._remove(e,u));let a=this._getWatchedDir(t),l=a.has(s);a.remove(s),this._symlinkPaths.has(n)&&this._symlinkPaths.delete(n);let c=e;if(this.options.cwd&&(c=d.relative(this.options.cwd,e)),this.options.awaitWriteFinish&&this._pendingWrites.has(c)&&this._pendingWrites.get(c).cancelWait()===m.ADD)return;this._watched.delete(e),this._watched.delete(n);let f=i?m.UNLINK_DIR:m.UNLINK;l&&!this._isIgnored(e)&&this._emit(f,e),this._closePath(e)}_closePath(t){this._closeFile(t);let s=d.dirname(t);this._getWatchedDir(s).remove(d.basename(t))}_closeFile(t){let s=this._closers.get(t);s&&(s.forEach(i=>i()),this._closers.delete(t))}_addPathCloser(t,s){if(!s)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(s)}_readdirp(t,s){if(this.closed)return;let i={type:m.ALL,alwaysStat:!0,lstat:!0,...s,depth:0},e=J(t,i);return this._streams.add(e),e.once(tt,()=>{e=void 0}),e.once(z,()=>{e&&(this._streams.delete(e),e=void 0)}),e}};function is(r,t={}){let s=new N(t);return s.add(r),s}var ys={watch:is,FSWatcher:N};export{N as FSWatcher,U as WatchHelper,ys as default,is as watch};
2
+ /*! Bundled license information:
3
+
4
+ chokidar/esm/index.js:
5
+ (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
6
+ */
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";var Se=Object.create;var $=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var De=(s,t)=>{for(var e in t)$(s,e,{get:t[e],enumerable:!0})},$t=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ve(t))!Le.call(s,r)&&r!==e&&$(s,r,{get:()=>t[r],enumerable:!(n=Pe(t,r))||n.enumerable});return s};var y=(s,t,e)=>(e=s!=null?Se(Re(s)):{},$t(t||!s||!s.__esModule?$(e,"default",{value:s,enumerable:!0}):e,s)),xe=s=>$t($({},"__esModule",{value:!0}),s);var fs={};De(fs,{TSRouter:()=>Y,createEffect:()=>St,createSignal:()=>_t,html:()=>nt,loadPyFiles:()=>Lt,mapper:()=>jt,renderChildRoutes:()=>Tt,useAnchor:()=>N,useAnchorSingle:()=>ft,useInitialDOM:()=>ut,useTSAnchorMount:()=>vt,useTSAuth:()=>wt,useTSCollection:()=>pt,useTSComponent:()=>H,useTSElementEach:()=>I,useTSElements:()=>dt,useTSEvent:()=>ot,useTSEventAll:()=>lt,useTSExtractParams:()=>ct,useTSFilebasedRouter:()=>_e,useTSHashAnchor:()=>F,useTSLazy:()=>Dt,useTSMetaData:()=>mt,useTSNavigate:()=>Et,useTSNoReload:()=>k,useTSOutlet:()=>yt,useTSParams:()=>C,useTSPurifier:()=>it,useTSSSRHydration:()=>xt,useTSSelect:()=>gt,useTSloadBrython:()=>Rt});module.exports=xe(fs);function Ae(s){return(s==null?"":String(s)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function nt(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?Ae(t[r]):"";return e+n+i},"")}function j(){let s=new Set;document.querySelectorAll("*").forEach(t=>{let e=t.tagName.toLowerCase();e.includes("-")&&s.add(e)}),s.forEach(t=>{customElements.get(t)||customElements.define(t,class extends HTMLElement{connectedCallback(){this.innerHTML=`<div style="padding:10px;background:#eee;">${t} (Auto)</div>`}})})}var be=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),jt=s=>s?.map(t=>be(t)).join("")??"";var rt=y(require("dompurify"),1),it=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?rt.default.sanitize(s,n):rt.default.sanitize(s.innerHTML,n)};var ot=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};var Ut=require("zustand/vanilla"),at=y(require("dompurify"),1);function Me(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=at.default.sanitize(i[c+1]??"")}),a}function Oe(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=at.default.sanitize(r);return t}var C=(0,Ut.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=Me(e,n),i=Oe(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function ct(s){let t=C.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var lt=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var U=y(require("dompurify"),1),dt=(s,t,e,n={})=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...e};U.default.addHook("uponSanitizeElement",(a,o)=>{let c=o.tagName.toLowerCase();c.includes("-")&&(o.allowedTags[c]=!0)}),U.default.addHook("uponSanitizeAttribute",(a,o)=>{o.attrName&&o.attrName.toLowerCase().startsWith("on")&&(o.keepAttr=!1)});let i=U.default.sanitize(t,r);s.innerHTML=i,s.querySelectorAll("[data-onclick]").forEach(a=>{let o=a.dataset.onclick;n[o]&&a.addEventListener("click",n[o])}),s.querySelectorAll("[data-onchange]").forEach(a=>{let o=a.dataset.onchange;n[o]&&a.addEventListener("change",n[o])}),s.querySelectorAll("[data-onselect]").forEach(a=>{let o=a.dataset.onselect;n[o]&&a.addEventListener("select",n[o])})};var qt=y(require("dompurify"),1),q=null,ut=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;let n=e.innerHTML,i=qt.default.sanitize(n,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(q!==null&&i!==q){let a=document.createElement("div");t(a),e.innerHTML=q}else q=i,e.innerHTML=i,t(e)};var ht=y(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var ft=(s,t,e,n="",r=null)=>{if(!s)return;let i=ht.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=ht.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var x=y(require("dompurify"),1);var Yt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'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",l=!1)=>{let d=()=>{try{let u=document.querySelector('meta[http-equiv="Content-Security-Policy"]');u||(u=document.createElement("meta"),u.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(u));let h=l?`report-uri ${c};`:"";u.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${h}`)}catch(u){console.error("Error adding CSP meta element:",u)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var mt=(s,t)=>{let e={name:x.default.sanitize(s.name||""),description:x.default.sanitize(s.description||"Default description"),author:x.default.sanitize(s.author||"")},n=f=>{e.name=x.default.sanitize(f),u("name",e.name)},r=f=>{e.description=x.default.sanitize(f),u("description",e.description)},i=f=>{e.author=x.default.sanitize(f),u("author",e.author)},a=()=>e.name,o=()=>e.description,c=()=>e.author,l=()=>e,d=(f,p)=>{let g=document.createElement("meta");g.setAttribute("name",f),g.setAttribute("content",p),document.head.appendChild(g)},u=(f,p)=>{let g=document.querySelector(`meta[name="${f}"]`);g?g.setAttribute("content",p):d(f,p)},h=()=>{u("name",e.name),u("description",e.description),u("author",e.author)};return t&&Yt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),h(),{setName:n,setDescription:r,setAuthor:i,getName:a,getDescription:o,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:h}};var Gt=y(require("dompurify"),1),H=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=Gt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var pt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.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=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?H(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var gt=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Bt=require("jwt-decode"),wt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Bt.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var I=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var Et=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var yt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function Tt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Vt=require("zustand/vanilla");function _t(s){let t=(0,Vt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function St(s){let t=s();typeof t=="function"&&t()}var F=()=>{let s=document.querySelectorAll('a[href^="#"]');I(s,["click"],(t,e)=>{e.preventDefault();let n=t.getAttribute("href")?.substring(1),r=n?document.getElementById(n):null;r&&r.scrollIntoView({behavior:"smooth",block:"start"})})};var Kt=require("lodash-es"),Pt=s=>s;typeof window<"u"&&typeof document<"u"&&(Pt=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var Ce=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",Pt(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",Pt(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},He=(0,Kt.debounce)(Ce,50),N=s=>{He(s)};var k=s=>{let t=s.querySelectorAll("a");N(t)};var vt=s=>{F(),k(s)};var Rt=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Lt=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Dt(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){e?.appendChild(t);return}if(t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var xt=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var At=y(require("dompurify"),1);var Jt=require("zustand/vanilla"),Xt=y(require("dompurify"),1),L=(0,Jt.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:Qt(t)})),setQuery:t=>s(()=>({query:Qt(t)}))}));function Qt(s){let t={};for(let e in s)t[e]=Xt.default.sanitize(s[e]);return t}var Y=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);L.getState().setParams(i),L.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);L.getState().setParams(a),L.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(L.getState().setParams(l),L.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let d=e.slice(a.path.length);this.renderChildren(a.children,d,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=At.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,u=>(o.push(u.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=t.match(l);if(d){let u={...n};if(o.forEach((h,f)=>{u[h]=d[f+1]??""}),r.children){let h=t.slice(d[0].length),f=this.findMatchingRoute(h,r.children,u);if(f)return f}return{...r,params:u}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=At.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var D=y(require("fs/promises"),1),P=y(require("path"),1);var pe=require("fs"),tt=require("fs/promises"),ge=require("events"),m=y(require("path"),1);var v=require("fs/promises"),se=require("stream"),R=require("path"),T={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},bt={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:T.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(bt);var ne="READDIRP_RECURSIVE_ERROR",Ie=new Set(["ENOENT","EPERM","EACCES","ELOOP",ne]),Zt=[T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE],Fe=new Set([T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE]),Ne=new Set([T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE]),ke=s=>Ie.has(s.code),ze=process.platform==="win32",te=s=>!0,ee=s=>{if(s===void 0)return te;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return te},Mt=class extends se.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...bt,...t},{root:n,type:r}=e;this._fileFilter=ee(e.fileFilter),this._directoryFilter=ee(e.directoryFilter);let i=e.lstat?v.lstat:v.stat;ze?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??bt.depth,this._wantsDir=r?Fe.has(r):!1,this._wantsFile=r?Ne.has(r):!1,this._wantsEverything=r===T.EVERYTHING_TYPE,this._root=(0,R.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,v.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,R.resolve)((0,R.join)(e,r));n={path:(0,R.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){ke(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,v.realpath)(n),i=await(0,v.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===R.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=ne,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function re(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=T.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!Zt.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${Zt.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Mt(t)}var b=require("fs"),S=require("fs/promises"),w=y(require("path"),1),oe=require("os"),We="data",Ht="end",ae="close",Q=()=>{};var J=process.platform,It=J==="win32",$e=J==="darwin",je=J==="linux",Ue=J==="freebsd",ce=(0,oe.type)()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},_=E,qe="watch",Ye={lstat:S.lstat,stat:S.stat},A="listeners",G="errHandlers",M="rawEmitters",Ge=[A,G,M],Be=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"]),Ve=s=>Be.has(w.extname(s).slice(1).toLowerCase()),Ct=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},z=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},Ke=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},W=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},le=s=>s instanceof Set?s.size===0:!s,B=new Map;function ie(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&V(w.resolve(s,o),A,w.join(s,o))};try{return(0,b.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var V=(s,t,e,n,r)=>{let i=B.get(s);i&&Ct(i[t],a=>{a(e,n,r)})},Qe=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=B.get(t),c;if(!e.persistent)return c=ie(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)z(o,A,r),z(o,G,i),z(o,M,a);else{if(c=ie(s,e,V.bind(null,t,A),i,V.bind(null,t,M)),!c)return;c.on(_.ERROR,async l=>{let d=V.bind(null,t,G);if(o&&(o.watcherUnusable=!0),It&&l.code==="EPERM")try{await(await(0,S.open)(s,"r")).close(),d(l)}catch{}else d(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},B.set(t,o)}return()=>{W(o,A,r),W(o,G,i),W(o,M,a),le(o.listeners)&&(o.watcher.close(),B.delete(t),Ge.forEach(Ke(o)),o.watcher=void 0,Object.freeze(o))}},Ot=new Map,Je=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=Ot.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,b.unwatchFile)(t),a=void 0),a?(z(a,A,r),z(a,M,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,b.watchFile)(t,e,(c,l)=>{Ct(a.rawEmitters,u=>{u(_.CHANGE,t,{curr:c,prev:l})});let d=c.mtimeMs;(c.size!==l.size||d>l.mtimeMs||d===0)&&Ct(a.listeners,u=>u(s,c))})},Ot.set(t,a)),()=>{W(a,A,r),W(a,M,i),le(a.listeners)&&(Ot.delete(t),(0,b.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},K=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=w.dirname(t),i=w.basename(t);this.fsw._getWatchedDir(r).add(i);let o=w.resolve(t),c={persistent:n.persistent};e||(e=Q);let l;if(n.usePolling){let d=n.interval!==n.binaryInterval;c.interval=d&&Ve(i)?n.binaryInterval:n.interval,l=Je(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=Qe(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=w.dirname(t),i=w.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(d,u)=>{if(this.fsw._throttle(qe,t,5)){if(!u||u.mtimeMs===0)try{let h=await(0,S.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,p=h.mtimeMs;if((!f||f<=p||p!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,h),($e||je||Ue)&&o.ino!==h.ino){this.fsw._closeFile(d),o=h;let g=this._watchWithNodeFs(t,c);g&&this.fsw._addPathCloser(d,g)}else o=h}catch{this.fsw._remove(r,i)}else if(a.has(i)){let h=u.atimeMs,f=u.mtimeMs;(!h||h<=f||f!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,u),o=u}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(_.ADD,t,0))return;this.fsw._emit(_.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,S.realpath)(n)}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(_.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(_.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=w.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,d=this.fsw._readdirp(t,{fileFilter:u=>n.filterPath(u),directoryFilter:u=>n.filterDir(u)});if(d)return d.on(We,async u=>{if(this.fsw.closed){d=void 0;return}let h=u.path,f=w.join(t,h);if(l.add(h),!(u.stats.isSymbolicLink()&&await this._handleSymlink(u,t,f,h))){if(this.fsw.closed){d=void 0;return}(h===r||!r&&!c.has(h))&&(this.fsw._incrReadyCount(),f=w.join(i,w.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(_.ERROR,this._boundHandleError),new Promise((u,h)=>{if(!d)return h();d.once(Ht,()=>{if(this.fsw.closed){d=void 0;return}let f=o?o.clear():!1;u(void 0),c.getChildren().filter(p=>p!==t&&!l.has(p)).forEach(p=>{this.fsw._remove(t,p)}),d=void 0,f&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(w.dirname(t)),l=c.has(w.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(_.ADD_DIR,t,e),c.add(w.basename(t)),this.fsw._getWatchedDir(t);let d,u,h=this.fsw.options.depth;if((h==null||r<=h)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,d),this.fsw.closed))return;u=this._watchWithNodeFs(t,(f,p)=>{p&&p.mtimeMs===0||this._handleRead(f,!1,a,i,t,r,d)})}return u}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await Ye[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,d;if(c.isDirectory()){let u=w.resolve(t),h=l?await(0,S.realpath)(t):t;if(this.fsw.closed||(d=await this._handleDir(o.watchPath,c,e,r,i,o,h),this.fsw.closed))return;u!==h&&h!==void 0&&this.fsw._symlinkPaths.set(u,h)}else if(c.isSymbolicLink()){let u=l?await(0,S.realpath)(t):t;if(this.fsw.closed)return;let h=w.dirname(o.watchPath);if(this.fsw._getWatchedDir(h).add(o.watchPath),this.fsw._emit(_.ADD,o.watchPath,c),d=await this._handleDir(h,c,e,r,t,o,u),this.fsw.closed)return;u!==void 0&&this.fsw._symlinkPaths.set(w.resolve(t),u)}else d=this._handleFile(o.watchPath,c,e);return a(),d&&this.fsw._addPathCloser(t,d),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}};var Ft="/",Xe="//",we=".",Ze="..",ts="string",es=/\\/g,de=/\/\//,ss=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ns=/^\.[/\\]/;function X(s){return Array.isArray(s)?s:[s]}var Nt=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);function rs(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=m.relative(s.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function is(s){if(typeof s!="string")throw new Error("string expected");s=m.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function ue(s,t,e){let n=is(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function os(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=X(s).map(r=>rs(r));return t==null?(r,i)=>ue(n,r,i):ue(n,t)}var he=s=>{let t=X(s).flat();if(!t.every(e=>typeof e===ts))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Ee)},fe=s=>{let t=s.replace(es,Ft),e=!1;for(t.startsWith(Xe)&&(e=!0);t.match(de);)t=t.replace(de,Ft);return e&&(t=Ft+t),t},Ee=s=>fe(m.normalize(fe(s))),me=(s="")=>t=>typeof t=="string"?Ee(m.isAbsolute(t)?t:m.join(s,t)):t,as=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),cs=Object.freeze(new Set),kt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==we&&t!==Ze&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,tt.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Q,this.items=cs,Object.freeze(this)}},ls="stat",ds="lstat",zt=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(ns,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?ls:ds}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},Z=class extends ge.EventEmitter{constructor(t={}){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 e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?X(t.ignored):X([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};ce&&(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=Q,this._readyEmitted=!0,process.nextTick(()=>this.emit(E.READY)))},this._emitRaw=(...c)=>this.emit(E.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new K(this),Object.freeze(r)}_addIgnoredPath(t){if(Nt(t)){for(let e of this._ignoredPaths)if(Nt(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)Nt(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=he(t);return r&&(i=i.map(a=>as(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,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=he(t),{cwd:n}=this.options;return e.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=m.join(n,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 t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?m.relative(this.options.cwd,n):n)||we;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==E.ERROR&&this.emit(E.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;It&&(e=m.normalize(e)),r.cwd&&(e=m.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===E.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(E.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===E.ADD&&this._pendingUnlinks.has(e)&&(t=E.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===E.ADD||t===E.CHANGE)&&this._readyEmitted){let c=(l,d)=>{l?(t=E.ERROR,i[0]=l,this.emitWithAll(t,i)):d&&(i.length>1?i[1]=d:i.push(d),this.emitWithAll(t,i))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===E.CHANGE&&!this._throttle(E.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===E.ADD||t===E.ADD_DIR||t===E.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,l;try{l=await(0,tt.stat)(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(E.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),d=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),d};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!m.isAbsolute(t)&&(c=m.join(this.options.cwd,t));let l=new Date,d=this._pendingWrites;function u(h){(0,pe.stat)(c,(f,p)=>{if(f||!d.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let g=Number(new Date);h&&p.size!==h.size&&(d.get(t).lastChange=g);let st=d.get(t);g-st.lastChange>=e?(d.delete(t),r(void 0,p)):o=setTimeout(u,a,p)})}d.has(t)||(d.set(t,{lastChange:l,cancelWait:()=>(d.delete(t),clearTimeout(o),n)}),o=setTimeout(u,a))}_isIgnored(t,e){if(this.options.atomic&&ss.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(me(n)),o=[...[...this._ignoredPaths].map(me(n)),...i];this._userIgnored=os(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new zt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new kt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=m.join(t,e),i=m.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(h=>this._remove(r,h));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let d=r;if(this.options.cwd&&(d=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===E.ADD)return;this._watched.delete(r),this._watched.delete(i);let u=n?E.UNLINK_DIR:E.UNLINK;l&&!this._isIgnored(r)&&this._emit(u,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:E.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=re(t,n);return this._streams.add(r),r.once(ae,()=>{r=void 0}),r.once(Ht,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function us(s,t={}){let e=new Z(t);return e.add(s),e}var Wt={watch:us,FSWatcher:Z};var O=P.default.resolve("src/pages"),ye=P.default.resolve("src/gen"),Te=P.default.resolve("src/routes"),hs=P.default.join(ye,"tsrouter.gen.ts"),et=P.default.join(Te,"__root.ts"),_e=async()=>{if(typeof window>"u"){console.log("\u26A0\uFE0F Skipping TS file-based router generation in SSR/Node environment");return}async function s(c){try{await D.default.mkdir(c,{recursive:!0})}catch{}}await s(ye),await s(Te);function t(c,l){let d="/"+P.default.relative(l,c).replace(/\\/g,"/");return d=d.replace(/\.ts$/,""),d=d.replace(/\/index$/,"")||"/",d=d.replace(/\[(.+?)\]/g,":$1"),d}function e(c){return c.replace(/^\//,"").split("/").map(l=>l.startsWith(":")?l.slice(1):l).filter(Boolean).join("-")||"index"}function n(c,l){let u=P.default.relative(l,c).replace(/\\/g,"/").split("/").filter(Boolean),h=u[u.length-1].replace(".ts",""),f=u.length>1?u[u.length-2]:"";if(h.startsWith("[")&&h.endsWith("]")){let p=h.slice(1,-1);return f.charAt(0).toUpperCase()+f.slice(1)+p.charAt(0).toUpperCase()+p.slice(1)+"Param"}else return h.charAt(0).toUpperCase()+h.slice(1)}async function r(c){let l=await D.default.readdir(c,{withFileTypes:!0}),d=[];for(let u of l){let h=P.default.join(c,u.name);if(u.isDirectory())d=d.concat(await r(h));else if(u.isFile()&&u.name.endsWith(".ts")){let f=t(h,O),p=e(f),g=n(h,O);d.push({file:h,route:f,routeName:p,importName:g})}}return d}function i(c,l){return`import { html, useTSElements, useTSExtractParams, useTSMetaData } from '@devwareng/vanilla-ts'
1
+ "use strict";var xe=Object.create;var j=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var rt=(s,t)=>()=>(s&&(t=s(s=0)),t);var $t=(s,t)=>{for(var e in t)j(s,e,{get:t[e],enumerable:!0})},jt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ae(t))!Oe.call(s,r)&&r!==e&&j(s,r,{get:()=>t[r],enumerable:!(n=be(t,r))||n.enumerable});return s};var y=(s,t,e)=>(e=s!=null?xe(Me(s)):{},jt(t||!s||!s.__esModule?j(e,"default",{value:s,enumerable:!0}):e,s)),Ce=s=>jt(j({},"__esModule",{value:!0}),s);function Vt(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=T.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!Ut.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${Ut.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new at(t)}var v,Gt,R,T,ot,Bt,Ie,Ut,Fe,Ne,ke,ze,qt,Yt,at,Kt=rt(()=>{"use strict";v=require("fs/promises"),Gt=require("stream"),R=require("path"),T={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},ot={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:T.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(ot);Bt="READDIRP_RECURSIVE_ERROR",Ie=new Set(["ENOENT","EPERM","EACCES","ELOOP",Bt]),Ut=[T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE],Fe=new Set([T.DIR_TYPE,T.EVERYTHING_TYPE,T.FILE_DIR_TYPE]),Ne=new Set([T.EVERYTHING_TYPE,T.FILE_DIR_TYPE,T.FILE_TYPE]),ke=s=>Ie.has(s.code),ze=process.platform==="win32",qt=s=>!0,Yt=s=>{if(s===void 0)return qt;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return qt},at=class extends Gt.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...ot,...t},{root:n,type:r}=e;this._fileFilter=Yt(e.fileFilter),this._directoryFilter=Yt(e.directoryFilter);let i=e.lstat?v.lstat:v.stat;ze?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??ot.depth,this._wantsDir=r?Fe.has(r):!1,this._wantsFile=r?Ne.has(r):!1,this._wantsEverything=r===T.EVERYTHING_TYPE,this._root=(0,R.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let d=await this._getEntryType(c);d==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(d==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,v.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,R.resolve)((0,R.join)(e,r));n={path:(0,R.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){ke(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,v.realpath)(n),i=await(0,v.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===R.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=Bt,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function Qt(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&G(w.resolve(s,o),x,w.join(s,o))};try{return(0,b.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var b,S,w,Jt,We,dt,Xt,V,K,ut,$e,je,Ue,Zt,E,_,qe,Ye,x,q,M,Ge,Be,Ve,lt,C,Ke,H,te,Y,G,Qe,ct,Je,B,ee=rt(()=>{"use strict";b=require("fs"),S=require("fs/promises"),w=y(require("path"),1),Jt=require("os"),We="data",dt="end",Xt="close",V=()=>{},K=process.platform,ut=K==="win32",$e=K==="darwin",je=K==="linux",Ue=K==="freebsd",Zt=(0,Jt.type)()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},_=E,qe="watch",Ye={lstat:S.lstat,stat:S.stat},x="listeners",q="errHandlers",M="rawEmitters",Ge=[x,q,M],Be=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"]),Ve=s=>Be.has(w.extname(s).slice(1).toLowerCase()),lt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},C=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},Ke=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},H=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},te=s=>s instanceof Set?s.size===0:!s,Y=new Map;G=(s,t,e,n,r)=>{let i=Y.get(s);i&&lt(i[t],a=>{a(e,n,r)})},Qe=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=Y.get(t),c;if(!e.persistent)return c=Qt(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)C(o,x,r),C(o,q,i),C(o,M,a);else{if(c=Qt(s,e,G.bind(null,t,x),i,G.bind(null,t,M)),!c)return;c.on(_.ERROR,async d=>{let l=G.bind(null,t,q);if(o&&(o.watcherUnusable=!0),ut&&d.code==="EPERM")try{await(await(0,S.open)(s,"r")).close(),l(d)}catch{}else l(d)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},Y.set(t,o)}return()=>{H(o,x,r),H(o,q,i),H(o,M,a),te(o.listeners)&&(o.watcher.close(),Y.delete(t),Ge.forEach(Ke(o)),o.watcher=void 0,Object.freeze(o))}},ct=new Map,Je=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=ct.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,b.unwatchFile)(t),a=void 0),a?(C(a,x,r),C(a,M,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,b.watchFile)(t,e,(c,d)=>{lt(a.rawEmitters,u=>{u(_.CHANGE,t,{curr:c,prev:d})});let l=c.mtimeMs;(c.size!==d.size||l>d.mtimeMs||l===0)&&lt(a.listeners,u=>u(s,c))})},ct.set(t,a)),()=>{H(a,x,r),H(a,M,i),te(a.listeners)&&(ct.delete(t),(0,b.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},B=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=w.dirname(t),i=w.basename(t);this.fsw._getWatchedDir(r).add(i);let o=w.resolve(t),c={persistent:n.persistent};e||(e=V);let d;if(n.usePolling){let l=n.interval!==n.binaryInterval;c.interval=l&&Ve(i)?n.binaryInterval:n.interval,d=Je(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else d=Qe(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return d}_handleFile(t,e,n){if(this.fsw.closed)return;let r=w.dirname(t),i=w.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(l,u)=>{if(this.fsw._throttle(qe,t,5)){if(!u||u.mtimeMs===0)try{let h=await(0,S.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,p=h.mtimeMs;if((!f||f<=p||p!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,h),($e||je||Ue)&&o.ino!==h.ino){this.fsw._closeFile(l),o=h;let g=this._watchWithNodeFs(t,c);g&&this.fsw._addPathCloser(l,g)}else o=h}catch{this.fsw._remove(r,i)}else if(a.has(i)){let h=u.atimeMs,f=u.mtimeMs;(!h||h<=f||f!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,u),o=u}}},d=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(_.ADD,t,0))return;this.fsw._emit(_.ADD,t,e)}return d}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,S.realpath)(n)}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(_.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(_.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=w.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),d=new Set,l=this.fsw._readdirp(t,{fileFilter:u=>n.filterPath(u),directoryFilter:u=>n.filterDir(u)});if(l)return l.on(We,async u=>{if(this.fsw.closed){l=void 0;return}let h=u.path,f=w.join(t,h);if(d.add(h),!(u.stats.isSymbolicLink()&&await this._handleSymlink(u,t,f,h))){if(this.fsw.closed){l=void 0;return}(h===r||!r&&!c.has(h))&&(this.fsw._incrReadyCount(),f=w.join(i,w.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(_.ERROR,this._boundHandleError),new Promise((u,h)=>{if(!l)return h();l.once(dt,()=>{if(this.fsw.closed){l=void 0;return}let f=o?o.clear():!1;u(void 0),c.getChildren().filter(p=>p!==t&&!d.has(p)).forEach(p=>{this.fsw._remove(t,p)}),l=void 0,f&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(w.dirname(t)),d=c.has(w.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!d&&this.fsw._emit(_.ADD_DIR,t,e),c.add(w.basename(t)),this.fsw._getWatchedDir(t);let l,u,h=this.fsw.options.depth;if((h==null||r<=h)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,l),this.fsw.closed))return;u=this._watchWithNodeFs(t,(f,p)=>{p&&p.mtimeMs===0||this._handleRead(f,!1,a,i,t,r,l)})}return u}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await Ye[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let d=this.fsw.options.followSymlinks,l;if(c.isDirectory()){let u=w.resolve(t),h=d?await(0,S.realpath)(t):t;if(this.fsw.closed||(l=await this._handleDir(o.watchPath,c,e,r,i,o,h),this.fsw.closed))return;u!==h&&h!==void 0&&this.fsw._symlinkPaths.set(u,h)}else if(c.isSymbolicLink()){let u=d?await(0,S.realpath)(t):t;if(this.fsw.closed)return;let h=w.dirname(o.watchPath);if(this.fsw._getWatchedDir(h).add(o.watchPath),this.fsw._emit(_.ADD,o.watchPath,c),l=await this._handleDir(h,c,e,r,t,o,u),this.fsw.closed)return;u!==void 0&&this.fsw._symlinkPaths.set(w.resolve(t),u)}else l=this._handleFile(o.watchPath,c,e);return a(),l&&this.fsw._addPathCloser(t,l),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}}});var he={};$t(he,{FSWatcher:()=>I,WatchHelper:()=>J,default:()=>us,watch:()=>ue});function Q(s){return Array.isArray(s)?s:[s]}function rs(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=m.relative(s.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function is(s){if(typeof s!="string")throw new Error("string expected");s=m.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function ne(s,t,e){let n=is(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function os(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=Q(s).map(r=>rs(r));return t==null?(r,i)=>ne(n,r,i):ne(n,t)}function ue(s,t={}){let e=new I(t);return e.add(s),e}var ae,X,ce,m,ht,Xe,le,Ze,ts,es,se,ss,ns,ft,re,ie,de,oe,as,cs,mt,ls,ds,J,I,us,fe=rt(()=>{"use strict";ae=require("fs"),X=require("fs/promises"),ce=require("events"),m=y(require("path"),1);Kt();ee();ht="/",Xe="//",le=".",Ze="..",ts="string",es=/\\/g,se=/\/\//,ss=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ns=/^\.[/\\]/;ft=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);re=s=>{let t=Q(s).flat();if(!t.every(e=>typeof e===ts))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(de)},ie=s=>{let t=s.replace(es,ht),e=!1;for(t.startsWith(Xe)&&(e=!0);t.match(se);)t=t.replace(se,ht);return e&&(t=ht+t),t},de=s=>ie(m.normalize(ie(s))),oe=(s="")=>t=>typeof t=="string"?de(m.isAbsolute(t)?t:m.join(s,t)):t,as=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),cs=Object.freeze(new Set),mt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==le&&t!==Ze&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,X.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=V,this.items=cs,Object.freeze(this)}},ls="stat",ds="lstat",J=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(ns,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?ls:ds}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},I=class extends ce.EventEmitter{constructor(t={}){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 e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?Q(t.ignored):Q([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};Zt&&(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=V,this._readyEmitted=!0,process.nextTick(()=>this.emit(E.READY)))},this._emitRaw=(...c)=>this.emit(E.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new B(this),Object.freeze(r)}_addIgnoredPath(t){if(ft(t)){for(let e of this._ignoredPaths)if(ft(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)ft(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=re(t);return r&&(i=i.map(a=>as(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,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=re(t),{cwd:n}=this.options;return e.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=m.join(n,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 t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?m.relative(this.options.cwd,n):n)||le;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==E.ERROR&&this.emit(E.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;ut&&(e=m.normalize(e)),r.cwd&&(e=m.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===E.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,d)=>{this.emit(...c),this.emit(E.ALL,...c),this._pendingUnlinks.delete(d)})},typeof r.atomic=="number"?r.atomic:100),this;t===E.ADD&&this._pendingUnlinks.has(e)&&(t=E.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===E.ADD||t===E.CHANGE)&&this._readyEmitted){let c=(d,l)=>{d?(t=E.ERROR,i[0]=d,this.emitWithAll(t,i)):l&&(i.length>1?i[1]=l:i.push(l),this.emitWithAll(t,i))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===E.CHANGE&&!this._throttle(E.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===E.ADD||t===E.ADD_DIR||t===E.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,d;try{d=await(0,X.stat)(c)}catch{}if(!d||this.closed)return;i.push(d)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(E.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let d=r.get(e),l=d?d.count:0;return r.delete(e),clearTimeout(a),d&&clearTimeout(d.timeoutObject),l};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!m.isAbsolute(t)&&(c=m.join(this.options.cwd,t));let d=new Date,l=this._pendingWrites;function u(h){(0,ae.stat)(c,(f,p)=>{if(f||!l.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let g=Number(new Date);h&&p.size!==h.size&&(l.get(t).lastChange=g);let nt=l.get(t);g-nt.lastChange>=e?(l.delete(t),r(void 0,p)):o=setTimeout(u,a,p)})}l.has(t)||(l.set(t,{lastChange:d,cancelWait:()=>(l.delete(t),clearTimeout(o),n)}),o=setTimeout(u,a))}_isIgnored(t,e){if(this.options.atomic&&ss.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(oe(n)),o=[...[...this._ignoredPaths].map(oe(n)),...i];this._userIgnored=os(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new J(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new mt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=m.join(t,e),i=m.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(h=>this._remove(r,h));let c=this._getWatchedDir(t),d=c.has(e);c.remove(e),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()===E.ADD)return;this._watched.delete(r),this._watched.delete(i);let u=n?E.UNLINK_DIR:E.UNLINK;d&&!this._isIgnored(r)&&this._emit(u,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:E.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=Vt(t,n);return this._streams.add(r),r.once(Xt,()=>{r=void 0}),r.once(dt,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};us={watch:ue,FSWatcher:I}});var Es={};$t(Es,{TSRouter:()=>st,createEffect:()=>Ct,createSignal:()=>Ot,html:()=>it,loadPyFiles:()=>Nt,mapper:()=>we,renderChildRoutes:()=>Mt,useAnchor:()=>W,useAnchorSingle:()=>vt,useInitialDOM:()=>St,useTSAnchorMount:()=>It,useTSAuth:()=>xt,useTSCollection:()=>Lt,useTSComponent:()=>N,useTSElementEach:()=>k,useTSElements:()=>_t,useTSEvent:()=>wt,useTSEventAll:()=>Tt,useTSExtractParams:()=>yt,useTSHashAnchor:()=>z,useTSLazy:()=>kt,useTSMetaData:()=>Rt,useTSNavigate:()=>bt,useTSNoReload:()=>$,useTSOutlet:()=>At,useTSParams:()=>F,useTSPurifier:()=>gt,useTSSSRHydration:()=>zt,useTSSelect:()=>Dt,useTSloadBrython:()=>Ft});module.exports=Ce(Es);function He(s){return(s==null?"":String(s)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function it(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?He(t[r]):"";return e+n+i},"")}function U(){let s=new Set;document.querySelectorAll("*").forEach(t=>{let e=t.tagName.toLowerCase();e.includes("-")&&s.add(e)}),s.forEach(t=>{customElements.get(t)||customElements.define(t,class extends HTMLElement{connectedCallback(){this.innerHTML=`<div style="padding:10px;background:#eee;">${t} (Auto)</div>`}})})}var L=y(require("fs/promises"),1),P=y(require("path"),1),O=P.default.resolve("src/pages"),me=P.default.resolve("src/gen"),pe=P.default.resolve("src/routes"),hs=P.default.join(me,"tsrouter.gen.ts"),Z=P.default.join(pe,"__root.ts"),ge=async()=>{if(typeof window>"u"){console.log("\u26A0\uFE0F Skipping TS file-based router generation in SSR/Node environment");return}async function s(c){try{await L.default.mkdir(c,{recursive:!0})}catch{}}await s(me),await s(pe);function t(c,d){let l="/"+P.default.relative(d,c).replace(/\\/g,"/");return l=l.replace(/\.ts$/,""),l=l.replace(/\/index$/,"")||"/",l=l.replace(/\[(.+?)\]/g,":$1"),l}function e(c){return c.replace(/^\//,"").split("/").map(d=>d.startsWith(":")?d.slice(1):d).filter(Boolean).join("-")||"index"}function n(c,d){let u=P.default.relative(d,c).replace(/\\/g,"/").split("/").filter(Boolean),h=u[u.length-1].replace(".ts",""),f=u.length>1?u[u.length-2]:"";if(h.startsWith("[")&&h.endsWith("]")){let p=h.slice(1,-1);return f.charAt(0).toUpperCase()+f.slice(1)+p.charAt(0).toUpperCase()+p.slice(1)+"Param"}else return h.charAt(0).toUpperCase()+h.slice(1)}async function r(c){let d=await L.default.readdir(c,{withFileTypes:!0}),l=[];for(let u of d){let h=P.default.join(c,u.name);if(u.isDirectory())l=l.concat(await r(h));else if(u.isFile()&&u.name.endsWith(".ts")){let f=t(h,O),p=e(f),g=n(h,O);l.push({file:h,route:f,routeName:p,importName:g})}}return l}function i(c,d){return`import { html, useTSElements, useTSExtractParams, useTSMetaData } from '@devwareng/vanilla-ts'
2
2
 
3
3
  export default function ${c}(DOM: HTMLElement) {
4
4
  useTSMetaData({ name: '${c.toLowerCase()}', description: '', author: '' })
5
- const params = useTSExtractParams("${l}")
5
+ const params = useTSExtractParams("${d}")
6
6
  return useTSElements(DOM, html\`
7
7
  <div class="p-4">
8
8
  <h1 class="font-semibold">${c}</h1>
@@ -17,9 +17,9 @@ export const Router = (DOM: HTMLElement) => {
17
17
  const router = createRouter(DOM)
18
18
  router.navigate(window.location.pathname)
19
19
  window.addEventListener("popstate", () => router.navigate(window.location.pathname))
20
- }`}async function o(){let c=await r(O),l=c.find(g=>g.route==="/notfound"),d=c.filter(g=>g.route!=="/notfound"),u=c.map(g=>{let st="../pages/"+P.default.relative(O,g.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`import ${g.importName} from "${st}";`}).join(`
21
- `),h=d.map(g=>`{ path: "${g.route}", name: "${g.routeName}", component: (DOM: HTMLElement) => ${g.importName}(DOM) }`).join(`,
22
- `),f=l?`export const NotFound = ${l.importName}`:"export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div><h1>404 - Page Not Found</h1></div>`)\n}",p=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
20
+ }`}async function o(){let c=await r(O),d=c.find(g=>g.route==="/notfound"),l=c.filter(g=>g.route!=="/notfound"),u=c.map(g=>{let nt="../pages/"+P.default.relative(O,g.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`import ${g.importName} from "${nt}";`}).join(`
21
+ `),h=l.map(g=>`{ path: "${g.route}", name: "${g.routeName}", component: (DOM: HTMLElement) => ${g.importName}(DOM) }`).join(`,
22
+ `),f=d?`export const NotFound = ${d.importName}`:"export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div><h1>404 - Page Not Found</h1></div>`)\n}",p=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
23
23
  import { html, useTSElements } from "@devwareng/vanilla-ts"
24
24
 
25
25
  ${u}
@@ -65,7 +65,7 @@ export function createRouter(DOM: HTMLElement) {
65
65
 
66
66
  navigate(window.location.pathname + window.location.search)
67
67
  return { navigate, routes: routeTree }
68
- }`;await D.default.writeFile(hs,p,"utf-8"),await D.default.writeFile(et,a(),"utf-8"),console.log("\u2705 Generated router and __root.ts")}typeof window<"u"&&(console.log("\u{1F440} Watching for changes in /src/pages and /src/routes/__root.ts..."),Wt.watch(O).on("all",async(c,l)=>{if(c==="add"&&l.endsWith(".ts")){let d=P.default.basename(l,".ts"),u=d.replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,p=>p.replace("-","").toUpperCase()),h=t(l,O);(await D.default.readFile(l,"utf-8")).trim()||(await D.default.writeFile(l,i(u,h),"utf-8"),console.log(`\u{1F4DD} Scaffolded page: ${d}.ts`))}await o()}),Wt.watch(et).on("unlink",async()=>{console.log("\u26A0\uFE0F __root.ts deleted. Recreating..."),await D.default.writeFile(et,a(),"utf-8"),console.log("\u{1F7E2} Recreated:",et)})),console.log("\u{1F7E2} TS Filebased Router Mounted Successfully...")};typeof window<"u"&&(window.addEventListener("popstate",()=>{j()}),window.addEventListener("DOMContentLoaded",j));0&&(module.exports={TSRouter,createEffect,createSignal,html,loadPyFiles,mapper,renderChildRoutes,useAnchor,useAnchorSingle,useInitialDOM,useTSAnchorMount,useTSAuth,useTSCollection,useTSComponent,useTSElementEach,useTSElements,useTSEvent,useTSEventAll,useTSExtractParams,useTSFilebasedRouter,useTSHashAnchor,useTSLazy,useTSMetaData,useTSNavigate,useTSNoReload,useTSOutlet,useTSParams,useTSPurifier,useTSSSRHydration,useTSSelect,useTSloadBrython});
68
+ }`;await L.default.writeFile(hs,p,"utf-8"),await L.default.writeFile(Z,a(),"utf-8"),console.log("\u2705 Generated router and __root.ts")}if(typeof window>"u")try{let c=await Promise.resolve().then(()=>(fe(),he));console.log("\u{1F440} Watching for changes in /src/pages and /src/routes/__root.ts..."),c.watch(O).on("all",async(d,l)=>{if(d==="add"&&l.endsWith(".ts")){let u=P.default.basename(l,".ts"),h=u.replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,g=>g.replace("-","").toUpperCase()),f=t(l,O);(await L.default.readFile(l,"utf-8")).trim()||(await L.default.writeFile(l,i(h,f),"utf-8"),console.log(`\u{1F4DD} Scaffolded page: ${u}.ts`))}await o()}),c.watch(Z).on("unlink",async()=>{console.log("\u26A0\uFE0F __root.ts deleted. Recreating..."),await L.default.writeFile(Z,a(),"utf-8"),console.log("\u{1F7E2} Recreated:",Z)})}catch{console.warn("\u26A0\uFE0F Chokidar not available, skipping watch mode.")}console.log("\u{1F7E2} TS Filebased Router Mounted Successfully...")};var fs=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),we=s=>s?.map(t=>fs(t)).join("")??"";var pt=y(require("dompurify"),1),gt=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?pt.default.sanitize(s,n):pt.default.sanitize(s.innerHTML,n)};var wt=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};var Ee=require("zustand/vanilla"),Et=y(require("dompurify"),1);function ms(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=Et.default.sanitize(i[c+1]??"")}),a}function ps(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=Et.default.sanitize(r);return t}var F=(0,Ee.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=ms(e,n),i=ps(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function yt(s){let t=F.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var Tt=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var tt=y(require("dompurify"),1),_t=(s,t,e,n={})=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...e};tt.default.addHook("uponSanitizeElement",(a,o)=>{let c=o.tagName.toLowerCase();c.includes("-")&&(o.allowedTags[c]=!0)}),tt.default.addHook("uponSanitizeAttribute",(a,o)=>{o.attrName&&o.attrName.toLowerCase().startsWith("on")&&(o.keepAttr=!1)});let i=tt.default.sanitize(t,r);s.innerHTML=i,s.querySelectorAll("[data-onclick]").forEach(a=>{let o=a.dataset.onclick;n[o]&&a.addEventListener("click",n[o])}),s.querySelectorAll("[data-onchange]").forEach(a=>{let o=a.dataset.onchange;n[o]&&a.addEventListener("change",n[o])}),s.querySelectorAll("[data-onselect]").forEach(a=>{let o=a.dataset.onselect;n[o]&&a.addEventListener("select",n[o])})};var ye=y(require("dompurify"),1),et=null,St=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;let n=e.innerHTML,i=ye.default.sanitize(n,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(et!==null&&i!==et){let a=document.createElement("div");t(a),e.innerHTML=et}else et=i,e.innerHTML=i,t(e)};var Pt=y(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var vt=(s,t,e,n="",r=null)=>{if(!s)return;let i=Pt.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Pt.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let d=o.currentTarget.getAttribute("href");if(d){let l=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:l},"",d),dispatchEvent(new PopStateEvent("popstate"))}})};var A=y(require("dompurify"),1);var Te=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'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",d=!1)=>{let l=()=>{try{let u=document.querySelector('meta[http-equiv="Content-Security-Policy"]');u||(u=document.createElement("meta"),u.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(u));let h=d?`report-uri ${c};`:"";u.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${h}`)}catch(u){console.error("Error adding CSP meta element:",u)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",l):l()};var Rt=(s,t)=>{let e={name:A.default.sanitize(s.name||""),description:A.default.sanitize(s.description||"Default description"),author:A.default.sanitize(s.author||"")},n=f=>{e.name=A.default.sanitize(f),u("name",e.name)},r=f=>{e.description=A.default.sanitize(f),u("description",e.description)},i=f=>{e.author=A.default.sanitize(f),u("author",e.author)},a=()=>e.name,o=()=>e.description,c=()=>e.author,d=()=>e,l=(f,p)=>{let g=document.createElement("meta");g.setAttribute("name",f),g.setAttribute("content",p),document.head.appendChild(g)},u=(f,p)=>{let g=document.querySelector(`meta[name="${f}"]`);g?g.setAttribute("content",p):l(f,p)},h=()=>{u("name",e.name),u("description",e.description),u("author",e.author)};return t&&Te(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),h(),{setName:n,setDescription:r,setAuthor:i,getName:a,getDescription:o,getAuthor:c,getAllMetaData:d,appendMetaTagsToHead:h}};var _e=y(require("dompurify"),1),N=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=_e.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var Lt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.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=e[a],d=Array.isArray(n)?n[a]:void 0;typeof c=="function"?N(i,t,c,d):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var Dt=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Se=require("jwt-decode"),xt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Se.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var k=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var bt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var At=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function Mt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Pe=require("zustand/vanilla");function Ot(s){let t=(0,Pe.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function Ct(s){let t=s();typeof t=="function"&&t()}var z=()=>{let s=document.querySelectorAll('a[href^="#"]');k(s,["click"],(t,e)=>{e.preventDefault();let n=t.getAttribute("href")?.substring(1),r=n?document.getElementById(n):null;r&&r.scrollIntoView({behavior:"smooth",block:"start"})})};var ve=require("lodash-es"),Ht=s=>s;typeof window<"u"&&typeof document<"u"&&(Ht=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var gs=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",Ht(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",Ht(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let d=new URL(c,window.location.href);window.history.pushState({},"",d.pathname+d.search+d.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(d){console.error("Invalid URL in anchor:",c,d)}})}})},ws=(0,ve.debounce)(gs,50),W=s=>{ws(s)};var $=s=>{let t=s.querySelectorAll("a");W(t)};var It=s=>{z(),$(s)};var Ft=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Nt=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function kt(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){e?.appendChild(t);return}if(t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var zt=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var Wt=y(require("dompurify"),1);var Le=require("zustand/vanilla"),De=y(require("dompurify"),1),D=(0,Le.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:Re(t)})),setQuery:t=>s(()=>({query:Re(t)}))}));function Re(s){let t={};for(let e in s)t[e]=De.default.sanitize(s[e]);return t}var st=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);D.getState().setParams(i),D.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);D.getState().setParams(a),D.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},d=this.filterAndSanitizeParams(c);if(D.getState().setParams(d),D.getState().setQuery(i),a.element?.(o,d,i),n.appendChild(o),a.children){let l=e.slice(a.path.length);this.renderChildren(a.children,l,o,d,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=Wt.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,u=>(o.push(u.substring(1)),"([^\\s/]+)")),d=new RegExp(`^${c}(?:/|$)`),l=t.match(d);if(l){let u={...n};if(o.forEach((h,f)=>{u[h]=l[f+1]??""}),r.children){let h=t.slice(l[0].length),f=this.findMatchingRoute(h,r.children,u);if(f)return f}return{...r,params:u}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=Wt.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};typeof window<"u"&&(window.addEventListener("popstate",()=>{U(),ge()}),window.addEventListener("DOMContentLoaded",U));0&&(module.exports={TSRouter,createEffect,createSignal,html,loadPyFiles,mapper,renderChildRoutes,useAnchor,useAnchorSingle,useInitialDOM,useTSAnchorMount,useTSAuth,useTSCollection,useTSComponent,useTSElementEach,useTSElements,useTSEvent,useTSEventAll,useTSExtractParams,useTSHashAnchor,useTSLazy,useTSMetaData,useTSNavigate,useTSNoReload,useTSOutlet,useTSParams,useTSPurifier,useTSSSRHydration,useTSSelect,useTSloadBrython});
69
69
  /*! Bundled license information:
70
70
 
71
71
  chokidar/esm/index.js:
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- function ie(s){return(s==null?"":String(s)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function lt(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?ie(t[r]):"";return e+n+i},"")}function b(){let s=new Set;document.querySelectorAll("*").forEach(t=>{let e=t.tagName.toLowerCase();e.includes("-")&&s.add(e)}),s.forEach(t=>{customElements.get(t)||customElements.define(t,class extends HTMLElement{connectedCallback(){this.innerHTML=`<div style="padding:10px;background:#eee;">${t} (Auto)</div>`}})})}var oe=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),ae=s=>s?.map(t=>oe(t)).join("")??"";import dt from"dompurify";var ut=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?dt.sanitize(s,n):dt.sanitize(s.innerHTML,n)};var ht=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};import{createStore as ce}from"zustand/vanilla";import ft from"dompurify";function le(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=ft.sanitize(i[c+1]??"")}),a}function de(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=ft.sanitize(r);return t}var M=ce((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=le(e,n),i=de(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function mt(s){let t=M.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var pt=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};import V from"dompurify";var gt=(s,t,e,n={})=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...e};V.addHook("uponSanitizeElement",(a,o)=>{let c=o.tagName.toLowerCase();c.includes("-")&&(o.allowedTags[c]=!0)}),V.addHook("uponSanitizeAttribute",(a,o)=>{o.attrName&&o.attrName.toLowerCase().startsWith("on")&&(o.keepAttr=!1)});let i=V.sanitize(t,r);s.innerHTML=i,s.querySelectorAll("[data-onclick]").forEach(a=>{let o=a.dataset.onclick;n[o]&&a.addEventListener("click",n[o])}),s.querySelectorAll("[data-onchange]").forEach(a=>{let o=a.dataset.onchange;n[o]&&a.addEventListener("change",n[o])}),s.querySelectorAll("[data-onselect]").forEach(a=>{let o=a.dataset.onselect;n[o]&&a.addEventListener("select",n[o])})};import ue from"dompurify";var O=null,wt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;let n=e.innerHTML,i=ue.sanitize(n,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(O!==null&&i!==O){let a=document.createElement("div");t(a),e.innerHTML=O}else O=i,e.innerHTML=i,t(e)};import Et from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var yt=(s,t,e,n="",r=null)=>{if(!s)return;let i=Et.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Et.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import R from"dompurify";var Tt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'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",l=!1)=>{let d=()=>{try{let u=document.querySelector('meta[http-equiv="Content-Security-Policy"]');u||(u=document.createElement("meta"),u.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(u));let h=l?`report-uri ${c};`:"";u.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${h}`)}catch(u){console.error("Error adding CSP meta element:",u)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var _t=(s,t)=>{let e={name:R.sanitize(s.name||""),description:R.sanitize(s.description||"Default description"),author:R.sanitize(s.author||"")},n=f=>{e.name=R.sanitize(f),u("name",e.name)},r=f=>{e.description=R.sanitize(f),u("description",e.description)},i=f=>{e.author=R.sanitize(f),u("author",e.author)},a=()=>e.name,o=()=>e.description,c=()=>e.author,l=()=>e,d=(f,p)=>{let g=document.createElement("meta");g.setAttribute("name",f),g.setAttribute("content",p),document.head.appendChild(g)},u=(f,p)=>{let g=document.querySelector(`meta[name="${f}"]`);g?g.setAttribute("content",p):d(f,p)},h=()=>{u("name",e.name),u("description",e.description),u("author",e.author)};return t&&Tt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),h(),{setName:n,setDescription:r,setAuthor:i,getName:a,getDescription:o,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:h}};import he from"dompurify";var C=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=he.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var St=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.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=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?C(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var Pt=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};import{jwtDecode as fe}from"jwt-decode";var vt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=fe(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var H=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var Rt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Lt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function Dt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}import{createStore as me}from"zustand/vanilla";function xt(s){let t=me(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function At(s){let t=s();typeof t=="function"&&t()}var I=()=>{let s=document.querySelectorAll('a[href^="#"]');H(s,["click"],(t,e)=>{e.preventDefault();let n=t.getAttribute("href")?.substring(1),r=n?document.getElementById(n):null;r&&r.scrollIntoView({behavior:"smooth",block:"start"})})};import{debounce as pe}from"lodash-es";var K=s=>s;typeof window<"u"&&typeof document<"u"&&(K=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var ge=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",K(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",K(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},we=pe(ge,50),F=s=>{we(s)};var N=s=>{let t=s.querySelectorAll("a");F(t)};var bt=s=>{I(),N(s)};var Mt=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Ot=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Ct(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){e?.appendChild(t);return}if(t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var Ht=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};import Ft from"dompurify";import{createStore as Ee}from"zustand/vanilla";import ye from"dompurify";var S=Ee(s=>({params:{},query:{},setParams:t=>s(()=>({params:It(t)})),setQuery:t=>s(()=>({query:It(t)}))}));function It(s){let t={};for(let e in s)t[e]=ye.sanitize(s[e]);return t}var Q=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);S.getState().setParams(i),S.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);S.getState().setParams(a),S.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(S.getState().setParams(l),S.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let d=e.slice(a.path.length);this.renderChildren(a.children,d,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=Ft.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,u=>(o.push(u.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=t.match(l);if(d){let u={...n};if(o.forEach((h,f)=>{u[h]=d[f+1]??""}),r.children){let h=t.slice(d[0].length),f=this.findMatchingRoute(h,r.children,u);if(f)return f}return{...r,params:u}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=Ft.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};import v from"fs/promises";import _ from"path";import{stat as Ke}from"fs";import{stat as Qe,readdir as Je}from"fs/promises";import{EventEmitter as Xe}from"events";import*as m from"path";import{stat as Te,lstat as Nt,readdir as _e,realpath as Se}from"fs/promises";import{Readable as Pe}from"stream";import{resolve as kt,relative as ve,join as Re,sep as Le}from"path";var y={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},J={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:y.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(J);var jt="READDIRP_RECURSIVE_ERROR",De=new Set(["ENOENT","EPERM","EACCES","ELOOP",jt]),zt=[y.DIR_TYPE,y.EVERYTHING_TYPE,y.FILE_DIR_TYPE,y.FILE_TYPE],xe=new Set([y.DIR_TYPE,y.EVERYTHING_TYPE,y.FILE_DIR_TYPE]),Ae=new Set([y.EVERYTHING_TYPE,y.FILE_DIR_TYPE,y.FILE_TYPE]),be=s=>De.has(s.code),Me=process.platform==="win32",Wt=s=>!0,$t=s=>{if(s===void 0)return Wt;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return Wt},X=class extends Pe{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...J,...t},{root:n,type:r}=e;this._fileFilter=$t(e.fileFilter),this._directoryFilter=$t(e.directoryFilter);let i=e.lstat?Nt:Te;Me?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??J.depth,this._wantsDir=r?xe.has(r):!1,this._wantsFile=r?Ae.has(r):!1,this._wantsEverything=r===y.EVERYTHING_TYPE,this._root=kt(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await _e(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=kt(Re(e,r));n={path:ve(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){be(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await Se(n),i=await Nt(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===Le){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=jt,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function Ut(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=y.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!zt.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${zt.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new X(t)}import{watchFile as Oe,unwatchFile as qt,watch as Ce}from"fs";import{open as He,stat as Gt,lstat as Ie,realpath as Z}from"fs/promises";import*as w from"path";import{type as Fe}from"os";var Ne="data",st="end",Bt="close",j=()=>{};var U=process.platform,nt=U==="win32",ke=U==="darwin",ze=U==="linux",We=U==="freebsd",Vt=Fe()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},T=E,$e="watch",je={lstat:Ie,stat:Gt},P="listeners",k="errHandlers",L="rawEmitters",Ue=[P,k,L],qe=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"]),Ye=s=>qe.has(w.extname(s).slice(1).toLowerCase()),et=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},x=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},Ge=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},A=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},Kt=s=>s instanceof Set?s.size===0:!s,z=new Map;function Yt(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&W(w.resolve(s,o),P,w.join(s,o))};try{return Ce(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var W=(s,t,e,n,r)=>{let i=z.get(s);i&&et(i[t],a=>{a(e,n,r)})},Be=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=z.get(t),c;if(!e.persistent)return c=Yt(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)x(o,P,r),x(o,k,i),x(o,L,a);else{if(c=Yt(s,e,W.bind(null,t,P),i,W.bind(null,t,L)),!c)return;c.on(T.ERROR,async l=>{let d=W.bind(null,t,k);if(o&&(o.watcherUnusable=!0),nt&&l.code==="EPERM")try{await(await He(s,"r")).close(),d(l)}catch{}else d(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},z.set(t,o)}return()=>{A(o,P,r),A(o,k,i),A(o,L,a),Kt(o.listeners)&&(o.watcher.close(),z.delete(t),Ue.forEach(Ge(o)),o.watcher=void 0,Object.freeze(o))}},tt=new Map,Ve=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=tt.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&(qt(t),a=void 0),a?(x(a,P,r),x(a,L,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:Oe(t,e,(c,l)=>{et(a.rawEmitters,u=>{u(T.CHANGE,t,{curr:c,prev:l})});let d=c.mtimeMs;(c.size!==l.size||d>l.mtimeMs||d===0)&&et(a.listeners,u=>u(s,c))})},tt.set(t,a)),()=>{A(a,P,r),A(a,L,i),Kt(a.listeners)&&(tt.delete(t),qt(t),a.options=a.watcher=void 0,Object.freeze(a))}},$=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=w.dirname(t),i=w.basename(t);this.fsw._getWatchedDir(r).add(i);let o=w.resolve(t),c={persistent:n.persistent};e||(e=j);let l;if(n.usePolling){let d=n.interval!==n.binaryInterval;c.interval=d&&Ye(i)?n.binaryInterval:n.interval,l=Ve(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=Be(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=w.dirname(t),i=w.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(d,u)=>{if(this.fsw._throttle($e,t,5)){if(!u||u.mtimeMs===0)try{let h=await Gt(t);if(this.fsw.closed)return;let f=h.atimeMs,p=h.mtimeMs;if((!f||f<=p||p!==o.mtimeMs)&&this.fsw._emit(T.CHANGE,t,h),(ke||ze||We)&&o.ino!==h.ino){this.fsw._closeFile(d),o=h;let g=this._watchWithNodeFs(t,c);g&&this.fsw._addPathCloser(d,g)}else o=h}catch{this.fsw._remove(r,i)}else if(a.has(i)){let h=u.atimeMs,f=u.mtimeMs;(!h||h<=f||f!==o.mtimeMs)&&this.fsw._emit(T.CHANGE,t,u),o=u}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(T.ADD,t,0))return;this.fsw._emit(T.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await Z(n)}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(T.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(T.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=w.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,d=this.fsw._readdirp(t,{fileFilter:u=>n.filterPath(u),directoryFilter:u=>n.filterDir(u)});if(d)return d.on(Ne,async u=>{if(this.fsw.closed){d=void 0;return}let h=u.path,f=w.join(t,h);if(l.add(h),!(u.stats.isSymbolicLink()&&await this._handleSymlink(u,t,f,h))){if(this.fsw.closed){d=void 0;return}(h===r||!r&&!c.has(h))&&(this.fsw._incrReadyCount(),f=w.join(i,w.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(T.ERROR,this._boundHandleError),new Promise((u,h)=>{if(!d)return h();d.once(st,()=>{if(this.fsw.closed){d=void 0;return}let f=o?o.clear():!1;u(void 0),c.getChildren().filter(p=>p!==t&&!l.has(p)).forEach(p=>{this.fsw._remove(t,p)}),d=void 0,f&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(w.dirname(t)),l=c.has(w.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(T.ADD_DIR,t,e),c.add(w.basename(t)),this.fsw._getWatchedDir(t);let d,u,h=this.fsw.options.depth;if((h==null||r<=h)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,d),this.fsw.closed))return;u=this._watchWithNodeFs(t,(f,p)=>{p&&p.mtimeMs===0||this._handleRead(f,!1,a,i,t,r,d)})}return u}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await je[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,d;if(c.isDirectory()){let u=w.resolve(t),h=l?await Z(t):t;if(this.fsw.closed||(d=await this._handleDir(o.watchPath,c,e,r,i,o,h),this.fsw.closed))return;u!==h&&h!==void 0&&this.fsw._symlinkPaths.set(u,h)}else if(c.isSymbolicLink()){let u=l?await Z(t):t;if(this.fsw.closed)return;let h=w.dirname(o.watchPath);if(this.fsw._getWatchedDir(h).add(o.watchPath),this.fsw._emit(T.ADD,o.watchPath,c),d=await this._handleDir(h,c,e,r,t,o,u),this.fsw.closed)return;u!==void 0&&this.fsw._symlinkPaths.set(w.resolve(t),u)}else d=this._handleFile(o.watchPath,c,e);return a(),d&&this.fsw._addPathCloser(t,d),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}};var rt="/",Ze="//",ee=".",ts="..",es="string",ss=/\\/g,Qt=/\/\//,ns=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,rs=/^\.[/\\]/;function q(s){return Array.isArray(s)?s:[s]}var it=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);function is(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=m.relative(s.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function os(s){if(typeof s!="string")throw new Error("string expected");s=m.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function Jt(s,t,e){let n=os(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function as(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=q(s).map(r=>is(r));return t==null?(r,i)=>Jt(n,r,i):Jt(n,t)}var Xt=s=>{let t=q(s).flat();if(!t.every(e=>typeof e===es))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(se)},Zt=s=>{let t=s.replace(ss,rt),e=!1;for(t.startsWith(Ze)&&(e=!0);t.match(Qt);)t=t.replace(Qt,rt);return e&&(t=rt+t),t},se=s=>Zt(m.normalize(Zt(s))),te=(s="")=>t=>typeof t=="string"?se(m.isAbsolute(t)?t:m.join(s,t)):t,cs=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),ls=Object.freeze(new Set),ot=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==ee&&t!==ts&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await Je(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=j,this.items=ls,Object.freeze(this)}},ds="stat",us="lstat",at=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(rs,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?ds:us}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},Y=class extends Xe{constructor(t={}){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 e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?q(t.ignored):q([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};Vt&&(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=j,this._readyEmitted=!0,process.nextTick(()=>this.emit(E.READY)))},this._emitRaw=(...c)=>this.emit(E.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new $(this),Object.freeze(r)}_addIgnoredPath(t){if(it(t)){for(let e of this._ignoredPaths)if(it(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)it(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=Xt(t);return r&&(i=i.map(a=>cs(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,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=Xt(t),{cwd:n}=this.options;return e.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=m.join(n,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 t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?m.relative(this.options.cwd,n):n)||ee;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==E.ERROR&&this.emit(E.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;nt&&(e=m.normalize(e)),r.cwd&&(e=m.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===E.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(E.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===E.ADD&&this._pendingUnlinks.has(e)&&(t=E.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===E.ADD||t===E.CHANGE)&&this._readyEmitted){let c=(l,d)=>{l?(t=E.ERROR,i[0]=l,this.emitWithAll(t,i)):d&&(i.length>1?i[1]=d:i.push(d),this.emitWithAll(t,i))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===E.CHANGE&&!this._throttle(E.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===E.ADD||t===E.ADD_DIR||t===E.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,l;try{l=await Qe(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(E.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),d=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),d};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!m.isAbsolute(t)&&(c=m.join(this.options.cwd,t));let l=new Date,d=this._pendingWrites;function u(h){Ke(c,(f,p)=>{if(f||!d.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let g=Number(new Date);h&&p.size!==h.size&&(d.get(t).lastChange=g);let B=d.get(t);g-B.lastChange>=e?(d.delete(t),r(void 0,p)):o=setTimeout(u,a,p)})}d.has(t)||(d.set(t,{lastChange:l,cancelWait:()=>(d.delete(t),clearTimeout(o),n)}),o=setTimeout(u,a))}_isIgnored(t,e){if(this.options.atomic&&ns.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(te(n)),o=[...[...this._ignoredPaths].map(te(n)),...i];this._userIgnored=as(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new at(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new ot(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=m.join(t,e),i=m.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(h=>this._remove(r,h));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let d=r;if(this.options.cwd&&(d=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===E.ADD)return;this._watched.delete(r),this._watched.delete(i);let u=n?E.UNLINK_DIR:E.UNLINK;l&&!this._isIgnored(r)&&this._emit(u,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:E.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=Ut(t,n);return this._streams.add(r),r.once(Bt,()=>{r=void 0}),r.once(st,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function hs(s,t={}){let e=new Y(t);return e.add(s),e}var ct={watch:hs,FSWatcher:Y};var D=_.resolve("src/pages"),ne=_.resolve("src/gen"),re=_.resolve("src/routes"),fs=_.join(ne,"tsrouter.gen.ts"),G=_.join(re,"__root.ts"),ms=async()=>{if(typeof window>"u"){console.log("\u26A0\uFE0F Skipping TS file-based router generation in SSR/Node environment");return}async function s(c){try{await v.mkdir(c,{recursive:!0})}catch{}}await s(ne),await s(re);function t(c,l){let d="/"+_.relative(l,c).replace(/\\/g,"/");return d=d.replace(/\.ts$/,""),d=d.replace(/\/index$/,"")||"/",d=d.replace(/\[(.+?)\]/g,":$1"),d}function e(c){return c.replace(/^\//,"").split("/").map(l=>l.startsWith(":")?l.slice(1):l).filter(Boolean).join("-")||"index"}function n(c,l){let u=_.relative(l,c).replace(/\\/g,"/").split("/").filter(Boolean),h=u[u.length-1].replace(".ts",""),f=u.length>1?u[u.length-2]:"";if(h.startsWith("[")&&h.endsWith("]")){let p=h.slice(1,-1);return f.charAt(0).toUpperCase()+f.slice(1)+p.charAt(0).toUpperCase()+p.slice(1)+"Param"}else return h.charAt(0).toUpperCase()+h.slice(1)}async function r(c){let l=await v.readdir(c,{withFileTypes:!0}),d=[];for(let u of l){let h=_.join(c,u.name);if(u.isDirectory())d=d.concat(await r(h));else if(u.isFile()&&u.name.endsWith(".ts")){let f=t(h,D),p=e(f),g=n(h,D);d.push({file:h,route:f,routeName:p,importName:g})}}return d}function i(c,l){return`import { html, useTSElements, useTSExtractParams, useTSMetaData } from '@devwareng/vanilla-ts'
1
+ function de(t){return(t==null?"":String(t)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function C(t,...e){return t.reduce((n,r,o)=>{let s=o<e.length?de(e[o]):"";return n+r+s},"")}function v(){let t=new Set;document.querySelectorAll("*").forEach(e=>{let n=e.tagName.toLowerCase();n.includes("-")&&t.add(n)}),t.forEach(e=>{customElements.get(e)||customElements.define(e,class extends HTMLElement{connectedCallback(){this.innerHTML=`<div style="padding:10px;background:#eee;">${e} (Auto)</div>`}})})}import S from"fs/promises";import g from"path";var E=g.resolve("src/pages"),k=g.resolve("src/gen"),$=g.resolve("src/routes"),me=g.join(k,"tsrouter.gen.ts"),w=g.join($,"__root.ts"),N=async()=>{if(typeof window>"u"){console.log("\u26A0\uFE0F Skipping TS file-based router generation in SSR/Node environment");return}async function t(c){try{await S.mkdir(c,{recursive:!0})}catch{}}await t(k),await t($);function e(c,l){let d="/"+g.relative(l,c).replace(/\\/g,"/");return d=d.replace(/\.ts$/,""),d=d.replace(/\/index$/,"")||"/",d=d.replace(/\[(.+?)\]/g,":$1"),d}function n(c){return c.replace(/^\//,"").split("/").map(l=>l.startsWith(":")?l.slice(1):l).filter(Boolean).join("-")||"index"}function r(c,l){let u=g.relative(l,c).replace(/\\/g,"/").split("/").filter(Boolean),p=u[u.length-1].replace(".ts",""),m=u.length>1?u[u.length-2]:"";if(p.startsWith("[")&&p.endsWith("]")){let h=p.slice(1,-1);return m.charAt(0).toUpperCase()+m.slice(1)+h.charAt(0).toUpperCase()+h.slice(1)+"Param"}else return p.charAt(0).toUpperCase()+p.slice(1)}async function o(c){let l=await S.readdir(c,{withFileTypes:!0}),d=[];for(let u of l){let p=g.join(c,u.name);if(u.isDirectory())d=d.concat(await o(p));else if(u.isFile()&&u.name.endsWith(".ts")){let m=e(p,E),h=n(m),f=r(p,E);d.push({file:p,route:m,routeName:h,importName:f})}}return d}function s(c,l){return`import { html, useTSElements, useTSExtractParams, useTSMetaData } from '@devwareng/vanilla-ts'
2
2
 
3
3
  export default function ${c}(DOM: HTMLElement) {
4
4
  useTSMetaData({ name: '${c.toLowerCase()}', description: '', author: '' })
@@ -9,7 +9,7 @@ export default function ${c}(DOM: HTMLElement) {
9
9
  <pre>\${JSON.stringify(params, null, 2)}</pre>
10
10
  </div>
11
11
  \`)
12
- }`}function a(){return`import { createRouter } from "@/gen/tsrouter.gen"
12
+ }`}function i(){return`import { createRouter } from "@/gen/tsrouter.gen"
13
13
  import { useTSParams } from "@devwareng/vanilla-ts"
14
14
 
15
15
  export const Router = (DOM: HTMLElement) => {
@@ -17,21 +17,21 @@ export const Router = (DOM: HTMLElement) => {
17
17
  const router = createRouter(DOM)
18
18
  router.navigate(window.location.pathname)
19
19
  window.addEventListener("popstate", () => router.navigate(window.location.pathname))
20
- }`}async function o(){let c=await r(D),l=c.find(g=>g.route==="/notfound"),d=c.filter(g=>g.route!=="/notfound"),u=c.map(g=>{let B="../pages/"+_.relative(D,g.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`import ${g.importName} from "${B}";`}).join(`
21
- `),h=d.map(g=>`{ path: "${g.route}", name: "${g.routeName}", component: (DOM: HTMLElement) => ${g.importName}(DOM) }`).join(`,
22
- `),f=l?`export const NotFound = ${l.importName}`:"export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div><h1>404 - Page Not Found</h1></div>`)\n}",p=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
20
+ }`}async function a(){let c=await o(E),l=c.find(f=>f.route==="/notfound"),d=c.filter(f=>f.route!=="/notfound"),u=c.map(f=>{let ue="../pages/"+g.relative(E,f.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`import ${f.importName} from "${ue}";`}).join(`
21
+ `),p=d.map(f=>`{ path: "${f.route}", name: "${f.routeName}", component: (DOM: HTMLElement) => ${f.importName}(DOM) }`).join(`,
22
+ `),m=l?`export const NotFound = ${l.importName}`:"export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div><h1>404 - Page Not Found</h1></div>`)\n}",h=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
23
23
  import { html, useTSElements } from "@devwareng/vanilla-ts"
24
24
 
25
25
  ${u}
26
26
 
27
- ${f}
27
+ ${m}
28
28
 
29
29
  export function RootDocument(DOM: HTMLElement) {
30
30
  return useTSElements(DOM, html\`<div><h1>Root</h1></div>\`)
31
31
  }
32
32
 
33
33
  export const routeTree = [
34
- ${h}
34
+ ${p}
35
35
  ]
36
36
 
37
37
  export function createRouter(DOM: HTMLElement) {
@@ -65,9 +65,4 @@ export function createRouter(DOM: HTMLElement) {
65
65
 
66
66
  navigate(window.location.pathname + window.location.search)
67
67
  return { navigate, routes: routeTree }
68
- }`;await v.writeFile(fs,p,"utf-8"),await v.writeFile(G,a(),"utf-8"),console.log("\u2705 Generated router and __root.ts")}typeof window<"u"&&(console.log("\u{1F440} Watching for changes in /src/pages and /src/routes/__root.ts..."),ct.watch(D).on("all",async(c,l)=>{if(c==="add"&&l.endsWith(".ts")){let d=_.basename(l,".ts"),u=d.replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,p=>p.replace("-","").toUpperCase()),h=t(l,D);(await v.readFile(l,"utf-8")).trim()||(await v.writeFile(l,i(u,h),"utf-8"),console.log(`\u{1F4DD} Scaffolded page: ${d}.ts`))}await o()}),ct.watch(G).on("unlink",async()=>{console.log("\u26A0\uFE0F __root.ts deleted. Recreating..."),await v.writeFile(G,a(),"utf-8"),console.log("\u{1F7E2} Recreated:",G)})),console.log("\u{1F7E2} TS Filebased Router Mounted Successfully...")};typeof window<"u"&&(window.addEventListener("popstate",()=>{b()}),window.addEventListener("DOMContentLoaded",b));export{Q as TSRouter,At as createEffect,xt as createSignal,lt as html,Ot as loadPyFiles,ae as mapper,Dt as renderChildRoutes,F as useAnchor,yt as useAnchorSingle,wt as useInitialDOM,bt as useTSAnchorMount,vt as useTSAuth,St as useTSCollection,C as useTSComponent,H as useTSElementEach,gt as useTSElements,ht as useTSEvent,pt as useTSEventAll,mt as useTSExtractParams,ms as useTSFilebasedRouter,I as useTSHashAnchor,Ct as useTSLazy,_t as useTSMetaData,Rt as useTSNavigate,N as useTSNoReload,Lt as useTSOutlet,M as useTSParams,ut as useTSPurifier,Ht as useTSSSRHydration,Pt as useTSSelect,Mt as useTSloadBrython};
69
- /*! Bundled license information:
70
-
71
- chokidar/esm/index.js:
72
- (*! chokidar - MIT License (c) 2012 Paul Miller (paulmillr.com) *)
73
- */
68
+ }`;await S.writeFile(me,h,"utf-8"),await S.writeFile(w,i(),"utf-8"),console.log("\u2705 Generated router and __root.ts")}if(typeof window>"u")try{let c=await import("./esm-KRNKVVL7.js");console.log("\u{1F440} Watching for changes in /src/pages and /src/routes/__root.ts..."),c.watch(E).on("all",async(l,d)=>{if(l==="add"&&d.endsWith(".ts")){let u=g.basename(d,".ts"),p=u.replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,f=>f.replace("-","").toUpperCase()),m=e(d,E);(await S.readFile(d,"utf-8")).trim()||(await S.writeFile(d,s(p,m),"utf-8"),console.log(`\u{1F4DD} Scaffolded page: ${u}.ts`))}await a()}),c.watch(w).on("unlink",async()=>{console.log("\u26A0\uFE0F __root.ts deleted. Recreating..."),await S.writeFile(w,i(),"utf-8"),console.log("\u{1F7E2} Recreated:",w)})}catch{console.warn("\u26A0\uFE0F Chokidar not available, skipping watch mode.")}console.log("\u{1F7E2} TS Filebased Router Mounted Successfully...")};var pe=t=>t.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),fe=t=>t?.map(e=>pe(e)).join("")??"";import F from"dompurify";var _=(t,e)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof t=="string"?F.sanitize(t,r):F.sanitize(t.innerHTML,r)};var z=(t,e,n)=>{if(typeof t=="string"){let r=document.getElementById(t);r?r.addEventListener(e,n):console.warn(`Element with id '${t}' not found.`)}else t===document?document.addEventListener(e,n):console.warn("Invalid id parameter provided.")};import{createStore as he}from"zustand/vanilla";import I from"dompurify";function ge(t,e){let n=[],r=t.replace(/:[^/]+/g,a=>(n.push(a.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),s=e.match(o),i={};return s&&n.forEach((a,c)=>{i[a]=I.sanitize(s[c+1]??"")}),i}function Te(t){let e={},n=new URLSearchParams(t);for(let[r,o]of n.entries())e[r]=I.sanitize(o);return e}var L=he((t,e)=>({params:{},query:{},setFromPattern:n=>{let r=window.location.pathname,o=ge(n,r),s=Te(window.location.search);t({params:o,query:s})},getParam:n=>e().params[n],getQuery:n=>e().query[n]}));function q(t){let e=L.getState();e.setFromPattern(t);let n=e.params,r=e.query;return{...n,...r}}var U=(t,e,n)=>{let r=document.querySelectorAll(t);return r.forEach(o=>{o.addEventListener(e,n)}),()=>{r.forEach(o=>{o.removeEventListener(e,n)})}};import H from"dompurify";var j=(t,e,n,r={})=>{let o={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...n};H.addHook("uponSanitizeElement",(i,a)=>{let c=a.tagName.toLowerCase();c.includes("-")&&(a.allowedTags[c]=!0)}),H.addHook("uponSanitizeAttribute",(i,a)=>{a.attrName&&a.attrName.toLowerCase().startsWith("on")&&(a.keepAttr=!1)});let s=H.sanitize(e,o);t.innerHTML=s,t.querySelectorAll("[data-onclick]").forEach(i=>{let a=i.dataset.onclick;r[a]&&i.addEventListener("click",r[a])}),t.querySelectorAll("[data-onchange]").forEach(i=>{let a=i.dataset.onchange;r[a]&&i.addEventListener("change",r[a])}),t.querySelectorAll("[data-onselect]").forEach(i=>{let a=i.dataset.onselect;r[a]&&i.addEventListener("select",r[a])})};import Se from"dompurify";var M=null,W=(t,e)=>{if(typeof document>"u")return;let n=document.getElementById(t);if(!n)return;let r=n.innerHTML,s=Se.sanitize(r,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(M!==null&&s!==M){let i=document.createElement("div");e(i),n.innerHTML=M}else M=s,n.innerHTML=s,e(n)};import B from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",t=>{let e=t.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var G=(t,e,n,r="",o=null)=>{if(!t)return;let s=B.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),i=B.sanitize(n,{USE_PROFILES:{html:!1}});t.setAttribute("href",s),t.setAttribute("aria-label",i),r&&(t.className=r.trim()),o&&t.replaceChildren(o),typeof window<"u"&&t.addEventListener("click",a=>{a.preventDefault();let l=a.currentTarget.getAttribute("href");if(l){let d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import y from"dompurify";var Q=(t="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",n="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'self' https://blogger.googleusercontent.com",s=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],i="'self' https://www.youtube.com",a="'self'",c="/csp-report",l=!1)=>{let d=()=>{try{let u=document.querySelector('meta[http-equiv="Content-Security-Policy"]');u||(u=document.createElement("meta"),u.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(u));let p=l?`report-uri ${c};`:"";u.setAttribute("content",`default-src 'self'; script-src ${t}; style-src ${e}; object-src ${n}; font-src ${r}; img-src ${o}; connect-src ${s.join(" ")}; frame-src ${i}; base-uri ${a}; ${p}`)}catch(u){console.error("Error adding CSP meta element:",u)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var V=(t,e)=>{let n={name:y.sanitize(t.name||""),description:y.sanitize(t.description||"Default description"),author:y.sanitize(t.author||"")},r=m=>{n.name=y.sanitize(m),u("name",n.name)},o=m=>{n.description=y.sanitize(m),u("description",n.description)},s=m=>{n.author=y.sanitize(m),u("author",n.author)},i=()=>n.name,a=()=>n.description,c=()=>n.author,l=()=>n,d=(m,h)=>{let f=document.createElement("meta");f.setAttribute("name",m),f.setAttribute("content",h),document.head.appendChild(f)},u=(m,h)=>{let f=document.querySelector(`meta[name="${m}"]`);f?f.setAttribute("content",h):d(m,h)},p=()=>{u("name",n.name),u("description",n.description),u("author",n.author)};return e&&Q(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),p(),{setName:r,setDescription:o,setAuthor:s,getName:i,getDescription:a,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:p}};import Ee from"dompurify";var R=(t,e,n,r,o)=>{let s=`#${t}`,i=e.querySelectorAll(s);if(i.length===0)throw new Error(`[useTSComponent] No element found with id '${t}' in the given parent.`);if(i.length>1)throw new Error(`[useTSComponent] Duplicate id '${t}' detected. Found ${i.length} elements.`);let a=i[0];a.innerHTML=Ee.sanitize(a.innerHTML,{USE_PROFILES:{html:!0}}),n(a,r,o)};var J=(t,e,n,r=[])=>{let o=new Set;t.forEach((s,i)=>{if(o.has(s)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${s}" \u2014 skipping.`);return}o.add(s);let a=e.querySelectorAll(`#${s}`);if(a.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${s}" (${a.length} elements found) \u2014 skipping component mount.`);return}let c=n[i],l=Array.isArray(r)?r[i]:void 0;typeof c=="function"?R(s,e,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${s}"`)})};var X=(t,e)=>{let r=(e??document).querySelectorAll(t);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${t}'`),null;if(t.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${t}'. Found ${r.length} elements with this ID.`);return r[0]}return r.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${t}'. Returning the first one.`),r[0]};import{jwtDecode as ye}from"jwt-decode";var Y=(t,e)=>{let n=localStorage.getItem("token");if(!n)return window.location.href=e,null;try{let r=ye(n),o=Date.now()/1e3;return r.exp&&r.exp<o&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=e),null}catch(r){return console.error("Invalid token:",r),window.location.href=e,null}};var A=(t,e,n)=>{t.forEach(r=>{e.forEach(o=>{r.addEventListener(o,s=>{n(r,s)})})})};var K=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Z=(t,e)=>{let n=document.querySelector(`#${t}`)||document.querySelector(`.${t}`);if(!n)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of e){let s=o.path.replace(/\/$/,"");if(r===s||r.startsWith(`${s}/`)){o.component(n);break}}};function ee(t,e){let n=window.location.pathname.replace(/\/$/,"");e.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let s=o.path.replace(/\/$/,"");if(n===s||n.startsWith(`${s}/`)){let i=t.querySelector(`#${o.outlet}`)||t.querySelector(`.${o.outlet}`);i instanceof HTMLElement&&o.element&&o.element(i)}})})}import{createStore as ve}from"zustand/vanilla";function te(t){let e=ve(()=>({value:t})),n=new Set;return{get:()=>e.getState().value,set:r=>{e.setState({value:r}),n.forEach(o=>o(r))},subscribe:r=>(n.add(r),r(e.getState().value),()=>n.delete(r))}}function ne(t){let e=t();typeof e=="function"&&e()}var P=()=>{let t=document.querySelectorAll('a[href^="#"]');A(t,["click"],(e,n)=>{n.preventDefault();let r=e.getAttribute("href")?.substring(1),o=r?document.getElementById(r):null;o&&o.scrollIntoView({behavior:"smooth",block:"start"})})};import{debounce as we}from"lodash-es";var O=t=>t;typeof window<"u"&&typeof document<"u"&&(O=t=>{let e=document.createElement("div");return e.innerText=t,e.innerHTML});var Le=t=>{(t?Array.isArray(t)?t:t instanceof HTMLAnchorElement?[t]:Array.from(t):Array.from(document.querySelectorAll("a"))).forEach(n=>{if(!n||n.dataset.anchorEnhanced==="true")return;n.dataset.anchorEnhanced="true";let r=n.getAttribute("class")||"";n.setAttribute("class",O(r));let o=n.getAttribute("aria-label");o&&n.setAttribute("aria-label",O(o));let s=n.querySelector(":scope > *");s&&(n.innerHTML="",n.appendChild(s));let i=n.getAttribute("href")||"";if(!i.startsWith("#")){try{if(new URL(i,window.location.href).origin!==window.location.origin)return}catch{return}n.addEventListener("click",a=>{a.preventDefault();let c=n.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},Me=we(Le,50),x=t=>{Me(t)};var D=t=>{let e=t.querySelectorAll("a");x(e)};var re=t=>{P(),D(t)};var oe=async()=>{let t="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",n=r=>new Promise((o,s)=>{let i=document.createElement("script");i.src=r,i.onload=()=>o(),i.onerror=()=>s(new Error(`Failed to load ${r}`)),document.head.appendChild(i)});await n(t),await n(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},se=t=>new Promise((e,n)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${t}`,r.onload=()=>e(),r.onerror=()=>n(new Error(`Failed to load ${t}`)),document.body.appendChild(r)});function ie(t){let e=null;return async(n,r)=>{try{if(!e){let o=await t();e=o.default||o}if(typeof e=="function")return e(n,r);if(e instanceof HTMLElement){n?.appendChild(e);return}if(e&&typeof e.render=="function")return e.render(n,r);console.warn("useTSLazy: Unsupported module type",e)}catch(o){console.error("useTSLazy failed:",o)}}}var ae=t=>typeof window>"u"?{isDOM:null}:{isDOM:t||document.body};import le from"dompurify";import{createStore as Re}from"zustand/vanilla";import Ae from"dompurify";var T=Re(t=>({params:{},query:{},setParams:e=>t(()=>({params:ce(e)})),setQuery:e=>t(()=>({query:ce(e)}))}));function ce(t){let e={};for(let n in t)e[n]=Ae.sanitize(t[n]);return e}var b=class{constructor(e,n){this.routes=[];this.routes=e,this.expectedParams=new Set(n),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,n=window.location.search,r=this.parseQueryParams(n),o=this.findMatchingRoute(e,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let s=this.filterAndSanitizeParams(o.params);T.getState().setParams(s),T.getState().setQuery(r);let i=document.createElement("div");if(o.element?.(i,s,r),o.children){let a=e.slice(o.path.length),c=i.querySelector("#child");c&&this.renderChildren(o.children,a,c,s,r)}}else{let s=this.findMatchingRoute("*",this.routes);if(s){let i=this.filterAndSanitizeParams(s.params);T.getState().setParams(i),T.getState().setQuery(r);let a=document.createElement("div");s.element?.(a,i,r)}}}renderChildren(e,n,r,o,s){if(!e||e.length===0){let a=r.querySelector("#child");a&&a.remove();return}let i=this.findMatchingRoute(n,e);if(i){let a=document.createElement("div");a.id="child";let c={...o,...i.params},l=this.filterAndSanitizeParams(c);if(T.getState().setParams(l),T.getState().setQuery(s),i.element?.(a,l,s),r.appendChild(a),i.children){let d=n.slice(i.path.length);this.renderChildren(i.children,d,a,l,s)}}}parseQueryParams(e){let n={},r=new URLSearchParams(e);for(let[o,s]of r.entries())this.expectedParams.has(o)&&(n[o]=le.sanitize(s));return n}findMatchingRoute(e,n,r={}){for(let o of n){let s=o.path;if(s==="*")return o;{let a=[],c=s.replace(/:[^\s/]+/g,u=>(a.push(u.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=e.match(l);if(d){let u={...r};if(a.forEach((p,m)=>{u[p]=d[m+1]??""}),o.children){let p=e.slice(d[0].length),m=this.findMatchingRoute(p,o.children,u);if(m)return m}return{...o,params:u}}}}}filterAndSanitizeParams(e){if(!e)return{};let n={};for(let r in e)this.expectedParams.has(r)&&(n[r]=le.sanitize(e[r]??""));return n}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};typeof window<"u"&&(window.addEventListener("popstate",()=>{v(),N()}),window.addEventListener("DOMContentLoaded",v));export{b as TSRouter,ne as createEffect,te as createSignal,C as html,se as loadPyFiles,fe as mapper,ee as renderChildRoutes,x as useAnchor,G as useAnchorSingle,W as useInitialDOM,re as useTSAnchorMount,Y as useTSAuth,J as useTSCollection,R as useTSComponent,A as useTSElementEach,j as useTSElements,z as useTSEvent,U as useTSEventAll,q as useTSExtractParams,P as useTSHashAnchor,ie as useTSLazy,V as useTSMetaData,K as useTSNavigate,D as useTSNoReload,Z as useTSOutlet,L as useTSParams,_ as useTSPurifier,ae as useTSSSRHydration,X as useTSSelect,oe as useTSloadBrython};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devwareng/vanilla-ts",
3
- "version": "1.4.23",
3
+ "version": "1.4.25",
4
4
  "description": "Framework-less TypeScript hooks for SPA development.",
5
5
  "author": "Waren Arapoc Gador",
6
6
  "license": "MIT",