@wsxjs/wsx-router 0.0.23 → 0.0.24

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("@wsxjs/wsx-core");var _e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Se(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var ge={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(_e,function(){var e=function(){},t="undefined",r=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),g=["trace","debug","info","warn","error"],v={},d=null;function _(o,c){var i=o[c];if(typeof i.bind=="function")return i.bind(o);try{return Function.prototype.bind.call(i,o)}catch{return function(){return Function.prototype.apply.apply(i,[o,arguments])}}}function y(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function T(o){return o==="debug"&&(o="log"),typeof console===t?!1:o==="trace"&&r?y:console[o]!==void 0?_(console,o):console.log!==void 0?_(console,"log"):e}function j(){for(var o=this.getLevel(),c=0;c<g.length;c++){var i=g[c];this[i]=c<o?e:this.methodFactory(i,o,this.name)}if(this.log=this.debug,typeof console===t&&o<this.levels.SILENT)return"No console available for logging"}function V(o){return function(){typeof console!==t&&(j.call(this),this[o].apply(this,arguments))}}function D(o,c,i){return T(o)||V.apply(this,arguments)}function B(o,c){var i=this,u,A,k,R="loglevel";typeof o=="string"?R+=":"+o:typeof o=="symbol"&&(R=void 0);function P(h){var l=(g[h]||"silent").toUpperCase();if(!(typeof window===t||!R)){try{window.localStorage[R]=l;return}catch{}try{window.document.cookie=encodeURIComponent(R)+"="+l+";"}catch{}}}function C(){var h;if(!(typeof window===t||!R)){try{h=window.localStorage[R]}catch{}if(typeof h===t)try{var l=window.document.cookie,x=encodeURIComponent(R),E=l.indexOf(x+"=");E!==-1&&(h=/^([^;]+)/.exec(l.slice(E+x.length+1))[1])}catch{}return i.levels[h]===void 0&&(h=void 0),h}}function L(){if(!(typeof window===t||!R)){try{window.localStorage.removeItem(R)}catch{}try{window.document.cookie=encodeURIComponent(R)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function p(h){var l=h;if(typeof l=="string"&&i.levels[l.toUpperCase()]!==void 0&&(l=i.levels[l.toUpperCase()]),typeof l=="number"&&l>=0&&l<=i.levels.SILENT)return l;throw new TypeError("log.setLevel() called with invalid level: "+h)}i.name=o,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=c||D,i.getLevel=function(){return k??A??u},i.setLevel=function(h,l){return k=p(h),l!==!1&&P(k),j.call(i)},i.setDefaultLevel=function(h){A=p(h),C()||i.setLevel(h,!1)},i.resetLevel=function(){k=null,L(),j.call(i)},i.enableAll=function(h){i.setLevel(i.levels.TRACE,h)},i.disableAll=function(h){i.setLevel(i.levels.SILENT,h)},i.rebuild=function(){if(d!==i&&(u=p(d.getLevel())),j.call(i),d===i)for(var h in v)v[h].rebuild()},u=p(d?d.getLevel():"WARN");var m=C();m!=null&&(k=p(m)),j.call(i)}d=new B,d.getLogger=function(c){if(typeof c!="symbol"&&typeof c!="string"||c==="")throw new TypeError("You must supply a name when creating a logger.");var i=v[c];return i||(i=v[c]=new B(c,d.methodFactory)),i};var s=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=s),d},d.getLoggers=function(){return v},d.default=d,d})})(ge);var Ie=ge.exports;const ke=Se(Ie),pe={trace:"trace",debug:"debug",info:"info",warn:"warn",error:"error",silent:"silent"},We={0:"trace",1:"debug",2:"info",3:"warn",4:"error",5:"silent"};function se(){var n,e;if(typeof process<"u")return process.env.NODE_ENV==="production"||process.env.MODE==="production";try{const t=globalThis;if((e=(n=t.import)==null?void 0:n.meta)!=null&&e.env){const r=t.import.meta.env;return r.MODE==="production"||r.PROD===!0}}catch{}return!1}const te={name:"WSX",level:se()?"info":"debug",pretty:!se()};function Ae(n={}){const{name:e,level:t}={...te,...n},r=e||te.name,g=ke.getLogger(r),v=t||te.level;return g.setLevel(pe[v]),g}function Y(n,e){return n?`[${n}] ${e}`:e}class ve{constructor(e={}){this.isProd=se(),this.name=e.name||te.name,this.currentLevel=e.level||te.level,this.logInstance=Ae(e)}debug(e,...t){if(!this.isProd||this.shouldLog("debug")){const r=Y(this.name,e);t.length>0?this.logInstance.debug(r,...t):this.logInstance.debug(r)}}info(e,...t){if(this.shouldLog("info")){const r=Y(this.name,e);t.length>0?this.logInstance.info(r,...t):this.logInstance.info(r)}}warn(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.warn(r,...t):this.logInstance.warn(r)}error(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(r,...t):this.logInstance.error(r)}fatal(e,...t){const r=Y(this.name,e);t.length>0?this.logInstance.error(`[FATAL] ${r}`,...t):this.logInstance.error(`[FATAL] ${r}`)}trace(e,...t){if(!this.isProd||this.shouldLog("trace")){const r=Y(this.name,e);t.length>0?this.logInstance.trace(r,...t):this.logInstance.trace(r)}}shouldLog(e){const t=["trace","debug","info","warn","error","silent"],r=t.indexOf(this.currentLevel);return t.indexOf(e)>=r}getLoglevelLogger(){return this.logInstance}setLevel(e){this.currentLevel=e,this.logInstance.setLevel(pe[e])}getLevel(){const e=this.logInstance.getLevel();return We[e]||this.currentLevel}}new ve;function re(n,e={}){return new ve({...e,name:e.name||`WSX:${n}`})}const Te=re("RouterUtils"),Z=class Z{static _setCurrentRoute(e){Z._currentRoute=e}static navigate(e,t=!1){t?window.history.replaceState(null,"",e):window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")),Te.debug(`Navigated to: ${e} (replace: ${t})`)}static getCurrentRoute(){if(Z._currentRoute)return Z._currentRoute;const e=new URL(window.location.href);return{path:e.pathname,params:{},query:Object.fromEntries(e.searchParams.entries()),hash:e.hash.slice(1)}}static parseRoute(e,t){var r;if(e===t)return{route:e,params:{},exact:!0};if(e==="*")return{route:e,params:{},exact:!1};if(e.includes(":")){const g=((r=e.match(/:([^/]+)/g))==null?void 0:r.map(y=>y.slice(1)))||[],v=e.replace(/:[^/]+/g,"([^/]+)"),d=new RegExp(`^${v}$`),_=t.match(d);if(_&&g.length>0){const y={};return g.forEach((T,j)=>{y[T]=_[j+1]}),{route:e,params:y,exact:!0}}}if(e.endsWith("/*")){const g=e.slice(0,-2);if(t.startsWith(g))return{route:e,params:{},exact:!1}}return null}static buildPath(e,t={}){let r=e;return Object.entries(t).forEach(([g,v])=>{r=r.replace(`:${g}`,encodeURIComponent(v))}),r}static isRouteActive(e,t=!1){const r=window.location.pathname;return t?r===e:e==="/"?r==="/":r.startsWith(e)}static getRouteDepth(e){return e.split("/").filter(t=>t.length>0).length}static getParentRoute(e){const t=e.split("/").filter(r=>r.length>0);return t.length<=1?"/":(t.pop(),"/"+t.join("/"))}static joinPaths(...e){return e.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>t.length>0).join("/").replace(/^/,"/")}static isExternalUrl(e){return/^https?:\/\//.test(e)||/^mailto:/.test(e)||/^tel:/.test(e)}static getQueryParam(e){return new URL(window.location.href).searchParams.get(e)}static setQueryParam(e,t,r=!1){const g=new URL(window.location.href);g.searchParams.set(e,t);const v=g.pathname+g.search+g.hash;this.navigate(v,r)}static removeQueryParam(e,t=!1){const r=new URL(window.location.href);r.searchParams.delete(e);const g=r.pathname+r.search+r.hash;this.navigate(g,t)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(e){this.navigate(e,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(e){const t=()=>{const r=this.getCurrentRoute();e(r)};return document.addEventListener("route-changed",t),()=>{document.removeEventListener("route-changed",t)}}};Z._currentRoute=null;let ne=Z;const ae=":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";var me;let be,ye;function q(n,e,t){return(e=we(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function je(n,e,t,r,g,v){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,P,C,L,p,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],E=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";C?(L||p?a={get:ce(function(){return E(this)},i,"get"),set:function(f){o[4](this,f)}}:a[w]=E,L||ce(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=P,O.private=C,C?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:C?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),L||W||(C?p?R.push(d(a,"get"),d(a,"set")):R.push(u===2?a[w]:d.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Me(w)===s},P=new Map;function C(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,E=!!(8&m),W=(m&=7)==0,a=h+"/"+E;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T(E?s:s.prototype,p,x,l?"#"+h:we(h),m,i,E?A=A||[]:u=u||[],k,E,l,W,m===1,E&&l?R:c)}}return C(u),C(A),k}(n,e,g,D);return t.length||j(n,D),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,D,s),D),_.bind(null,s,n)]}}}function we(n){var e=Oe(n,"string");return typeof e=="symbol"?e:e+""}function Oe(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function ce(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Me(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const $=re("WsxRouter");ye=[N.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class De extends N.LightComponent{constructor(){super({styles:ae,styleName:"wsx-router"}),q(this,"_autoStyles",ae),q(this,"views",new Map),q(this,"currentView",null),q(this,"currentPath",""),q(this,"isHandlingRoute",!1),q(this,"compiledRoutes",new Map),q(this,"matchCache",new Map),q(this,"enableViewTransitions",!0),q(this,"scrollRestoration","manual"),q(this,"handleRouteChange",()=>{if(this.isHandlingRoute){$.debug("Route change already in progress, skipping");return}this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter re-collected views: ${this.views.size}`)),this.isHandlingRoute=!0;try{const e=window.location.pathname;$.debug(`WsxRouter: Route changed to: ${e}`);const t=new CustomEvent("before-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0,cancelable:!0});if(!this.dispatchEvent(t)){$.debug(`Navigation to ${e} was cancelled`);return}this.performNavigation(e)}finally{requestAnimationFrame(()=>{this.isHandlingRoute=!1})}}),q(this,"interceptLinks",e=>{const t=e.target.closest("a");if(!t)return;const r=t.getAttribute("href");!r||r.startsWith("http")||r.startsWith("#")||(e.preventDefault(),this.navigate(r))})}render(){return N.jsx("div",{class:"router-outlet"})}onRendered(){var e;(e=super.onRendered)==null||e.call(this),this.views.size===0&&(this.collectViews(),$.debug("WsxRouter collected views in onRendered:",this.views.size)),this.views.size>0&&!this.currentView&&requestAnimationFrame(()=>{this.handleRouteChange()})}onConnected(){var e;(e=super.onConnected)==null||e.call(this),$.debug("WsxRouter connected to DOM"),"scrollRestoration"in history&&(history.scrollRestoration=this.scrollRestoration),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),requestAnimationFrame(()=>{this.views.size===0&&(this.collectViews(),$.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)),requestAnimationFrame(()=>{$.debug(`WsxRouter handling initial route: ${window.location.pathname}`),this.handleRouteChange()})})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const e=Array.from(this.children).filter(t=>t.tagName.toLowerCase()==="wsx-view");$.debug(`WsxRouter found ${e.length} views`),this.views.clear(),this.compiledRoutes.clear(),this.matchCache.clear(),e.forEach(t=>{const r=t.getAttribute("route")||"/";if(this.views.set(r,t),$.debug(`WsxRouter registered route: ${r}`),r.includes(":")){const g=r.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`);this.compiledRoutes.set(r,v),$.debug(`WsxRouter compiled regex for route: ${r} -> ${v}`)}t.style.display="none"})}performNavigation(e){const t=()=>{const r=this.matchRoute(e);if(r){r.style.display="block",r.style.visibility="visible";const g=r.getAttribute("route")||"/";$.debug(`Showing view for route: ${g}`);for(const[j,V]of this.views)V!==r&&(V.style.display="none",V.style.visibility="");this.currentView=r;const v=this.extractParams(g,e);$.debug(`Extracted params for route ${g} and path ${e}:`,v),v&&requestAnimationFrame(()=>{r.setAttribute("params",JSON.stringify(v)),$.debug(`Set params attribute on view: ${JSON.stringify(v)}`)});const d=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,_=new URL(d,window.location.origin||"http://localhost"),y={path:e,params:v||{},query:Object.fromEntries(_.searchParams.entries()),hash:_.hash.slice(1)};ne._setCurrentRoute(y),$.debug("Updated RouterUtils._currentRoute:",y);const T=new CustomEvent("route-changed",{detail:y,bubbles:!0});document.dispatchEvent(T)}else{for(const[y,T]of this.views)T.style.display="none";this.currentView=null,$.warn(`No view found for path: ${e}`);const g=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,v=new URL(g,window.location.origin||"http://localhost"),d={path:e,params:{},query:Object.fromEntries(v.searchParams.entries()),hash:v.hash.slice(1)};ne._setCurrentRoute(d);const _=new CustomEvent("route-changed",{detail:d,bubbles:!0});document.dispatchEvent(_)}this.handleScrollRestoration(e),this.dispatchEvent(new CustomEvent("after-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0})),this.currentPath=e};this.enableViewTransitions&&"startViewTransition"in document?document.startViewTransition(t):t()}handleScrollRestoration(e){this.scrollRestoration==="manual"&&(this.isBackNavigation()||(window.scrollTo(0,0),$.debug("Scrolled to top for forward navigation")))}isBackNavigation(){var e;return"navigation"in performance&&performance.navigation?performance.navigation.type===2:((e=window.history.state)==null?void 0:e.navigationType)==="back"}matchRoute(e){if($.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`),this.matchCache.has(e)){const r=this.matchCache.get(e);return $.warn(`matchRoute: found in cache, route: ${r}`),this.views.get(r)||null}if(this.views.has(e))return this.matchCache.set(e,e),$.warn(`matchRoute: exact match found for ${e}`),this.views.get(e);$.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);for(const[r,g]of this.views)if(r.includes(":")){const v=this.compiledRoutes.get(r);if(v){const d=v.test(e);if($.warn(`matchRoute: testing route ${r} against ${e}, matches: ${d}`),d)return this.matchCache.set(e,r),$.warn(`matchRoute: parameter match found, route: ${r}, path: ${e}`),g}else $.warn(`matchRoute: route ${r} has ':' but no compiled regex found`)}const t=this.views.get("*")||null;return t?(this.matchCache.set(e,"*"),$.warn(`matchRoute: wildcard match found for ${e}`)):$.warn(`matchRoute: no match found for ${e}, no wildcard view available`),t}extractParams(e,t){var y;if(!e.includes(":"))return null;const r=((y=e.match(/:([^/]+)/g))==null?void 0:y.map(T=>T.slice(1)))||[],g=e.replace(/:[^/]+/g,"([^/]+)"),v=new RegExp(`^${g}$`),d=t.match(v);if(!d||!r.length)return null;const _={};return r.forEach((T,j)=>{_[T]=d[j+1]}),_}clearMatchCache(){this.matchCache.clear(),$.debug("WsxRouter cleared match cache")}setViewTransitions(e){this.enableViewTransitions=e,$.debug(`View Transitions ${e?"enabled":"disabled"}`)}setScrollRestoration(e){this.scrollRestoration=e,"scrollRestoration"in history&&(history.scrollRestoration=e),$.debug(`Scroll Restoration set to ${e}`)}navigate(e){window.history.pushState(null,"",e),this.handleRouteChange()}}me=De;[exports.WsxRouter,be]=je(me,[],ye,0,void 0,N.LightComponent).c;be();const Pe=":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";var Le;let Re,xe;function ee(n,e,t){return(e=Ce(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Ve(n,e,t,r,g,v){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,P,C,L,p,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],E=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";C?(L||p?a={get:le(function(){return E(this)},i,"get"),set:function(f){o[4](this,f)}}:a[w]=E,L||le(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=P,O.private=C,C?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:C?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),L||W||(C?p?R.push(d(a,"get"),d(a,"set")):R.push(u===2?a[w]:d.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return ze(w)===s},P=new Map;function C(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,E=!!(8&m),W=(m&=7)==0,a=h+"/"+E;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T(E?s:s.prototype,p,x,l?"#"+h:Ce(h),m,i,E?A=A||[]:u=u||[],k,E,l,W,m===1,E&&l?R:c)}}return C(u),C(A),k}(n,e,g,D);return t.length||j(n,D),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,D,s),D),_.bind(null,s,n)]}}}function Ce(n){var e=Ue(n,"string");return typeof e=="symbol"?e:e+""}function Ue(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(n)}function le(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function ze(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}const H=re("WsxView");xe=[N.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;class Ne extends N.LightComponent{constructor(){super(),ee(this,"_autoStyles",Pe),ee(this,"_component",""),ee(this,"params",void 0),ee(this,"componentInstance",null),ee(this,"isLoading",!1);let e=this.reactive({});Object.defineProperty(this,"params",{get:()=>e,set:t=>{e=t!==null&&typeof t<"u"&&(Array.isArray(t)||typeof t=="object")?this.reactive(t):t,this.scheduleRerender()},enumerable:!0,configurable:!0})}get component(){return this._component}set component(e){this._component=e||"",this._component&&requestAnimationFrame(()=>{this.connected&&!this.componentInstance&&!this.isLoading&&this.loadComponent(this._component||"")})}render(){return N.jsx("div",{class:"route-view"})}onConnected(){var e;(e=super.onConnected)==null||e.call(this),requestAnimationFrame(()=>{!this.connected||this.isLoading||this.componentInstance||this.component&&this.loadComponent(this.component)})}async loadComponent(e){if(!(!this.connected||this.isLoading||this.componentInstance)){this.isLoading=!0;try{const t=this.componentInstance;if(t&&(t.remove(),this.componentInstance=null),!customElements.get(e)){H.warn(`Component ${e} not found in customElements registry`),this.isLoading=!1;return}H.warn(`WsxView: Creating instance of ${e}`),this.componentInstance=document.createElement(e),Object.keys(this.params).length>0&&(H.warn(`WsxView: Setting initial params on ${e}:`,this.params),Object.entries(this.params).forEach(([v,d])=>{this.componentInstance.setAttribute(v,d)}));const g=this.querySelector(".route-view");if(g){if(H.warn(`WsxView: Appending ${e} to container`),!customElements.get(e)){H.error(`WsxView: Component ${e} is not registered in customElements registry!`),this.isLoading=!1,this.componentInstance=null;return}g.appendChild(this.componentInstance),H.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`),setTimeout(()=>{this.componentInstance&&this.componentInstance.isConnected?H.warn(`WsxView: Component ${e} is now connected to DOM`):H.error(`WsxView: Component ${e} was not connected to DOM!`)},0)}else H.error("WsxView: Route view container not found"),this.componentInstance=null}catch(t){H.warn(`Error loading component ${e}:`,t),this.componentInstance=null}finally{this.isLoading=!1,H.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`)}}}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}}Le=Ne;[exports.WsxView,Re]=Ve(Le,[],xe,0,void 0,N.LightComponent).c;Re();const Fe=':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';var ie,oe;let ue,Ee,he;function X(n,e,t){return(e=$e(e))in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function qe(n,e,t,r,g,v){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function y(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,R,P,C,L,p,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],E=o[3],W=!R;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],w=u===3?"get":u===4||p?"set":"value";C?(L||p?a={get:de(function(){return E(this)},i,"get"),set:function(f){o[4](this,f)}}:a[w]=E,L||de(a[w],i,u===2?"":w)):L||(a=Object.getOwnPropertyDescriptor(s,i))}for(var b=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");y(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=y(G.call(K,b,O),"class decorators","return"))&&(b=l);else{var M,z;O.static=P,O.private=C,C?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:C?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),b=G.call(K,p?{get:a.get,set:a.set}:a[w],O),p){if(typeof b=="object"&&b)(l=y(b.get,"accessor.get"))&&(a.get=l),(l=y(b.set,"accessor.set"))&&(a.set=l),(l=y(b.init,"accessor.init"))&&S.push(l);else if(b!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(b,(L?"field":"method")+" decorators","return")&&(L?S.push(b):a[w]=b)}}finally{J.v=!0}}return(L||p)&&R.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),L||W||(C?p?R.push(d(a,"get"),d(a,"set")):R.push(u===2?a[w]:d.call.bind(a[w])):Object.defineProperty(s,i,a)),b}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=v[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],R=function(w){return Be(w)===s},P=new Map;function C(w){w&&k.push(_.bind(null,w))}for(var L=0;L<o.length;L++){var p=o[L];if(Array.isArray(p)){var m=p[1],h=p[2],l=p.length>3,x=16&m,E=!!(8&m),W=(m&=7)==0,a=h+"/"+E;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T(E?s:s.prototype,p,x,l?"#"+h:$e(h),m,i,E?A=A||[]:u=u||[],k,E,l,W,m===1,E&&l?R:c)}}return C(u),C(A),k}(n,e,g,D);return t.length||j(n,D),{e:B,get c(){var s=[];return t.length&&[j(T(n,[t],r,n.name,5,D,s),D),_.bind(null,s,n)]}}}function $e(n){var e=He(n,"string");return typeof e=="symbol"?e:e+""}function He(n,e){if(typeof n!="object"||!n)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function de(n,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(n,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return n}function Be(n){if(Object(n)!==n)throw TypeError("right-hand side of 'in' should be an object, got "+(n!==null?typeof n:"null"));return n}function Ge(n){return n}const fe=re("WsxLink");Ee=[N.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(he=(oe=class extends N.WebComponent{constructor(){super(),X(this,"_autoStyles",Fe),X(this,"to",void 0),X(this,"activeClass",void 0),X(this,"handleClick",v=>{if(v.preventDefault(),!this.to){fe.warn("No 'to' attribute specified");return}if(this.isExternalLink(this.to)){window.open(this.to,"_blank");return}this.replace?window.history.replaceState(null,"",this.to):window.history.pushState(null,"",this.to),window.dispatchEvent(new PopStateEvent("popstate")),fe.debug(`Navigated to: ${this.to}`)}),X(this,"updateActiveState",()=>{var y;const v=window.location.pathname,d=this.exact?v===this.to:v.startsWith(this.to)&&this.to!=="/",_=(y=this.shadowRoot)==null?void 0:y.querySelector("a");_&&(d?(_.classList.add(this.activeClass),this.setAttribute("active","")):(_.classList.remove(this.activeClass),this.removeAttribute("active")))});const[e,t]=this.useState("to","");Object.defineProperty(this,"to",{get:e,set:t,enumerable:!0,configurable:!0});const[r,g]=this.useState("activeClass","active");Object.defineProperty(this,"activeClass",{get:r,set:g,enumerable:!0,configurable:!0})}get replace(){return this.hasAttribute("replace")}get exact(){return this.hasAttribute("exact")}render(){return N.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},N.jsx("slot",null))}onConnected(){var t;(t=super.onConnected)==null||t.call(this),this.to=this.to||"",this.activeClass=this.activeClass||"active";const e=this.shadowRoot.querySelector(".wsx-link");e&&(e.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(e,t,r){switch(e){case"to":this.to=r||"",this.updateActiveState();break;case"replace":this.replace=r!==null&&r!=="false";break;case"active-class":this.activeClass=r||"active",this.updateActiveState();break;case"exact":this.exact=r!==null&&r!=="false",this.updateActiveState();break}}isExternalLink(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mailto:")||e.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,ue]=qe(oe,[],Ee,0,void 0,N.WebComponent).c,oe),ie=class extends Ge{constructor(){super(exports.WsxLink),X(this,"observedAttributes",["to","replace","active-class","exact"]),ue()}},X(ie,he,void 0),ie);exports.RouterUtils=ne;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("@wsxjs/wsx-core");var _e=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Se(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ge={exports:{}};(function(r){(function(e,t){r.exports?r.exports=t():e.log=t()})(_e,function(){var e=function(){},t="undefined",n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),g=["trace","debug","info","warn","error"],p={},d=null;function _(o,c){var i=o[c];if(typeof i.bind=="function")return i.bind(o);try{return Function.prototype.bind.call(i,o)}catch{return function(){return Function.prototype.apply.apply(i,[o,arguments])}}}function b(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function T(o){return o==="debug"&&(o="log"),typeof console===t?!1:o==="trace"&&n?b:console[o]!==void 0?_(console,o):console.log!==void 0?_(console,"log"):e}function j(){for(var o=this.getLevel(),c=0;c<g.length;c++){var i=g[c];this[i]=c<o?e:this.methodFactory(i,o,this.name)}if(this.log=this.debug,typeof console===t&&o<this.levels.SILENT)return"No console available for logging"}function V(o){return function(){typeof console!==t&&(j.call(this),this[o].apply(this,arguments))}}function D(o,c,i){return T(o)||V.apply(this,arguments)}function B(o,c){var i=this,u,A,k,L="loglevel";typeof o=="string"?L+=":"+o:typeof o=="symbol"&&(L=void 0);function P(h){var l=(g[h]||"silent").toUpperCase();if(!(typeof window===t||!L)){try{window.localStorage[L]=l;return}catch{}try{window.document.cookie=encodeURIComponent(L)+"="+l+";"}catch{}}}function E(){var h;if(!(typeof window===t||!L)){try{h=window.localStorage[L]}catch{}if(typeof h===t)try{var l=window.document.cookie,x=encodeURIComponent(L),$=l.indexOf(x+"=");$!==-1&&(h=/^([^;]+)/.exec(l.slice($+x.length+1))[1])}catch{}return i.levels[h]===void 0&&(h=void 0),h}}function R(){if(!(typeof window===t||!L)){try{window.localStorage.removeItem(L)}catch{}try{window.document.cookie=encodeURIComponent(L)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function v(h){var l=h;if(typeof l=="string"&&i.levels[l.toUpperCase()]!==void 0&&(l=i.levels[l.toUpperCase()]),typeof l=="number"&&l>=0&&l<=i.levels.SILENT)return l;throw new TypeError("log.setLevel() called with invalid level: "+h)}i.name=o,i.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},i.methodFactory=c||D,i.getLevel=function(){return k??A??u},i.setLevel=function(h,l){return k=v(h),l!==!1&&P(k),j.call(i)},i.setDefaultLevel=function(h){A=v(h),E()||i.setLevel(h,!1)},i.resetLevel=function(){k=null,R(),j.call(i)},i.enableAll=function(h){i.setLevel(i.levels.TRACE,h)},i.disableAll=function(h){i.setLevel(i.levels.SILENT,h)},i.rebuild=function(){if(d!==i&&(u=v(d.getLevel())),j.call(i),d===i)for(var h in p)p[h].rebuild()},u=v(d?d.getLevel():"WARN");var m=E();m!=null&&(k=v(m)),j.call(i)}d=new B,d.getLogger=function(c){if(typeof c!="symbol"&&typeof c!="string"||c==="")throw new TypeError("You must supply a name when creating a logger.");var i=p[c];return i||(i=p[c]=new B(c,d.methodFactory)),i};var s=typeof window!==t?window.log:void 0;return d.noConflict=function(){return typeof window!==t&&window.log===d&&(window.log=s),d},d.getLoggers=function(){return p},d.default=d,d})})(ge);var Ie=ge.exports;const ke=Se(Ie),pe={trace:"trace",debug:"debug",info:"info",warn:"warn",error:"error",silent:"silent"},We={0:"trace",1:"debug",2:"info",3:"warn",4:"error",5:"silent"};function se(){var r,e;if(typeof process<"u")return process.env.NODE_ENV==="production"||process.env.MODE==="production";try{const t=globalThis;if((e=(r=t.import)==null?void 0:r.meta)!=null&&e.env){const n=t.import.meta.env;return n.MODE==="production"||n.PROD===!0}}catch{}return!1}const te={name:"WSX",level:se()?"info":"debug",pretty:!se()};function Ae(r={}){const{name:e,level:t}={...te,...r},n=e||te.name,g=ke.getLogger(n),p=t||te.level;return g.setLevel(pe[p]),g}function Y(r,e){return r?`[${r}] ${e}`:e}class ve{constructor(e={}){this.isProd=se(),this.name=e.name||te.name,this.currentLevel=e.level||te.level,this.logInstance=Ae(e)}debug(e,...t){if(!this.isProd||this.shouldLog("debug")){const n=Y(this.name,e);t.length>0?this.logInstance.debug(n,...t):this.logInstance.debug(n)}}info(e,...t){if(this.shouldLog("info")){const n=Y(this.name,e);t.length>0?this.logInstance.info(n,...t):this.logInstance.info(n)}}warn(e,...t){const n=Y(this.name,e);t.length>0?this.logInstance.warn(n,...t):this.logInstance.warn(n)}error(e,...t){const n=Y(this.name,e);t.length>0?this.logInstance.error(n,...t):this.logInstance.error(n)}fatal(e,...t){const n=Y(this.name,e);t.length>0?this.logInstance.error(`[FATAL] ${n}`,...t):this.logInstance.error(`[FATAL] ${n}`)}trace(e,...t){if(!this.isProd||this.shouldLog("trace")){const n=Y(this.name,e);t.length>0?this.logInstance.trace(n,...t):this.logInstance.trace(n)}}shouldLog(e){const t=["trace","debug","info","warn","error","silent"],n=t.indexOf(this.currentLevel);return t.indexOf(e)>=n}getLoglevelLogger(){return this.logInstance}setLevel(e){this.currentLevel=e,this.logInstance.setLevel(pe[e])}getLevel(){const e=this.logInstance.getLevel();return We[e]||this.currentLevel}}new ve;function re(r,e={}){return new ve({...e,name:e.name||`WSX:${r}`})}const Te=re("RouterUtils"),Z=class Z{static _setCurrentRoute(e){Z._currentRoute=e}static navigate(e,t=!1){t?window.history.replaceState(null,"",e):window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")),Te.debug(`Navigated to: ${e} (replace: ${t})`)}static getCurrentRoute(){if(Z._currentRoute)return Z._currentRoute;const e=new URL(window.location.href);return{path:e.pathname,params:{},query:Object.fromEntries(e.searchParams.entries()),hash:e.hash.slice(1)}}static parseRoute(e,t){var n;if(e===t)return{route:e,params:{},exact:!0};if(e==="*")return{route:e,params:{},exact:!1};if(e.includes(":")){const g=((n=e.match(/:([^/]+)/g))==null?void 0:n.map(b=>b.slice(1)))||[],p=e.replace(/:[^/]+/g,"([^/]+)"),d=new RegExp(`^${p}$`),_=t.match(d);if(_&&g.length>0){const b={};return g.forEach((T,j)=>{b[T]=_[j+1]}),{route:e,params:b,exact:!0}}}if(e.endsWith("/*")){const g=e.slice(0,-2);if(t.startsWith(g))return{route:e,params:{},exact:!1}}return null}static buildPath(e,t={}){let n=e;return Object.entries(t).forEach(([g,p])=>{n=n.replace(`:${g}`,encodeURIComponent(p))}),n}static isRouteActive(e,t=!1){const n=window.location.pathname;return t?n===e:e==="/"?n==="/":n.startsWith(e)}static getRouteDepth(e){return e.split("/").filter(t=>t.length>0).length}static getParentRoute(e){const t=e.split("/").filter(n=>n.length>0);return t.length<=1?"/":(t.pop(),"/"+t.join("/"))}static joinPaths(...e){return e.map(t=>t.replace(/^\/+|\/+$/g,"")).filter(t=>t.length>0).join("/").replace(/^/,"/")}static isExternalUrl(e){return/^https?:\/\//.test(e)||/^mailto:/.test(e)||/^tel:/.test(e)}static getQueryParam(e){return new URL(window.location.href).searchParams.get(e)}static setQueryParam(e,t,n=!1){const g=new URL(window.location.href);g.searchParams.set(e,t);const p=g.pathname+g.search+g.hash;this.navigate(p,n)}static removeQueryParam(e,t=!1){const n=new URL(window.location.href);n.searchParams.delete(e);const g=n.pathname+n.search+n.hash;this.navigate(g,t)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(e){this.navigate(e,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(e){const t=()=>{const n=this.getCurrentRoute();e(n)};return document.addEventListener("route-changed",t),()=>{document.removeEventListener("route-changed",t)}}};Z._currentRoute=null;let ne=Z;const ae=":host{display:grid;width:100%}.router-outlet{width:100%}:host>wsx-view{grid-area:1 / 1}";var me;let we,be;function q(r,e,t){return(e=ye(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function je(r,e,t,n,g,p){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function b(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,L,P,E,R,v,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],$=o[3],W=!L;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],y=u===3?"get":u===4||v?"set":"value";E?(R||v?a={get:ce(function(){return $(this)},i,"get"),set:function(f){o[4](this,f)}}:a[y]=$,R||ce(a[y],i,u===2?"":y)):R||(a=Object.getOwnPropertyDescriptor(s,i))}for(var w=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");b(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=b(G.call(K,w,O),"class decorators","return"))&&(w=l);else{var M,z;O.static=P,O.private=E,E?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:E?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),w=G.call(K,v?{get:a.get,set:a.set}:a[y],O),v){if(typeof w=="object"&&w)(l=b(w.get,"accessor.get"))&&(a.get=l),(l=b(w.set,"accessor.set"))&&(a.set=l),(l=b(w.init,"accessor.init"))&&S.push(l);else if(w!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(w,(R?"field":"method")+" decorators","return")&&(R?S.push(w):a[y]=w)}}finally{J.v=!0}}return(R||v)&&L.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),R||W||(E?v?L.push(d(a,"get"),d(a,"set")):L.push(u===2?a[y]:d.call.bind(a[y])):Object.defineProperty(s,i,a)),w}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=p[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],L=function(y){return Me(y)===s},P=new Map;function E(y){y&&k.push(_.bind(null,y))}for(var R=0;R<o.length;R++){var v=o[R];if(Array.isArray(v)){var m=v[1],h=v[2],l=v.length>3,x=16&m,$=!!(8&m),W=(m&=7)==0,a=h+"/"+$;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T($?s:s.prototype,v,x,l?"#"+h:ye(h),m,i,$?A=A||[]:u=u||[],k,$,l,W,m===1,$&&l?L:c)}}return E(u),E(A),k}(r,e,g,D);return t.length||j(r,D),{e:B,get c(){var s=[];return t.length&&[j(T(r,[t],n,r.name,5,D,s),D),_.bind(null,s,r)]}}}function ye(r){var e=Oe(r,"string");return typeof e=="symbol"?e:e+""}function Oe(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ce(r,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return r}function Me(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}const C=re("WsxRouter");be=[N.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class De extends N.LightComponent{constructor(){super({styles:ae,styleName:"wsx-router"}),q(this,"_autoStyles",ae),q(this,"views",new Map),q(this,"currentView",null),q(this,"currentPath",""),q(this,"isHandlingRoute",!1),q(this,"compiledRoutes",new Map),q(this,"matchCache",new Map),q(this,"enableViewTransitions",!0),q(this,"scrollRestoration","manual"),q(this,"handleRouteChange",()=>{if(this.isHandlingRoute){C.debug("Route change already in progress, skipping");return}this.views.size===0&&(this.collectViews(),C.debug(`WsxRouter re-collected views: ${this.views.size}`)),this.isHandlingRoute=!0;try{const e=window.location.pathname;C.debug(`WsxRouter: Route changed to: ${e}`);const t=new CustomEvent("before-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0,cancelable:!0});if(!this.dispatchEvent(t)){C.debug(`Navigation to ${e} was cancelled`);return}this.performNavigation(e)}finally{requestAnimationFrame(()=>{this.isHandlingRoute=!1})}}),q(this,"interceptLinks",e=>{const t=e.target.closest("a");if(!t)return;const n=t.getAttribute("href");!n||n.startsWith("http")||n.startsWith("#")||(e.preventDefault(),this.navigate(n))})}render(){return N.jsx("div",{class:"router-outlet"})}onRendered(){var e;(e=super.onRendered)==null||e.call(this),this.views.size===0&&(this.collectViews(),C.debug("WsxRouter collected views in onRendered:",this.views.size)),this.views.size>0&&!this.currentView&&requestAnimationFrame(()=>{this.handleRouteChange()})}onConnected(){var e;(e=super.onConnected)==null||e.call(this),C.debug("WsxRouter connected to DOM"),"scrollRestoration"in history&&(history.scrollRestoration=this.scrollRestoration),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),requestAnimationFrame(()=>{this.views.size===0&&(this.collectViews(),C.debug(`WsxRouter collected views in onConnected: ${this.views.size}`)),requestAnimationFrame(()=>{C.debug(`WsxRouter handling initial route: ${window.location.pathname}`),this.handleRouteChange()})})}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const e=Array.from(this.children).filter(t=>t.tagName.toLowerCase()==="wsx-view");C.debug(`WsxRouter found ${e.length} views`),this.views.clear(),this.compiledRoutes.clear(),this.matchCache.clear(),e.forEach(t=>{const n=t.getAttribute("route")||"/";if(this.views.set(n,t),C.debug(`WsxRouter registered route: ${n}`),n.includes(":")){const g=n.replace(/:[^/]+/g,"([^/]+)"),p=new RegExp(`^${g}$`);this.compiledRoutes.set(n,p),C.debug(`WsxRouter compiled regex for route: ${n} -> ${p}`)}t.style.display="none"})}performNavigation(e){const t=()=>{const n=this.matchRoute(e);if(n){n.style.display="block",n.style.visibility="visible";const g=n.getAttribute("route")||"/";C.debug(`Showing view for route: ${g}`);for(const[j,V]of this.views)V!==n&&(V.style.display="none",V.style.visibility="");this.currentView=n;const p=this.extractParams(g,e);C.debug(`Extracted params for route ${g} and path ${e}:`,p),p&&requestAnimationFrame(()=>{n.setAttribute("params",JSON.stringify(p)),C.debug(`Set params attribute on view: ${JSON.stringify(p)}`)});const d=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,_=new URL(d,window.location.origin||"http://localhost"),b={path:e,params:p||{},query:Object.fromEntries(_.searchParams.entries()),hash:_.hash.slice(1)};ne._setCurrentRoute(b),C.debug("Updated RouterUtils._currentRoute:",b);const T=new CustomEvent("route-changed",{detail:b,bubbles:!0});document.dispatchEvent(T)}else{for(const[b,T]of this.views)T.style.display="none";this.currentView=null,C.warn(`No view found for path: ${e}`);const g=window.location.href||`${window.location.pathname}${window.location.search}${window.location.hash}`,p=new URL(g,window.location.origin||"http://localhost"),d={path:e,params:{},query:Object.fromEntries(p.searchParams.entries()),hash:p.hash.slice(1)};ne._setCurrentRoute(d);const _=new CustomEvent("route-changed",{detail:d,bubbles:!0});document.dispatchEvent(_)}this.handleScrollRestoration(e),this.dispatchEvent(new CustomEvent("after-navigate",{detail:{to:e,from:this.currentPath},bubbles:!0})),this.currentPath=e};this.enableViewTransitions&&"startViewTransition"in document?document.startViewTransition(t):t()}handleScrollRestoration(e){this.scrollRestoration==="manual"&&(this.isBackNavigation()||(window.scrollTo(0,0),C.debug("Scrolled to top for forward navigation")))}isBackNavigation(){var e;return"navigation"in performance&&performance.navigation?performance.navigation.type===2:((e=window.history.state)==null?void 0:e.navigationType)==="back"}matchRoute(e){if(C.warn(`matchRoute called for path: ${e}, views count: ${this.views.size}`),this.matchCache.has(e)){const n=this.matchCache.get(e);return C.warn(`matchRoute: found in cache, route: ${n}`),this.views.get(n)||null}if(this.views.has(e))return this.matchCache.set(e,e),C.warn(`matchRoute: exact match found for ${e}`),this.views.get(e);for(const[n,g]of this.views)if(n.endsWith("/*")){const p=n.slice(0,-2);if(e.startsWith(p))return this.matchCache.set(e,n),C.warn(`matchRoute: prefix match found, route: ${n}, path: ${e}`),g}C.warn(`matchRoute: checking parameter routes, compiledRoutes count: ${this.compiledRoutes.size}`);for(const[n,g]of this.views)if(n.includes(":")){const p=this.compiledRoutes.get(n);if(p){const d=p.test(e);if(C.warn(`matchRoute: testing route ${n} against ${e}, matches: ${d}`),d)return this.matchCache.set(e,n),C.warn(`matchRoute: parameter match found, route: ${n}, path: ${e}`),g}else C.warn(`matchRoute: route ${n} has ':' but no compiled regex found`)}const t=this.views.get("*")||null;return t?(this.matchCache.set(e,"*"),C.warn(`matchRoute: wildcard match found for ${e}`)):C.warn(`matchRoute: no match found for ${e}, no wildcard view available`),t}extractParams(e,t){var b;if(!e.includes(":"))return null;const n=((b=e.match(/:([^/]+)/g))==null?void 0:b.map(T=>T.slice(1)))||[],g=e.replace(/:[^/]+/g,"([^/]+)"),p=new RegExp(`^${g}$`),d=t.match(p);if(!d||!n.length)return null;const _={};return n.forEach((T,j)=>{_[T]=d[j+1]}),_}clearMatchCache(){this.matchCache.clear(),C.debug("WsxRouter cleared match cache")}setViewTransitions(e){this.enableViewTransitions=e,C.debug(`View Transitions ${e?"enabled":"disabled"}`)}setScrollRestoration(e){this.scrollRestoration=e,"scrollRestoration"in history&&(history.scrollRestoration=e),C.debug(`Scroll Restoration set to ${e}`)}navigate(e){window.history.pushState(null,"",e),this.handleRouteChange()}}me=De;[exports.WsxRouter,we]=je(me,[],be,0,void 0,N.LightComponent).c;we();const Pe=":host{display:block;width:100%;height:100%}.route-view{width:100%;height:100%;position:relative}:host([loading]) .route-view{opacity:.5;transition:opacity .3s ease}:host([error]) .route-view{border:1px solid var(--error-color, #ff0000);padding:1rem}.route-view.entering{animation:fadeIn .3s ease-out}.route-view.leaving{animation:fadeOut .3s ease-in}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}";var Re;let Le,xe;function ee(r,e,t){return(e=Ce(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Ve(r,e,t,n,g,p){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function b(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,L,P,E,R,v,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],$=o[3],W=!L;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],y=u===3?"get":u===4||v?"set":"value";E?(R||v?a={get:le(function(){return $(this)},i,"get"),set:function(f){o[4](this,f)}}:a[y]=$,R||le(a[y],i,u===2?"":y)):R||(a=Object.getOwnPropertyDescriptor(s,i))}for(var w=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");b(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=b(G.call(K,w,O),"class decorators","return"))&&(w=l);else{var M,z;O.static=P,O.private=E,E?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:E?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),w=G.call(K,v?{get:a.get,set:a.set}:a[y],O),v){if(typeof w=="object"&&w)(l=b(w.get,"accessor.get"))&&(a.get=l),(l=b(w.set,"accessor.set"))&&(a.set=l),(l=b(w.init,"accessor.init"))&&S.push(l);else if(w!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(w,(R?"field":"method")+" decorators","return")&&(R?S.push(w):a[y]=w)}}finally{J.v=!0}}return(R||v)&&L.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),R||W||(E?v?L.push(d(a,"get"),d(a,"set")):L.push(u===2?a[y]:d.call.bind(a[y])):Object.defineProperty(s,i,a)),w}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=p[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],L=function(y){return ze(y)===s},P=new Map;function E(y){y&&k.push(_.bind(null,y))}for(var R=0;R<o.length;R++){var v=o[R];if(Array.isArray(v)){var m=v[1],h=v[2],l=v.length>3,x=16&m,$=!!(8&m),W=(m&=7)==0,a=h+"/"+$;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T($?s:s.prototype,v,x,l?"#"+h:Ce(h),m,i,$?A=A||[]:u=u||[],k,$,l,W,m===1,$&&l?L:c)}}return E(u),E(A),k}(r,e,g,D);return t.length||j(r,D),{e:B,get c(){var s=[];return t.length&&[j(T(r,[t],n,r.name,5,D,s),D),_.bind(null,s,r)]}}}function Ce(r){var e=Ue(r,"string");return typeof e=="symbol"?e:e+""}function Ue(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function le(r,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return r}function ze(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}const H=re("WsxView");xe=[N.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;class Ne extends N.LightComponent{constructor(){super(),ee(this,"_autoStyles",Pe),ee(this,"_component",""),ee(this,"params",void 0),ee(this,"componentInstance",null),ee(this,"isLoading",!1);let e=this.reactive({});Object.defineProperty(this,"params",{get:()=>e,set:t=>{e=t!==null&&typeof t<"u"&&(Array.isArray(t)||typeof t=="object")?this.reactive(t):t,this.scheduleRerender()},enumerable:!0,configurable:!0})}get component(){return this._component}set component(e){this._component=e||"",this._component&&requestAnimationFrame(()=>{this.connected&&!this.componentInstance&&!this.isLoading&&this.loadComponent(this._component||"")})}render(){return N.jsx("div",{class:"route-view"})}onConnected(){var e;(e=super.onConnected)==null||e.call(this),requestAnimationFrame(()=>{!this.connected||this.isLoading||this.componentInstance||this.component&&this.loadComponent(this.component)})}async loadComponent(e){if(!(!this.connected||this.isLoading||this.componentInstance)){this.isLoading=!0;try{const t=this.componentInstance;if(t&&(t.remove(),this.componentInstance=null),!customElements.get(e)){H.warn(`Component ${e} not found in customElements registry`),this.isLoading=!1;return}H.warn(`WsxView: Creating instance of ${e}`),this.componentInstance=document.createElement(e),Object.keys(this.params).length>0&&(H.warn(`WsxView: Setting initial params on ${e}:`,this.params),Object.entries(this.params).forEach(([p,d])=>{this.componentInstance.setAttribute(p,d)}));const g=this.querySelector(".route-view");if(g){if(H.warn(`WsxView: Appending ${e} to container`),!customElements.get(e)){H.error(`WsxView: Component ${e} is not registered in customElements registry!`),this.isLoading=!1,this.componentInstance=null;return}g.appendChild(this.componentInstance),H.warn(`WsxView: Component ${e} appended successfully, waiting for connectedCallback...`),setTimeout(()=>{this.componentInstance&&this.componentInstance.isConnected?H.warn(`WsxView: Component ${e} is now connected to DOM`):H.error(`WsxView: Component ${e} was not connected to DOM!`)},0)}else H.error("WsxView: Route view container not found"),this.componentInstance=null}catch(t){H.warn(`Error loading component ${e}:`,t),this.componentInstance=null}finally{this.isLoading=!1,H.warn(`WsxView: loadComponent for ${e} completed, isLoading=${this.isLoading}`)}}}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}}Re=Ne;[exports.WsxView,Le]=Ve(Re,[],xe,0,void 0,N.LightComponent).c;Le();const Fe=':host{display:inline-block;min-width:fit-content;min-height:fit-content;width:auto;height:auto}.wsx-link{color:var(--link-color, #007bff);text-decoration:var(--link-decoration, underline);cursor:pointer;transition:color .2s ease;display:inline-block;min-height:1.2em;line-height:1.2}.wsx-link:hover{color:var(--link-hover-color, #0056b3);text-decoration:var(--link-hover-decoration, underline)}.wsx-link:focus{outline:2px solid var(--link-focus-color, var(--focus-color, #dc2626));outline-offset:2px}.wsx-link.active{color:var(--link-active-color, #6c757d);font-weight:var(--link-active-weight, bold)}:host([disabled]) .wsx-link{color:var(--link-disabled-color, #6c757d);cursor:not-allowed;pointer-events:none}:host([external]) .wsx-link:after{content:"↗";font-size:.8em;margin-left:.2em;opacity:.7}:host([variant="button"]) .wsx-link{background-color:var(--button-bg, #007bff);color:var(--button-color, white);padding:.5rem 1rem;border-radius:.25rem;text-decoration:none;display:inline-block}:host([variant="button"]) .wsx-link:hover{background-color:var(--button-hover-bg, #0056b3);color:var(--button-hover-color, white)}:host([variant="tab"]) .wsx-link{padding:.5rem 1rem;border-bottom:2px solid transparent;text-decoration:none}:host([variant="tab"]) .wsx-link.active{border-bottom-color:var(--tab-active-border, #007bff)}';var ie,oe;let ue,Ee,he;function X(r,e,t){return(e=$e(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function qe(r,e,t,n,g,p){function d(s,o,c){return function(i,u){return c&&c(i),s[o].call(i,u)}}function _(s,o){for(var c=0;c<s.length;c++)s[c].call(o);return o}function b(s,o,c,i){if(typeof s!="function"&&(i||s!==void 0))throw new TypeError(o+" must "+(c||"be")+" a function"+(i?"":" or undefined"));return s}function T(s,o,c,i,u,A,k,L,P,E,R,v,m){function h(f){if(!m(f))throw new TypeError("Attempted to access private element on non-instance")}var l,x=o[0],$=o[3],W=!L;if(!W){c||Array.isArray(x)||(x=[x]);var a={},S=[],y=u===3?"get":u===4||v?"set":"value";E?(R||v?a={get:de(function(){return $(this)},i,"get"),set:function(f){o[4](this,f)}}:a[y]=$,R||de(a[y],i,u===2?"":y)):R||(a=Object.getOwnPropertyDescriptor(s,i))}for(var w=s,U=x.length-1;U>=0;U-=c?2:1){var G=x[U],K=c?x[U-1]:void 0,J={},O={kind:["field","accessor","method","getter","setter","class"][u],name:i,metadata:A,addInitializer:(function(f,I){if(f.v)throw Error("attempted to call addInitializer after decoration was finished");b(I,"An initializer","be",!0),k.push(I)}).bind(null,J)};try{if(W)(l=b(G.call(K,w,O),"class decorators","return"))&&(w=l);else{var M,z;O.static=P,O.private=E,E?u===2?M=function(f){return h(f),a.value}:(u<4&&(M=d(a,"get",h)),u!==3&&(z=d(a,"set",h))):(M=function(f){return f[i]},(u<2||u===4)&&(z=function(f,I){f[i]=I}));var Q=O.access={has:E?m.bind():function(f){return i in f}};if(M&&(Q.get=M),z&&(Q.set=z),w=G.call(K,v?{get:a.get,set:a.set}:a[y],O),v){if(typeof w=="object"&&w)(l=b(w.get,"accessor.get"))&&(a.get=l),(l=b(w.set,"accessor.set"))&&(a.set=l),(l=b(w.init,"accessor.init"))&&S.push(l);else if(w!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(w,(R?"field":"method")+" decorators","return")&&(R?S.push(w):a[y]=w)}}finally{J.v=!0}}return(R||v)&&L.push(function(f,I){for(var F=S.length-1;F>=0;F--)I=S[F].call(f,I);return I}),R||W||(E?v?L.push(d(a,"get"),d(a,"set")):L.push(u===2?a[y]:d.call.bind(a[y])):Object.defineProperty(s,i,a)),w}function j(s,o){return Object.defineProperty(s,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:o})}if(arguments.length>=6)var V=p[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(V??null),B=function(s,o,c,i){var u,A,k=[],L=function(y){return Be(y)===s},P=new Map;function E(y){y&&k.push(_.bind(null,y))}for(var R=0;R<o.length;R++){var v=o[R];if(Array.isArray(v)){var m=v[1],h=v[2],l=v.length>3,x=16&m,$=!!(8&m),W=(m&=7)==0,a=h+"/"+$;if(!W&&!l){var S=P.get(a);if(S===!0||S===3&&m!==4||S===4&&m!==3)throw Error("Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: "+h);P.set(a,!(m>2)||m)}T($?s:s.prototype,v,x,l?"#"+h:$e(h),m,i,$?A=A||[]:u=u||[],k,$,l,W,m===1,$&&l?L:c)}}return E(u),E(A),k}(r,e,g,D);return t.length||j(r,D),{e:B,get c(){var s=[];return t.length&&[j(T(r,[t],n,r.name,5,D,s),D),_.bind(null,s,r)]}}}function $e(r){var e=He(r,"string");return typeof e=="symbol"?e:e+""}function He(r,e){if(typeof r!="object"||!r)return r;var t=r[Symbol.toPrimitive];if(t!==void 0){var n=t.call(r,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(r)}function de(r,e,t){typeof e=="symbol"&&(e=(e=e.description)?"["+e+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:t?t+" "+e:e})}catch{}return r}function Be(r){if(Object(r)!==r)throw TypeError("right-hand side of 'in' should be an object, got "+(r!==null?typeof r:"null"));return r}function Ge(r){return r}const fe=re("WsxLink");Ee=[N.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(he=(oe=class extends N.WebComponent{constructor(){super(),X(this,"_autoStyles",Fe),X(this,"to",void 0),X(this,"activeClass",void 0),X(this,"handleClick",p=>{if(p.preventDefault(),!this.to){fe.warn("No 'to' attribute specified");return}if(this.isExternalLink(this.to)){window.open(this.to,"_blank");return}this.replace?window.history.replaceState(null,"",this.to):window.history.pushState(null,"",this.to),window.dispatchEvent(new PopStateEvent("popstate")),fe.debug(`Navigated to: ${this.to}`)}),X(this,"updateActiveState",()=>{var b;const p=window.location.pathname,d=this.exact?p===this.to:p.startsWith(this.to)&&this.to!=="/",_=(b=this.shadowRoot)==null?void 0:b.querySelector("a");_&&(d?(_.classList.add(this.activeClass),this.setAttribute("active","")):(_.classList.remove(this.activeClass),this.removeAttribute("active")))});const[e,t]=this.useState("to","");Object.defineProperty(this,"to",{get:e,set:t,enumerable:!0,configurable:!0});const[n,g]=this.useState("activeClass","active");Object.defineProperty(this,"activeClass",{get:n,set:g,enumerable:!0,configurable:!0})}get replace(){return this.hasAttribute("replace")}get exact(){return this.hasAttribute("exact")}render(){return N.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},N.jsx("slot",null))}onConnected(){var t;(t=super.onConnected)==null||t.call(this),this.to=this.to||"",this.activeClass=this.activeClass||"active";const e=this.shadowRoot.querySelector(".wsx-link");e&&(e.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){var e;(e=super.onDisconnected)==null||e.call(this),window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(e,t,n){switch(e){case"to":this.to=n||"",this.updateActiveState();break;case"replace":this.replace=n!==null&&n!=="false";break;case"active-class":this.activeClass=n||"active",this.updateActiveState();break;case"exact":this.exact=n!==null&&n!=="false",this.updateActiveState();break}}isExternalLink(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("mailto:")||e.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,ue]=qe(oe,[],Ee,0,void 0,N.WebComponent).c,oe),ie=class extends Ge{constructor(){super(exports.WsxLink),X(this,"observedAttributes",["to","replace","active-class","exact"]),ue()}},X(ie,he,void 0),ie);exports.RouterUtils=ne;