import{r as registerInstance,h,g as getElement}from"./index-ecdfb761.js";import{m as matchPath,q as isModifiedEvent}from"./dom-utils-96bcc231.js";import{A as ActiveRouter}from"./active-router-f8de0a09.js";import"./state-tunnel-04c0b67a.js";var getUrl=function(t,i){if(t.charAt(0)=="/"&&i.charAt(i.length-1)=="/"){return i.slice(0,i.length-1)+t}return i+t};var RouteLink=function(){function t(t){registerInstance(this,t);this.unsubscribe=function(){return};this.activeClass="link-active";this.exact=false;this.strict=true;this.custom="a";this.match=null}t.prototype.componentWillLoad=function(){this.computeMatch()};t.prototype.computeMatch=function(){if(this.location){this.match=matchPath(this.location.pathname,{path:this.urlMatch||this.url,exact:this.exact,strict:this.strict})}};t.prototype.handleClick=function(t){if(isModifiedEvent(t)||!this.history||!this.url||!this.root){return}t.preventDefault();return this.history.push(getUrl(this.url,this.root))};t.prototype.render=function(){var t;var i={class:(t={},t[this.activeClass]=this.match!==null,t),onClick:this.handleClick.bind(this)};if(this.anchorClass){i.class[this.anchorClass]=true}if(this.custom==="a"){i=Object.assign({},i,{href:this.url,title:this.anchorTitle,role:this.anchorRole,tabindex:this.anchorTabIndex,"aria-haspopup":this.ariaHaspopup,id:this.anchorId,"aria-posinset":this.ariaPosinset,"aria-setsize":this.ariaSetsize,"aria-label":this.ariaLabel})}return h(this.custom,Object.assign({},i),h("slot",null))};Object.defineProperty(t.prototype,"el",{get:function(){return getElement(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{location:["computeMatch"]}},enumerable:false,configurable:true});return t}();ActiveRouter.injectProps(RouteLink,["history","location","root"]);export{RouteLink as stencil_route_link};