import{s as c,V as d,a as u,b as f,c as h,p,d as m}from"./purify.es-DP_WP6YH.js";import{L as g}from"./LegacyUrl-CeiszSHN.js";import{n as l}from"./_plugin-vue2_normalizer-BFq-tfv7.js";const v=[{name:"__checkbox",titleClass:"center aligned",dataClass:"center aligned"},{name:"__component:legacy-url",sortField:"redirectSrcUrl",title:Craft.t("retour","Short Link"),titleClass:"center",dataClass:"center"},{name:"__component:element-url",sortField:"elementTitle",title:Craft.t("retour","Redirect To"),titleClass:"center",dataClass:"center"},{name:"redirectMatchType",sortField:"redirectMatchType",title:Craft.t("retour","Match Type"),titleClass:"text-left",dataClass:"text-left",callback:"matchFormatter"},{name:"siteName",sortField:"siteId",title:Craft.t("retour","Sites"),titleClass:"text-left",dataClass:"text-left"},{name:"redirectHttpCode",sortField:"redirectHttpCode",title:Craft.t("retour","Status"),titleClass:"text-left",dataClass:"text-left"},{name:"hitCount",sortField:"hitCount",title:Craft.t("retour","Hits"),titleClass:"text-right",dataClass:"text-right"},{name:"hitLastTime",sortField:"hitLastTime",title:Craft.t("retour","Last Hit"),titleClass:"center",dataClass:"center"}],b={props:{rowData:{type:Object,required:!0},rowIndex:{type:Number,default:0}},computed:{linkTitle:function(){let a="";return a+=this.rowData.redirectDestUrl,a}}};var C=function(){var e=this,t=e._self._c;return t("div",[t("a",{staticClass:"go",attrs:{href:e.rowData.elementCpUrl,title:e.linkTitle}},[t("span",{staticStyle:{"white-space":"nowrap"}},[t("span"),t("span",{staticStyle:{"white-space":"normal"}},[e._v(e._s(e.rowData.elementTitle))])])])])},_=[],T=l(b,C,_,!1,null,null);const x=T.exports;Vue.component("LegacyUrl",g);Vue.component("ElementUrl",x);const $={components:{vuetable:h,"vuetable-pagination":f,"vuetable-pagination-info":u,"vuetable-filter-bar":d},mixins:[c],props:{siteId:{type:Number,default:0},apiUrl:{type:String,default:""}},data:function(){return{moreParams:{siteId:this.siteId,shortLinks:!0},css:{tableClass:"data fullwidth retour-redirects",ascendingIcon:"icon retour-menubtn-asc",descendingIcon:"icon retour-menubtn-desc"},sortOrder:[{field:"hitCount",sortField:"hitCount",direction:"desc"}],fields:v,numSelected:0,selectedIds:[],filterText:"",perPage:20,stringPerPage:Craft.t("retour","Per-page:"),stringDelete:Craft.t("retour","Delete"),stringRedirect:Craft.t("retour","redirect"),stringRedirects:Craft.t("retour","redirects")}},computed:{csrfTokenName:function(){return window.Craft.csrfTokenName},csrfTokenValue:function(){return window.Craft.csrfTokenValue}},watch:{perPage:function(){this.$events.fire("refresh-table",this.$refs.vuetable)}},mounted(){this.$events.$on("filter-set",a=>this.onFilterSet(a)),this.$events.$on("filter-reset",()=>this.onFilterReset()),this.$refs.vuetable.$on("vuetable:checkbox-toggled",(a,e)=>this.onCheckboxToggled(a,e)),this.$refs.vuetable.$on("vuetable:checkbox-toggled-all",a=>this.onCheckboxToggled(a,null))},methods:{getSaveStateConfig(){return{cacheKey:"retour-shortlinks-state-v2-"+Craft.username+Craft.siteId,ignoreProperties:["numSelected","selectedIds","moreParams"]}},onFilterSet(a){this.filterText=a,this.moreParams={filter:this.filterText,siteId:this.siteId,shortLinks:!0},this.$events.fire("refresh-table",this.$refs.vuetable)},onFilterReset(){this.filterText="",this.moreParams={filter:this.filterText,siteId:this.siteId,shortLinks:!0},this.$events.fire("refresh-table",this.$refs.vuetable)},onPaginationData(a){this.$refs.paginationTop.setPaginationData(a),this.$refs.paginationInfoTop.setPaginationData(a),this.$refs.pagination.setPaginationData(a),this.$refs.paginationInfo.setPaginationData(a)},onChangePage(a){this.$refs.vuetable.changePage(a)},onCheckboxToggled(){this.numSelected=0,this.selectedIds=[],this.$refs.vuetable!==void 0&&this.$refs.vuetable.selectedTo!==void 0&&(this.numSelected=this.$refs.vuetable.selectedTo.length,this.selectedIds=this.$refs.vuetable.selectedTo)},matchFormatter(a){let e="Pluing Match";switch(a){case"exactmatch":e="Exact Match";break;case"regexmatch":e="RegEx Match";break}return e},urlFormatter(a){if(a==="")return"";a=p.sanitize(a),a=encodeURI(a);let e=a;return!new RegExp("^(?:[a-z]+:)?//","i").test(e)&&!e.includes("$")&&(e=Craft.getSiteUrl(e)),`
                <a class="go" href="${e}" title="${e}" target="_blank" rel="noopener">${a}</a>
                `},deleteRedirectFormatter(a){return a===""?"":`
                <a class="delete icon" href="${a}" title="Delete"></a>
                `}}};var P=function(){var e=this,t=e._self._c;return t("div",[t("div",{directives:[{name:"show",rawName:"v-show",value:e.numSelected!==0,expression:"numSelected !== 0"}]},[t("form",{attrs:{"accept-charset":"UTF-8",method:"post"}},[t("input",{attrs:{name:e.csrfTokenName,type:"hidden"},domProps:{value:e.csrfTokenValue}}),e._l(e.selectedIds,function(r){return t("input",{key:r,attrs:{name:"redirectIds[]",type:"hidden"},domProps:{value:r}})}),t("label",{staticClass:"text-gray-600"},[e._v(e._s(e.numSelected)+" "),e.numSelected===1?t("span",[e._v(e._s(e.stringRedirect))]):e._e(),e.numSelected!==1?t("span",[e._v(e._s(e.stringRedirects))]):e._e(),e._v(":")]),t("div",{staticClass:"btngroup inline"},[t("div",{staticClass:"ml-2 btn menubtn",attrs:{"data-icon":"settings"}}),t("div",{staticClass:"menu",attrs:{"data-align":"right"}},[t("ul",[t("li",[t("a",{staticClass:"formsubmit",attrs:{"data-action":"retour/redirects/delete-shortlinks"}},[e._v(e._s(e.stringDelete))])])])])])],2)]),t("vuetable-filter-bar",{directives:[{name:"show",rawName:"v-show",value:e.numSelected===0,expression:"numSelected === 0"}],attrs:{"initial-filter-text":e.filterText}}),t("div",{staticClass:"vuetable-pagination clearafter"},[t("vuetable-pagination-info",{ref:"paginationInfoTop"}),t("div",{staticClass:"floated left vuetable-pagination-info py-3"},[t("div",{staticClass:"inline pl-3 text-gray-600"},[e._v(" "+e._s(e.stringPerPage)+" ")]),t("div",{staticClass:"inline pl-3 text-gray-600"},[t("div",{staticClass:"select"},[t("select",{directives:[{name:"model",rawName:"v-model",value:e.perPage,expression:"perPage"}],staticClass:"fieldtoggle",attrs:{"data-target-prefix":"per-page-",name:"perPage"},on:{change:function(r){var n=Array.prototype.filter.call(r.target.options,function(s){return s.selected}).map(function(s){var o="_value"in s?s._value:s.value;return o});e.perPage=r.target.multiple?n:n[0]}}},[t("option",{attrs:{selected:"",value:"20"}},[e._v(" 20 ")]),t("option",{attrs:{value:"50"}},[e._v(" 50 ")]),t("option",{attrs:{value:"100"}},[e._v(" 100 ")]),t("option",{attrs:{value:"500"}},[e._v(" 500 ")])])])])]),t("vuetable-pagination",{ref:"paginationTop",on:{"vuetable-pagination:change-page":e.onChangePage}})],1),t("vuetable",{ref:"vuetable",attrs:{"api-url":e.apiUrl,"append-params":e.moreParams,css:e.css,fields:e.fields,"per-page":e.perPage,"sort-order":e.sortOrder},on:{"vuetable:pagination-data":e.onPaginationData}}),t("div",{staticClass:"vuetable-pagination clearafter border-solid"},[t("vuetable-pagination-info",{ref:"paginationInfo"}),t("vuetable-pagination",{ref:"pagination",on:{"vuetable-pagination:change-page":e.onChangePage}})],1)],1)},k=[],w=l($,P,k,!1,null,null);const y=w.exports,i=window.Vue;i.use(m);new i({el:"#cp-nav-content",components:{"shortlinks-table":y},mounted(){this.$events.$on("refresh-table",a=>this.onTableRefresh(a))},methods:{onTableRefresh(a){i.nextTick(()=>a.refresh())}}});
//# sourceMappingURL=shortlinks-Jev4OoWa.js.map
