@wsxjs/wsx-router 0.0.13 → 0.0.15

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 I=require("@wsxjs/wsx-core"),nt=":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";var ft;let pt,vt;function Y(r,t,e){return(t=mt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function xt(r,t,e,n,g,R){function C(i,c,u){return function(s,a){return u&&u(s),i[c].call(s,a)}}function O(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function b(i,c,u,s){if(typeof i!="function"&&(s||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(s?"":" or undefined"));return i}function T(i,c,u,s,a,$,L,j,N,y,m,f,p){function w(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],k=c[3],_=!j;if(!_){u||Array.isArray(x)||(x=[x]);var o={},E=[],v=a===3?"get":a===4||f?"set":"value";y?(m||f?o={get:it(function(){return k(this)},s,"get"),set:function(l){c[4](this,l)}}:o[v]=k,m||it(o[v],s,a===2?"":v)):m||(o=Object.getOwnPropertyDescriptor(i,s))}for(var d=i,P=x.length-1;P>=0;P-=u?2:1){var H=x[P],K=u?x[P-1]:void 0,Q={},W={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:$,addInitializer:(function(l,S){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");b(S,"An initializer","be",!0),L.push(S)}).bind(null,Q)};try{if(_)(h=b(H.call(K,d,W),"class decorators","return"))&&(d=h);else{var A,z;W.static=N,W.private=y,y?a===2?A=function(l){return w(l),o.value}:(a<4&&(A=C(o,"get",w)),a!==3&&(z=C(o,"set",w))):(A=function(l){return l[s]},(a<2||a===4)&&(z=function(l,S){l[s]=S}));var J=W.access={has:y?p.bind():function(l){return s in l}};if(A&&(J.get=A),z&&(J.set=z),d=H.call(K,f?{get:o.get,set:o.set}:o[v],W),f){if(typeof d=="object"&&d)(h=b(d.get,"accessor.get"))&&(o.get=h),(h=b(d.set,"accessor.set"))&&(o.set=h),(h=b(d.init,"accessor.init"))&&E.push(h);else if(d!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(d,(m?"field":"method")+" decorators","return")&&(m?E.push(d):o[v]=d)}}finally{Q.v=!0}}return(m||f)&&j.push(function(l,S){for(var V=E.length-1;V>=0;V--)S=E[V].call(l,S);return S}),m||_||(y?f?j.push(C(o,"get"),C(o,"set")):j.push(a===2?o[v]:C.call.bind(o[v])):Object.defineProperty(i,s,o)),d}function U(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var q=R[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(q??null),X=function(i,c,u,s){var a,$,L=[],j=function(v){return Et(v)===i},N=new Map;function y(v){v&&L.push(O.bind(null,v))}for(var m=0;m<c.length;m++){var f=c[m];if(Array.isArray(f)){var p=f[1],w=f[2],h=f.length>3,x=16&p,k=!!(8&p),_=(p&=7)==0,o=w+"/"+k;if(!_&&!h){var E=N.get(o);if(E===!0||E===3&&p!==4||E===4&&p!==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: "+w);N.set(o,!(p>2)||p)}T(k?i:i.prototype,f,x,h?"#"+w:mt(w),p,s,k?$=$||[]:a=a||[],L,k,h,_,p===1,k&&h?j:u)}}return y(a),y($),L}(r,t,g,D);return e.length||U(r,D),{e:X,get c(){var i=[];return e.length&&[U(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function mt(r){var t=kt(r,"string");return typeof t=="symbol"?t:t+""}function kt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function it(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function Et(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 B=I.createLogger("WsxRouter");vt=[I.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class St extends I.LightComponent{constructor(){super({styles:nt,styleName:"wsx-router"}),Y(this,"_autoStyles",nt),Y(this,"views",new Map),Y(this,"currentView",null),Y(this,"handleRouteChange",()=>{const t=window.location.pathname;B.debug(`Route changed to: ${t}`),this.currentView&&(this.currentView.style.display="none",B.debug("Hiding previous view"));const e=this.matchRoute(t);if(e){e.style.display="block",this.currentView=e,B.debug(`Showing view for route: ${e.getAttribute("route")}`);const n=this.extractParams(e.getAttribute("route")||"/",t);n&&e.setAttribute("params",JSON.stringify(n))}else B.warn(`No view found for path: ${t}`);this.dispatchEvent(new CustomEvent("route-changed",{detail:{path:t,view:e},bubbles:!0,composed:!0}))}),Y(this,"interceptLinks",t=>{const e=t.target.closest("a");if(!e)return;const n=e.getAttribute("href");!n||n.startsWith("http")||n.startsWith("#")||(t.preventDefault(),this.navigate(n))})}render(){return I.jsx("div",{class:"router-outlet"})}onConnected(){B.debug("WsxRouter connected to DOM"),this.collectViews(),B.debug("WsxRouter collected views:",this.views.size),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),this.handleRouteChange()}onDisconnected(){window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()==="wsx-view");B.debug("WsxRouter found views:",t.length),t.forEach(e=>{const n=e.getAttribute("route")||"/";this.views.set(n,e),e.style.display="none",B.debug(`WsxRouter hiding view for route: ${n}`)})}matchRoute(t){if(this.views.has(t))return this.views.get(t);for(const[e,n]of this.views)if(e.includes(":")){const g=e.replace(/:[^/]+/g,"([^/]+)");if(new RegExp(`^${g}$`).test(t))return n}return this.views.get("*")||null}extractParams(t,e){var b;if(!t.includes(":"))return null;const n=((b=t.match(/:([^/]+)/g))==null?void 0:b.map(T=>T.slice(1)))||[],g=t.replace(/:[^/]+/g,"([^/]+)"),R=new RegExp(`^${g}$`),C=e.match(R);if(!C||!n.length)return null;const O={};return n.forEach((T,U)=>{O[T]=C[U+1]}),O}navigate(t){window.history.pushState(null,"",t),this.handleRouteChange()}}ft=St;[exports.WsxRouter,pt]=xt(ft,[],vt,0,void 0,I.LightComponent).c;pt();const ot=":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 Z,F;let st,gt,at;function G(r,t,e){return(t=bt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Ct(r,t,e,n,g,R){function C(i,c,u){return function(s,a){return u&&u(s),i[c].call(s,a)}}function O(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function b(i,c,u,s){if(typeof i!="function"&&(s||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(s?"":" or undefined"));return i}function T(i,c,u,s,a,$,L,j,N,y,m,f,p){function w(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],k=c[3],_=!j;if(!_){u||Array.isArray(x)||(x=[x]);var o={},E=[],v=a===3?"get":a===4||f?"set":"value";y?(m||f?o={get:ct(function(){return k(this)},s,"get"),set:function(l){c[4](this,l)}}:o[v]=k,m||ct(o[v],s,a===2?"":v)):m||(o=Object.getOwnPropertyDescriptor(i,s))}for(var d=i,P=x.length-1;P>=0;P-=u?2:1){var H=x[P],K=u?x[P-1]:void 0,Q={},W={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:$,addInitializer:(function(l,S){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");b(S,"An initializer","be",!0),L.push(S)}).bind(null,Q)};try{if(_)(h=b(H.call(K,d,W),"class decorators","return"))&&(d=h);else{var A,z;W.static=N,W.private=y,y?a===2?A=function(l){return w(l),o.value}:(a<4&&(A=C(o,"get",w)),a!==3&&(z=C(o,"set",w))):(A=function(l){return l[s]},(a<2||a===4)&&(z=function(l,S){l[s]=S}));var J=W.access={has:y?p.bind():function(l){return s in l}};if(A&&(J.get=A),z&&(J.set=z),d=H.call(K,f?{get:o.get,set:o.set}:o[v],W),f){if(typeof d=="object"&&d)(h=b(d.get,"accessor.get"))&&(o.get=h),(h=b(d.set,"accessor.set"))&&(o.set=h),(h=b(d.init,"accessor.init"))&&E.push(h);else if(d!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(d,(m?"field":"method")+" decorators","return")&&(m?E.push(d):o[v]=d)}}finally{Q.v=!0}}return(m||f)&&j.push(function(l,S){for(var V=E.length-1;V>=0;V--)S=E[V].call(l,S);return S}),m||_||(y?f?j.push(C(o,"get"),C(o,"set")):j.push(a===2?o[v]:C.call.bind(o[v])):Object.defineProperty(i,s,o)),d}function U(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var q=R[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(q??null),X=function(i,c,u,s){var a,$,L=[],j=function(v){return jt(v)===i},N=new Map;function y(v){v&&L.push(O.bind(null,v))}for(var m=0;m<c.length;m++){var f=c[m];if(Array.isArray(f)){var p=f[1],w=f[2],h=f.length>3,x=16&p,k=!!(8&p),_=(p&=7)==0,o=w+"/"+k;if(!_&&!h){var E=N.get(o);if(E===!0||E===3&&p!==4||E===4&&p!==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: "+w);N.set(o,!(p>2)||p)}T(k?i:i.prototype,f,x,h?"#"+w:bt(w),p,s,k?$=$||[]:a=a||[],L,k,h,_,p===1,k&&h?j:u)}}return y(a),y($),L}(r,t,g,D);return e.length||U(r,D),{e:X,get c(){var i=[];return e.length&&[U(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function bt(r){var t=Rt(r,"string");return typeof t=="symbol"?t:t+""}function Rt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ct(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function jt(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 _t(r){return r}const tt=I.createLogger("WsxView");gt=[I.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;new(at=(F=class extends I.LightComponent{constructor(){super({styles:ot,styleName:"wsx-view"}),G(this,"_autoStyles",ot),G(this,"component",null),G(this,"params",{}),G(this,"componentInstance",null)}render(){return I.jsx("div",{class:"route-view"})}onConnected(){const t=this.getAttribute("component");t&&!this.componentInstance&&this.loadComponent(t)}onAttributeChanged(t,e,n){if(t==="component"&&n&&!this.componentInstance)this.loadComponent(n);else if(t==="params"&&this.componentInstance)try{this.params=JSON.parse(n),Object.entries(this.params).forEach(([g,R])=>{this.componentInstance.setAttribute(g,R)})}catch(g){tt.error("Failed to parse params:",g)}}async loadComponent(t){if(this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null),!customElements.get(t)){tt.warn(`Component ${t} not found in customElements registry`);return}this.componentInstance=document.createElement(t),Object.keys(this.params).length>0&&Object.entries(this.params).forEach(([g,R])=>{this.componentInstance.setAttribute(g,R)});const n=this.querySelector(".route-view");n?n.appendChild(this.componentInstance):tt.error("Route view container not found")}onDisconnected(){this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}},[exports.WsxView,st]=Ct(F,[],gt,0,void 0,I.LightComponent).c,F),Z=class extends _t{constructor(){super(exports.WsxView),G(this,"observedAttributes",["route","component","params"]),st()}},G(Z,at,void 0),Z);const $t=':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, #007bff);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 et,rt;let lt,yt,ut;function M(r,t,e){return(t=wt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function Lt(r,t,e,n,g,R){function C(i,c,u){return function(s,a){return u&&u(s),i[c].call(s,a)}}function O(i,c){for(var u=0;u<i.length;u++)i[u].call(c);return c}function b(i,c,u,s){if(typeof i!="function"&&(s||i!==void 0))throw new TypeError(c+" must "+(u||"be")+" a function"+(s?"":" or undefined"));return i}function T(i,c,u,s,a,$,L,j,N,y,m,f,p){function w(l){if(!p(l))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],k=c[3],_=!j;if(!_){u||Array.isArray(x)||(x=[x]);var o={},E=[],v=a===3?"get":a===4||f?"set":"value";y?(m||f?o={get:ht(function(){return k(this)},s,"get"),set:function(l){c[4](this,l)}}:o[v]=k,m||ht(o[v],s,a===2?"":v)):m||(o=Object.getOwnPropertyDescriptor(i,s))}for(var d=i,P=x.length-1;P>=0;P-=u?2:1){var H=x[P],K=u?x[P-1]:void 0,Q={},W={kind:["field","accessor","method","getter","setter","class"][a],name:s,metadata:$,addInitializer:(function(l,S){if(l.v)throw Error("attempted to call addInitializer after decoration was finished");b(S,"An initializer","be",!0),L.push(S)}).bind(null,Q)};try{if(_)(h=b(H.call(K,d,W),"class decorators","return"))&&(d=h);else{var A,z;W.static=N,W.private=y,y?a===2?A=function(l){return w(l),o.value}:(a<4&&(A=C(o,"get",w)),a!==3&&(z=C(o,"set",w))):(A=function(l){return l[s]},(a<2||a===4)&&(z=function(l,S){l[s]=S}));var J=W.access={has:y?p.bind():function(l){return s in l}};if(A&&(J.get=A),z&&(J.set=z),d=H.call(K,f?{get:o.get,set:o.set}:o[v],W),f){if(typeof d=="object"&&d)(h=b(d.get,"accessor.get"))&&(o.get=h),(h=b(d.set,"accessor.set"))&&(o.set=h),(h=b(d.init,"accessor.init"))&&E.push(h);else if(d!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else b(d,(m?"field":"method")+" decorators","return")&&(m?E.push(d):o[v]=d)}}finally{Q.v=!0}}return(m||f)&&j.push(function(l,S){for(var V=E.length-1;V>=0;V--)S=E[V].call(l,S);return S}),m||_||(y?f?j.push(C(o,"get"),C(o,"set")):j.push(a===2?o[v]:C.call.bind(o[v])):Object.defineProperty(i,s,o)),d}function U(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var q=R[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(q??null),X=function(i,c,u,s){var a,$,L=[],j=function(v){return At(v)===i},N=new Map;function y(v){v&&L.push(O.bind(null,v))}for(var m=0;m<c.length;m++){var f=c[m];if(Array.isArray(f)){var p=f[1],w=f[2],h=f.length>3,x=16&p,k=!!(8&p),_=(p&=7)==0,o=w+"/"+k;if(!_&&!h){var E=N.get(o);if(E===!0||E===3&&p!==4||E===4&&p!==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: "+w);N.set(o,!(p>2)||p)}T(k?i:i.prototype,f,x,h?"#"+w:wt(w),p,s,k?$=$||[]:a=a||[],L,k,h,_,p===1,k&&h?j:u)}}return y(a),y($),L}(r,t,g,D);return e.length||U(r,D),{e:X,get c(){var i=[];return e.length&&[U(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function wt(r){var t=Wt(r,"string");return typeof t=="symbol"?t:t+""}function Wt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ht(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function At(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 It(r){return r}const dt=I.createLogger("WsxLink");yt=[I.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(ut=(rt=class extends I.WebComponent{constructor(...t){super(...t),M(this,"_autoStyles",$t),M(this,"to",""),M(this,"replace",!1),M(this,"activeClass","active"),M(this,"exact",!1),M(this,"handleClick",e=>{if(e.preventDefault(),!this.to){dt.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")),dt.debug(`Navigated to: ${this.to}`)}),M(this,"updateActiveState",()=>{var R;const e=window.location.pathname,n=this.exact?e===this.to:e.startsWith(this.to)&&this.to!=="/",g=(R=this.shadowRoot)==null?void 0:R.querySelector("a");g&&(n?(g.classList.add(this.activeClass),this.setAttribute("active","")):(g.classList.remove(this.activeClass),this.removeAttribute("active")))})}render(){return I.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},I.jsx("slot",null))}onConnected(){this.to=this.getAttribute("to")||"",this.replace=this.hasAttribute("replace"),this.activeClass=this.getAttribute("active-class")||"active",this.exact=this.hasAttribute("exact");const t=this.shadowRoot.querySelector(".wsx-link");t&&(t.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(t,e,n){switch(t){case"to":this.to=n||"",this.rerender(),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(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("mailto:")||t.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,lt]=Lt(rt,[],yt,0,void 0,I.WebComponent).c,rt),et=class extends It{constructor(){super(exports.WsxLink),M(this,"observedAttributes",["to","replace","active-class","exact"]),lt()}},M(et,ut,void 0),et);const Ot=I.createLogger("RouterUtils");class Tt{static navigate(t,e=!1){e?window.history.replaceState(null,"",t):window.history.pushState(null,"",t),window.dispatchEvent(new PopStateEvent("popstate")),Ot.debug(`Navigated to: ${t} (replace: ${e})`)}static getCurrentRoute(){const t=new URL(window.location.href);return{path:t.pathname,params:{},query:Object.fromEntries(t.searchParams.entries()),hash:t.hash.slice(1)}}static parseRoute(t,e){var n;if(t===e)return{route:t,params:{},exact:!0};if(t==="*")return{route:t,params:{},exact:!1};if(t.includes(":")){const g=((n=t.match(/:([^/]+)/g))==null?void 0:n.map(b=>b.slice(1)))||[],R=t.replace(/:[^/]+/g,"([^/]+)"),C=new RegExp(`^${R}$`),O=e.match(C);if(O&&g.length>0){const b={};return g.forEach((T,U)=>{b[T]=O[U+1]}),{route:t,params:b,exact:!0}}}if(t.endsWith("/*")){const g=t.slice(0,-2);if(e.startsWith(g))return{route:t,params:{},exact:!1}}return null}static buildPath(t,e={}){let n=t;return Object.entries(e).forEach(([g,R])=>{n=n.replace(`:${g}`,encodeURIComponent(R))}),n}static isRouteActive(t,e=!1){const n=window.location.pathname;return e?n===t:t==="/"?n==="/":n.startsWith(t)}static getRouteDepth(t){return t.split("/").filter(e=>e.length>0).length}static getParentRoute(t){const e=t.split("/").filter(n=>n.length>0);return e.length<=1?"/":(e.pop(),"/"+e.join("/"))}static joinPaths(...t){return t.map(e=>e.replace(/^\/+|\/+$/g,"")).filter(e=>e.length>0).join("/").replace(/^/,"/")}static isExternalUrl(t){return/^https?:\/\//.test(t)||/^mailto:/.test(t)||/^tel:/.test(t)}static getQueryParam(t){return new URL(window.location.href).searchParams.get(t)}static setQueryParam(t,e,n=!1){const g=new URL(window.location.href);g.searchParams.set(t,e);const R=g.pathname+g.search+g.hash;this.navigate(R,n)}static removeQueryParam(t,e=!1){const n=new URL(window.location.href);n.searchParams.delete(t);const g=n.pathname+n.search+n.hash;this.navigate(g,e)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(t){this.navigate(t,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(t){const e=()=>{const n=this.getCurrentRoute();t(n)};return window.addEventListener("popstate",e),document.addEventListener("route-changed",e),()=>{window.removeEventListener("popstate",e),document.removeEventListener("route-changed",e)}}}exports.RouterUtils=Tt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@wsxjs/wsx-core"),nt=":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";var ft;let pt,dt;function X(r,t,e){return(t=mt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function wt(r,t,e,n,v,j){function S(i,c,l){return function(a,o){return l&&l(a),i[c].call(a,o)}}function O(i,c){for(var l=0;l<i.length;l++)i[l].call(c);return c}function y(i,c,l,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(l||"be")+" a function"+(a?"":" or undefined"));return i}function T(i,c,l,a,o,_,W,L,N,b,g,p,d){function w(u){if(!d(u))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],E=c[3],$=!L;if(!$){l||Array.isArray(x)||(x=[x]);var s={},C=[],m=o===3?"get":o===4||p?"set":"value";b?(g||p?s={get:it(function(){return E(this)},a,"get"),set:function(u){c[4](this,u)}}:s[m]=E,g||it(s[m],a,o===2?"":m)):g||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,P=x.length-1;P>=0;P-=l?2:1){var q=x[P],H=l?x[P-1]:void 0,K={},A={kind:["field","accessor","method","getter","setter","class"][o],name:a,metadata:_,addInitializer:(function(u,R){if(u.v)throw Error("attempted to call addInitializer after decoration was finished");y(R,"An initializer","be",!0),W.push(R)}).bind(null,K)};try{if($)(h=y(q.call(H,f,A),"class decorators","return"))&&(f=h);else{var k,U;A.static=N,A.private=b,b?o===2?k=function(u){return w(u),s.value}:(o<4&&(k=S(s,"get",w)),o!==3&&(U=S(s,"set",w))):(k=function(u){return u[a]},(o<2||o===4)&&(U=function(u,R){u[a]=R}));var Q=A.access={has:b?d.bind():function(u){return a in u}};if(k&&(Q.get=k),U&&(Q.set=U),f=q.call(H,p?{get:s.get,set:s.set}:s[m],A),p){if(typeof f=="object"&&f)(h=y(f.get,"accessor.get"))&&(s.get=h),(h=y(f.set,"accessor.set"))&&(s.set=h),(h=y(f.init,"accessor.init"))&&C.push(h);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(f,(g?"field":"method")+" decorators","return")&&(g?C.push(f):s[m]=f)}}finally{K.v=!0}}return(g||p)&&L.push(function(u,R){for(var V=C.length-1;V>=0;V--)R=C[V].call(u,R);return R}),g||$||(b?p?L.push(S(s,"get"),S(s,"set")):L.push(o===2?s[m]:S.call.bind(s[m])):Object.defineProperty(i,a,s)),f}function z(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=j[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(M??null),G=function(i,c,l,a){var o,_,W=[],L=function(m){return Et(m)===i},N=new Map;function b(m){m&&W.push(O.bind(null,m))}for(var g=0;g<c.length;g++){var p=c[g];if(Array.isArray(p)){var d=p[1],w=p[2],h=p.length>3,x=16&d,E=!!(8&d),$=(d&=7)==0,s=w+"/"+E;if(!$&&!h){var C=N.get(s);if(C===!0||C===3&&d!==4||C===4&&d!==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: "+w);N.set(s,!(d>2)||d)}T(E?i:i.prototype,p,x,h?"#"+w:mt(w),d,a,E?_=_||[]:o=o||[],W,E,h,$,d===1,E&&h?L:l)}}return b(o),b(_),W}(r,t,v,D);return e.length||z(r,D),{e:G,get c(){var i=[];return e.length&&[z(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function mt(r){var t=xt(r,"string");return typeof t=="symbol"?t:t+""}function xt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function it(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function Et(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 J=I.createLogger("WsxRouter");dt=[I.autoRegister({tagName:"wsx-router"})];exports.WsxRouter=void 0;class Ct extends I.LightComponent{constructor(){super({styles:nt,styleName:"wsx-router"}),X(this,"_autoStyles",nt),X(this,"views",new Map),X(this,"currentView",null),X(this,"handleRouteChange",()=>{const t=window.location.pathname;J.debug(`Route changed to: ${t}`),this.currentView&&(this.currentView.style.display="none",J.debug("Hiding previous view"));const e=this.matchRoute(t);if(e){e.style.display="block",this.currentView=e,J.debug(`Showing view for route: ${e.getAttribute("route")}`);const n=this.extractParams(e.getAttribute("route")||"/",t);n&&e.setAttribute("params",JSON.stringify(n))}else J.warn(`No view found for path: ${t}`);this.dispatchEvent(new CustomEvent("route-changed",{detail:{path:t,view:e},bubbles:!0,composed:!0}))}),X(this,"interceptLinks",t=>{const e=t.target.closest("a");if(!e)return;const n=e.getAttribute("href");!n||n.startsWith("http")||n.startsWith("#")||(t.preventDefault(),this.navigate(n))})}render(){return I.jsx("div",{class:"router-outlet"})}onConnected(){J.debug("WsxRouter connected to DOM"),this.collectViews(),J.debug("WsxRouter collected views:",this.views.size),window.addEventListener("popstate",this.handleRouteChange),this.addEventListener("click",this.interceptLinks),this.handleRouteChange()}onDisconnected(){window.removeEventListener("popstate",this.handleRouteChange)}collectViews(){const t=Array.from(this.children).filter(e=>e.tagName.toLowerCase()==="wsx-view");J.debug("WsxRouter found views:",t.length),t.forEach(e=>{const n=e.getAttribute("route")||"/";this.views.set(n,e),e.style.display="none",J.debug(`WsxRouter hiding view for route: ${n}`)})}matchRoute(t){if(this.views.has(t))return this.views.get(t);for(const[e,n]of this.views)if(e.includes(":")){const v=e.replace(/:[^/]+/g,"([^/]+)");if(new RegExp(`^${v}$`).test(t))return n}return this.views.get("*")||null}extractParams(t,e){var y;if(!t.includes(":"))return null;const n=((y=t.match(/:([^/]+)/g))==null?void 0:y.map(T=>T.slice(1)))||[],v=t.replace(/:[^/]+/g,"([^/]+)"),j=new RegExp(`^${v}$`),S=e.match(j);if(!S||!n.length)return null;const O={};return n.forEach((T,z)=>{O[T]=S[z+1]}),O}navigate(t){window.history.pushState(null,"",t),this.handleRouteChange()}}ft=Ct;[exports.WsxRouter,pt]=wt(ft,[],dt,0,void 0,I.LightComponent).c;pt();const Rt=":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 Z,F;let st,gt,at;function Y(r,t,e){return(t=vt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function St(r,t,e,n,v,j){function S(i,c,l){return function(a,o){return l&&l(a),i[c].call(a,o)}}function O(i,c){for(var l=0;l<i.length;l++)i[l].call(c);return c}function y(i,c,l,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(l||"be")+" a function"+(a?"":" or undefined"));return i}function T(i,c,l,a,o,_,W,L,N,b,g,p,d){function w(u){if(!d(u))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],E=c[3],$=!L;if(!$){l||Array.isArray(x)||(x=[x]);var s={},C=[],m=o===3?"get":o===4||p?"set":"value";b?(g||p?s={get:ot(function(){return E(this)},a,"get"),set:function(u){c[4](this,u)}}:s[m]=E,g||ot(s[m],a,o===2?"":m)):g||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,P=x.length-1;P>=0;P-=l?2:1){var q=x[P],H=l?x[P-1]:void 0,K={},A={kind:["field","accessor","method","getter","setter","class"][o],name:a,metadata:_,addInitializer:(function(u,R){if(u.v)throw Error("attempted to call addInitializer after decoration was finished");y(R,"An initializer","be",!0),W.push(R)}).bind(null,K)};try{if($)(h=y(q.call(H,f,A),"class decorators","return"))&&(f=h);else{var k,U;A.static=N,A.private=b,b?o===2?k=function(u){return w(u),s.value}:(o<4&&(k=S(s,"get",w)),o!==3&&(U=S(s,"set",w))):(k=function(u){return u[a]},(o<2||o===4)&&(U=function(u,R){u[a]=R}));var Q=A.access={has:b?d.bind():function(u){return a in u}};if(k&&(Q.get=k),U&&(Q.set=U),f=q.call(H,p?{get:s.get,set:s.set}:s[m],A),p){if(typeof f=="object"&&f)(h=y(f.get,"accessor.get"))&&(s.get=h),(h=y(f.set,"accessor.set"))&&(s.set=h),(h=y(f.init,"accessor.init"))&&C.push(h);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(f,(g?"field":"method")+" decorators","return")&&(g?C.push(f):s[m]=f)}}finally{K.v=!0}}return(g||p)&&L.push(function(u,R){for(var V=C.length-1;V>=0;V--)R=C[V].call(u,R);return R}),g||$||(b?p?L.push(S(s,"get"),S(s,"set")):L.push(o===2?s[m]:S.call.bind(s[m])):Object.defineProperty(i,a,s)),f}function z(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=j[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(M??null),G=function(i,c,l,a){var o,_,W=[],L=function(m){return Lt(m)===i},N=new Map;function b(m){m&&W.push(O.bind(null,m))}for(var g=0;g<c.length;g++){var p=c[g];if(Array.isArray(p)){var d=p[1],w=p[2],h=p.length>3,x=16&d,E=!!(8&d),$=(d&=7)==0,s=w+"/"+E;if(!$&&!h){var C=N.get(s);if(C===!0||C===3&&d!==4||C===4&&d!==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: "+w);N.set(s,!(d>2)||d)}T(E?i:i.prototype,p,x,h?"#"+w:vt(w),d,a,E?_=_||[]:o=o||[],W,E,h,$,d===1,E&&h?L:l)}}return b(o),b(_),W}(r,t,v,D);return e.length||z(r,D),{e:G,get c(){var i=[];return e.length&&[z(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function vt(r){var t=jt(r,"string");return typeof t=="symbol"?t:t+""}function jt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function ot(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function Lt(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 $t(r){return r}const tt=I.createLogger("WsxView");gt=[I.autoRegister({tagName:"wsx-view"})];exports.WsxView=void 0;new(at=(F=class extends I.LightComponent{constructor(){super({styles:Rt,styleName:"wsx-view"}),Y(this,"component",null),Y(this,"params",{}),Y(this,"componentInstance",null)}render(){return I.jsx("div",{class:"route-view"})}onConnected(){const t=this.getAttribute("component");t&&!this.componentInstance&&this.loadComponent(t)}onAttributeChanged(t,e,n){if(t==="component"&&n&&!this.componentInstance)this.loadComponent(n);else if(t==="params"&&this.componentInstance)try{this.params=JSON.parse(n),Object.entries(this.params).forEach(([v,j])=>{this.componentInstance.setAttribute(v,j)})}catch(v){tt.error("Failed to parse params:",v)}}async loadComponent(t){if(this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null),!customElements.get(t)){tt.warn(`Component ${t} not found in customElements registry`);return}this.componentInstance=document.createElement(t),Object.keys(this.params).length>0&&Object.entries(this.params).forEach(([v,j])=>{this.componentInstance.setAttribute(v,j)});const n=this.querySelector(".route-view");n?n.appendChild(this.componentInstance):tt.error("Route view container not found")}onDisconnected(){this.componentInstance&&(this.componentInstance.remove(),this.componentInstance=null)}},[exports.WsxView,st]=St(F,[],gt,0,void 0,I.LightComponent).c,F),Z=class extends $t{constructor(){super(exports.WsxView),Y(this,"observedAttributes",["route","component","params"]),st()}},Y(Z,at,void 0),Z);var et,rt;let ct,yt,ut;function B(r,t,e){return(t=bt(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function _t(r,t,e,n,v,j){function S(i,c,l){return function(a,o){return l&&l(a),i[c].call(a,o)}}function O(i,c){for(var l=0;l<i.length;l++)i[l].call(c);return c}function y(i,c,l,a){if(typeof i!="function"&&(a||i!==void 0))throw new TypeError(c+" must "+(l||"be")+" a function"+(a?"":" or undefined"));return i}function T(i,c,l,a,o,_,W,L,N,b,g,p,d){function w(u){if(!d(u))throw new TypeError("Attempted to access private element on non-instance")}var h,x=c[0],E=c[3],$=!L;if(!$){l||Array.isArray(x)||(x=[x]);var s={},C=[],m=o===3?"get":o===4||p?"set":"value";b?(g||p?s={get:lt(function(){return E(this)},a,"get"),set:function(u){c[4](this,u)}}:s[m]=E,g||lt(s[m],a,o===2?"":m)):g||(s=Object.getOwnPropertyDescriptor(i,a))}for(var f=i,P=x.length-1;P>=0;P-=l?2:1){var q=x[P],H=l?x[P-1]:void 0,K={},A={kind:["field","accessor","method","getter","setter","class"][o],name:a,metadata:_,addInitializer:(function(u,R){if(u.v)throw Error("attempted to call addInitializer after decoration was finished");y(R,"An initializer","be",!0),W.push(R)}).bind(null,K)};try{if($)(h=y(q.call(H,f,A),"class decorators","return"))&&(f=h);else{var k,U;A.static=N,A.private=b,b?o===2?k=function(u){return w(u),s.value}:(o<4&&(k=S(s,"get",w)),o!==3&&(U=S(s,"set",w))):(k=function(u){return u[a]},(o<2||o===4)&&(U=function(u,R){u[a]=R}));var Q=A.access={has:b?d.bind():function(u){return a in u}};if(k&&(Q.get=k),U&&(Q.set=U),f=q.call(H,p?{get:s.get,set:s.set}:s[m],A),p){if(typeof f=="object"&&f)(h=y(f.get,"accessor.get"))&&(s.get=h),(h=y(f.set,"accessor.set"))&&(s.set=h),(h=y(f.init,"accessor.init"))&&C.push(h);else if(f!==void 0)throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0")}else y(f,(g?"field":"method")+" decorators","return")&&(g?C.push(f):s[m]=f)}}finally{K.v=!0}}return(g||p)&&L.push(function(u,R){for(var V=C.length-1;V>=0;V--)R=C[V].call(u,R);return R}),g||$||(b?p?L.push(S(s,"get"),S(s,"set")):L.push(o===2?s[m]:S.call.bind(s[m])):Object.defineProperty(i,a,s)),f}function z(i,c){return Object.defineProperty(i,Symbol.metadata||Symbol.for("Symbol.metadata"),{configurable:!0,enumerable:!0,value:c})}if(arguments.length>=6)var M=j[Symbol.metadata||Symbol.for("Symbol.metadata")];var D=Object.create(M??null),G=function(i,c,l,a){var o,_,W=[],L=function(m){return At(m)===i},N=new Map;function b(m){m&&W.push(O.bind(null,m))}for(var g=0;g<c.length;g++){var p=c[g];if(Array.isArray(p)){var d=p[1],w=p[2],h=p.length>3,x=16&d,E=!!(8&d),$=(d&=7)==0,s=w+"/"+E;if(!$&&!h){var C=N.get(s);if(C===!0||C===3&&d!==4||C===4&&d!==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: "+w);N.set(s,!(d>2)||d)}T(E?i:i.prototype,p,x,h?"#"+w:bt(w),d,a,E?_=_||[]:o=o||[],W,E,h,$,d===1,E&&h?L:l)}}return b(o),b(_),W}(r,t,v,D);return e.length||z(r,D),{e:G,get c(){var i=[];return e.length&&[z(T(r,[e],n,r.name,5,D,i),D),O.bind(null,i,r)]}}}function bt(r){var t=Wt(r,"string");return typeof t=="symbol"?t:t+""}function Wt(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var n=e.call(r,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function lt(r,t,e){typeof t=="symbol"&&(t=(t=t.description)?"["+t+"]":"");try{Object.defineProperty(r,"name",{configurable:!0,value:e?e+" "+t:t})}catch{}return r}function At(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 kt(r){return r}const ht=I.createLogger("WsxLink");yt=[I.autoRegister({tagName:"wsx-link"})];exports.WsxLink=void 0;new(ut=(rt=class extends I.WebComponent{constructor(...t){super(...t),B(this,"to",""),B(this,"replace",!1),B(this,"activeClass","active"),B(this,"exact",!1),B(this,"handleClick",e=>{if(e.preventDefault(),!this.to){ht.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")),ht.debug(`Navigated to: ${this.to}`)}),B(this,"updateActiveState",()=>{var j;const e=window.location.pathname,n=this.exact?e===this.to:e.startsWith(this.to)&&this.to!=="/",v=(j=this.shadowRoot)==null?void 0:j.querySelector("a");v&&(n?(v.classList.add(this.activeClass),this.setAttribute("active","")):(v.classList.remove(this.activeClass),this.removeAttribute("active")))})}render(){return I.jsx("a",{href:this.to,class:"wsx-link",onClick:this.handleClick,part:"link"},I.jsx("slot",null))}onConnected(){this.to=this.getAttribute("to")||"",this.replace=this.hasAttribute("replace"),this.activeClass=this.getAttribute("active-class")||"active",this.exact=this.hasAttribute("exact");const t=this.shadowRoot.querySelector(".wsx-link");t&&(t.href=this.to),window.addEventListener("popstate",this.updateActiveState),document.addEventListener("route-changed",this.updateActiveState),this.updateActiveState()}onDisconnected(){window.removeEventListener("popstate",this.updateActiveState),document.removeEventListener("route-changed",this.updateActiveState)}onAttributeChanged(t,e,n){switch(t){case"to":this.to=n||"",this.rerender(),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(t){return t.startsWith("http://")||t.startsWith("https://")||t.startsWith("mailto:")||t.startsWith("tel:")}navigate(){this.to&&this.handleClick(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}},[exports.WsxLink,ct]=_t(rt,[],yt,0,void 0,I.WebComponent).c,rt),et=class extends kt{constructor(){super(exports.WsxLink),B(this,"observedAttributes",["to","replace","active-class","exact"]),ct()}},B(et,ut,void 0),et);const It=I.createLogger("RouterUtils");class Ot{static navigate(t,e=!1){e?window.history.replaceState(null,"",t):window.history.pushState(null,"",t),window.dispatchEvent(new PopStateEvent("popstate")),It.debug(`Navigated to: ${t} (replace: ${e})`)}static getCurrentRoute(){const t=new URL(window.location.href);return{path:t.pathname,params:{},query:Object.fromEntries(t.searchParams.entries()),hash:t.hash.slice(1)}}static parseRoute(t,e){var n;if(t===e)return{route:t,params:{},exact:!0};if(t==="*")return{route:t,params:{},exact:!1};if(t.includes(":")){const v=((n=t.match(/:([^/]+)/g))==null?void 0:n.map(y=>y.slice(1)))||[],j=t.replace(/:[^/]+/g,"([^/]+)"),S=new RegExp(`^${j}$`),O=e.match(S);if(O&&v.length>0){const y={};return v.forEach((T,z)=>{y[T]=O[z+1]}),{route:t,params:y,exact:!0}}}if(t.endsWith("/*")){const v=t.slice(0,-2);if(e.startsWith(v))return{route:t,params:{},exact:!1}}return null}static buildPath(t,e={}){let n=t;return Object.entries(e).forEach(([v,j])=>{n=n.replace(`:${v}`,encodeURIComponent(j))}),n}static isRouteActive(t,e=!1){const n=window.location.pathname;return e?n===t:t==="/"?n==="/":n.startsWith(t)}static getRouteDepth(t){return t.split("/").filter(e=>e.length>0).length}static getParentRoute(t){const e=t.split("/").filter(n=>n.length>0);return e.length<=1?"/":(e.pop(),"/"+e.join("/"))}static joinPaths(...t){return t.map(e=>e.replace(/^\/+|\/+$/g,"")).filter(e=>e.length>0).join("/").replace(/^/,"/")}static isExternalUrl(t){return/^https?:\/\//.test(t)||/^mailto:/.test(t)||/^tel:/.test(t)}static getQueryParam(t){return new URL(window.location.href).searchParams.get(t)}static setQueryParam(t,e,n=!1){const v=new URL(window.location.href);v.searchParams.set(t,e);const j=v.pathname+v.search+v.hash;this.navigate(j,n)}static removeQueryParam(t,e=!1){const n=new URL(window.location.href);n.searchParams.delete(t);const v=n.pathname+n.search+n.hash;this.navigate(v,e)}static goBack(){window.history.back()}static goForward(){window.history.forward()}static replace(t){this.navigate(t,!0)}static getHistoryLength(){return window.history.length}static onRouteChange(t){const e=()=>{const n=this.getCurrentRoute();t(n)};return window.addEventListener("popstate",e),document.addEventListener("route-changed",e),()=>{window.removeEventListener("popstate",e),document.removeEventListener("route-changed",e)}}}exports.RouterUtils=Ot;
package/dist/index.js CHANGED
@@ -1,102 +1,102 @@
1
- import { createLogger as F, autoRegister as ot, LightComponent as Y, jsx as Z, WebComponent as st } from "@wsxjs/wsx-core";
2
- const at = ":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";
1
+ import { createLogger as F, autoRegister as st, LightComponent as Y, jsx as Z, WebComponent as at } from "@wsxjs/wsx-core";
2
+ const ot = ":host{display:block;width:100%;height:100%}.router-outlet{width:100%;height:100%}";
3
3
  var yt;
4
- let wt, xt;
5
- function X(r, t, e) {
6
- return (t = kt(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
4
+ let bt, wt;
5
+ function G(r, t, e) {
6
+ return (t = xt(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
7
7
  }
8
- function Ct(r, t, e, n, g, R) {
9
- function _(i, c, u) {
10
- return function(s, a) {
11
- return u && u(s), i[c].call(s, a);
8
+ function Ct(r, t, e, n, g, C) {
9
+ function _(i, c, l) {
10
+ return function(a, o) {
11
+ return l && l(a), i[c].call(a, o);
12
12
  };
13
13
  }
14
14
  function I(i, c) {
15
- for (var u = 0; u < i.length; u++) i[u].call(c);
15
+ for (var l = 0; l < i.length; l++) i[l].call(c);
16
16
  return c;
17
17
  }
18
- function b(i, c, u, s) {
19
- if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
18
+ function y(i, c, l, a) {
19
+ if (typeof i != "function" && (a || i !== void 0)) throw new TypeError(c + " must " + (l || "be") + " a function" + (a ? "" : " or undefined"));
20
20
  return i;
21
21
  }
22
- function O(i, c, u, s, a, j, A, C, D, y, m, d, p) {
23
- function w(l) {
24
- if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
22
+ function O(i, c, l, a, o, A, W, $, D, b, v, p, d) {
23
+ function w(u) {
24
+ if (!d(u)) throw new TypeError("Attempted to access private element on non-instance");
25
25
  }
26
- var h, x = c[0], k = c[3], $ = !C;
27
- if (!$) {
28
- u || Array.isArray(x) || (x = [x]);
29
- var o = {}, E = [], v = a === 3 ? "get" : a === 4 || d ? "set" : "value";
30
- y ? (m || d ? o = { get: ct(function() {
31
- return k(this);
32
- }, s, "get"), set: function(l) {
33
- c[4](this, l);
34
- } } : o[v] = k, m || ct(o[v], s, a === 2 ? "" : v)) : m || (o = Object.getOwnPropertyDescriptor(i, s));
26
+ var h, x = c[0], E = c[3], j = !$;
27
+ if (!j) {
28
+ l || Array.isArray(x) || (x = [x]);
29
+ var s = {}, R = [], m = o === 3 ? "get" : o === 4 || p ? "set" : "value";
30
+ b ? (v || p ? s = { get: ct(function() {
31
+ return E(this);
32
+ }, a, "get"), set: function(u) {
33
+ c[4](this, u);
34
+ } } : s[m] = E, v || ct(s[m], a, o === 2 ? "" : m)) : v || (s = Object.getOwnPropertyDescriptor(i, a));
35
35
  }
36
- for (var f = i, N = x.length - 1; N >= 0; N -= u ? 2 : 1) {
37
- var H = x[N], q = u ? x[N - 1] : void 0, K = {}, W = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: j, addInitializer: (function(l, S) {
38
- if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
39
- b(S, "An initializer", "be", !0), A.push(S);
40
- }).bind(null, K) };
36
+ for (var f = i, N = x.length - 1; N >= 0; N -= l ? 2 : 1) {
37
+ var M = x[N], H = l ? x[N - 1] : void 0, q = {}, L = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: a, metadata: A, addInitializer: (function(u, S) {
38
+ if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
39
+ y(S, "An initializer", "be", !0), W.push(S);
40
+ }).bind(null, q) };
41
41
  try {
42
- if ($) (h = b(H.call(q, f, W), "class decorators", "return")) && (f = h);
42
+ if (j) (h = y(M.call(H, f, L), "class decorators", "return")) && (f = h);
43
43
  else {
44
- var L, P;
45
- W.static = D, W.private = y, y ? a === 2 ? L = function(l) {
46
- return w(l), o.value;
47
- } : (a < 4 && (L = _(o, "get", w)), a !== 3 && (P = _(o, "set", w))) : (L = function(l) {
48
- return l[s];
49
- }, (a < 2 || a === 4) && (P = function(l, S) {
50
- l[s] = S;
44
+ var k, P;
45
+ L.static = D, L.private = b, b ? o === 2 ? k = function(u) {
46
+ return w(u), s.value;
47
+ } : (o < 4 && (k = _(s, "get", w)), o !== 3 && (P = _(s, "set", w))) : (k = function(u) {
48
+ return u[a];
49
+ }, (o < 2 || o === 4) && (P = function(u, S) {
50
+ u[a] = S;
51
51
  }));
52
- var Q = W.access = { has: y ? p.bind() : function(l) {
53
- return s in l;
52
+ var K = L.access = { has: b ? d.bind() : function(u) {
53
+ return a in u;
54
54
  } };
55
- if (L && (Q.get = L), P && (Q.set = P), f = H.call(q, d ? { get: o.get, set: o.set } : o[v], W), d) {
56
- if (typeof f == "object" && f) (h = b(f.get, "accessor.get")) && (o.get = h), (h = b(f.set, "accessor.set")) && (o.set = h), (h = b(f.init, "accessor.init")) && E.push(h);
55
+ if (k && (K.get = k), P && (K.set = P), f = M.call(H, p ? { get: s.get, set: s.set } : s[m], L), p) {
56
+ if (typeof f == "object" && f) (h = y(f.get, "accessor.get")) && (s.get = h), (h = y(f.set, "accessor.set")) && (s.set = h), (h = y(f.init, "accessor.init")) && R.push(h);
57
57
  else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
58
- } else b(f, (m ? "field" : "method") + " decorators", "return") && (m ? E.push(f) : o[v] = f);
58
+ } else y(f, (v ? "field" : "method") + " decorators", "return") && (v ? R.push(f) : s[m] = f);
59
59
  }
60
60
  } finally {
61
- K.v = !0;
61
+ q.v = !0;
62
62
  }
63
63
  }
64
- return (m || d) && C.push(function(l, S) {
65
- for (var U = E.length - 1; U >= 0; U--) S = E[U].call(l, S);
64
+ return (v || p) && $.push(function(u, S) {
65
+ for (var U = R.length - 1; U >= 0; U--) S = R[U].call(u, S);
66
66
  return S;
67
- }), m || $ || (y ? d ? C.push(_(o, "get"), _(o, "set")) : C.push(a === 2 ? o[v] : _.call.bind(o[v])) : Object.defineProperty(i, s, o)), f;
67
+ }), v || j || (b ? p ? $.push(_(s, "get"), _(s, "set")) : $.push(o === 2 ? s[m] : _.call.bind(s[m])) : Object.defineProperty(i, a, s)), f;
68
68
  }
69
69
  function z(i, c) {
70
70
  return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
71
71
  }
72
- if (arguments.length >= 6) var M = R[Symbol.metadata || Symbol.for("Symbol.metadata")];
73
- var T = Object.create(M ?? null), G = function(i, c, u, s) {
74
- var a, j, A = [], C = function(v) {
75
- return jt(v) === i;
72
+ if (arguments.length >= 6) var V = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
73
+ var T = Object.create(V ?? null), B = function(i, c, l, a) {
74
+ var o, A, W = [], $ = function(m) {
75
+ return jt(m) === i;
76
76
  }, D = /* @__PURE__ */ new Map();
77
- function y(v) {
78
- v && A.push(I.bind(null, v));
77
+ function b(m) {
78
+ m && W.push(I.bind(null, m));
79
79
  }
80
- for (var m = 0; m < c.length; m++) {
81
- var d = c[m];
82
- if (Array.isArray(d)) {
83
- var p = d[1], w = d[2], h = d.length > 3, x = 16 & p, k = !!(8 & p), $ = (p &= 7) == 0, o = w + "/" + k;
84
- if (!$ && !h) {
85
- var E = D.get(o);
86
- if (E === !0 || E === 3 && p !== 4 || E === 4 && p !== 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: " + w);
87
- D.set(o, !(p > 2) || p);
80
+ for (var v = 0; v < c.length; v++) {
81
+ var p = c[v];
82
+ if (Array.isArray(p)) {
83
+ var d = p[1], w = p[2], h = p.length > 3, x = 16 & d, E = !!(8 & d), j = (d &= 7) == 0, s = w + "/" + E;
84
+ if (!j && !h) {
85
+ var R = D.get(s);
86
+ if (R === !0 || R === 3 && d !== 4 || R === 4 && d !== 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: " + w);
87
+ D.set(s, !(d > 2) || d);
88
88
  }
89
- O(k ? i : i.prototype, d, x, h ? "#" + w : kt(w), p, s, k ? j = j || [] : a = a || [], A, k, h, $, p === 1, k && h ? C : u);
89
+ O(E ? i : i.prototype, p, x, h ? "#" + w : xt(w), d, a, E ? A = A || [] : o = o || [], W, E, h, j, d === 1, E && h ? $ : l);
90
90
  }
91
91
  }
92
- return y(a), y(j), A;
92
+ return b(o), b(A), W;
93
93
  }(r, t, g, T);
94
- return e.length || z(r, T), { e: G, get c() {
94
+ return e.length || z(r, T), { e: B, get c() {
95
95
  var i = [];
96
96
  return e.length && [z(O(r, [e], n, r.name, 5, T, i), T), I.bind(null, i, r)];
97
97
  } };
98
98
  }
99
- function kt(r) {
99
+ function xt(r) {
100
100
  var t = $t(r, "string");
101
101
  return typeof t == "symbol" ? t : t + "";
102
102
  }
@@ -122,26 +122,26 @@ function jt(r) {
122
122
  if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
123
123
  return r;
124
124
  }
125
- const J = F("WsxRouter");
126
- xt = [ot({
125
+ const Q = F("WsxRouter");
126
+ wt = [st({
127
127
  tagName: "wsx-router"
128
128
  })];
129
129
  let At;
130
130
  class Wt extends Y {
131
131
  constructor() {
132
132
  super({
133
- styles: at,
133
+ styles: ot,
134
134
  styleName: "wsx-router"
135
- }), X(this, "_autoStyles", at), X(this, "views", /* @__PURE__ */ new Map()), X(this, "currentView", null), X(this, "handleRouteChange", () => {
135
+ }), G(this, "_autoStyles", ot), G(this, "views", /* @__PURE__ */ new Map()), G(this, "currentView", null), G(this, "handleRouteChange", () => {
136
136
  const t = window.location.pathname;
137
- J.debug(`Route changed to: ${t}`), this.currentView && (this.currentView.style.display = "none", J.debug("Hiding previous view"));
137
+ Q.debug(`Route changed to: ${t}`), this.currentView && (this.currentView.style.display = "none", Q.debug("Hiding previous view"));
138
138
  const e = this.matchRoute(t);
139
139
  if (e) {
140
- e.style.display = "block", this.currentView = e, J.debug(`Showing view for route: ${e.getAttribute("route")}`);
140
+ e.style.display = "block", this.currentView = e, Q.debug(`Showing view for route: ${e.getAttribute("route")}`);
141
141
  const n = this.extractParams(e.getAttribute("route") || "/", t);
142
142
  n && e.setAttribute("params", JSON.stringify(n));
143
143
  } else
144
- J.warn(`No view found for path: ${t}`);
144
+ Q.warn(`No view found for path: ${t}`);
145
145
  this.dispatchEvent(new CustomEvent("route-changed", {
146
146
  detail: {
147
147
  path: t,
@@ -150,7 +150,7 @@ class Wt extends Y {
150
150
  bubbles: !0,
151
151
  composed: !0
152
152
  }));
153
- }), X(this, "interceptLinks", (t) => {
153
+ }), G(this, "interceptLinks", (t) => {
154
154
  const e = t.target.closest("a");
155
155
  if (!e) return;
156
156
  const n = e.getAttribute("href");
@@ -161,16 +161,16 @@ class Wt extends Y {
161
161
  return /* @__PURE__ */ Z("div", { class: "router-outlet" });
162
162
  }
163
163
  onConnected() {
164
- J.debug("WsxRouter connected to DOM"), this.collectViews(), J.debug("WsxRouter collected views:", this.views.size), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), this.handleRouteChange();
164
+ Q.debug("WsxRouter connected to DOM"), this.collectViews(), Q.debug("WsxRouter collected views:", this.views.size), window.addEventListener("popstate", this.handleRouteChange), this.addEventListener("click", this.interceptLinks), this.handleRouteChange();
165
165
  }
166
166
  onDisconnected() {
167
167
  window.removeEventListener("popstate", this.handleRouteChange);
168
168
  }
169
169
  collectViews() {
170
170
  const t = Array.from(this.children).filter((e) => e.tagName.toLowerCase() === "wsx-view");
171
- J.debug("WsxRouter found views:", t.length), t.forEach((e) => {
171
+ Q.debug("WsxRouter found views:", t.length), t.forEach((e) => {
172
172
  const n = e.getAttribute("route") || "/";
173
- this.views.set(n, e), e.style.display = "none", J.debug(`WsxRouter hiding view for route: ${n}`);
173
+ this.views.set(n, e), e.style.display = "none", Q.debug(`WsxRouter hiding view for route: ${n}`);
174
174
  });
175
175
  }
176
176
  matchRoute(t) {
@@ -185,9 +185,9 @@ class Wt extends Y {
185
185
  return this.views.get("*") || null;
186
186
  }
187
187
  extractParams(t, e) {
188
- var b;
188
+ var y;
189
189
  if (!t.includes(":")) return null;
190
- const n = ((b = t.match(/:([^/]+)/g)) == null ? void 0 : b.map((O) => O.slice(1))) || [], g = t.replace(/:[^/]+/g, "([^/]+)"), R = new RegExp(`^${g}$`), _ = e.match(R);
190
+ const n = ((y = t.match(/:([^/]+)/g)) == null ? void 0 : y.map((O) => O.slice(1))) || [], g = t.replace(/:[^/]+/g, "([^/]+)"), C = new RegExp(`^${g}$`), _ = e.match(C);
191
191
  if (!_ || !n.length) return null;
192
192
  const I = {};
193
193
  return n.forEach((O, z) => {
@@ -202,106 +202,106 @@ class Wt extends Y {
202
202
  }
203
203
  }
204
204
  yt = Wt;
205
- [At, wt] = Ct(yt, [], xt, 0, void 0, Y).c;
206
- wt();
207
- const lt = ":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}}";
205
+ [At, bt] = Ct(yt, [], wt, 0, void 0, Y).c;
206
+ bt();
207
+ const Lt = ":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}}";
208
208
  var tt, et;
209
- let ut, Et, ht;
210
- function B(r, t, e) {
211
- return (t = St(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
209
+ let ut, Et, lt;
210
+ function X(r, t, e) {
211
+ return (t = Rt(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
212
212
  }
213
- function Lt(r, t, e, n, g, R) {
214
- function _(i, c, u) {
215
- return function(s, a) {
216
- return u && u(s), i[c].call(s, a);
213
+ function kt(r, t, e, n, g, C) {
214
+ function _(i, c, l) {
215
+ return function(a, o) {
216
+ return l && l(a), i[c].call(a, o);
217
217
  };
218
218
  }
219
219
  function I(i, c) {
220
- for (var u = 0; u < i.length; u++) i[u].call(c);
220
+ for (var l = 0; l < i.length; l++) i[l].call(c);
221
221
  return c;
222
222
  }
223
- function b(i, c, u, s) {
224
- if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
223
+ function y(i, c, l, a) {
224
+ if (typeof i != "function" && (a || i !== void 0)) throw new TypeError(c + " must " + (l || "be") + " a function" + (a ? "" : " or undefined"));
225
225
  return i;
226
226
  }
227
- function O(i, c, u, s, a, j, A, C, D, y, m, d, p) {
228
- function w(l) {
229
- if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
227
+ function O(i, c, l, a, o, A, W, $, D, b, v, p, d) {
228
+ function w(u) {
229
+ if (!d(u)) throw new TypeError("Attempted to access private element on non-instance");
230
230
  }
231
- var h, x = c[0], k = c[3], $ = !C;
232
- if (!$) {
233
- u || Array.isArray(x) || (x = [x]);
234
- var o = {}, E = [], v = a === 3 ? "get" : a === 4 || d ? "set" : "value";
235
- y ? (m || d ? o = { get: ft(function() {
236
- return k(this);
237
- }, s, "get"), set: function(l) {
238
- c[4](this, l);
239
- } } : o[v] = k, m || ft(o[v], s, a === 2 ? "" : v)) : m || (o = Object.getOwnPropertyDescriptor(i, s));
231
+ var h, x = c[0], E = c[3], j = !$;
232
+ if (!j) {
233
+ l || Array.isArray(x) || (x = [x]);
234
+ var s = {}, R = [], m = o === 3 ? "get" : o === 4 || p ? "set" : "value";
235
+ b ? (v || p ? s = { get: ht(function() {
236
+ return E(this);
237
+ }, a, "get"), set: function(u) {
238
+ c[4](this, u);
239
+ } } : s[m] = E, v || ht(s[m], a, o === 2 ? "" : m)) : v || (s = Object.getOwnPropertyDescriptor(i, a));
240
240
  }
241
- for (var f = i, N = x.length - 1; N >= 0; N -= u ? 2 : 1) {
242
- var H = x[N], q = u ? x[N - 1] : void 0, K = {}, W = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: j, addInitializer: (function(l, S) {
243
- if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
244
- b(S, "An initializer", "be", !0), A.push(S);
245
- }).bind(null, K) };
241
+ for (var f = i, N = x.length - 1; N >= 0; N -= l ? 2 : 1) {
242
+ var M = x[N], H = l ? x[N - 1] : void 0, q = {}, L = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: a, metadata: A, addInitializer: (function(u, S) {
243
+ if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
244
+ y(S, "An initializer", "be", !0), W.push(S);
245
+ }).bind(null, q) };
246
246
  try {
247
- if ($) (h = b(H.call(q, f, W), "class decorators", "return")) && (f = h);
247
+ if (j) (h = y(M.call(H, f, L), "class decorators", "return")) && (f = h);
248
248
  else {
249
- var L, P;
250
- W.static = D, W.private = y, y ? a === 2 ? L = function(l) {
251
- return w(l), o.value;
252
- } : (a < 4 && (L = _(o, "get", w)), a !== 3 && (P = _(o, "set", w))) : (L = function(l) {
253
- return l[s];
254
- }, (a < 2 || a === 4) && (P = function(l, S) {
255
- l[s] = S;
249
+ var k, P;
250
+ L.static = D, L.private = b, b ? o === 2 ? k = function(u) {
251
+ return w(u), s.value;
252
+ } : (o < 4 && (k = _(s, "get", w)), o !== 3 && (P = _(s, "set", w))) : (k = function(u) {
253
+ return u[a];
254
+ }, (o < 2 || o === 4) && (P = function(u, S) {
255
+ u[a] = S;
256
256
  }));
257
- var Q = W.access = { has: y ? p.bind() : function(l) {
258
- return s in l;
257
+ var K = L.access = { has: b ? d.bind() : function(u) {
258
+ return a in u;
259
259
  } };
260
- if (L && (Q.get = L), P && (Q.set = P), f = H.call(q, d ? { get: o.get, set: o.set } : o[v], W), d) {
261
- if (typeof f == "object" && f) (h = b(f.get, "accessor.get")) && (o.get = h), (h = b(f.set, "accessor.set")) && (o.set = h), (h = b(f.init, "accessor.init")) && E.push(h);
260
+ if (k && (K.get = k), P && (K.set = P), f = M.call(H, p ? { get: s.get, set: s.set } : s[m], L), p) {
261
+ if (typeof f == "object" && f) (h = y(f.get, "accessor.get")) && (s.get = h), (h = y(f.set, "accessor.set")) && (s.set = h), (h = y(f.init, "accessor.init")) && R.push(h);
262
262
  else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
263
- } else b(f, (m ? "field" : "method") + " decorators", "return") && (m ? E.push(f) : o[v] = f);
263
+ } else y(f, (v ? "field" : "method") + " decorators", "return") && (v ? R.push(f) : s[m] = f);
264
264
  }
265
265
  } finally {
266
- K.v = !0;
266
+ q.v = !0;
267
267
  }
268
268
  }
269
- return (m || d) && C.push(function(l, S) {
270
- for (var U = E.length - 1; U >= 0; U--) S = E[U].call(l, S);
269
+ return (v || p) && $.push(function(u, S) {
270
+ for (var U = R.length - 1; U >= 0; U--) S = R[U].call(u, S);
271
271
  return S;
272
- }), m || $ || (y ? d ? C.push(_(o, "get"), _(o, "set")) : C.push(a === 2 ? o[v] : _.call.bind(o[v])) : Object.defineProperty(i, s, o)), f;
272
+ }), v || j || (b ? p ? $.push(_(s, "get"), _(s, "set")) : $.push(o === 2 ? s[m] : _.call.bind(s[m])) : Object.defineProperty(i, a, s)), f;
273
273
  }
274
274
  function z(i, c) {
275
275
  return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
276
276
  }
277
- if (arguments.length >= 6) var M = R[Symbol.metadata || Symbol.for("Symbol.metadata")];
278
- var T = Object.create(M ?? null), G = function(i, c, u, s) {
279
- var a, j, A = [], C = function(v) {
280
- return Ot(v) === i;
277
+ if (arguments.length >= 6) var V = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
278
+ var T = Object.create(V ?? null), B = function(i, c, l, a) {
279
+ var o, A, W = [], $ = function(m) {
280
+ return Ot(m) === i;
281
281
  }, D = /* @__PURE__ */ new Map();
282
- function y(v) {
283
- v && A.push(I.bind(null, v));
282
+ function b(m) {
283
+ m && W.push(I.bind(null, m));
284
284
  }
285
- for (var m = 0; m < c.length; m++) {
286
- var d = c[m];
287
- if (Array.isArray(d)) {
288
- var p = d[1], w = d[2], h = d.length > 3, x = 16 & p, k = !!(8 & p), $ = (p &= 7) == 0, o = w + "/" + k;
289
- if (!$ && !h) {
290
- var E = D.get(o);
291
- if (E === !0 || E === 3 && p !== 4 || E === 4 && p !== 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: " + w);
292
- D.set(o, !(p > 2) || p);
285
+ for (var v = 0; v < c.length; v++) {
286
+ var p = c[v];
287
+ if (Array.isArray(p)) {
288
+ var d = p[1], w = p[2], h = p.length > 3, x = 16 & d, E = !!(8 & d), j = (d &= 7) == 0, s = w + "/" + E;
289
+ if (!j && !h) {
290
+ var R = D.get(s);
291
+ if (R === !0 || R === 3 && d !== 4 || R === 4 && d !== 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: " + w);
292
+ D.set(s, !(d > 2) || d);
293
293
  }
294
- O(k ? i : i.prototype, d, x, h ? "#" + w : St(w), p, s, k ? j = j || [] : a = a || [], A, k, h, $, p === 1, k && h ? C : u);
294
+ O(E ? i : i.prototype, p, x, h ? "#" + w : Rt(w), d, a, E ? A = A || [] : o = o || [], W, E, h, j, d === 1, E && h ? $ : l);
295
295
  }
296
296
  }
297
- return y(a), y(j), A;
297
+ return b(o), b(A), W;
298
298
  }(r, t, g, T);
299
- return e.length || z(r, T), { e: G, get c() {
299
+ return e.length || z(r, T), { e: B, get c() {
300
300
  var i = [];
301
301
  return e.length && [z(O(r, [e], n, r.name, 5, T, i), T), I.bind(null, i, r)];
302
302
  } };
303
303
  }
304
- function St(r) {
304
+ function Rt(r) {
305
305
  var t = It(r, "string");
306
306
  return typeof t == "symbol" ? t : t + "";
307
307
  }
@@ -315,7 +315,7 @@ function It(r, t) {
315
315
  }
316
316
  return (t === "string" ? String : Number)(r);
317
317
  }
318
- function ft(r, t, e) {
318
+ function ht(r, t, e) {
319
319
  typeof t == "symbol" && (t = (t = t.description) ? "[" + t + "]" : "");
320
320
  try {
321
321
  Object.defineProperty(r, "name", { configurable: !0, value: e ? e + " " + t : t });
@@ -331,16 +331,16 @@ function Tt(r) {
331
331
  return r;
332
332
  }
333
333
  const rt = F("WsxView");
334
- Et = [ot({
334
+ Et = [st({
335
335
  tagName: "wsx-view"
336
336
  })];
337
- let dt;
338
- new (ht = (et = class extends Y {
337
+ let ft;
338
+ new (lt = (et = class extends Y {
339
339
  constructor() {
340
340
  super({
341
- styles: lt,
341
+ styles: Lt,
342
342
  styleName: "wsx-view"
343
- }), B(this, "_autoStyles", lt), B(this, "component", null), B(this, "params", {}), B(this, "componentInstance", null);
343
+ }), X(this, "component", null), X(this, "params", {}), X(this, "componentInstance", null);
344
344
  }
345
345
  render() {
346
346
  return /* @__PURE__ */ Z("div", { class: "route-view" });
@@ -354,8 +354,8 @@ new (ht = (et = class extends Y {
354
354
  this.loadComponent(n);
355
355
  else if (t === "params" && this.componentInstance)
356
356
  try {
357
- this.params = JSON.parse(n), Object.entries(this.params).forEach(([g, R]) => {
358
- this.componentInstance.setAttribute(g, R);
357
+ this.params = JSON.parse(n), Object.entries(this.params).forEach(([g, C]) => {
358
+ this.componentInstance.setAttribute(g, C);
359
359
  });
360
360
  } catch (g) {
361
361
  rt.error("Failed to parse params:", g);
@@ -366,8 +366,8 @@ new (ht = (et = class extends Y {
366
366
  rt.warn(`Component ${t} not found in customElements registry`);
367
367
  return;
368
368
  }
369
- this.componentInstance = document.createElement(t), Object.keys(this.params).length > 0 && Object.entries(this.params).forEach(([g, R]) => {
370
- this.componentInstance.setAttribute(g, R);
369
+ this.componentInstance = document.createElement(t), Object.keys(this.params).length > 0 && Object.entries(this.params).forEach(([g, C]) => {
370
+ this.componentInstance.setAttribute(g, C);
371
371
  });
372
372
  const n = this.querySelector(".route-view");
373
373
  n ? n.appendChild(this.componentInstance) : rt.error("Route view container not found");
@@ -375,113 +375,112 @@ new (ht = (et = class extends Y {
375
375
  onDisconnected() {
376
376
  this.componentInstance && (this.componentInstance.remove(), this.componentInstance = null);
377
377
  }
378
- }, [dt, ut] = Lt(et, [], Et, 0, void 0, Y).c, et), tt = class extends Tt {
378
+ }, [ft, ut] = kt(et, [], Et, 0, void 0, Y).c, et), tt = class extends Tt {
379
379
  constructor() {
380
- super(dt), B(this, "observedAttributes", ["route", "component", "params"]), ut();
380
+ super(ft), X(this, "observedAttributes", ["route", "component", "params"]), ut();
381
381
  }
382
- }, B(tt, ht, void 0), tt)();
383
- const Dt = ':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, #007bff);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)}';
382
+ }, X(tt, lt, void 0), tt)();
384
383
  var nt, it;
385
- let pt, _t, vt;
386
- function V(r, t, e) {
387
- return (t = Rt(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
384
+ let pt, St, dt;
385
+ function J(r, t, e) {
386
+ return (t = _t(t)) in r ? Object.defineProperty(r, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : r[t] = e, r;
388
387
  }
389
- function Nt(r, t, e, n, g, R) {
390
- function _(i, c, u) {
391
- return function(s, a) {
392
- return u && u(s), i[c].call(s, a);
388
+ function Dt(r, t, e, n, g, C) {
389
+ function _(i, c, l) {
390
+ return function(a, o) {
391
+ return l && l(a), i[c].call(a, o);
393
392
  };
394
393
  }
395
394
  function I(i, c) {
396
- for (var u = 0; u < i.length; u++) i[u].call(c);
395
+ for (var l = 0; l < i.length; l++) i[l].call(c);
397
396
  return c;
398
397
  }
399
- function b(i, c, u, s) {
400
- if (typeof i != "function" && (s || i !== void 0)) throw new TypeError(c + " must " + (u || "be") + " a function" + (s ? "" : " or undefined"));
398
+ function y(i, c, l, a) {
399
+ if (typeof i != "function" && (a || i !== void 0)) throw new TypeError(c + " must " + (l || "be") + " a function" + (a ? "" : " or undefined"));
401
400
  return i;
402
401
  }
403
- function O(i, c, u, s, a, j, A, C, D, y, m, d, p) {
404
- function w(l) {
405
- if (!p(l)) throw new TypeError("Attempted to access private element on non-instance");
402
+ function O(i, c, l, a, o, A, W, $, D, b, v, p, d) {
403
+ function w(u) {
404
+ if (!d(u)) throw new TypeError("Attempted to access private element on non-instance");
406
405
  }
407
- var h, x = c[0], k = c[3], $ = !C;
408
- if (!$) {
409
- u || Array.isArray(x) || (x = [x]);
410
- var o = {}, E = [], v = a === 3 ? "get" : a === 4 || d ? "set" : "value";
411
- y ? (m || d ? o = { get: mt(function() {
412
- return k(this);
413
- }, s, "get"), set: function(l) {
414
- c[4](this, l);
415
- } } : o[v] = k, m || mt(o[v], s, a === 2 ? "" : v)) : m || (o = Object.getOwnPropertyDescriptor(i, s));
406
+ var h, x = c[0], E = c[3], j = !$;
407
+ if (!j) {
408
+ l || Array.isArray(x) || (x = [x]);
409
+ var s = {}, R = [], m = o === 3 ? "get" : o === 4 || p ? "set" : "value";
410
+ b ? (v || p ? s = { get: mt(function() {
411
+ return E(this);
412
+ }, a, "get"), set: function(u) {
413
+ c[4](this, u);
414
+ } } : s[m] = E, v || mt(s[m], a, o === 2 ? "" : m)) : v || (s = Object.getOwnPropertyDescriptor(i, a));
416
415
  }
417
- for (var f = i, N = x.length - 1; N >= 0; N -= u ? 2 : 1) {
418
- var H = x[N], q = u ? x[N - 1] : void 0, K = {}, W = { kind: ["field", "accessor", "method", "getter", "setter", "class"][a], name: s, metadata: j, addInitializer: (function(l, S) {
419
- if (l.v) throw Error("attempted to call addInitializer after decoration was finished");
420
- b(S, "An initializer", "be", !0), A.push(S);
421
- }).bind(null, K) };
416
+ for (var f = i, N = x.length - 1; N >= 0; N -= l ? 2 : 1) {
417
+ var M = x[N], H = l ? x[N - 1] : void 0, q = {}, L = { kind: ["field", "accessor", "method", "getter", "setter", "class"][o], name: a, metadata: A, addInitializer: (function(u, S) {
418
+ if (u.v) throw Error("attempted to call addInitializer after decoration was finished");
419
+ y(S, "An initializer", "be", !0), W.push(S);
420
+ }).bind(null, q) };
422
421
  try {
423
- if ($) (h = b(H.call(q, f, W), "class decorators", "return")) && (f = h);
422
+ if (j) (h = y(M.call(H, f, L), "class decorators", "return")) && (f = h);
424
423
  else {
425
- var L, P;
426
- W.static = D, W.private = y, y ? a === 2 ? L = function(l) {
427
- return w(l), o.value;
428
- } : (a < 4 && (L = _(o, "get", w)), a !== 3 && (P = _(o, "set", w))) : (L = function(l) {
429
- return l[s];
430
- }, (a < 2 || a === 4) && (P = function(l, S) {
431
- l[s] = S;
424
+ var k, P;
425
+ L.static = D, L.private = b, b ? o === 2 ? k = function(u) {
426
+ return w(u), s.value;
427
+ } : (o < 4 && (k = _(s, "get", w)), o !== 3 && (P = _(s, "set", w))) : (k = function(u) {
428
+ return u[a];
429
+ }, (o < 2 || o === 4) && (P = function(u, S) {
430
+ u[a] = S;
432
431
  }));
433
- var Q = W.access = { has: y ? p.bind() : function(l) {
434
- return s in l;
432
+ var K = L.access = { has: b ? d.bind() : function(u) {
433
+ return a in u;
435
434
  } };
436
- if (L && (Q.get = L), P && (Q.set = P), f = H.call(q, d ? { get: o.get, set: o.set } : o[v], W), d) {
437
- if (typeof f == "object" && f) (h = b(f.get, "accessor.get")) && (o.get = h), (h = b(f.set, "accessor.set")) && (o.set = h), (h = b(f.init, "accessor.init")) && E.push(h);
435
+ if (k && (K.get = k), P && (K.set = P), f = M.call(H, p ? { get: s.get, set: s.set } : s[m], L), p) {
436
+ if (typeof f == "object" && f) (h = y(f.get, "accessor.get")) && (s.get = h), (h = y(f.set, "accessor.set")) && (s.set = h), (h = y(f.init, "accessor.init")) && R.push(h);
438
437
  else if (f !== void 0) throw new TypeError("accessor decorators must return an object with get, set, or init properties or void 0");
439
- } else b(f, (m ? "field" : "method") + " decorators", "return") && (m ? E.push(f) : o[v] = f);
438
+ } else y(f, (v ? "field" : "method") + " decorators", "return") && (v ? R.push(f) : s[m] = f);
440
439
  }
441
440
  } finally {
442
- K.v = !0;
441
+ q.v = !0;
443
442
  }
444
443
  }
445
- return (m || d) && C.push(function(l, S) {
446
- for (var U = E.length - 1; U >= 0; U--) S = E[U].call(l, S);
444
+ return (v || p) && $.push(function(u, S) {
445
+ for (var U = R.length - 1; U >= 0; U--) S = R[U].call(u, S);
447
446
  return S;
448
- }), m || $ || (y ? d ? C.push(_(o, "get"), _(o, "set")) : C.push(a === 2 ? o[v] : _.call.bind(o[v])) : Object.defineProperty(i, s, o)), f;
447
+ }), v || j || (b ? p ? $.push(_(s, "get"), _(s, "set")) : $.push(o === 2 ? s[m] : _.call.bind(s[m])) : Object.defineProperty(i, a, s)), f;
449
448
  }
450
449
  function z(i, c) {
451
450
  return Object.defineProperty(i, Symbol.metadata || Symbol.for("Symbol.metadata"), { configurable: !0, enumerable: !0, value: c });
452
451
  }
453
- if (arguments.length >= 6) var M = R[Symbol.metadata || Symbol.for("Symbol.metadata")];
454
- var T = Object.create(M ?? null), G = function(i, c, u, s) {
455
- var a, j, A = [], C = function(v) {
456
- return zt(v) === i;
452
+ if (arguments.length >= 6) var V = C[Symbol.metadata || Symbol.for("Symbol.metadata")];
453
+ var T = Object.create(V ?? null), B = function(i, c, l, a) {
454
+ var o, A, W = [], $ = function(m) {
455
+ return Pt(m) === i;
457
456
  }, D = /* @__PURE__ */ new Map();
458
- function y(v) {
459
- v && A.push(I.bind(null, v));
457
+ function b(m) {
458
+ m && W.push(I.bind(null, m));
460
459
  }
461
- for (var m = 0; m < c.length; m++) {
462
- var d = c[m];
463
- if (Array.isArray(d)) {
464
- var p = d[1], w = d[2], h = d.length > 3, x = 16 & p, k = !!(8 & p), $ = (p &= 7) == 0, o = w + "/" + k;
465
- if (!$ && !h) {
466
- var E = D.get(o);
467
- if (E === !0 || E === 3 && p !== 4 || E === 4 && p !== 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: " + w);
468
- D.set(o, !(p > 2) || p);
460
+ for (var v = 0; v < c.length; v++) {
461
+ var p = c[v];
462
+ if (Array.isArray(p)) {
463
+ var d = p[1], w = p[2], h = p.length > 3, x = 16 & d, E = !!(8 & d), j = (d &= 7) == 0, s = w + "/" + E;
464
+ if (!j && !h) {
465
+ var R = D.get(s);
466
+ if (R === !0 || R === 3 && d !== 4 || R === 4 && d !== 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: " + w);
467
+ D.set(s, !(d > 2) || d);
469
468
  }
470
- O(k ? i : i.prototype, d, x, h ? "#" + w : Rt(w), p, s, k ? j = j || [] : a = a || [], A, k, h, $, p === 1, k && h ? C : u);
469
+ O(E ? i : i.prototype, p, x, h ? "#" + w : _t(w), d, a, E ? A = A || [] : o = o || [], W, E, h, j, d === 1, E && h ? $ : l);
471
470
  }
472
471
  }
473
- return y(a), y(j), A;
472
+ return b(o), b(A), W;
474
473
  }(r, t, g, T);
475
- return e.length || z(r, T), { e: G, get c() {
474
+ return e.length || z(r, T), { e: B, get c() {
476
475
  var i = [];
477
476
  return e.length && [z(O(r, [e], n, r.name, 5, T, i), T), I.bind(null, i, r)];
478
477
  } };
479
478
  }
480
- function Rt(r) {
481
- var t = Pt(r, "string");
479
+ function _t(r) {
480
+ var t = Nt(r, "string");
482
481
  return typeof t == "symbol" ? t : t + "";
483
482
  }
484
- function Pt(r, t) {
483
+ function Nt(r, t) {
485
484
  if (typeof r != "object" || !r) return r;
486
485
  var e = r[Symbol.toPrimitive];
487
486
  if (e !== void 0) {
@@ -499,33 +498,33 @@ function mt(r, t, e) {
499
498
  }
500
499
  return r;
501
500
  }
502
- function zt(r) {
501
+ function Pt(r) {
503
502
  if (Object(r) !== r) throw TypeError("right-hand side of 'in' should be an object, got " + (r !== null ? typeof r : "null"));
504
503
  return r;
505
504
  }
506
- function Ut(r) {
505
+ function zt(r) {
507
506
  return r;
508
507
  }
509
- const gt = F("WsxLink");
510
- _t = [ot({
508
+ const vt = F("WsxLink");
509
+ St = [st({
511
510
  tagName: "wsx-link"
512
511
  })];
513
- let bt;
514
- new (vt = (it = class extends st {
512
+ let gt;
513
+ new (dt = (it = class extends at {
515
514
  constructor(...t) {
516
- super(...t), V(this, "_autoStyles", Dt), V(this, "to", ""), V(this, "replace", !1), V(this, "activeClass", "active"), V(this, "exact", !1), V(this, "handleClick", (e) => {
515
+ super(...t), J(this, "to", ""), J(this, "replace", !1), J(this, "activeClass", "active"), J(this, "exact", !1), J(this, "handleClick", (e) => {
517
516
  if (e.preventDefault(), !this.to) {
518
- gt.warn("No 'to' attribute specified");
517
+ vt.warn("No 'to' attribute specified");
519
518
  return;
520
519
  }
521
520
  if (this.isExternalLink(this.to)) {
522
521
  window.open(this.to, "_blank");
523
522
  return;
524
523
  }
525
- this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), gt.debug(`Navigated to: ${this.to}`);
526
- }), V(this, "updateActiveState", () => {
527
- var R;
528
- const e = window.location.pathname, n = this.exact ? e === this.to : e.startsWith(this.to) && this.to !== "/", g = (R = this.shadowRoot) == null ? void 0 : R.querySelector("a");
524
+ this.replace ? window.history.replaceState(null, "", this.to) : window.history.pushState(null, "", this.to), window.dispatchEvent(new PopStateEvent("popstate")), vt.debug(`Navigated to: ${this.to}`);
525
+ }), J(this, "updateActiveState", () => {
526
+ var C;
527
+ const e = window.location.pathname, n = this.exact ? e === this.to : e.startsWith(this.to) && this.to !== "/", g = (C = this.shadowRoot) == null ? void 0 : C.querySelector("a");
529
528
  g && (n ? (g.classList.add(this.activeClass), this.setAttribute("active", "")) : (g.classList.remove(this.activeClass), this.removeAttribute("active")));
530
529
  });
531
530
  }
@@ -568,18 +567,18 @@ new (vt = (it = class extends st {
568
567
  cancelable: !0
569
568
  }));
570
569
  }
571
- }, [bt, pt] = Nt(it, [], _t, 0, void 0, st).c, it), nt = class extends Ut {
570
+ }, [gt, pt] = Dt(it, [], St, 0, void 0, at).c, it), nt = class extends zt {
572
571
  constructor() {
573
- super(bt), V(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), pt();
572
+ super(gt), J(this, "observedAttributes", ["to", "replace", "active-class", "exact"]), pt();
574
573
  }
575
- }, V(nt, vt, void 0), nt)();
576
- const Vt = F("RouterUtils");
577
- class Kt {
574
+ }, J(nt, dt, void 0), nt)();
575
+ const Ut = F("RouterUtils");
576
+ class qt {
578
577
  /**
579
578
  * 编程式导航
580
579
  */
581
580
  static navigate(t, e = !1) {
582
- e ? window.history.replaceState(null, "", t) : window.history.pushState(null, "", t), window.dispatchEvent(new PopStateEvent("popstate")), Vt.debug(`Navigated to: ${t} (replace: ${e})`);
581
+ e ? window.history.replaceState(null, "", t) : window.history.pushState(null, "", t), window.dispatchEvent(new PopStateEvent("popstate")), Ut.debug(`Navigated to: ${t} (replace: ${e})`);
583
582
  }
584
583
  /**
585
584
  * 获取当前路由信息
@@ -613,14 +612,14 @@ class Kt {
613
612
  exact: !1
614
613
  };
615
614
  if (t.includes(":")) {
616
- const g = ((n = t.match(/:([^/]+)/g)) == null ? void 0 : n.map((b) => b.slice(1))) || [], R = t.replace(/:[^/]+/g, "([^/]+)"), _ = new RegExp(`^${R}$`), I = e.match(_);
615
+ const g = ((n = t.match(/:([^/]+)/g)) == null ? void 0 : n.map((y) => y.slice(1))) || [], C = t.replace(/:[^/]+/g, "([^/]+)"), _ = new RegExp(`^${C}$`), I = e.match(_);
617
616
  if (I && g.length > 0) {
618
- const b = {};
617
+ const y = {};
619
618
  return g.forEach((O, z) => {
620
- b[O] = I[z + 1];
619
+ y[O] = I[z + 1];
621
620
  }), {
622
621
  route: t,
623
- params: b,
622
+ params: y,
624
623
  exact: !0
625
624
  };
626
625
  }
@@ -641,8 +640,8 @@ class Kt {
641
640
  */
642
641
  static buildPath(t, e = {}) {
643
642
  let n = t;
644
- return Object.entries(e).forEach(([g, R]) => {
645
- n = n.replace(`:${g}`, encodeURIComponent(R));
643
+ return Object.entries(e).forEach(([g, C]) => {
644
+ n = n.replace(`:${g}`, encodeURIComponent(C));
646
645
  }), n;
647
646
  }
648
647
  /**
@@ -689,8 +688,8 @@ class Kt {
689
688
  static setQueryParam(t, e, n = !1) {
690
689
  const g = new URL(window.location.href);
691
690
  g.searchParams.set(t, e);
692
- const R = g.pathname + g.search + g.hash;
693
- this.navigate(R, n);
691
+ const C = g.pathname + g.search + g.hash;
692
+ this.navigate(C, n);
694
693
  }
695
694
  /**
696
695
  * 删除查询参数
@@ -739,8 +738,8 @@ class Kt {
739
738
  }
740
739
  }
741
740
  export {
742
- Kt as RouterUtils,
743
- bt as WsxLink,
741
+ qt as RouterUtils,
742
+ gt as WsxLink,
744
743
  At as WsxRouter,
745
- dt as WsxView
744
+ ft as WsxView
746
745
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wsxjs/wsx-router",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "WSX Router - Native History API-based routing for WSX Framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -18,7 +18,7 @@
18
18
  "!**/test"
19
19
  ],
20
20
  "dependencies": {
21
- "@wsxjs/wsx-core": "0.0.13"
21
+ "@wsxjs/wsx-core": "0.0.15"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@typescript-eslint/eslint-plugin": "^8.37.0",
@@ -30,8 +30,8 @@
30
30
  "typescript": "^5.0.0",
31
31
  "vite": "^5.4.19",
32
32
  "vitest": "^2.1.8",
33
- "@wsxjs/eslint-plugin-wsx": "0.0.13",
34
- "@wsxjs/wsx-vite-plugin": "0.0.13"
33
+ "@wsxjs/eslint-plugin-wsx": "0.0.15",
34
+ "@wsxjs/wsx-vite-plugin": "0.0.15"
35
35
  },
36
36
  "keywords": [
37
37
  "wsx",
package/src/WsxLink.wsx CHANGED
@@ -1,5 +1,5 @@
1
1
  /** @jsxImportSource @wsxjs/wsx-core */
2
- import { WebComponent, autoRegister, createLogger } from "@wsxjs/wsx-core";
2
+ import { WebComponent, autoRegister, createLogger, state } from "@wsxjs/wsx-core";
3
3
 
4
4
  const logger = createLogger("WsxLink");
5
5
 
@@ -23,10 +23,10 @@ const logger = createLogger("WsxLink");
23
23
  export default class WsxLink extends WebComponent {
24
24
  static observedAttributes = ["to", "replace", "active-class", "exact"];
25
25
 
26
- private to: string = "";
27
- private replace: boolean = false;
28
- private activeClass: string = "active";
29
- private exact: boolean = false;
26
+ @state private to: string = "";
27
+ @state private replace: boolean = false;
28
+ @state private activeClass: string = "active";
29
+ @state private exact: boolean = false;
30
30
 
31
31
  render() {
32
32
  return (
@@ -66,7 +66,6 @@ export default class WsxLink extends WebComponent {
66
66
  switch (name) {
67
67
  case "to":
68
68
  this.to = newValue || "";
69
- this.rerender(); // Re-render to update href in JSX
70
69
  this.updateActiveState();
71
70
  break;
72
71
  case "replace":