@devwareng/vanilla-ts 1.9.1 → 1.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +56 -54
- package/dist/index.js +56 -54
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,78 +1,80 @@
|
|
|
1
|
-
"use strict";var De=Object.create;var G=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var Ie=Object.getPrototypeOf,Oe=Object.prototype.hasOwnProperty;var at=(s,t)=>()=>(s&&(t=s(s=0)),t);var Yt=(s,t)=>{for(var e in t)G(s,e,{get:t[e],enumerable:!0})},Bt=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ce(t))!Oe.call(s,n)&&n!==e&&G(s,n,{get:()=>t[n],enumerable:!(r=Me(t,n))||r.enumerable});return s};var P=(s,t,e)=>(e=s!=null?De(Ie(s)):{},Bt(t||!s||!s.__esModule?G(e,"default",{value:s,enumerable:!0}):e,s)),ke=s=>Bt(G({},"__esModule",{value:!0}),s);function le(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=v.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&&!re.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${re.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Ft(t)}var M,ae,C,v,Ht,ce,je,re,Ue,qe,Ye,Be,ie,oe,Ft,de=at(()=>{"use strict";M=require("fs/promises"),ae=require("stream"),C=require("path"),v={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Ht={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:v.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Ht);ce="READDIRP_RECURSIVE_ERROR",je=new Set(["ENOENT","EPERM","EACCES","ELOOP",ce]),re=[v.DIR_TYPE,v.EVERYTHING_TYPE,v.FILE_DIR_TYPE,v.FILE_TYPE],Ue=new Set([v.DIR_TYPE,v.EVERYTHING_TYPE,v.FILE_DIR_TYPE]),qe=new Set([v.EVERYTHING_TYPE,v.FILE_DIR_TYPE,v.FILE_TYPE]),Ye=s=>je.has(s.code),Be=process.platform==="win32",ie=s=>!0,oe=s=>{if(s===void 0)return ie;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(r=>e.basename===r)}return ie},Ft=class extends ae.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...Ht,...t},{root:r,type:n}=e;this._fileFilter=oe(e.fileFilter),this._directoryFilter=oe(e.directoryFilter);let i=e.lstat?M.lstat:M.stat;Be?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??Ht.depth,this._wantsDir=n?Ue.has(n):!1,this._wantsFile=n?qe.has(n):!1,this._wantsEverything=n===v.EVERYTHING_TYPE,this._root=(0,C.resolve)(r),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(r,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,r=e&&e.files;if(r&&r.length>0){let{path:n,depth:i}=e,a=r.splice(0,t).map(c=>this._formatEntry(c,n)),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 n=this.parents.pop();if(!n){this.push(null);break}if(this.parent=await n,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let r;try{r=await(0,M.readdir)(t,this._rdOptions)}catch(n){this._onError(n)}return{files:r,depth:e,path:t}}async _formatEntry(t,e){let r,n=this._isDirent?t.name:t;try{let i=(0,C.resolve)((0,C.join)(e,n));r={path:(0,C.relative)(this._root,i),fullPath:i,basename:n},r[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return r}_onError(t){Ye(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 r=t.fullPath;try{let n=await(0,M.realpath)(r),i=await(0,M.lstat)(n);if(i.isFile())return"file";if(i.isDirectory()){let a=n.length;if(r.startsWith(n)&&r.substr(a,1)===C.sep){let o=new Error(`Circular symlink detected: "${r}" points to "${n}"`);return o.code=ce,this._onError(o)}return"directory"}}catch(n){return this._onError(n),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function ue(s,t,e,r,n){let i=(a,o)=>{e(s),n(a,o,{watchedPath:s}),o&&s!==o&&J(w.resolve(s,o),k,w.join(s,o))};try{return(0,H.watch)(s,{persistent:t.persistent},i)}catch(a){r(a);return}}var H,L,w,he,Ge,$t,fe,et,st,Wt,Ve,Ke,Qe,me,E,R,Ze,Xe,k,Z,N,Je,ts,es,zt,j,ss,U,pe,X,J,ns,Nt,rs,tt,ge=at(()=>{"use strict";H=require("fs"),L=require("fs/promises"),w=P(require("path"),1),he=require("os"),Ge="data",$t="end",fe="close",et=()=>{},st=process.platform,Wt=st==="win32",Ve=st==="darwin",Ke=st==="linux",Qe=st==="freebsd",me=(0,he.type)()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},R=E,Ze="watch",Xe={lstat:L.lstat,stat:L.stat},k="listeners",Z="errHandlers",N="rawEmitters",Je=[k,Z,N],ts=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"]),es=s=>ts.has(w.extname(s).slice(1).toLowerCase()),zt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},j=(s,t,e)=>{let r=s[t];r instanceof Set||(s[t]=r=new Set([r])),r.add(e)},ss=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},U=(s,t,e)=>{let r=s[t];r instanceof Set?r.delete(e):r===e&&delete s[t]},pe=s=>s instanceof Set?s.size===0:!s,X=new Map;J=(s,t,e,r,n)=>{let i=X.get(s);i&&zt(i[t],a=>{a(e,r,n)})},ns=(s,t,e,r)=>{let{listener:n,errHandler:i,rawEmitter:a}=r,o=X.get(t),c;if(!e.persistent)return c=ue(s,e,n,i,a),c?c.close.bind(c):void 0;if(o)j(o,k,n),j(o,Z,i),j(o,N,a);else{if(c=ue(s,e,J.bind(null,t,k),i,J.bind(null,t,N)),!c)return;c.on(R.ERROR,async l=>{let d=J.bind(null,t,Z);if(o&&(o.watcherUnusable=!0),Wt&&l.code==="EPERM")try{await(await(0,L.open)(s,"r")).close(),d(l)}catch{}else d(l)}),o={listeners:n,errHandlers:i,rawEmitters:a,watcher:c},X.set(t,o)}return()=>{U(o,k,n),U(o,Z,i),U(o,N,a),pe(o.listeners)&&(o.watcher.close(),X.delete(t),Je.forEach(ss(o)),o.watcher=void 0,Object.freeze(o))}},Nt=new Map,rs=(s,t,e,r)=>{let{listener:n,rawEmitter:i}=r,a=Nt.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,H.unwatchFile)(t),a=void 0),a?(j(a,k,n),j(a,N,i)):(a={listeners:n,rawEmitters:i,options:e,watcher:(0,H.watchFile)(t,e,(c,l)=>{zt(a.rawEmitters,u=>{u(R.CHANGE,t,{curr:c,prev:l})});let d=c.mtimeMs;(c.size!==l.size||d>l.mtimeMs||d===0)&&zt(a.listeners,u=>u(s,c))})},Nt.set(t,a)),()=>{U(a,k,n),U(a,N,i),pe(a.listeners)&&(Nt.delete(t),(0,H.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},tt=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let r=this.fsw.options,n=w.dirname(t),i=w.basename(t);this.fsw._getWatchedDir(n).add(i);let o=w.resolve(t),c={persistent:r.persistent};e||(e=et);let l;if(r.usePolling){let d=r.interval!==r.binaryInterval;c.interval=d&&es(i)?r.binaryInterval:r.interval,l=rs(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=ns(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,r){if(this.fsw.closed)return;let n=w.dirname(t),i=w.basename(t),a=this.fsw._getWatchedDir(n),o=e;if(a.has(i))return;let c=async(d,u)=>{if(this.fsw._throttle(Ze,t,5)){if(!u||u.mtimeMs===0)try{let h=await(0,L.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,y=h.mtimeMs;if((!f||f<=y||y!==o.mtimeMs)&&this.fsw._emit(R.CHANGE,t,h),(Ve||Ke||Qe)&&o.ino!==h.ino){this.fsw._closeFile(d),o=h;let _=this._watchWithNodeFs(t,c);_&&this.fsw._addPathCloser(d,_)}else o=h}catch{this.fsw._remove(n,i)}else if(a.has(i)){let h=u.atimeMs,f=u.mtimeMs;(!h||h<=f||f!==o.mtimeMs)&&this.fsw._emit(R.CHANGE,t,u),o=u}}},l=this._watchWithNodeFs(t,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(R.ADD,t,0))return;this.fsw._emit(R.ADD,t,e)}return l}async _handleSymlink(t,e,r,n){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,L.realpath)(r)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(n)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(R.CHANGE,r,t.stats)):(a.add(n),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(R.ADD,r,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,r,n,i,a,o){if(t=w.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(r.path),l=new Set,d=this.fsw._readdirp(t,{fileFilter:u=>r.filterPath(u),directoryFilter:u=>r.filterDir(u)});if(d)return d.on(Ge,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===n||!n&&!c.has(h))&&(this.fsw._incrReadyCount(),f=w.join(i,w.relative(i,f)),this._addToNodeFs(f,e,r,a+1))}}).on(R.ERROR,this._boundHandleError),new Promise((u,h)=>{if(!d)return h();d.once($t,()=>{if(this.fsw.closed){d=void 0;return}let f=o?o.clear():!1;u(void 0),c.getChildren().filter(y=>y!==t&&!l.has(y)).forEach(y=>{this.fsw._remove(t,y)}),d=void 0,f&&this._handleRead(t,!1,r,n,i,a,o)})})}async _handleDir(t,e,r,n,i,a,o){let c=this.fsw._getWatchedDir(w.dirname(t)),l=c.has(w.basename(t));!(r&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(R.ADD_DIR,t,e),c.add(w.basename(t)),this.fsw._getWatchedDir(t);let d,u,h=this.fsw.options.depth;if((h==null||n<=h)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,r,a,i,t,n,d),this.fsw.closed))return;u=this._watchWithNodeFs(t,(f,y)=>{y&&y.mtimeMs===0||this._handleRead(f,!1,a,i,t,n,d)})}return u}async _addToNodeFs(t,e,r,n,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);r&&(o.filterPath=c=>r.filterPath(c),o.filterDir=c=>r.filterDir(c));try{let c=await Xe[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,L.realpath)(t):t;if(this.fsw.closed||(d=await this._handleDir(o.watchPath,c,e,n,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,L.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(R.ADD,o.watchPath,c),d=await this._handleDir(h,c,e,n,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 be={};Yt(be,{FSWatcher:()=>q,WatchHelper:()=>rt,default:()=>ws,watch:()=>Le});function nt(s){return Array.isArray(s)?s:[s]}function us(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 hs(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 we(s,t,e){let r=hs(t);for(let n=0;n<s.length;n++){let i=s[n];if(i(r,e))return!0}return!1}function fs(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let r=nt(s).map(n=>us(n));return t==null?(n,i)=>we(r,n,i):we(r,t)}function Le(s,t={}){let e=new q(t);return e.add(s),e}var Se,it,Pe,m,jt,is,ve,os,as,cs,ye,ls,ds,Ut,Ee,Te,Re,_e,ms,ps,qt,gs,ys,rt,q,ws,xe=at(()=>{"use strict";Se=require("fs"),it=require("fs/promises"),Pe=require("events"),m=P(require("path"),1);de();ge();jt="/",is="//",ve=".",os="..",as="string",cs=/\\/g,ye=/\/\//,ls=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ds=/^\.[/\\]/;Ut=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);Ee=s=>{let t=nt(s).flat();if(!t.every(e=>typeof e===as))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Re)},Te=s=>{let t=s.replace(cs,jt),e=!1;for(t.startsWith(is)&&(e=!0);t.match(ye);)t=t.replace(ye,jt);return e&&(t=jt+t),t},Re=s=>Te(m.normalize(Te(s))),_e=(s="")=>t=>typeof t=="string"?Re(m.isAbsolute(t)?t:m.join(s,t)):t,ms=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),ps=Object.freeze(new Set),qt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==ve&&t!==os&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let r=this.path;try{await(0,it.readdir)(r)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(r),m.basename(r))}}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=et,this.items=ps,Object.freeze(this)}},gs="stat",ys="lstat",rt=class{constructor(t,e,r){this.fsw=r;let n=t;this.path=t=t.replace(ds,""),this.watchPath=n,this.fullWatchPath=m.resolve(n),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?gs:ys}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 r=this.entryPath(t);return this.fsw._isntIgnored(r,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},q=class extends Pe.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,r={stabilityThreshold:2e3,pollInterval:100},n={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?nt(t.ignored):nt([]),awaitWriteFinish:e===!0?r:typeof e=="object"?{...r,...e}:!1};me&&(n.usePolling=!0),n.atomic===void 0&&(n.atomic=!n.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?n.usePolling=!1:c==="true"||c==="1"?n.usePolling=!0:n.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(n.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=et,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=n,this._nodeFsHandler=new tt(this),Object.freeze(n)}_addIgnoredPath(t){if(Ut(t)){for(let e of this._ignoredPaths)if(Ut(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)Ut(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,r){let{cwd:n}=this.options;this.closed=!1,this._closePromise=void 0;let i=Ee(t);return n&&(i=i.map(a=>ms(a,n))),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,!r,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=Ee(t),{cwd:r}=this.options;return e.forEach(n=>{!m.isAbsolute(n)&&!this._closers.has(n)&&(r&&(n=m.join(r,n)),n=m.resolve(n)),this._closePath(n),this._addIgnoredPath(n),this._watched.has(n)&&this._addIgnoredPath({path:n,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(r=>{let n=r();n instanceof Promise&&t.push(n)})),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,r)=>{let i=(this.options.cwd?m.relative(this.options.cwd,r):r)||ve;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,r){if(this.closed)return;let n=this.options;Wt&&(e=m.normalize(e)),n.cwd&&(e=m.relative(n.cwd,e));let i=[e];r!=null&&i.push(r);let a=n.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(n.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 n.atomic=="number"?n.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(n.alwaysStat&&r===void 0&&(t===E.ADD||t===E.ADD_DIR||t===E.CHANGE)){let c=n.cwd?m.join(n.cwd,e):e,l;try{l=await(0,it.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,r){this._throttled.has(t)||this._throttled.set(t,new Map);let n=this._throttled.get(t);if(!n)throw new Error("invalid throttle");let i=n.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=n.get(e),d=l?l.count:0;return n.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),d};a=setTimeout(o,r);let c={timeoutObject:a,clear:o,count:0};return n.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,r,n){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,Se.stat)(c,(f,y)=>{if(f||!d.has(t)){f&&f.code!=="ENOENT"&&n(f);return}let _=Number(new Date);h&&y.size!==h.size&&(d.get(t).lastChange=_);let O=d.get(t);_-O.lastChange>=e?(d.delete(t),n(void 0,y)):o=setTimeout(u,a,y)})}d.has(t)||(d.set(t,{lastChange:l,cancelWait:()=>(d.delete(t),clearTimeout(o),r)}),o=setTimeout(u,a))}_isIgnored(t,e){if(this.options.atomic&&ls.test(t))return!0;if(!this._userIgnored){let{cwd:r}=this.options,i=(this.options.ignored||[]).map(_e(r)),o=[...[...this._ignoredPaths].map(_e(r)),...i];this._userIgnored=fs(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new rt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new qt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,r){let n=m.join(t,e),i=m.resolve(n);if(r=r??(this._watched.has(n)||this._watched.has(i)),!this._throttle("remove",n,100))return;!r&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(n).getChildren().forEach(h=>this._remove(n,h));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let d=n;if(this.options.cwd&&(d=m.relative(this.options.cwd,n)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===E.ADD)return;this._watched.delete(n),this._watched.delete(i);let u=r?E.UNLINK_DIR:E.UNLINK;l&&!this._isIgnored(n)&&this._emit(u,n),this._closePath(n)}_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(r=>r()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let r=this._closers.get(t);r||(r=[],this._closers.set(t,r)),r.push(e)}_readdirp(t,e){if(this.closed)return;let r={type:E.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},n=le(t,r);return this._streams.add(n),n.once(fe,()=>{n=void 0}),n.once($t,()=>{n&&(this._streams.delete(n),n=void 0)}),n}};ws={watch:Le,FSWatcher:q}});var Es={};Yt(Es,{TSFilebasedRouter:()=>Ae,TSRouter:()=>Q,createEffect:()=>xt,createSignal:()=>bt,html:()=>ct,loadPyFiles:()=>Dt,mapper:()=>Gt,renderChildRoutes:()=>Lt,useAnchorSingle:()=>Tt,useInitialDOM:()=>wt,useTSAuth:()=>Pt,useTSCollection:()=>St,useTSComponent:()=>W,useTSElementEach:()=>K,useTSElements:()=>gt,useTSEvent:()=>ut,useTSEventAll:()=>mt,useTSExtractParams:()=>ft,useTSLazy:()=>Mt,useTSMetaData:()=>_t,useTSNavigate:()=>vt,useTSNoReload:()=>Ot,useTSOutlet:()=>Rt,useTSParams:()=>$,useTSPurifier:()=>dt,useTSSSRHydration:()=>Ct,useTSSelect:()=>F,useTSloadBrython:()=>At});module.exports=ke(Es);function He(s){let t=s==null?"":String(s),e=t.toLowerCase();return(e.includes("<script")||e.includes("javascript:"))&&(t=""),t=t.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),t.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function ct(s,...t){return s.reduce((e,r,n)=>{let i=n<t.length?He(t[n]):"";return e+r+i},"")}var Fe=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),Gt=s=>s?.map(t=>Fe(t)).join("")??"";var lt=P(require("dompurify"),1),dt=(s,t)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?lt.default.sanitize(s,r):lt.default.sanitize(s.innerHTML,r)};var ut=(s,t,e)=>{if(typeof s=="string"){let r=document.getElementById(s);r?r.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s instanceof HTMLElement?s.addEventListener(t,e):s===document?document.addEventListener(t,e):console.warn("Invalid target parameter provided.")};var Vt=require("zustand/vanilla"),ht=P(require("dompurify"),1);function Ne(s,t){let e=[],r=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),n=new RegExp(`^${r}$`),i=t.match(n),a={};return i&&e.forEach((o,c)=>{a[o]=ht.default.sanitize(i[c+1]??"")}),a}function ze(s){let t={},e=new URLSearchParams(s);for(let[r,n]of e.entries())t[r]=ht.default.sanitize(n);return t}var $=(0,Vt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let r=window.location.pathname,n=Ne(e,r),i=ze(window.location.search);s({params:n,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function ft(s){let t=$.getState();t.setFromPattern(s);let e=t.params,r=t.query;return{...e,...r}}var mt=(s,t,e)=>{let r=document.querySelectorAll(s);return r.forEach(n=>{n.addEventListener(t,e)}),()=>{r.forEach(n=>{n.removeEventListener(t,e)})}};var pt=P(require("dompurify"),1),gt=(s,t,e={},r)=>{let n={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","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...r};pt.default.addHook("uponSanitizeAttribute",(o,c)=>{let l=(c.attrName||"").toLowerCase(),d=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(o.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(d)||/^\/(?!\/)/.test(d)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(d)||(c.keepAttr=!1);return}if(l==="class"){let h=d.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let y=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return y===""||/^https?:\/\//i.test(y)||/^\/(?!\/)/.test(y)||/^\.{0,2}\//.test(y)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=h.join(" ");return}});let i=pt.default.sanitize(t,{...n,RETURN_DOM_FRAGMENT:!0});for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(i);let a=(o,c)=>{s.querySelectorAll(`[${o}]`).forEach(l=>{let d=l.getAttribute(o);d&&Object.prototype.hasOwnProperty.call(e,d)&&l.addEventListener(c,u=>{c==="submit"&&u.preventDefault(),e[d](u)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),s.querySelectorAll("[data-key]").forEach(o=>{let c=o.dataset.key,l=o.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(e,c)&&o.addEventListener(l,e[c])}),s.querySelectorAll("[data-hover]").forEach(o=>{let c=o.dataset.hover;c&&Object.prototype.hasOwnProperty.call(e,c)&&(o.addEventListener("mouseenter",e[c]),o.addEventListener("mouseleave",e[c]))}),s.querySelectorAll("[data-classlist]").forEach(o=>{let c=o.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&o.classList.add(...c.split(/\s+/))})};var yt=P(require("dompurify"),1),V=null,wt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;yt.default.addHook("uponSanitizeAttribute",(a,o)=>{let c=(o.attrName||"").toLowerCase(),l=(o.attrValue??"").toString().trim();if(c.startsWith("on")){o.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){o.keepAttr=!1;return}if(c==="class"){let u=l.split(/\s+/).filter(Boolean).filter(h=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(h)){if(/^bg-\[url\(.*\)\]$/.test(h)){let f=h.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return f===""||/^https?:\/\//i.test(f)||/^\/(?!\/)/.test(f)||/^\.{0,2}\//.test(f)}return!0}return!1});o.attrValue=u.join(" ");return}if(c==="style"){o.keepAttr=!1;return}});let r=e.cloneNode(!0),n=yt.default.sanitize(r.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(n.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(V!==null&&i!==V){let a=document.createElement("div");t(a);let c=new DOMParser().parseFromString(V,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(V=i;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(n),t(e)}};var Et=P(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 Tt=(s,t,e,r="",n=null)=>{if(!s)return;let i=Et.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Et.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),r&&(s.className=r.trim()),n&&s.replaceChildren(n),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=P(require("dompurify"),1);var Kt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",n="'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 ${r}; img-src ${n}; 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:x.default.sanitize(s.name||""),title:x.default.sanitize(s.title||""),description:x.default.sanitize(s.description||"Default description"),author:x.default.sanitize(s.author||""),favicon:s.favicon},r=g=>{e.name=x.default.sanitize(g),_("name",e.name)},n=g=>{e.title=x.default.sanitize(g),document.title=e.title},i=g=>{e.description=x.default.sanitize(g),_("description",e.description)},a=g=>{e.author=x.default.sanitize(g),_("author",e.author)},o=g=>{e.favicon=x.default.sanitize(g);let p=document.querySelector('link[rel="icon"]');p||(p=document.createElement("link"),p.rel="icon",document.head.appendChild(p)),p.href=e.favicon},c=()=>e.name,l=()=>e.title,d=()=>e.description,u=()=>e.author,h=()=>e.favicon,f=()=>e,y=(g,p)=>{let T=document.createElement("meta");T.setAttribute("name",g),T.setAttribute("content",p),document.head.appendChild(T)},_=(g,p)=>{let T=document.querySelector(`meta[name="${g}"]`);T?T.setAttribute("content",p):y(g,p)},O=()=>{e.title&&(document.title=e.title),e.name&&_("name",e.name),e.description&&_("description",e.description),e.author&&_("author",e.author),e.favicon&&o(e.favicon)};return t&&Kt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),O(),{setName:r,setTitle:n,setDescription:i,setAuthor:a,setFavicon:o,getName:c,getTitle:l,getDescription:d,getAuthor:u,getFavicon:h,getAllMetaData:f,appendMetaTagsToHead:O}};var Qt=P(require("dompurify"),1),W=(s,t,e,r,n)=>{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=Qt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,r,n)};var St=(s,t,e,r=[])=>{let n=new Set;s.forEach((i,a)=>{if(n.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}n.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(r)?r[a]:void 0;typeof c=="function"?W(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var F=(s,t)=>{let r=(t??document).querySelectorAll(s);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. 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: '${s}'. Returning the first one.`),r[0]};var Zt=require("jwt-decode"),Pt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let r=(0,Zt.jwtDecode)(e),n=Date.now()/1e3;return r.exp&&r.exp<n&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(r){return console.error("Invalid token:",r),window.location.href=t,null}};var K=(s,t,e)=>{s.forEach(r=>{t.forEach(n=>{r.addEventListener(n,i=>{e(r,i)})})})};var vt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Rt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let r=window.location.pathname.replace(/\/$/,"");for(let n of t){let i=n.path.replace(/\/$/,"");if(r===i||r.startsWith(`${i}/`)){n.component(e);break}}};function Lt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(r=>{r.children?.length&&r.children.forEach(n=>{let i=n.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${n.outlet}`)||s.querySelector(`.${n.outlet}`);a instanceof HTMLElement&&n.element&&n.element(a)}})})}var Xt=require("zustand/vanilla");function bt(s){let t=(0,Xt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:r=>{t.setState({value:r}),e.forEach(n=>n(r))},subscribe:r=>(e.add(r),r(t.getState().value),()=>e.delete(r))}}function xt(s){let t=s();typeof t=="function"&&t()}var At=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=r=>new Promise((n,i)=>{let a=document.createElement("script");a.src=r,a.onload=()=>n(),a.onerror=()=>i(new Error(`Failed to load ${r}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Dt=s=>new Promise((t,e)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${s}`,r.onload=()=>t(),r.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(r)});function Mt(s){let t=null;return async(e,r)=>{try{if(!t){let n=await s();t=n.default||n}if(typeof t=="function")return t(e,r);if(t instanceof HTMLElement){let n=t.cloneNode(!0);return e?.appendChild(n),n}if(typeof t=="object"&&t!==null&&"render"in t&&typeof t.render=="function")return t.render(e,r);console.warn("useTSLazy: Unsupported module type",t)}catch(n){console.error("useTSLazy failed:",n)}}}var Ct=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var Jt=require("lodash-es"),It=s=>s;typeof window<"u"&&typeof document<"u"&&(It=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var $e=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 r=e.getAttribute("class")||"";e.setAttribute("class",It(r));let n=e.getAttribute("aria-label");n&&e.setAttribute("aria-label",It(n));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=(0,Jt.debounce)($e,50),te=s=>{We(s)};var Ot=s=>{if(!s)return;let t=F("a",s);te(t)};var kt=P(require("dompurify"),1);var se=require("zustand/vanilla"),ne=P(require("dompurify"),1),I=(0,se.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:ee(t)})),setQuery:t=>s(()=>({query:ee(t)}))}));function ee(s){let t={};for(let e in s)t[e]=ne.default.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,r=this.parseQueryParams(e),n=this.findMatchingRoute(t,this.routes);if(n){if(n.routeto){this.navigate(n.routeto);return}let i=this.filterAndSanitizeParams(n.params);I.getState().setParams(i),I.getState().setQuery(r);let a=document.createElement("div");if(n.element?.(a,i,r),n.children){let o=t.slice(n.path.length),c=a.querySelector("#child");c&&this.renderChildren(n.children,o,c,i,r)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);I.getState().setParams(a),I.getState().setQuery(r);let o=document.createElement("div");i.element?.(o,a,r)}}}renderChildren(t,e,r,n,i){if(!t||t.length===0){let o=r.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...n,...a.params},l=this.filterAndSanitizeParams(c);if(I.getState().setParams(l),I.getState().setQuery(i),a.element?.(o,l,i),r.appendChild(o),a.children){let d=e.slice(a.path.length);this.renderChildren(a.children,d,o,l,i)}}}parseQueryParams(t){let e={},r=new URLSearchParams(t);for(let[n,i]of r.entries())this.expectedParams.has(n)&&(e[n]=kt.default.sanitize(i));return e}findMatchingRoute(t,e,r={}){for(let n of e){let i=n.path;if(i==="*")return n;{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={...r};if(o.forEach((h,f)=>{u[h]=d[f+1]??""}),n.children){let h=t.slice(d[0].length),f=this.findMatchingRoute(h,n.children,u);if(f)return f}return{...n,params:u}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let r in t)this.expectedParams.has(r)&&(e[r]=kt.default.sanitize(t[r]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var Ae=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await import("path"),e=await Promise.resolve().then(()=>(xe(),be)),r=t.resolve("src/pages"),n=t.resolve("src/gen"),i=t.resolve("src/routes"),a=t.join(n,"tsrouter.gen.ts"),o=t.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(g){try{await s.mkdir(g,{recursive:!0})}catch{}}function d(g,p){let T="/"+t.relative(p,g).replace(/\\/g,"/");return T=T.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",T.replace(/\[(.+?)\]/g,":$1")}function u(g){return g.replace(/^\//,"").split("/").map(p=>p.startsWith(":")?p.slice(1):p).filter(Boolean).join("-")||"index"}function h(g,p){let A=t.relative(p,g).replace(/\\/g,"/").split("/").filter(Boolean),S=A[A.length-1].replace(".ts",""),b=A.length>1?A[A.length-2]:"";if(S==="index")return b?b.charAt(0).toUpperCase()+b.slice(1):"Index";if(S.startsWith("[")&&S.endsWith("]")){let D=S.slice(1,-1);return b.charAt(0).toUpperCase()+D.charAt(0).toUpperCase()+D.slice(1)}return S.charAt(0).toUpperCase()+S.slice(1)}async function f(g,p=""){let T=await s.readdir(g,{withFileTypes:!0}),A=[];for(let S of T){let b=t.join(g,S.name);if(S.isDirectory()){let D=S.name,Y=await f(b,t.join(p,D)),B=Y.find(z=>z.isIndex),ot={path:"/"+t.join(p,D).replace(/\\/g,"/"),name:(p?p.replace(/\\/g,"-")+"-":"")+D,component:B?B.component:void 0,children:Y.filter(z=>!z.isIndex)};A.push(ot)}else if(S.isFile()&&S.name.endsWith(".ts")){let D=d(b,r),Y=u(D),B=h(b,r),ot="../pages/"+t.relative(r,b).replace(/\\/g,"/").replace(/\.ts$/,""),z=S.name==="index.ts";A.push({file:b,route:D,routeName:Y,importName:B,component:`useTSLazy(() => import("${ot}"))`,isIndex:z})}}return A}function y(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
1
|
+
"use strict";var be=Object.create;var Y=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Ae=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Me=Object.prototype.hasOwnProperty;var rt=(s,t)=>()=>(s&&(t=s(s=0)),t);var jt=(s,t)=>{for(var e in t)Y(s,e,{get:t[e],enumerable:!0})},Ut=(s,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ae(t))!Me.call(s,n)&&n!==e&&Y(s,n,{get:()=>t[n],enumerable:!(r=xe(t,n))||r.enumerable});return s};var v=(s,t,e)=>(e=s!=null?be(De(s)):{},Ut(t||!s||!s.__esModule?Y(e,"default",{value:s,enumerable:!0}):e,s)),Ce=s=>Ut(Y({},"__esModule",{value:!0}),s);function oe(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=R.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&&!ee.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${ee.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Ft(t)}var M,re,C,R,Ot,ie,ze,ee,$e,We,je,Ue,se,ne,Ft,ae=rt(()=>{"use strict";M=require("fs/promises"),re=require("stream"),C=require("path"),R={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Ot={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:R.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Ot);ie="READDIRP_RECURSIVE_ERROR",ze=new Set(["ENOENT","EPERM","EACCES","ELOOP",ie]),ee=[R.DIR_TYPE,R.EVERYTHING_TYPE,R.FILE_DIR_TYPE,R.FILE_TYPE],$e=new Set([R.DIR_TYPE,R.EVERYTHING_TYPE,R.FILE_DIR_TYPE]),We=new Set([R.EVERYTHING_TYPE,R.FILE_DIR_TYPE,R.FILE_TYPE]),je=s=>ze.has(s.code),Ue=process.platform==="win32",se=s=>!0,ne=s=>{if(s===void 0)return se;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(r=>e.basename===r)}return se},Ft=class extends re.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...Ot,...t},{root:r,type:n}=e;this._fileFilter=ne(e.fileFilter),this._directoryFilter=ne(e.directoryFilter);let i=e.lstat?M.lstat:M.stat;Ue?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??Ot.depth,this._wantsDir=n?$e.has(n):!1,this._wantsFile=n?We.has(n):!1,this._wantsEverything=n===R.EVERYTHING_TYPE,this._root=(0,C.resolve)(r),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(r,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,r=e&&e.files;if(r&&r.length>0){let{path:n,depth:i}=e,a=r.splice(0,t).map(c=>this._formatEntry(c,n)),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 n=this.parents.pop();if(!n){this.push(null);break}if(this.parent=await n,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let r;try{r=await(0,M.readdir)(t,this._rdOptions)}catch(n){this._onError(n)}return{files:r,depth:e,path:t}}async _formatEntry(t,e){let r,n=this._isDirent?t.name:t;try{let i=(0,C.resolve)((0,C.join)(e,n));r={path:(0,C.relative)(this._root,i),fullPath:i,basename:n},r[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return r}_onError(t){je(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 r=t.fullPath;try{let n=await(0,M.realpath)(r),i=await(0,M.lstat)(n);if(i.isFile())return"file";if(i.isDirectory()){let a=n.length;if(r.startsWith(n)&&r.substr(a,1)===C.sep){let o=new Error(`Circular symlink detected: "${r}" points to "${n}"`);return o.code=ie,this._onError(o)}return"directory"}}catch(n){return this._onError(n),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function ce(s,t,e,r,n){let i=(a,o)=>{e(s),n(a,o,{watchedPath:s}),o&&s!==o&&Z(w.resolve(s,o),F,w.join(s,o))};try{return(0,I.watch)(s,{persistent:t.persistent},i)}catch(a){r(a);return}}var I,x,w,le,qe,Ht,ue,J,tt,Nt,Ye,Be,Ge,de,E,b,Ve,Ke,F,K,H,Qe,Ze,Xe,kt,$,Je,W,he,Q,Z,ts,It,es,X,fe=rt(()=>{"use strict";I=require("fs"),x=require("fs/promises"),w=v(require("path"),1),le=require("os"),qe="data",Ht="end",ue="close",J=()=>{},tt=process.platform,Nt=tt==="win32",Ye=tt==="darwin",Be=tt==="linux",Ge=tt==="freebsd",de=(0,le.type)()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},b=E,Ve="watch",Ke={lstat:x.lstat,stat:x.stat},F="listeners",K="errHandlers",H="rawEmitters",Qe=[F,K,H],Ze=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"]),Xe=s=>Ze.has(w.extname(s).slice(1).toLowerCase()),kt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},$=(s,t,e)=>{let r=s[t];r instanceof Set||(s[t]=r=new Set([r])),r.add(e)},Je=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},W=(s,t,e)=>{let r=s[t];r instanceof Set?r.delete(e):r===e&&delete s[t]},he=s=>s instanceof Set?s.size===0:!s,Q=new Map;Z=(s,t,e,r,n)=>{let i=Q.get(s);i&&kt(i[t],a=>{a(e,r,n)})},ts=(s,t,e,r)=>{let{listener:n,errHandler:i,rawEmitter:a}=r,o=Q.get(t),c;if(!e.persistent)return c=ce(s,e,n,i,a),c?c.close.bind(c):void 0;if(o)$(o,F,n),$(o,K,i),$(o,H,a);else{if(c=ce(s,e,Z.bind(null,t,F),i,Z.bind(null,t,H)),!c)return;c.on(b.ERROR,async l=>{let u=Z.bind(null,t,K);if(o&&(o.watcherUnusable=!0),Nt&&l.code==="EPERM")try{await(await(0,x.open)(s,"r")).close(),u(l)}catch{}else u(l)}),o={listeners:n,errHandlers:i,rawEmitters:a,watcher:c},Q.set(t,o)}return()=>{W(o,F,n),W(o,K,i),W(o,H,a),he(o.listeners)&&(o.watcher.close(),Q.delete(t),Qe.forEach(Je(o)),o.watcher=void 0,Object.freeze(o))}},It=new Map,es=(s,t,e,r)=>{let{listener:n,rawEmitter:i}=r,a=It.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,I.unwatchFile)(t),a=void 0),a?($(a,F,n),$(a,H,i)):(a={listeners:n,rawEmitters:i,options:e,watcher:(0,I.watchFile)(t,e,(c,l)=>{kt(a.rawEmitters,d=>{d(b.CHANGE,t,{curr:c,prev:l})});let u=c.mtimeMs;(c.size!==l.size||u>l.mtimeMs||u===0)&&kt(a.listeners,d=>d(s,c))})},It.set(t,a)),()=>{W(a,F,n),W(a,H,i),he(a.listeners)&&(It.delete(t),(0,I.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},X=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let r=this.fsw.options,n=w.dirname(t),i=w.basename(t);this.fsw._getWatchedDir(n).add(i);let o=w.resolve(t),c={persistent:r.persistent};e||(e=J);let l;if(r.usePolling){let u=r.interval!==r.binaryInterval;c.interval=u&&Xe(i)?r.binaryInterval:r.interval,l=es(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=ts(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,r){if(this.fsw.closed)return;let n=w.dirname(t),i=w.basename(t),a=this.fsw._getWatchedDir(n),o=e;if(a.has(i))return;let c=async(u,d)=>{if(this.fsw._throttle(Ve,t,5)){if(!d||d.mtimeMs===0)try{let h=await(0,x.stat)(t);if(this.fsw.closed)return;let f=h.atimeMs,g=h.mtimeMs;if((!f||f<=g||g!==o.mtimeMs)&&this.fsw._emit(b.CHANGE,t,h),(Ye||Be||Ge)&&o.ino!==h.ino){this.fsw._closeFile(u),o=h;let S=this._watchWithNodeFs(t,c);S&&this.fsw._addPathCloser(u,S)}else o=h}catch{this.fsw._remove(n,i)}else if(a.has(i)){let h=d.atimeMs,f=d.mtimeMs;(!h||h<=f||f!==o.mtimeMs)&&this.fsw._emit(b.CHANGE,t,d),o=d}}},l=this._watchWithNodeFs(t,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(b.ADD,t,0))return;this.fsw._emit(b.ADD,t,e)}return l}async _handleSymlink(t,e,r,n){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,x.realpath)(r)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(n)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(b.CHANGE,r,t.stats)):(a.add(n),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(b.ADD,r,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,r,n,i,a,o){if(t=w.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(r.path),l=new Set,u=this.fsw._readdirp(t,{fileFilter:d=>r.filterPath(d),directoryFilter:d=>r.filterDir(d)});if(u)return u.on(qe,async d=>{if(this.fsw.closed){u=void 0;return}let h=d.path,f=w.join(t,h);if(l.add(h),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,t,f,h))){if(this.fsw.closed){u=void 0;return}(h===n||!n&&!c.has(h))&&(this.fsw._incrReadyCount(),f=w.join(i,w.relative(i,f)),this._addToNodeFs(f,e,r,a+1))}}).on(b.ERROR,this._boundHandleError),new Promise((d,h)=>{if(!u)return h();u.once(Ht,()=>{if(this.fsw.closed){u=void 0;return}let f=o?o.clear():!1;d(void 0),c.getChildren().filter(g=>g!==t&&!l.has(g)).forEach(g=>{this.fsw._remove(t,g)}),u=void 0,f&&this._handleRead(t,!1,r,n,i,a,o)})})}async _handleDir(t,e,r,n,i,a,o){let c=this.fsw._getWatchedDir(w.dirname(t)),l=c.has(w.basename(t));!(r&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(b.ADD_DIR,t,e),c.add(w.basename(t)),this.fsw._getWatchedDir(t);let u,d,h=this.fsw.options.depth;if((h==null||n<=h)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,r,a,i,t,n,u),this.fsw.closed))return;d=this._watchWithNodeFs(t,(f,g)=>{g&&g.mtimeMs===0||this._handleRead(f,!1,a,i,t,n,u)})}return d}async _addToNodeFs(t,e,r,n,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);r&&(o.filterPath=c=>r.filterPath(c),o.filterDir=c=>r.filterDir(c));try{let c=await Ke[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,u;if(c.isDirectory()){let d=w.resolve(t),h=l?await(0,x.realpath)(t):t;if(this.fsw.closed||(u=await this._handleDir(o.watchPath,c,e,n,i,o,h),this.fsw.closed))return;d!==h&&h!==void 0&&this.fsw._symlinkPaths.set(d,h)}else if(c.isSymbolicLink()){let d=l?await(0,x.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(b.ADD,o.watchPath,c),u=await this._handleDir(h,c,e,n,t,o,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(w.resolve(t),d)}else u=this._handleFile(o.watchPath,c,e);return a(),u&&this.fsw._addPathCloser(t,u),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}}});var ve={};jt(ve,{FSWatcher:()=>j,WatchHelper:()=>st,default:()=>ps,watch:()=>Pe});function et(s){return Array.isArray(s)?s:[s]}function cs(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 ls(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 pe(s,t,e){let r=ls(t);for(let n=0;n<s.length;n++){let i=s[n];if(i(r,e))return!0}return!1}function us(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let r=et(s).map(n=>cs(n));return t==null?(n,i)=>pe(r,n,i):pe(r,t)}function Pe(s,t={}){let e=new j(t);return e.add(s),e}var Ee,nt,Te,m,zt,ss,_e,ns,rs,is,me,os,as,$t,ge,ye,Se,we,ds,hs,Wt,fs,ms,st,j,ps,Re=rt(()=>{"use strict";Ee=require("fs"),nt=require("fs/promises"),Te=require("events"),m=v(require("path"),1);ae();fe();zt="/",ss="//",_e=".",ns="..",rs="string",is=/\\/g,me=/\/\//,os=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,as=/^\.[/\\]/;$t=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);ge=s=>{let t=et(s).flat();if(!t.every(e=>typeof e===rs))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Se)},ye=s=>{let t=s.replace(is,zt),e=!1;for(t.startsWith(ss)&&(e=!0);t.match(me);)t=t.replace(me,zt);return e&&(t=zt+t),t},Se=s=>ye(m.normalize(ye(s))),we=(s="")=>t=>typeof t=="string"?Se(m.isAbsolute(t)?t:m.join(s,t)):t,ds=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),hs=Object.freeze(new Set),Wt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==_e&&t!==ns&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let r=this.path;try{await(0,nt.readdir)(r)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(r),m.basename(r))}}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=hs,Object.freeze(this)}},fs="stat",ms="lstat",st=class{constructor(t,e,r){this.fsw=r;let n=t;this.path=t=t.replace(as,""),this.watchPath=n,this.fullWatchPath=m.resolve(n),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?fs:ms}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 r=this.entryPath(t);return this.fsw._isntIgnored(r,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},j=class extends Te.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,r={stabilityThreshold:2e3,pollInterval:100},n={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?et(t.ignored):et([]),awaitWriteFinish:e===!0?r:typeof e=="object"?{...r,...e}:!1};de&&(n.usePolling=!0),n.atomic===void 0&&(n.atomic=!n.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?n.usePolling=!1:c==="true"||c==="1"?n.usePolling=!0:n.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(n.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=n,this._nodeFsHandler=new X(this),Object.freeze(n)}_addIgnoredPath(t){if($t(t)){for(let e of this._ignoredPaths)if($t(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)$t(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,r){let{cwd:n}=this.options;this.closed=!1,this._closePromise=void 0;let i=ge(t);return n&&(i=i.map(a=>ds(a,n))),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,!r,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=ge(t),{cwd:r}=this.options;return e.forEach(n=>{!m.isAbsolute(n)&&!this._closers.has(n)&&(r&&(n=m.join(r,n)),n=m.resolve(n)),this._closePath(n),this._addIgnoredPath(n),this._watched.has(n)&&this._addIgnoredPath({path:n,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(r=>{let n=r();n instanceof Promise&&t.push(n)})),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,r)=>{let i=(this.options.cwd?m.relative(this.options.cwd,r):r)||_e;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,r){if(this.closed)return;let n=this.options;Nt&&(e=m.normalize(e)),n.cwd&&(e=m.relative(n.cwd,e));let i=[e];r!=null&&i.push(r);let a=n.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(n.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 n.atomic=="number"?n.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,u)=>{l?(t=E.ERROR,i[0]=l,this.emitWithAll(t,i)):u&&(i.length>1?i[1]=u:i.push(u),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(n.alwaysStat&&r===void 0&&(t===E.ADD||t===E.ADD_DIR||t===E.CHANGE)){let c=n.cwd?m.join(n.cwd,e):e,l;try{l=await(0,nt.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,r){this._throttled.has(t)||this._throttled.set(t,new Map);let n=this._throttled.get(t);if(!n)throw new Error("invalid throttle");let i=n.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=n.get(e),u=l?l.count:0;return n.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),u};a=setTimeout(o,r);let c={timeoutObject:a,clear:o,count:0};return n.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,r,n){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,u=this._pendingWrites;function d(h){(0,Ee.stat)(c,(f,g)=>{if(f||!u.has(t)){f&&f.code!=="ENOENT"&&n(f);return}let S=Number(new Date);h&&g.size!==h.size&&(u.get(t).lastChange=S);let T=u.get(t);S-T.lastChange>=e?(u.delete(t),n(void 0,g)):o=setTimeout(d,a,g)})}u.has(t)||(u.set(t,{lastChange:l,cancelWait:()=>(u.delete(t),clearTimeout(o),r)}),o=setTimeout(d,a))}_isIgnored(t,e){if(this.options.atomic&&os.test(t))return!0;if(!this._userIgnored){let{cwd:r}=this.options,i=(this.options.ignored||[]).map(we(r)),o=[...[...this._ignoredPaths].map(we(r)),...i];this._userIgnored=us(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new st(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new Wt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,r){let n=m.join(t,e),i=m.resolve(n);if(r=r??(this._watched.has(n)||this._watched.has(i)),!this._throttle("remove",n,100))return;!r&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(n).getChildren().forEach(h=>this._remove(n,h));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let u=n;if(this.options.cwd&&(u=m.relative(this.options.cwd,n)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===E.ADD)return;this._watched.delete(n),this._watched.delete(i);let d=r?E.UNLINK_DIR:E.UNLINK;l&&!this._isIgnored(n)&&this._emit(d,n),this._closePath(n)}_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(r=>r()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let r=this._closers.get(t);r||(r=[],this._closers.set(t,r)),r.push(e)}_readdirp(t,e){if(this.closed)return;let r={type:E.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},n=oe(t,r);return this._streams.add(n),n.once(ue,()=>{n=void 0}),n.once(Ht,()=>{n&&(this._streams.delete(n),n=void 0)}),n}};ps={watch:Pe,FSWatcher:j}});var gs={};jt(gs,{TSFilebasedRouter:()=>Le,TSRouter:()=>V,createEffect:()=>Rt,createSignal:()=>vt,html:()=>it,loadPyFiles:()=>bt,mapper:()=>qt,renderChildRoutes:()=>Pt,useAnchorSingle:()=>yt,useInitialDOM:()=>pt,useTSAuth:()=>Tt,useTSCollection:()=>Et,useTSComponent:()=>z,useTSElementEach:()=>G,useTSElements:()=>ft,useTSEvent:()=>ct,useTSEventAll:()=>dt,useTSExtractParams:()=>ut,useTSLazy:()=>xt,useTSMetaData:()=>wt,useTSNavigate:()=>_t,useTSNoReload:()=>Mt,useTSOutlet:()=>St,useTSParams:()=>N,useTSPurifier:()=>at,useTSSSRHydration:()=>At,useTSSelect:()=>k,useTSloadBrython:()=>Lt});module.exports=Ce(gs);function Oe(s){let t=s==null?"":String(s),e=t.toLowerCase();return(e.includes("<script")||e.includes("javascript:"))&&(t=""),t=t.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),t.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function it(s,...t){return s.reduce((e,r,n)=>{let i=n<t.length?Oe(t[n]):"";return e+r+i},"")}var Fe=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),qt=s=>s?.map(t=>Fe(t)).join("")??"";var ot=v(require("dompurify"),1),at=(s,t)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?ot.default.sanitize(s,r):ot.default.sanitize(s.innerHTML,r)};var ct=(s,t,e)=>{if(typeof s=="string"){let r=document.getElementById(s);r?r.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s instanceof HTMLElement?s.addEventListener(t,e):s===document?document.addEventListener(t,e):console.warn("Invalid target parameter provided.")};var Yt=require("zustand/vanilla"),lt=v(require("dompurify"),1);function Ie(s,t){let e=[],r=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),n=new RegExp(`^${r}$`),i=t.match(n),a={};return i&&e.forEach((o,c)=>{a[o]=lt.default.sanitize(i[c+1]??"")}),a}function ke(s){let t={},e=new URLSearchParams(s);for(let[r,n]of e.entries())t[r]=lt.default.sanitize(n);return t}var N=(0,Yt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let r=window.location.pathname,n=Ie(e,r),i=ke(window.location.search);s({params:n,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function ut(s){let t=N.getState();t.setFromPattern(s);let e=t.params,r=t.query;return{...e,...r}}var dt=(s,t,e)=>{let r=document.querySelectorAll(s);return r.forEach(n=>{n.addEventListener(t,e)}),()=>{r.forEach(n=>{n.removeEventListener(t,e)})}};var ht=v(require("dompurify"),1),ft=(s,t,e={},r)=>{let n={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","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...r};ht.default.addHook("uponSanitizeAttribute",(o,c)=>{let l=(c.attrName||"").toLowerCase(),u=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(o.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(u)||/^\/(?!\/)/.test(u)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(u)||(c.keepAttr=!1);return}if(l==="class"){let h=u.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let g=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return g===""||/^https?:\/\//i.test(g)||/^\/(?!\/)/.test(g)||/^\.{0,2}\//.test(g)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=h.join(" ");return}});let i=ht.default.sanitize(t,{...n,RETURN_DOM_FRAGMENT:!0});for(;s.firstChild;)s.removeChild(s.firstChild);s.appendChild(i);let a=(o,c)=>{s.querySelectorAll(`[${o}]`).forEach(l=>{let u=l.getAttribute(o);u&&Object.prototype.hasOwnProperty.call(e,u)&&l.addEventListener(c,d=>{c==="submit"&&d.preventDefault(),e[u](d)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),s.querySelectorAll("[data-key]").forEach(o=>{let c=o.dataset.key,l=o.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(e,c)&&o.addEventListener(l,e[c])}),s.querySelectorAll("[data-hover]").forEach(o=>{let c=o.dataset.hover;c&&Object.prototype.hasOwnProperty.call(e,c)&&(o.addEventListener("mouseenter",e[c]),o.addEventListener("mouseleave",e[c]))}),s.querySelectorAll("[data-classlist]").forEach(o=>{let c=o.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&o.classList.add(...c.split(/\s+/))})};var mt=v(require("dompurify"),1),B=null,pt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;mt.default.addHook("uponSanitizeAttribute",(a,o)=>{let c=(o.attrName||"").toLowerCase(),l=(o.attrValue??"").toString().trim();if(c.startsWith("on")){o.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){o.keepAttr=!1;return}if(c==="class"){let d=l.split(/\s+/).filter(Boolean).filter(h=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(h)){if(/^bg-\[url\(.*\)\]$/.test(h)){let f=h.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return f===""||/^https?:\/\//i.test(f)||/^\/(?!\/)/.test(f)||/^\.{0,2}\//.test(f)}return!0}return!1});o.attrValue=d.join(" ");return}if(c==="style"){o.keepAttr=!1;return}});let r=e.cloneNode(!0),n=mt.default.sanitize(r.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(n.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(B!==null&&i!==B){let a=document.createElement("div");t(a);let c=new DOMParser().parseFromString(B,"text/html");for(;e.firstChild;)e.removeChild(e.firstChild);c.body.childNodes.forEach(l=>e.appendChild(l.cloneNode(!0)))}else{for(B=i;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(n),t(e)}};var gt=v(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 yt=(s,t,e,r="",n=null)=>{if(!s)return;let i=gt.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=gt.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),r&&(s.className=r.trim()),n&&s.replaceChildren(n),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var A=v(require("dompurify"),1);var Bt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",n="'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 u=()=>{try{let d=document.querySelector('meta[http-equiv="Content-Security-Policy"]');d||(d=document.createElement("meta"),d.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(d));let h=l?`report-uri ${c};`:"";d.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${r}; img-src ${n}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${h}`)}catch(d){console.error("Error adding CSP meta element:",d)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var wt=(s,t)=>{let e={name:A.default.sanitize(s.name||""),title:A.default.sanitize(s.title||""),description:A.default.sanitize(s.description||"Default description"),author:A.default.sanitize(s.author||""),favicon:s.favicon},r=p=>{e.name=A.default.sanitize(p),S("name",e.name)},n=p=>{e.title=A.default.sanitize(p),document.title=e.title},i=p=>{e.description=A.default.sanitize(p),S("description",e.description)},a=p=>{e.author=A.default.sanitize(p),S("author",e.author)},o=p=>{e.favicon=A.default.sanitize(p);let y=document.querySelector('link[rel="icon"]');y||(y=document.createElement("link"),y.rel="icon",document.head.appendChild(y)),y.href=e.favicon},c=()=>e.name,l=()=>e.title,u=()=>e.description,d=()=>e.author,h=()=>e.favicon,f=()=>e,g=(p,y)=>{let _=document.createElement("meta");_.setAttribute("name",p),_.setAttribute("content",y),document.head.appendChild(_)},S=(p,y)=>{let _=document.querySelector(`meta[name="${p}"]`);_?_.setAttribute("content",y):g(p,y)},T=()=>{e.title&&(document.title=e.title),e.name&&S("name",e.name),e.description&&S("description",e.description),e.author&&S("author",e.author),e.favicon&&o(e.favicon)};return t&&Bt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),T(),{setName:r,setTitle:n,setDescription:i,setAuthor:a,setFavicon:o,getName:c,getTitle:l,getDescription:u,getAuthor:d,getFavicon:h,getAllMetaData:f,appendMetaTagsToHead:T}};var Gt=v(require("dompurify"),1),z=(s,t,e,r,n)=>{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,r,n)};var Et=(s,t,e,r=[])=>{let n=new Set;s.forEach((i,a)=>{if(n.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}n.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(r)?r[a]:void 0;typeof c=="function"?z(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var k=(s,t)=>{let r=(t??document).querySelectorAll(s);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. 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: '${s}'. Returning the first one.`),r[0]};var Vt=require("jwt-decode"),Tt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let r=(0,Vt.jwtDecode)(e),n=Date.now()/1e3;return r.exp&&r.exp<n&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(r){return console.error("Invalid token:",r),window.location.href=t,null}};var G=(s,t,e)=>{s.forEach(r=>{t.forEach(n=>{r.addEventListener(n,i=>{e(r,i)})})})};var _t=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var St=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let r=window.location.pathname.replace(/\/$/,"");for(let n of t){let i=n.path.replace(/\/$/,"");if(r===i||r.startsWith(`${i}/`)){n.component(e);break}}};function Pt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(r=>{r.children?.length&&r.children.forEach(n=>{let i=n.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${n.outlet}`)||s.querySelector(`.${n.outlet}`);a instanceof HTMLElement&&n.element&&n.element(a)}})})}var Kt=require("zustand/vanilla");function vt(s){let t=(0,Kt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:r=>{t.setState({value:r}),e.forEach(n=>n(r))},subscribe:r=>(e.add(r),r(t.getState().value),()=>e.delete(r))}}function Rt(s){let t=s();typeof t=="function"&&t()}var Lt=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=r=>new Promise((n,i)=>{let a=document.createElement("script");a.src=r,a.onload=()=>n(),a.onerror=()=>i(new Error(`Failed to load ${r}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},bt=s=>new Promise((t,e)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${s}`,r.onload=()=>t(),r.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(r)});function xt(s){let t=null;return async(e,r)=>{try{if(!t){let n=await s();t=n.default||n}if(typeof t=="function")return t(e,r);if(t instanceof HTMLElement){let n=t.cloneNode(!0);return e?.appendChild(n),n}if(typeof t=="object"&&t!==null&&"render"in t&&typeof t.render=="function")return t.render(e,r);console.warn("useTSLazy: Unsupported module type",t)}catch(n){console.error("useTSLazy failed:",n)}}}var At=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var Qt=require("lodash-es"),Dt=s=>s;typeof window<"u"&&typeof document<"u"&&(Dt=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var He=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 r=e.getAttribute("class")||"";e.setAttribute("class",Dt(r));let n=e.getAttribute("aria-label");n&&e.setAttribute("aria-label",Dt(n));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)}})}})},Ne=(0,Qt.debounce)(He,50),Zt=s=>{Ne(s)};var Mt=s=>{if(!s)return;let t=k("a",s);Zt(t)};var Ct=v(require("dompurify"),1);var Jt=require("zustand/vanilla"),te=v(require("dompurify"),1),O=(0,Jt.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:Xt(t)})),setQuery:t=>s(()=>({query:Xt(t)}))}));function Xt(s){let t={};for(let e in s)t[e]=te.default.sanitize(s[e]);return t}var V=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,r=this.parseQueryParams(e),n=this.findMatchingRoute(t,this.routes);if(n){if(n.routeto){this.navigate(n.routeto);return}let i=this.filterAndSanitizeParams(n.params);O.getState().setParams(i),O.getState().setQuery(r);let a=document.createElement("div");if(n.element?.(a,i,r),n.children){let o=t.slice(n.path.length),c=a.querySelector("#child");c&&this.renderChildren(n.children,o,c,i,r)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);O.getState().setParams(a),O.getState().setQuery(r);let o=document.createElement("div");i.element?.(o,a,r)}}}renderChildren(t,e,r,n,i){if(!t||t.length===0){let o=r.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...n,...a.params},l=this.filterAndSanitizeParams(c);if(O.getState().setParams(l),O.getState().setQuery(i),a.element?.(o,l,i),r.appendChild(o),a.children){let u=e.slice(a.path.length);this.renderChildren(a.children,u,o,l,i)}}}parseQueryParams(t){let e={},r=new URLSearchParams(t);for(let[n,i]of r.entries())this.expectedParams.has(n)&&(e[n]=Ct.default.sanitize(i));return e}findMatchingRoute(t,e,r={}){for(let n of e){let i=n.path;if(i==="*")return n;{let o=[],c=i.replace(/:[^\s/]+/g,d=>(o.push(d.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=t.match(l);if(u){let d={...r};if(o.forEach((h,f)=>{d[h]=u[f+1]??""}),n.children){let h=t.slice(u[0].length),f=this.findMatchingRoute(h,n.children,d);if(f)return f}return{...n,params:d}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let r in t)this.expectedParams.has(r)&&(e[r]=Ct.default.sanitize(t[r]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var Le=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await import("path"),e=await Promise.resolve().then(()=>(Re(),ve)),r=t.resolve("src/pages"),n=t.resolve("src/gen"),i=t.resolve("src/routes"),a=t.join(n,"tsrouter.gen.ts"),o=t.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(T){try{await s.mkdir(T,{recursive:!0})}catch{}}function u(T,p){let y="/"+t.relative(p,T).replace(/\\/g,"/");return y=y.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",y.replace(/\[(.+?)\]/g,":$1")}function d(T){return T.replace(/^\//,"").split("/").map(p=>p.startsWith(":")?p.slice(1):p).filter(Boolean).join("-")||"index"}function h(T,p){let _=t.relative(p,T).replace(/\\/g,"/").split("/").filter(Boolean),L=_[_.length-1].replace(".ts",""),D=_.length>1?_[_.length-2]:"";if(L==="index")return D?D.charAt(0).toUpperCase()+D.slice(1):"Index";if(L.startsWith("[")&&L.endsWith("]")){let P=L.slice(1,-1);return D.charAt(0).toUpperCase()+P.charAt(0).toUpperCase()+P.slice(1)}return L.charAt(0).toUpperCase()+L.slice(1)}async function f(T){let p=await s.readdir(T,{withFileTypes:!0}),y=[];for(let _ of p){let L=t.join(T,_.name);if(_.isDirectory())y=y.concat(await f(L));else if(_.isFile()&&_.name.endsWith(".ts")){let D=u(L,r),P=d(D),U=h(L,r);y.push({file:L,route:D,routeName:P,importName:U})}}return y}function g(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
2
2
|
import { useTSParams } from "@devwareng/vanilla-ts";
|
|
3
3
|
|
|
4
4
|
export const Router = async (DOM: HTMLElement) => {
|
|
5
5
|
useTSParams.getState();
|
|
6
|
-
const router = createRouter(DOM);
|
|
7
|
-
(await router).navigate(window.location.pathname);
|
|
6
|
+
const router = await createRouter(DOM);
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// initial navigation
|
|
9
|
+
await router.navigate(window.location.pathname + window.location.search);
|
|
10
|
+
|
|
11
|
+
// back/forward navigation
|
|
12
|
+
window.addEventListener("popstate", () => {
|
|
13
|
+
void router.navigate(window.location.pathname + window.location.search, false);
|
|
11
14
|
});
|
|
12
|
-
};`}function
|
|
13
|
-
path: "${p.route||p.path||"/"}",
|
|
14
|
-
name: "${p.routeName||p.name||"index"}",
|
|
15
|
-
${p.component?`component: ${p.component},`:""}
|
|
16
|
-
${p.children&&p.children.length?`children: ${_(p.children)}`:""}
|
|
17
|
-
}`).join(`,
|
|
18
|
-
`)}]`}async function O(){let g=await f(r),T=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
|
|
19
|
-
import { html, useTSElements, useTSLazy } from "@devwareng/vanilla-ts";
|
|
15
|
+
};`}async function S(){let T=await f(r),p=T.find(P=>P.route==="/notfound"),y=T.filter(P=>P.route!=="/notfound");for(let P of T)if(!(await s.readFile(P.file,"utf-8")).trim()){let q=P.importName;await s.writeFile(P.file,`import { html, useTSElements, useTSMetaData } from "@devwareng/vanilla-ts";
|
|
20
16
|
|
|
21
|
-
export
|
|
17
|
+
export default function ${q}(DOM: HTMLElement) {
|
|
18
|
+
useTSMetaData({
|
|
19
|
+
title: "${q}",
|
|
20
|
+
description: "${q}",
|
|
21
|
+
author: "Your name here",
|
|
22
|
+
favicon: "/favicon.ico",
|
|
23
|
+
});
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
keys.push(key);
|
|
29
|
-
return "([^/]+)";
|
|
30
|
-
}) + "$"
|
|
31
|
-
);
|
|
32
|
-
const pathname = path.split("?")[0];
|
|
33
|
-
const match = pathname?.match(regex);
|
|
25
|
+
const ui = useTSElements(DOM, html\`
|
|
26
|
+
<div>
|
|
27
|
+
<h1>${q}</h1>
|
|
28
|
+
</div>
|
|
29
|
+
\`)
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
return ui;
|
|
32
|
+
}`,"utf-8")}let _=y.map(P=>{let U="../pages/"+t.relative(r,P.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`{
|
|
33
|
+
path: "${P.route}",
|
|
34
|
+
name: "${P.routeName}",
|
|
35
|
+
component: useTSLazy(() => import("${U}"))
|
|
36
|
+
}`}).join(`,
|
|
37
|
+
`),D=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
|
|
38
|
+
import { html, useTSElements, useTSLazy } from "@devwareng/vanilla-ts";
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
40
|
+
${p?`export const NotFound = useTSLazy(() => import("../pages/${t.relative(r,p.file).replace(/\\/g,"/").replace(/\.ts$/,"")}"))`:'export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div class="p-4 animate__animated animate__fadeIn"><h1>404 - Page Not Found</h1></div>`)\n}'}
|
|
41
|
+
|
|
42
|
+
export const routeTree = [
|
|
43
|
+
${_}
|
|
44
|
+
]
|
|
48
45
|
|
|
49
46
|
export async function createRouter(DOM: HTMLElement) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
function matchRoute(path: string) {
|
|
48
|
+
for (const route of routeTree) {
|
|
49
|
+
const keys: string[] = []
|
|
50
|
+
const regex = new RegExp("^" + route.path.replace(/:([^/]+)/g, (_, key) => {
|
|
51
|
+
keys.push(key)
|
|
52
|
+
return "([^/]+)"
|
|
53
|
+
}) + "$")
|
|
54
|
+
const pathname = path.split("?")[0]
|
|
55
|
+
const match = pathname?.match(regex)
|
|
56
|
+
if (match) {
|
|
57
|
+
const params: Record<string, string> = {}
|
|
58
|
+
keys.forEach((key, i) => (params[key] = match[i + 1] || ""))
|
|
59
|
+
return { ...route, params }
|
|
60
|
+
}
|
|
54
61
|
}
|
|
55
|
-
|
|
62
|
+
return null
|
|
56
63
|
}
|
|
57
64
|
|
|
58
|
-
async function navigate(path: string) {
|
|
59
|
-
const match = matchRoute(path)
|
|
65
|
+
async function navigate(path: string, pushState: boolean = true) {
|
|
66
|
+
const match = matchRoute(path)
|
|
60
67
|
if (match) {
|
|
61
|
-
await
|
|
62
|
-
history.pushState({}, "", path)
|
|
68
|
+
await match.component(DOM)
|
|
69
|
+
if (pushState) history.pushState({}, "", path)
|
|
63
70
|
} else {
|
|
64
|
-
DOM
|
|
71
|
+
NotFound(DOM)
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
await navigate(window.location.pathname + window.location.search);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await navigate(window.location.pathname + window.location.search);
|
|
73
|
-
return { navigate, routes: routeTree };
|
|
75
|
+
return { navigate, routes: routeTree }
|
|
74
76
|
}
|
|
75
|
-
`;await l(n),await s.writeFile(a,
|
|
77
|
+
`;await l(n),await s.writeFile(a,D,"utf-8"),await s.writeFile(o,g(),"utf-8")}await l(n),await l(i),await l(r),await S(),c&&(e.watch(r).on("all",async(p,y)=>{y.endsWith(".ts")&&await S()}),e.watch(o).on("unlink",async()=>{await s.writeFile(o,g(),"utf-8")})),console.log("\u{1F7E2} TS Filebased Router Generated with Lazy Routes...")}});0&&(module.exports={TSFilebasedRouter,TSRouter,createEffect,createSignal,html,loadPyFiles,mapper,renderChildRoutes,useAnchorSingle,useInitialDOM,useTSAuth,useTSCollection,useTSComponent,useTSElementEach,useTSElements,useTSEvent,useTSEventAll,useTSExtractParams,useTSLazy,useTSMetaData,useTSNavigate,useTSNoReload,useTSOutlet,useTSParams,useTSPurifier,useTSSSRHydration,useTSSelect,useTSloadBrython});
|
|
76
78
|
/*! Bundled license information:
|
|
77
79
|
|
|
78
80
|
chokidar/esm/index.js:
|
package/dist/index.js
CHANGED
|
@@ -1,75 +1,77 @@
|
|
|
1
|
-
function pe(n){let e=n==null?"":String(n),t=e.toLowerCase();return(t.includes("<script")||t.includes("javascript:"))&&(e=""),e=e.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),e.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function F(n,...e){return n.reduce((t,r,o)=>{let i=o<e.length?pe(e[o]):"";return t+r+i},"")}var fe=n=>n.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),he=n=>n?.map(e=>fe(e)).join("")??"";import z from"dompurify";var I=(n,e)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof n=="string"?z.sanitize(n,r):z.sanitize(n.innerHTML,r)};var _=(n,e,t)=>{if(typeof n=="string"){let r=document.getElementById(n);r?r.addEventListener(e,t):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(e,t):n===document?document.addEventListener(e,t):console.warn("Invalid target parameter provided.")};import{createStore as ge}from"zustand/vanilla";import q from"dompurify";function Te(n,e){let t=[],r=n.replace(/:[^/]+/g,s=>(t.push(s.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),i=e.match(o),a={};return i&&t.forEach((s,c)=>{a[s]=q.sanitize(i[c+1]??"")}),a}function ye(n){let e={},t=new URLSearchParams(n);for(let[r,o]of t.entries())e[r]=q.sanitize(o);return e}var C=ge((n,e)=>({params:{},query:{},setFromPattern:t=>{let r=window.location.pathname,o=Te(t,r),i=ye(window.location.search);n({params:o,query:i})},getParam:t=>e().params[t],getQuery:t=>e().query[t]}));function j(n){let e=C.getState();e.setFromPattern(n);let t=e.params,r=e.query;return{...t,...r}}var U=(n,e,t)=>{let r=document.querySelectorAll(n);return r.forEach(o=>{o.addEventListener(e,t)}),()=>{r.forEach(o=>{o.removeEventListener(e,t)})}};import B from"dompurify";var W=(n,e,t={},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","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...r};B.addHook("uponSanitizeAttribute",(s,c)=>{let l=(c.attrName||"").toLowerCase(),m=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(s.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(m)||/^\/(?!\/)/.test(m)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(m)||(c.keepAttr=!1);return}if(l==="class"){let g=m.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let E=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return E===""||/^https?:\/\//i.test(E)||/^\/(?!\/)/.test(E)||/^\.{0,2}\//.test(E)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=g.join(" ");return}});let i=B.sanitize(e,{...o,RETURN_DOM_FRAGMENT:!0});for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(i);let a=(s,c)=>{n.querySelectorAll(`[${s}]`).forEach(l=>{let m=l.getAttribute(s);m&&Object.prototype.hasOwnProperty.call(t,m)&&l.addEventListener(c,p=>{c==="submit"&&p.preventDefault(),t[m](p)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),n.querySelectorAll("[data-key]").forEach(s=>{let c=s.dataset.key,l=s.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(t,c)&&s.addEventListener(l,t[c])}),n.querySelectorAll("[data-hover]").forEach(s=>{let c=s.dataset.hover;c&&Object.prototype.hasOwnProperty.call(t,c)&&(s.addEventListener("mouseenter",t[c]),s.addEventListener("mouseleave",t[c]))}),n.querySelectorAll("[data-classlist]").forEach(s=>{let c=s.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&s.classList.add(...c.split(/\s+/))})};import G from"dompurify";var D=null,V=(n,e)=>{if(typeof document>"u")return;let t=document.getElementById(n);if(!t)return;G.addHook("uponSanitizeAttribute",(a,s)=>{let c=(s.attrName||"").toLowerCase(),l=(s.attrValue??"").toString().trim();if(c.startsWith("on")){s.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){s.keepAttr=!1;return}if(c==="class"){let p=l.split(/\s+/).filter(Boolean).filter(g=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(g)){if(/^bg-\[url\(.*\)\]$/.test(g)){let f=g.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return f===""||/^https?:\/\//i.test(f)||/^\/(?!\/)/.test(f)||/^\.{0,2}\//.test(f)}return!0}return!1});s.attrValue=p.join(" ");return}if(c==="style"){s.keepAttr=!1;return}});let r=t.cloneNode(!0),o=G.sanitize(r.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(o.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(D!==null&&i!==D){let a=document.createElement("div");e(a);let c=new DOMParser().parseFromString(D,"text/html");for(;t.firstChild;)t.removeChild(t.firstChild);c.body.childNodes.forEach(l=>t.appendChild(l.cloneNode(!0)))}else{for(D=i;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(o),e(t)}};import Q from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let e=n.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var K=(n,e,t,r="",o=null)=>{if(!n)return;let i=Q.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Q.sanitize(t,{USE_PROFILES:{html:!1}});n.setAttribute("href",i),n.setAttribute("aria-label",a),r&&(n.className=r.trim()),o&&n.replaceChildren(o),typeof window<"u"&&n.addEventListener("click",s=>{s.preventDefault();let l=s.currentTarget.getAttribute("href");if(l){let m=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:m},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import L from"dompurify";var Z=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",t="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'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",s="'self'",c="/csp-report",l=!1)=>{let m=()=>{try{let p=document.querySelector('meta[http-equiv="Content-Security-Policy"]');p||(p=document.createElement("meta"),p.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(p));let g=l?`report-uri ${c};`:"";p.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${e}; object-src ${t}; font-src ${r}; img-src ${o}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${s}; ${g}`)}catch(p){console.error("Error adding CSP meta element:",p)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",m):m()};var X=(n,e)=>{let t={name:L.sanitize(n.name||""),title:L.sanitize(n.title||""),description:L.sanitize(n.description||"Default description"),author:L.sanitize(n.author||""),favicon:n.favicon},r=d=>{t.name=L.sanitize(d),y("name",t.name)},o=d=>{t.title=L.sanitize(d),document.title=t.title},i=d=>{t.description=L.sanitize(d),y("description",t.description)},a=d=>{t.author=L.sanitize(d),y("author",t.author)},s=d=>{t.favicon=L.sanitize(d);let u=document.querySelector('link[rel="icon"]');u||(u=document.createElement("link"),u.rel="icon",document.head.appendChild(u)),u.href=t.favicon},c=()=>t.name,l=()=>t.title,m=()=>t.description,p=()=>t.author,g=()=>t.favicon,f=()=>t,E=(d,u)=>{let h=document.createElement("meta");h.setAttribute("name",d),h.setAttribute("content",u),document.head.appendChild(h)},y=(d,u)=>{let h=document.querySelector(`meta[name="${d}"]`);h?h.setAttribute("content",u):E(d,u)},R=()=>{t.title&&(document.title=t.title),t.name&&y("name",t.name),t.description&&y("description",t.description),t.author&&y("author",t.author),t.favicon&&s(t.favicon)};return e&&Z(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),R(),{setName:r,setTitle:o,setDescription:i,setAuthor:a,setFavicon:s,getName:c,getTitle:l,getDescription:m,getAuthor:p,getFavicon:g,getAllMetaData:f,appendMetaTagsToHead:R}};import Se from"dompurify";var O=(n,e,t,r,o)=>{let i=`#${n}`,a=e.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${n}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${n}' detected. Found ${a.length} elements.`);let s=a[0];s.innerHTML=Se.sanitize(s.innerHTML,{USE_PROFILES:{html:!0}}),t(s,r,o)};var Y=(n,e,t,r=[])=>{let o=new Set;n.forEach((i,a)=>{if(o.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}o.add(i);let s=e.querySelectorAll(`#${i}`);if(s.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${s.length} elements found) \u2014 skipping component mount.`);return}let c=t[a],l=Array.isArray(r)?r[a]:void 0;typeof c=="function"?O(i,e,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var P=(n,e)=>{let r=(e??document).querySelectorAll(n);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${n}'`),null;if(n.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${n}'. 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: '${n}'. Returning the first one.`),r[0]};import{jwtDecode as Ee}from"jwt-decode";var J=(n,e)=>{let t=localStorage.getItem("token");if(!t)return window.location.href=e,null;try{let r=Ee(t),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 k=(n,e,t)=>{n.forEach(r=>{e.forEach(o=>{r.addEventListener(o,i=>{t(r,i)})})})};var ee=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var te=(n,e)=>{let t=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!t)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of e){let i=o.path.replace(/\/$/,"");if(r===i||r.startsWith(`${i}/`)){o.component(t);break}}};function ne(n,e){let t=window.location.pathname.replace(/\/$/,"");e.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let i=o.path.replace(/\/$/,"");if(t===i||t.startsWith(`${i}/`)){let a=n.querySelector(`#${o.outlet}`)||n.querySelector(`.${o.outlet}`);a instanceof HTMLElement&&o.element&&o.element(a)}})})}import{createStore as ve}from"zustand/vanilla";function re(n){let e=ve(()=>({value:n})),t=new Set;return{get:()=>e.getState().value,set:r=>{e.setState({value:r}),t.forEach(o=>o(r))},subscribe:r=>(t.add(r),r(e.getState().value),()=>t.delete(r))}}function oe(n){let e=n();typeof e=="function"&&e()}var se=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",t=r=>new Promise((o,i)=>{let a=document.createElement("script");a.src=r,a.onload=()=>o(),a.onerror=()=>i(new Error(`Failed to load ${r}`)),document.head.appendChild(a)});await t(n),await t(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},ie=n=>new Promise((e,t)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${n}`,r.onload=()=>e(),r.onerror=()=>t(new Error(`Failed to load ${n}`)),document.body.appendChild(r)});function ae(n){let e=null;return async(t,r)=>{try{if(!e){let o=await n();e=o.default||o}if(typeof e=="function")return e(t,r);if(e instanceof HTMLElement){let o=e.cloneNode(!0);return t?.appendChild(o),o}if(typeof e=="object"&&e!==null&&"render"in e&&typeof e.render=="function")return e.render(t,r);console.warn("useTSLazy: Unsupported module type",e)}catch(o){console.error("useTSLazy failed:",o)}}}var ce=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};import{debounce as we}from"lodash-es";var $=n=>n;typeof window<"u"&&typeof document<"u"&&($=n=>{let e=document.createElement("div");return e.innerText=n,e.innerHTML});var Le=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(t=>{if(!t||t.dataset.anchorEnhanced==="true")return;t.dataset.anchorEnhanced="true";let r=t.getAttribute("class")||"";t.setAttribute("class",$(r));let o=t.getAttribute("aria-label");o&&t.setAttribute("aria-label",$(o));let i=t.querySelector(":scope > *");i&&(t.innerHTML="",t.appendChild(i));let a=t.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}t.addEventListener("click",s=>{s.preventDefault();let c=t.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),le=n=>{Me(n)};var ue=n=>{if(!n)return;let e=P("a",n);le(e)};import me from"dompurify";import{createStore as Re}from"zustand/vanilla";import Ae from"dompurify";var M=Re(n=>({params:{},query:{},setParams:e=>n(()=>({params:de(e)})),setQuery:e=>n(()=>({query:de(e)}))}));function de(n){let e={};for(let t in n)e[t]=Ae.sanitize(n[t]);return e}var N=class{constructor(e,t){this.routes=[];this.routes=e,this.expectedParams=new Set(t),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,t=window.location.search,r=this.parseQueryParams(t),o=this.findMatchingRoute(e,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let i=this.filterAndSanitizeParams(o.params);M.getState().setParams(i),M.getState().setQuery(r);let a=document.createElement("div");if(o.element?.(a,i,r),o.children){let s=e.slice(o.path.length),c=a.querySelector("#child");c&&this.renderChildren(o.children,s,c,i,r)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);M.getState().setParams(a),M.getState().setQuery(r);let s=document.createElement("div");i.element?.(s,a,r)}}}renderChildren(e,t,r,o,i){if(!e||e.length===0){let s=r.querySelector("#child");s&&s.remove();return}let a=this.findMatchingRoute(t,e);if(a){let s=document.createElement("div");s.id="child";let c={...o,...a.params},l=this.filterAndSanitizeParams(c);if(M.getState().setParams(l),M.getState().setQuery(i),a.element?.(s,l,i),r.appendChild(s),a.children){let m=t.slice(a.path.length);this.renderChildren(a.children,m,s,l,i)}}}parseQueryParams(e){let t={},r=new URLSearchParams(e);for(let[o,i]of r.entries())this.expectedParams.has(o)&&(t[o]=me.sanitize(i));return t}findMatchingRoute(e,t,r={}){for(let o of t){let i=o.path;if(i==="*")return o;{let s=[],c=i.replace(/:[^\s/]+/g,p=>(s.push(p.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),m=e.match(l);if(m){let p={...r};if(s.forEach((g,f)=>{p[g]=m[f+1]??""}),o.children){let g=e.slice(m[0].length),f=this.findMatchingRoute(g,o.children,p);if(f)return f}return{...o,params:p}}}}}filterAndSanitizeParams(e){if(!e)return{};let t={};for(let r in e)this.expectedParams.has(r)&&(t[r]=me.sanitize(e[r]??""));return t}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Pe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let n=await import("fs/promises"),e=await import("path"),t=await import("./esm-KRNKVVL7.js"),r=e.resolve("src/pages"),o=e.resolve("src/gen"),i=e.resolve("src/routes"),a=e.join(o,"tsrouter.gen.ts"),s=e.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(d){try{await n.mkdir(d,{recursive:!0})}catch{}}function m(d,u){let h="/"+e.relative(u,d).replace(/\\/g,"/");return h=h.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",h.replace(/\[(.+?)\]/g,":$1")}function p(d){return d.replace(/^\//,"").split("/").map(u=>u.startsWith(":")?u.slice(1):u).filter(Boolean).join("-")||"index"}function g(d,u){let v=e.relative(u,d).replace(/\\/g,"/").split("/").filter(Boolean),T=v[v.length-1].replace(".ts",""),S=v.length>1?v[v.length-2]:"";if(T==="index")return S?S.charAt(0).toUpperCase()+S.slice(1):"Index";if(T.startsWith("[")&&T.endsWith("]")){let w=T.slice(1,-1);return S.charAt(0).toUpperCase()+w.charAt(0).toUpperCase()+w.slice(1)}return T.charAt(0).toUpperCase()+T.slice(1)}async function f(d,u=""){let h=await n.readdir(d,{withFileTypes:!0}),v=[];for(let T of h){let S=e.join(d,T.name);if(T.isDirectory()){let w=T.name,b=await f(S,e.join(u,w)),x=b.find(A=>A.isIndex),H={path:"/"+e.join(u,w).replace(/\\/g,"/"),name:(u?u.replace(/\\/g,"-")+"-":"")+w,component:x?x.component:void 0,children:b.filter(A=>!A.isIndex)};v.push(H)}else if(T.isFile()&&T.name.endsWith(".ts")){let w=m(S,r),b=p(w),x=g(S,r),H="../pages/"+e.relative(r,S).replace(/\\/g,"/").replace(/\.ts$/,""),A=T.name==="index.ts";v.push({file:S,route:w,routeName:b,importName:x,component:`useTSLazy(() => import("${H}"))`,isIndex:A})}}return v}function E(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
1
|
+
function ue(n){let e=n==null?"":String(n),t=e.toLowerCase();return(t.includes("<script")||t.includes("javascript:"))&&(e=""),e=e.replace(/url\(\s*(['"])?\s*\1?\s*\)/gi,""),e.replace(/<\s*(script|iframe|object|embed|link|style|meta|body)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style|meta)[^>]*>/gi,"").replace(/\s+on\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s+on\w+\s*=\s*[^\s>]+/gi,"").replace(/\s(href|src)\s*=\s*(['"]?)\s*(javascript:|vbscript:|data:|file:)[^'">\s]*\2/gi,'$1="#"')}function k(n,...e){return n.reduce((t,r,o)=>{let i=o<e.length?ue(e[o]):"";return t+r+i},"")}var de=n=>n.replace(/<\/?(script|iframe|object|embed|link|meta|style|form|textarea|svg|math|body)[^>]*>/gi,"").replace(/<(?!\/?(b|i|em|strong|p|br|ul|ol|li|a|div|span|h1|h2|h3|h4|h5|h6|section|article|input|button)\b)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s*style\s*=\s*("[^"]*"|'[^']*')/gi,"").replace(/<a\b([^>]*)href\s*=\s*(['"]?)(?!https?:|#)[^'"\s>]+(['"]?)([^>]*)>/gi,"<a$1$4>").replace(/\s+(href|src)\s*=\s*(['"]?)\s*(javascript:|data:)[^'"\s>]*/gi,"").replace(/<a\b([^>]*)\bhref\s*=\s*(['"])(\/blog|#blog)\2([^>]*)>/gi,'<a$1 href=$2$3$2 href-line="true"$4>').trim(),me=n=>n?.map(e=>de(e)).join("")??"";import $ from"dompurify";var N=(n,e)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof n=="string"?$.sanitize(n,r):$.sanitize(n.innerHTML,r)};var F=(n,e,t)=>{if(typeof n=="string"){let r=document.getElementById(n);r?r.addEventListener(e,t):console.warn(`Element with id '${n}' not found.`)}else n instanceof HTMLElement?n.addEventListener(e,t):n===document?document.addEventListener(e,t):console.warn("Invalid target parameter provided.")};import{createStore as pe}from"zustand/vanilla";import z from"dompurify";function fe(n,e){let t=[],r=n.replace(/:[^/]+/g,s=>(t.push(s.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),i=e.match(o),a={};return i&&t.forEach((s,c)=>{a[s]=z.sanitize(i[c+1]??"")}),a}function he(n){let e={},t=new URLSearchParams(n);for(let[r,o]of t.entries())e[r]=z.sanitize(o);return e}var P=pe((n,e)=>({params:{},query:{},setFromPattern:t=>{let r=window.location.pathname,o=fe(t,r),i=he(window.location.search);n({params:o,query:i})},getParam:t=>e().params[t],getQuery:t=>e().query[t]}));function _(n){let e=P.getState();e.setFromPattern(n);let t=e.params,r=e.query;return{...t,...r}}var I=(n,e,t)=>{let r=document.querySelectorAll(n);return r.forEach(o=>{o.addEventListener(e,t)}),()=>{r.forEach(o=>{o.removeEventListener(e,t)})}};import q from"dompurify";var U=(n,e,t={},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","label","form"],ALLOWED_ATTR:["class","id","href","src","alt","title","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","type","name","value","placeholder","data-click","data-change","data-select","data-classlist","data-hover","data-submit","data-key","data-event"],FORBID_TAGS:["script","iframe","foreignObject","body","html"],FORBID_ATTR:["style","xlink:href"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...r};q.addHook("uponSanitizeAttribute",(s,c)=>{let l=(c.attrName||"").toLowerCase(),d=(c.attrValue??"").toString().trim();if(l.startsWith("on")){c.keepAttr=!1;return}if(/^data-(click|change|submit|select|hover|classlist|key|event)$/.test(l)){c.keepAttr=!0;return}if(s.nodeName.toLowerCase()==="img"&&l==="src"){/^https?:\/\//i.test(d)||/^\/(?!\/)/.test(d)||/^data:image\/(png|jpeg|jpg|gif|webp);base64,/i.test(d)||(c.keepAttr=!1);return}if(l==="class"){let y=d.split(/\s+/).filter(Boolean).filter(f=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]*$/.test(f)){if(/^bg-\[url\(.*\)\]$/.test(f)){let v=f.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return v===""||/^https?:\/\//i.test(v)||/^\/(?!\/)/.test(v)||/^\.{0,2}\//.test(v)}return/^bg-\[\]$/.test(f),!0}return!1});c.attrValue=y.join(" ");return}});let i=q.sanitize(e,{...o,RETURN_DOM_FRAGMENT:!0});for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(i);let a=(s,c)=>{n.querySelectorAll(`[${s}]`).forEach(l=>{let d=l.getAttribute(s);d&&Object.prototype.hasOwnProperty.call(t,d)&&l.addEventListener(c,m=>{c==="submit"&&m.preventDefault(),t[d](m)})})};a("data-click","click"),a("data-change","change"),a("data-select","select"),a("data-submit","submit"),n.querySelectorAll("[data-key]").forEach(s=>{let c=s.dataset.key,l=s.dataset.event??"click";c&&Object.prototype.hasOwnProperty.call(t,c)&&s.addEventListener(l,t[c])}),n.querySelectorAll("[data-hover]").forEach(s=>{let c=s.dataset.hover;c&&Object.prototype.hasOwnProperty.call(t,c)&&(s.addEventListener("mouseenter",t[c]),s.addEventListener("mouseleave",t[c]))}),n.querySelectorAll("[data-classlist]").forEach(s=>{let c=s.dataset.classlist;/^[a-zA-Z0-9\-\s:_]+$/.test(c)&&s.classList.add(...c.split(/\s+/))})};import j from"dompurify";var x=null,B=(n,e)=>{if(typeof document>"u")return;let t=document.getElementById(n);if(!t)return;j.addHook("uponSanitizeAttribute",(a,s)=>{let c=(s.attrName||"").toLowerCase(),l=(s.attrValue??"").toString().trim();if(c.startsWith("on")){s.keepAttr=!1;return}if((c==="href"||c==="src")&&/^(javascript:|vbscript:|data:|file:|about:)/i.test(l)){s.keepAttr=!1;return}if(c==="class"){let m=l.split(/\s+/).filter(Boolean).filter(y=>{if(/^[a-zA-Z0-9\-\:\/_\[\]\(\)]+$/.test(y)){if(/^bg-\[url\(.*\)\]$/.test(y)){let f=y.replace(/^bg-\[url\(/,"").replace(/\)\]$/,"").replace(/^['"]|['"]$/g,"");return f===""||/^https?:\/\//i.test(f)||/^\/(?!\/)/.test(f)||/^\.{0,2}\//.test(f)}return!0}return!1});s.attrValue=m.join(" ");return}if(c==="style"){s.keepAttr=!1;return}});let r=t.cloneNode(!0),o=j.sanitize(r.innerHTML,{USE_PROFILES:{html:!0},ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br","form","button","input","label"],ALLOWED_ATTR:["href","src","alt","title","class","id","type","name","value","placeholder","data-click","data-change","data-submit","data-select","data-hover","data-classlist"],FORBID_TAGS:["script","iframe","object","embed","body","html","svg","math","link","meta"],ALLOW_DATA_ATTR:!0,KEEP_CONTENT:!1,RETURN_DOM_FRAGMENT:!0}),i=Array.from(o.childNodes).map(a=>a.outerHTML||a.textContent||"").join("");if(x!==null&&i!==x){let a=document.createElement("div");e(a);let c=new DOMParser().parseFromString(x,"text/html");for(;t.firstChild;)t.removeChild(t.firstChild);c.body.childNodes.forEach(l=>t.appendChild(l.cloneNode(!0)))}else{for(x=i;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(o),e(t)}};import W from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",n=>{let e=n.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var G=(n,e,t,r="",o=null)=>{if(!n)return;let i=W.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=W.sanitize(t,{USE_PROFILES:{html:!1}});n.setAttribute("href",i),n.setAttribute("aria-label",a),r&&(n.className=r.trim()),o&&n.replaceChildren(o),typeof window<"u"&&n.addEventListener("click",s=>{s.preventDefault();let l=s.currentTarget.getAttribute("href");if(l){let d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import L from"dompurify";var V=(n="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",t="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'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",s="'self'",c="/csp-report",l=!1)=>{let d=()=>{try{let m=document.querySelector('meta[http-equiv="Content-Security-Policy"]');m||(m=document.createElement("meta"),m.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(m));let y=l?`report-uri ${c};`:"";m.setAttribute("content",`default-src 'self'; script-src ${n}; style-src ${e}; object-src ${t}; font-src ${r}; img-src ${o}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${s}; ${y}`)}catch(m){console.error("Error adding CSP meta element:",m)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var Q=(n,e)=>{let t={name:L.sanitize(n.name||""),title:L.sanitize(n.title||""),description:L.sanitize(n.description||"Default description"),author:L.sanitize(n.author||""),favicon:n.favicon},r=u=>{t.name=L.sanitize(u),E("name",t.name)},o=u=>{t.title=L.sanitize(u),document.title=t.title},i=u=>{t.description=L.sanitize(u),E("description",t.description)},a=u=>{t.author=L.sanitize(u),E("author",t.author)},s=u=>{t.favicon=L.sanitize(u);let p=document.querySelector('link[rel="icon"]');p||(p=document.createElement("link"),p.rel="icon",document.head.appendChild(p)),p.href=t.favicon},c=()=>t.name,l=()=>t.title,d=()=>t.description,m=()=>t.author,y=()=>t.favicon,f=()=>t,v=(u,p)=>{let h=document.createElement("meta");h.setAttribute("name",u),h.setAttribute("content",p),document.head.appendChild(h)},E=(u,p)=>{let h=document.querySelector(`meta[name="${u}"]`);h?h.setAttribute("content",p):v(u,p)},g=()=>{t.title&&(document.title=t.title),t.name&&E("name",t.name),t.description&&E("description",t.description),t.author&&E("author",t.author),t.favicon&&s(t.favicon)};return e&&V(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),g(),{setName:r,setTitle:o,setDescription:i,setAuthor:a,setFavicon:s,getName:c,getTitle:l,getDescription:d,getAuthor:m,getFavicon:y,getAllMetaData:f,appendMetaTagsToHead:g}};import ge from"dompurify";var C=(n,e,t,r,o)=>{let i=`#${n}`,a=e.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${n}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${n}' detected. Found ${a.length} elements.`);let s=a[0];s.innerHTML=ge.sanitize(s.innerHTML,{USE_PROFILES:{html:!0}}),t(s,r,o)};var K=(n,e,t,r=[])=>{let o=new Set;n.forEach((i,a)=>{if(o.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}o.add(i);let s=e.querySelectorAll(`#${i}`);if(s.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${s.length} elements found) \u2014 skipping component mount.`);return}let c=t[a],l=Array.isArray(r)?r[a]:void 0;typeof c=="function"?C(i,e,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var R=(n,e)=>{let r=(e??document).querySelectorAll(n);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${n}'`),null;if(n.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${n}'. 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: '${n}'. Returning the first one.`),r[0]};import{jwtDecode as Te}from"jwt-decode";var Y=(n,e)=>{let t=localStorage.getItem("token");if(!t)return window.location.href=e,null;try{let r=Te(t),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 D=(n,e,t)=>{n.forEach(r=>{e.forEach(o=>{r.addEventListener(o,i=>{t(r,i)})})})};var Z=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var X=(n,e)=>{let t=document.querySelector(`#${n}`)||document.querySelector(`.${n}`);if(!t)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of e){let i=o.path.replace(/\/$/,"");if(r===i||r.startsWith(`${i}/`)){o.component(t);break}}};function J(n,e){let t=window.location.pathname.replace(/\/$/,"");e.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let i=o.path.replace(/\/$/,"");if(t===i||t.startsWith(`${i}/`)){let a=n.querySelector(`#${o.outlet}`)||n.querySelector(`.${o.outlet}`);a instanceof HTMLElement&&o.element&&o.element(a)}})})}import{createStore as ye}from"zustand/vanilla";function ee(n){let e=ye(()=>({value:n})),t=new Set;return{get:()=>e.getState().value,set:r=>{e.setState({value:r}),t.forEach(o=>o(r))},subscribe:r=>(t.add(r),r(e.getState().value),()=>t.delete(r))}}function te(n){let e=n();typeof e=="function"&&e()}var ne=async()=>{let n="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",t=r=>new Promise((o,i)=>{let a=document.createElement("script");a.src=r,a.onload=()=>o(),a.onerror=()=>i(new Error(`Failed to load ${r}`)),document.head.appendChild(a)});await t(n),await t(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},re=n=>new Promise((e,t)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${n}`,r.onload=()=>e(),r.onerror=()=>t(new Error(`Failed to load ${n}`)),document.body.appendChild(r)});function oe(n){let e=null;return async(t,r)=>{try{if(!e){let o=await n();e=o.default||o}if(typeof e=="function")return e(t,r);if(e instanceof HTMLElement){let o=e.cloneNode(!0);return t?.appendChild(o),o}if(typeof e=="object"&&e!==null&&"render"in e&&typeof e.render=="function")return e.render(t,r);console.warn("useTSLazy: Unsupported module type",e)}catch(o){console.error("useTSLazy failed:",o)}}}var se=n=>typeof window>"u"?{isDOM:null}:{isDOM:n||document.body};import{debounce as Se}from"lodash-es";var H=n=>n;typeof window<"u"&&typeof document<"u"&&(H=n=>{let e=document.createElement("div");return e.innerText=n,e.innerHTML});var Ee=n=>{(n?Array.isArray(n)?n:n instanceof HTMLAnchorElement?[n]:Array.from(n):Array.from(document.querySelectorAll("a"))).forEach(t=>{if(!t||t.dataset.anchorEnhanced==="true")return;t.dataset.anchorEnhanced="true";let r=t.getAttribute("class")||"";t.setAttribute("class",H(r));let o=t.getAttribute("aria-label");o&&t.setAttribute("aria-label",H(o));let i=t.querySelector(":scope > *");i&&(t.innerHTML="",t.appendChild(i));let a=t.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}t.addEventListener("click",s=>{s.preventDefault();let c=t.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)}})}})},ve=Se(Ee,50),ie=n=>{ve(n)};var ae=n=>{if(!n)return;let e=R("a",n);ie(e)};import le from"dompurify";import{createStore as we}from"zustand/vanilla";import Le from"dompurify";var M=we(n=>({params:{},query:{},setParams:e=>n(()=>({params:ce(e)})),setQuery:e=>n(()=>({query:ce(e)}))}));function ce(n){let e={};for(let t in n)e[t]=Le.sanitize(n[t]);return e}var O=class{constructor(e,t){this.routes=[];this.routes=e,this.expectedParams=new Set(t),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,t=window.location.search,r=this.parseQueryParams(t),o=this.findMatchingRoute(e,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let i=this.filterAndSanitizeParams(o.params);M.getState().setParams(i),M.getState().setQuery(r);let a=document.createElement("div");if(o.element?.(a,i,r),o.children){let s=e.slice(o.path.length),c=a.querySelector("#child");c&&this.renderChildren(o.children,s,c,i,r)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);M.getState().setParams(a),M.getState().setQuery(r);let s=document.createElement("div");i.element?.(s,a,r)}}}renderChildren(e,t,r,o,i){if(!e||e.length===0){let s=r.querySelector("#child");s&&s.remove();return}let a=this.findMatchingRoute(t,e);if(a){let s=document.createElement("div");s.id="child";let c={...o,...a.params},l=this.filterAndSanitizeParams(c);if(M.getState().setParams(l),M.getState().setQuery(i),a.element?.(s,l,i),r.appendChild(s),a.children){let d=t.slice(a.path.length);this.renderChildren(a.children,d,s,l,i)}}}parseQueryParams(e){let t={},r=new URLSearchParams(e);for(let[o,i]of r.entries())this.expectedParams.has(o)&&(t[o]=le.sanitize(i));return t}findMatchingRoute(e,t,r={}){for(let o of t){let i=o.path;if(i==="*")return o;{let s=[],c=i.replace(/:[^\s/]+/g,m=>(s.push(m.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=e.match(l);if(d){let m={...r};if(s.forEach((y,f)=>{m[y]=d[f+1]??""}),o.children){let y=e.slice(d[0].length),f=this.findMatchingRoute(y,o.children,m);if(f)return f}return{...o,params:m}}}}}filterAndSanitizeParams(e){if(!e)return{};let t={};for(let r in e)this.expectedParams.has(r)&&(t[r]=le.sanitize(e[r]??""));return t}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Me=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let n=await import("fs/promises"),e=await import("path"),t=await import("./esm-KRNKVVL7.js"),r=e.resolve("src/pages"),o=e.resolve("src/gen"),i=e.resolve("src/routes"),a=e.join(o,"tsrouter.gen.ts"),s=e.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(g){try{await n.mkdir(g,{recursive:!0})}catch{}}function d(g,u){let p="/"+e.relative(u,g).replace(/\\/g,"/");return p=p.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",p.replace(/\[(.+?)\]/g,":$1")}function m(g){return g.replace(/^\//,"").split("/").map(u=>u.startsWith(":")?u.slice(1):u).filter(Boolean).join("-")||"index"}function y(g,u){let h=e.relative(u,g).replace(/\\/g,"/").split("/").filter(Boolean),S=h[h.length-1].replace(".ts",""),w=h.length>1?h[h.length-2]:"";if(S==="index")return w?w.charAt(0).toUpperCase()+w.slice(1):"Index";if(S.startsWith("[")&&S.endsWith("]")){let T=S.slice(1,-1);return w.charAt(0).toUpperCase()+T.charAt(0).toUpperCase()+T.slice(1)}return S.charAt(0).toUpperCase()+S.slice(1)}async function f(g){let u=await n.readdir(g,{withFileTypes:!0}),p=[];for(let h of u){let S=e.join(g,h.name);if(h.isDirectory())p=p.concat(await f(S));else if(h.isFile()&&h.name.endsWith(".ts")){let w=d(S,r),T=m(w),b=y(S,r);p.push({file:S,route:w,routeName:T,importName:b})}}return p}function v(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
2
2
|
import { useTSParams } from "@devwareng/vanilla-ts";
|
|
3
3
|
|
|
4
4
|
export const Router = async (DOM: HTMLElement) => {
|
|
5
5
|
useTSParams.getState();
|
|
6
|
-
const router = createRouter(DOM);
|
|
7
|
-
(await router).navigate(window.location.pathname);
|
|
6
|
+
const router = await createRouter(DOM);
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
// initial navigation
|
|
9
|
+
await router.navigate(window.location.pathname + window.location.search);
|
|
10
|
+
|
|
11
|
+
// back/forward navigation
|
|
12
|
+
window.addEventListener("popstate", () => {
|
|
13
|
+
void router.navigate(window.location.pathname + window.location.search, false);
|
|
11
14
|
});
|
|
12
|
-
};`}function
|
|
13
|
-
path: "${u.route||u.path||"/"}",
|
|
14
|
-
name: "${u.routeName||u.name||"index"}",
|
|
15
|
-
${u.component?`component: ${u.component},`:""}
|
|
16
|
-
${u.children&&u.children.length?`children: ${y(u.children)}`:""}
|
|
17
|
-
}`).join(`,
|
|
18
|
-
`)}]`}async function R(){let d=await f(r),h=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
|
|
19
|
-
import { html, useTSElements, useTSLazy } from "@devwareng/vanilla-ts";
|
|
15
|
+
};`}async function E(){let g=await f(r),u=g.find(T=>T.route==="/notfound"),p=g.filter(T=>T.route!=="/notfound");for(let T of g)if(!(await n.readFile(T.file,"utf-8")).trim()){let A=T.importName;await n.writeFile(T.file,`import { html, useTSElements, useTSMetaData } from "@devwareng/vanilla-ts";
|
|
20
16
|
|
|
21
|
-
export
|
|
17
|
+
export default function ${A}(DOM: HTMLElement) {
|
|
18
|
+
useTSMetaData({
|
|
19
|
+
title: "${A}",
|
|
20
|
+
description: "${A}",
|
|
21
|
+
author: "Your name here",
|
|
22
|
+
favicon: "/favicon.ico",
|
|
23
|
+
});
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
keys.push(key);
|
|
29
|
-
return "([^/]+)";
|
|
30
|
-
}) + "$"
|
|
31
|
-
);
|
|
32
|
-
const pathname = path.split("?")[0];
|
|
33
|
-
const match = pathname?.match(regex);
|
|
25
|
+
const ui = useTSElements(DOM, html\`
|
|
26
|
+
<div>
|
|
27
|
+
<h1>${A}</h1>
|
|
28
|
+
</div>
|
|
29
|
+
\`)
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
return ui;
|
|
32
|
+
}`,"utf-8")}let h=p.map(T=>{let b="../pages/"+e.relative(r,T.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`{
|
|
33
|
+
path: "${T.route}",
|
|
34
|
+
name: "${T.routeName}",
|
|
35
|
+
component: useTSLazy(() => import("${b}"))
|
|
36
|
+
}`}).join(`,
|
|
37
|
+
`),w=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
|
|
38
|
+
import { html, useTSElements, useTSLazy } from "@devwareng/vanilla-ts";
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
40
|
+
${u?`export const NotFound = useTSLazy(() => import("../pages/${e.relative(r,u.file).replace(/\\/g,"/").replace(/\.ts$/,"")}"))`:'export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div class="p-4 animate__animated animate__fadeIn"><h1>404 - Page Not Found</h1></div>`)\n}'}
|
|
41
|
+
|
|
42
|
+
export const routeTree = [
|
|
43
|
+
${h}
|
|
44
|
+
]
|
|
48
45
|
|
|
49
46
|
export async function createRouter(DOM: HTMLElement) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
function matchRoute(path: string) {
|
|
48
|
+
for (const route of routeTree) {
|
|
49
|
+
const keys: string[] = []
|
|
50
|
+
const regex = new RegExp("^" + route.path.replace(/:([^/]+)/g, (_, key) => {
|
|
51
|
+
keys.push(key)
|
|
52
|
+
return "([^/]+)"
|
|
53
|
+
}) + "$")
|
|
54
|
+
const pathname = path.split("?")[0]
|
|
55
|
+
const match = pathname?.match(regex)
|
|
56
|
+
if (match) {
|
|
57
|
+
const params: Record<string, string> = {}
|
|
58
|
+
keys.forEach((key, i) => (params[key] = match[i + 1] || ""))
|
|
59
|
+
return { ...route, params }
|
|
60
|
+
}
|
|
54
61
|
}
|
|
55
|
-
|
|
62
|
+
return null
|
|
56
63
|
}
|
|
57
64
|
|
|
58
|
-
async function navigate(path: string) {
|
|
59
|
-
const match = matchRoute(path)
|
|
65
|
+
async function navigate(path: string, pushState: boolean = true) {
|
|
66
|
+
const match = matchRoute(path)
|
|
60
67
|
if (match) {
|
|
61
|
-
await
|
|
62
|
-
history.pushState({}, "", path)
|
|
68
|
+
await match.component(DOM)
|
|
69
|
+
if (pushState) history.pushState({}, "", path)
|
|
63
70
|
} else {
|
|
64
|
-
DOM
|
|
71
|
+
NotFound(DOM)
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
await navigate(window.location.pathname + window.location.search);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await navigate(window.location.pathname + window.location.search);
|
|
73
|
-
return { navigate, routes: routeTree };
|
|
75
|
+
return { navigate, routes: routeTree }
|
|
74
76
|
}
|
|
75
|
-
`;await l(o),await n.writeFile(a,
|
|
77
|
+
`;await l(o),await n.writeFile(a,w,"utf-8"),await n.writeFile(s,v(),"utf-8")}await l(o),await l(i),await l(r),await E(),c&&(t.watch(r).on("all",async(u,p)=>{p.endsWith(".ts")&&await E()}),t.watch(s).on("unlink",async()=>{await n.writeFile(s,v(),"utf-8")})),console.log("\u{1F7E2} TS Filebased Router Generated with Lazy Routes...")}});export{Me as TSFilebasedRouter,O as TSRouter,te as createEffect,ee as createSignal,k as html,re as loadPyFiles,me as mapper,J as renderChildRoutes,G as useAnchorSingle,B as useInitialDOM,Y as useTSAuth,K as useTSCollection,C as useTSComponent,D as useTSElementEach,U as useTSElements,F as useTSEvent,I as useTSEventAll,_ as useTSExtractParams,oe as useTSLazy,Q as useTSMetaData,Z as useTSNavigate,ae as useTSNoReload,X as useTSOutlet,P as useTSParams,N as useTSPurifier,se as useTSSSRHydration,R as useTSSelect,ne as useTSloadBrython};
|