@devwareng/vanilla-ts 1.4.7 → 1.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,60 +1,73 @@
1
- "use strict";var Se=Object.create;var j=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var xe=(s,t)=>{for(var e in t)j(s,e,{get:t[e],enumerable:!0})},Wt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ve(t))!Le.call(s,r)&&r!==e&&j(s,r,{get:()=>t[r],enumerable:!(n=Pe(t,r))||n.enumerable});return s};var y=(s,t,e)=>(e=s!=null?Se(Re(s)):{},Wt(t||!s||!s.__esModule?j(e,"default",{value:s,enumerable:!0}):e,s)),De=s=>Wt(j({},"__esModule",{value:!0}),s);var gs={};xe(gs,{TSRouter:()=>et,createEffect:()=>_t,createSignal:()=>Tt,html:()=>st,loadPyFiles:()=>Rt,mapper:()=>$t,renderChildRoutes:()=>wt,useAnchor:()=>N,useAnchorSingle:()=>ut,useInitialDOM:()=>dt,useTSAnchorMount:()=>Pt,useTSAuth:()=>gt,useTSCollection:()=>mt,useTSComponent:()=>H,useTSElementEach:()=>I,useTSElements:()=>lt,useTSEvent:()=>it,useTSEventAll:()=>ct,useTSExtractParams:()=>at,useTSFilebasedRouter:()=>b,useTSHashAnchor:()=>k,useTSLazy:()=>Lt,useTSMetaData:()=>ft,useTSNavigate:()=>Et,useTSNoReload:()=>F,useTSOutlet:()=>yt,useTSParams:()=>O,useTSPurifier:()=>rt,useTSSSRHydration:()=>xt,useTSSelect:()=>pt,useTSloadBrython:()=>vt});module.exports=De(gs);function Ae(s){return(s==null?"":String(s)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function st(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?Ae(t[r]):"";return e+n+i},"")}function U(){let s=new Set;document.querySelectorAll("*").forEach(t=>{let e=t.tagName.toLowerCase();e.includes("-")&&s.add(e)}),s.forEach(t=>{customElements.get(t)||customElements.define(t,class extends HTMLElement{connectedCallback(){this.innerHTML=`<div style="padding:10px;background:#eee;">${t} (Auto)</div>`}})})}var be=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),$t=s=>s?.map(t=>be(t)).join("")??"";var nt=y(require("dompurify"),1),rt=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?nt.default.sanitize(s,n):nt.default.sanitize(s.innerHTML,n)};var it=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};var jt=require("zustand/vanilla"),ot=y(require("dompurify"),1);function Me(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=ot.default.sanitize(i[c+1]??"")}),a}function Ce(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=ot.default.sanitize(r);return t}var O=(0,jt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=Me(e,n),i=Ce(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function at(s){let t=O.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var ct=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var q=y(require("dompurify"),1),lt=(s,t,e,n={})=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...e};q.default.addHook("uponSanitizeElement",(a,o)=>{let c=o.tagName.toLowerCase();c.includes("-")&&(o.allowedTags[c]=!0)}),q.default.addHook("uponSanitizeAttribute",(a,o)=>{o.attrName&&o.attrName.toLowerCase().startsWith("on")&&(o.keepAttr=!1)});let i=q.default.sanitize(t,r);s.innerHTML=i,s.querySelectorAll("[data-onclick]").forEach(a=>{let o=a.dataset.onclick;n[o]&&a.addEventListener("click",n[o])}),s.querySelectorAll("[data-onchange]").forEach(a=>{let o=a.dataset.onchange;n[o]&&a.addEventListener("change",n[o])}),s.querySelectorAll("[data-onselect]").forEach(a=>{let o=a.dataset.onselect;n[o]&&a.addEventListener("select",n[o])})};var Ut=y(require("dompurify"),1),Y=null,dt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;let n=e.innerHTML,i=Ut.default.sanitize(n,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(Y!==null&&i!==Y){let a=document.createElement("div");t(a),e.innerHTML=Y}else Y=i,e.innerHTML=i,t(e)};var ht=y(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var ut=(s,t,e,n="",r=null)=>{if(!s)return;let i=ht.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=ht.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var x=y(require("dompurify"),1);var qt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",l=!1)=>{let d=()=>{try{let h=document.querySelector('meta[http-equiv="Content-Security-Policy"]');h||(h=document.createElement("meta"),h.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(h));let u=l?`report-uri ${c};`:"";h.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${u}`)}catch(h){console.error("Error adding CSP meta element:",h)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var ft=(s,t)=>{let e={name:x.default.sanitize(s.name||""),description:x.default.sanitize(s.description||"Default description"),author:x.default.sanitize(s.author||"")},n=m=>{e.name=x.default.sanitize(m),h("name",e.name)},r=m=>{e.description=x.default.sanitize(m),h("description",e.description)},i=m=>{e.author=x.default.sanitize(m),h("author",e.author)},a=()=>e.name,o=()=>e.description,c=()=>e.author,l=()=>e,d=(m,E)=>{let T=document.createElement("meta");T.setAttribute("name",m),T.setAttribute("content",E),document.head.appendChild(T)},h=(m,E)=>{let T=document.querySelector(`meta[name="${m}"]`);T?T.setAttribute("content",E):d(m,E)},u=()=>{h("name",e.name),h("description",e.description),h("author",e.author)};return t&&qt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),u(),{setName:n,setDescription:r,setAuthor:i,getName:a,getDescription:o,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:u}};var Yt=y(require("dompurify"),1),H=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=Yt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var mt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?H(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var pt=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Gt=require("jwt-decode"),gt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Gt.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var I=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var Et=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var yt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function wt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Bt=require("zustand/vanilla");function Tt(s){let t=(0,Bt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function _t(s){let t=s();typeof t=="function"&&t()}var k=()=>{let s=document.querySelectorAll('a[href^="#"]');I(s,["click"],(t,e)=>{e.preventDefault();let n=t.getAttribute("href")?.substring(1),r=n?document.getElementById(n):null;r&&r.scrollIntoView({behavior:"smooth",block:"start"})})};var Vt=require("lodash-es"),St=s=>s;typeof window<"u"&&typeof document<"u"&&(St=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var Oe=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",St(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",St(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},He=(0,Vt.debounce)(Oe,50),N=s=>{He(s)};var F=s=>{let t=s.querySelectorAll("a");N(t)};var Pt=s=>{k(),F(s)};var vt=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Rt=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Lt(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){e?.appendChild(t);return}if(t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var xt=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var M=y(require("fs"),1),R=y(require("path"),1);var he=require("fs"),tt=require("fs/promises"),ue=require("events"),f=y(require("path"),1);var P=require("fs/promises"),Xt=require("stream"),v=require("path"),w={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Dt={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:w.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Dt);var Zt="READDIRP_RECURSIVE_ERROR",Ie=new Set(["ENOENT","EPERM","EACCES","ELOOP",Zt]),Kt=[w.DIR_TYPE,w.EVERYTHING_TYPE,w.FILE_DIR_TYPE,w.FILE_TYPE],ke=new Set([w.DIR_TYPE,w.EVERYTHING_TYPE,w.FILE_DIR_TYPE]),Ne=new Set([w.EVERYTHING_TYPE,w.FILE_DIR_TYPE,w.FILE_TYPE]),Fe=s=>Ie.has(s.code),ze=process.platform==="win32",Qt=s=>!0,Jt=s=>{if(s===void 0)return Qt;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return Qt},At=class extends Xt.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...Dt,...t},{root:n,type:r}=e;this._fileFilter=Jt(e.fileFilter),this._directoryFilter=Jt(e.directoryFilter);let i=e.lstat?P.lstat:P.stat;ze?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??Dt.depth,this._wantsDir=r?ke.has(r):!1,this._wantsFile=r?Ne.has(r):!1,this._wantsEverything=r===w.EVERYTHING_TYPE,this._root=(0,v.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,P.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,v.resolve)((0,v.join)(e,r));n={path:(0,v.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){Fe(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,P.realpath)(n),i=await(0,P.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===v.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=Zt,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function te(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=w.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&&!Kt.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${Kt.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new At(t)}var A=require("fs"),S=require("fs/promises"),p=y(require("path"),1),se=require("os"),We="data",Ct="end",ne="close",Q=()=>{};var J=process.platform,Ot=J==="win32",$e=J==="darwin",je=J==="linux",Ue=J==="freebsd",re=(0,se.type)()==="OS400",g={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},_=g,qe="watch",Ye={lstat:S.lstat,stat:S.stat},D="listeners",G="errHandlers",C="rawEmitters",Ge=[D,G,C],Be=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Ve=s=>Be.has(p.extname(s).slice(1).toLowerCase()),Mt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},z=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},Ke=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},W=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},ie=s=>s instanceof Set?s.size===0:!s,B=new Map;function ee(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&V(p.resolve(s,o),D,p.join(s,o))};try{return(0,A.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var V=(s,t,e,n,r)=>{let i=B.get(s);i&&Mt(i[t],a=>{a(e,n,r)})},Qe=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=B.get(t),c;if(!e.persistent)return c=ee(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)z(o,D,r),z(o,G,i),z(o,C,a);else{if(c=ee(s,e,V.bind(null,t,D),i,V.bind(null,t,C)),!c)return;c.on(_.ERROR,async l=>{let d=V.bind(null,t,G);if(o&&(o.watcherUnusable=!0),Ot&&l.code==="EPERM")try{await(await(0,S.open)(s,"r")).close(),d(l)}catch{}else d(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},B.set(t,o)}return()=>{W(o,D,r),W(o,G,i),W(o,C,a),ie(o.listeners)&&(o.watcher.close(),B.delete(t),Ge.forEach(Ke(o)),o.watcher=void 0,Object.freeze(o))}},bt=new Map,Je=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=bt.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,A.unwatchFile)(t),a=void 0),a?(z(a,D,r),z(a,C,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,A.watchFile)(t,e,(c,l)=>{Mt(a.rawEmitters,h=>{h(_.CHANGE,t,{curr:c,prev:l})});let d=c.mtimeMs;(c.size!==l.size||d>l.mtimeMs||d===0)&&Mt(a.listeners,h=>h(s,c))})},bt.set(t,a)),()=>{W(a,D,r),W(a,C,i),ie(a.listeners)&&(bt.delete(t),(0,A.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},K=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=p.dirname(t),i=p.basename(t);this.fsw._getWatchedDir(r).add(i);let o=p.resolve(t),c={persistent:n.persistent};e||(e=Q);let l;if(n.usePolling){let d=n.interval!==n.binaryInterval;c.interval=d&&Ve(i)?n.binaryInterval:n.interval,l=Je(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=Qe(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=p.dirname(t),i=p.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(d,h)=>{if(this.fsw._throttle(qe,t,5)){if(!h||h.mtimeMs===0)try{let u=await(0,S.stat)(t);if(this.fsw.closed)return;let m=u.atimeMs,E=u.mtimeMs;if((!m||m<=E||E!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,u),($e||je||Ue)&&o.ino!==u.ino){this.fsw._closeFile(d),o=u;let T=this._watchWithNodeFs(t,c);T&&this.fsw._addPathCloser(d,T)}else o=u}catch{this.fsw._remove(r,i)}else if(a.has(i)){let u=h.atimeMs,m=h.mtimeMs;(!u||u<=m||m!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,h),o=h}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(_.ADD,t,0))return;this.fsw._emit(_.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,S.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(_.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(_.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=p.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,d=this.fsw._readdirp(t,{fileFilter:h=>n.filterPath(h),directoryFilter:h=>n.filterDir(h)});if(d)return d.on(We,async h=>{if(this.fsw.closed){d=void 0;return}let u=h.path,m=p.join(t,u);if(l.add(u),!(h.stats.isSymbolicLink()&&await this._handleSymlink(h,t,m,u))){if(this.fsw.closed){d=void 0;return}(u===r||!r&&!c.has(u))&&(this.fsw._incrReadyCount(),m=p.join(i,p.relative(i,m)),this._addToNodeFs(m,e,n,a+1))}}).on(_.ERROR,this._boundHandleError),new Promise((h,u)=>{if(!d)return u();d.once(Ct,()=>{if(this.fsw.closed){d=void 0;return}let m=o?o.clear():!1;h(void 0),c.getChildren().filter(E=>E!==t&&!l.has(E)).forEach(E=>{this.fsw._remove(t,E)}),d=void 0,m&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(p.dirname(t)),l=c.has(p.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(_.ADD_DIR,t,e),c.add(p.basename(t)),this.fsw._getWatchedDir(t);let d,h,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,d),this.fsw.closed))return;h=this._watchWithNodeFs(t,(m,E)=>{E&&E.mtimeMs===0||this._handleRead(m,!1,a,i,t,r,d)})}return h}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await Ye[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,d;if(c.isDirectory()){let h=p.resolve(t),u=l?await(0,S.realpath)(t):t;if(this.fsw.closed||(d=await this._handleDir(o.watchPath,c,e,r,i,o,u),this.fsw.closed))return;h!==u&&u!==void 0&&this.fsw._symlinkPaths.set(h,u)}else if(c.isSymbolicLink()){let h=l?await(0,S.realpath)(t):t;if(this.fsw.closed)return;let u=p.dirname(o.watchPath);if(this.fsw._getWatchedDir(u).add(o.watchPath),this.fsw._emit(_.ADD,o.watchPath,c),d=await this._handleDir(u,c,e,r,t,o,h),this.fsw.closed)return;h!==void 0&&this.fsw._symlinkPaths.set(p.resolve(t),h)}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 Ht="/",Xe="//",fe=".",Ze="..",ts="string",es=/\\/g,oe=/\/\//,ss=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ns=/^\.[/\\]/;function X(s){return Array.isArray(s)?s:[s]}var It=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);function rs(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=f.relative(s.path,t);return e?!e.startsWith("..")&&!f.isAbsolute(e):!1}return!1}:()=>!1}function is(s){if(typeof s!="string")throw new Error("string expected");s=f.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 ae(s,t,e){let n=is(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function os(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=X(s).map(r=>rs(r));return t==null?(r,i)=>ae(n,r,i):ae(n,t)}var ce=s=>{let t=X(s).flat();if(!t.every(e=>typeof e===ts))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(me)},le=s=>{let t=s.replace(es,Ht),e=!1;for(t.startsWith(Xe)&&(e=!0);t.match(oe);)t=t.replace(oe,Ht);return e&&(t=Ht+t),t},me=s=>le(f.normalize(le(s))),de=(s="")=>t=>typeof t=="string"?me(f.isAbsolute(t)?t:f.join(s,t)):t,as=(s,t)=>f.isAbsolute(s)?s:f.join(t,s),cs=Object.freeze(new Set),kt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==fe&&t!==Ze&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,tt.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(f.dirname(n),f.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Q,this.items=cs,Object.freeze(this)}},ls="stat",ds="lstat",Nt=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(ns,""),this.watchPath=r,this.fullWatchPath=f.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?ls:ds}entryPath(t){return f.join(this.watchPath,f.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},Z=class extends ue.EventEmitter{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?X(t.ignored):X([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};re&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=Q,this._readyEmitted=!0,process.nextTick(()=>this.emit(g.READY)))},this._emitRaw=(...c)=>this.emit(g.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new K(this),Object.freeze(r)}_addIgnoredPath(t){if(It(t)){for(let e of this._ignoredPaths)if(It(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)It(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=ce(t);return r&&(i=i.map(a=>as(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(f.dirname(o),f.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=ce(t),{cwd:n}=this.options;return e.forEach(r=>{!f.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=f.join(n,r)),r=f.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?f.relative(this.options.cwd,n):n)||fe;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==g.ERROR&&this.emit(g.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;Ot&&(e=f.normalize(e)),r.cwd&&(e=f.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===g.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(g.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===g.ADD&&this._pendingUnlinks.has(e)&&(t=g.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===g.ADD||t===g.CHANGE)&&this._readyEmitted){let c=(l,d)=>{l?(t=g.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===g.CHANGE&&!this._throttle(g.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===g.ADD||t===g.ADD_DIR||t===g.CHANGE)){let c=r.cwd?f.join(r.cwd,e):e,l;try{l=await(0,tt.stat)(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(g.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),d=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),d};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!f.isAbsolute(t)&&(c=f.join(this.options.cwd,t));let l=new Date,d=this._pendingWrites;function h(u){(0,he.stat)(c,(m,E)=>{if(m||!d.has(t)){m&&m.code!=="ENOENT"&&r(m);return}let T=Number(new Date);u&&E.size!==u.size&&(d.get(t).lastChange=T);let _e=d.get(t);T-_e.lastChange>=e?(d.delete(t),r(void 0,E)):o=setTimeout(h,a,E)})}d.has(t)||(d.set(t,{lastChange:l,cancelWait:()=>(d.delete(t),clearTimeout(o),n)}),o=setTimeout(h,a))}_isIgnored(t,e){if(this.options.atomic&&ss.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(de(n)),o=[...[...this._ignoredPaths].map(de(n)),...i];this._userIgnored=os(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new Nt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=f.resolve(t);return this._watched.has(e)||this._watched.set(e,new kt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=f.join(t,e),i=f.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let d=r;if(this.options.cwd&&(d=f.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===g.ADD)return;this._watched.delete(r),this._watched.delete(i);let h=n?g.UNLINK_DIR:g.UNLINK;l&&!this._isIgnored(r)&&this._emit(h,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=f.dirname(t);this._getWatchedDir(e).remove(f.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:g.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=te(t,n);return this._streams.add(r),r.once(ne,()=>{r=void 0}),r.once(Ct,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function hs(s,t={}){let e=new Z(t);return e.add(s),e}var pe={watch:hs,FSWatcher:Z};var $=R.default.resolve("src/pages"),Ft=R.default.resolve("src/gen"),ge=R.default.join(Ft,"tsrouter.gen.ts");M.default.existsSync(Ft)||M.default.mkdirSync(Ft,{recursive:!0});function us(s,t){let e="/"+R.default.relative(t,s).replace(/\\/g,"/");return e=e.replace(/\.ts$/,""),e=e.replace(/\/index$/,"")||"/",e=e.replace(/\[(.+?)\]/g,":$1"),e}function fs(s){return s.replace(/^\//,"").split("/").map(t=>t.startsWith(":")?"id":t).join("-")||"index"}function ms(s,t){return R.default.relative(t,s).replace(/\\/g,"-").replace(/\.ts$/,"").replace(/\[|\]/g,"Param").replace(/[^a-zA-Z0-9]/g,"-").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function Ee(s){let t=M.default.readdirSync(s,{withFileTypes:!0}),e=[];for(let n of t){let r=R.default.join(s,n.name);if(n.isDirectory())e=e.concat(Ee(r));else if(n.isFile()&&n.name.endsWith(".ts")){let i=us(r,$);e.push({file:r,route:i,importName:ms(r,$),name:fs(i)})}}return e}function ps(s){return`import { html, useTSElements, useTSMetaData } from '@devwareng/vanilla-ts'
1
+ "use strict";var Se=Object.create;var j=Object.defineProperty;var Pe=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var Re=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var xe=(s,t)=>{for(var e in t)j(s,e,{get:t[e],enumerable:!0})},$t=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ve(t))!Le.call(s,r)&&r!==e&&j(s,r,{get:()=>t[r],enumerable:!(n=Pe(t,r))||n.enumerable});return s};var y=(s,t,e)=>(e=s!=null?Se(Re(s)):{},$t(t||!s||!s.__esModule?j(e,"default",{value:s,enumerable:!0}):e,s)),be=s=>$t(j({},"__esModule",{value:!0}),s);var gs={};xe(gs,{TSRouter:()=>et,createEffect:()=>_t,createSignal:()=>Tt,html:()=>st,loadPyFiles:()=>Rt,mapper:()=>Wt,renderChildRoutes:()=>wt,useAnchor:()=>F,useAnchorSingle:()=>ut,useInitialDOM:()=>dt,useTSAnchorMount:()=>Pt,useTSAuth:()=>gt,useTSCollection:()=>mt,useTSComponent:()=>H,useTSElementEach:()=>I,useTSElements:()=>lt,useTSEvent:()=>it,useTSEventAll:()=>ct,useTSExtractParams:()=>at,useTSFilebasedRouter:()=>D,useTSHashAnchor:()=>N,useTSLazy:()=>Lt,useTSMetaData:()=>ft,useTSNavigate:()=>Et,useTSNoReload:()=>k,useTSOutlet:()=>yt,useTSParams:()=>O,useTSPurifier:()=>rt,useTSSSRHydration:()=>xt,useTSSelect:()=>pt,useTSloadBrython:()=>vt});module.exports=be(gs);function Ae(s){return(s==null?"":String(s)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function st(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?Ae(t[r]):"";return e+n+i},"")}function U(){let s=new Set;document.querySelectorAll("*").forEach(t=>{let e=t.tagName.toLowerCase();e.includes("-")&&s.add(e)}),s.forEach(t=>{customElements.get(t)||customElements.define(t,class extends HTMLElement{connectedCallback(){this.innerHTML=`<div style="padding:10px;background:#eee;">${t} (Auto)</div>`}})})}var De=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),Wt=s=>s?.map(t=>De(t)).join("")??"";var nt=y(require("dompurify"),1),rt=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?nt.default.sanitize(s,n):nt.default.sanitize(s.innerHTML,n)};var it=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};var jt=require("zustand/vanilla"),ot=y(require("dompurify"),1);function Me(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=ot.default.sanitize(i[c+1]??"")}),a}function Ce(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=ot.default.sanitize(r);return t}var O=(0,jt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=Me(e,n),i=Ce(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function at(s){let t=O.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var ct=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var q=y(require("dompurify"),1),lt=(s,t,e,n={})=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...e};q.default.addHook("uponSanitizeElement",(a,o)=>{let c=o.tagName.toLowerCase();c.includes("-")&&(o.allowedTags[c]=!0)}),q.default.addHook("uponSanitizeAttribute",(a,o)=>{o.attrName&&o.attrName.toLowerCase().startsWith("on")&&(o.keepAttr=!1)});let i=q.default.sanitize(t,r);s.innerHTML=i,s.querySelectorAll("[data-onclick]").forEach(a=>{let o=a.dataset.onclick;n[o]&&a.addEventListener("click",n[o])}),s.querySelectorAll("[data-onchange]").forEach(a=>{let o=a.dataset.onchange;n[o]&&a.addEventListener("change",n[o])}),s.querySelectorAll("[data-onselect]").forEach(a=>{let o=a.dataset.onselect;n[o]&&a.addEventListener("select",n[o])})};var Ut=y(require("dompurify"),1),Y=null,dt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;let n=e.innerHTML,i=Ut.default.sanitize(n,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(Y!==null&&i!==Y){let a=document.createElement("div");t(a),e.innerHTML=Y}else Y=i,e.innerHTML=i,t(e)};var ht=y(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var ut=(s,t,e,n="",r=null)=>{if(!s)return;let i=ht.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=ht.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let d=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:d},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var x=y(require("dompurify"),1);var qt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",l=!1)=>{let d=()=>{try{let h=document.querySelector('meta[http-equiv="Content-Security-Policy"]');h||(h=document.createElement("meta"),h.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(h));let u=l?`report-uri ${c};`:"";h.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${u}`)}catch(h){console.error("Error adding CSP meta element:",h)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",d):d()};var ft=(s,t)=>{let e={name:x.default.sanitize(s.name||""),description:x.default.sanitize(s.description||"Default description"),author:x.default.sanitize(s.author||"")},n=m=>{e.name=x.default.sanitize(m),h("name",e.name)},r=m=>{e.description=x.default.sanitize(m),h("description",e.description)},i=m=>{e.author=x.default.sanitize(m),h("author",e.author)},a=()=>e.name,o=()=>e.description,c=()=>e.author,l=()=>e,d=(m,E)=>{let T=document.createElement("meta");T.setAttribute("name",m),T.setAttribute("content",E),document.head.appendChild(T)},h=(m,E)=>{let T=document.querySelector(`meta[name="${m}"]`);T?T.setAttribute("content",E):d(m,E)},u=()=>{h("name",e.name),h("description",e.description),h("author",e.author)};return t&&qt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),u(),{setName:n,setDescription:r,setAuthor:i,getName:a,getDescription:o,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:u}};var Yt=y(require("dompurify"),1),H=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=Yt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var mt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?H(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var pt=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Gt=require("jwt-decode"),gt=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Gt.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var I=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var Et=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var yt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function wt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Bt=require("zustand/vanilla");function Tt(s){let t=(0,Bt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function _t(s){let t=s();typeof t=="function"&&t()}var N=()=>{let s=document.querySelectorAll('a[href^="#"]');I(s,["click"],(t,e)=>{e.preventDefault();let n=t.getAttribute("href")?.substring(1),r=n?document.getElementById(n):null;r&&r.scrollIntoView({behavior:"smooth",block:"start"})})};var Vt=require("lodash-es"),St=s=>s;typeof window<"u"&&typeof document<"u"&&(St=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var Oe=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",St(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",St(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},He=(0,Vt.debounce)(Oe,50),F=s=>{He(s)};var k=s=>{let t=s.querySelectorAll("a");F(t)};var Pt=s=>{N(),k(s)};var vt=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Rt=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Lt(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){e?.appendChild(t);return}if(t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var xt=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var M=y(require("fs"),1),R=y(require("path"),1);var he=require("fs"),tt=require("fs/promises"),ue=require("events"),f=y(require("path"),1);var P=require("fs/promises"),Xt=require("stream"),v=require("path"),w={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},bt={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:w.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(bt);var Zt="READDIRP_RECURSIVE_ERROR",Ie=new Set(["ENOENT","EPERM","EACCES","ELOOP",Zt]),Kt=[w.DIR_TYPE,w.EVERYTHING_TYPE,w.FILE_DIR_TYPE,w.FILE_TYPE],Ne=new Set([w.DIR_TYPE,w.EVERYTHING_TYPE,w.FILE_DIR_TYPE]),Fe=new Set([w.EVERYTHING_TYPE,w.FILE_DIR_TYPE,w.FILE_TYPE]),ke=s=>Ie.has(s.code),ze=process.platform==="win32",Qt=s=>!0,Jt=s=>{if(s===void 0)return Qt;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return Qt},At=class extends Xt.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...bt,...t},{root:n,type:r}=e;this._fileFilter=Jt(e.fileFilter),this._directoryFilter=Jt(e.directoryFilter);let i=e.lstat?P.lstat:P.stat;ze?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??bt.depth,this._wantsDir=r?Ne.has(r):!1,this._wantsFile=r?Fe.has(r):!1,this._wantsEverything=r===w.EVERYTHING_TYPE,this._root=(0,v.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,P.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,v.resolve)((0,v.join)(e,r));n={path:(0,v.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){ke(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,P.realpath)(n),i=await(0,P.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===v.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=Zt,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}};function te(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=w.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&&!Kt.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${Kt.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new At(t)}var A=require("fs"),S=require("fs/promises"),p=y(require("path"),1),se=require("os"),$e="data",Ct="end",ne="close",Q=()=>{};var J=process.platform,Ot=J==="win32",We=J==="darwin",je=J==="linux",Ue=J==="freebsd",re=(0,se.type)()==="OS400",g={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},_=g,qe="watch",Ye={lstat:S.lstat,stat:S.stat},b="listeners",G="errHandlers",C="rawEmitters",Ge=[b,G,C],Be=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Ve=s=>Be.has(p.extname(s).slice(1).toLowerCase()),Mt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},z=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},Ke=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},$=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},ie=s=>s instanceof Set?s.size===0:!s,B=new Map;function ee(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&V(p.resolve(s,o),b,p.join(s,o))};try{return(0,A.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var V=(s,t,e,n,r)=>{let i=B.get(s);i&&Mt(i[t],a=>{a(e,n,r)})},Qe=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=B.get(t),c;if(!e.persistent)return c=ee(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)z(o,b,r),z(o,G,i),z(o,C,a);else{if(c=ee(s,e,V.bind(null,t,b),i,V.bind(null,t,C)),!c)return;c.on(_.ERROR,async l=>{let d=V.bind(null,t,G);if(o&&(o.watcherUnusable=!0),Ot&&l.code==="EPERM")try{await(await(0,S.open)(s,"r")).close(),d(l)}catch{}else d(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},B.set(t,o)}return()=>{$(o,b,r),$(o,G,i),$(o,C,a),ie(o.listeners)&&(o.watcher.close(),B.delete(t),Ge.forEach(Ke(o)),o.watcher=void 0,Object.freeze(o))}},Dt=new Map,Je=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=Dt.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,A.unwatchFile)(t),a=void 0),a?(z(a,b,r),z(a,C,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,A.watchFile)(t,e,(c,l)=>{Mt(a.rawEmitters,h=>{h(_.CHANGE,t,{curr:c,prev:l})});let d=c.mtimeMs;(c.size!==l.size||d>l.mtimeMs||d===0)&&Mt(a.listeners,h=>h(s,c))})},Dt.set(t,a)),()=>{$(a,b,r),$(a,C,i),ie(a.listeners)&&(Dt.delete(t),(0,A.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},K=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=p.dirname(t),i=p.basename(t);this.fsw._getWatchedDir(r).add(i);let o=p.resolve(t),c={persistent:n.persistent};e||(e=Q);let l;if(n.usePolling){let d=n.interval!==n.binaryInterval;c.interval=d&&Ve(i)?n.binaryInterval:n.interval,l=Je(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=Qe(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=p.dirname(t),i=p.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(d,h)=>{if(this.fsw._throttle(qe,t,5)){if(!h||h.mtimeMs===0)try{let u=await(0,S.stat)(t);if(this.fsw.closed)return;let m=u.atimeMs,E=u.mtimeMs;if((!m||m<=E||E!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,u),(We||je||Ue)&&o.ino!==u.ino){this.fsw._closeFile(d),o=u;let T=this._watchWithNodeFs(t,c);T&&this.fsw._addPathCloser(d,T)}else o=u}catch{this.fsw._remove(r,i)}else if(a.has(i)){let u=h.atimeMs,m=h.mtimeMs;(!u||u<=m||m!==o.mtimeMs)&&this.fsw._emit(_.CHANGE,t,h),o=h}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(_.ADD,t,0))return;this.fsw._emit(_.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,S.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(_.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(_.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=p.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,d=this.fsw._readdirp(t,{fileFilter:h=>n.filterPath(h),directoryFilter:h=>n.filterDir(h)});if(d)return d.on($e,async h=>{if(this.fsw.closed){d=void 0;return}let u=h.path,m=p.join(t,u);if(l.add(u),!(h.stats.isSymbolicLink()&&await this._handleSymlink(h,t,m,u))){if(this.fsw.closed){d=void 0;return}(u===r||!r&&!c.has(u))&&(this.fsw._incrReadyCount(),m=p.join(i,p.relative(i,m)),this._addToNodeFs(m,e,n,a+1))}}).on(_.ERROR,this._boundHandleError),new Promise((h,u)=>{if(!d)return u();d.once(Ct,()=>{if(this.fsw.closed){d=void 0;return}let m=o?o.clear():!1;h(void 0),c.getChildren().filter(E=>E!==t&&!l.has(E)).forEach(E=>{this.fsw._remove(t,E)}),d=void 0,m&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(p.dirname(t)),l=c.has(p.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(_.ADD_DIR,t,e),c.add(p.basename(t)),this.fsw._getWatchedDir(t);let d,h,u=this.fsw.options.depth;if((u==null||r<=u)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,d),this.fsw.closed))return;h=this._watchWithNodeFs(t,(m,E)=>{E&&E.mtimeMs===0||this._handleRead(m,!1,a,i,t,r,d)})}return h}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await Ye[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,d;if(c.isDirectory()){let h=p.resolve(t),u=l?await(0,S.realpath)(t):t;if(this.fsw.closed||(d=await this._handleDir(o.watchPath,c,e,r,i,o,u),this.fsw.closed))return;h!==u&&u!==void 0&&this.fsw._symlinkPaths.set(h,u)}else if(c.isSymbolicLink()){let h=l?await(0,S.realpath)(t):t;if(this.fsw.closed)return;let u=p.dirname(o.watchPath);if(this.fsw._getWatchedDir(u).add(o.watchPath),this.fsw._emit(_.ADD,o.watchPath,c),d=await this._handleDir(u,c,e,r,t,o,h),this.fsw.closed)return;h!==void 0&&this.fsw._symlinkPaths.set(p.resolve(t),h)}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 Ht="/",Xe="//",fe=".",Ze="..",ts="string",es=/\\/g,oe=/\/\//,ss=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ns=/^\.[/\\]/;function X(s){return Array.isArray(s)?s:[s]}var It=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);function rs(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=f.relative(s.path,t);return e?!e.startsWith("..")&&!f.isAbsolute(e):!1}return!1}:()=>!1}function is(s){if(typeof s!="string")throw new Error("string expected");s=f.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 ae(s,t,e){let n=is(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function os(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=X(s).map(r=>rs(r));return t==null?(r,i)=>ae(n,r,i):ae(n,t)}var ce=s=>{let t=X(s).flat();if(!t.every(e=>typeof e===ts))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(me)},le=s=>{let t=s.replace(es,Ht),e=!1;for(t.startsWith(Xe)&&(e=!0);t.match(oe);)t=t.replace(oe,Ht);return e&&(t=Ht+t),t},me=s=>le(f.normalize(le(s))),de=(s="")=>t=>typeof t=="string"?me(f.isAbsolute(t)?t:f.join(s,t)):t,as=(s,t)=>f.isAbsolute(s)?s:f.join(t,s),cs=Object.freeze(new Set),Nt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==fe&&t!==Ze&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,tt.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(f.dirname(n),f.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=Q,this.items=cs,Object.freeze(this)}},ls="stat",ds="lstat",Ft=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(ns,""),this.watchPath=r,this.fullWatchPath=f.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?ls:ds}entryPath(t){return f.join(this.watchPath,f.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},Z=class extends ue.EventEmitter{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?X(t.ignored):X([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};re&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=Q,this._readyEmitted=!0,process.nextTick(()=>this.emit(g.READY)))},this._emitRaw=(...c)=>this.emit(g.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new K(this),Object.freeze(r)}_addIgnoredPath(t){if(It(t)){for(let e of this._ignoredPaths)if(It(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)It(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=ce(t);return r&&(i=i.map(a=>as(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(f.dirname(o),f.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=ce(t),{cwd:n}=this.options;return e.forEach(r=>{!f.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=f.join(n,r)),r=f.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?f.relative(this.options.cwd,n):n)||fe;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==g.ERROR&&this.emit(g.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;Ot&&(e=f.normalize(e)),r.cwd&&(e=f.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===g.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(g.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===g.ADD&&this._pendingUnlinks.has(e)&&(t=g.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===g.ADD||t===g.CHANGE)&&this._readyEmitted){let c=(l,d)=>{l?(t=g.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===g.CHANGE&&!this._throttle(g.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===g.ADD||t===g.ADD_DIR||t===g.CHANGE)){let c=r.cwd?f.join(r.cwd,e):e,l;try{l=await(0,tt.stat)(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(g.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),d=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),d};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!f.isAbsolute(t)&&(c=f.join(this.options.cwd,t));let l=new Date,d=this._pendingWrites;function h(u){(0,he.stat)(c,(m,E)=>{if(m||!d.has(t)){m&&m.code!=="ENOENT"&&r(m);return}let T=Number(new Date);u&&E.size!==u.size&&(d.get(t).lastChange=T);let _e=d.get(t);T-_e.lastChange>=e?(d.delete(t),r(void 0,E)):o=setTimeout(h,a,E)})}d.has(t)||(d.set(t,{lastChange:l,cancelWait:()=>(d.delete(t),clearTimeout(o),n)}),o=setTimeout(h,a))}_isIgnored(t,e){if(this.options.atomic&&ss.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(de(n)),o=[...[...this._ignoredPaths].map(de(n)),...i];this._userIgnored=os(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new Ft(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=f.resolve(t);return this._watched.has(e)||this._watched.set(e,new Nt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=f.join(t,e),i=f.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(u=>this._remove(r,u));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let d=r;if(this.options.cwd&&(d=f.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===g.ADD)return;this._watched.delete(r),this._watched.delete(i);let h=n?g.UNLINK_DIR:g.UNLINK;l&&!this._isIgnored(r)&&this._emit(h,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=f.dirname(t);this._getWatchedDir(e).remove(f.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:g.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=te(t,n);return this._streams.add(r),r.once(ne,()=>{r=void 0}),r.once(Ct,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};function hs(s,t={}){let e=new Z(t);return e.add(s),e}var pe={watch:hs,FSWatcher:Z};var W=R.default.resolve("src/pages"),kt=R.default.resolve("src/gen"),ge=R.default.join(kt,"tsrouter.gen.ts");M.default.existsSync(kt)||M.default.mkdirSync(kt,{recursive:!0});function us(s,t){let e="/"+R.default.relative(t,s).replace(/\\/g,"/");return e=e.replace(/\.ts$/,""),e=e.replace(/\/index$/,"")||"/",e=e.replace(/\[(.+?)\]/g,":$1"),e}function fs(s){return s.replace(/^\//,"").split("/").map(t=>t.startsWith(":")?"id":t).join("-")||"index"}function ms(s,t){return R.default.relative(t,s).replace(/\\/g,"-").replace(/\.ts$/,"").replace(/\[|\]/g,"Param").replace(/[^a-zA-Z0-9]/g,"-").split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}function Ee(s){let t=M.default.readdirSync(s,{withFileTypes:!0}),e=[];for(let n of t){let r=R.default.join(s,n.name);if(n.isDirectory())e=e.concat(Ee(r));else if(n.isFile()&&n.name.endsWith(".ts")){let i=us(r,W);e.push({file:r,route:i,importName:ms(r,W),name:fs(i)})}}return e}function ps(s){return`import { html, useTSElements, useTSMetaData } from '@devwareng/vanilla-ts'
2
2
 
3
3
  export default function ${s}(DOM: HTMLElement, params: Record<string,string> = {}) {
4
- useTSMetaData({
5
- name: '${s.toLowerCase()}',
6
- description: '',
7
- author: ''
8
- });
4
+ useTSMetaData({
5
+ name: '${s.toLowerCase()}',
6
+ description: '',
7
+ author: ''
8
+ });
9
9
 
10
- const ui = useTSElements(
11
- DOM,
12
- html\`
13
- <div class="p-4">
14
- <h1 class="text-semibold">${s}</h1>
15
- <pre>\${JSON.stringify(params)}</pre>
16
- </div>
17
- \`
18
- );
19
- return ui
10
+ const ui = useTSElements(
11
+ DOM,
12
+ html\`
13
+ <div class="p-4">
14
+ <h1 class="text-semibold">${s}</h1>
15
+ <pre>\${JSON.stringify(params)}</pre>
16
+ </div>
17
+ \`
18
+ )
19
+ return ui
20
20
  }
21
- `}function b(){let s=Ee($),t=s.find(o=>o.file.toLowerCase().endsWith("notfound.ts")),e=s.filter(o=>o!==t),n=s.map(o=>`import ${o.importName} from "../pages/${R.default.relative($,o.file).replace(/\\/g,"/").replace(/\.ts$/,"")}";`).join(`
22
- `),r=e.map(o=>`{ path: "${o.route}", name: "${o.name}", component: (DOM: HTMLElement, params: Record<string,string> = {}) => ${o.importName}(DOM, params) }`).join(`,
23
- `),i=t?`export const NotFound = ${t.importName}`:"export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div><h1>404 - Page Not Found</h1></div>`)\n}",a=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
21
+
22
+ // Optional SSR render hook
23
+ export function render${s}(params: Record<string,string> = {}): string {
24
+ return html\`
25
+ <div class="p-4">
26
+ <h1 class="text-semibold">${s}</h1>
27
+ <pre>\${JSON.stringify(params)}</pre>
28
+ </div>
29
+ \`
30
+ }
31
+ `}function D(){let s=Ee(W),t=s.find(o=>o.file.toLowerCase().endsWith("notfound.ts")),e=s.filter(o=>o!==t),n=s.map(o=>`import ${o.importName}, { render${o.importName} } from "../pages/${R.default.relative(W,o.file).replace(/\\/g,"/").replace(/\.ts$/,"")}";`).join(`
32
+ `),r=e.map(o=>`{ path: "${o.route}", name: "${o.name}",
33
+ component: (DOM: HTMLElement, params: Record<string,string> = {}) => ${o.importName}(DOM, params),
34
+ render: (params: Record<string,string> = {}) => render${o.importName}(params)
35
+ }`).join(`,
36
+ `),i=t?`export const NotFound = ${t.importName};
37
+ export const renderNotFound = () => "<div><h1>404 - Page Not Found</h1></div>";`:`export function NotFound(DOM: HTMLElement) {
38
+ return useTSElements(DOM, html\`<div><h1>404 - Page Not Found</h1></div>\`)
39
+ }
40
+ export const renderNotFound = () => "<div><h1>404 - Page Not Found</h1></div>";`,a=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
24
41
  import { html, useTSElements } from "@devwareng/vanilla-ts"
25
42
 
26
43
  ${n}
27
44
 
28
45
  ${i}
29
46
 
30
- export function RootDocument(DOM: HTMLElement) {
31
- return useTSElements(DOM, html\`<div><h1>Root</h1></div>\`)
32
- }
33
-
34
47
  export const routeTree = [
35
48
  ${r}
36
49
  ]
37
50
 
38
51
  // --- Router with Param Support ---
39
- export function createRouter(DOM: HTMLElement) {
40
- function matchRoute(path: string) {
41
- for (const r of routeTree) {
42
- const keys: string[] = []
43
- const regex = new RegExp("^" + r.path.replace(/:([^/]+)/g, (_, k) => {
44
- keys.push(k)
45
- return "([^/]+)"
46
- }) + "$")
52
+ function matchRoute(path: string) {
53
+ for (const r of routeTree) {
54
+ const keys: string[] = []
55
+ const regex = new RegExp("^" + r.path.replace(/:([^/]+)/g, (_, k) => {
56
+ keys.push(k)
57
+ return "([^/]+)"
58
+ }) + "$")
47
59
 
48
- const match = path.match(regex)
49
- if (match) {
50
- const params: Record<string,string> = {}
51
- keys.forEach((k, i) => params[k] = match[i+1])
52
- return { ...r, params }
53
- }
60
+ const match = path.match(regex)
61
+ if (match) {
62
+ const params: Record<string,string> = {}
63
+ keys.forEach((k, i) => params[k] = match[i+1])
64
+ return { ...r, params }
54
65
  }
55
- return null
56
66
  }
67
+ return null
68
+ }
57
69
 
70
+ export function createRouter(DOM: HTMLElement) {
58
71
  function navigate(path: string) {
59
72
  const match = matchRoute(path)
60
73
  if (match) {
@@ -63,10 +76,18 @@ export function createRouter(DOM: HTMLElement) {
63
76
  NotFound(DOM)
64
77
  }
65
78
  }
66
-
67
79
  return { navigate }
68
80
  }
69
- `;M.default.writeFileSync(ge,a,"utf-8"),console.log("\u2705 Generated:",ge)}b();console.log("\u{1F440} Watching for changes in /src/pages...");pe.watch($).on("add",s=>{if(s.endsWith(".ts")){let t=R.default.basename(s,".ts"),e=t.replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,r=>r.replace("-","").toUpperCase());M.default.readFileSync(s,"utf-8").trim()||(M.default.writeFileSync(s,ps(e),"utf-8"),console.log(`\u{1F4DD} Scaffolded page: ${t}.ts`))}b()}).on("unlink",()=>{b()}).on("change",()=>{b()});var zt=y(require("dompurify"),1);var we=require("zustand/vanilla"),Te=y(require("dompurify"),1),L=(0,we.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:ye(t)})),setQuery:t=>s(()=>({query:ye(t)}))}));function ye(s){let t={};for(let e in s)t[e]=Te.default.sanitize(s[e]);return t}var et=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);L.getState().setParams(i),L.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);L.getState().setParams(a),L.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(L.getState().setParams(l),L.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let d=e.slice(a.path.length);this.renderChildren(a.children,d,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=zt.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,h=>(o.push(h.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=t.match(l);if(d){let h={...n};if(o.forEach((u,m)=>{h[u]=d[m+1]??""}),r.children){let u=t.slice(d[0].length),m=this.findMatchingRoute(u,r.children,h);if(m)return m}return{...r,params:h}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=zt.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};typeof window<"u"&&(window.addEventListener("popstate",()=>{U()}),document.addEventListener("DOMContentLoaded",U));0&&(module.exports={TSRouter,createEffect,createSignal,html,loadPyFiles,mapper,renderChildRoutes,useAnchor,useAnchorSingle,useInitialDOM,useTSAnchorMount,useTSAuth,useTSCollection,useTSComponent,useTSElementEach,useTSElements,useTSEvent,useTSEventAll,useTSExtractParams,useTSFilebasedRouter,useTSHashAnchor,useTSLazy,useTSMetaData,useTSNavigate,useTSNoReload,useTSOutlet,useTSParams,useTSPurifier,useTSSSRHydration,useTSSelect,useTSloadBrython});
81
+
82
+ // --- SSR Render Router ---
83
+ export function renderRoute(path: string): string {
84
+ const match = matchRoute(path)
85
+ if (match) {
86
+ return match.render(match.params)
87
+ }
88
+ return renderNotFound()
89
+ }
90
+ `;M.default.writeFileSync(ge,a,"utf-8"),console.log("\u2705 Generated:",ge)}D();console.log("\u{1F440} Watching for changes in /src/pages...");pe.watch(W).on("add",s=>{if(s.endsWith(".ts")){let t=R.default.basename(s,".ts"),e=t.replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,r=>r.replace("-","").toUpperCase());M.default.readFileSync(s,"utf-8").trim()||(M.default.writeFileSync(s,ps(e),"utf-8"),console.log(`\u{1F4DD} Scaffolded page: ${t}.ts`))}D()}).on("unlink",D).on("change",D);var zt=y(require("dompurify"),1);var we=require("zustand/vanilla"),Te=y(require("dompurify"),1),L=(0,we.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:ye(t)})),setQuery:t=>s(()=>({query:ye(t)}))}));function ye(s){let t={};for(let e in s)t[e]=Te.default.sanitize(s[e]);return t}var et=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);L.getState().setParams(i),L.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);L.getState().setParams(a),L.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(L.getState().setParams(l),L.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let d=e.slice(a.path.length);this.renderChildren(a.children,d,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=zt.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,h=>(o.push(h.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),d=t.match(l);if(d){let h={...n};if(o.forEach((u,m)=>{h[u]=d[m+1]??""}),r.children){let u=t.slice(d[0].length),m=this.findMatchingRoute(u,r.children,h);if(m)return m}return{...r,params:h}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=zt.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};typeof window<"u"&&(window.addEventListener("popstate",()=>{U()}),document.addEventListener("DOMContentLoaded",U));0&&(module.exports={TSRouter,createEffect,createSignal,html,loadPyFiles,mapper,renderChildRoutes,useAnchor,useAnchorSingle,useInitialDOM,useTSAnchorMount,useTSAuth,useTSCollection,useTSComponent,useTSElementEach,useTSElements,useTSEvent,useTSEventAll,useTSExtractParams,useTSFilebasedRouter,useTSHashAnchor,useTSLazy,useTSMetaData,useTSNavigate,useTSNoReload,useTSOutlet,useTSParams,useTSPurifier,useTSSSRHydration,useTSSelect,useTSloadBrython});
70
91
  /*! Bundled license information:
71
92
 
72
93
  chokidar/esm/index.js: