From 642994833a548dee253357b0752beb361cc1b854 Mon Sep 17 00:00:00 2001 From: acelaya Date: Fri, 1 Nov 2024 11:49:56 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20preview-env=20from=20@=20shlin?= =?UTF-8?q?kio/shlink-web-client@913264b0dbbb73ee114d2f0dfdf45bd77598a408?= =?UTF-8?q?=20=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/{index-75rZeHHF.js => index-a1IVSAfq.js} | 2 +- feature/predictable-server-ids/index.html | 2 +- feature/predictable-server-ids/service-worker.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename feature/predictable-server-ids/assets/{index-75rZeHHF.js => index-a1IVSAfq.js} (98%) diff --git a/feature/predictable-server-ids/assets/index-75rZeHHF.js b/feature/predictable-server-ids/assets/index-a1IVSAfq.js similarity index 98% rename from feature/predictable-server-ids/assets/index-75rZeHHF.js rename to feature/predictable-server-ids/assets/index-a1IVSAfq.js index 812493d0..8e1bc02f 100644 --- a/feature/predictable-server-ids/assets/index-75rZeHHF.js +++ b/feature/predictable-server-ids/assets/index-a1IVSAfq.js @@ -733,7 +733,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho top: -9999px; z-index: 999999; display: none; - `,document.body.append(t.touchedNode),MB(e.targetData.node.el,t.touchedNode),t.touchedNode.style.display="none",document.addEventListener("contextmenu",UB)}function p4e(e,t){const n=e.targetData.parent.data.config;n.longTouch&&(t.longTouchTimeout=setTimeout(()=>{t&&(t.longTouch=!0,n.longTouchClass&&e.e.cancelable&&bl(t.draggedNodes.map(r=>r.el),n.longTouchClass),e.e.preventDefault())},n.longTouchTimeout||200))}function m4e(e){!Ge||!("touchedNode"in Ge)||S4e(e,Ge)}function v4e(e,t){t.longTouchClass&&Oy(e.draggedNodes.map(n=>n.el),t==null?void 0:t.longTouchClass),t.touchDraggingClass&&bl([e.touchedNode],t.touchDraggingClass),t.touchDropZoneClass&&bl(e.draggedNodes.map(n=>n.el),t.touchDropZoneClass)}function g4e(e){if(!e||!e.scrollParent)return;const{x:t,y:n,width:r,height:i}=e.scrollParent.getBoundingClientRect(),{x:o,y:a,scrollOutside:s}=e.lastParent.data.config.scrollBehavior;return{state:e,xThresh:o,yThresh:a,scrollOutside:s,scrollParent:e.scrollParent,x:t,y:n,width:r,height:i}}function y4e(e){const t=g4e(Ge);if(t)switch(e){case"down":return w4e(t.state,t);case"up":return x4e(t.state,t);case"right":return b4e(t.state,t);case"left":return _4e(t.state,t)}}function b4e(e,t){const n=t.scrollParent.clientWidth+t.x-e.coordinates.x;if(!(!t.scrollOutside&&n<0)&&n<(1-t.xThresh)*t.scrollParent.clientWidth&&!(t.scrollParent.scrollLeft+t.scrollParent.clientWidth>=t.scrollParent.scrollWidth))return e}function _4e(e,t){const n=t.scrollParent.clientWidth+t.x-e.coordinates.x;if(!(!t.scrollOutside&&n>t.scrollParent.clientWidth)&&n>t.xThresh*t.scrollParent.clientWidth&&t.scrollParent.scrollLeft!==0)return e}function x4e(e,t){const n=t.scrollParent.clientHeight+t.y-e.coordinates.y;if(!(!t.scrollOutside&&n>t.scrollParent.clientHeight)&&n>t.yThresh*t.scrollParent.clientHeight&&t.scrollParent.scrollTop!==0)return e}function w4e(e,t){const n=t.scrollParent.clientHeight+t.y-e.coordinates.y;if(!(!t.scrollOutside&&n<0)&&n<(1-t.yThresh)*t.scrollParent.clientHeight&&!(t.scrollParent.scrollTop+t.scrollParent.clientHeight>=t.scrollParent.scrollHeight))return e}function O4e(e,t){t.touchMoving=!0,t.touchedNode.style.display=t.touchedNodeDisplay||"";const{x:n,y:r}=Tl(e.e);t.coordinates.y=r,t.coordinates.x=n;const i=t.touchStartLeft??0,o=t.touchStartTop??0;t.touchedNode.style.left=`${n-i}px`,t.touchedNode.style.top=`${r-o}px`,v4e(t,e.targetData.parent.data.config)}function S4e(e,t){if(e.targetData.parent.data.config.longTouch&&!t.longTouch){clearTimeout(t.longTouchTimeout);return}e.e.cancelable&&e.e.preventDefault(),O4e(e,t),db();const n=HLe(e);if(!n)return;const r={e:e.e,targetData:n};"node"in n?n.node.el.dispatchEvent(new CustomEvent("touchOverNode",{detail:r})):n.parent.el.dispatchEvent(new CustomEvent("touchOverParent",{detail:r}))}function db(){for(const e of Object.keys(f4)){const[t,n]=f4[e];zB(e,t,n)}}function zB(e,t,n){const r=y4e(e);r&&(r.scrollParent.scrollBy(t,n),setTimeout(()=>{zB(e,t,n)},"touchedNode"in r?10:100))}function P4e(e){if(!Ge)return;const{x:t,y:n}=Tl(e.e);Ge.coordinates.y=n,Ge.coordinates.x=t,db(),j4e(e,Ge)}function E4e(e){if(!Ge)return;const{x:t,y:n}=Tl(e.e);Ge.coordinates.y=n,Ge.coordinates.x=t,db(),hb(e,Ge)}function C4e(e){Ge&&hb(e.detail,Ge)}function T4e(e,t){if(e.targetData.parent.el===t.lastParent.el)return!1;const n=e.targetData.parent.data.config;if(n.dropZone===!1)return!1;const r=t.initialParent.data.config;return n.accepts?n.accepts(e.targetData.parent,t.initialParent,t.lastParent,t):!(!n.group||n.group!==r.group)}function j4e(e,t){var n;e.e.preventDefault(),e.e.stopPropagation(),e.targetData.parent.el===((n=t.lastParent)==null?void 0:n.el)?VB(e,t):hb(e,t)}function A4e(e,t,n,r){var i;if(t.remapJustFinished)return t.remapJustFinished=!1,t.lastTargetValue=e.targetData.node.data.value,!1;if(t.lastTargetValue===e.targetData.node.data.value||t.draggedNodes.map(p=>p.el).includes(e.targetData.node.el)||t.preventEnter||t.swappedNodeValue===e.targetData.node.data.value||e.targetData.parent.el!==((i=t.lastParent)==null?void 0:i.el)||e.targetData.parent.data.config.sortable===!1)return!1;const o=e.targetData.node.el.getBoundingClientRect(),a=t.draggedNode.el.getBoundingClientRect(),s=o.y-a.y,l=o.x-a.x;let c;const f=t.draggedNode.data.index>e.targetData.node.data.index?[e.targetData.node.data.index,t.draggedNode.data.index]:[t.draggedNode.data.index,e.targetData.node.data.index];t.targetIndex=e.targetData.node.data.index,t.affectedNodes=e.targetData.parent.data.enabledNodes.filter(p=>f[0]<=p.data.index&&p.data.index<=f[1]&&p.el!==t.draggedNode.el),Math.abs(s)>Math.abs(l)?c=s>0?"above":"below":c=l>0?"left":"right";const d=t.lastParent.data.config.threshold;switch(c){case"left":if(n>o.x+o.width*d.horizontal)return t.incomingDirection="left",!0;break;case"right":if(no.y+o.height*d.vertical)return t.incomingDirection="above",!0;break;case"below":if(r{const r=t(n.currentTarget);if(r)return e({e:n,targetData:r})}}function k4e(e,t){const n=$B(e),r=ZO(e.lastParent.el,e.lastParent.data).filter(s=>!n.includes(s)),i=ZO(t.targetData.parent.el,t.targetData.parent.data),o=e.initialParent.el===t.targetData.parent.el&&t.targetData.parent.data.config.sortable===!1;let a;"node"in t.targetData?(o?a=e.initialIndex:t.targetData.parent.data.config.sortable===!1?a=t.targetData.parent.data.enabledNodes.length:a=t.targetData.node.data.index,i.splice(a,0,...n)):(a=o?e.initialIndex:t.targetData.parent.data.enabledNodes.length,i.splice(a,0,...n)),XO(e.lastParent.el,e.lastParent.data,r),XO(t.targetData.parent.el,t.targetData.parent.data,i)}function hb(e,t){T4e(e,t)&&(e.targetData.parent.data.config.performTransfer(t,e),t.lastParent=e.targetData.parent)}function N4e(e){function t(n){const r=Ei.get(n);if(r)return{parent:{el:n,data:r}}}return n=>{const r=t(n.currentTarget);if(r)return e({e:n,targetData:r})}}function M4e(e){if(e instanceof HTMLElement)return e;if("current"in e&&e.current instanceof HTMLElement)return e.current;console.warn("Invalid parent element",e)}function L4e(e,t){const n=M4e(e);n&&t(n)}var Sy=new WeakMap;function R4e(e){const t=Sy.get(e);return t?t[0]:(console.warn("No values found for parent element"),[])}function $4e(e,t){const n=Sy.get(t);n&&n[1](e),Sy.set(t,[e,n[1]])}function I4e(e,t){return n=>{Sy.set(n,t),YLe({parent:n,getValues:R4e,setValues:$4e,config:e})}}function d4(e){AB&&(Array.isArray(e)||(e=[e]),e.forEach(t=>{const{parent:n,state:r,...i}=t;L4e(n,I4e(i,r))}))}function D4e(e,t={}){const n=M.useRef(null),[r,i]=M.useState(e);function o(a={}){d4({parent:n,state:[r,i],...a})}return M.useEffect(()=>{d4({parent:n,state:[r,i],...t})},[r]),M.useEffect(()=>()=>{n.current&&IB(n.current)},[]),[n,r,i,o]}const pb=()=>{const e=po(),t=ds(),n=$u(),r=M.useMemo(()=>{const{orderBy:o,tags:a,excludeBots:s,excludeMaxVisitsReached:l,excludePastValidUntil:c,...f}=n,d=o?Yre(o):void 0,p=(a==null?void 0:a.split(","))??[];return{...f,orderBy:d,tags:p,excludeBots:s!==void 0?s==="true":void 0,excludeMaxVisitsReached:l!==void 0?l==="true":void 0,excludePastValidUntil:c!==void 0?c==="true":void 0}},[n]),i=M.useCallback(o=>{const a={...r,...o},{orderBy:s,tags:l,excludeBots:c,excludeMaxVisitsReached:f,excludePastValidUntil:d,...p}=a,v={...p,orderBy:s&&Kre(s),tags:l.length>0?l.join(","):void 0,excludeBots:h_(c),excludeMaxVisitsReached:h_(f),excludePastValidUntil:h_(d)},y=s0(v),g=y?`?${y}`:"";e(`${t}/list-short-urls/1${g}`)},[r,e,t]);return[r,i]},wC=()=>{const{domain:e}=$u(),{shortCode:t=""}=Mu();return M.useMemo(()=>({shortCode:hC(t),domain:e}),[e,t])},mb=()=>{const e=mLe();return m.jsx(qe,{color:"link",size:"lg",className:"p-0 me-3",onClick:e,"aria-label":"Go back",children:m.jsx(je,{icon:gK})})},F4e=(e,{maxVersion:t,minVersion:n})=>{const r=!n||u2(e,n,">=");return(!t||u2(e,t,"<="))&&r},WB={excludeBotsOnShortUrls:{minVersion:"3.4.0"},filterDisabledUrls:{minVersion:"3.4.0"},deviceLongUrls:{minVersion:"3.5.0",maxVersion:"3.*.*"},shortUrlVisitsDeletion:{minVersion:"3.6.0"},orphanVisitsDeletion:{minVersion:"3.7.0"},shortUrlRedirectRules:{minVersion:"4.0.0"},urlValidation:{maxVersion:"3.*.*"},ipRedirectCondition:{minVersion:"4.2.*"}};Object.freeze(WB);const ua=(e,t)=>t==="latest"||F4e(t,WB[e]),HB=e=>({excludeBotsOnShortUrls:ua("excludeBotsOnShortUrls",e),filterDisabledUrls:ua("filterDisabledUrls",e),deviceLongUrls:ua("deviceLongUrls",e),shortUrlVisitsDeletion:ua("shortUrlVisitsDeletion",e),orphanVisitsDeletion:ua("orphanVisitsDeletion",e),shortUrlRedirectRules:ua("shortUrlRedirectRules",e),urlValidation:ua("urlValidation",e),ipRedirectCondition:ua("ipRedirectCondition",e)}),GB=M.createContext(HB("0.0.0")),B4e=GB.Provider,U4e=e=>M.useMemo(()=>HB(e),[e]),Ko=e=>M.useContext(GB)[e],z4e={android:"Android",ios:"iOS",desktop:"Desktop"},V4e=({deviceType:e,onDeviceTypeChange:t})=>{const n=M.useId();return m.jsxs("div",{children:[m.jsx("label",{htmlFor:n,children:"Device type:"}),m.jsxs("select",{id:n,className:"form-select",value:e,onChange:r=>t(r.target.value),required:!0,children:[!e&&m.jsx("option",{value:"",children:"- Select type -"}),Object.entries(z4e).map(([r,i])=>m.jsx("option",{value:r,children:i},r))]})]})},qB=({value:e,onValueChange:t,label:n,placeholder:r})=>{const i=M.useId();return m.jsxs("div",{children:[m.jsxs("label",{htmlFor:i,children:[n,":"]}),m.jsx(An,{id:i,value:e??"",onChange:o=>t(o.target.value),placeholder:r,required:!0})]})},W4e=({language:e,onLanguageChange:t})=>m.jsx(qB,{value:e,onValueChange:t,label:"Language",placeholder:"en-US / en"}),H4e=({name:e,value:t,onNameChange:n,onValueChange:r})=>{const i=M.useId(),o=M.useId();return m.jsxs(m.Fragment,{children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:i,children:"Param name:"}),m.jsx(An,{id:i,value:e??"",onChange:a=>n(a.target.value),placeholder:"hello",required:!0})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:o,children:"Param value:"}),m.jsx(An,{id:o,value:t??"",onChange:a=>r(a.target.value),placeholder:"world",required:!0})]})]})},G4e=({ipAddress:e,onIpAddressChange:t})=>m.jsx(qB,{value:e,onValueChange:t,label:"IP address",placeholder:"192.168.1.10"}),q4e=({condition:e,onConditionChange:t,onDelete:n})=>{const r=M.useId(),i=M.useCallback(c=>t({type:c,matchValue:"",matchKey:null}),[t]),o=M.useCallback(c=>t({...e,matchValue:c}),[e,t]),a=M.useCallback(c=>t({...e,matchKey:c}),[e,t]),s=Ko("ipRedirectCondition"),l=M.useMemo(()=>{const c={device:"Device type",language:"Language","query-param":"Query param"};return s?{...c,"ip-address":"IP address"}:c},[s]);return m.jsxs("div",{className:"redirect-rule-modal__condition rounded p-3 h-100 d-flex flex-column gap-2 position-relative",children:[m.jsxs("div",{children:[m.jsx(qe,{outline:!0,size:"sm",type:"button","aria-label":"Remove condition",onClick:n,className:"position-absolute rounded-circle redirect-rule-modal__remove-condition-button",children:m.jsx(je,{icon:D6,className:"redirect-rule-modal__remove-condition-button-icon"})}),m.jsx("label",{htmlFor:r,children:"Type:"}),m.jsx("select",{id:r,className:"form-select flex-grow-1",value:e.type,onChange:c=>i(c.target.value),children:Object.entries(l).map(([c,f])=>m.jsx("option",{value:c,children:f},c))})]}),e.type==="device"&&m.jsx(V4e,{deviceType:e.matchValue,onDeviceTypeChange:o}),e.type==="language"&&m.jsx(W4e,{language:e.matchValue,onLanguageChange:o}),e.type==="query-param"&&m.jsx(H4e,{value:e.matchValue,name:e.matchKey??"",onNameChange:a,onValueChange:o}),e.type==="ip-address"&&m.jsx(G4e,{ipAddress:e.matchValue,onIpAddressChange:o})]})},KB=({isOpen:e,toggle:t,onSave:n,initialData:r})=>{const[i,o]=M.useState(r??{longUrl:"",conditions:[]}),a=M.useCallback(v=>{v.preventDefault(),v.stopPropagation(),i&&n(i),t()},[n,i,t]),s=M.useCallback(()=>o(({longUrl:v,conditions:y})=>({longUrl:v,conditions:[...y,{type:"device",matchValue:"",matchKey:null}]})),[]),l=M.useCallback((v,y)=>o(({longUrl:g,conditions:x})=>{const _=[...x];return _[v]=y,{longUrl:g,conditions:_}}),[]),c=M.useCallback(v=>o(({longUrl:y,conditions:g})=>{const x=[...g];return x.splice(v,1),{longUrl:y,conditions:x}}),[]),f=Mi(),d=M.useCallback(()=>{var v;return(v=f==null?void 0:f.current)==null?void 0:v.focus()},[f]),p=M.useCallback(()=>o(r??{longUrl:"",conditions:[]}),[r]);return m.jsx(vr,{size:"xl",isOpen:e,toggle:t,centered:!0,onOpened:d,onClosed:p,children:m.jsxs("form",{onSubmit:a,children:[m.jsx(mo,{toggle:t,className:"sticky-top redirect-rule-modal__header",children:"Redirect rule"}),m.jsxs(Li,{children:[m.jsx("label",{htmlFor:"longUrl",className:"fw-bold",children:"Long URL:"}),m.jsx(An,{id:"longUrl",type:"url",placeholder:"https://www.example.com",value:i.longUrl,onChange:v=>o(y=>({...y,longUrl:v.target.value})),required:!0,innerRef:f}),m.jsx("hr",{}),m.jsxs("div",{className:"d-flex justify-content-between",children:[m.jsx("b",{children:"Conditions:"}),m.jsx(qe,{outline:!0,size:"sm",type:"button","aria-label":"Add condition",onClick:s,children:m.jsx(je,{icon:Zh})})]}),i.conditions.length===0&&m.jsx("div",{className:"text-center",children:m.jsx("i",{children:"Add conditions..."})}),i.conditions.length>0&&m.jsx(Pr,{className:"redirect-rule-modal__conditions-row",children:i.conditions.map((v,y)=>m.jsx("div",{className:"col-lg-6 col-xl-4 mt-4",children:m.jsx(q4e,{condition:v,onConditionChange:g=>l(y,g),onDelete:()=>c(y)})},`${y}_${v.type}`))})]}),m.jsxs(as,{className:"sticky-bottom redirect-rule-modal__footer",children:[m.jsx(qe,{type:"button",color:"link",onClick:t,children:"Cancel"}),m.jsx(qe,{color:"primary",disabled:i.conditions.length===0,children:"Confirm"})]})]})})},K4e=({priority:e,isLast:t,redirectRule:n,onDelete:r,onMoveUp:i,onMoveDown:o,onUpdate:a})=>{const[s,l]=Lt();return m.jsxs(gt,{children:[m.jsxs("div",{className:"d-flex align-content-center gap-3",children:[m.jsx("div",{className:"d-flex flex-column my-auto drag-n-drop-handler d-none d-md-block",style:{cursor:"grab"},children:m.jsx(je,{icon:OK})}),m.jsxs("div",{className:"d-flex flex-column my-auto",children:[m.jsx(qe,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} up`,disabled:e===1,onClick:i,className:"rounded-0 rounded-top",style:{marginBottom:"-1px"},children:m.jsx(je,{icon:DK})}),m.jsx(qe,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} down`,disabled:t,onClick:o,className:"rounded-0 rounded-bottom",children:m.jsx(je,{icon:MK})})]}),m.jsxs("div",{className:"flex-grow-1",children:[m.jsxs("div",{className:"mb-2",children:[m.jsx("b",{children:"Long URL:"})," ",m.jsx(hr,{href:n.longUrl,"data-testid":"rule-long-url"})]}),m.jsxs("div",{className:"d-flex flex-column flex-lg-row gap-2",children:[m.jsx("b",{children:"Conditions:"}),n.conditions.map((c,f)=>m.jsxs("div",{className:"badge bg-secondary",children:[c.type==="device"&&m.jsxs(m.Fragment,{children:["Device is ",c.matchValue]}),c.type==="language"&&m.jsxs(m.Fragment,{children:[c.matchValue," language is accepted"]}),c.type==="query-param"&&m.jsxs(m.Fragment,{children:["Query string contains ",c.matchKey,"=",c.matchValue]}),c.type==="ip-address"&&m.jsxs(m.Fragment,{children:["IP address matches ",c.matchValue]})]},`${c.type}_${f}`))]})]}),m.jsxs("div",{className:"d-flex flex-column flex-sm-row gap-1 my-auto",children:[m.jsx(qe,{outline:!0,color:"secondary",size:"sm","aria-label":`Edit rule with priority ${e}`,onClick:l,children:m.jsx(je,{icon:N6})}),m.jsx(qe,{outline:!0,color:"danger",size:"sm","aria-label":`Delete rule with priority ${e}`,onClick:r,children:m.jsx(je,{icon:Yq})})]})]}),m.jsx(KB,{onSave:a,isOpen:s,toggle:l,initialData:n})]})},Y4e=({shortUrlRedirectRules:e,getShortUrlRedirectRules:t,getShortUrlsDetails:n,shortUrlsDetails:r,setShortUrlRedirectRules:i,shortUrlRedirectRulesSaving:o,resetSetRules:a})=>{const s=wC(),{shortUrls:l}=r,c=s&&(l==null?void 0:l.get(s)),[f,d,p]=D4e([],{dragHandle:".drag-n-drop-handler",dropZoneClass:"opacity-25"}),{saving:v,saved:y,errorData:g}=o,[x,_]=Lt(),b=M.useCallback(F=>p((k=[])=>[...k,F]),[p]),w=M.useCallback(F=>p((k=[])=>{const I=[...k];return I.splice(F,1),I}),[p]),S=M.useCallback((F,k)=>p((I=[])=>{const D=[...I];return D[F]=k,D}),[p]),P=M.useCallback((F,k)=>p((I=[])=>{if(!I[k])return I;const D=[...I],K=D[k];return D[k]=D[F],D[F]=K,D}),[p]),E=M.useCallback(F=>P(F,F-1),[P]),T=M.useCallback(F=>P(F,F+1),[P]),j=M.useCallback(F=>{F.preventDefault(),d&&i({shortUrl:s,data:{redirectRules:d}})},[s,d,i]);return M.useEffect(()=>(t(s),n([s]),a),[t,n,s,a]),M.useEffect(()=>{e.redirectRules&&p(e.redirectRules)},[p,e.redirectRules]),m.jsxs("div",{className:"d-flex flex-column gap-3",children:[m.jsx("header",{children:m.jsxs(Dr,{body:!0,children:[m.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[m.jsx(mb,{}),m.jsxs("div",{className:"text-center flex-grow-1",children:[r.loading&&m.jsx(m.Fragment,{children:"Loading..."}),!r.loading&&m.jsxs("small",{children:["Redirect rules for ",m.jsx(hr,{href:(c==null?void 0:c.shortUrl)??""})]})]})]}),m.jsx("hr",{}),m.jsxs("div",{children:[m.jsx("p",{className:"mb-2",children:"Configure dynamic conditions that will be checked at runtime."}),"If no conditions match, visitors will be redirected to: ",m.jsx(hr,{href:e.defaultLongUrl??""})]})]})}),m.jsx("div",{children:m.jsxs(qe,{outline:!0,color:"primary",onClick:_,children:[m.jsx(je,{icon:Zh,className:"me-1"})," Add rule"]})}),m.jsxs("form",{onSubmit:j,children:[e.loading&&m.jsx(zo,{loading:!0}),d.length===0&&!e.loading&&m.jsx(gt,{className:"text-center",children:m.jsx("i",{children:"This short URL has no dynamic redirect rules"})}),m.jsx("div",{className:"d-flex flex-column gap-2",ref:f,children:d.map((F,k)=>m.jsx(K4e,{redirectRule:F,priority:k+1,isLast:k===d.length-1,onDelete:()=>w(k),onMoveUp:()=>E(k),onMoveDown:()=>T(k),onUpdate:I=>S(k,I)},`${F.longUrl}_${k}`))}),m.jsx("div",{className:"text-center mt-3",children:m.jsx(qe,{outline:!0,color:"primary",className:"btn-sm-block",disabled:v,"data-testid":"save-button",children:v?"Saving...":"Save rules"})})]}),g&&m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:g,fallbackMessage:"An error occurred while saving short URL redirect rules :("})}),y&&m.jsx(Zn,{type:"success",children:"Redirect rules properly saved."}),m.jsx(KB,{isOpen:x,toggle:_,onSave:b})]})},Z4e=(e,t)=>{e.serviceFactory("ShortUrlRedirectRules",()=>Y4e),e.decorator("ShortUrlRedirectRules",t(["shortUrlRedirectRules","shortUrlsDetails","shortUrlRedirectRulesSaving"],["getShortUrlRedirectRules","getShortUrlsDetails","setShortUrlRedirectRules","resetSetRules"])),e.serviceFactory("getShortUrlRedirectRules",zLe,"apiClientFactory"),e.serviceFactory("setShortUrlRedirectRules",FLe,"apiClientFactory"),e.serviceFactory("resetSetRules",n=>n.resetSetRules,"setShortUrlRedirectRulesReducerCreator"),e.serviceFactory("shortUrlRedirectRulesReducerCreator",VLe,"getShortUrlRedirectRules"),e.serviceFactory("shortUrlRedirectRulesReducer",n=>n.reducer,"shortUrlRedirectRulesReducerCreator"),e.serviceFactory("setShortUrlRedirectRulesReducerCreator",BLe,"setShortUrlRedirectRules"),e.serviceFactory("setShortUrlRedirectRulesReducer",n=>n.reducer,"setShortUrlRedirectRulesReducerCreator")},X4e=e=>({longUrl:"",tags:[],customSlug:"",title:void 0,shortCodeLength:void 0,domain:"",validSince:void 0,validUntil:void 0,maxVisits:void 0,findIfExists:!1,validateUrl:(e==null?void 0:e.validateUrls)??!1,forwardQuery:(e==null?void 0:e.forwardQuery)??!0}),YB=({createShortUrl:e,shortUrlCreation:t,resetCreateShortUrl:n,basicMode:r=!1})=>{const{ShortUrlForm:i,CreateShortUrlResult:o}=Rt(YB),a=nr("shortUrlCreation"),s=M.useMemo(()=>X4e(a),[a]);return m.jsxs(m.Fragment,{children:[m.jsx(i,{initialState:s,saving:t.saving,basicMode:r,onSave:async l=>(n(),e(l))}),m.jsx(o,{creation:t,resetCreateShortUrl:n,canBeClosed:r})]})},Q4e=$t(YB,["ShortUrlForm","CreateShortUrlResult"]),ZB=({shortUrlsDetails:e,getShortUrlsDetails:t,shortUrlEdition:n,editShortUrl:r})=>{const{ShortUrlForm:i}=Rt(ZB),o=wC(),{loading:a,error:s,errorData:l,shortUrls:c}=e,f=o&&(c==null?void 0:c.get(o)),{saving:d,saved:p,error:v,errorData:y}=n,g=nr("shortUrlCreation"),x=M.useMemo(()=>WMe(f,g),[f,g]);return M.useEffect(()=>{o&&t([o])},[t,o]),a?m.jsx(zo,{loading:!0}):s?m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:l,fallbackMessage:"An error occurred while loading short URL detail :("})}):m.jsxs(m.Fragment,{children:[m.jsx("header",{className:"mb-3",children:m.jsx(Dr,{body:!0,children:m.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[m.jsx(mb,{}),m.jsx("div",{className:"text-center flex-grow-1",children:m.jsxs("small",{children:["Edit ",m.jsx(hr,{href:(f==null?void 0:f.shortUrl)??""})]})})]})})}),m.jsx(i,{initialState:x,saving:d,onSave:async _=>{f&&r({...f,data:_})}}),p&&v&&m.jsx(Zn,{type:"error",className:"mt-3",children:m.jsx(ho,{errorData:y,fallbackMessage:"An error occurred while updating short URL :("})}),p&&!v&&m.jsx(Zn,{type:"success",className:"mt-3",children:"Short URL properly edited."})]})},J4e=$t(ZB,["ShortUrlForm"]),XB=({text:e,onCopy:t},n=navigator)=>{var r;return(r=n.clipboard)==null?void 0:r.writeText(e).then(()=>t==null?void 0:t(e,!0)).catch(()=>t==null?void 0:t(e,!1))},QB=({creation:e,resetCreateShortUrl:t,canBeClosed:n=!1})=>{const{useTimeoutToggle:r}=Rt(QB),[i,o]=r(),{error:a,saved:s}=e;if(M.useEffect(()=>{t()},[t]),a)return m.jsxs(Zn,{type:"error",className:"mt-3",children:[n&&m.jsx(je,{"data-testid":"error-close-button",icon:_x,className:"float-end pointer",onClick:t}),m.jsx(ho,{errorData:e.errorData,fallbackMessage:"An error occurred while creating the URL :("})]});if(!s)return null;const{shortUrl:l}=e.result;return m.jsxs(Zn,{type:"success",className:"mt-3",children:[n&&m.jsx(je,{"data-testid":"success-close-button",icon:_x,className:"float-end pointer",onClick:t}),m.jsxs("span",{children:[m.jsx("b",{children:"Great!"})," The short URL is ",m.jsx("b",{children:l})]}),m.jsxs("button",{className:"btn btn-light btn-sm create-short-url-result__copy-btn",id:"copyBtn",type:"button",onClick:()=>XB({text:l,onCopy:o}),children:[m.jsx(je,{icon:YD})," Copy ",m.jsxs("span",{className:"sr-only",children:[l," to clipboard"]})]}),m.jsx(o0,{placement:"left",isOpen:i,target:"copyBtn",children:"Copied!"})]})},eRe=$t(QB,["useTimeoutToggle"]),v_="delete",tRe=({shortUrl:e,toggle:t,isOpen:n,shortUrlDeletion:r,resetDeleteShortUrl:i,deleteShortUrl:o,shortUrlDeleted:a})=>{const[s,l]=M.useState("");M.useEffect(()=>i,[i]);const{loading:c,error:f,deleted:d,errorData:p}=r,v=M.useCallback(()=>{i(),t()},[i,t]),y=M.useCallback(g=>(g.preventDefault(),o(e).then(x=>!cC(x)&&t())),[o,e,t]);return m.jsx(vr,{isOpen:n,toggle:v,centered:!0,onClosed:()=>d&&a(e),children:m.jsxs("form",{onSubmit:y,children:[m.jsx(mo,{toggle:v,children:m.jsx("span",{className:"text-danger",children:"Delete short URL"})}),m.jsxs(Li,{children:[m.jsxs("p",{children:[m.jsx("b",{className:"text-danger",children:"Caution!"})," You are about to delete a short URL."]}),m.jsx("p",{children:"This action cannot be undone. Once you have deleted it, all the visits stats will be lost."}),m.jsxs("p",{children:["Write ",m.jsx("b",{children:v_})," to confirm deletion."]}),m.jsx("input",{type:"text",className:"form-control",placeholder:`Insert ${v_}`,value:s,onChange:g=>l(g.target.value)}),f&&m.jsx(Zn,{type:FMe(p)?"warning":"error",small:!0,className:"mt-2",children:m.jsx(ho,{errorData:p,fallbackMessage:"Something went wrong while deleting the URL :("})})]}),m.jsxs(as,{children:[m.jsx("button",{type:"button",className:"btn btn-link",onClick:v,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-danger",disabled:s!==v_||c,children:c?"Deleting...":"Delete"})]})]})})},JB=({amount:e=0,loading:t=!1,...n})=>m.jsxs(qe,{...n,outline:!0,color:"primary",disabled:t,children:[m.jsx(je,{icon:eK})," ",t?"Exporting...":m.jsxs(m.Fragment,{children:["Export (",qt(e),")"]})]}),h4=20,eU=({amount:e=0})=>{const{apiClientFactory:t,ReportExporter:n}=Rt(eU),[{tags:r,search:i,startDate:o,endDate:a,orderBy:s,tagsMode:l}]=pb(),[c,,f,d]=Lt(),p=M.useCallback(async()=>{const v=e/h4,y=async(x=1)=>{const{data:_}=await t().listShortUrls({page:`${x}`,tags:r,searchTerm:i,startDate:o,endDate:a,orderBy:s,tagsMode:l,itemsPerPage:h4});return x>=v?_:_.concat(await y(x+1))};f();const g=await y();n.exportShortUrls(g.map(x=>{var _;const{hostname:b,pathname:w}=new URL(x.shortUrl),S=w.substring(1);return{createdAt:x.dateCreated,domain:b,shortCode:S,shortUrl:x.shortUrl,longUrl:x.longUrl,title:x.title??"",tags:x.tags.join("|"),visits:((_=x==null?void 0:x.visitsSummary)==null?void 0:_.total)??x.visitsCount??0}})),d()},[e,t,a,s,n,i,o,f,d,r,l]);return m.jsx(JB,{loading:c,className:"btn-md-block",amount:e,onClick:p})},nRe=$t(eU,["apiClientFactory","ReportExporter"]),tU=({text:e,onCopy:t,copyToClipboard:n=XB})=>m.jsx(yl,{className:"ms-2 p-0","aria-label":`Copy ${e} to clipboard`,onClick:()=>n({text:e,onCopy:t}),children:m.jsx(je,{icon:YD,className:"fs-5"})}),rRe=(e,t)=>{const n=`${e}/qr-code`,r=s0({...t});return`${n}${r?`?${r}`:""}`},p4=({name:e,value:t,step:n,min:r,max:i,onChange:o,className:a,initial:s=r})=>{const l=M.useId();return m.jsxs(cl,{className:a,children:[t===void 0&&m.jsxs(qe,{outline:!0,color:"link",className:"text-start fst-italic w-100",style:{color:"var(--input-text-color)",borderColor:"var(--border-color)"},onClick:()=>o(s),children:["Customize ",e]}),t!==void 0&&m.jsxs("div",{className:"d-flex gap-3",children:[m.jsxs("div",{className:"d-flex flex-column flex-grow-1",children:[m.jsxs("label",{htmlFor:l,className:"text-capitalize",children:[e,": ",t,"px"]}),m.jsx("input",{id:l,type:"range",className:"form-control-range",value:t,step:n,min:r,max:i,onChange:c=>o(Number(c.target.value))})]}),m.jsx(qe,{"aria-label":`Default ${e}`,title:`Default ${e}`,outline:!0,color:"link",onClick:()=>o(void 0),style:{color:"var(--input-text-color)",borderColor:"var(--border-color)"},children:m.jsx(je,{icon:$6})})]})]})},iRe=({errorCorrection:e,onChange:t})=>m.jsxs(ea,{text:e?`Error correction (${e})`:m.jsx("i",{children:"Default error correction"}),children:[m.jsx(Ne,{active:!e,onClick:()=>t(void 0),children:"Default"}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{active:e==="L",onClick:()=>t("L"),children:[m.jsx("b",{children:"L"}),"ow"]}),m.jsxs(Ne,{active:e==="M",onClick:()=>t("M"),children:[m.jsx("b",{children:"M"}),"edium"]}),m.jsxs(Ne,{active:e==="Q",onClick:()=>t("Q"),children:[m.jsx("b",{children:"Q"}),"uartile"]}),m.jsxs(Ne,{active:e==="H",onClick:()=>t("H"),children:[m.jsx("b",{children:"H"}),"igh"]})]}),oRe=({format:e,onChange:t})=>m.jsxs(ea,{text:e?`Format (${e})`:m.jsx("i",{children:"Default format"}),children:[m.jsx(Ne,{active:!e,onClick:()=>t(void 0),children:"Default"}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{active:e==="png",onClick:()=>t("png"),children:"PNG"}),m.jsx(Ne,{active:e==="svg",onClick:()=>t("svg"),children:"SVG"})]}),nU=({shortUrl:{shortUrl:e,shortCode:t},toggle:n,isOpen:r})=>{const{ImageDownloader:i}=Rt(nU),[o,a]=M.useState(),[s,l]=M.useState(),[c,f]=M.useState(),[d,p]=M.useState(),v=M.useMemo(()=>rRe(e,{size:o,format:c,margin:s,errorCorrection:d}),[e,o,c,s,d]),[y,g]=M.useState(),x=M.useCallback(_=>{const b=_.target,{naturalWidth:w}=b;w<500?g(void 0):g(w<800?"lg":"xl")},[]);return m.jsxs(vr,{isOpen:r,toggle:n,centered:!0,size:y,children:[m.jsxs(mo,{toggle:n,children:["QR code for ",m.jsx(hr,{href:e,children:e})]}),m.jsxs(Li,{children:[m.jsxs(Pr,{children:[m.jsx(p4,{className:"col-sm-6",name:"size",value:o,step:10,min:50,max:1e3,initial:300,onChange:a}),m.jsx(p4,{className:"col-sm-6",name:"margin",value:s,step:1,min:0,max:100,onChange:l}),m.jsx(cl,{className:"d-grid col-sm-6",children:m.jsx(oRe,{format:c,onChange:f})}),m.jsx(cl,{className:"col-sm-6",children:m.jsx(iRe,{errorCorrection:d,onChange:p})})]}),m.jsxs("div",{className:"text-center",children:[m.jsxs("div",{className:"mb-3",children:[m.jsx(hr,{href:v}),m.jsx(tU,{text:v})]}),m.jsx("img",{src:v,alt:"QR code",className:"shadow-lg",style:{maxWidth:"100%"},onLoad:x}),m.jsx("div",{className:"mt-3",children:m.jsxs(qe,{block:!0,color:"primary",onClick:()=>{i.saveImage(v,`${t}-qr-code.${c}`).catch(()=>{})},children:["Download ",m.jsx(je,{icon:I6,className:"ms-1"})]})})]})]})]})},aRe=$t(nU,["ImageDownloader"]),Py=({date:e,format:t=cB,relative:n=!1})=>{const r=mC(e)?e:Ka(e);return m.jsx("time",{dateTime:`${bae(r)}000`,children:n?`${gae(Xa(),r)} ago`:pg(r,t)})},sRe=e=>{const{meta:t,visitsCount:n,visitsSummary:r}=e,{maxVisits:i,validSince:o,validUntil:a}=t,s=(r==null?void 0:r.total)??n??0;return i&&s>=i?{icon:GK,className:"text-danger",description:m.jsxs(m.Fragment,{children:["This short URL cannot be currently visited because it has reached the maximum amount of ",m.jsx("b",{children:i})," visit",i>1?"s":"","."]})}:a&&mg(Er(a),Xa())?{icon:rA,className:"text-danger",description:m.jsxs(m.Fragment,{children:["This short URL cannot be visited since ",m.jsx("b",{className:"indivisible",children:zh(Er(a))}),"."]})}:o&&mg(Xa(),Er(o))?{icon:rA,className:"text-warning",description:m.jsxs(m.Fragment,{children:["This short URL will start working on ",m.jsx("b",{className:"indivisible",children:zh(Er(o))}),"."]})}:{icon:qd,className:"text-primary",description:"This short URL can be visited normally."}},lRe=({shortUrl:e})=>{const t=Mi(),{icon:n,className:r,description:i}=sRe(e);return m.jsxs(m.Fragment,{children:[m.jsx("span",{style:{cursor:i?"help":void 0},ref:t,children:m.jsx(je,{icon:n,className:r})}),m.jsx(Fr,{target:t,placement:"bottom",children:i})]})},cRe=(e,{shortCode:t,domain:n},r)=>{const i=n?`?domain=${n}`:"";return`${e}/short-code/${sB(t)}/${r}${i}`},ov=({shortUrl:e,suffix:t,asLink:n,children:r,...i})=>{const o=ds();return!n||!e?m.jsx("span",{...i,children:r}):m.jsx(At,{to:cRe(o,e,t),...i,children:r})},rU=({visitsCount:e,shortUrl:t,active:n=!1,asLink:r=!1})=>{const i=Mi(),{maxVisits:o,validSince:a,validUntil:s}=(t==null?void 0:t.meta)??{},l=!!o||!!a||!!s,c=m.jsx(ov,{shortUrl:t,suffix:"visits",asLink:r,children:m.jsx("strong",{className:Oe("short-url-visits-count__amount",{"short-url-visits-count__amount--big":n}),children:qt(e)})});return l?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"indivisible",children:[c,m.jsxs("small",{className:"short-urls-visits-count__max-visits-control",ref:i,children:[o&&m.jsxs(m.Fragment,{children:[" / ",qt(o)]}),m.jsx("sup",{className:"ms-1",children:m.jsx(je,{icon:cP})})]})]}),m.jsx(Fr,{target:i,placement:"bottom",children:m.jsxs("ul",{className:"list-unstyled mb-0",children:[o&&m.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept more than ",m.jsx("b",{children:qt(o)})," visit",o===1?"":"s","."]}),a&&m.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits before ",m.jsx("b",{className:"indivisible",children:zh(Er(a))}),"."]}),s&&m.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits after ",m.jsx("b",{className:"indivisible",children:zh(Er(s))}),"."]})]})})]}):c},uRe=e=>!!e.onClose,fRe=e=>!!e.onClick,vb=e=>{const{text:t,children:n,className:r,colorGenerator:i}=e,o=fRe(e),a=o?yl:"span",s=M.useMemo(()=>i.stylesForKey(t),[t,i]);return m.jsxs(a,{className:Oe("badge tag fw-bold",r,{pointer:o}),style:s,onClick:o?e.onClick:void 0,children:[n??t,uRe(e)&&m.jsx(yl,{"aria-label":`Remove ${t}`,className:"bg-transparent ms-1 opacity-100 p-0 fw-bold tag__close",onClick:e.onClose,children:"×"})]})},dRe=({tags:e,onTagClick:t,colorGenerator:n})=>e.length===0?m.jsx("i",{className:"indivisible",children:m.jsx("small",{children:"No tags"})}):m.jsx(m.Fragment,{children:e.map(r=>m.jsx(vb,{text:r,colorGenerator:n,onClick:()=>t==null?void 0:t(r)},r))}),iU=({shortUrl:e,onTagClick:t})=>{var n,r,i,o;const{ShortUrlsRowMenu:a,ColorGenerator:s,useTimeoutToggle:l}=Rt(iU),[c,f]=l(),[d,p]=l(!1,500),v=M.useRef(!0),[{excludeBots:y}]=pb(),g=nr("visits"),x=y??(g==null?void 0:g.excludeBots);return M.useEffect(()=>{v.current||p(),v.current=!1},[(n=e.visitsSummary)==null?void 0:n.total,(r=e.visitsSummary)==null?void 0:r.nonBots,e.visitsCount,p]),m.jsxs("tr",{className:"responsive-table__row",children:[m.jsx("td",{className:"indivisible short-urls-row__cell responsive-table__cell","data-th":"Created at",children:m.jsx(Py,{date:e.dateCreated})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Short URL",children:m.jsxs("span",{className:"position-relative short-urls-row__cell--indivisible",children:[m.jsx("span",{className:"short-urls-row__short-url-wrapper",children:m.jsx(hr,{href:e.shortUrl})}),m.jsx(tU,{text:e.shortUrl,onCopy:f}),m.jsx("span",{role:"status",className:"badge bg-warning text-black short-urls-row__copy-hint",hidden:!c,children:"Copied short URL!"})]})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell short-urls-row__cell--break","data-th":`${e.title?"Title":"Long URL"}`,children:m.jsx(hr,{href:e.longUrl,children:e.title??e.longUrl})}),e.title&&m.jsx("td",{className:"short-urls-row__cell responsive-table__cell short-urls-row__cell--break d-lg-none","data-th":"Long URL",children:m.jsx(hr,{href:e.longUrl})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Tags",children:m.jsx(dRe,{tags:e.tags,colorGenerator:s,onTagClick:t})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-lg-end","data-th":"Visits",children:m.jsx(rU,{visitsCount:(x?(i=e.visitsSummary)==null?void 0:i.nonBots:(o=e.visitsSummary)==null?void 0:o.total)??e.visitsCount??0,shortUrl:e,active:d,asLink:!0})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Status",children:m.jsx(lRe,{shortUrl:e})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-end",children:m.jsx(a,{shortUrl:e})})]})},hRe=$t(iU,["ShortUrlsRowMenu","ColorGenerator","useTimeoutToggle"]),oU=({shortUrl:e,deleteShortUrl:t,shortUrlDeleted:n})=>{const{DeleteShortUrlModal:r,QrCodeModal:i}=Rt(oU),[o,,a,s]=Lt(),[l,,c,f]=Lt(),d=cb(),p=Ko("shortUrlRedirectRules"),{confirmDeletions:v=!0}=nr("shortUrlsList",{}),y=M.useCallback(async()=>{const g=await t(e);cC(g)||n(e)},[t,e,n]);return m.jsxs(l0,{minWidth:p?220:190,children:[m.jsxs(Ne,{tag:ov,shortUrl:e,suffix:"visits",asLink:!0,children:[m.jsx(je,{icon:lP,fixedWidth:!0})," Visit stats"]}),d&&m.jsxs(m.Fragment,{children:[m.jsxs(Ne,{disabled:!d.canAddItemWithName(e.shortUrl),onClick:()=>d.addItemToCompare({name:e.shortUrl,query:pC(e)}),children:[m.jsx(je,{icon:Jy,fixedWidth:!0})," Compare visits"]}),m.jsx(Ne,{divider:!0,tag:"hr"})]}),m.jsxs(Ne,{tag:ov,shortUrl:e,suffix:"edit",asLink:!0,children:[m.jsx(je,{icon:sP,fixedWidth:!0})," Edit short URL"]}),p&&m.jsxs(Ne,{tag:ov,shortUrl:e,suffix:"redirect-rules",asLink:!0,children:[m.jsx(je,{icon:KK,fixedWidth:!0})," Manage redirect rules"]}),m.jsxs(Ne,{onClick:a,children:[m.jsx(je,{icon:VK,fixedWidth:!0})," QR code"]}),m.jsx(i,{shortUrl:e,isOpen:o,toggle:s}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{className:"dropdown-item--danger",onClick:v?c:y,children:[m.jsx(je,{icon:aP,fixedWidth:!0})," Delete short URL"]}),m.jsx(r,{shortUrl:e,deleteShortUrl:t,shortUrlDeleted:n,isOpen:l,toggle:f})]})},pRe=$t(oU,["DeleteShortUrlModal","QrCodeModal"]),aU="shlink/shortUrlCreation",m4={saving:!1,saved:!1,error:!1},mRe=e=>fn(`${aU}/createShortUrl`,t=>e().createShortUrl(t)),vRe=e=>{const{reducer:t,actions:n}=Qt({name:aU,initialState:m4,reducers:{resetCreateShortUrl:()=>m4},extraReducers:i=>{i.addCase(e.pending,()=>({saving:!0,saved:!1,error:!1})),i.addCase(e.rejected,(o,{error:a})=>({saving:!1,saved:!1,error:!0,errorData:Br(a)})),i.addCase(e.fulfilled,(o,{payload:a})=>({result:a,saving:!1,saved:!0,error:!1}))}}),{resetCreateShortUrl:r}=n;return{reducer:t,resetCreateShortUrl:r}},sU="shlink/shortUrlEdition",gRe={saving:!1,saved:!1,error:!1},yRe=e=>fn(`${sU}/editShortUrl`,({shortCode:t,domain:n,data:r})=>e().updateShortUrl(t,n,r)),bRe=e=>Qt({name:sU,initialState:gRe,reducers:{},extraReducers:t=>{t.addCase(e.pending,n=>({...n,saving:!0,error:!1,saved:!1})),t.addCase(e.rejected,(n,{error:r})=>({...n,saving:!1,error:!0,saved:!1,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>({shortUrl:r,saving:!1,error:!1,saved:!0}))}}),v4="shlink/shortUrlsDetails",g4={loading:!1,error:!1},_Re=e=>{const t=fn(`${v4}/getShortUrlsDetails`,async(r,{getState:i})=>{const{shortUrlsList:o}=i(),a=await Promise.all(r.map(async s=>{var l;const{shortCode:c,domain:f}=s,d=(l=o==null?void 0:o.shortUrls)==null?void 0:l.data.find(p=>Ed(p,c,f));return[s,d??await e().getShortUrl(c,f)]}));return new Map(a)}),{reducer:n}=Qt({name:v4,initialState:g4,reducers:{},extraReducers:r=>{r.addCase(t.pending,()=>({loading:!0,error:!1})),r.addCase(t.rejected,(i,{error:o})=>({loading:!1,error:!0,errorData:Br(o)})),r.addCase(t.fulfilled,(i,{payload:o})=>({...g4,shortUrls:o}))}});return{reducer:n,getShortUrlsDetails:t}},xRe=({domains:e,value:t,onChange:n})=>{const[r,,i,o]=Lt(),a=!t,s=M.useCallback(()=>{n(""),o()},[n,o]),l=M.useCallback(()=>{n(""),i()},[n,i]);return r?m.jsxs(a0,{children:[m.jsx(An,{value:t??"",placeholder:"Domain",onChange:c=>n(c.target.value)}),m.jsx(qe,{id:"backToDropdown",outline:!0,type:"button",className:"domains-dropdown__back-btn","aria-label":"Back to domains list",onClick:s,children:m.jsx(je,{icon:wK})}),m.jsx(Fr,{target:"backToDropdown",placement:"left",trigger:"hover",children:"Existing domains"})]}):m.jsxs(ea,{text:a?"Domain":`Domain: ${t}`,className:a?"domains-dropdown__toggle-btn":"domains-dropdown__toggle-btn--active",children:[e.map(({domain:c,isDefault:f})=>m.jsxs(Ne,{active:(t===c||f)&&a,onClick:()=>n(c),className:"d-flex justify-content-between align-items-center",children:[c,f&&m.jsx("span",{className:"text-muted",children:"default"})]},c)),m.jsx(Ne,{divider:!0}),m.jsx(Ne,{onClick:l,children:m.jsx("i",{children:"New domain"})})]})},g_=({icon:e,className:t,...n})=>{const r=Mi();return m.jsxs("div",{className:"icon-input-container",children:[m.jsx(An,{className:Oe("icon-input-container__input",t),innerRef:r,...n}),m.jsx(je,{icon:e,fixedWidth:!0,className:"icon-input-container__icon",onClick:()=>{var i;return(i=r.current)==null?void 0:i.focus()}})]})},wRe=({minDate:e,maxDate:t,value:n,onChange:r,withTime:i=!1,...o})=>{const a=M.useCallback(({target:l})=>{if(!l.value){r==null||r(null);return}r==null||r(Er(l.value))},[r]),s=M.useMemo(()=>i?zh:Ta,[i]);return m.jsx(An,{...o,type:i?"datetime-local":"date",value:s(n)??"",max:s(t)??void 0,min:s(e)??void 0,onChange:a})},Ey=({label:e,id:t,...n})=>{const r=M.useId();return m.jsxs(m.Fragment,{children:[m.jsxs("label",{htmlFor:t??r,className:"mb-1",children:[e,":"]}),m.jsx(wRe,{id:t??r,...n})]})},y_=({children:e,infoTooltip:t,checked:n,onChange:r})=>m.jsxs("p",{children:[m.jsx(dD,{inline:!0,checked:n,className:t?"me-2":"",onChange:r,children:e}),t&&m.jsx(iv,{placement:"right",children:t})]}),ORe=({isOpen:e,toggle:t})=>m.jsxs(vr,{isOpen:e,toggle:t,centered:!0,size:"lg",children:[m.jsx(mo,{toggle:t,children:"Info"}),m.jsxs(Li,{children:[m.jsxs("p",{children:["When the ",m.jsx("b",{children:m.jsx("i",{children:'"Use existing URL if found"'})})," checkbox is checked, the server will return an existing short URL if it matches provided params."]}),m.jsx("p",{children:"These are the checks performed by Shlink in order to determine if an existing short URL should be returned:"}),m.jsxs("ul",{children:[m.jsx("li",{children:"When only the long URL is provided: The most recent match will be returned, or a new short URL will be created if none is found."}),m.jsxs("li",{children:["When long URL and custom slug and/or domain are provided: Same as in previous case, but it will try to match the short URL using both the long URL and the slug, the long URL and the domain, or the three of them.",m.jsx("br",{}),"If the slug is being used by another long URL, an error will be returned."]}),m.jsx("li",{children:"When other params are provided: Same as in previous cases, but it will try to match existing short URLs with all provided data. If any of them does not match, a new short URL will be created"})]})]})]}),SRe=()=>{const[e,t]=Lt();return m.jsxs(m.Fragment,{children:[m.jsx(yl,{className:"p-0",title:"What does this mean?",onClick:t,children:m.jsx(je,{icon:cP})}),m.jsx(ORe,{isOpen:e,toggle:t})]})},Nm=e=>typeof e=="string"?Ka(e):e,PRe=e=>"shortCodeLength"in e&&"customSlug"in e&&"domain"in e,lU=({basicMode:e=!1,saving:t,onSave:n,initialState:r,tagsList:i,domainsList:o})=>{var a,s,l;const{TagsSelector:c}=Rt(lU),[f,d]=M.useState(r),p=PRe(f),v=Ko("deviceLongUrls"),y=Ko("urlValidation"),g=y||p,x=M.useCallback(()=>d(r),[r]),_=M.useCallback((E,T)=>Rs(E)?E:Rs(T)?null:void 0,[]),b=M.useCallback((E,T)=>d(({deviceLongUrls:j={},...F})=>{var k;return{...F,deviceLongUrls:{...j,[E]:_(T,(k=r.deviceLongUrls)==null?void 0:k[E])}}}),[r.deviceLongUrls,_]),w=M.useCallback(E=>d(T=>({...T,tags:E})),[]),S=M.useCallback(async E=>(E.preventDefault(),n(f).then(T=>p&&!cC(T)&&x()).catch(()=>{})),[p,n,x,f]),P=M.useMemo(()=>m.jsxs("div",{className:"d-flex flex-column gap-3",children:[m.jsx(An,{bsSize:"lg",type:"url",placeholder:"URL to be shortened",required:!0,value:f.longUrl,onChange:E=>d(T=>({...T,longUrl:E.target.value}))}),m.jsxs("div",{className:Oe("d-flex flex-column flex-lg-row gap-3",{"mb-3":e}),children:[e&&p&&m.jsx("div",{className:"w-100 w-lg-50",children:m.jsx(An,{bsSize:"lg",placeholder:"Custom slug",value:f.customSlug??"",onChange:E=>d(T=>({...T,customSlug:E.target.value}))})}),m.jsx("div",{className:Oe("w-100",{"w-lg-50":e}),children:m.jsx(c,{tags:i.tags,selectedTags:f.tags??[],onChange:w})})]})]}),[c,e,w,p,f,i.tags]);return m.jsxs("form",{name:"shortUrlForm",className:"short-url-form",onSubmit:S,children:[e&&P,!e&&m.jsxs(m.Fragment,{children:[m.jsxs(Pr,{children:[m.jsx("div",{className:Oe("mb-3",{"col-sm-6":v,"col-12":!v}),children:m.jsx(gt,{title:"Main options",children:P})}),v&&m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Device-specific long URLs",bodyClassName:"d-flex flex-column gap-3",children:[m.jsx(g_,{type:"url",icon:vse,placeholder:"Android-specific redirection",value:((a=f.deviceLongUrls)==null?void 0:a.android)??"",onChange:({target:E})=>b("android",E.value)}),m.jsx(g_,{type:"url",icon:mse,placeholder:"iOS-specific redirection",value:((s=f.deviceLongUrls)==null?void 0:s.ios)??"",onChange:({target:E})=>b("ios",E.value)}),m.jsx(g_,{type:"url",icon:qK,placeholder:"Desktop-specific redirection",value:((l=f.deviceLongUrls)==null?void 0:l.desktop)??"",onChange:({target:E})=>b("desktop",E.value)})]})})]}),m.jsxs(Pr,{children:[m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Customize the short URL",bodyClassName:"d-flex flex-column gap-3",children:[m.jsx(An,{placeholder:"Title",value:f.title??"",onChange:({target:E})=>d(T=>({...T,title:_(E.value,r.title)}))}),p&&m.jsxs(m.Fragment,{children:[m.jsxs(Pr,{children:[m.jsx("div",{className:"col-lg-6 mb-3 mb-lg-0",children:m.jsx(An,{placeholder:"Custom slug",value:f.customSlug??"",onChange:E=>d(T=>({...T,customSlug:E.target.value})),disabled:Rs(f.shortCodeLength)})}),m.jsx("div",{className:"col-lg-6",children:m.jsx(An,{type:"number",placeholder:"Short code length",value:f.shortCodeLength??"",onChange:E=>d(T=>({...T,shortCodeLength:E.target.value})),min:4,disabled:Rs(f.customSlug)})})]}),m.jsx(xRe,{value:f.domain,onChange:E=>d(T=>({...T,domain:E})),domains:o.domains})]})]})}),m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Limit access to the short URL",children:[m.jsxs("div",{className:"row mb-3",children:[m.jsx("div",{className:"col-lg-6",children:m.jsx(Ey,{label:"Enabled since",withTime:!0,maxDate:f.validUntil?Nm(f.validUntil):void 0,value:f.validSince?Nm(f.validSince):null,onChange:E=>d(T=>({...T,validSince:Qa(E)}))})}),m.jsx("div",{className:"col-lg-6 mt-3 mt-lg-0",children:m.jsx(Ey,{label:"Enabled until",withTime:!0,minDate:f.validSince?Nm(f.validSince):void 0,value:f.validUntil?Nm(f.validUntil):null,onChange:E=>d(T=>({...T,validUntil:Qa(E)}))})})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"maxVisits",className:"mb-1",children:"Maximum visits allowed:"}),m.jsx(An,{id:"maxVisits",type:"number",min:1,placeholder:"25...",value:f.maxVisits??"",onChange:E=>d(T=>({...T,maxVisits:Rs(E.target.value)?Number(E.target.value):null}))})]})]})})]}),m.jsxs(Pr,{children:[g&&m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Extra checks",children:[y&&m.jsx(y_,{infoTooltip:"If checked, Shlink will try to reach the long URL, failing in case it's not publicly accessible.",checked:f.validateUrl,onChange:E=>d(T=>({...T,validateUrl:E})),children:"Validate URL"}),p&&m.jsxs("p",{children:[m.jsx(dD,{inline:!0,className:"me-2",checked:f.findIfExists,onChange:E=>d(T=>({...T,findIfExists:E})),children:"Use existing URL if found"}),m.jsx(SRe,{})]})]})}),m.jsx("div",{className:Oe("mb-3",{"col-sm-6":g}),children:m.jsxs(gt,{title:"Configure behavior",children:[m.jsx(y_,{infoTooltip:"This short URL will be included in the robots.txt for your Shlink instance, allowing web crawlers (like Google) to index it.",checked:f.crawlable,onChange:E=>d(T=>({...T,crawlable:E})),children:"Make it crawlable"}),m.jsx(y_,{infoTooltip:"When this short URL is visited, any query params appended to it will be forwarded to the long URL.",checked:f.forwardQuery,onChange:E=>d(T=>({...T,forwardQuery:E})),children:"Forward query params on redirect"})]})})]})]}),m.jsx("div",{className:"text-center",children:m.jsx(qe,{outline:!0,color:"primary",disabled:t||!f.longUrl,className:"btn-xs-block",children:t?"Saving...":"Save"})})]})},ERe=$t(lU,["TagsSelector"]),CRe=({active:e,allText:t,onChange:n})=>m.jsxs(m.Fragment,{children:[m.jsx(Ne,{active:e==="all",onClick:()=>n("all"),children:t}),m.jsx(Ne,{divider:!0,tag:"hr"}),qMe.map(r=>m.jsx(Ne,{active:e===r,onClick:()=>n(r),children:hB(r)},r))]}),TRe=({startDate:e,endDate:t,disabled:n=!1,onStartDateChange:r,onEndDateChange:i})=>m.jsxs("div",{className:"row",children:[m.jsx("div",{className:"col-md-6",children:m.jsx(Ey,{label:"Since",value:e,maxDate:t??void 0,disabled:n,onChange:r})}),m.jsx("div",{className:"col-md-6 mt-3 mt-md-0",children:m.jsx(Ey,{label:"Until",value:t,minDate:e??void 0,disabled:n,onChange:o=>i(o&&Jc(o))})})]}),OC=({onDatesChange:e,dateRangeOrInterval:t,defaultText:n,disabled:r})=>{const i=M.useMemo(()=>hB(t)??n,[t,n]),[o,a]=M.useMemo(()=>wy(t)?[void 0,t]:[t,void 0],[t]),s=M.useCallback(l=>{wy(l)?e(pB(l),l):e(l)},[e]);return m.jsxs(ea,{disabled:r,text:i,children:[m.jsx(CRe,{allText:n,active:a,onChange:s}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx("div",{className:"px-3 py-1",children:m.jsx(TRe,{...o,onStartDateChange:l=>s({...o,startDate:l}),onEndDateChange:l=>s({...o,endDate:l})})})]})},jRe={dateCreated:"Created at",shortCode:"Short URL",longUrl:"Long URL",title:"Title",visits:"Visits"},ARe=({onChange:e,selected:t={},className:n,supportsDisabledFiltering:r})=>{const{excludeBots:i=!1,excludeMaxVisitsReached:o=!1,excludePastValidUntil:a=!1}=t,s=l=>()=>e({...t,[l]:!(t!=null&&t[l])});return m.jsxs(ea,{text:"Filters",dropdownClassName:n,end:!0,minWidth:250,children:[m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Visits:"}),m.jsx(Ne,{active:i,onClick:s("excludeBots"),children:"Ignore visits from bots"}),r&&m.jsxs(m.Fragment,{children:[m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Short URLs:"}),m.jsx(Ne,{active:o,onClick:s("excludeMaxVisitsReached"),children:"Exclude with visits reached"}),m.jsx(Ne,{active:a,onClick:s("excludePastValidUntil"),children:"Exclude enabled in the past"})]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{disabled:t.excludeBots===void 0&&t.excludeMaxVisitsReached===void 0&&t.excludePastValidUntil===void 0,onClick:()=>e({excludeBots:void 0,excludeMaxVisitsReached:void 0,excludePastValidUntil:void 0}),children:m.jsx("i",{children:"Reset to defaults"})})]})},cU=({className:e,shortUrlsAmount:t,order:n,handleOrderBy:r,tagsList:i})=>{const{ExportShortUrlsBtn:o,TagsSelector:a}=Rt(cU),[{search:s,tags:l,startDate:c,endDate:f,excludeBots:d,excludeMaxVisitsReached:p,excludePastValidUntil:v,tagsMode:y="any"},g]=pb(),x=Ko("filterDisabledUrls"),_=nr("visits"),[b,w]=M.useState(),S=M.useCallback(({startDate:j,endDate:F},k)=>{g({startDate:Qa(j)??void 0,endDate:Qa(F)??void 0}),w(k)},[g]),P=M.useCallback(j=>g({search:j||void 0}),[g]),E=M.useCallback(j=>g({tags:j}),[g]),T=M.useCallback(()=>g({tagsMode:y==="any"?"all":"any"}),[y,g]);return m.jsxs("div",{className:Oe("short-urls-filtering-bar-container",e),children:[m.jsx(ip,{initialValue:s,onChange:P}),m.jsxs(a0,{className:"mt-3",children:[m.jsx(a,{immutable:!0,placeholder:"With tags...",tags:i.tags,selectedTags:l,onChange:E}),l.length>1&&m.jsxs(m.Fragment,{children:[m.jsx(qe,{outline:!0,color:"secondary",onClick:T,id:"tagsModeBtn","aria-label":"Change tags mode",children:m.jsx(je,{className:"short-urls-filtering-bar__tags-icon",icon:y==="all"?R6:_K})}),m.jsx(Fr,{target:"tagsModeBtn",placement:"left",children:y==="all"?"With all the tags.":"With any of the tags."})]})]}),m.jsxs(Pr,{className:"flex-lg-row-reverse",children:[m.jsx("div",{className:"col-lg-8 col-xl-6 mt-3",children:m.jsxs("div",{className:"d-md-flex",children:[m.jsx("div",{className:"flex-grow-1",children:m.jsx(OC,{defaultText:"All short URLs",dateRangeOrInterval:b??dB(c,f),onDatesChange:S})}),m.jsx(ARe,{className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:{excludeBots:d??(_==null?void 0:_.excludeBots),excludeMaxVisitsReached:p,excludePastValidUntil:v},onChange:g,supportsDisabledFiltering:x})]})}),m.jsx("div",{className:"col-6 col-lg-4 col-xl-6 mt-3",children:m.jsx(o,{amount:t})}),m.jsx("div",{className:"col-6 d-lg-none mt-3",children:m.jsx(op,{prefixed:!1,items:jRe,order:n,onChange:r})})]})]})},kRe=$t(cU,["ExportShortUrlsBtn","TagsSelector"]);function Cd({currentOrder:e,field:t,className:n="ms-1"}){return!e.dir||e.field!==t?null:m.jsx(je,{icon:e.dir==="ASC"?dK:SK,className:n})}const Ql=2,QO="...",uU=(e,t)=>{const n=HP(Math.max(Ql,e-Ql),Math.min(t-1,e+Ql)+1);return e-Ql>Ql&&n.unshift(QO),e+Qle===QO,fU=e=>Vh(e)?e:qt(e),dU=(e,t)=>Vh(e)?`${e}_${t}`:`${e}`,NRe=({paginator:e,currentQueryString:t=""})=>{const{currentPage:n=0,pagesCount:r=0}=e??{},i=ds(),o=s=>`${i}/list-short-urls/${s}${t}`;if(r<=1)return m.jsx("div",{className:"pb-3"});const a=()=>uU(n,r).map((s,l)=>m.jsx(Zs,{disabled:Vh(s),active:n===s,children:m.jsx(Xs,{tag:At,to:o(s),children:fU(s)})},dU(s,l)));return m.jsxs(DP,{className:"sticky-card-paginator py-3",listClassName:"flex-wrap justify-content-center mb-0",children:[m.jsx(Zs,{disabled:n===1,children:m.jsx(Xs,{previous:!0,tag:At,to:o(n-1)})}),a(),m.jsx(Zs,{disabled:n>=r,children:m.jsx(Xs,{next:!0,tag:At,to:o(n+1)})})]})},MRe={field:"dateCreated",dir:"DESC"},hU=Di(({listShortUrls:e,shortUrlsList:t})=>{var n,r,i;const{ShortUrlsTable:o,ShortUrlsFilteringBar:a}=Rt(hU),{page:s}=Mu(),l=pr(),[{tags:c,search:f,startDate:d,endDate:p,orderBy:v,tagsMode:y,excludeBots:g,excludePastValidUntil:x,excludeMaxVisitsReached:_},b]=pb(),w=YP(),[S,P]=M.useState(v??((n=w.shortUrlsList)==null?void 0:n.defaultOrdering)??MRe),{pagination:E}=(t==null?void 0:t.shortUrls)??{},T=M.useMemo(()=>{var X;return g??((X=w.visits)==null?void 0:X.excludeBots)},[g,(r=w.visits)==null?void 0:r.excludeBots]),j=Ko("excludeBotsOnShortUrls"),F=M.useCallback((X,Q)=>{b({orderBy:{field:X,dir:Q}}),P({field:X,dir:Q})},[b]),k=X=>()=>F(X,c0(X,S.field,S.dir)),I=X=>m.jsx(Cd,{currentOrder:S,field:X}),D=M.useCallback(X=>b({tags:[...new Set([...c,X])]}),[c,b]),K=M.useCallback(({field:X,dir:Q})=>j&&T&&X==="visits"?{field:"nonBotVisits",dir:Q}:{field:X,dir:Q},[T,j]),W=fC();return M.useEffect(()=>{e({page:s,searchTerm:f,tags:c,startDate:d,endDate:p,orderBy:K(S),tagsMode:y,excludePastValidUntil:x,excludeMaxVisitsReached:_})},[e,K,s,f,c,d,p,S,y,x,_]),m.jsxs(uC,{value:W,children:[m.jsx(a,{shortUrlsAmount:(i=t.shortUrls)==null?void 0:i.pagination.totalItems,order:S,handleOrderBy:F,className:"mb-3"}),m.jsx(dC,{type:"short-urls",className:"mb-3"}),m.jsxs(Dr,{body:!0,className:Oe({"pb-0":!t.loading}),children:[m.jsx(o,{shortUrlsList:t,orderByColumn:k,renderOrderIcon:I,onTagClick:D}),!t.loading&&m.jsx(NRe,{paginator:E,currentQueryString:l.search})]})]})},()=>[Jn.visits]),LRe=$t(hU,["ShortUrlsTable","ShortUrlsFilteringBar"]),pU=({orderByColumn:e,renderOrderIcon:t,shortUrlsList:n,onTagClick:r,className:i})=>{const{ShortUrlsRow:o}=Rt(pU),{error:a,loading:s,shortUrls:l}=n,c=Oe({"short-urls-table__header-cell--with-action":!!e}),f=Oe("short-urls-table__header-cell",c),d=Oe("table table-hover responsive-table short-urls-table",i),p=()=>a?m.jsx("tr",{children:m.jsx("td",{colSpan:6,className:"text-center table-danger text-dark",children:"Something went wrong while loading short URLs :("})}):s?m.jsx("tr",{children:m.jsx("td",{colSpan:6,className:"text-center",children:"Loading..."})}):!s&&(!l||l.data.length===0)?m.jsx("tr",{children:m.jsx("td",{colSpan:6,className:"text-center",children:"No results found"})}):l==null?void 0:l.data.map(v=>m.jsx(o,{shortUrl:v,onTagClick:r},v.shortUrl));return m.jsxs("table",{className:d,children:[m.jsx("thead",{className:"responsive-table__header short-urls-table__header",children:m.jsxs("tr",{children:[m.jsxs("th",{className:f,onClick:e==null?void 0:e("dateCreated"),children:["Created at ",t==null?void 0:t("dateCreated")]}),m.jsxs("th",{className:f,onClick:e==null?void 0:e("shortCode"),children:["Short URL ",t==null?void 0:t("shortCode")]}),m.jsxs("th",{className:"short-urls-table__header-cell",children:[m.jsxs(yl,{className:Oe("p-0",c),onClick:e==null?void 0:e("title"),children:["Title ",t==null?void 0:t("title")]}),"  /  ",m.jsxs(yl,{className:Oe("p-0",c),onClick:e==null?void 0:e("longUrl"),children:[m.jsx("span",{className:"indivisible",children:"Long URL"})," ",t==null?void 0:t("longUrl")]})]}),m.jsx("th",{className:"short-urls-table__header-cell",children:"Tags"}),m.jsx("th",{className:f,onClick:e==null?void 0:e("visits"),children:m.jsxs("span",{className:"indivisible",children:["Visits ",t==null?void 0:t("visits")]})}),m.jsx("th",{className:"short-urls-table__header-cell",colSpan:2,"aria-hidden":!0})]})}),m.jsx("tbody",{children:p()})]})},RRe=$t(pU,["ShortUrlsRow"]),$Re=(e,t)=>{e.factory("ShortUrlsList",LRe),e.decorator("ShortUrlsList",t(["mercureInfo","shortUrlsList"],["listShortUrls","createNewVisits","loadMercureInfo"])),e.factory("ShortUrlsTable",RRe),e.factory("ShortUrlsRow",hRe),e.factory("CreateShortUrlResult",eRe),e.factory("ShortUrlsRowMenu",pRe),e.decorator("ShortUrlsRowMenu",t(null,["shortUrlDeleted","deleteShortUrl"])),e.factory("ShortUrlForm",ERe),e.decorator("ShortUrlForm",t(["tagsList","domainsList"])),e.factory("CreateShortUrl",Q4e),e.decorator("CreateShortUrl",t(["shortUrlCreation"],["createShortUrl","resetCreateShortUrl"])),e.factory("EditShortUrl",J4e),e.decorator("EditShortUrl",t(["shortUrlsDetails","shortUrlEdition"],["getShortUrlsDetails","editShortUrl"])),e.serviceFactory("DeleteShortUrlModal",()=>tRe),e.decorator("DeleteShortUrlModal",t(["shortUrlDeletion"],["resetDeleteShortUrl"])),e.factory("QrCodeModal",aRe),e.factory("ExportShortUrlsBtn",nRe),e.factory("ShortUrlsFilteringBar",kRe),e.decorator("ShortUrlsFilteringBar",t(["tagsList"])),e.serviceFactory("shortUrlsListReducerCreator",MLe,"listShortUrls","editShortUrl","createShortUrl"),e.serviceFactory("shortUrlsListReducer",n=>n.reducer,"shortUrlsListReducerCreator"),e.serviceFactory("shortUrlCreationReducerCreator",vRe,"createShortUrl"),e.serviceFactory("shortUrlCreationReducer",n=>n.reducer,"shortUrlCreationReducerCreator"),e.serviceFactory("shortUrlEditionReducerCreator",bRe,"editShortUrl"),e.serviceFactory("shortUrlEditionReducer",n=>n.reducer,"shortUrlEditionReducerCreator"),e.serviceFactory("shortUrlDeletionReducerCreator",ALe,"deleteShortUrl"),e.serviceFactory("shortUrlDeletionReducer",n=>n.reducer,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlsDetailsReducerCreator",_Re,"apiClientFactory"),e.serviceFactory("shortUrlsDetailsReducer",n=>n.reducer,"shortUrlsDetailsReducerCreator"),e.serviceFactory("listShortUrls",NLe,"apiClientFactory"),e.serviceFactory("createShortUrl",mRe,"apiClientFactory"),e.serviceFactory("resetCreateShortUrl",n=>n.resetCreateShortUrl,"shortUrlCreationReducerCreator"),e.serviceFactory("deleteShortUrl",jLe,"apiClientFactory"),e.serviceFactory("resetDeleteShortUrl",n=>n.resetDeleteShortUrl,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlDeleted",()=>OB),e.serviceFactory("getShortUrlsDetails",n=>n.getShortUrlsDetails,"shortUrlsDetailsReducerCreator"),e.serviceFactory("editShortUrl",yRe,"apiClientFactory")},IRe=({tag:e,toggle:t,isOpen:n,deleteTag:r,tagDelete:i,tagDeleted:o})=>{const{deleting:a,error:s,deleted:l,errorData:c}=i;return m.jsxs(vr,{toggle:t,isOpen:n,centered:!0,onClosed:()=>l&&o(e),children:[m.jsx(mo,{toggle:t,className:"text-danger",children:"Delete tag"}),m.jsxs(Li,{children:["Are you sure you want to delete tag ",m.jsx("b",{children:e}),"?",s&&m.jsx(Zn,{type:"error",small:!0,className:"mt-2",children:m.jsx(ho,{errorData:c,fallbackMessage:"Something went wrong while deleting the tag :("})})]}),m.jsxs(as,{children:[m.jsx(qe,{color:"link",onClick:t,children:"Cancel"}),m.jsx(qe,{color:"danger",disabled:a,onClick:async()=>{await r(e),t()},children:a?"Deleting tag...":"Delete tag"})]})]})},mU=({tag:e,editTag:t,toggle:n,tagEdited:r,isOpen:i,tagEdit:o})=>{const{ColorGenerator:a}=Rt(mU),[s,l]=M.useState(e),[c,f]=M.useState(a.getColorForKey(e)),{editing:d,error:p,edited:v,errorData:y}=o,g=wB(async()=>{await t({oldName:e,newName:s,color:c}),n()}),x=M.useCallback(()=>v&&r({oldName:e,newName:s,color:c}),[c,v,s,e,r]);return m.jsx(vr,{isOpen:i,toggle:n,centered:!0,onClosed:x,children:m.jsxs("form",{name:"editTag",onSubmit:g,children:[m.jsx(mo,{toggle:n,children:"Edit tag"}),m.jsxs(Li,{children:[m.jsxs(a0,{children:[m.jsxs("div",{className:"input-group-text p-0 position-relative",style:{backgroundColor:c,borderColor:c},children:[m.jsx(je,{icon:hK,className:"position-absolute top-50 start-50 translate-middle text-white"}),m.jsx(An,{className:"form-control-color opacity-0",type:"color",value:c,onChange:_=>f(_.target.value)})]}),m.jsx(An,{value:s,placeholder:"Tag",required:!0,onChange:({target:_})=>l(_.value)})]}),p&&m.jsx(Zn,{type:"error",small:!0,className:"mt-2",children:m.jsx(ho,{errorData:y,fallbackMessage:"Something went wrong while editing the tag :("})})]}),m.jsxs(as,{children:[m.jsx(qe,{type:"button",color:"link",onClick:n,children:"Cancel"}),m.jsx(qe,{color:"primary",disabled:d,children:d?"Saving...":"Save"})]})]})})},DRe=$t(mU,["ColorGenerator"]),FRe=/\s+/g,vU=e=>e.trim().toLowerCase().replace(FRe,"-"),gU=({color:e})=>m.jsx("div",{style:{backgroundColor:e},className:"color-bullet"}),yU=({tag:e,colorGenerator:t})=>m.jsx(gU,{color:t.getColorForKey(e)});let y4=1;const bU="Tag not found",_U="Add tag",BRe=e=>e!==bU,URe=e=>e===_U,b4=e=>(y4+=1,{label:e,value:`${e}${y4}`}),zRe=e=>({tag:t,onClick:n})=>m.jsx(vb,{colorGenerator:e,text:t.label,className:"react-tags__tag",onClose:n}),VRe=(e,t)=>({option:n,classNames:r,...i})=>{var o;const a=BRe(n.label),s=URe(n.label);return m.jsx("div",{className:Oe(r.option,{[r.optionIsActive]:a&&n.active,"react-tags__listbox-option--not-selectable":!a}),...i,children:a?m.jsxs(m.Fragment,{children:[!s&&m.jsx(yU,{tag:`${n.label}`,colorGenerator:e}),s?m.jsxs("i",{children:['Add "',vU(((o=t.current)==null?void 0:o.input.value)??""),'"']}):n.label]}):m.jsx("i",{children:n.label})})},xU=({selectedTags:e,onChange:t,placeholder:n,tags:r,immutable:i=!1})=>{const{ColorGenerator:o}=Rt(xU),a=nr("shortUrlCreation"),s=(a==null?void 0:a.tagFilteringMode)??"startsWith",l=Mi();return m.jsx(ple,{ref:l,selected:e.map(b4),suggestions:r.filter(c=>!e.includes(c)).map(b4),renderTag:zRe(o),renderOption:VRe(o,l),activateFirstOption:!0,allowNew:!i,newOptionText:_U,noOptionsText:bU,placeholderText:n??"Add tags to the URL",delimiterKeys:["Enter",","],suggestionsTransform:(c,f)=>{const d=c.toLowerCase().trim();return d.length<1?[]:[...f.filter(({label:p})=>s==="includes"?p.includes(d):p.startsWith(d))].slice(0,5)},onDelete:c=>{const f=[...e];f.splice(c,1),t(f)},onAdd:({label:c})=>t([...new Set([...e,...c.split(",").map(vU)])])})},WRe=$t(xU,["ColorGenerator"]),JO="shlink/tagDelete",HRe={deleting:!1,deleted:!1,error:!1},wU=Xn(`${JO}/tagDeleted`),GRe=e=>{const t=fn(`${JO}/deleteTag`,async r=>{await e().deleteTags([r])}),{reducer:n}=Qt({name:JO,initialState:HRe,reducers:{},extraReducers:r=>{r.addCase(t.pending,()=>({deleting:!0,deleted:!1,error:!1})),r.addCase(t.rejected,(i,{error:o})=>({deleting:!1,deleted:!1,error:!0,errorData:Br(o)})),r.addCase(t.fulfilled,()=>({deleting:!1,deleted:!0,error:!1}))}});return{reducer:n,deleteTag:t}},SC="shlink/tagEdit",qRe={editing:!1,edited:!1,error:!1},OU=Xn(`${SC}/tagEdited`),KRe=(e,t)=>fn(`${SC}/editTag`,async({oldName:n,newName:r,color:i})=>(await e().editTag(n,r),t.setColorForKey(r,i),{oldName:n,newName:r,color:i})),YRe=e=>Qt({name:SC,initialState:qRe,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({editing:!0,edited:!1,error:!1})),t.addCase(e.rejected,(n,{error:r})=>({editing:!1,edited:!1,error:!0,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>{const{oldName:i,newName:o}=r;return{oldName:i,newName:o,editing:!1,edited:!0,error:!1}})}}),PC="shlink/tagsList",b_={tags:[],filteredTags:[],stats:{},loading:!1,error:!1},_4=(e,t)=>n=>n===e?t:n,x4=(e,t)=>e.filter(n=>n!==t),ZRe=(e,t)=>e.reduce((n,[r,i])=>{if(!n[r])return n;const{bots:o,nonBots:a}=i,s=n[r];return{...n,[r]:{...s,visitsSummary:s.visitsSummary&&{total:s.visitsSummary.total+o+a,bots:s.visitsSummary.bots+o,nonBots:s.visitsSummary.nonBots+a},visitsCount:(s.visitsCount??0)+o+a}}},{...t}),XRe=e=>Object.entries(e.reduce((t,{shortUrl:n,visit:r})=>(n==null||n.tags.forEach(i=>{t[i]||(t[i]={bots:0,nonBots:0}),r.potentialBot?t[i].bots+=1:t[i].nonBots+=1}),t),{})),QRe=e=>fn(`${PC}/listTags`,async()=>{const{data:t}=await e().tagsStats(),n=t.reduce((r,{tag:i,...o})=>(r[i]=o,r),{});return{tags:Object.keys(n),stats:n}}),SU=Xn(`${PC}/filterTags`),JRe=(e,t)=>Qt({name:PC,initialState:b_,reducers:{},extraReducers:n=>{n.addCase(SU,(r,{payload:i})=>({...r,filteredTags:r.tags.filter(o=>o.toLowerCase().match(i.toLowerCase()))})),n.addCase(e.pending,r=>({...r,loading:!0,error:!1})),n.addCase(e.rejected,(r,{error:i})=>({...b_,error:!0,errorData:Br(i)})),n.addCase(e.fulfilled,(r,{payload:i})=>({...b_,stats:i.stats,tags:i.tags,filteredTags:i.tags})),n.addCase(wU,({tags:r,filteredTags:i,...o},{payload:a})=>({...o,tags:x4(r,a),filteredTags:x4(i,a)})),n.addCase(OU,({tags:r,filteredTags:i,stats:o,...a},{payload:s})=>({...a,stats:{...o,[s.newName]:o[s.oldName]},tags:r.map(_4(s.oldName,s.newName)).sort(),filteredTags:i.map(_4(s.oldName,s.newName)).sort()})),n.addCase(tf,(r,{payload:i})=>({...r,stats:ZRe(XRe(i.createdVisits),r.stats)})),n.addCase(t.fulfilled,({tags:r,...i},{payload:o})=>({...i,tags:r.concat(o.tags.filter(a=>!r.includes(a)))}))}}),e$e={tag:"Tag",shortUrls:"Short URLs",visits:"Visits"},PU=Di(({filterTags:e,tagsList:t})=>{var n,r;const{TagsTable:i}=Rt(PU),o=YP(),[a,s]=M.useState(((n=o.tags)==null?void 0:n.defaultOrdering)??{}),l=M.useMemo(()=>{const f=t.filteredTags.map(d=>{var p,v,y;const g=t.stats[d],x=((p=o.visits)!=null&&p.excludeBots?(v=g==null?void 0:g.visitsSummary)==null?void 0:v.nonBots:(y=g==null?void 0:g.visitsSummary)==null?void 0:y.total)??(g==null?void 0:g.visitsCount)??0;return{tag:d,visits:x,shortUrls:(g==null?void 0:g.shortUrlsCount)??0}});return vD(f,a)},[a,(r=o.visits)==null?void 0:r.excludeBots,t.filteredTags,t.stats]),c=fC();return t.loading?m.jsx(zo,{loading:!0}):t.error?m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:t.errorData,fallbackMessage:"Error loading tags :("})}):m.jsxs(uC,{value:c,children:[m.jsx(ip,{className:"mb-3",onChange:e}),m.jsx(Pr,{className:"mb-3",children:m.jsx("div",{className:"col-lg-6 offset-lg-6",children:m.jsx(op,{items:e$e,order:a,onChange:(f,d)=>s({field:f,dir:d})})})}),m.jsx(dC,{type:"tags",className:"mb-3"}),m.jsx(i,{sortedTags:l,currentOrder:a,orderByColumn:f=>()=>{const d=c0(f,a.field,a.dir);s({field:d?f:void 0,dir:d})}})]})},()=>[Jn.visits]),t$e=$t(PU,["TagsTable"]),EC=({pagesCount:e,currentPage:t,setCurrentPage:n,centered:r=!0})=>{if(e<2)return null;const i=o=>()=>!Vh(o)&&n(o);return m.jsxs(DP,{listClassName:Oe("flex-wrap mb-0 simple-paginator",{"justify-content-center":r}),children:[m.jsx(Zs,{disabled:t<=1,children:m.jsx(Xs,{previous:!0,tag:"span",onClick:i(t-1)})}),uU(t,e).map((o,a)=>m.jsx(Zs,{disabled:Vh(o),active:t===o,children:m.jsx(Xs,{role:"link",tag:"span",onClick:i(o),children:fU(o)})},dU(o,a))),m.jsx(Zs,{disabled:t>=e,children:m.jsx(Xs,{next:!0,tag:"span",onClick:i(t+1)})})]})},n$e=20,EU=({sortedTags:e,orderByColumn:t,currentOrder:n})=>{const{TagsTableRow:r}=Rt(EU),i=M.useRef(!0),{page:o=1}=$u(),[a,s]=pLe("page",Number(o)),l=M.useCallback(p=>{s(p),scrollTo(0,0)},[s]),c=Ac(e,n$e),f=c.length>1,d=c[a-1]??[];return M.useEffect(()=>{i.current||l(1),i.current=!1},[l,e]),m.jsxs(gt,{bodyClassName:f?"pb-1":"",children:[m.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[m.jsxs("thead",{className:"responsive-table__header",children:[m.jsxs("tr",{children:[m.jsxs("th",{className:"tags-table__header-cell",onClick:t("tag"),children:["Tag ",m.jsx(Cd,{currentOrder:n,field:"tag"})]}),m.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("shortUrls"),children:["Short URLs ",m.jsx(Cd,{currentOrder:n,field:"shortUrls"})]}),m.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("visits"),children:["Visits ",m.jsx(Cd,{currentOrder:n,field:"visits"})]}),m.jsx("th",{className:"tags-table__header-cell",children:m.jsx("span",{className:"sr-only",children:"Options"})})]}),m.jsx("tr",{children:m.jsx("th",{"aria-hidden":!0,colSpan:4,className:"p-0 border-top-0"})})]}),m.jsxs("tbody",{children:[d.length===0&&m.jsx("tr",{children:m.jsx("td",{colSpan:4,className:"text-center",children:"No tags found"})}),d.map(p=>m.jsx(r,{tag:p},p.tag))]})]}),f&&m.jsx("div",{className:"sticky-card-paginator",children:m.jsx(EC,{pagesCount:c.length,currentPage:a,setCurrentPage:l})})]},a)},r$e=$t(EU,["TagsTableRow"]),CU=({tag:e})=>{const{DeleteTagConfirmModal:t,EditTagModal:n,ColorGenerator:r}=Rt(CU),[i,o]=Lt(),[a,s]=Lt(),l=ds(),c=cb();return m.jsxs("tr",{className:"responsive-table__row",children:[m.jsxs("th",{className:"responsive-table__cell","data-th":"Tag",children:[m.jsx(yU,{tag:e.tag,colorGenerator:r})," ",e.tag]}),m.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Short URLs",children:m.jsx(At,{to:`${l}/list-short-urls/1?tags=${encodeURIComponent(e.tag)}`,children:qt(e.shortUrls)})}),m.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Visits",children:m.jsx(At,{to:`${l}/tag/${e.tag}/visits`,children:qt(e.visits)})}),m.jsx("td",{className:"responsive-table__cell text-lg-end",children:m.jsxs(l0,{children:[m.jsxs(Ne,{onClick:s,children:[m.jsx(je,{icon:N6,fixedWidth:!0,className:"me-1"})," Edit"]}),m.jsxs(Ne,{disabled:!c||!c.canAddItemWithName(e.tag),onClick:()=>c==null?void 0:c.addItemToCompare({name:e.tag,query:e.tag,style:r.stylesForKey(e.tag)}),children:[m.jsx(je,{icon:Jy,fixedWidth:!0})," Compare visits"]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{className:"dropdown-item--danger",onClick:o,children:[m.jsx(je,{icon:vK,fixedWidth:!0,className:"me-1"})," Delete tag"]})]})}),m.jsx(n,{tag:e.tag,toggle:s,isOpen:a}),m.jsx(t,{tag:e.tag,toggle:o,isOpen:i})]})},i$e=$t(CU,["DeleteTagConfirmModal","EditTagModal","ColorGenerator"]),o$e=(e,t)=>{e.factory("TagsSelector",WRe),e.serviceFactory("DeleteTagConfirmModal",()=>IRe),e.decorator("DeleteTagConfirmModal",t(["tagDelete"],["deleteTag","tagDeleted"])),e.factory("EditTagModal",DRe),e.decorator("EditTagModal",t(["tagEdit"],["editTag","tagEdited"])),e.factory("TagsTableRow",i$e),e.factory("TagsTable",r$e),e.factory("TagsList",t$e),e.decorator("TagsList",t(["tagsList","mercureInfo"],["filterTags","createNewVisits","loadMercureInfo"])),e.serviceFactory("tagEditReducerCreator",YRe,"editTag"),e.serviceFactory("tagEditReducer",n=>n.reducer,"tagEditReducerCreator"),e.serviceFactory("tagDeleteReducerCreator",GRe,"apiClientFactory"),e.serviceFactory("tagDeleteReducer",n=>n.reducer,"tagDeleteReducerCreator"),e.serviceFactory("tagsListReducerCreator",JRe,"listTags","createShortUrl"),e.serviceFactory("tagsListReducer",n=>n.reducer,"tagsListReducerCreator"),e.serviceFactory("listTags",QRe,"apiClientFactory"),e.serviceFactory("filterTags",()=>SU),e.serviceFactory("deleteTag",n=>n.deleteTag,"tagDeleteReducerCreator"),e.serviceFactory("tagDeleted",()=>wU),e.serviceFactory("editTag",KRe,"apiClientFactory","ColorGenerator"),e.serviceFactory("tagEdited",()=>OU)},a$e=new r5,s$e=e=>a$e.parse(e),l$e=6,w4="0123456789ABCDEF",c$e=128,{floor:u$e,random:f$e,sqrt:d$e,round:h$e}=Math,p$e=()=>`#${yC(l$e,()=>w4[u$e(f$e()*w4.length)]).join("")}`,O4=e=>e.toLowerCase().trim(),m$e=e=>(e.match(/../g)??[]).map(t=>parseInt(t,16)||0),v$e=(e=0,t=0,n=0)=>h$e(d$e(.299*e**2+.587*t**2+.114*n**2));class g$e{constructor(t){za(this,"colors"),za(this,"lights");var n;this.storage=t,this.colors=((n=this.storage)==null?void 0:n.getTagColors())??{},this.lights={}}getColorForKey(t){const n=O4(t);return this.colors[n]||this.setColorForKey(n,p$e())}setColorForKey(t,n){var r;const i=O4(t);return this.colors[i]=n,(r=this.storage)==null||r.storeTagColors(this.colors),n}stylesForKey(t){const n=this.getColorForKey(t);return{backgroundColor:n,color:this.isLightColor(n)?"#222":"#fff"}}isLightColor(t){const n=t.substring(1);if(this.lights[n]===void 0){const r=m$e(n);this.lights[n]=v$e(...r)>=c$e}return this.lights[n]}}const TU=({document:e},t,n)=>{const r=e.createElement("a");r.setAttribute("href",t),r.setAttribute("download",n),r.style.visibility="hidden",e.body.appendChild(r),r.click(),e.body.removeChild(r)},y$e=(e,t,n)=>{const r=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(r);TU(e,i,n)};class b$e{constructor(t,n){this.fetch=t,this.window=n}async saveImage(t,n){const r=await this.fetch(t).then(o=>o.blob()),i=URL.createObjectURL(r);TU(this.window,i,n)}}class _$e{constructor(t,n){za(this,"exportVisits",(r,i)=>{i.length&&this.exportCsv(r,i)}),za(this,"exportShortUrls",r=>{r.length&&this.exportCsv("short_urls.csv",r)}),za(this,"exportCsv",(r,i)=>{const o=this.jsonToCsv(i);y$e(this.window,o,r)}),this.window=t,this.jsonToCsv=n}}function x$e(e){e.constant("window",window),e.constant("fetch",window.fetch.bind(window)),e.service("ImageDownloader",b$e,"fetch","window"),e.service("ColorGenerator",g$e,"TagColorsStorage"),e.constant("jsonToCsv",s$e),e.service("ReportExporter",_$e,"window","jsonToCsv"),e.serviceFactory("useTimeoutToggle",()=>pD)}const Op=({visits:e,shortUrl:t,children:n,title:r})=>m.jsx("header",{children:m.jsxs(Dr,{body:!0,children:[m.jsxs("h2",{className:"d-flex justify-content-between align-items-center mb-0",children:[m.jsx(mb,{}),m.jsx("span",{className:"text-center d-none d-sm-block",children:m.jsx("small",{children:r})}),m.jsxs("span",{className:"badge badge-main ms-3",children:["Visits:"," ",m.jsx(rU,{visitsCount:e.length,shortUrl:t})]})]}),m.jsx("h3",{className:"text-center d-block d-sm-none mb-0 mt-3",children:m.jsx("small",{children:r})}),n&&m.jsx("div",{className:"mt-md-2",children:n})]})}),gb=({children:e,className:t})=>m.jsx("div",{className:Oe("d-flex justify-content-between align-items-center",t),children:e}),jU=({title:e,footer:t,children:n})=>m.jsxs(Dr,{role:"document",children:[m.jsx(np,{className:"chart-card__header",children:e}),m.jsx(tp,{children:n}),t&&m.jsx(QI,{className:"chart-card__footer--sticky",children:t})]}),AU={color:"white",background:"rgb(0 0 0 / .9)",border:"none",borderRadius:"5px"},w$e={marginBottom:"5px",fontWeight:"bold"},kU={contentStyle:AU,labelStyle:w$e,itemStyle:{padding:0}},S4=["#97BBCD","#F7464A","#46BFBD","#FDB45C","#949FB1","#57A773","#414066","#08B2E3","#B6C454","#DCDCDC","#463730"],NU=e=>S4[e%S4.length],Cy=()=>ap()?"#46e587":"#1DAA58",O$e=()=>ap()?"rgba(70, 229, 135, 0.4)":"rgba(29, 170, 88, 0.4)",S$e=({chartData:e,showNumbers:t})=>m.jsx("ul",{className:"doughnut-chart-legend",children:e.map(({name:n,color:r,value:i})=>m.jsxs("li",{className:"doughnut-chart-legend__item d-flex",children:[m.jsx("div",{className:"doughnut-chart-legend__item-color",style:{backgroundColor:r}}),m.jsxs("small",{className:"doughnut-chart-legend__item-text flex-fill",children:[n,t&&m.jsxs("b",{children:[" (",qt(i),")"]})]})]},n))}),P4=e=>M.useMemo(()=>Object.entries(e).map(([t,n],r)=>({name:t,value:n,color:NU(r)})),[e]),P$e=({stats:e,prevStats:t,showNumbersInLegend:n,dimensions:r})=>{const i=P4(e),o=P4(t),a=o.length>0,s=ap()?Jre:Qre;return m.jsxs("div",{className:"row align-items-center",children:[m.jsx("div",{className:"col-sm-12 col-md-7",children:m.jsx("div",{style:r??{width:"100%",height:300},children:m.jsx(r?M.Fragment:wE,{children:m.jsxs(fMe,{...r,children:[m.jsx(Yr,{formatter:qt,contentStyle:AU,itemStyle:{color:"white"}}),m.jsx(fo,{data:i,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"100%",innerRadius:a?"65%":"50%",animationBegin:0,children:i.map((l,c)=>m.jsx(Fa,{fill:l.color,stroke:s},`${l.name}-${c}`))}),a&&m.jsx(fo,{data:o,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"55%",innerRadius:"20%",animationBegin:0,stroke:s,fill:Cy()})]})})})}),m.jsx("div",{className:"col-sm-12 col-md-5",children:m.jsx(S$e,{chartData:i,showNumbers:n})})]})},E4=({title:e,...t})=>{const[n,r]=Lt(!1);return m.jsx(jU,{title:m.jsxs(gb,{children:[e,m.jsx("div",{children:m.jsx(Vo,{checked:n,onChange:r,children:"Show numbers"})})]}),children:m.jsx(P$e,{...t,showNumbersInLegend:n})})},E$e=M.forwardRef(({visitsGroups:e},t)=>{const n=M.useMemo(()=>Object.entries(e),[e]);return n.length===0?null:m.jsx("ul",{className:"list-unstyled mb-0 mt-2 d-flex flex-wrap justify-content-center gap-3",ref:t,children:n.map(([r,i],o)=>m.jsxs("li",{className:"d-inline",children:[m.jsx(gU,{color:MU(i)}),m.jsxs("strong",{children:[r," (",qt(i.length),")"]})]},`${r}${o}`))})}),C$e={monthly:"Month",weekly:"Week",daily:"Day",hourly:"Hour"},T$e={hourly:e=>({hours:e}),daily:e=>({days:e}),weekly:e=>({weeks:e}),monthly:e=>({months:e})},j$e={hourly:foe,daily:m0,weekly:uoe,monthly:hg},CC={hourly:e=>pg(e,"yyyy-MM-dd HH:00"),daily:e=>Ta(e),weekly(e){const t=Ta(ah(e)),n=Ta(boe(e));return`${t} - ${n}`},monthly:e=>pg(e,"yyyy-MM")},A$e=e=>{var t;const n=Object.values(e).filter(a=>a.length>0);if(n.length===0)return"monthly";const r=new Date,i=n.map(a=>Ka(a[a.length-1].date)),o=DD(i);return((t=[[()=>m0(r,o)<=2,"hourly"],[()=>hg(r,o)<=1,"daily"],[()=>hg(r,o)<=6,"weekly"]].find(([a])=>a()))==null?void 0:t[1])??"monthly"},k$e=(e,t)=>Object.keys(t).reduce((n,r)=>(n[r]=MD(t[r],i=>CC[e](Ka(i.date))),n),{}),N$e=(e,t)=>t.reduce((n,r)=>{const i=CC[e](Ka(r.date));return n[i]=n[i]??[],n[i].push(r),n},{}),M$e=(e,t)=>{const n=Object.values(t).filter(f=>f.length>0).map(f=>[...f].reverse());if(n.length===0)return[];const r=j$e[e],i=CC[e],o=T$e[e],a=n.flat(),s=Ka(a[0].date),l=Ka(a[a.length-1].date),c=r(l,s)||1;return[{formattedDate:i(s),date:s},...yC(c,f=>{const d=ioe(s,o(f));return{formattedDate:i(d),date:d}})]},MU=e=>{if(e.color)return e.color;const t={main:nh,highlighted:e2,previous:Cy()};return e.type?t[e.type]:nh},C4=(e,t)=>M.useMemo(()=>Object.values(e).find(n=>n.type===t)??[],[e,t]),L$e=(e,t,n)=>{const r=C4(e,"main"),i=C4(e,"highlighted"),o=M.useMemo(()=>n?N$e(t,r):{},[n,t,r]),a=M.useCallback((s,{payload:l})=>{const c=o[l.formattedDate]??[];n==null||n(c===i?[]:c)},[o,i,n]);return n&&{cursor:"pointer",onClick:a}},T4=e=>{var t,n;return(n=(t=e.activePayload)==null?void 0:t[0])==null?void 0:n.payload},LU=({visitsGroups:e,setSelectedVisits:t,dimensions:n,matchMedia:r,onDateRangeChange:i})=>{const[o,a]=M.useState(A$e(e)),s=_C(767,r??window.matchMedia),l=M.useMemo(()=>{const D=k$e(o,e),K=Object.keys(D);return M$e(o,e).map(({formattedDate:W,date:X})=>({date:X,formattedDate:W,...K.reduce((Q,te)=>(Q[te]=D[te][W]??0,Q),{})}))},[o,e]),c=L$e(e,o,t),[f,d,,p]=Lt(),v=Mi(),y=M.useId(),g=Mi(),[x,_]=M.useState(s?300:400);M.useLayoutEffect(()=>{if(!f)return _(s?300:400),()=>{};const D=new ResizeObserver(()=>{const{height:K}=v.current.getBoundingClientRect(),{height:W}=g.current.getBoundingClientRect();_(K-W-48)});return D.observe(v.current),D.observe(g.current),()=>D.disconnect()},[v,f,s,g]),vLe("Escape",p,f);const b=n?M.Fragment:wE,w=M.useMemo(()=>n?{}:{width:"100%",height:x},[n,x]),[S,P]=M.useState(),[E,T]=M.useState(),j=M.useCallback(()=>{P(void 0),T(void 0)},[]),F=M.useCallback((D,K)=>{const W=T4(D);K.button===0&&W&&P(W)},[]),k=M.useCallback(D=>{const K=T4(D);S&&K&&T(K)},[S]),I=M.useCallback(()=>{if(!S||!E)return;const D=[S.date,E.date],K=soe(D),W=DD(D);j(),i({startDate:K,endDate:W})},[i,j,E,S]);return m.jsxs(Dr,{className:Oe({"fixed-top fixed-bottom":f}),"data-testid":"line-chart-card",children:[m.jsxs(np,{role:"heading","aria-level":4,className:"d-flex justify-content-between align-items-center",children:["Visits over time",m.jsxs("div",{className:"d-flex align-content-center gap-1",children:[m.jsx(qe,{"aria-label":f?"Collapse":"Expand","aria-expanded":f,"aria-controls":y,size:"sm",color:"link",onClick:d,children:m.jsx(je,{icon:f?Zq:HK})}),m.jsxs(rp,{className:"d-flex align-items-center",children:[m.jsx(Jo,{caret:!0,color:"link",className:"btn-sm p-0",children:"Group by"}),m.jsx(os,{end:!0,children:Object.entries(C$e).map(([D,K])=>m.jsx(Ne,{active:o===D,onClick:()=>a(D),children:K},D))})]})]})]}),m.jsxs(tp,{innerRef:v,id:y,children:[m.jsx(b,{...w,children:m.jsxs(uMe,{className:"user-select-none",data:l,...n,onMouseDown:F,onMouseMove:k,onMouseUp:I,children:[m.jsx(Ju,{dataKey:"formattedDate"}),m.jsx(ef,{tickFormatter:qt,yAxisId:"1"}),m.jsx(Yr,{formatter:qt,...kU}),m.jsx(iC,{strokeOpacity:ap()?.1:.9}),Object.entries(e).map(([D,K])=>K.length>0&&m.jsx(Qu,{yAxisId:"1",dataKey:D,type:"monotone",stroke:MU(K),strokeWidth:2,activeDot:K.type==="previous"?void 0:c,strokeDasharray:K.type==="previous"?"8 3":void 0},D)),S&&E&&m.jsx(vp,{yAxisId:"1",x1:S.formattedDate,x2:E.formattedDate})]})}),m.jsx(E$e,{visitsGroups:e,ref:g})]})]})},R$e=({toggleClassName:e,ranges:t,value:n,setValue:r})=>m.jsxs(rp,{children:[m.jsx(Jo,{caret:!0,color:"link",className:e,children:"Paginate"}),m.jsxs(os,{end:!0,children:[t.map(i=>m.jsxs(Ne,{active:i===n,onClick:()=>r(i),children:[m.jsx("b",{children:i})," items per page"]},i)),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{disabled:n===1/0,onClick:()=>r(1/0),children:m.jsx("i",{children:"Clear pagination"})})]})]}),j4=e=>e.startsWith("hidden_"),$$e=({stats:e,prevStats:t,highlightedStats:n,highlightedLabel:r,max:i,onClick:o,dimensions:a})=>{const s=M.useMemo(()=>Object.entries(e).map(([d,p])=>{const v=(n==null?void 0:n[d])??0,y=(t==null?void 0:t[d])??0,g=j4(d);return{name:d,amount:Math.max(p,y),nonHighlightedAmount:g?null:p-v,highlightedAmount:g?null:v,prevAmount:g?null:y}}),[e,t,n]),l=M.useMemo(()=>{const d=s.reduce((p,{name:v})=>p>v.length?p:v.length,0);return Math.min(150,d*7)},[s]),c=a?M.Fragment:wE,f=M.useMemo(()=>a?{}:{width:"100%",height:Math.max(300,s.length*(t?44:22))},[a,s.length,t]);return m.jsx(c,{...f,children:m.jsxs(dMe,{layout:"vertical",data:s,barCategoryGap:3,...a,children:[m.jsx(Ju,{type:"number",dataKey:"amount",tickFormatter:qt,domain:i?[0,i]:void 0}),m.jsx(ef,{type:"category",dataKey:"name",width:l,interval:0,style:{fontSize:".8rem"},tickFormatter:d=>j4(d)?"":d}),m.jsx(iC,{strokeOpacity:ap()?.05:.9}),m.jsx(Yr,{filterNull:!0,...kU,formatter:(d,p)=>[qt(d),p==="highlightedAmount"?r:p==="prevAmount"?"Previous period":n?"Non-selected":"Visits"]}),m.jsx(Lo,{dataKey:"nonHighlightedAmount",stackId:"main",cursor:"pointer",fill:nh,onClick:({name:d})=>o==null?void 0:o(d),children:s.map(d=>m.jsx(Fa,{fill:Zre,stroke:nh,strokeWidth:2},d.name))}),n&&m.jsx(Lo,{dataKey:"highlightedAmount",stackId:"main",cursor:"pointer",fill:e2,onClick:({name:d})=>o==null?void 0:o(d),children:s.map(d=>m.jsx(Fa,{fill:Xre,stroke:e2,strokeWidth:2},d.name))}),t&&m.jsx(Lo,{dataKey:"prevAmount",fill:Cy(),children:s.map(d=>m.jsx(Fa,{fill:O$e(),stroke:Cy(),strokeWidth:2},d.name))})]})})},I$e=e=>typeof e=="string"?e.toLowerCase():e,D$e=([e])=>e,F$e=([,e])=>e,Mm=({stats:e,prevStats:t,highlightedStats:n,title:r,sortingItems:i,extraHeaderContent:o,withPagination:a=!0,...s})=>{const[l,c]=M.useState({}),[f,d]=M.useState(1),[p,v]=M.useState(50),y=M.useCallback((j,F)=>{const k=Object.entries(j),I=l.field?toe(k,([D,K])=>I$e(l.field===Object.keys(F)[0]?D:K)):k;return!l.dir||l.dir==="ASC"?I:[...I].reverse()},[l.dir,l.field]),g=M.useCallback(j=>{const F=j[f-1];if(f[`hidden_${I}`,0])]},[f]),x=M.useCallback(j=>m.jsx(EC,{currentPage:f,pagesCount:j,setCurrentPage:d}),[f]),_=M.useCallback((j,F,k,I)=>{const D=y(j,F),K=D.map(D$e),W=k&&Object.entries({...S3(K,K.map(()=>0)),...k}),X=I&&Object.entries({...S3(K,K.map(()=>0)),...I});if(D.length<=p)return{currentPageStats:Object.fromEntries(D),currentPageHighlightedStats:W&&Object.fromEntries(W),currentPagePrevStats:X&&Object.fromEntries(X)};const Q=Ac(D,p),te=W&&Ac(W,p),Z=X&&Ac(X,p);return{currentPageStats:Object.fromEntries(g(Q)),currentPageHighlightedStats:te&&Object.fromEntries(g(te)),currentPagePrevStats:Z&&Object.fromEntries(g(Z)),pagination:x(Q.length),max:$Le(Math.max(...D.map(F$e)))}},[g,y,p,x]),{currentPageStats:b,currentPagePrevStats:w,currentPageHighlightedStats:S,pagination:P,max:E}=M.useMemo(()=>_(e,i,n&&Object.keys(n).length>0?n:void 0,t&&Object.keys(t).length>0?t:void 0),[_,n,t,i,e]),T=M.useMemo(()=>Object.keys(b),[b]);return m.jsx(jU,{title:m.jsxs(gb,{children:[r,m.jsxs("div",{className:"d-flex gap-3",children:[o==null?void 0:o(P?T:void 0),a&&Object.keys(e).length>50&&m.jsx(R$e,{toggleClassName:"btn-sm p-0",ranges:[50,100,200,500],value:p,setValue:j=>{v(j),d(1)}}),m.jsx(op,{isButton:!1,right:!0,items:i,order:l,onChange:(j,F)=>{c({field:j,dir:F}),d(1)}})]})]}),footer:P,children:m.jsx($$e,{stats:b,prevStats:w,highlightedStats:S,max:E,...s})})},A4=(e,t)=>{if(!(!t||!(e in t)))return t[e]&&Qa(t[e])||""},RU=()=>{const e=po(),t=$u(),{startDate:n,endDate:r,orphanVisitsType:i,excludeBots:o,loadPrevInterval:a,...s}=t,l=M.useMemo(()=>({dateRange:n!=null||r!=null?dB(n,r):void 0,visitsFilter:{orphanVisitsType:i,excludeBots:o!==void 0?o==="true":void 0},loadPrevInterval:a!==void 0?a==="true":void 0}),[r,o,a,i,n]),c=M.useCallback(f=>{const{dateRange:d,visitsFilter:p={},loadPrevInterval:v}=p0(l,f),{excludeBots:y,orphanVisitsType:g}=p,x={...s,startDate:A4("startDate",d),endDate:A4("endDate",d),excludeBots:y===void 0?void 0:KO(y),orphanVisitsType:g,loadPrevInterval:v===void 0?void 0:KO(v)},_=s0(x),b=_?`?${_}`:"";e(b,{replace:!0,relative:"route"})},[l,e,s]);return[l,c]},B$e=()=>m.jsx(jMe,{attribution:'© OpenStreetMap contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),U$e=e=>{if(e.length===0)return{};if(e.length>1)return{bounds:e.map(({latLong:n})=>n)};const[{latLong:t}]=e;return{zoom:10,center:t}},$U=({toggle:e,isOpen:t,title:n,locations:r=[]})=>m.jsx(vr,{toggle:e,isOpen:t,className:"map-modal__modal",contentClassName:"map-modal__modal-content",children:m.jsxs(Li,{className:"map-modal__modal-body",children:[m.jsxs(gb,{className:"map-modal__modal-title fs-4",children:[n,m.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:e})]}),m.jsxs(EMe,{...U$e(r),children:[m.jsx(B$e,{}),r.map(({cityName:i,latLong:o,count:a},s)=>m.jsx(CMe,{position:o,children:m.jsxs(TMe,{children:[m.jsx("b",{children:a})," visit",a>1?"s":""," from ",m.jsx("b",{children:i})]})},s))]})]})}),z$e=({modalTitle:e,activeCities:t,locations:n=[]})=>{const[r,,i,o]=Lt(),[a,s]=Lt(),[l,c]=M.useState([]),f=M.useCallback(d=>{c(d?n.filter(d):n),i()},[n,i]);return m.jsxs(m.Fragment,{children:[!t&&m.jsx(qe,{color:"link",className:"p-0",onClick:()=>f(),"aria-label":"Show in map",title:"Show in map",children:m.jsx(je,{icon:bx})}),t&&m.jsxs(is,{isOpen:a,toggle:s,children:[m.jsx(Jo,{color:"link",className:"p-0",title:"Show in map",children:m.jsx(je,{icon:bx})}),m.jsxs(os,{end:!0,children:[m.jsx(Ne,{onClick:()=>f(),children:"Show all locations"}),m.jsx(Ne,{onClick:()=>f(({cityName:d})=>t.includes(d)),children:"Show locations in current page"})]})]}),m.jsx($U,{toggle:o,isOpen:r,title:e,locations:l})]})},IU=({onChange:e,selected:t={},className:n,isOrphanVisits:r=!1,withPrevInterval:i=!1,disabled:o})=>{const{orphanVisitsType:a,excludeBots:s=!1,loadPrevInterval:l=!1}=t,c=p=>({active:a===p,onClick:()=>e({...t,orphanVisitsType:p===a?void 0:p})}),f=M.useCallback(()=>e({...t,excludeBots:!s}),[s,e,t]),d=M.useCallback(()=>e({...t,loadPrevInterval:!l}),[l,e,t]);return m.jsxs(ea,{disabled:o,text:"More",dropdownClassName:n,end:!0,minWidth:250,children:[i&&m.jsxs(m.Fragment,{children:[m.jsx(Ne,{active:l,onClick:d,children:"Compare with previous period"}),m.jsx(Ne,{divider:!0,tag:"hr"})]}),m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Bots:"}),m.jsx(Ne,{active:s,onClick:f,children:"Exclude potential bots"}),r&&m.jsxs(m.Fragment,{children:[m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Orphan visits type:"}),m.jsx(Ne,{...c("base_url"),children:"Base URL"}),m.jsx(Ne,{...c("invalid_short_url"),children:"Invalid short URL"}),m.jsx(Ne,{...c("regular_404"),children:"Regular 404"})]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{disabled:t.excludeBots===void 0&&t.loadPrevInterval===void 0&&t.orphanVisitsType===void 0,onClick:()=>e({excludeBots:void 0,loadPrevInterval:void 0,orphanVisitsType:void 0}),children:m.jsx("i",{children:"Reset to defaults"})})]})},DU=({info:e})=>{const{loading:t,errorData:n,progress:r}=e;return m.jsxs(m.Fragment,{children:[t&&r===null&&m.jsx(zo,{loading:!0}),t&&r!==null&&m.jsxs(zo,{loading:!0,children:["This is going to take a while... :S",m.jsx(rD,{value:r,striped:r>=100,className:"mt-3"})]}),n&&m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:n,fallbackMessage:"An error occurred while loading visits :("})})]})},av=({children:e,showFallback:t})=>m.jsxs(m.Fragment,{children:[t&&m.jsx(zo,{className:"mt-3",children:"There are no visits matching current filter"}),!t&&m.jsx(m.Fragment,{children:e})]}),V$e=({visitsDeletion:e,deleteVisits:t})=>{const{deleting:n}=e,[r,,i]=Lt();return m.jsx(gt,{title:m.jsx("span",{className:"text-danger fw-bold",children:"Danger zone"}),children:m.jsxs(gb,{children:[m.jsxs("dl",{className:"m-0 me-3",children:[m.jsx("dt",{children:"Delete visits."}),m.jsxs("dd",{className:"m-0",children:["This will delete ",m.jsx("b",{children:"all"})," visits, not only the ones matching current filter."]})]}),!r&&m.jsx(qe,{color:"danger",className:"indivisible",onClick:i,children:"Delete visits"}),r&&m.jsxs(qe,{color:"danger",disabled:n,className:"indivisible",onClick:t,innerRef:o=>{o==null||o.focus()},children:[!n&&m.jsx(m.Fragment,{children:"Click again to confirm"}),n&&m.jsx(m.Fragment,{children:"Deleting..."})]})]})})},Lm="Others",W$e=["Android Browser","Chrome","Chromium","Firefox","Internet Explorer","Microsoft Edge","Opera","Safari","Samsung Internet for Android","Vivaldi","WeChat"],H$e=e=>{if(!Rs(e))return{browser:Lm,os:Lm};const{browser:{name:t},os:{name:n}}=RMe.parse(e);return{os:n??Lm,browser:t&&W$e.includes(t)?t:Lm}},G$e=e=>{var t;return Rs(e)?((t=e.split("/")[e.includes("://")?2:0])==null?void 0:t.split(":")[0])??"":"Direct"},FU=(e,t)=>e[t]!==void 0,k4=e=>typeof e=="number"?e:e?parseFloat(e):0,q$e=(e,{os:t})=>{e[t]=(e[t]||0)+1},K$e=(e,{browser:t})=>{e[t]=(e[t]||0)+1},Y$e=(e,{referer:t})=>{e[t]=(e[t]||0)+1},BU=e=>(t,n)=>{const r=FU(n,e)?n[e]:"Unknown";t[r]=(t[r]||0)+1},Z$e=BU("country"),X$e=BU("city"),Q$e=(e,t)=>{if(!FU(t,"city")||t.city==="Unknown")return;const{city:n,latitude:r,longitude:i}=t,o=e[n]||{cityName:n,count:0,latLong:[k4(r),k4(i)]};o.count+=1,e[n]=o},J$e=(e,t)=>{if(!QMe(t))return;const{visitedUrl:n}=t;e[n]=(e[n]||0)+1},eS=e=>e.reduce((t,n)=>(q$e(t.os,n),K$e(t.browsers,n),Y$e(t.referrers,n),Z$e(t.countries,n),X$e(t.cities,n),Q$e(t.citiesForMap,n),J$e(t.visitedUrls,n),t),{os:{},browsers:{},referrers:{},countries:{},cities:{},citiesForMap:{},visitedUrls:{}}),Ty=e=>e.map(t=>{const{userAgent:n,date:r,referer:i,visitLocation:o,potentialBot:a}=t;return{date:r,potentialBot:a,userAgent:n,...H$e(n),referer:G$e(i),country:(o==null?void 0:o.countryName)||"Unknown",city:(o==null?void 0:o.cityName)||"Unknown",latitude:o==null?void 0:o.latitude,longitude:o==null?void 0:o.longitude,visitedUrl:t.visitedUrl,type:gC(t)?t.type:void 0}}),e6e=Object.freeze(Object.defineProperty({__proto__:null,normalizeVisits:Ty,processStatsFromVisits:eS},Symbol.toStringTag,{value:"Module"})),Jf=20,t6e=({browser:e,os:t,referer:n,country:r,city:i,userAgent:o,...a},s,l)=>{const c=l?o:`${r} ${i}`;return`${e} ${t} ${n} ${c} ${a.visitedUrl}`.toLowerCase().includes(s.toLowerCase())},n6e=(e,t,n)=>t.filter(r=>t6e(r,e,n)),r6e=(e,t)=>vD(t,e),i6e=({visits:e,searchTerm:t,order:n,searchInRawUserAgent:r})=>{const i=t?n6e(t,e,r):[...e],o=r6e(n,i),a=o.length;return{visitsGroups:Ac(o,Jf),total:a}},Gi="visits-table__header-cell visits-table__sticky",o6e=({visits:e,selectedVisits:t=[],setSelectedVisits:n,matchMedia:r=window.matchMedia})=>{var i;const o=_C(767,r),[a,s]=M.useState(),l=M.useCallback(j=>{s(j),x(1),n([])},[n]),[c,f]=M.useState({}),[d,p]=Lt(),v=M.useCallback(()=>{p(),f({})},[p]),y=M.useMemo(()=>i6e({visits:e,searchTerm:a,order:c,searchInRawUserAgent:d}),[e,a,c,d]),[g,x]=M.useState(1),_=g*Jf,b=_-Jf,w=M.useMemo(()=>{var j,F;return!!((F=(j=y.visitsGroups[g-1])==null?void 0:j[0])!=null&&F.visitedUrl)},[g,y.visitsGroups]),S=6+Number(w)+(d?1:2),P=y.total>0,E=j=>f({field:j,dir:c0(j,c.field,c.dir)}),T=j=>m.jsx(Cd,{currentOrder:c,field:j,className:"visits-table__header-icon"});return m.jsx(gt,{className:"mt-3",bodyClassName:"p-0 pb-1",title:m.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:["Visits list",m.jsx(Vo,{checked:d,onChange:v,children:"Show user agent"})]}),children:m.jsx("div",{className:"table-responsive-md",children:m.jsxs("table",{className:Oe("table table-sm position-relative m-0 visits-table",{"table-hover":P}),children:[m.jsxs("thead",{className:"visits-table__header",children:[m.jsxs("tr",{children:[m.jsxs("th",{className:`${Gi} text-center`,onClick:()=>n(t.length0})})]}),m.jsxs("th",{className:`${Gi} text-center`,onClick:()=>E("potentialBot"),children:[m.jsx("span",{className:"sr-only",children:"Is bot"}),m.jsx(je,{icon:iA}),T("potentialBot")]}),m.jsxs("th",{className:Gi,onClick:()=>E("date"),children:["Date",T("date")]}),m.jsxs("th",{className:Gi,onClick:()=>E("country"),children:["Country",T("country")]}),m.jsxs("th",{className:Gi,onClick:()=>E("city"),children:["City",T("city")]}),d?m.jsxs("th",{className:Gi,onClick:()=>E("userAgent"),children:["User agent",T("userAgent")]}):m.jsxs(m.Fragment,{children:[m.jsxs("th",{className:Gi,onClick:()=>E("browser"),children:["Browser",T("browser")]}),m.jsxs("th",{className:Gi,onClick:()=>E("os"),children:["OS",T("os")]})]}),m.jsxs("th",{className:Gi,onClick:()=>E("referer"),children:["Referrer",T("referer")]}),w&&m.jsxs("th",{className:Gi,onClick:()=>E("visitedUrl"),children:["Visited URL",T("visitedUrl")]})]}),m.jsx("tr",{children:m.jsx("td",{colSpan:S,className:"p-0",children:m.jsx(ip,{noBorder:!0,large:!1,onChange:l})})})]}),m.jsxs("tbody",{children:[!P&&m.jsx("tr",{children:m.jsx("td",{colSpan:S,className:"text-center",children:"There are no visits matching current filter"})}),(i=y.visitsGroups[g-1])==null?void 0:i.map((j,F)=>{const k=t.includes(j);return m.jsxs("tr",{style:{cursor:"pointer"},className:Oe({"table-active":k}),onClick:()=>n(k?t.filter(I=>I!==j):[...t,j]),children:[m.jsx("td",{className:"text-center",children:k&&m.jsx(je,{icon:qd,className:"text-primary"})}),m.jsx("td",{className:"text-center",children:j.potentialBot&&m.jsxs(m.Fragment,{children:[m.jsx(je,{icon:iA,id:`botIcon${F}`}),m.jsx(Fr,{placement:"right",target:`botIcon${F}`,children:"Potentially a visit from a bot or crawler"})]})}),m.jsx("td",{children:m.jsx(Py,{date:j.date})}),m.jsx("td",{children:j.country}),m.jsx("td",{children:j.city}),d?m.jsx("td",{children:j.userAgent}):m.jsxs(m.Fragment,{children:[m.jsx("td",{children:j.browser}),m.jsx("td",{children:j.os})]}),m.jsx("td",{children:j.referer}),j.visitedUrl&&m.jsx("td",{children:j.visitedUrl})]},F)})]}),y.total>Jf&&m.jsx("tfoot",{children:m.jsx("tr",{children:m.jsx("td",{colSpan:S,className:"visits-table__footer-cell visits-table__sticky",children:m.jsxs("div",{className:"d-flex flex-column flex-md-row justify-content-between align-items-center gap-3 p-2",children:[m.jsx(EC,{pagesCount:Math.ceil(y.total/Jf),currentPage:g,setCurrentPage:x,centered:o}),m.jsxs("div",{children:["Visits ",m.jsx("b",{children:qt(b+1)})," to"," ",m.jsx("b",{children:qt(Math.min(_,y.total))})," of"," ",m.jsx("b",{children:qt(y.total)})]})]})})})})]})})})},pa={byTime:{title:"By time",subPath:"by-time",icon:Qq},byContext:{title:"By context",subPath:"by-context",icon:lP},byLocation:{title:"By location",subPath:"by-location",icon:bx},list:{title:"List",subPath:"list",icon:L6},options:{title:"Options",subPath:"options",icon:F6,shouldRender:({deletion:e})=>!!e}};Object.freeze(pa);const __=({display:e})=>e&&m.jsx("div",{className:"mt-3 mx-auto w-75",children:m.jsx(gt,{children:m.jsxs("div",{className:"d-flex gap-2",children:[m.jsx(je,{icon:ZK,className:"mt-1"}),m.jsx("i",{children:"Could not calculate previous period because selected one does not have a strictly defined start date."})]})})});let Rm;const Sp=e=>{const{children:t,visitsInfo:n,getVisits:r,cancelGetVisits:i,deletion:o,exportCsv:a,isOrphanVisits:s=!1}=e,{visits:l,prevVisits:c,loading:f,errorData:d,fallbackInterval:p}=n,[{dateRange:v,visitsFilter:y,loadPrevInterval:g},x]=RU(),_=nr("visits"),[b,w]=M.useState(),S=M.useCallback(({startDate:A,endDate:N},U)=>{x({dateRange:{startDate:A??void 0,endDate:N??void 0}}),w(U)},[x]),P=M.useRef(v??p??(_==null?void 0:_.defaultInterval)??"last30Days"),[E,T]=M.useState([]),[j,F]=M.useState(),k=M.useRef(!0),{search:I}=pr(),D=M.useCallback(A=>A?`${A}${I}`:I,[I]),K=M.useMemo(()=>Ty(l),[l]),W=M.useMemo(()=>c&&Ty(c),[c]),{os:X,browsers:Q,referrers:te,countries:Z,cities:z,citiesForMap:B,visitedUrls:H}=M.useMemo(()=>eS(K),[K]),ee=M.useMemo(()=>eS(W??[]),[W]),q=M.useMemo(()=>Object.fromEntries([["Visits",Object.assign(K,{type:"main"})],W&&["Previous period",Object.assign(W,{type:"previous"})],E.length>0&&[j??"Selected",Object.assign(E,{type:"highlighted"})]].filter(Boolean)),[j,E,W,K]),ne=M.useMemo(()=>({...y,excludeBots:y.excludeBots??(_==null?void 0:_.excludeBots),loadPrevInterval:g??(_==null?void 0:_.loadPrevInterval)}),[g,y,_==null?void 0:_.excludeBots,_==null?void 0:_.loadPrevInterval]),re=M.useMemo(()=>Object.values(B),[B]),ae=M.useCallback(A=>{Rm=void 0,T(A)},[]),ue=M.useCallback((A,N)=>{const U=`${A}_${N}`;Rm===U?(T([]),F(void 0),Rm=void 0):(T(K.filter(J=>J[A]===N)),F(N),Rm=U)},[K]);return M.useEffect(()=>i,[i]),M.useEffect(()=>{const A=v??mB(P.current),{loadPrevInterval:N,...U}=ne,J={doIntervalFallback:k.current,loadPrevInterval:N};r({dateRange:A,filter:U},J),ae([]),k.current=!1},[v,y,r,ne,ae]),M.useEffect(()=>{p&&P.current===((_==null?void 0:_.defaultInterval)??"last30Days")&&(P.current=p)},[p,_==null?void 0:_.defaultInterval]),m.jsxs(m.Fragment,{children:[t,m.jsx("section",{className:"mt-3",children:m.jsxs("div",{className:"row flex-md-row-reverse",children:[m.jsx("div",{className:"col-lg-7 col-xl-6",children:m.jsxs("div",{className:"d-md-flex",children:[m.jsx("div",{className:"flex-grow-1",children:m.jsx(OC,{disabled:f,dateRangeOrInterval:b??v??P.current,defaultText:"All visits",onDatesChange:S})}),m.jsx(IU,{disabled:f,className:"ms-0 ms-md-2 mt-3 mt-md-0",isOrphanVisits:s,withPrevInterval:!0,selected:ne,onChange:({loadPrevInterval:A,...N})=>x({visitsFilter:N,loadPrevInterval:A})})]})}),l.length>0&&m.jsx("div",{className:"col-lg-5 col-xl-6 mt-3 mt-lg-0",children:m.jsxs("div",{className:"d-flex",children:[m.jsx(JB,{className:"btn-md-block",amount:K.length,onClick:()=>a(K)}),m.jsxs(qe,{outline:!0,disabled:E.length===0,className:"btn-md-block ms-2",onClick:()=>ae([]),children:["Clear selection ",E.length>0&&m.jsxs(m.Fragment,{children:["(",qt(E.length),")"]})]})]})})]})}),m.jsxs("section",{className:"mt-3",children:[m.jsx(DU,{info:n}),!f&&!d&&m.jsxs(m.Fragment,{children:[m.jsx(mD,{fill:!0,children:Object.values(pa).map(({title:A,icon:N,subPath:U,shouldRender:J},Y)=>!J||J(e)?m.jsxs(md,{to:D(U),replace:!0,children:[m.jsx(je,{icon:N}),m.jsx("span",{className:"ms-2 d-none d-lg-inline",children:A})]},Y):void 0).filter(Boolean)}),m.jsx(Pr,{children:m.jsxs(Xy,{children:[m.jsx(ot,{path:pa.byTime.subPath,element:m.jsxs(av,{showFallback:l.length===0,children:[m.jsx("div",{className:"col-12 mt-3","data-testid":"line-chart-container",children:m.jsx(LU,{visitsGroups:q,setSelectedVisits:ae,onDateRangeChange:S})}),m.jsx(__,{display:!!ne.loadPrevInterval&&!c})]})}),m.jsx(ot,{path:pa.byContext.subPath,element:m.jsxs(av,{showFallback:l.length===0,children:[m.jsx("div",{className:Oe("mt-3 col-lg-6",{"col-xl-4":!s}),children:m.jsx(E4,{title:"Operating systems",stats:X,prevStats:ee.os})}),m.jsx("div",{className:Oe("mt-3 col-lg-6",{"col-xl-4":!s}),children:m.jsx(E4,{title:"Browsers",stats:Q,prevStats:ee.browsers})}),m.jsx("div",{className:Oe("mt-3",{"col-xl-4":!s,"col-lg-6":s}),children:m.jsx(Mm,{title:"Referrers",withPagination:!1,stats:te,prevStats:ee.referrers,highlightedStats:jm(E,"referer"),highlightedLabel:j,sortingItems:{name:"Referrer name",amount:"Visits amount"},onClick:A=>ue("referer",A)})}),s&&m.jsx("div",{className:"mt-3 col-lg-6",children:m.jsx(Mm,{title:"Visited URLs",stats:H,prevStats:ee.visitedUrls,highlightedStats:jm(E,"visitedUrl"),highlightedLabel:j,sortingItems:{visitedUrl:"Visited URL",amount:"Visits amount"},onClick:A=>ue("visitedUrl",A)})}),m.jsx("div",{className:"col-12",children:m.jsx(__,{display:!!ne.loadPrevInterval&&!c})})]})}),m.jsx(ot,{path:pa.byLocation.subPath,element:m.jsxs(av,{showFallback:l.length===0,children:[m.jsx("div",{className:"col-lg-6 mt-3",children:m.jsx(Mm,{title:"Countries",stats:Z,prevStats:ee.countries,highlightedStats:jm(E,"country"),highlightedLabel:j,sortingItems:{name:"Country name",amount:"Visits amount"},onClick:A=>ue("country",A)})}),m.jsx("div",{className:"col-lg-6 mt-3",children:m.jsx(Mm,{title:"Cities",stats:z,prevStats:ee.cities,highlightedStats:jm(E,"city"),highlightedLabel:j,extraHeaderContent:A=>re.length>0&&m.jsx(z$e,{modalTitle:"Cities",locations:re,activeCities:A}),sortingItems:{name:"City name",amount:"Visits amount"},onClick:A=>ue("city",A)})}),m.jsx("div",{className:"col-12",children:m.jsx(__,{display:!!ne.loadPrevInterval&&!c})})]})}),m.jsx(ot,{path:pa.list.subPath,element:m.jsx("div",{className:"col-12",children:m.jsx(o6e,{visits:K,selectedVisits:E,setSelectedVisits:ae})})}),o&&m.jsx(ot,{path:pa.options.subPath,element:m.jsx("div",{className:"col-12 mt-3",children:m.jsx(V$e,{...o})})}),m.jsx(ot,{path:"*",element:m.jsx(eP,{replace:!0,to:D(pa.byTime.subPath)})})]})})]})]})]})},UU=Di(({getDomainVisits:e,domainVisits:t,cancelGetDomainVisits:n})=>{const{ReportExporter:r}=Rt(UU),{domain:i=""}=Mu(),[o,a=o]=i.split("_"),s=M.useCallback((c,f)=>e({domain:a,options:f,params:c}),[a,e]),l=M.useCallback(c=>r.exportVisits(`domain_${o}_visits.csv`,c),[o,r]);return m.jsx(Sp,{getVisits:s,cancelGetVisits:n,visitsInfo:t,exportCsv:l,children:m.jsx(Op,{visits:t.visits,title:`"${o}" visits`})})},()=>[Jn.visits]),a6e=$t(UU,["ReportExporter"]),zU=Di(({getNonOrphanVisits:e,nonOrphanVisits:t,cancelGetNonOrphanVisits:n})=>{const{ReportExporter:r}=Rt(zU),i=M.useCallback(a=>r.exportVisits("non_orphan_visits.csv",a),[r]),o=M.useCallback((a,s)=>e({options:s,params:a}),[e]);return m.jsx(Sp,{getVisits:o,cancelGetVisits:n,visitsInfo:t,exportCsv:i,children:m.jsx(Op,{title:"Non-orphan visits",visits:t.visits})})},()=>[Jn.visits]),s6e=$t(zU,["ReportExporter"]),VU=Di(({getOrphanVisits:e,orphanVisits:t,cancelGetOrphanVisits:n,deleteOrphanVisits:r,orphanVisitsDeletion:i})=>{const o=Ko("orphanVisitsDeletion"),{ReportExporter:a}=Rt(VU),s=M.useCallback(f=>a.exportVisits("orphan_visits.csv",f),[a]),l=M.useCallback((f,d)=>{var p;return e({options:d,params:f,orphanVisitsType:(p=f.filter)==null?void 0:p.orphanVisitsType})},[e]),c=M.useMemo(()=>o?{deleteVisits:r,visitsDeletion:i}:void 0,[r,i,o]);return m.jsx(Sp,{getVisits:l,cancelGetVisits:n,visitsInfo:t,exportCsv:s,deletion:c,isOrphanVisits:!0,children:m.jsx(Op,{title:"Orphan visits",visits:t.visits})})},()=>[Jn.orphanVisits]),l6e=$t(VU,["ReportExporter"]),WU="shlink/orphanVisits",c6e={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},u6e=e=>_p({typePrefix:`${WU}/getNonOrphanVisits`,createLoaders:({options:t})=>{const n=e(),{doIntervalFallback:r=!1}=t,i=async a=>n.getNonOrphanVisits(a),o=bp(r,a=>n.getNonOrphanVisits(a));return{visitsLoader:i,lastVisitLoader:o}},shouldCancel:t=>t().orphanVisits.cancelLoad}),f6e=e=>xp({name:WU,initialState:c6e,asyncThunkCreator:e,filterCreatedVisits:({params:t},n)=>{const{startDate:r,endDate:i}=(t==null?void 0:t.dateRange)??{};return n.filter(({visit:o})=>yp(o.date,r,i))}}),HU="shlink/orphanVisits",d6e={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},h6e=(e,t)=>!t||t===e.type,p6e=({data:e,...t},n)=>{const r=e.filter(i=>gC(i)&&h6e(i,n));return{...t,data:r}},m6e=e=>_p({typePrefix:`${HU}/getOrphanVisits`,createLoaders:({orphanVisitsType:t,options:n})=>{const r=e(),{doIntervalFallback:i=!1}=n,o=async s=>r.getOrphanVisits({...s,type:t}).then(l=>p6e(l,t)),a=bp(i,s=>r.getOrphanVisits(s));return{visitsLoader:o,lastVisitLoader:a}},shouldCancel:t=>t().orphanVisits.cancelLoad}),v6e=(e,t)=>xp({name:HU,initialState:d6e,asyncThunkCreator:e,extraReducers:n=>{n.addCase(t.fulfilled,r=>({...r,visits:[]}))},filterCreatedVisits:({params:n},r)=>{const{startDate:i,endDate:o}=(n==null?void 0:n.dateRange)??{};return r.filter(({visit:a,shortUrl:s})=>!s&&yp(a.date,i,o))}}),GU="shlink/orphanVisitsDeletion",N4={deletedVisits:0,deleting:!1,error:!1},g6e=e=>fn(`${GU}/deleteOrphanVisits`,()=>e().deleteOrphanVisits()),y6e=e=>Qt({name:GU,initialState:N4,reducers:{},extraReducers:t=>{t.addCase(e.pending,n=>({...n,deleting:!0,error:!1})),t.addCase(e.rejected,(n,{error:r})=>({...n,deleting:!1,error:!0,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>{const{deletedVisits:i}=r;return{...N4,deletedVisits:i}})}}),qU="shlink/shortUrlVisits",b6e={visits:[],shortCode:"",loading:!1,errorData:null,cancelLoad:!1,progress:null},_6e=e=>_p({typePrefix:`${qU}/getShortUrlVisits`,createLoaders:({shortCode:t,domain:n,options:r})=>{const i=e(),{doIntervalFallback:o=!1}=r,a=l=>i.getShortUrlVisits(t,{...l,domain:n}),s=bp(o,l=>i.getShortUrlVisits(t,{...l,domain:n}));return{visitsLoader:a,lastVisitLoader:s}},shouldCancel:t=>t().shortUrlVisits.cancelLoad}),x6e=(e,t)=>xp({name:qU,initialState:b6e,asyncThunkCreator:e,extraReducers:n=>{n.addCase(t.fulfilled,(r,{payload:i})=>r.shortCode===i.shortCode&&r.domain===i.domain?{...r,visits:[]}:r)},filterCreatedVisits:({shortCode:n,domain:r,params:i},o)=>gB(o,{shortCode:n,domain:r},i==null?void 0:i.dateRange)}),KU="shlink/shortUrlVisitsDeletion",M4={shortCode:"",deletedVisits:0,deleting:!1,error:!1},w6e=e=>fn(`${KU}/deleteShortUrlVisits`,async({shortCode:t,domain:n})=>({...await e().deleteShortUrlVisits(t,n),shortCode:t,domain:n})),O6e=e=>Qt({name:KU,initialState:M4,reducers:{},extraReducers:t=>{t.addCase(e.pending,n=>({...n,deleting:!0,error:!1})),t.addCase(e.rejected,(n,{error:r})=>({...n,deleting:!1,error:!0,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>{const{shortCode:i,domain:o,deletedVisits:a}=r;return{...M4,shortCode:i,domain:o,deletedVisits:a}})}}),YU="shlink/tagVisits",S6e={visits:[],tag:"",loading:!1,cancelLoad:!1,errorData:null,progress:null},P6e=e=>_p({typePrefix:`${YU}/getTagVisits`,createLoaders:({tag:t,options:n})=>{const r=e(),{doIntervalFallback:i=!1}=n,o=s=>r.getTagVisits(t,s),a=bp(i,async s=>r.getTagVisits(t,s));return{visitsLoader:o,lastVisitLoader:a}},shouldCancel:t=>t().tagVisits.cancelLoad}),E6e=e=>xp({name:YU,initialState:S6e,asyncThunkCreator:e,filterCreatedVisits:({tag:t,params:n},r)=>bB(r,t,n==null?void 0:n.dateRange)}),ZU="shlink/visitsOverview",$m={nonOrphanVisits:{total:0},orphanVisits:{total:0},loading:!1,error:!1},L4=e=>e.filter(({visit:t})=>t.potentialBot).length,C6e=e=>fn(`${ZU}/loadVisitsOverview`,()=>e().getVisitsOverview().then(({nonOrphanVisits:t,visitsCount:n=0,orphanVisits:r,orphanVisitsCount:i=0})=>({nonOrphanVisits:{total:(t==null?void 0:t.total)??n,nonBots:t==null?void 0:t.nonBots,bots:t==null?void 0:t.bots},orphanVisits:{total:(r==null?void 0:r.total)??i,nonBots:r==null?void 0:r.nonBots,bots:r==null?void 0:r.bots}}))),T6e=e=>Qt({name:ZU,initialState:$m,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({...$m,loading:!0})),t.addCase(e.rejected,()=>({...$m,error:!0})),t.addCase(e.fulfilled,(n,{payload:r})=>({...$m,...r})),t.addCase(tf,({nonOrphanVisits:n,orphanVisits:r,...i},{payload:o})=>{const{nonOrphanVisits:a,orphanVisits:s}=JMe(o.createdVisits),l=a.length,c=L4(a),f=l-c,d=s.length,p=L4(s),v=d-p;return{...i,nonOrphanVisits:{total:n.total+l,bots:n.bots&&n.bots+c,nonBots:n.nonBots&&n.nonBots+f},orphanVisits:{total:r.total+d,bots:r.bots&&r.bots+p,nonBots:r.nonBots&&r.nonBots+v}}})}}),j6e=({shortUrl:e,loading:t,shortUrlVisits:n})=>{const{visits:r}=n,i=(e==null?void 0:e.shortUrl)??"",o=(e==null?void 0:e.longUrl)??"",a=e==null?void 0:e.title;return m.jsxs(Op,{title:m.jsxs(m.Fragment,{children:["Visits for ",m.jsx(hr,{href:i})]}),visits:r,shortUrl:e,children:[m.jsx("hr",{}),m.jsxs("div",{children:["Created: ",e?m.jsxs("span",{children:[m.jsx("b",{id:"created",className:"short-url-visits-header__created-at",children:m.jsx(Py,{date:e.dateCreated,relative:!0})}),m.jsx(Fr,{placement:"bottom",target:"created",children:m.jsx(Py,{date:e.dateCreated})})]}):m.jsx("small",{children:"Loading..."})]}),m.jsxs("div",{className:"long-url-container",children:[`${a?"Title":"Long URL"}: `,t&&m.jsx("small",{children:"Loading..."}),!t&&m.jsx(hr,{href:o,children:a??o})]})]})},XU=Di(({shortUrlVisits:e,shortUrlVisitsDeletion:t,shortUrlsDetails:n,getShortUrlVisits:r,getShortUrlsDetails:i,deleteShortUrlVisits:o,cancelGetShortUrlVisits:a})=>{const s=Ko("shortUrlVisitsDeletion"),{ReportExporter:l}=Rt(XU),c=wC(),f=M.useMemo(()=>{var y;return(y=n.shortUrls)==null?void 0:y.get(c)},[c,n.shortUrls]),d=M.useCallback((y,g)=>r({...c,options:g,params:y}),[r,c]),p=M.useCallback(y=>l.exportVisits(`short-url_${f==null?void 0:f.shortUrl.replace(/https?:\/\//g,"")}_visits.csv`,y),[l,f==null?void 0:f.shortUrl]),v=M.useMemo(()=>s?{deleteVisits:()=>o(c),visitsDeletion:t}:void 0,[o,c,t,s]);return M.useEffect(()=>{i([c])},[c,i]),m.jsx(Sp,{getVisits:d,cancelGetVisits:a,visitsInfo:e,exportCsv:p,deletion:v,children:m.jsx(j6e,{shortUrl:f,loading:n.loading,shortUrlVisits:e})})},e=>e.shortCode?[Jn.shortUrlVisits(hC(e.shortCode))]:[]),A6e=$t(XU,["ReportExporter"]),k6e=({tagVisits:e,colorGenerator:t})=>{const{visits:n,tag:r}=e;return m.jsx(Op,{title:m.jsxs("span",{className:"d-flex align-items-center justify-content-center",children:[m.jsx("span",{className:"me-2",children:"Visits for"}),m.jsx(vb,{text:r,colorGenerator:t})]}),visits:n})},QU=Di(({getTagVisits:e,tagVisits:t,cancelGetTagVisits:n})=>{const{ColorGenerator:r,ReportExporter:i}=Rt(QU),{tag:o=""}=Mu(),a=M.useCallback((l,c)=>e({tag:o,params:l,options:c}),[e,o]),s=M.useCallback(l=>i.exportVisits(`tag_${o}_visits.csv`,l),[i,o]);return m.jsx(Sp,{getVisits:a,cancelGetVisits:n,visitsInfo:t,exportCsv:s,children:m.jsx(k6e,{tagVisits:t,colorGenerator:r})})},()=>[Jn.visits]),N6e=$t(QU,["ColorGenerator","ReportExporter"]),TC=({title:e,colors:t,getVisitsForComparison:n,visitsComparisonInfo:r,cancelGetVisitsComparison:i})=>{const{loading:o,visitsGroups:a}=r,s=nr("visits"),l=M.useMemo(()=>Object.keys(a).reduce((b,w,S)=>(b[w]=Object.assign(Ty(a[w]),{color:(t==null?void 0:t[w])??NU(S)}),b),{}),[t,a]),c=M.useMemo(()=>Object.values(a).every(b=>b.length===0),[a]),[{dateRange:f,visitsFilter:d},p]=RU(),[v,y]=M.useState(),g=M.useCallback(({startDate:b,endDate:w},S)=>{p({dateRange:{startDate:b??void 0,endDate:w??void 0}}),y(S)},[p]),x=M.useRef(f??(s==null?void 0:s.defaultInterval)??"last30Days"),_=M.useMemo(()=>({...d,excludeBots:d.excludeBots??(s==null?void 0:s.excludeBots)}),[d,s==null?void 0:s.excludeBots]);return M.useEffect(()=>{const b=f??mB(x.current);return n({params:{dateRange:b,filter:_}}),i},[i,f,n,_]),m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"mb-3",children:m.jsxs(gt,{bodyClassName:"d-flex",children:[m.jsx(mb,{}),m.jsx("h3",{className:"mb-0 flex-grow-1 text-center",children:e})]})}),m.jsx("div",{className:"col-lg-7 col-xl-6 offset-lg-5 offset-xl-6 mb-3",children:m.jsxs("div",{className:"d-md-flex",children:[m.jsx("div",{className:"flex-grow-1",children:m.jsx(OC,{disabled:o,defaultText:"All visits",dateRangeOrInterval:v??f??x.current,onDatesChange:g})}),m.jsx(IU,{disabled:o,className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:_,onChange:({orphanVisitsType:b,excludeBots:w})=>p({visitsFilter:{orphanVisitsType:b,excludeBots:w}})})]})}),m.jsx(DU,{info:r}),!o&&m.jsx(av,{showFallback:c,children:m.jsx(LU,{visitsGroups:l,onDateRangeChange:g})})]})},M6e=Di(({getDomainVisitsForComparison:e,domainVisitsComparison:t,cancelGetDomainVisitsComparison:n})=>{const r=bC("domains"),i=M.useCallback(o=>e({...o,domains:r}),[r,e]);return m.jsx(TC,{title:`Comparing "${r.join('", "')}"`,getVisitsForComparison:i,visitsComparisonInfo:t,cancelGetVisitsComparison:n})},()=>[Jn.visits]),L6e=({visitsLoaders:e,shouldCancel:t,progressChanged:n})=>{const r=Object.keys(e),i=Math.max(1,Math.round(4/r.length)),o=Object.fromEntries(r.map(l=>[l,0])),a=(l,c)=>{o[l]=c;const f=Object.values(o),d=f.reduce((p,v)=>p+v,0);n(d/f.length)},s=Object.entries(e).map(([l,c])=>[l,_B({visitsLoader:c,batchSize:i,shouldCancel:t,progressChanged:f=>a(l,f)})]);return async l=>{const c=await Promise.all(s.map(async([f,d])=>{const p=await d(l);return[f,p]}));return Object.fromEntries(c)}},jC=({typePrefix:e,createLoaders:t,shouldCancel:n})=>{const r=Xn(`${e}/progressChanged`),i=fn(e,async(o,{getState:a,dispatch:s})=>{const l=t(o),c=await L6e({visitsLoaders:l,shouldCancel:()=>n(a),progressChanged:f=>s(r(f))})(qO(o.params));return{...o,visitsGroups:c}});return Object.assign(i,{progressChanged:r})},AC=({name:e,asyncThunkCreator:t,initialState:n,filterCreatedVisitsForGroup:r})=>{const{pending:i,rejected:o,fulfilled:a,progressChanged:s}=t,{reducer:l,actions:c}=Qt({name:e,initialState:n,reducers:{cancelGetVisits:d=>({...d,cancelLoad:!0})},extraReducers:d=>{d.addCase(i,()=>({...n,loading:!0})),d.addCase(o,(p,{error:v})=>({...n,errorData:Br(v)??null})),d.addCase(a,(p,{payload:v})=>({...p,...v,loading:!1,progress:null,errorData:null})),d.addCase(s,(p,{payload:v})=>({...p,progress:v})),d.addCase(tf,(p,{payload:v})=>{const{visitsGroups:y,...g}=p,x=Object.keys(y).map(b=>{const w=r({...g,groupKey:b},v.createdVisits).map(({visit:S})=>S);return[b,[...w,...y[b]]]}),_=Object.fromEntries(x);return{...g,visitsGroups:_}})}}),{cancelGetVisits:f}=c;return{reducer:l,cancelGetVisits:f}},JU="shlink/domainVisitsComparison",R6e={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},$6e=e=>jC({typePrefix:`${JU}/getDomainVisitsForComparison`,createLoaders:({domains:t})=>{const n=e(),r=t.map(i=>[i,o=>n.getDomainVisits(i,o)]);return Object.fromEntries(r)},shouldCancel:t=>t().domainVisitsComparison.cancelLoad}),I6e=e=>AC({name:JU,initialState:R6e,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:n},r)=>yB(r,t,n==null?void 0:n.dateRange)}),e9="shlink/shortUrlVisitsComparison",D6e={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},F6e=e=>jC({typePrefix:`${e9}/getShortUrlVisitsForComparison`,createLoaders:({shortUrls:t})=>{const n=e(),r=t.map(i=>[pC(i),o=>n.getShortUrlVisits(i.shortCode,{...o,domain:i.domain})]);return Object.fromEntries(r)},shouldCancel:t=>t().shortUrlVisitsComparison.cancelLoad}),B6e=e=>AC({name:e9,initialState:D6e,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:n},r)=>gB(r,lB(t),n==null?void 0:n.dateRange)}),t9="shlink/tagVisitsComparison",U6e={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},z6e=e=>jC({typePrefix:`${t9}/getTagVisitsForComparison`,createLoaders:({tags:t})=>{const n=e(),r=t.map(i=>[i,o=>n.getTagVisits(i,o)]);return Object.fromEntries(r)},shouldCancel:t=>t().tagVisitsComparison.cancelLoad}),V6e=e=>AC({name:t9,initialState:U6e,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:n},r)=>bB(r,t,n==null?void 0:n.dateRange)}),W6e=Di(({getShortUrlVisitsForComparison:e,shortUrlVisitsComparison:t,cancelGetShortUrlVisitsComparison:n,shortUrlsDetails:r,getShortUrlsDetails:i})=>{const o=bC("short-urls"),a=M.useMemo(()=>o.map(lB),[o]),s=M.useCallback(f=>e({...f,shortUrls:a}),[e,a]),l=M.useMemo(()=>{var f;return[...((f=r.shortUrls)==null?void 0:f.values())??[]]},[r.shortUrls]),c=M.useMemo(()=>{const{visitsGroups:f,loading:d,...p}=t,v=l.reduce((y,g)=>(y[g.shortUrl]=f[pC(g)]??[],y),{});return{...p,visitsGroups:v,loading:d||r.loading}},[t,r.loading,l]);return M.useEffect(()=>{a.length>0&&i(a)},[i,a]),m.jsx(TC,{title:m.jsx("span",{"data-testid":"title",children:r.loading?"Loading...":`Comparing ${l.length} short URLs`}),getVisitsForComparison:s,visitsComparisonInfo:c,cancelGetVisitsComparison:n})},()=>[Jn.visits]),n9=Di(({getTagVisitsForComparison:e,tagVisitsComparison:t,cancelGetTagVisitsComparison:n})=>{const{ColorGenerator:r}=Rt(n9),i=bC("tags"),o=M.useCallback(l=>e({...l,tags:i}),[e,i]),{visitsGroups:a}=t,s=M.useMemo(()=>Object.keys(a).reduce((l,c)=>(l[c]=r.getColorForKey(c),l),{}),[r,a]);return m.jsx(TC,{title:m.jsxs(m.Fragment,{children:["Comparing ",i.map(l=>m.jsx(vb,{colorGenerator:r,text:l},l))]}),getVisitsForComparison:o,visitsComparisonInfo:t,cancelGetVisitsComparison:n,colors:s})},()=>[Jn.visits]),H6e=$t(n9,["ColorGenerator"]),G6e=(e,t)=>{const n=(r,i)=>t([...r,"mercureInfo"],[...i,"createNewVisits","loadMercureInfo"]);e.serviceFactory("MapModal",()=>$U),e.factory("ShortUrlVisits",A6e),e.decorator("ShortUrlVisits",t(["shortUrlVisits","shortUrlVisitsDeletion","shortUrlsDetails","mercureInfo"],["getShortUrlVisits","deleteShortUrlVisits","getShortUrlsDetails","cancelGetShortUrlVisits","createNewVisits","loadMercureInfo"])),e.factory("TagVisits",N6e),e.decorator("TagVisits",n(["tagVisits"],["getTagVisits","cancelGetTagVisits"])),e.factory("TagVisitsComparison",H6e),e.decorator("TagVisitsComparison",n(["tagVisitsComparison"],["getTagVisitsForComparison","cancelGetTagVisitsForComparison"])),e.serviceFactory("DomainVisitsComparison",()=>M6e),e.decorator("DomainVisitsComparison",n(["domainVisitsComparison"],["getDomainVisitsForComparison","cancelGetDomainVisitsForComparison"])),e.serviceFactory("ShortUrlVisitsComparison",()=>W6e),e.decorator("ShortUrlVisitsComparison",n(["shortUrlVisitsComparison","shortUrlsDetails"],["getShortUrlVisitsForComparison","cancelGetShortUrlVisitsForComparison","getShortUrlsDetails"])),e.factory("DomainVisits",a6e),e.decorator("DomainVisits",n(["domainVisits"],["getDomainVisits","cancelGetDomainVisits"])),e.factory("OrphanVisits",l6e),e.decorator("OrphanVisits",n(["orphanVisits","orphanVisitsDeletion"],["getOrphanVisits","cancelGetOrphanVisits","deleteOrphanVisits"])),e.factory("NonOrphanVisits",s6e),e.decorator("NonOrphanVisits",n(["nonOrphanVisits"],["getNonOrphanVisits","cancelGetNonOrphanVisits"])),e.serviceFactory("VisitsParser",()=>e6e),e.serviceFactory("getShortUrlVisits",_6e,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisits",r=>r.cancelGetVisits,"shortUrlVisitsReducerCreator"),e.serviceFactory("getShortUrlVisitsForComparison",F6e,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisitsForComparison",r=>r.cancelGetVisits,"shortUrlVisitsComparisonReducerCreator"),e.serviceFactory("deleteShortUrlVisits",w6e,"apiClientFactory"),e.serviceFactory("getTagVisits",P6e,"apiClientFactory"),e.serviceFactory("cancelGetTagVisits",r=>r.cancelGetVisits,"tagVisitsReducerCreator"),e.serviceFactory("getTagVisitsForComparison",z6e,"apiClientFactory"),e.serviceFactory("cancelGetTagVisitsForComparison",r=>r.cancelGetVisits,"tagVisitsComparisonReducerCreator"),e.serviceFactory("getDomainVisits",lLe,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisits",r=>r.cancelGetVisits,"domainVisitsReducerCreator"),e.serviceFactory("getDomainVisitsForComparison",$6e,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisitsForComparison",r=>r.cancelGetVisits,"domainVisitsComparisonReducerCreator"),e.serviceFactory("getOrphanVisits",m6e,"apiClientFactory"),e.serviceFactory("cancelGetOrphanVisits",r=>r.cancelGetVisits,"orphanVisitsReducerCreator"),e.serviceFactory("deleteOrphanVisits",g6e,"apiClientFactory"),e.serviceFactory("getNonOrphanVisits",u6e,"apiClientFactory"),e.serviceFactory("cancelGetNonOrphanVisits",r=>r.cancelGetVisits,"nonOrphanVisitsReducerCreator"),e.serviceFactory("createNewVisits",()=>tf),e.serviceFactory("loadVisitsOverview",C6e,"apiClientFactory"),e.serviceFactory("visitsOverviewReducerCreator",T6e,"loadVisitsOverview"),e.serviceFactory("visitsOverviewReducer",r=>r.reducer,"visitsOverviewReducerCreator"),e.serviceFactory("domainVisitsReducerCreator",cLe,"getDomainVisits"),e.serviceFactory("domainVisitsReducer",r=>r.reducer,"domainVisitsReducerCreator"),e.serviceFactory("nonOrphanVisitsReducerCreator",f6e,"getNonOrphanVisits"),e.serviceFactory("nonOrphanVisitsReducer",r=>r.reducer,"nonOrphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsReducerCreator",v6e,"getOrphanVisits","deleteOrphanVisits"),e.serviceFactory("orphanVisitsReducer",r=>r.reducer,"orphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsDeletionReducerCreator",y6e,"deleteOrphanVisits"),e.serviceFactory("orphanVisitsDeletionReducer",r=>r.reducer,"orphanVisitsDeletionReducerCreator"),e.serviceFactory("shortUrlVisitsReducerCreator",x6e,"getShortUrlVisits","deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsReducer",r=>r.reducer,"shortUrlVisitsReducerCreator"),e.serviceFactory("shortUrlVisitsDeletionReducerCreator",O6e,"deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsDeletionReducer",r=>r.reducer,"shortUrlVisitsDeletionReducerCreator"),e.serviceFactory("tagVisitsReducerCreator",E6e,"getTagVisits"),e.serviceFactory("tagVisitsReducer",r=>r.reducer,"tagVisitsReducerCreator"),e.serviceFactory("tagVisitsComparisonReducerCreator",V6e,"getTagVisitsForComparison"),e.serviceFactory("tagVisitsComparisonReducer",r=>r.reducer,"tagVisitsComparisonReducerCreator"),e.serviceFactory("domainVisitsComparisonReducerCreator",I6e,"getDomainVisitsForComparison"),e.serviceFactory("domainVisitsComparisonReducer",r=>r.reducer,"domainVisitsComparisonReducerCreator"),e.serviceFactory("shortUrlVisitsComparisonReducerCreator",B6e,"getShortUrlVisitsForComparison"),e.serviceFactory("shortUrlVisitsComparisonReducer",r=>r.reducer,"shortUrlVisitsComparisonReducerCreator")},zf=({children:e,to:t,className:n,...r})=>m.jsx(b6,{className:({isActive:i})=>Oe("aside-menu__item",n,{"aside-menu__item--selected":i}),to:t,...r,children:e}),q6e=({routePrefix:e,showOnMobile:t=!1})=>{const{pathname:n}=pr(),r=Oe("aside-menu",{"aside-menu--hidden":!t}),i=o=>`${e}${o}`;return m.jsx("aside",{className:r,children:m.jsxs("nav",{className:"nav flex-column aside-menu__nav",children:[m.jsxs(zf,{to:i("/overview"),children:[m.jsx(je,{fixedWidth:!0,icon:TK}),m.jsx("span",{className:"aside-menu__item-text",children:"Overview"})]}),m.jsxs(zf,{to:i("/list-short-urls/1"),className:Oe({"aside-menu__item--selected":n.match("/list-short-urls")!==null}),children:[m.jsx(je,{fixedWidth:!0,icon:L6}),m.jsx("span",{className:"aside-menu__item-text",children:"List short URLs"})]}),m.jsxs(zf,{to:i("/create-short-url"),children:[m.jsx(je,{fixedWidth:!0,icon:LK,flip:"horizontal"}),m.jsx("span",{className:"aside-menu__item-text",children:"Create short URL"})]}),m.jsxs(zf,{to:i("/manage-tags"),children:[m.jsx(je,{fixedWidth:!0,icon:R6}),m.jsx("span",{className:"aside-menu__item-text",children:"Manage tags"})]}),m.jsxs(zf,{to:i("/manage-domains"),children:[m.jsx(je,{fixedWidth:!0,icon:sK}),m.jsx("span",{className:"aside-menu__item-text",children:"Manage domains"})]})]})})},r9=({createNotFound:e})=>{const{TagsList:t,ShortUrlsList:n,CreateShortUrl:r,ShortUrlVisits:i,TagVisits:o,DomainVisits:a,OrphanVisits:s,NonOrphanVisits:l,Overview:c,EditShortUrl:f,ManageDomains:d,TagVisitsComparison:p,DomainVisitsComparison:v,ShortUrlVisitsComparison:y,ShortUrlRedirectRules:g}=Rt(r9),x=pr(),_=ds(),[b,w,S,P]=Lt();M.useEffect(()=>P(),[x,P]);const E=Oe("shlink-layout__burger-icon",{"shlink-layout__burger-icon--active":b}),T=hLe(S,P),j=Ko("shortUrlRedirectRules");return m.jsxs(m.Fragment,{children:[m.jsx(je,{icon:nK,className:E,onClick:w}),m.jsx("div",{...T,className:"shlink-layout__swipeable",children:m.jsxs("div",{className:"shlink-layout__swipeable-inner",children:[m.jsx(q6e,{routePrefix:_,showOnMobile:b}),m.jsx("div",{className:"shlink-layout__container",onPointerDown:()=>P(),children:m.jsx("div",{className:"container-xl",children:m.jsxs(Xy,{children:[m.jsx(ot,{index:!0,element:m.jsx(eP,{replace:!0,to:"overview"})}),m.jsx(ot,{path:"/overview",element:m.jsx(c,{})}),m.jsx(ot,{path:"/list-short-urls/:page",element:m.jsx(n,{})}),m.jsx(ot,{path:"/create-short-url",element:m.jsx(r,{})}),m.jsx(ot,{path:"/short-code/:shortCode/visits/*",element:m.jsx(i,{})}),m.jsx(ot,{path:"/short-code/:shortCode/edit",element:m.jsx(f,{})}),j&&m.jsx(ot,{path:"/short-code/:shortCode/redirect-rules",element:m.jsx(g,{})}),m.jsx(ot,{path:"/short-urls/compare-visits",element:m.jsx(y,{})}),m.jsx(ot,{path:"/tag/:tag/visits/*",element:m.jsx(o,{})}),m.jsx(ot,{path:"/tags/compare-visits",element:m.jsx(p,{})}),m.jsx(ot,{path:"/domain/:domain/visits/*",element:m.jsx(a,{})}),m.jsx(ot,{path:"/orphan-visits/*",element:m.jsx(s,{})}),m.jsx(ot,{path:"/non-orphan-visits/*",element:m.jsx(l,{})}),m.jsx(ot,{path:"/manage-tags",element:m.jsx(t,{})}),m.jsx(ot,{path:"/manage-domains",element:m.jsx(d,{})}),m.jsx(ot,{path:"/domains/compare-visits",element:m.jsx(v,{})}),e&&m.jsx(ot,{path:"*",element:e("/list-short-urls/1")})]})})})]})})]})},K6e=$t(r9,["TagsList","ShortUrlsList","CreateShortUrl","ShortUrlVisits","TagVisits","DomainVisits","OrphanVisits","NonOrphanVisits","Overview","EditShortUrl","ManageDomains","TagVisitsComparison","DomainVisitsComparison","ShortUrlVisitsComparison","ShortUrlRedirectRules"]),Y6e=!0,Z6e=e=>AD({devTools:!Y6e,reducer:UP({mercureInfo:e.mercureInfoReducer,shortUrlsList:e.shortUrlsListReducer,shortUrlCreation:e.shortUrlCreationReducer,shortUrlDeletion:e.shortUrlDeletionReducer,shortUrlEdition:e.shortUrlEditionReducer,shortUrlsDetails:e.shortUrlsDetailsReducer,shortUrlVisits:e.shortUrlVisitsReducer,shortUrlVisitsDeletion:e.shortUrlVisitsDeletionReducer,shortUrlVisitsComparison:e.shortUrlVisitsComparisonReducer,tagVisits:e.tagVisitsReducer,tagVisitsComparison:e.tagVisitsComparisonReducer,domainVisits:e.domainVisitsReducer,domainVisitsComparison:e.domainVisitsComparisonReducer,orphanVisits:e.orphanVisitsReducer,orphanVisitsDeletion:e.orphanVisitsDeletionReducer,nonOrphanVisits:e.nonOrphanVisitsReducer,tagsList:e.tagsListReducer,tagDelete:e.tagDeleteReducer,tagEdit:e.tagEditReducer,domainsList:e.domainsListReducer,visitsOverview:e.visitsOverviewReducer,shortUrlRedirectRules:e.shortUrlRedirectRulesReducer,shortUrlRedirectRulesSaving:e.setShortUrlRedirectRulesReducer}),middleware:t=>t({immutableCheck:!1,serializableCheck:!1})}),X6e=e=>{e.factory("Main",K6e),e.factory("store",Z6e)},Fi=new A6,{container:Q6e}=Fi,J6e=e=>t=>Object.fromEntries(e.map(n=>[n,t[n]])),eIe=(e,t)=>(...n)=>e[t](...n),tIe=(e,t)=>({...e,[t]:eIe(Q6e,t)}),nf=(e,t=[])=>a6(e?J6e(e):null,t.reduce(tIe,{}));X6e(Fi);$Re(Fi,nf);o$e(Fi,nf);G6e(Fi,nf);CLe(Fi);SLe(Fi,nf);DLe(Fi,nf);x$e(Fi);Z4e(Fi,nf);let R4;const nIe=e=>({serverVersion:t,apiClient:n,settings:r,routesPrefix:i="",createNotFound:o,tagColorsStorage:a})=>{const s=U4e(t),l=M.useRef(),[c,f]=M.useState(),d=wl(),p=M.useMemo(()=>d?M.Fragment:y6,[d]);return M.useEffect(()=>{R4=n,e.value("apiClientFactory",()=>R4),a&&e.value("TagColorsStorage",a);const{container:v}=e,{Main:y,store:g,loadMercureInfo:x,listTags:_,listDomains:b}=v;l.current=m.jsx(y,{createNotFound:o}),f(g),g.dispatch(x(r)),g.dispatch(_()),g.dispatch(b())},[n,o,r,a]),c?m.jsx(s6,{store:c,children:m.jsx(KD,{value:r??{},children:m.jsx(B4e,{value:s,children:m.jsx(UMe,{value:i,children:m.jsx(p,{children:l.current})})})})}):m.jsx(m.Fragment,{})},rIe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",iIe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",oIe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",aIe=()=>{delete QL.Icon.Default.prototype._getIconUrl,QL.Icon.Default.mergeOptions({iconRetinaUrl:iIe,iconUrl:rIe,shadowUrl:oIe})};aIe();const sIe=nIe(Fi);function jy(e){return t=>{const{resetSelectedServer:n}=t;return M.useEffect(()=>{n()},[n]),m.jsx(e,{...t})}}let lIe=class extends M.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){const{console:n=globalThis.console}=this.props;n.error(t)}render(){const{hasError:t}=this.state,{location:n=globalThis.location}=this.props;if(t)return m.jsx("div",{className:"home",children:m.jsxs(gt,{className:"p-4",children:[m.jsx("h1",{children:"Oops! This is awkward :S"}),m.jsx("p",{children:"It seems that something went wrong. Try refreshing the page or just click this button."}),m.jsx("br",{}),m.jsx(qe,{outline:!0,color:"primary",onClick:()=>n.reload(),children:"Take me back"})]})});const{children:r}=this.props;return r}};const cIe=({id:e,name:t})=>m.jsxs(lD,{tag:At,to:`/server/${e}`,className:"servers-list__server-item",children:[t,m.jsx(je,{icon:FK,className:"servers-list__server-item-icon"})]}),i9=({servers:e,children:t,embedded:n=!1})=>m.jsxs(m.Fragment,{children:[t&&m.jsx("div",{"data-testid":"title",className:"mb-0 fs-5 fw-normal lh-sm",children:t}),e.length>0&&m.jsx(aD,{"data-testid":"list",tag:"div",className:Oe("servers-list__list-group",{"servers-list__list-group--embedded":n}),children:e.map(({id:r,name:i})=>m.jsx(cIe,{id:r,name:i},r))})]}),o9=({color:e=nh,className:t})=>m.jsx("svg",{className:t,viewBox:"0 0 512 512",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:m.jsxs("g",{fill:e,children:[m.jsx("path",{d:" M 23.71 85.08 C 17.22 49.81 49.44 14.86 85.08 18.12 C 118.83 19.21 145.72 53.33 139.45 86.37 C 155.64 102.30 171.32 118.83 187.87 134.36 C 198.32 111.73 208.84 89.12 219.57 66.62 C 226.05 53.84 243.47 48.74 255.73 56.27 C 263.76 62.10 270.34 69.69 277.25 76.75 C 286.28 86.61 285.72 102.89 276.31 112.31 C 223.38 165.37 170.38 218.37 117.35 271.34 C 107.72 280.99 91.01 281.25 81.11 271.86 C 74.39 264.94 66.82 258.69 61.24 250.77 C 53.72 238.52 58.85 221.07 71.64 214.62 C 94.11 203.87 116.72 193.38 139.33 182.91 C 123.81 166.36 107.30 150.68 91.37 134.49 C 60.20 140.28 27.37 116.78 23.71 85.08 Z"}),m.jsx("path",{d:" M 205.21 201.23 C 225.32 181.36 260.88 181.11 281.14 200.86 C 299.25 218.75 317.37 236.65 335.10 254.93 C 356.73 278.01 352.01 318.70 326.03 336.56 C 320.07 330.47 313.73 324.65 308.12 318.28 C 323.86 309.39 328.76 286.18 316.63 272.39 C 301.73 256.95 286.30 242.03 271.24 226.75 C 264.49 219.65 256.80 212.00 246.37 211.52 C 224.65 208.64 205.52 233.36 214.49 253.58 C 221.09 266.81 234.22 275.12 243.62 286.24 C 240.43 295.96 238.09 306.13 238.29 316.46 C 225.55 304.29 213.16 291.73 200.89 279.09 C 180.97 257.57 183.10 220.45 205.21 201.23 Z"}),m.jsx("path",{d:" M 273.90 352.07 C 252.28 328.99 256.98 288.31 282.96 270.46 C 288.93 276.54 295.26 282.36 300.88 288.72 C 285.14 297.62 280.23 320.82 292.38 334.61 C 307.27 350.05 322.70 364.96 337.75 380.25 C 344.51 387.35 352.20 395.00 362.64 395.48 C 384.35 398.37 403.49 373.64 394.51 353.42 C 387.92 340.18 374.78 331.88 365.38 320.76 C 368.56 311.04 370.91 300.86 370.71 290.54 C 383.45 302.70 395.84 315.27 408.11 327.91 C 428.03 349.43 425.90 386.55 403.78 405.77 C 383.68 425.64 348.13 425.89 327.86 406.14 C 309.75 388.25 291.60 370.37 273.90 352.07 Z"}),m.jsx("path",{d:" M 422.11 403.83 C 431.96 394.07 441.60 384.06 451.66 374.51 C 460.90 383.74 471.89 392.70 474.89 406.11 C 480.16 429.97 484.08 454.13 488.76 478.12 C 490.00 483.41 484.47 488.29 479.35 486.63 C 454.66 481.52 429.55 478.12 405.14 471.84 C 393.17 467.97 385.20 457.75 376.55 449.27 C 386.39 439.49 396.13 429.60 406.06 419.91 C 416.37 433.45 435.74 414.00 422.11 403.83 Z"})]})}),uIe=({servers:e})=>{const t=po(),n=Object.values(e),r=n.length>0;return M.useEffect(()=>{const i=n.find(({autoConnect:o})=>o);i&&t(`/server/${i.id}`)},[n,t]),m.jsx("div",{className:"w-100",children:m.jsx(Dr,{className:"mx-auto",style:{maxWidth:"720px"},children:m.jsxs("div",{className:"d-flex flex-column flex-md-row",children:[m.jsx("div",{className:"p-4 d-none d-md-flex align-items-center",style:{width:"40%"},children:m.jsx("div",{className:"w-100",children:m.jsx(o9,{})})}),m.jsxs("div",{className:"home__servers-container flex-grow-1",children:[m.jsx("h1",{className:Oe("home__title p-4 text-center m-0",{"border-bottom":!r}),style:{borderColor:"var(--border-color) !important"},children:"Welcome!"}),m.jsx(i9,{embedded:!0,servers:n,children:!r&&m.jsxs("div",{className:"p-4 text-center d-flex flex-column gap-5",children:[m.jsx("p",{className:"mb-0",children:"This application will help you manage your Shlink servers."}),m.jsx("p",{className:"mb-0",children:m.jsxs(At,{to:"/server/create",className:"btn btn-outline-primary btn-lg me-2",children:[m.jsx(je,{icon:Zh})," ",m.jsx("span",{className:"ms-1",children:"Add a server"})]})}),m.jsx("p",{className:"mb-0",children:m.jsx(hr,{href:"https://shlink.io/documentation",children:m.jsxs("small",{children:[m.jsx("span",{className:"me-2",children:"Learn more about Shlink"}),m.jsx(je,{icon:bK})]})})})]})})]})]})})})},a9=()=>{const{ServersDropdown:e}=Ri(a9),[t,n,,r]=Lt(),i=pr(),{pathname:o}=i;M.useEffect(r,[i,r]);const a="/settings",s=Oe("main-header__toggle-icon",{"main-header__toggle-icon--opened":t});return m.jsxs(jI,{color:"primary",dark:!0,fixed:"top",className:"main-header",expand:"md",children:[m.jsxs(AI,{tag:At,to:"/",children:[m.jsx(o9,{className:"main-header__brand-logo",color:"white"})," Shlink"]}),m.jsx(kI,{onClick:n,children:m.jsx(je,{icon:IK,className:s})}),m.jsx(LP,{navbar:!0,isOpen:t,children:m.jsxs(SP,{navbar:!0,className:"ms-auto",children:[m.jsx(PP,{children:m.jsxs(EP,{tag:At,to:a,active:o.startsWith(a),children:[m.jsx(je,{icon:zK}),"  Settings"]})}),m.jsx(e,{})]})})]})},fIe=$i(a9,["ServersDropdown"]),dIe=({children:e})=>{const t=pr();return M.useEffect(()=>{scrollTo(0,0)},[t]),m.jsx(m.Fragment,{children:e})},s9=RD(e=>e,e=>{try{return u2(e,e,"=")}catch{return!1}}),l9=e=>s9(e)?`v${e}`:e,c9=(e,t="latest")=>s9(e)?e:t,hIe="%_VERSION_%",pIe=e=>l9(c9(e)),$4=({project:e,version:t})=>m.jsx(hr,{href:`https://github.com/shlinkio/${e}/releases/${t}`,className:"text-muted",children:m.jsx("b",{children:t})}),mIe=({selectedServer:e,clientVersion:t=hIe})=>{const n=pIe(t);return m.jsxs("small",{className:"text-muted",children:[oP(e)&&m.jsxs(m.Fragment,{children:["Server: ",m.jsx($4,{project:"shlink",version:e.printableVersion})," - "]}),"Client: ",m.jsx($4,{project:"shlink-web-client",version:n})]})},vIe=({selectedServer:e})=>m.jsx("div",{className:Oe("text-center",{"shlink-versions-container--with-sidebar":oP(e)}),children:m.jsx(mIe,{selectedServer:e})}),rf=({children:e,className:t})=>m.jsx("div",{className:Oe("no-menu-wrapper container-xl",t),children:e});function u9(e){const t=n=>{const{ServerError:r}=Ri(t),i=Mu(),{selectServer:o,selectedServer:a}=n;return M.useEffect(()=>{i.serverId&&o(i.serverId)},[i.serverId,o]),a?zq(a)?m.jsx(r,{}):m.jsx(e,{...n}):m.jsx(rf,{children:m.jsx(zo,{loading:!0})})};return t}const f9=u9(M.memo(({selectedServer:e,settings:t})=>{const{buildShlinkApiClient:n,TagColorsStorage:r,ShlinkWebComponent:i,ServerError:o}=Ri(f9);if(!oP(e))return m.jsx(o,{});const a=`/server/${e.id}`;return m.jsx(i,{serverVersion:e.version,apiClient:n(e),settings:t,routesPrefix:a,tagColorsStorage:r,createNotFound:s=>m.jsx(gD,{to:`${a}${s}`,children:"List short URLs"})})})),gIe=$i(f9,["buildShlinkApiClient","TagColorsStorage","ShlinkWebComponent","ServerError"]),yIe=(e,t)=>{e.constant("window",window),e.constant("console",console),e.constant("fetch",window.fetch.bind(window)),e.service("HttpClient",eoe,"fetch"),e.serviceFactory("ScrollToTop",()=>dIe),e.factory("MainHeader",fIe),e.serviceFactory("Home",()=>uIe),e.decorator("Home",jy),e.decorator("Home",t(["servers"],["resetSelectedServer"])),e.serviceFactory("ShlinkWebComponent",()=>sIe),e.factory("ShlinkWebComponentContainer",gIe),e.decorator("ShlinkWebComponentContainer",t(["selectedServer","settings"],["selectServer"])),e.serviceFactory("ShlinkVersionsContainer",()=>vIe),e.decorator("ShlinkVersionsContainer",t(["selectedServer"])),e.serviceFactory("ErrorHandler",()=>lIe)},d9=()=>{const e=po();return M.useCallback(()=>e(-1),[e])};function bIe(e){const t=new URL(e.url);return`${e.name} ${t.host}`.toLowerCase().replace(/[^a-zA-Z0-9-_.~]/g,"-")}function _Ie(e){const t={};return e.forEach(n=>{t[n.id]=n}),t}const xIe=(e,{url:t,apiKey:n})=>e.some(r=>r.url===t&&r.apiKey===n);function wIe(e,t){const n=Object.values(e),{duplicatedServers:r=[],newServers:i=[]}=LD(t,o=>xIe(n,o)?"duplicatedServers":"newServers");return{duplicatedServers:r,newServers:i}}function Ay(e,t){const n=new Set(Object.keys(e)),r=[];return t.forEach(i=>{const o=bIe(i);let a=o,s=1;for(;n.has(a);)a=`${o}-${s}`,s++;r.push({...i,id:a}),n.add(a)}),r}const h9=({isOpen:e,duplicatedServers:t,onDiscard:n,onSave:r})=>{const i=t.length>1;return m.jsxs(vr,{centered:!0,isOpen:e,children:[m.jsxs(mo,{children:["Duplicated server",i&&"s"]}),m.jsxs(Li,{children:[m.jsx("p",{children:i?"The next servers already exist:":"There is already a server with:"}),m.jsx("ul",{children:t.map(({url:o,apiKey:a},s)=>i?m.jsxs("li",{children:[m.jsx("b",{children:o})," - ",m.jsx("b",{children:a})]},s):m.jsxs(M.Fragment,{children:[m.jsxs("li",{children:["URL: ",m.jsx("b",{children:o})]}),m.jsxs("li",{children:["API key: ",m.jsx("b",{children:a})]})]},s))}),m.jsxs("span",{children:[i?"Do you want to ignore duplicated servers":"Do you want to save this server anyway","?"]})]}),m.jsxs(as,{children:[m.jsx(qe,{color:"link",onClick:n,children:i?"Ignore duplicates":"Discard"}),m.jsx(qe,{color:"primary",onClick:r,children:"Save anyway"})]})]})},OIe=e=>t=>{t.preventDefault(),e()},p9=({onSubmit:e,initialValues:t,children:n,title:r})=>{const[i,o]=M.useState((t==null?void 0:t.name)??""),[a,s]=M.useState((t==null?void 0:t.url)??""),[l,c]=M.useState((t==null?void 0:t.apiKey)??""),f=OIe(()=>e({name:i,url:a,apiKey:l}));return m.jsxs("form",{className:"server-form",name:"serverForm",onSubmit:f,children:[m.jsxs(gt,{className:"mb-3",title:r,children:[m.jsx(ev,{value:i,onChange:o,children:"Name"}),m.jsx(ev,{type:"url",value:a,onChange:s,children:"URL"}),m.jsx(ev,{value:l,onChange:c,children:"API key"})]}),m.jsx("div",{className:"text-end",children:n})]})},I4=4e3,D4=({type:e})=>m.jsx("div",{className:"mt-3",children:m.jsxs(Zn,{type:e,children:[e==="success"&&"Servers properly imported. You can now select one from the list :)",e==="error"&&"The servers could not be imported. Make sure the format is correct."]})}),m9=({servers:e,createServers:t})=>{const{ImportServersBtn:n,useTimeoutToggle:r}=Ri(m9),i=po(),o=d9(),a=!!Object.keys(e).length,[s,l]=r(!1,I4),[c,f]=r(!1,I4),[d,p]=Lt(),[v,y]=M.useState(),g=M.useCallback(_=>{const[b]=Ay(e,[_]);t([b]),i(`/server/${b.id}`)},[t,i,e]),x=M.useCallback(_=>{y(_),Object.values(e).some(({url:w,apiKey:S})=>_.url===w&&_.apiKey===S)?p():g(_)},[g,e,p]);return m.jsxs(rf,{children:[m.jsxs(p9,{title:m.jsx("h5",{className:"mb-0",children:"Add new server"}),onSubmit:x,children:[!a&&m.jsx(n,{tooltipPlacement:"top",onImport:l,onImportError:f}),a&&m.jsx(qe,{outline:!0,onClick:o,children:"Cancel"}),m.jsx(qe,{outline:!0,color:"primary",className:"ms-2",children:"Create server"})]}),s&&m.jsx(D4,{type:"success"}),c&&m.jsx(D4,{type:"error"}),m.jsx(h9,{isOpen:d,duplicatedServers:v?[v]:[],onDiscard:o,onSave:()=>v&&g(v)})]})},SIe=$i(m9,["ImportServersBtn","useTimeoutToggle"]),v9=({server:e,className:t,children:n,textClassName:r})=>{const{DeleteServerModal:i}=Ri(v9),[o,,a,s]=Lt();return m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:Oe(t,"p-0 bg-transparent border-0"),onClick:a,children:[!n&&m.jsx(je,{fixedWidth:!0,icon:aP}),m.jsx("span",{className:r,children:n??"Remove this server"})]}),m.jsx(i,{server:e,isOpen:o,toggle:s})]})},PIe=$i(v9,["DeleteServerModal"]),EIe=({server:e,toggle:t,isOpen:n,deleteServer:r,redirectHome:i=!0})=>{const o=po(),a=M.useRef(!1),s=()=>{a.current=!0,t()},l=()=>{a.current&&(r(e),i&&o("/"))};return m.jsxs(vr,{isOpen:n,toggle:t,centered:!0,onClosed:l,children:[m.jsx(mo,{toggle:t,className:"text-danger",children:"Remove server"}),m.jsxs(Li,{children:[m.jsxs("p",{children:["Are you sure you want to remove ",m.jsx("b",{children:e?e.name:""}),"?"]}),m.jsx("p",{children:m.jsx("i",{children:"No data will be deleted, only the access to this server will be removed from this device. You can create it again at any moment."})})]}),m.jsxs(as,{children:[m.jsx(qe,{color:"link",onClick:t,children:"Cancel"}),m.jsx(qe,{color:"danger",onClick:s,children:"Delete"})]})]})},CIe=u9(({editServer:e,selectedServer:t,selectServer:n})=>{const r=d9(),{reconnect:i}=$u();if(!cd(t))return null;const o=a=>{e(t.id,a),i==="true"&&n(t.id),r()};return m.jsx(rf,{children:m.jsxs(p9,{title:m.jsxs("h5",{className:"mb-0",children:['Edit "',t.name,'"']}),initialValues:t,onSubmit:o,children:[m.jsx(qe,{outline:!0,className:"me-2",onClick:r,children:"Cancel"}),m.jsx(qe,{outline:!0,color:"primary",children:"Save"})]})})}),TIe=$i(CIe,["ServerError"]),g9=({createServers:e,servers:t,children:n,onImport:r=()=>{},onImportError:i=()=>{},tooltipPlacement:o="bottom",className:a=""})=>{const{ServersImporter:s}=Ri(g9),l=Mi(),[c,f]=M.useState([]),[d,,p,v]=Lt(),y=M.useRef([]),g=M.useRef([]),x=M.useCallback(S=>{e(S),r()},[e,r]),_=M.useCallback(async({target:S})=>{var P;return s.importServersFromFile((P=S.files)==null?void 0:P[0]).then(E=>{const{duplicatedServers:T,newServers:j}=wIe(t,E);y.current=Ay(t,E),g.current=Ay(t,j),T.length===0?x(y.current):(f(T),p())}).then(()=>{S.value=null}).catch(i)},[x,i,t,s,p]),b=M.useCallback(()=>{x(y.current),v()},[x,v]),w=M.useCallback(()=>{x(g.current),v()},[x,v]);return m.jsxs(m.Fragment,{children:[m.jsxs(qe,{outline:!0,id:"importBtn",className:a,onClick:()=>{var S;return(S=l.current)==null?void 0:S.click()},children:[m.jsx(je,{icon:uK,fixedWidth:!0})," ",n??"Import from file"]}),m.jsxs(Fr,{placement:o,target:"importBtn",children:["You can create servers by importing a CSV file with ",m.jsx("b",{children:"name"}),", ",m.jsx("b",{children:"apiKey"})," and ",m.jsx("b",{children:"url"})," columns."]}),m.jsx("input",{type:"file",accept:".csv",className:"d-none","aria-hidden":!0,ref:l,onChange:_,"data-testid":"csv-file-input"}),m.jsx(h9,{isOpen:d,duplicatedServers:c,onDiscard:w,onSave:b})]})},jIe=$i(g9,["ServersImporter"]),y9=({servers:e,selectedServer:t})=>{const{DeleteServerButton:n}=Ri(y9);return m.jsx(rf,{children:m.jsxs("div",{className:"server-error__container flex-column",children:[m.jsxs(zo,{className:"w-100 mb-3 mb-md-5",type:"error",fullWidth:!0,children:[!cd(t)&&"Could not find this Shlink server.",cd(t)&&m.jsxs(m.Fragment,{children:[m.jsx("p",{children:"Oops! Could not connect to this Shlink server."}),"Make sure you have internet connection, and the server is properly configured and on-line."]})]}),m.jsx(i9,{servers:Object.values(e),children:m.jsxs("p",{className:"mb-md-3",children:["These are the Shlink servers currently configured. Choose one of them or ",m.jsx(At,{to:"/server/create",children:"add a new one"}),"."]})}),cd(t)&&m.jsx("div",{className:"container mt-3 mt-md-5",children:m.jsxs("p",{className:"fs-5 fw-normal lh-sm",children:["Alternatively, if you think you may have miss-configured this server, you can ",m.jsx(n,{server:t,className:"server-error__delete-btn",children:"remove it"})," or ",m.jsx(At,{to:`/server/${t.id}/edit?reconnect=true`,children:"edit it"}),"."]})})]})})},AIe=$i(y9,["DeleteServerButton"]),kIe=4e3,b9=({servers:e})=>{const{ServersExporter:t,ImportServersBtn:n,useTimeoutToggle:r,ManageServersRow:i}=Ri(b9),[o,a]=M.useState(""),s=M.useMemo(()=>Object.values(e),[e]),l=M.useMemo(()=>s.filter(({name:p,url:v})=>`${p} ${v}`.toLowerCase().match(o.toLowerCase())),[s,o]),c=s.some(({autoConnect:p})=>!!p),[f,d]=r(!1,kIe);return m.jsxs(rf,{className:"d-flex flex-column gap-3",children:[m.jsx(ip,{onChange:a}),m.jsxs("div",{className:"d-flex flex-column flex-md-row gap-2",children:[m.jsxs("div",{className:"d-flex gap-2",children:[m.jsx(n,{className:"flex-fill",onImportError:d,children:"Import servers"}),l.length>0&&m.jsxs(qe,{outline:!0,className:"flex-fill",onClick:async()=>t.exportServers(),children:[m.jsx(je,{icon:I6,fixedWidth:!0})," Export servers"]})]}),m.jsxs(qe,{outline:!0,color:"primary",className:"ms-md-auto",tag:At,to:"/server/create",children:[m.jsx(je,{icon:Zh,fixedWidth:!0})," Add a server"]})]}),m.jsx(gt,{children:m.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[m.jsx("thead",{className:"responsive-table__header",children:m.jsxs("tr",{children:[c&&m.jsx("th",{style:{width:"50px"},children:m.jsx("span",{className:"sr-only",children:"Auto-connect"})}),m.jsx("th",{children:"Name"}),m.jsx("th",{children:"Base URL"}),m.jsx("th",{children:m.jsx("span",{className:"sr-only",children:"Options"})})]})}),m.jsxs("tbody",{children:[!l.length&&m.jsx("tr",{className:"text-center",children:m.jsx("td",{colSpan:4,children:"No servers found."})}),l.map(p=>m.jsx(i,{server:p,hasAutoConnect:c},p.id))]})]})}),f&&m.jsx("div",{children:m.jsx(Zn,{type:"error",children:"The servers could not be imported. Make sure the format is correct."})})]})},NIe=$i(b9,["ServersExporter","ImportServersBtn","useTimeoutToggle","ManageServersRow"]),_9=({server:e,hasAutoConnect:t})=>{const{ManageServersRowDropdown:n}=Ri(_9);return m.jsxs("tr",{className:"responsive-table__row",children:[t&&m.jsx("td",{className:"responsive-table__cell","data-th":"Auto-connect",children:e.autoConnect&&m.jsxs(m.Fragment,{children:[m.jsx(je,{icon:qd,className:"text-primary",id:"autoConnectIcon"}),m.jsx(Fr,{target:"autoConnectIcon",placement:"right",children:"Auto-connect to this server"})]})}),m.jsx("th",{className:"responsive-table__cell","data-th":"Name",children:m.jsx(At,{to:`/server/${e.id}`,children:e.name})}),m.jsx("td",{className:"responsive-table__cell","data-th":"Base URL",children:e.url}),m.jsx("td",{className:"responsive-table__cell text-end",children:m.jsx(n,{server:e})})]})},MIe=$i(_9,["ManageServersRowDropdown"]),x9=({server:e,setAutoConnect:t})=>{const{DeleteServerModal:n}=Ri(x9),[r,,i,o]=Lt(),a=`/server/${e.id}`,{autoConnect:s}=e,l=s?lK:cse;return m.jsxs(l0,{minWidth:s?210:170,children:[m.jsxs(Ne,{tag:At,to:a,children:[m.jsx(je,{icon:aK,fixedWidth:!0})," Connect"]}),m.jsxs(Ne,{tag:At,to:`${a}/edit`,children:[m.jsx(je,{icon:sP,fixedWidth:!0})," Edit server"]}),m.jsxs(Ne,{onClick:()=>t(e,!s),children:[m.jsx(je,{icon:l,fixedWidth:!0})," ",s?"Do not a":"A","uto-connect"]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{className:"dropdown-item--danger",onClick:i,children:[m.jsx(je,{icon:aP,fixedWidth:!0})," Remove server"]}),m.jsx(n,{redirectHome:!1,server:e,isOpen:r,toggle:o})]})},LIe=$i(x9,["DeleteServerModal"]),w9=(e,t)=>ND(e,t,{serializeError:n=>n}),RIe={},{actions:$Ie,reducer:IIe}=Qt({name:"shlink/servers",initialState:RIe,reducers:{editServer:{prepare:(e,t)=>({payload:{serverId:e,serverData:t}}),reducer:(e,{payload:t})=>{const{serverId:n,serverData:r}=t;return e[n]?{...e,[n]:{...e[n],...r}}:e}},deleteServer:(e,{payload:t})=>(delete e[t.id],e),setAutoConnect:{prepare:({id:e},t)=>({payload:{serverId:e,autoConnect:t}}),reducer:(e,{payload:t})=>{const{serverId:n,autoConnect:r}=t;return e[n]?r?Object.fromEntries(Object.entries(e).map(([i,o])=>[i,{...o,autoConnect:i===n}])):{...e,[n]:{...e[n],autoConnect:r}}:e}},createServers:{prepare:e=>({payload:_Ie(e)}),reducer:(e,{payload:t})=>({...e,...t})}}}),{editServer:DIe,deleteServer:FIe,setAutoConnect:BIe,createServers:O9}=$Ie,UIe=IIe,zIe=e=>Ay({},Array.isArray(e)?e.filter(k6):[]),VIe=e=>w9("shlink/remoteServers/fetchServers",async(t,{dispatch:n})=>{const r=await e.jsonRequest(`${$v.homepage}/servers.json`),i=zIe(r);n(O9(i))}),kC="shlink/selectedServer",WIe="1.0.0",HIe="999.999.999",GIe="latest",qIe=e=>c9(e===GIe?HIe:e,WIe),KIe=RD(e=>`${e.id}_${e.url}_${e.apiKey}`,async(e,t)=>t().then(({version:n})=>({version:qIe(n),printableVersion:l9(n)}))),F4=null,NC=Xn(`${kC}/resetSelectedServer`),YIe=e=>w9(`${kC}/selectServer`,async(t,{dispatch:n,getState:r})=>{n(NC());const{servers:i}=r(),o=i[t];if(!o)return{serverNotFound:!0};try{const a=e(o),{version:s,printableVersion:l}=await KIe(o,()=>a.health());return{...o,version:s,printableVersion:l}}catch{return{...o,serverNotReachable:!0}}}),ZIe=e=>Qt({name:kC,initialState:F4,reducers:{},extraReducers:t=>{t.addCase(NC,()=>F4),t.addCase(e.fulfilled,(n,{payload:r})=>r)}}),XIe=({servers:e,selectedServer:t})=>{const n=Object.values(e),r=()=>n.length===0?m.jsxs(Ne,{tag:At,to:"/server/create",children:[m.jsx(je,{icon:Zh})," ",m.jsx("span",{className:"ms-1",children:"Add a server"})]}):m.jsxs(m.Fragment,{children:[n.map(({name:i,id:o})=>m.jsx(Ne,{tag:At,to:`/server/${o}`,active:Vq(t)===o,children:i},o)),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{tag:At,to:"/manage-servers",children:[m.jsx(je,{icon:nA})," ",m.jsx("span",{className:"ms-1",children:"Manage servers"})]})]});return m.jsxs(rp,{nav:!0,inNavbar:!0,children:[m.jsxs(Jo,{nav:!0,caret:!0,children:[m.jsx(je,{icon:nA})," ",m.jsx("span",{className:"ms-1",children:"Servers"})]}),m.jsx(os,{end:!0,style:{right:0},children:r()})]})},QIe=({document:e},t,n)=>{const r=e.createElement("a");r.setAttribute("href",t),r.setAttribute("download",n),r.style.visibility="hidden",e.body.appendChild(r),r.click(),e.body.removeChild(r)},JIe=(e,t,n)=>{const r=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(r);QIe(e,i,n)},eDe="shlink-servers.csv";class tDe{constructor(t,n,r){Fl(this,"exportServers",async()=>{const t=Object.values(this.storage.get("servers")??{}).map(Wq);try{const n=this.jsonToCsv(t);JIe(this.window,n,eDe)}catch(n){console.error(n)}});this.storage=t,this.window=n,this.jsonToCsv=r}}const nDe=e=>typeof e.url=="string"&&typeof e.apiKey=="string"&&typeof e.name=="string",rDe=e=>Array.isArray(e)&&e.every(nDe);class iDe{constructor(t){this.csvToJson=t}async importServersFromFile(t){if(!t)throw new Error("No file provided");const n=await t.text(),r=await this.csvToJson(n);if(!rDe(r))throw new Error("Provided file does not have the right format.");return r}}const oDe=(e,t)=>{e.factory("ManageServers",NIe),e.decorator("ManageServers",jy),e.decorator("ManageServers",t(["selectedServer","servers"],["resetSelectedServer"])),e.factory("ManageServersRow",MIe),e.factory("ManageServersRowDropdown",LIe),e.decorator("ManageServersRowDropdown",t(null,["setAutoConnect"])),e.factory("CreateServer",SIe),e.decorator("CreateServer",jy),e.decorator("CreateServer",t(["selectedServer","servers"],["createServers","resetSelectedServer"])),e.factory("EditServer",TIe),e.decorator("EditServer",t(["selectedServer"],["editServer","selectServer","resetSelectedServer"])),e.serviceFactory("ServersDropdown",()=>XIe),e.decorator("ServersDropdown",t(["servers","selectedServer"])),e.serviceFactory("DeleteServerModal",()=>EIe),e.decorator("DeleteServerModal",t(null,["deleteServer"])),e.factory("DeleteServerButton",PIe),e.factory("ImportServersBtn",jIe),e.decorator("ImportServersBtn",t(["servers"],["createServers"])),e.factory("ServerError",AIe),e.decorator("ServerError",t(["servers","selectedServer"])),e.service("ServersImporter",iDe,"csvToJson"),e.service("ServersExporter",tDe,"Storage","window","jsonToCsv"),e.serviceFactory("selectServer",YIe,"buildShlinkApiClient","loadMercureInfo"),e.serviceFactory("createServers",()=>O9),e.serviceFactory("deleteServer",()=>FIe),e.serviceFactory("editServer",()=>DIe),e.serviceFactory("setAutoConnect",()=>BIe),e.serviceFactory("fetchServers",VIe,"HttpClient"),e.serviceFactory("resetSelectedServer",()=>NC),e.serviceFactory("selectedServerReducerCreator",ZIe,"selectServer"),e.serviceFactory("selectedServerReducer",n=>n.reducer,"selectedServerReducerCreator")},S9={field:"dateCreated",dir:"DESC"},aDe={realTimeUpdates:{enabled:!0},shortUrlCreation:{validateUrls:!1},ui:{theme:FP()},visits:{defaultInterval:"last30Days"},shortUrlsList:{defaultOrdering:S9}},{reducer:sDe,actions:lDe}=Qt({name:"shlink/settings",initialState:aDe,reducers:{setSettings:(e,{payload:t})=>p0(e,t)}}),{setSettings:cDe}=lDe,uDe=sDe,fDe=({settings:e,setSettings:t})=>m.jsx(rf,{children:m.jsx(ase,{settings:e,updateSettings:t,defaultShortUrlsListOrdering:S9})}),dDe=(e,t)=>{e.serviceFactory("Settings",()=>fDe),e.decorator("Settings",jy),e.decorator("Settings",t(["settings"],["setSettings","resetSelectedServer"])),e.serviceFactory("setSettings",()=>cDe)};var hDe=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(r,i,o){n.o(r,i)||Object.defineProperty(r,i,{enumerable:!0,get:o})},n.r=function(r){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,i){if(1&i&&(r=n(r)),8&i||4&i&&typeof r=="object"&&r&&r.__esModule)return r;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:r}),2&i&&typeof r!="string")for(var a in r)n.d(o,a,(function(s){return r[s]}).bind(null,a));return o},n.n=function(r){var i=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(i,"a",i),i},n.o=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)},n.p="",n(n.s=32)}([function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(n=window)}e.exports=n},function(e,t,n){var r=n(6),i=Object.keys||function(y){var g=[];for(var x in y)g.push(x);return g};e.exports=d;var o=n(5);o.inherits=n(2);var a=n(23),s=n(14);o.inherits(d,a);for(var l=i(s.prototype),c=0;c{t&&(t.longTouch=!0,n.longTouchClass&&e.e.cancelable&&bl(t.draggedNodes.map(r=>r.el),n.longTouchClass),e.e.preventDefault())},n.longTouchTimeout||200))}function m4e(e){!Ge||!("touchedNode"in Ge)||S4e(e,Ge)}function v4e(e,t){t.longTouchClass&&Oy(e.draggedNodes.map(n=>n.el),t==null?void 0:t.longTouchClass),t.touchDraggingClass&&bl([e.touchedNode],t.touchDraggingClass),t.touchDropZoneClass&&bl(e.draggedNodes.map(n=>n.el),t.touchDropZoneClass)}function g4e(e){if(!e||!e.scrollParent)return;const{x:t,y:n,width:r,height:i}=e.scrollParent.getBoundingClientRect(),{x:o,y:a,scrollOutside:s}=e.lastParent.data.config.scrollBehavior;return{state:e,xThresh:o,yThresh:a,scrollOutside:s,scrollParent:e.scrollParent,x:t,y:n,width:r,height:i}}function y4e(e){const t=g4e(Ge);if(t)switch(e){case"down":return w4e(t.state,t);case"up":return x4e(t.state,t);case"right":return b4e(t.state,t);case"left":return _4e(t.state,t)}}function b4e(e,t){const n=t.scrollParent.clientWidth+t.x-e.coordinates.x;if(!(!t.scrollOutside&&n<0)&&n<(1-t.xThresh)*t.scrollParent.clientWidth&&!(t.scrollParent.scrollLeft+t.scrollParent.clientWidth>=t.scrollParent.scrollWidth))return e}function _4e(e,t){const n=t.scrollParent.clientWidth+t.x-e.coordinates.x;if(!(!t.scrollOutside&&n>t.scrollParent.clientWidth)&&n>t.xThresh*t.scrollParent.clientWidth&&t.scrollParent.scrollLeft!==0)return e}function x4e(e,t){const n=t.scrollParent.clientHeight+t.y-e.coordinates.y;if(!(!t.scrollOutside&&n>t.scrollParent.clientHeight)&&n>t.yThresh*t.scrollParent.clientHeight&&t.scrollParent.scrollTop!==0)return e}function w4e(e,t){const n=t.scrollParent.clientHeight+t.y-e.coordinates.y;if(!(!t.scrollOutside&&n<0)&&n<(1-t.yThresh)*t.scrollParent.clientHeight&&!(t.scrollParent.scrollTop+t.scrollParent.clientHeight>=t.scrollParent.scrollHeight))return e}function O4e(e,t){t.touchMoving=!0,t.touchedNode.style.display=t.touchedNodeDisplay||"";const{x:n,y:r}=Tl(e.e);t.coordinates.y=r,t.coordinates.x=n;const i=t.touchStartLeft??0,o=t.touchStartTop??0;t.touchedNode.style.left=`${n-i}px`,t.touchedNode.style.top=`${r-o}px`,v4e(t,e.targetData.parent.data.config)}function S4e(e,t){if(e.targetData.parent.data.config.longTouch&&!t.longTouch){clearTimeout(t.longTouchTimeout);return}e.e.cancelable&&e.e.preventDefault(),O4e(e,t),db();const n=HLe(e);if(!n)return;const r={e:e.e,targetData:n};"node"in n?n.node.el.dispatchEvent(new CustomEvent("touchOverNode",{detail:r})):n.parent.el.dispatchEvent(new CustomEvent("touchOverParent",{detail:r}))}function db(){for(const e of Object.keys(f4)){const[t,n]=f4[e];zB(e,t,n)}}function zB(e,t,n){const r=y4e(e);r&&(r.scrollParent.scrollBy(t,n),setTimeout(()=>{zB(e,t,n)},"touchedNode"in r?10:100))}function P4e(e){if(!Ge)return;const{x:t,y:n}=Tl(e.e);Ge.coordinates.y=n,Ge.coordinates.x=t,db(),j4e(e,Ge)}function E4e(e){if(!Ge)return;const{x:t,y:n}=Tl(e.e);Ge.coordinates.y=n,Ge.coordinates.x=t,db(),hb(e,Ge)}function C4e(e){Ge&&hb(e.detail,Ge)}function T4e(e,t){if(e.targetData.parent.el===t.lastParent.el)return!1;const n=e.targetData.parent.data.config;if(n.dropZone===!1)return!1;const r=t.initialParent.data.config;return n.accepts?n.accepts(e.targetData.parent,t.initialParent,t.lastParent,t):!(!n.group||n.group!==r.group)}function j4e(e,t){var n;e.e.preventDefault(),e.e.stopPropagation(),e.targetData.parent.el===((n=t.lastParent)==null?void 0:n.el)?VB(e,t):hb(e,t)}function A4e(e,t,n,r){var i;if(t.remapJustFinished)return t.remapJustFinished=!1,t.lastTargetValue=e.targetData.node.data.value,!1;if(t.lastTargetValue===e.targetData.node.data.value||t.draggedNodes.map(p=>p.el).includes(e.targetData.node.el)||t.preventEnter||t.swappedNodeValue===e.targetData.node.data.value||e.targetData.parent.el!==((i=t.lastParent)==null?void 0:i.el)||e.targetData.parent.data.config.sortable===!1)return!1;const o=e.targetData.node.el.getBoundingClientRect(),a=t.draggedNode.el.getBoundingClientRect(),s=o.y-a.y,l=o.x-a.x;let c;const f=t.draggedNode.data.index>e.targetData.node.data.index?[e.targetData.node.data.index,t.draggedNode.data.index]:[t.draggedNode.data.index,e.targetData.node.data.index];t.targetIndex=e.targetData.node.data.index,t.affectedNodes=e.targetData.parent.data.enabledNodes.filter(p=>f[0]<=p.data.index&&p.data.index<=f[1]&&p.el!==t.draggedNode.el),Math.abs(s)>Math.abs(l)?c=s>0?"above":"below":c=l>0?"left":"right";const d=t.lastParent.data.config.threshold;switch(c){case"left":if(n>o.x+o.width*d.horizontal)return t.incomingDirection="left",!0;break;case"right":if(no.y+o.height*d.vertical)return t.incomingDirection="above",!0;break;case"below":if(r{const r=t(n.currentTarget);if(r)return e({e:n,targetData:r})}}function k4e(e,t){const n=$B(e),r=ZO(e.lastParent.el,e.lastParent.data).filter(s=>!n.includes(s)),i=ZO(t.targetData.parent.el,t.targetData.parent.data),o=e.initialParent.el===t.targetData.parent.el&&t.targetData.parent.data.config.sortable===!1;let a;"node"in t.targetData?(o?a=e.initialIndex:t.targetData.parent.data.config.sortable===!1?a=t.targetData.parent.data.enabledNodes.length:a=t.targetData.node.data.index,i.splice(a,0,...n)):(a=o?e.initialIndex:t.targetData.parent.data.enabledNodes.length,i.splice(a,0,...n)),XO(e.lastParent.el,e.lastParent.data,r),XO(t.targetData.parent.el,t.targetData.parent.data,i)}function hb(e,t){T4e(e,t)&&(e.targetData.parent.data.config.performTransfer(t,e),t.lastParent=e.targetData.parent)}function N4e(e){function t(n){const r=Ei.get(n);if(r)return{parent:{el:n,data:r}}}return n=>{const r=t(n.currentTarget);if(r)return e({e:n,targetData:r})}}function M4e(e){if(e instanceof HTMLElement)return e;if("current"in e&&e.current instanceof HTMLElement)return e.current;console.warn("Invalid parent element",e)}function L4e(e,t){const n=M4e(e);n&&t(n)}var Sy=new WeakMap;function R4e(e){const t=Sy.get(e);return t?t[0]:(console.warn("No values found for parent element"),[])}function $4e(e,t){const n=Sy.get(t);n&&n[1](e),Sy.set(t,[e,n[1]])}function I4e(e,t){return n=>{Sy.set(n,t),YLe({parent:n,getValues:R4e,setValues:$4e,config:e})}}function d4(e){AB&&(Array.isArray(e)||(e=[e]),e.forEach(t=>{const{parent:n,state:r,...i}=t;L4e(n,I4e(i,r))}))}function D4e(e,t={}){const n=M.useRef(null),[r,i]=M.useState(e);function o(a={}){d4({parent:n,state:[r,i],...a})}return M.useEffect(()=>{d4({parent:n,state:[r,i],...t})},[r]),M.useEffect(()=>()=>{n.current&&IB(n.current)},[]),[n,r,i,o]}const pb=()=>{const e=po(),t=ds(),n=$u(),r=M.useMemo(()=>{const{orderBy:o,tags:a,excludeBots:s,excludeMaxVisitsReached:l,excludePastValidUntil:c,...f}=n,d=o?Yre(o):void 0,p=(a==null?void 0:a.split(","))??[];return{...f,orderBy:d,tags:p,excludeBots:s!==void 0?s==="true":void 0,excludeMaxVisitsReached:l!==void 0?l==="true":void 0,excludePastValidUntil:c!==void 0?c==="true":void 0}},[n]),i=M.useCallback(o=>{const a={...r,...o},{orderBy:s,tags:l,excludeBots:c,excludeMaxVisitsReached:f,excludePastValidUntil:d,...p}=a,v={...p,orderBy:s&&Kre(s),tags:l.length>0?l.join(","):void 0,excludeBots:h_(c),excludeMaxVisitsReached:h_(f),excludePastValidUntil:h_(d)},y=s0(v),g=y?`?${y}`:"";e(`${t}/list-short-urls/1${g}`)},[r,e,t]);return[r,i]},wC=()=>{const{domain:e}=$u(),{shortCode:t=""}=Mu();return M.useMemo(()=>({shortCode:hC(t),domain:e}),[e,t])},mb=()=>{const e=mLe();return m.jsx(qe,{color:"link",size:"lg",className:"p-0 me-3",onClick:e,"aria-label":"Go back",children:m.jsx(je,{icon:gK})})},F4e=(e,{maxVersion:t,minVersion:n})=>{const r=!n||u2(e,n,">=");return(!t||u2(e,t,"<="))&&r},WB={excludeBotsOnShortUrls:{minVersion:"3.4.0"},filterDisabledUrls:{minVersion:"3.4.0"},deviceLongUrls:{minVersion:"3.5.0",maxVersion:"3.*.*"},shortUrlVisitsDeletion:{minVersion:"3.6.0"},orphanVisitsDeletion:{minVersion:"3.7.0"},shortUrlRedirectRules:{minVersion:"4.0.0"},urlValidation:{maxVersion:"3.*.*"},ipRedirectCondition:{minVersion:"4.2.*"}};Object.freeze(WB);const ua=(e,t)=>t==="latest"||F4e(t,WB[e]),HB=e=>({excludeBotsOnShortUrls:ua("excludeBotsOnShortUrls",e),filterDisabledUrls:ua("filterDisabledUrls",e),deviceLongUrls:ua("deviceLongUrls",e),shortUrlVisitsDeletion:ua("shortUrlVisitsDeletion",e),orphanVisitsDeletion:ua("orphanVisitsDeletion",e),shortUrlRedirectRules:ua("shortUrlRedirectRules",e),urlValidation:ua("urlValidation",e),ipRedirectCondition:ua("ipRedirectCondition",e)}),GB=M.createContext(HB("0.0.0")),B4e=GB.Provider,U4e=e=>M.useMemo(()=>HB(e),[e]),Ko=e=>M.useContext(GB)[e],z4e={android:"Android",ios:"iOS",desktop:"Desktop"},V4e=({deviceType:e,onDeviceTypeChange:t})=>{const n=M.useId();return m.jsxs("div",{children:[m.jsx("label",{htmlFor:n,children:"Device type:"}),m.jsxs("select",{id:n,className:"form-select",value:e,onChange:r=>t(r.target.value),required:!0,children:[!e&&m.jsx("option",{value:"",children:"- Select type -"}),Object.entries(z4e).map(([r,i])=>m.jsx("option",{value:r,children:i},r))]})]})},qB=({value:e,onValueChange:t,label:n,placeholder:r})=>{const i=M.useId();return m.jsxs("div",{children:[m.jsxs("label",{htmlFor:i,children:[n,":"]}),m.jsx(An,{id:i,value:e??"",onChange:o=>t(o.target.value),placeholder:r,required:!0})]})},W4e=({language:e,onLanguageChange:t})=>m.jsx(qB,{value:e,onValueChange:t,label:"Language",placeholder:"en-US / en"}),H4e=({name:e,value:t,onNameChange:n,onValueChange:r})=>{const i=M.useId(),o=M.useId();return m.jsxs(m.Fragment,{children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:i,children:"Param name:"}),m.jsx(An,{id:i,value:e??"",onChange:a=>n(a.target.value),placeholder:"hello",required:!0})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:o,children:"Param value:"}),m.jsx(An,{id:o,value:t??"",onChange:a=>r(a.target.value),placeholder:"world",required:!0})]})]})},G4e=({ipAddress:e,onIpAddressChange:t})=>m.jsx(qB,{value:e,onValueChange:t,label:"IP address",placeholder:"192.168.1.10"}),q4e=({condition:e,onConditionChange:t,onDelete:n})=>{const r=M.useId(),i=M.useCallback(c=>t({type:c,matchValue:"",matchKey:null}),[t]),o=M.useCallback(c=>t({...e,matchValue:c}),[e,t]),a=M.useCallback(c=>t({...e,matchKey:c}),[e,t]),s=Ko("ipRedirectCondition"),l=M.useMemo(()=>{const c={device:"Device type",language:"Language","query-param":"Query param"};return s?{...c,"ip-address":"IP address"}:c},[s]);return m.jsxs("div",{className:"redirect-rule-modal__condition rounded p-3 h-100 d-flex flex-column gap-2 position-relative",children:[m.jsxs("div",{children:[m.jsx(qe,{outline:!0,size:"sm",type:"button","aria-label":"Remove condition",onClick:n,className:"position-absolute rounded-circle redirect-rule-modal__remove-condition-button",children:m.jsx(je,{icon:D6,className:"redirect-rule-modal__remove-condition-button-icon"})}),m.jsx("label",{htmlFor:r,children:"Type:"}),m.jsx("select",{id:r,className:"form-select flex-grow-1",value:e.type,onChange:c=>i(c.target.value),children:Object.entries(l).map(([c,f])=>m.jsx("option",{value:c,children:f},c))})]}),e.type==="device"&&m.jsx(V4e,{deviceType:e.matchValue,onDeviceTypeChange:o}),e.type==="language"&&m.jsx(W4e,{language:e.matchValue,onLanguageChange:o}),e.type==="query-param"&&m.jsx(H4e,{value:e.matchValue,name:e.matchKey??"",onNameChange:a,onValueChange:o}),e.type==="ip-address"&&m.jsx(G4e,{ipAddress:e.matchValue,onIpAddressChange:o})]})},KB=({isOpen:e,toggle:t,onSave:n,initialData:r})=>{const[i,o]=M.useState(r??{longUrl:"",conditions:[]}),a=M.useCallback(v=>{v.preventDefault(),v.stopPropagation(),i&&n(i),t()},[n,i,t]),s=M.useCallback(()=>o(({longUrl:v,conditions:y})=>({longUrl:v,conditions:[...y,{type:"device",matchValue:"",matchKey:null}]})),[]),l=M.useCallback((v,y)=>o(({longUrl:g,conditions:x})=>{const _=[...x];return _[v]=y,{longUrl:g,conditions:_}}),[]),c=M.useCallback(v=>o(({longUrl:y,conditions:g})=>{const x=[...g];return x.splice(v,1),{longUrl:y,conditions:x}}),[]),f=Mi(),d=M.useCallback(()=>{var v;return(v=f==null?void 0:f.current)==null?void 0:v.focus()},[f]),p=M.useCallback(()=>o(r??{longUrl:"",conditions:[]}),[r]);return m.jsx(vr,{size:"xl",isOpen:e,toggle:t,centered:!0,onOpened:d,onClosed:p,children:m.jsxs("form",{onSubmit:a,children:[m.jsx(mo,{toggle:t,className:"sticky-top redirect-rule-modal__header",children:"Redirect rule"}),m.jsxs(Li,{children:[m.jsx("label",{htmlFor:"longUrl",className:"fw-bold",children:"Long URL:"}),m.jsx(An,{id:"longUrl",type:"url",placeholder:"https://www.example.com",value:i.longUrl,onChange:v=>o(y=>({...y,longUrl:v.target.value})),required:!0,innerRef:f}),m.jsx("hr",{}),m.jsxs("div",{className:"d-flex justify-content-between",children:[m.jsx("b",{children:"Conditions:"}),m.jsx(qe,{outline:!0,size:"sm",type:"button","aria-label":"Add condition",onClick:s,children:m.jsx(je,{icon:Zh})})]}),i.conditions.length===0&&m.jsx("div",{className:"text-center",children:m.jsx("i",{children:"Add conditions..."})}),i.conditions.length>0&&m.jsx(Pr,{className:"redirect-rule-modal__conditions-row",children:i.conditions.map((v,y)=>m.jsx("div",{className:"col-lg-6 col-xl-4 mt-4",children:m.jsx(q4e,{condition:v,onConditionChange:g=>l(y,g),onDelete:()=>c(y)})},`${y}_${v.type}`))})]}),m.jsxs(as,{className:"sticky-bottom redirect-rule-modal__footer",children:[m.jsx(qe,{type:"button",color:"link",onClick:t,children:"Cancel"}),m.jsx(qe,{color:"primary",disabled:i.conditions.length===0,children:"Confirm"})]})]})})},K4e=({priority:e,isLast:t,redirectRule:n,onDelete:r,onMoveUp:i,onMoveDown:o,onUpdate:a})=>{const[s,l]=Lt();return m.jsxs(gt,{children:[m.jsxs("div",{className:"d-flex align-content-center gap-3",children:[m.jsx("div",{className:"d-flex flex-column my-auto drag-n-drop-handler d-none d-md-block",style:{cursor:"grab"},children:m.jsx(je,{icon:OK})}),m.jsxs("div",{className:"d-flex flex-column my-auto",children:[m.jsx(qe,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} up`,disabled:e===1,onClick:i,className:"rounded-0 rounded-top",style:{marginBottom:"-1px"},children:m.jsx(je,{icon:DK})}),m.jsx(qe,{outline:!0,color:"secondary",size:"sm","aria-label":`Move rule with priority ${e} down`,disabled:t,onClick:o,className:"rounded-0 rounded-bottom",children:m.jsx(je,{icon:MK})})]}),m.jsxs("div",{className:"flex-grow-1",children:[m.jsxs("div",{className:"mb-2",children:[m.jsx("b",{children:"Long URL:"})," ",m.jsx(hr,{href:n.longUrl,"data-testid":"rule-long-url"})]}),m.jsxs("div",{className:"d-flex flex-column flex-lg-row gap-2",children:[m.jsx("b",{children:"Conditions:"}),n.conditions.map((c,f)=>m.jsxs("div",{className:"badge bg-secondary",children:[c.type==="device"&&m.jsxs(m.Fragment,{children:["Device is ",c.matchValue]}),c.type==="language"&&m.jsxs(m.Fragment,{children:[c.matchValue," language is accepted"]}),c.type==="query-param"&&m.jsxs(m.Fragment,{children:["Query string contains ",c.matchKey,"=",c.matchValue]}),c.type==="ip-address"&&m.jsxs(m.Fragment,{children:["IP address matches ",c.matchValue]})]},`${c.type}_${f}`))]})]}),m.jsxs("div",{className:"d-flex flex-column flex-sm-row gap-1 my-auto",children:[m.jsx(qe,{outline:!0,color:"secondary",size:"sm","aria-label":`Edit rule with priority ${e}`,onClick:l,children:m.jsx(je,{icon:N6})}),m.jsx(qe,{outline:!0,color:"danger",size:"sm","aria-label":`Delete rule with priority ${e}`,onClick:r,children:m.jsx(je,{icon:Yq})})]})]}),m.jsx(KB,{onSave:a,isOpen:s,toggle:l,initialData:n})]})},Y4e=({shortUrlRedirectRules:e,getShortUrlRedirectRules:t,getShortUrlsDetails:n,shortUrlsDetails:r,setShortUrlRedirectRules:i,shortUrlRedirectRulesSaving:o,resetSetRules:a})=>{const s=wC(),{shortUrls:l}=r,c=s&&(l==null?void 0:l.get(s)),[f,d,p]=D4e([],{dragHandle:".drag-n-drop-handler",dropZoneClass:"opacity-25"}),{saving:v,saved:y,errorData:g}=o,[x,_]=Lt(),b=M.useCallback(F=>p((k=[])=>[...k,F]),[p]),w=M.useCallback(F=>p((k=[])=>{const I=[...k];return I.splice(F,1),I}),[p]),S=M.useCallback((F,k)=>p((I=[])=>{const D=[...I];return D[F]=k,D}),[p]),P=M.useCallback((F,k)=>p((I=[])=>{if(!I[k])return I;const D=[...I],K=D[k];return D[k]=D[F],D[F]=K,D}),[p]),E=M.useCallback(F=>P(F,F-1),[P]),T=M.useCallback(F=>P(F,F+1),[P]),j=M.useCallback(F=>{F.preventDefault(),d&&i({shortUrl:s,data:{redirectRules:d}})},[s,d,i]);return M.useEffect(()=>(t(s),n([s]),a),[t,n,s,a]),M.useEffect(()=>{e.redirectRules&&p(e.redirectRules)},[p,e.redirectRules]),m.jsxs("div",{className:"d-flex flex-column gap-3",children:[m.jsx("header",{children:m.jsxs(Dr,{body:!0,children:[m.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[m.jsx(mb,{}),m.jsxs("div",{className:"text-center flex-grow-1",children:[r.loading&&m.jsx(m.Fragment,{children:"Loading..."}),!r.loading&&m.jsxs("small",{children:["Redirect rules for ",m.jsx(hr,{href:(c==null?void 0:c.shortUrl)??""})]})]})]}),m.jsx("hr",{}),m.jsxs("div",{children:[m.jsx("p",{className:"mb-2",children:"Configure dynamic conditions that will be checked at runtime."}),"If no conditions match, visitors will be redirected to: ",m.jsx(hr,{href:e.defaultLongUrl??""})]})]})}),m.jsx("div",{children:m.jsxs(qe,{outline:!0,color:"primary",onClick:_,children:[m.jsx(je,{icon:Zh,className:"me-1"})," Add rule"]})}),m.jsxs("form",{onSubmit:j,children:[e.loading&&m.jsx(zo,{loading:!0}),d.length===0&&!e.loading&&m.jsx(gt,{className:"text-center",children:m.jsx("i",{children:"This short URL has no dynamic redirect rules"})}),m.jsx("div",{className:"d-flex flex-column gap-2",ref:f,children:d.map((F,k)=>m.jsx(K4e,{redirectRule:F,priority:k+1,isLast:k===d.length-1,onDelete:()=>w(k),onMoveUp:()=>E(k),onMoveDown:()=>T(k),onUpdate:I=>S(k,I)},`${F.longUrl}_${k}`))}),m.jsx("div",{className:"text-center mt-3",children:m.jsx(qe,{outline:!0,color:"primary",className:"btn-sm-block",disabled:v,"data-testid":"save-button",children:v?"Saving...":"Save rules"})})]}),g&&m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:g,fallbackMessage:"An error occurred while saving short URL redirect rules :("})}),y&&m.jsx(Zn,{type:"success",children:"Redirect rules properly saved."}),m.jsx(KB,{isOpen:x,toggle:_,onSave:b})]})},Z4e=(e,t)=>{e.serviceFactory("ShortUrlRedirectRules",()=>Y4e),e.decorator("ShortUrlRedirectRules",t(["shortUrlRedirectRules","shortUrlsDetails","shortUrlRedirectRulesSaving"],["getShortUrlRedirectRules","getShortUrlsDetails","setShortUrlRedirectRules","resetSetRules"])),e.serviceFactory("getShortUrlRedirectRules",zLe,"apiClientFactory"),e.serviceFactory("setShortUrlRedirectRules",FLe,"apiClientFactory"),e.serviceFactory("resetSetRules",n=>n.resetSetRules,"setShortUrlRedirectRulesReducerCreator"),e.serviceFactory("shortUrlRedirectRulesReducerCreator",VLe,"getShortUrlRedirectRules"),e.serviceFactory("shortUrlRedirectRulesReducer",n=>n.reducer,"shortUrlRedirectRulesReducerCreator"),e.serviceFactory("setShortUrlRedirectRulesReducerCreator",BLe,"setShortUrlRedirectRules"),e.serviceFactory("setShortUrlRedirectRulesReducer",n=>n.reducer,"setShortUrlRedirectRulesReducerCreator")},X4e=e=>({longUrl:"",tags:[],customSlug:"",title:void 0,shortCodeLength:void 0,domain:"",validSince:void 0,validUntil:void 0,maxVisits:void 0,findIfExists:!1,validateUrl:(e==null?void 0:e.validateUrls)??!1,forwardQuery:(e==null?void 0:e.forwardQuery)??!0}),YB=({createShortUrl:e,shortUrlCreation:t,resetCreateShortUrl:n,basicMode:r=!1})=>{const{ShortUrlForm:i,CreateShortUrlResult:o}=Rt(YB),a=nr("shortUrlCreation"),s=M.useMemo(()=>X4e(a),[a]);return m.jsxs(m.Fragment,{children:[m.jsx(i,{initialState:s,saving:t.saving,basicMode:r,onSave:async l=>(n(),e(l))}),m.jsx(o,{creation:t,resetCreateShortUrl:n,canBeClosed:r})]})},Q4e=$t(YB,["ShortUrlForm","CreateShortUrlResult"]),ZB=({shortUrlsDetails:e,getShortUrlsDetails:t,shortUrlEdition:n,editShortUrl:r})=>{const{ShortUrlForm:i}=Rt(ZB),o=wC(),{loading:a,error:s,errorData:l,shortUrls:c}=e,f=o&&(c==null?void 0:c.get(o)),{saving:d,saved:p,error:v,errorData:y}=n,g=nr("shortUrlCreation"),x=M.useMemo(()=>WMe(f,g),[f,g]);return M.useEffect(()=>{o&&t([o])},[t,o]),a?m.jsx(zo,{loading:!0}):s?m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:l,fallbackMessage:"An error occurred while loading short URL detail :("})}):m.jsxs(m.Fragment,{children:[m.jsx("header",{className:"mb-3",children:m.jsx(Dr,{body:!0,children:m.jsxs("h2",{className:"d-sm-flex justify-content-between align-items-center mb-0",children:[m.jsx(mb,{}),m.jsx("div",{className:"text-center flex-grow-1",children:m.jsxs("small",{children:["Edit ",m.jsx(hr,{href:(f==null?void 0:f.shortUrl)??""})]})})]})})}),m.jsx(i,{initialState:x,saving:d,onSave:async _=>{f&&r({...f,data:_})}}),p&&v&&m.jsx(Zn,{type:"error",className:"mt-3",children:m.jsx(ho,{errorData:y,fallbackMessage:"An error occurred while updating short URL :("})}),p&&!v&&m.jsx(Zn,{type:"success",className:"mt-3",children:"Short URL properly edited."})]})},J4e=$t(ZB,["ShortUrlForm"]),XB=({text:e,onCopy:t},n=navigator)=>{var r;return(r=n.clipboard)==null?void 0:r.writeText(e).then(()=>t==null?void 0:t(e,!0)).catch(()=>t==null?void 0:t(e,!1))},QB=({creation:e,resetCreateShortUrl:t,canBeClosed:n=!1})=>{const{useTimeoutToggle:r}=Rt(QB),[i,o]=r(),{error:a,saved:s}=e;if(M.useEffect(()=>{t()},[t]),a)return m.jsxs(Zn,{type:"error",className:"mt-3",children:[n&&m.jsx(je,{"data-testid":"error-close-button",icon:_x,className:"float-end pointer",onClick:t}),m.jsx(ho,{errorData:e.errorData,fallbackMessage:"An error occurred while creating the URL :("})]});if(!s)return null;const{shortUrl:l}=e.result;return m.jsxs(Zn,{type:"success",className:"mt-3",children:[n&&m.jsx(je,{"data-testid":"success-close-button",icon:_x,className:"float-end pointer",onClick:t}),m.jsxs("span",{children:[m.jsx("b",{children:"Great!"})," The short URL is ",m.jsx("b",{children:l})]}),m.jsxs("button",{className:"btn btn-light btn-sm create-short-url-result__copy-btn",id:"copyBtn",type:"button",onClick:()=>XB({text:l,onCopy:o}),children:[m.jsx(je,{icon:YD})," Copy ",m.jsxs("span",{className:"sr-only",children:[l," to clipboard"]})]}),m.jsx(o0,{placement:"left",isOpen:i,target:"copyBtn",children:"Copied!"})]})},eRe=$t(QB,["useTimeoutToggle"]),v_="delete",tRe=({shortUrl:e,toggle:t,isOpen:n,shortUrlDeletion:r,resetDeleteShortUrl:i,deleteShortUrl:o,shortUrlDeleted:a})=>{const[s,l]=M.useState("");M.useEffect(()=>i,[i]);const{loading:c,error:f,deleted:d,errorData:p}=r,v=M.useCallback(()=>{i(),t()},[i,t]),y=M.useCallback(g=>(g.preventDefault(),o(e).then(x=>!cC(x)&&t())),[o,e,t]);return m.jsx(vr,{isOpen:n,toggle:v,centered:!0,onClosed:()=>d&&a(e),children:m.jsxs("form",{onSubmit:y,children:[m.jsx(mo,{toggle:v,children:m.jsx("span",{className:"text-danger",children:"Delete short URL"})}),m.jsxs(Li,{children:[m.jsxs("p",{children:[m.jsx("b",{className:"text-danger",children:"Caution!"})," You are about to delete a short URL."]}),m.jsx("p",{children:"This action cannot be undone. Once you have deleted it, all the visits stats will be lost."}),m.jsxs("p",{children:["Write ",m.jsx("b",{children:v_})," to confirm deletion."]}),m.jsx("input",{type:"text",className:"form-control",placeholder:`Insert ${v_}`,value:s,onChange:g=>l(g.target.value)}),f&&m.jsx(Zn,{type:FMe(p)?"warning":"error",small:!0,className:"mt-2",children:m.jsx(ho,{errorData:p,fallbackMessage:"Something went wrong while deleting the URL :("})})]}),m.jsxs(as,{children:[m.jsx("button",{type:"button",className:"btn btn-link",onClick:v,children:"Cancel"}),m.jsx("button",{type:"submit",className:"btn btn-danger",disabled:s!==v_||c,children:c?"Deleting...":"Delete"})]})]})})},JB=({amount:e=0,loading:t=!1,...n})=>m.jsxs(qe,{...n,outline:!0,color:"primary",disabled:t,children:[m.jsx(je,{icon:eK})," ",t?"Exporting...":m.jsxs(m.Fragment,{children:["Export (",qt(e),")"]})]}),h4=20,eU=({amount:e=0})=>{const{apiClientFactory:t,ReportExporter:n}=Rt(eU),[{tags:r,search:i,startDate:o,endDate:a,orderBy:s,tagsMode:l}]=pb(),[c,,f,d]=Lt(),p=M.useCallback(async()=>{const v=e/h4,y=async(x=1)=>{const{data:_}=await t().listShortUrls({page:`${x}`,tags:r,searchTerm:i,startDate:o,endDate:a,orderBy:s,tagsMode:l,itemsPerPage:h4});return x>=v?_:_.concat(await y(x+1))};f();const g=await y();n.exportShortUrls(g.map(x=>{var _;const{hostname:b,pathname:w}=new URL(x.shortUrl),S=w.substring(1);return{createdAt:x.dateCreated,domain:b,shortCode:S,shortUrl:x.shortUrl,longUrl:x.longUrl,title:x.title??"",tags:x.tags.join("|"),visits:((_=x==null?void 0:x.visitsSummary)==null?void 0:_.total)??x.visitsCount??0}})),d()},[e,t,a,s,n,i,o,f,d,r,l]);return m.jsx(JB,{loading:c,className:"btn-md-block",amount:e,onClick:p})},nRe=$t(eU,["apiClientFactory","ReportExporter"]),tU=({text:e,onCopy:t,copyToClipboard:n=XB})=>m.jsx(yl,{className:"ms-2 p-0","aria-label":`Copy ${e} to clipboard`,onClick:()=>n({text:e,onCopy:t}),children:m.jsx(je,{icon:YD,className:"fs-5"})}),rRe=(e,t)=>{const n=`${e}/qr-code`,r=s0({...t});return`${n}${r?`?${r}`:""}`},p4=({name:e,value:t,step:n,min:r,max:i,onChange:o,className:a,initial:s=r})=>{const l=M.useId();return m.jsxs(cl,{className:a,children:[t===void 0&&m.jsxs(qe,{outline:!0,color:"link",className:"text-start fst-italic w-100",style:{color:"var(--input-text-color)",borderColor:"var(--border-color)"},onClick:()=>o(s),children:["Customize ",e]}),t!==void 0&&m.jsxs("div",{className:"d-flex gap-3",children:[m.jsxs("div",{className:"d-flex flex-column flex-grow-1",children:[m.jsxs("label",{htmlFor:l,className:"text-capitalize",children:[e,": ",t,"px"]}),m.jsx("input",{id:l,type:"range",className:"form-control-range",value:t,step:n,min:r,max:i,onChange:c=>o(Number(c.target.value))})]}),m.jsx(qe,{"aria-label":`Default ${e}`,title:`Default ${e}`,outline:!0,color:"link",onClick:()=>o(void 0),style:{color:"var(--input-text-color)",borderColor:"var(--border-color)"},children:m.jsx(je,{icon:$6})})]})]})},iRe=({errorCorrection:e,onChange:t})=>m.jsxs(ea,{text:e?`Error correction (${e})`:m.jsx("i",{children:"Default error correction"}),children:[m.jsx(Ne,{active:!e,onClick:()=>t(void 0),children:"Default"}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{active:e==="L",onClick:()=>t("L"),children:[m.jsx("b",{children:"L"}),"ow"]}),m.jsxs(Ne,{active:e==="M",onClick:()=>t("M"),children:[m.jsx("b",{children:"M"}),"edium"]}),m.jsxs(Ne,{active:e==="Q",onClick:()=>t("Q"),children:[m.jsx("b",{children:"Q"}),"uartile"]}),m.jsxs(Ne,{active:e==="H",onClick:()=>t("H"),children:[m.jsx("b",{children:"H"}),"igh"]})]}),oRe=({format:e,onChange:t})=>m.jsxs(ea,{text:e?`Format (${e})`:m.jsx("i",{children:"Default format"}),children:[m.jsx(Ne,{active:!e,onClick:()=>t(void 0),children:"Default"}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{active:e==="png",onClick:()=>t("png"),children:"PNG"}),m.jsx(Ne,{active:e==="svg",onClick:()=>t("svg"),children:"SVG"})]}),nU=({shortUrl:{shortUrl:e,shortCode:t},toggle:n,isOpen:r})=>{const{ImageDownloader:i}=Rt(nU),[o,a]=M.useState(),[s,l]=M.useState(),[c,f]=M.useState(),[d,p]=M.useState(),v=M.useMemo(()=>rRe(e,{size:o,format:c,margin:s,errorCorrection:d}),[e,o,c,s,d]),[y,g]=M.useState(),x=M.useCallback(_=>{const b=_.target,{naturalWidth:w}=b;w<500?g(void 0):g(w<800?"lg":"xl")},[]);return m.jsxs(vr,{isOpen:r,toggle:n,centered:!0,size:y,children:[m.jsxs(mo,{toggle:n,children:["QR code for ",m.jsx(hr,{href:e,children:e})]}),m.jsxs(Li,{children:[m.jsxs(Pr,{children:[m.jsx(p4,{className:"col-sm-6",name:"size",value:o,step:10,min:50,max:1e3,initial:300,onChange:a}),m.jsx(p4,{className:"col-sm-6",name:"margin",value:s,step:1,min:0,max:100,onChange:l}),m.jsx(cl,{className:"d-grid col-sm-6",children:m.jsx(oRe,{format:c,onChange:f})}),m.jsx(cl,{className:"col-sm-6",children:m.jsx(iRe,{errorCorrection:d,onChange:p})})]}),m.jsxs("div",{className:"text-center",children:[m.jsxs("div",{className:"mb-3",children:[m.jsx(hr,{href:v}),m.jsx(tU,{text:v})]}),m.jsx("img",{src:v,alt:"QR code",className:"shadow-lg",style:{maxWidth:"100%"},onLoad:x}),m.jsx("div",{className:"mt-3",children:m.jsxs(qe,{block:!0,color:"primary",onClick:()=>{i.saveImage(v,`${t}-qr-code.${c}`).catch(()=>{})},children:["Download ",m.jsx(je,{icon:I6,className:"ms-1"})]})})]})]})]})},aRe=$t(nU,["ImageDownloader"]),Py=({date:e,format:t=cB,relative:n=!1})=>{const r=mC(e)?e:Ka(e);return m.jsx("time",{dateTime:`${bae(r)}000`,children:n?`${gae(Xa(),r)} ago`:pg(r,t)})},sRe=e=>{const{meta:t,visitsCount:n,visitsSummary:r}=e,{maxVisits:i,validSince:o,validUntil:a}=t,s=(r==null?void 0:r.total)??n??0;return i&&s>=i?{icon:GK,className:"text-danger",description:m.jsxs(m.Fragment,{children:["This short URL cannot be currently visited because it has reached the maximum amount of ",m.jsx("b",{children:i})," visit",i>1?"s":"","."]})}:a&&mg(Er(a),Xa())?{icon:rA,className:"text-danger",description:m.jsxs(m.Fragment,{children:["This short URL cannot be visited since ",m.jsx("b",{className:"indivisible",children:zh(Er(a))}),"."]})}:o&&mg(Xa(),Er(o))?{icon:rA,className:"text-warning",description:m.jsxs(m.Fragment,{children:["This short URL will start working on ",m.jsx("b",{className:"indivisible",children:zh(Er(o))}),"."]})}:{icon:qd,className:"text-primary",description:"This short URL can be visited normally."}},lRe=({shortUrl:e})=>{const t=Mi(),{icon:n,className:r,description:i}=sRe(e);return m.jsxs(m.Fragment,{children:[m.jsx("span",{style:{cursor:i?"help":void 0},ref:t,children:m.jsx(je,{icon:n,className:r})}),m.jsx(Fr,{target:t,placement:"bottom",children:i})]})},cRe=(e,{shortCode:t,domain:n},r)=>{const i=n?`?domain=${n}`:"";return`${e}/short-code/${sB(t)}/${r}${i}`},ov=({shortUrl:e,suffix:t,asLink:n,children:r,...i})=>{const o=ds();return!n||!e?m.jsx("span",{...i,children:r}):m.jsx(At,{to:cRe(o,e,t),...i,children:r})},rU=({visitsCount:e,shortUrl:t,active:n=!1,asLink:r=!1})=>{const i=Mi(),{maxVisits:o,validSince:a,validUntil:s}=(t==null?void 0:t.meta)??{},l=!!o||!!a||!!s,c=m.jsx(ov,{shortUrl:t,suffix:"visits",asLink:r,children:m.jsx("strong",{className:Oe("short-url-visits-count__amount",{"short-url-visits-count__amount--big":n}),children:qt(e)})});return l?m.jsxs(m.Fragment,{children:[m.jsxs("span",{className:"indivisible",children:[c,m.jsxs("small",{className:"short-urls-visits-count__max-visits-control",ref:i,children:[o&&m.jsxs(m.Fragment,{children:[" / ",qt(o)]}),m.jsx("sup",{className:"ms-1",children:m.jsx(je,{icon:cP})})]})]}),m.jsx(Fr,{target:i,placement:"bottom",children:m.jsxs("ul",{className:"list-unstyled mb-0",children:[o&&m.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept more than ",m.jsx("b",{children:qt(o)})," visit",o===1?"":"s","."]}),a&&m.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits before ",m.jsx("b",{className:"indivisible",children:zh(Er(a))}),"."]}),s&&m.jsxs("li",{className:"short-url-visits-count__tooltip-list-item",children:["This short URL will not accept visits after ",m.jsx("b",{className:"indivisible",children:zh(Er(s))}),"."]})]})})]}):c},uRe=e=>!!e.onClose,fRe=e=>!!e.onClick,vb=e=>{const{text:t,children:n,className:r,colorGenerator:i}=e,o=fRe(e),a=o?yl:"span",s=M.useMemo(()=>i.stylesForKey(t),[t,i]);return m.jsxs(a,{className:Oe("badge tag fw-bold",r,{pointer:o}),style:s,onClick:o?e.onClick:void 0,children:[n??t,uRe(e)&&m.jsx(yl,{"aria-label":`Remove ${t}`,className:"bg-transparent ms-1 opacity-100 p-0 fw-bold tag__close",onClick:e.onClose,children:"×"})]})},dRe=({tags:e,onTagClick:t,colorGenerator:n})=>e.length===0?m.jsx("i",{className:"indivisible",children:m.jsx("small",{children:"No tags"})}):m.jsx(m.Fragment,{children:e.map(r=>m.jsx(vb,{text:r,colorGenerator:n,onClick:()=>t==null?void 0:t(r)},r))}),iU=({shortUrl:e,onTagClick:t})=>{var n,r,i,o;const{ShortUrlsRowMenu:a,ColorGenerator:s,useTimeoutToggle:l}=Rt(iU),[c,f]=l(),[d,p]=l(!1,500),v=M.useRef(!0),[{excludeBots:y}]=pb(),g=nr("visits"),x=y??(g==null?void 0:g.excludeBots);return M.useEffect(()=>{v.current||p(),v.current=!1},[(n=e.visitsSummary)==null?void 0:n.total,(r=e.visitsSummary)==null?void 0:r.nonBots,e.visitsCount,p]),m.jsxs("tr",{className:"responsive-table__row",children:[m.jsx("td",{className:"indivisible short-urls-row__cell responsive-table__cell","data-th":"Created at",children:m.jsx(Py,{date:e.dateCreated})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Short URL",children:m.jsxs("span",{className:"position-relative short-urls-row__cell--indivisible",children:[m.jsx("span",{className:"short-urls-row__short-url-wrapper",children:m.jsx(hr,{href:e.shortUrl})}),m.jsx(tU,{text:e.shortUrl,onCopy:f}),m.jsx("span",{role:"status",className:"badge bg-warning text-black short-urls-row__copy-hint",hidden:!c,children:"Copied short URL!"})]})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell short-urls-row__cell--break","data-th":`${e.title?"Title":"Long URL"}`,children:m.jsx(hr,{href:e.longUrl,children:e.title??e.longUrl})}),e.title&&m.jsx("td",{className:"short-urls-row__cell responsive-table__cell short-urls-row__cell--break d-lg-none","data-th":"Long URL",children:m.jsx(hr,{href:e.longUrl})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Tags",children:m.jsx(dRe,{tags:e.tags,colorGenerator:s,onTagClick:t})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-lg-end","data-th":"Visits",children:m.jsx(rU,{visitsCount:(x?(i=e.visitsSummary)==null?void 0:i.nonBots:(o=e.visitsSummary)==null?void 0:o.total)??e.visitsCount??0,shortUrl:e,active:d,asLink:!0})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell","data-th":"Status",children:m.jsx(lRe,{shortUrl:e})}),m.jsx("td",{className:"responsive-table__cell short-urls-row__cell text-end",children:m.jsx(a,{shortUrl:e})})]})},hRe=$t(iU,["ShortUrlsRowMenu","ColorGenerator","useTimeoutToggle"]),oU=({shortUrl:e,deleteShortUrl:t,shortUrlDeleted:n})=>{const{DeleteShortUrlModal:r,QrCodeModal:i}=Rt(oU),[o,,a,s]=Lt(),[l,,c,f]=Lt(),d=cb(),p=Ko("shortUrlRedirectRules"),{confirmDeletions:v=!0}=nr("shortUrlsList",{}),y=M.useCallback(async()=>{const g=await t(e);cC(g)||n(e)},[t,e,n]);return m.jsxs(l0,{minWidth:p?220:190,children:[m.jsxs(Ne,{tag:ov,shortUrl:e,suffix:"visits",asLink:!0,children:[m.jsx(je,{icon:lP,fixedWidth:!0})," Visit stats"]}),d&&m.jsxs(m.Fragment,{children:[m.jsxs(Ne,{disabled:!d.canAddItemWithName(e.shortUrl),onClick:()=>d.addItemToCompare({name:e.shortUrl,query:pC(e)}),children:[m.jsx(je,{icon:Jy,fixedWidth:!0})," Compare visits"]}),m.jsx(Ne,{divider:!0,tag:"hr"})]}),m.jsxs(Ne,{tag:ov,shortUrl:e,suffix:"edit",asLink:!0,children:[m.jsx(je,{icon:sP,fixedWidth:!0})," Edit short URL"]}),p&&m.jsxs(Ne,{tag:ov,shortUrl:e,suffix:"redirect-rules",asLink:!0,children:[m.jsx(je,{icon:KK,fixedWidth:!0})," Manage redirect rules"]}),m.jsxs(Ne,{onClick:a,children:[m.jsx(je,{icon:VK,fixedWidth:!0})," QR code"]}),m.jsx(i,{shortUrl:e,isOpen:o,toggle:s}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{className:"dropdown-item--danger",onClick:v?c:y,children:[m.jsx(je,{icon:aP,fixedWidth:!0})," Delete short URL"]}),m.jsx(r,{shortUrl:e,deleteShortUrl:t,shortUrlDeleted:n,isOpen:l,toggle:f})]})},pRe=$t(oU,["DeleteShortUrlModal","QrCodeModal"]),aU="shlink/shortUrlCreation",m4={saving:!1,saved:!1,error:!1},mRe=e=>fn(`${aU}/createShortUrl`,t=>e().createShortUrl(t)),vRe=e=>{const{reducer:t,actions:n}=Qt({name:aU,initialState:m4,reducers:{resetCreateShortUrl:()=>m4},extraReducers:i=>{i.addCase(e.pending,()=>({saving:!0,saved:!1,error:!1})),i.addCase(e.rejected,(o,{error:a})=>({saving:!1,saved:!1,error:!0,errorData:Br(a)})),i.addCase(e.fulfilled,(o,{payload:a})=>({result:a,saving:!1,saved:!0,error:!1}))}}),{resetCreateShortUrl:r}=n;return{reducer:t,resetCreateShortUrl:r}},sU="shlink/shortUrlEdition",gRe={saving:!1,saved:!1,error:!1},yRe=e=>fn(`${sU}/editShortUrl`,({shortCode:t,domain:n,data:r})=>e().updateShortUrl(t,n,r)),bRe=e=>Qt({name:sU,initialState:gRe,reducers:{},extraReducers:t=>{t.addCase(e.pending,n=>({...n,saving:!0,error:!1,saved:!1})),t.addCase(e.rejected,(n,{error:r})=>({...n,saving:!1,error:!0,saved:!1,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>({shortUrl:r,saving:!1,error:!1,saved:!0}))}}),v4="shlink/shortUrlsDetails",g4={loading:!1,error:!1},_Re=e=>{const t=fn(`${v4}/getShortUrlsDetails`,async(r,{getState:i})=>{const{shortUrlsList:o}=i(),a=await Promise.all(r.map(async s=>{var l;const{shortCode:c,domain:f}=s,d=(l=o==null?void 0:o.shortUrls)==null?void 0:l.data.find(p=>Ed(p,c,f));return[s,d??await e().getShortUrl(c,f)]}));return new Map(a)}),{reducer:n}=Qt({name:v4,initialState:g4,reducers:{},extraReducers:r=>{r.addCase(t.pending,()=>({loading:!0,error:!1})),r.addCase(t.rejected,(i,{error:o})=>({loading:!1,error:!0,errorData:Br(o)})),r.addCase(t.fulfilled,(i,{payload:o})=>({...g4,shortUrls:o}))}});return{reducer:n,getShortUrlsDetails:t}},xRe=({domains:e,value:t,onChange:n})=>{const[r,,i,o]=Lt(),a=!t,s=M.useCallback(()=>{n(""),o()},[n,o]),l=M.useCallback(()=>{n(""),i()},[n,i]);return r?m.jsxs(a0,{children:[m.jsx(An,{value:t??"",placeholder:"Domain",onChange:c=>n(c.target.value)}),m.jsx(qe,{id:"backToDropdown",outline:!0,type:"button",className:"domains-dropdown__back-btn","aria-label":"Back to domains list",onClick:s,children:m.jsx(je,{icon:wK})}),m.jsx(Fr,{target:"backToDropdown",placement:"left",trigger:"hover",children:"Existing domains"})]}):m.jsxs(ea,{text:a?"Domain":`Domain: ${t}`,className:a?"domains-dropdown__toggle-btn":"domains-dropdown__toggle-btn--active",children:[e.map(({domain:c,isDefault:f})=>m.jsxs(Ne,{active:(t===c||f)&&a,onClick:()=>n(c),className:"d-flex justify-content-between align-items-center",children:[c,f&&m.jsx("span",{className:"text-muted",children:"default"})]},c)),m.jsx(Ne,{divider:!0}),m.jsx(Ne,{onClick:l,children:m.jsx("i",{children:"New domain"})})]})},g_=({icon:e,className:t,...n})=>{const r=Mi();return m.jsxs("div",{className:"icon-input-container",children:[m.jsx(An,{className:Oe("icon-input-container__input",t),innerRef:r,...n}),m.jsx(je,{icon:e,fixedWidth:!0,className:"icon-input-container__icon",onClick:()=>{var i;return(i=r.current)==null?void 0:i.focus()}})]})},wRe=({minDate:e,maxDate:t,value:n,onChange:r,withTime:i=!1,...o})=>{const a=M.useCallback(({target:l})=>{if(!l.value){r==null||r(null);return}r==null||r(Er(l.value))},[r]),s=M.useMemo(()=>i?zh:Ta,[i]);return m.jsx(An,{...o,type:i?"datetime-local":"date",value:s(n)??"",max:s(t)??void 0,min:s(e)??void 0,onChange:a})},Ey=({label:e,id:t,...n})=>{const r=M.useId();return m.jsxs(m.Fragment,{children:[m.jsxs("label",{htmlFor:t??r,className:"mb-1",children:[e,":"]}),m.jsx(wRe,{id:t??r,...n})]})},y_=({children:e,infoTooltip:t,checked:n,onChange:r})=>m.jsxs("p",{children:[m.jsx(dD,{inline:!0,checked:n,className:t?"me-2":"",onChange:r,children:e}),t&&m.jsx(iv,{placement:"right",children:t})]}),ORe=({isOpen:e,toggle:t})=>m.jsxs(vr,{isOpen:e,toggle:t,centered:!0,size:"lg",children:[m.jsx(mo,{toggle:t,children:"Info"}),m.jsxs(Li,{children:[m.jsxs("p",{children:["When the ",m.jsx("b",{children:m.jsx("i",{children:'"Use existing URL if found"'})})," checkbox is checked, the server will return an existing short URL if it matches provided params."]}),m.jsx("p",{children:"These are the checks performed by Shlink in order to determine if an existing short URL should be returned:"}),m.jsxs("ul",{children:[m.jsx("li",{children:"When only the long URL is provided: The most recent match will be returned, or a new short URL will be created if none is found."}),m.jsxs("li",{children:["When long URL and custom slug and/or domain are provided: Same as in previous case, but it will try to match the short URL using both the long URL and the slug, the long URL and the domain, or the three of them.",m.jsx("br",{}),"If the slug is being used by another long URL, an error will be returned."]}),m.jsx("li",{children:"When other params are provided: Same as in previous cases, but it will try to match existing short URLs with all provided data. If any of them does not match, a new short URL will be created"})]})]})]}),SRe=()=>{const[e,t]=Lt();return m.jsxs(m.Fragment,{children:[m.jsx(yl,{className:"p-0",title:"What does this mean?",onClick:t,children:m.jsx(je,{icon:cP})}),m.jsx(ORe,{isOpen:e,toggle:t})]})},Nm=e=>typeof e=="string"?Ka(e):e,PRe=e=>"shortCodeLength"in e&&"customSlug"in e&&"domain"in e,lU=({basicMode:e=!1,saving:t,onSave:n,initialState:r,tagsList:i,domainsList:o})=>{var a,s,l;const{TagsSelector:c}=Rt(lU),[f,d]=M.useState(r),p=PRe(f),v=Ko("deviceLongUrls"),y=Ko("urlValidation"),g=y||p,x=M.useCallback(()=>d(r),[r]),_=M.useCallback((E,T)=>Rs(E)?E:Rs(T)?null:void 0,[]),b=M.useCallback((E,T)=>d(({deviceLongUrls:j={},...F})=>{var k;return{...F,deviceLongUrls:{...j,[E]:_(T,(k=r.deviceLongUrls)==null?void 0:k[E])}}}),[r.deviceLongUrls,_]),w=M.useCallback(E=>d(T=>({...T,tags:E})),[]),S=M.useCallback(async E=>(E.preventDefault(),n(f).then(T=>p&&!cC(T)&&x()).catch(()=>{})),[p,n,x,f]),P=M.useMemo(()=>m.jsxs("div",{className:"d-flex flex-column gap-3",children:[m.jsx(An,{bsSize:"lg",type:"url",placeholder:"URL to be shortened",required:!0,value:f.longUrl,onChange:E=>d(T=>({...T,longUrl:E.target.value}))}),m.jsxs("div",{className:Oe("d-flex flex-column flex-lg-row gap-3",{"mb-3":e}),children:[e&&p&&m.jsx("div",{className:"w-100 w-lg-50",children:m.jsx(An,{bsSize:"lg",placeholder:"Custom slug",value:f.customSlug??"",onChange:E=>d(T=>({...T,customSlug:E.target.value}))})}),m.jsx("div",{className:Oe("w-100",{"w-lg-50":e}),children:m.jsx(c,{tags:i.tags,selectedTags:f.tags??[],onChange:w})})]})]}),[c,e,w,p,f,i.tags]);return m.jsxs("form",{name:"shortUrlForm",className:"short-url-form",onSubmit:S,children:[e&&P,!e&&m.jsxs(m.Fragment,{children:[m.jsxs(Pr,{children:[m.jsx("div",{className:Oe("mb-3",{"col-sm-6":v,"col-12":!v}),children:m.jsx(gt,{title:"Main options",children:P})}),v&&m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Device-specific long URLs",bodyClassName:"d-flex flex-column gap-3",children:[m.jsx(g_,{type:"url",icon:vse,placeholder:"Android-specific redirection",value:((a=f.deviceLongUrls)==null?void 0:a.android)??"",onChange:({target:E})=>b("android",E.value)}),m.jsx(g_,{type:"url",icon:mse,placeholder:"iOS-specific redirection",value:((s=f.deviceLongUrls)==null?void 0:s.ios)??"",onChange:({target:E})=>b("ios",E.value)}),m.jsx(g_,{type:"url",icon:qK,placeholder:"Desktop-specific redirection",value:((l=f.deviceLongUrls)==null?void 0:l.desktop)??"",onChange:({target:E})=>b("desktop",E.value)})]})})]}),m.jsxs(Pr,{children:[m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Customize the short URL",bodyClassName:"d-flex flex-column gap-3",children:[m.jsx(An,{placeholder:"Title",value:f.title??"",onChange:({target:E})=>d(T=>({...T,title:_(E.value,r.title)}))}),p&&m.jsxs(m.Fragment,{children:[m.jsxs(Pr,{children:[m.jsx("div",{className:"col-lg-6 mb-3 mb-lg-0",children:m.jsx(An,{placeholder:"Custom slug",value:f.customSlug??"",onChange:E=>d(T=>({...T,customSlug:E.target.value})),disabled:Rs(f.shortCodeLength)})}),m.jsx("div",{className:"col-lg-6",children:m.jsx(An,{type:"number",placeholder:"Short code length",value:f.shortCodeLength??"",onChange:E=>d(T=>({...T,shortCodeLength:E.target.value})),min:4,disabled:Rs(f.customSlug)})})]}),m.jsx(xRe,{value:f.domain,onChange:E=>d(T=>({...T,domain:E})),domains:o.domains})]})]})}),m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Limit access to the short URL",children:[m.jsxs("div",{className:"row mb-3",children:[m.jsx("div",{className:"col-lg-6",children:m.jsx(Ey,{label:"Enabled since",withTime:!0,maxDate:f.validUntil?Nm(f.validUntil):void 0,value:f.validSince?Nm(f.validSince):null,onChange:E=>d(T=>({...T,validSince:Qa(E)}))})}),m.jsx("div",{className:"col-lg-6 mt-3 mt-lg-0",children:m.jsx(Ey,{label:"Enabled until",withTime:!0,minDate:f.validSince?Nm(f.validSince):void 0,value:f.validUntil?Nm(f.validUntil):null,onChange:E=>d(T=>({...T,validUntil:Qa(E)}))})})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"maxVisits",className:"mb-1",children:"Maximum visits allowed:"}),m.jsx(An,{id:"maxVisits",type:"number",min:1,placeholder:"25...",value:f.maxVisits??"",onChange:E=>d(T=>({...T,maxVisits:Rs(E.target.value)?Number(E.target.value):null}))})]})]})})]}),m.jsxs(Pr,{children:[g&&m.jsx("div",{className:"col-sm-6 mb-3",children:m.jsxs(gt,{title:"Extra checks",children:[y&&m.jsx(y_,{infoTooltip:"If checked, Shlink will try to reach the long URL, failing in case it's not publicly accessible.",checked:f.validateUrl,onChange:E=>d(T=>({...T,validateUrl:E})),children:"Validate URL"}),p&&m.jsxs("p",{children:[m.jsx(dD,{inline:!0,className:"me-2",checked:f.findIfExists,onChange:E=>d(T=>({...T,findIfExists:E})),children:"Use existing URL if found"}),m.jsx(SRe,{})]})]})}),m.jsx("div",{className:Oe("mb-3",{"col-sm-6":g}),children:m.jsxs(gt,{title:"Configure behavior",children:[m.jsx(y_,{infoTooltip:"This short URL will be included in the robots.txt for your Shlink instance, allowing web crawlers (like Google) to index it.",checked:f.crawlable,onChange:E=>d(T=>({...T,crawlable:E})),children:"Make it crawlable"}),m.jsx(y_,{infoTooltip:"When this short URL is visited, any query params appended to it will be forwarded to the long URL.",checked:f.forwardQuery,onChange:E=>d(T=>({...T,forwardQuery:E})),children:"Forward query params on redirect"})]})})]})]}),m.jsx("div",{className:"text-center",children:m.jsx(qe,{outline:!0,color:"primary",disabled:t||!f.longUrl,className:"btn-xs-block",children:t?"Saving...":"Save"})})]})},ERe=$t(lU,["TagsSelector"]),CRe=({active:e,allText:t,onChange:n})=>m.jsxs(m.Fragment,{children:[m.jsx(Ne,{active:e==="all",onClick:()=>n("all"),children:t}),m.jsx(Ne,{divider:!0,tag:"hr"}),qMe.map(r=>m.jsx(Ne,{active:e===r,onClick:()=>n(r),children:hB(r)},r))]}),TRe=({startDate:e,endDate:t,disabled:n=!1,onStartDateChange:r,onEndDateChange:i})=>m.jsxs("div",{className:"row",children:[m.jsx("div",{className:"col-md-6",children:m.jsx(Ey,{label:"Since",value:e,maxDate:t??void 0,disabled:n,onChange:r})}),m.jsx("div",{className:"col-md-6 mt-3 mt-md-0",children:m.jsx(Ey,{label:"Until",value:t,minDate:e??void 0,disabled:n,onChange:o=>i(o&&Jc(o))})})]}),OC=({onDatesChange:e,dateRangeOrInterval:t,defaultText:n,disabled:r})=>{const i=M.useMemo(()=>hB(t)??n,[t,n]),[o,a]=M.useMemo(()=>wy(t)?[void 0,t]:[t,void 0],[t]),s=M.useCallback(l=>{wy(l)?e(pB(l),l):e(l)},[e]);return m.jsxs(ea,{disabled:r,text:i,children:[m.jsx(CRe,{allText:n,active:a,onChange:s}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx("div",{className:"px-3 py-1",children:m.jsx(TRe,{...o,onStartDateChange:l=>s({...o,startDate:l}),onEndDateChange:l=>s({...o,endDate:l})})})]})},jRe={dateCreated:"Created at",shortCode:"Short URL",longUrl:"Long URL",title:"Title",visits:"Visits"},ARe=({onChange:e,selected:t={},className:n,supportsDisabledFiltering:r})=>{const{excludeBots:i=!1,excludeMaxVisitsReached:o=!1,excludePastValidUntil:a=!1}=t,s=l=>()=>e({...t,[l]:!(t!=null&&t[l])});return m.jsxs(ea,{text:"Filters",dropdownClassName:n,end:!0,minWidth:250,children:[m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Visits:"}),m.jsx(Ne,{active:i,onClick:s("excludeBots"),children:"Ignore visits from bots"}),r&&m.jsxs(m.Fragment,{children:[m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Short URLs:"}),m.jsx(Ne,{active:o,onClick:s("excludeMaxVisitsReached"),children:"Exclude with visits reached"}),m.jsx(Ne,{active:a,onClick:s("excludePastValidUntil"),children:"Exclude enabled in the past"})]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{disabled:t.excludeBots===void 0&&t.excludeMaxVisitsReached===void 0&&t.excludePastValidUntil===void 0,onClick:()=>e({excludeBots:void 0,excludeMaxVisitsReached:void 0,excludePastValidUntil:void 0}),children:m.jsx("i",{children:"Reset to defaults"})})]})},cU=({className:e,shortUrlsAmount:t,order:n,handleOrderBy:r,tagsList:i})=>{const{ExportShortUrlsBtn:o,TagsSelector:a}=Rt(cU),[{search:s,tags:l,startDate:c,endDate:f,excludeBots:d,excludeMaxVisitsReached:p,excludePastValidUntil:v,tagsMode:y="any"},g]=pb(),x=Ko("filterDisabledUrls"),_=nr("visits"),[b,w]=M.useState(),S=M.useCallback(({startDate:j,endDate:F},k)=>{g({startDate:Qa(j)??void 0,endDate:Qa(F)??void 0}),w(k)},[g]),P=M.useCallback(j=>g({search:j||void 0}),[g]),E=M.useCallback(j=>g({tags:j}),[g]),T=M.useCallback(()=>g({tagsMode:y==="any"?"all":"any"}),[y,g]);return m.jsxs("div",{className:Oe("short-urls-filtering-bar-container",e),children:[m.jsx(ip,{initialValue:s,onChange:P}),m.jsxs(a0,{className:"mt-3",children:[m.jsx(a,{immutable:!0,placeholder:"With tags...",tags:i.tags,selectedTags:l,onChange:E}),l.length>1&&m.jsxs(m.Fragment,{children:[m.jsx(qe,{outline:!0,color:"secondary",onClick:T,id:"tagsModeBtn","aria-label":"Change tags mode",children:m.jsx(je,{className:"short-urls-filtering-bar__tags-icon",icon:y==="all"?R6:_K})}),m.jsx(Fr,{target:"tagsModeBtn",placement:"left",children:y==="all"?"With all the tags.":"With any of the tags."})]})]}),m.jsxs(Pr,{className:"flex-lg-row-reverse",children:[m.jsx("div",{className:"col-lg-8 col-xl-6 mt-3",children:m.jsxs("div",{className:"d-md-flex",children:[m.jsx("div",{className:"flex-grow-1",children:m.jsx(OC,{defaultText:"All short URLs",dateRangeOrInterval:b??dB(c,f),onDatesChange:S})}),m.jsx(ARe,{className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:{excludeBots:d??(_==null?void 0:_.excludeBots),excludeMaxVisitsReached:p,excludePastValidUntil:v},onChange:g,supportsDisabledFiltering:x})]})}),m.jsx("div",{className:"col-6 col-lg-4 col-xl-6 mt-3",children:m.jsx(o,{amount:t})}),m.jsx("div",{className:"col-6 d-lg-none mt-3",children:m.jsx(op,{prefixed:!1,items:jRe,order:n,onChange:r})})]})]})},kRe=$t(cU,["ExportShortUrlsBtn","TagsSelector"]);function Cd({currentOrder:e,field:t,className:n="ms-1"}){return!e.dir||e.field!==t?null:m.jsx(je,{icon:e.dir==="ASC"?dK:SK,className:n})}const Ql=2,QO="...",uU=(e,t)=>{const n=HP(Math.max(Ql,e-Ql),Math.min(t-1,e+Ql)+1);return e-Ql>Ql&&n.unshift(QO),e+Qle===QO,fU=e=>Vh(e)?e:qt(e),dU=(e,t)=>Vh(e)?`${e}_${t}`:`${e}`,NRe=({paginator:e,currentQueryString:t=""})=>{const{currentPage:n=0,pagesCount:r=0}=e??{},i=ds(),o=s=>`${i}/list-short-urls/${s}${t}`;if(r<=1)return m.jsx("div",{className:"pb-3"});const a=()=>uU(n,r).map((s,l)=>m.jsx(Zs,{disabled:Vh(s),active:n===s,children:m.jsx(Xs,{tag:At,to:o(s),children:fU(s)})},dU(s,l)));return m.jsxs(DP,{className:"sticky-card-paginator py-3",listClassName:"flex-wrap justify-content-center mb-0",children:[m.jsx(Zs,{disabled:n===1,children:m.jsx(Xs,{previous:!0,tag:At,to:o(n-1)})}),a(),m.jsx(Zs,{disabled:n>=r,children:m.jsx(Xs,{next:!0,tag:At,to:o(n+1)})})]})},MRe={field:"dateCreated",dir:"DESC"},hU=Di(({listShortUrls:e,shortUrlsList:t})=>{var n,r,i;const{ShortUrlsTable:o,ShortUrlsFilteringBar:a}=Rt(hU),{page:s}=Mu(),l=pr(),[{tags:c,search:f,startDate:d,endDate:p,orderBy:v,tagsMode:y,excludeBots:g,excludePastValidUntil:x,excludeMaxVisitsReached:_},b]=pb(),w=YP(),[S,P]=M.useState(v??((n=w.shortUrlsList)==null?void 0:n.defaultOrdering)??MRe),{pagination:E}=(t==null?void 0:t.shortUrls)??{},T=M.useMemo(()=>{var X;return g??((X=w.visits)==null?void 0:X.excludeBots)},[g,(r=w.visits)==null?void 0:r.excludeBots]),j=Ko("excludeBotsOnShortUrls"),F=M.useCallback((X,Q)=>{b({orderBy:{field:X,dir:Q}}),P({field:X,dir:Q})},[b]),k=X=>()=>F(X,c0(X,S.field,S.dir)),I=X=>m.jsx(Cd,{currentOrder:S,field:X}),D=M.useCallback(X=>b({tags:[...new Set([...c,X])]}),[c,b]),K=M.useCallback(({field:X,dir:Q})=>j&&T&&X==="visits"?{field:"nonBotVisits",dir:Q}:{field:X,dir:Q},[T,j]),W=fC();return M.useEffect(()=>{e({page:s,searchTerm:f,tags:c,startDate:d,endDate:p,orderBy:K(S),tagsMode:y,excludePastValidUntil:x,excludeMaxVisitsReached:_})},[e,K,s,f,c,d,p,S,y,x,_]),m.jsxs(uC,{value:W,children:[m.jsx(a,{shortUrlsAmount:(i=t.shortUrls)==null?void 0:i.pagination.totalItems,order:S,handleOrderBy:F,className:"mb-3"}),m.jsx(dC,{type:"short-urls",className:"mb-3"}),m.jsxs(Dr,{body:!0,className:Oe({"pb-0":!t.loading}),children:[m.jsx(o,{shortUrlsList:t,orderByColumn:k,renderOrderIcon:I,onTagClick:D}),!t.loading&&m.jsx(NRe,{paginator:E,currentQueryString:l.search})]})]})},()=>[Jn.visits]),LRe=$t(hU,["ShortUrlsTable","ShortUrlsFilteringBar"]),pU=({orderByColumn:e,renderOrderIcon:t,shortUrlsList:n,onTagClick:r,className:i})=>{const{ShortUrlsRow:o}=Rt(pU),{error:a,loading:s,shortUrls:l}=n,c=Oe({"short-urls-table__header-cell--with-action":!!e}),f=Oe("short-urls-table__header-cell",c),d=Oe("table table-hover responsive-table short-urls-table",i),p=()=>a?m.jsx("tr",{children:m.jsx("td",{colSpan:6,className:"text-center table-danger text-dark",children:"Something went wrong while loading short URLs :("})}):s?m.jsx("tr",{children:m.jsx("td",{colSpan:6,className:"text-center",children:"Loading..."})}):!s&&(!l||l.data.length===0)?m.jsx("tr",{children:m.jsx("td",{colSpan:6,className:"text-center",children:"No results found"})}):l==null?void 0:l.data.map(v=>m.jsx(o,{shortUrl:v,onTagClick:r},v.shortUrl));return m.jsxs("table",{className:d,children:[m.jsx("thead",{className:"responsive-table__header short-urls-table__header",children:m.jsxs("tr",{children:[m.jsxs("th",{className:f,onClick:e==null?void 0:e("dateCreated"),children:["Created at ",t==null?void 0:t("dateCreated")]}),m.jsxs("th",{className:f,onClick:e==null?void 0:e("shortCode"),children:["Short URL ",t==null?void 0:t("shortCode")]}),m.jsxs("th",{className:"short-urls-table__header-cell",children:[m.jsxs(yl,{className:Oe("p-0",c),onClick:e==null?void 0:e("title"),children:["Title ",t==null?void 0:t("title")]}),"  /  ",m.jsxs(yl,{className:Oe("p-0",c),onClick:e==null?void 0:e("longUrl"),children:[m.jsx("span",{className:"indivisible",children:"Long URL"})," ",t==null?void 0:t("longUrl")]})]}),m.jsx("th",{className:"short-urls-table__header-cell",children:"Tags"}),m.jsx("th",{className:f,onClick:e==null?void 0:e("visits"),children:m.jsxs("span",{className:"indivisible",children:["Visits ",t==null?void 0:t("visits")]})}),m.jsx("th",{className:"short-urls-table__header-cell",colSpan:2,"aria-hidden":!0})]})}),m.jsx("tbody",{children:p()})]})},RRe=$t(pU,["ShortUrlsRow"]),$Re=(e,t)=>{e.factory("ShortUrlsList",LRe),e.decorator("ShortUrlsList",t(["mercureInfo","shortUrlsList"],["listShortUrls","createNewVisits","loadMercureInfo"])),e.factory("ShortUrlsTable",RRe),e.factory("ShortUrlsRow",hRe),e.factory("CreateShortUrlResult",eRe),e.factory("ShortUrlsRowMenu",pRe),e.decorator("ShortUrlsRowMenu",t(null,["shortUrlDeleted","deleteShortUrl"])),e.factory("ShortUrlForm",ERe),e.decorator("ShortUrlForm",t(["tagsList","domainsList"])),e.factory("CreateShortUrl",Q4e),e.decorator("CreateShortUrl",t(["shortUrlCreation"],["createShortUrl","resetCreateShortUrl"])),e.factory("EditShortUrl",J4e),e.decorator("EditShortUrl",t(["shortUrlsDetails","shortUrlEdition"],["getShortUrlsDetails","editShortUrl"])),e.serviceFactory("DeleteShortUrlModal",()=>tRe),e.decorator("DeleteShortUrlModal",t(["shortUrlDeletion"],["resetDeleteShortUrl"])),e.factory("QrCodeModal",aRe),e.factory("ExportShortUrlsBtn",nRe),e.factory("ShortUrlsFilteringBar",kRe),e.decorator("ShortUrlsFilteringBar",t(["tagsList"])),e.serviceFactory("shortUrlsListReducerCreator",MLe,"listShortUrls","editShortUrl","createShortUrl"),e.serviceFactory("shortUrlsListReducer",n=>n.reducer,"shortUrlsListReducerCreator"),e.serviceFactory("shortUrlCreationReducerCreator",vRe,"createShortUrl"),e.serviceFactory("shortUrlCreationReducer",n=>n.reducer,"shortUrlCreationReducerCreator"),e.serviceFactory("shortUrlEditionReducerCreator",bRe,"editShortUrl"),e.serviceFactory("shortUrlEditionReducer",n=>n.reducer,"shortUrlEditionReducerCreator"),e.serviceFactory("shortUrlDeletionReducerCreator",ALe,"deleteShortUrl"),e.serviceFactory("shortUrlDeletionReducer",n=>n.reducer,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlsDetailsReducerCreator",_Re,"apiClientFactory"),e.serviceFactory("shortUrlsDetailsReducer",n=>n.reducer,"shortUrlsDetailsReducerCreator"),e.serviceFactory("listShortUrls",NLe,"apiClientFactory"),e.serviceFactory("createShortUrl",mRe,"apiClientFactory"),e.serviceFactory("resetCreateShortUrl",n=>n.resetCreateShortUrl,"shortUrlCreationReducerCreator"),e.serviceFactory("deleteShortUrl",jLe,"apiClientFactory"),e.serviceFactory("resetDeleteShortUrl",n=>n.resetDeleteShortUrl,"shortUrlDeletionReducerCreator"),e.serviceFactory("shortUrlDeleted",()=>OB),e.serviceFactory("getShortUrlsDetails",n=>n.getShortUrlsDetails,"shortUrlsDetailsReducerCreator"),e.serviceFactory("editShortUrl",yRe,"apiClientFactory")},IRe=({tag:e,toggle:t,isOpen:n,deleteTag:r,tagDelete:i,tagDeleted:o})=>{const{deleting:a,error:s,deleted:l,errorData:c}=i;return m.jsxs(vr,{toggle:t,isOpen:n,centered:!0,onClosed:()=>l&&o(e),children:[m.jsx(mo,{toggle:t,className:"text-danger",children:"Delete tag"}),m.jsxs(Li,{children:["Are you sure you want to delete tag ",m.jsx("b",{children:e}),"?",s&&m.jsx(Zn,{type:"error",small:!0,className:"mt-2",children:m.jsx(ho,{errorData:c,fallbackMessage:"Something went wrong while deleting the tag :("})})]}),m.jsxs(as,{children:[m.jsx(qe,{color:"link",onClick:t,children:"Cancel"}),m.jsx(qe,{color:"danger",disabled:a,onClick:async()=>{await r(e),t()},children:a?"Deleting tag...":"Delete tag"})]})]})},mU=({tag:e,editTag:t,toggle:n,tagEdited:r,isOpen:i,tagEdit:o})=>{const{ColorGenerator:a}=Rt(mU),[s,l]=M.useState(e),[c,f]=M.useState(a.getColorForKey(e)),{editing:d,error:p,edited:v,errorData:y}=o,g=wB(async()=>{await t({oldName:e,newName:s,color:c}),n()}),x=M.useCallback(()=>v&&r({oldName:e,newName:s,color:c}),[c,v,s,e,r]);return m.jsx(vr,{isOpen:i,toggle:n,centered:!0,onClosed:x,children:m.jsxs("form",{name:"editTag",onSubmit:g,children:[m.jsx(mo,{toggle:n,children:"Edit tag"}),m.jsxs(Li,{children:[m.jsxs(a0,{children:[m.jsxs("div",{className:"input-group-text p-0 position-relative",style:{backgroundColor:c,borderColor:c},children:[m.jsx(je,{icon:hK,className:"position-absolute top-50 start-50 translate-middle text-white"}),m.jsx(An,{className:"form-control-color opacity-0",type:"color",value:c,onChange:_=>f(_.target.value)})]}),m.jsx(An,{value:s,placeholder:"Tag",required:!0,onChange:({target:_})=>l(_.value)})]}),p&&m.jsx(Zn,{type:"error",small:!0,className:"mt-2",children:m.jsx(ho,{errorData:y,fallbackMessage:"Something went wrong while editing the tag :("})})]}),m.jsxs(as,{children:[m.jsx(qe,{type:"button",color:"link",onClick:n,children:"Cancel"}),m.jsx(qe,{color:"primary",disabled:d,children:d?"Saving...":"Save"})]})]})})},DRe=$t(mU,["ColorGenerator"]),FRe=/\s+/g,vU=e=>e.trim().toLowerCase().replace(FRe,"-"),gU=({color:e})=>m.jsx("div",{style:{backgroundColor:e},className:"color-bullet"}),yU=({tag:e,colorGenerator:t})=>m.jsx(gU,{color:t.getColorForKey(e)});let y4=1;const bU="Tag not found",_U="Add tag",BRe=e=>e!==bU,URe=e=>e===_U,b4=e=>(y4+=1,{label:e,value:`${e}${y4}`}),zRe=e=>({tag:t,onClick:n})=>m.jsx(vb,{colorGenerator:e,text:t.label,className:"react-tags__tag",onClose:n}),VRe=(e,t)=>({option:n,classNames:r,...i})=>{var o;const a=BRe(n.label),s=URe(n.label);return m.jsx("div",{className:Oe(r.option,{[r.optionIsActive]:a&&n.active,"react-tags__listbox-option--not-selectable":!a}),...i,children:a?m.jsxs(m.Fragment,{children:[!s&&m.jsx(yU,{tag:`${n.label}`,colorGenerator:e}),s?m.jsxs("i",{children:['Add "',vU(((o=t.current)==null?void 0:o.input.value)??""),'"']}):n.label]}):m.jsx("i",{children:n.label})})},xU=({selectedTags:e,onChange:t,placeholder:n,tags:r,immutable:i=!1})=>{const{ColorGenerator:o}=Rt(xU),a=nr("shortUrlCreation"),s=(a==null?void 0:a.tagFilteringMode)??"startsWith",l=Mi();return m.jsx(ple,{ref:l,selected:e.map(b4),suggestions:r.filter(c=>!e.includes(c)).map(b4),renderTag:zRe(o),renderOption:VRe(o,l),activateFirstOption:!0,allowNew:!i,newOptionText:_U,noOptionsText:bU,placeholderText:n??"Add tags to the URL",delimiterKeys:["Enter",","],suggestionsTransform:(c,f)=>{const d=c.toLowerCase().trim();return d.length<1?[]:[...f.filter(({label:p})=>s==="includes"?p.includes(d):p.startsWith(d))].slice(0,5)},onDelete:c=>{const f=[...e];f.splice(c,1),t(f)},onAdd:({label:c})=>t([...new Set([...e,...c.split(",").map(vU)])])})},WRe=$t(xU,["ColorGenerator"]),JO="shlink/tagDelete",HRe={deleting:!1,deleted:!1,error:!1},wU=Xn(`${JO}/tagDeleted`),GRe=e=>{const t=fn(`${JO}/deleteTag`,async r=>{await e().deleteTags([r])}),{reducer:n}=Qt({name:JO,initialState:HRe,reducers:{},extraReducers:r=>{r.addCase(t.pending,()=>({deleting:!0,deleted:!1,error:!1})),r.addCase(t.rejected,(i,{error:o})=>({deleting:!1,deleted:!1,error:!0,errorData:Br(o)})),r.addCase(t.fulfilled,()=>({deleting:!1,deleted:!0,error:!1}))}});return{reducer:n,deleteTag:t}},SC="shlink/tagEdit",qRe={editing:!1,edited:!1,error:!1},OU=Xn(`${SC}/tagEdited`),KRe=(e,t)=>fn(`${SC}/editTag`,async({oldName:n,newName:r,color:i})=>(await e().editTag(n,r),t.setColorForKey(r,i),{oldName:n,newName:r,color:i})),YRe=e=>Qt({name:SC,initialState:qRe,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({editing:!0,edited:!1,error:!1})),t.addCase(e.rejected,(n,{error:r})=>({editing:!1,edited:!1,error:!0,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>{const{oldName:i,newName:o}=r;return{oldName:i,newName:o,editing:!1,edited:!0,error:!1}})}}),PC="shlink/tagsList",b_={tags:[],filteredTags:[],stats:{},loading:!1,error:!1},_4=(e,t)=>n=>n===e?t:n,x4=(e,t)=>e.filter(n=>n!==t),ZRe=(e,t)=>e.reduce((n,[r,i])=>{if(!n[r])return n;const{bots:o,nonBots:a}=i,s=n[r];return{...n,[r]:{...s,visitsSummary:s.visitsSummary&&{total:s.visitsSummary.total+o+a,bots:s.visitsSummary.bots+o,nonBots:s.visitsSummary.nonBots+a},visitsCount:(s.visitsCount??0)+o+a}}},{...t}),XRe=e=>Object.entries(e.reduce((t,{shortUrl:n,visit:r})=>(n==null||n.tags.forEach(i=>{t[i]||(t[i]={bots:0,nonBots:0}),r.potentialBot?t[i].bots+=1:t[i].nonBots+=1}),t),{})),QRe=e=>fn(`${PC}/listTags`,async()=>{const{data:t}=await e().tagsStats(),n=t.reduce((r,{tag:i,...o})=>(r[i]=o,r),{});return{tags:Object.keys(n),stats:n}}),SU=Xn(`${PC}/filterTags`),JRe=(e,t)=>Qt({name:PC,initialState:b_,reducers:{},extraReducers:n=>{n.addCase(SU,(r,{payload:i})=>({...r,filteredTags:r.tags.filter(o=>o.toLowerCase().match(i.toLowerCase()))})),n.addCase(e.pending,r=>({...r,loading:!0,error:!1})),n.addCase(e.rejected,(r,{error:i})=>({...b_,error:!0,errorData:Br(i)})),n.addCase(e.fulfilled,(r,{payload:i})=>({...b_,stats:i.stats,tags:i.tags,filteredTags:i.tags})),n.addCase(wU,({tags:r,filteredTags:i,...o},{payload:a})=>({...o,tags:x4(r,a),filteredTags:x4(i,a)})),n.addCase(OU,({tags:r,filteredTags:i,stats:o,...a},{payload:s})=>({...a,stats:{...o,[s.newName]:o[s.oldName]},tags:r.map(_4(s.oldName,s.newName)).sort(),filteredTags:i.map(_4(s.oldName,s.newName)).sort()})),n.addCase(tf,(r,{payload:i})=>({...r,stats:ZRe(XRe(i.createdVisits),r.stats)})),n.addCase(t.fulfilled,({tags:r,...i},{payload:o})=>({...i,tags:r.concat(o.tags.filter(a=>!r.includes(a)))}))}}),e$e={tag:"Tag",shortUrls:"Short URLs",visits:"Visits"},PU=Di(({filterTags:e,tagsList:t})=>{var n,r;const{TagsTable:i}=Rt(PU),o=YP(),[a,s]=M.useState(((n=o.tags)==null?void 0:n.defaultOrdering)??{}),l=M.useMemo(()=>{const f=t.filteredTags.map(d=>{var p,v,y;const g=t.stats[d],x=((p=o.visits)!=null&&p.excludeBots?(v=g==null?void 0:g.visitsSummary)==null?void 0:v.nonBots:(y=g==null?void 0:g.visitsSummary)==null?void 0:y.total)??(g==null?void 0:g.visitsCount)??0;return{tag:d,visits:x,shortUrls:(g==null?void 0:g.shortUrlsCount)??0}});return vD(f,a)},[a,(r=o.visits)==null?void 0:r.excludeBots,t.filteredTags,t.stats]),c=fC();return t.loading?m.jsx(zo,{loading:!0}):t.error?m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:t.errorData,fallbackMessage:"Error loading tags :("})}):m.jsxs(uC,{value:c,children:[m.jsx(ip,{className:"mb-3",onChange:e}),m.jsx(Pr,{className:"mb-3",children:m.jsx("div",{className:"col-lg-6 offset-lg-6",children:m.jsx(op,{items:e$e,order:a,onChange:(f,d)=>s({field:f,dir:d})})})}),m.jsx(dC,{type:"tags",className:"mb-3"}),m.jsx(i,{sortedTags:l,currentOrder:a,orderByColumn:f=>()=>{const d=c0(f,a.field,a.dir);s({field:d?f:void 0,dir:d})}})]})},()=>[Jn.visits]),t$e=$t(PU,["TagsTable"]),EC=({pagesCount:e,currentPage:t,setCurrentPage:n,centered:r=!0})=>{if(e<2)return null;const i=o=>()=>!Vh(o)&&n(o);return m.jsxs(DP,{listClassName:Oe("flex-wrap mb-0 simple-paginator",{"justify-content-center":r}),children:[m.jsx(Zs,{disabled:t<=1,children:m.jsx(Xs,{previous:!0,tag:"span",onClick:i(t-1)})}),uU(t,e).map((o,a)=>m.jsx(Zs,{disabled:Vh(o),active:t===o,children:m.jsx(Xs,{role:"link",tag:"span",onClick:i(o),children:fU(o)})},dU(o,a))),m.jsx(Zs,{disabled:t>=e,children:m.jsx(Xs,{next:!0,tag:"span",onClick:i(t+1)})})]})},n$e=20,EU=({sortedTags:e,orderByColumn:t,currentOrder:n})=>{const{TagsTableRow:r}=Rt(EU),i=M.useRef(!0),{page:o=1}=$u(),[a,s]=pLe("page",Number(o)),l=M.useCallback(p=>{s(p),scrollTo(0,0)},[s]),c=Ac(e,n$e),f=c.length>1,d=c[a-1]??[];return M.useEffect(()=>{i.current||l(1),i.current=!1},[l,e]),m.jsxs(gt,{bodyClassName:f?"pb-1":"",children:[m.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[m.jsxs("thead",{className:"responsive-table__header",children:[m.jsxs("tr",{children:[m.jsxs("th",{className:"tags-table__header-cell",onClick:t("tag"),children:["Tag ",m.jsx(Cd,{currentOrder:n,field:"tag"})]}),m.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("shortUrls"),children:["Short URLs ",m.jsx(Cd,{currentOrder:n,field:"shortUrls"})]}),m.jsxs("th",{className:"tags-table__header-cell text-lg-end",onClick:t("visits"),children:["Visits ",m.jsx(Cd,{currentOrder:n,field:"visits"})]}),m.jsx("th",{className:"tags-table__header-cell",children:m.jsx("span",{className:"sr-only",children:"Options"})})]}),m.jsx("tr",{children:m.jsx("th",{"aria-hidden":!0,colSpan:4,className:"p-0 border-top-0"})})]}),m.jsxs("tbody",{children:[d.length===0&&m.jsx("tr",{children:m.jsx("td",{colSpan:4,className:"text-center",children:"No tags found"})}),d.map(p=>m.jsx(r,{tag:p},p.tag))]})]}),f&&m.jsx("div",{className:"sticky-card-paginator",children:m.jsx(EC,{pagesCount:c.length,currentPage:a,setCurrentPage:l})})]},a)},r$e=$t(EU,["TagsTableRow"]),CU=({tag:e})=>{const{DeleteTagConfirmModal:t,EditTagModal:n,ColorGenerator:r}=Rt(CU),[i,o]=Lt(),[a,s]=Lt(),l=ds(),c=cb();return m.jsxs("tr",{className:"responsive-table__row",children:[m.jsxs("th",{className:"responsive-table__cell","data-th":"Tag",children:[m.jsx(yU,{tag:e.tag,colorGenerator:r})," ",e.tag]}),m.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Short URLs",children:m.jsx(At,{to:`${l}/list-short-urls/1?tags=${encodeURIComponent(e.tag)}`,children:qt(e.shortUrls)})}),m.jsx("td",{className:"responsive-table__cell text-lg-end","data-th":"Visits",children:m.jsx(At,{to:`${l}/tag/${e.tag}/visits`,children:qt(e.visits)})}),m.jsx("td",{className:"responsive-table__cell text-lg-end",children:m.jsxs(l0,{children:[m.jsxs(Ne,{onClick:s,children:[m.jsx(je,{icon:N6,fixedWidth:!0,className:"me-1"})," Edit"]}),m.jsxs(Ne,{disabled:!c||!c.canAddItemWithName(e.tag),onClick:()=>c==null?void 0:c.addItemToCompare({name:e.tag,query:e.tag,style:r.stylesForKey(e.tag)}),children:[m.jsx(je,{icon:Jy,fixedWidth:!0})," Compare visits"]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{className:"dropdown-item--danger",onClick:o,children:[m.jsx(je,{icon:vK,fixedWidth:!0,className:"me-1"})," Delete tag"]})]})}),m.jsx(n,{tag:e.tag,toggle:s,isOpen:a}),m.jsx(t,{tag:e.tag,toggle:o,isOpen:i})]})},i$e=$t(CU,["DeleteTagConfirmModal","EditTagModal","ColorGenerator"]),o$e=(e,t)=>{e.factory("TagsSelector",WRe),e.serviceFactory("DeleteTagConfirmModal",()=>IRe),e.decorator("DeleteTagConfirmModal",t(["tagDelete"],["deleteTag","tagDeleted"])),e.factory("EditTagModal",DRe),e.decorator("EditTagModal",t(["tagEdit"],["editTag","tagEdited"])),e.factory("TagsTableRow",i$e),e.factory("TagsTable",r$e),e.factory("TagsList",t$e),e.decorator("TagsList",t(["tagsList","mercureInfo"],["filterTags","createNewVisits","loadMercureInfo"])),e.serviceFactory("tagEditReducerCreator",YRe,"editTag"),e.serviceFactory("tagEditReducer",n=>n.reducer,"tagEditReducerCreator"),e.serviceFactory("tagDeleteReducerCreator",GRe,"apiClientFactory"),e.serviceFactory("tagDeleteReducer",n=>n.reducer,"tagDeleteReducerCreator"),e.serviceFactory("tagsListReducerCreator",JRe,"listTags","createShortUrl"),e.serviceFactory("tagsListReducer",n=>n.reducer,"tagsListReducerCreator"),e.serviceFactory("listTags",QRe,"apiClientFactory"),e.serviceFactory("filterTags",()=>SU),e.serviceFactory("deleteTag",n=>n.deleteTag,"tagDeleteReducerCreator"),e.serviceFactory("tagDeleted",()=>wU),e.serviceFactory("editTag",KRe,"apiClientFactory","ColorGenerator"),e.serviceFactory("tagEdited",()=>OU)},a$e=new r5,s$e=e=>a$e.parse(e),l$e=6,w4="0123456789ABCDEF",c$e=128,{floor:u$e,random:f$e,sqrt:d$e,round:h$e}=Math,p$e=()=>`#${yC(l$e,()=>w4[u$e(f$e()*w4.length)]).join("")}`,O4=e=>e.toLowerCase().trim(),m$e=e=>(e.match(/../g)??[]).map(t=>parseInt(t,16)||0),v$e=(e=0,t=0,n=0)=>h$e(d$e(.299*e**2+.587*t**2+.114*n**2));class g$e{constructor(t){za(this,"colors"),za(this,"lights");var n;this.storage=t,this.colors=((n=this.storage)==null?void 0:n.getTagColors())??{},this.lights={}}getColorForKey(t){const n=O4(t);return this.colors[n]||this.setColorForKey(n,p$e())}setColorForKey(t,n){var r;const i=O4(t);return this.colors[i]=n,(r=this.storage)==null||r.storeTagColors(this.colors),n}stylesForKey(t){const n=this.getColorForKey(t);return{backgroundColor:n,color:this.isLightColor(n)?"#222":"#fff"}}isLightColor(t){const n=t.substring(1);if(this.lights[n]===void 0){const r=m$e(n);this.lights[n]=v$e(...r)>=c$e}return this.lights[n]}}const TU=({document:e},t,n)=>{const r=e.createElement("a");r.setAttribute("href",t),r.setAttribute("download",n),r.style.visibility="hidden",e.body.appendChild(r),r.click(),e.body.removeChild(r)},y$e=(e,t,n)=>{const r=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(r);TU(e,i,n)};class b$e{constructor(t,n){this.fetch=t,this.window=n}async saveImage(t,n){const r=await this.fetch(t).then(o=>o.blob()),i=URL.createObjectURL(r);TU(this.window,i,n)}}class _$e{constructor(t,n){za(this,"exportVisits",(r,i)=>{i.length&&this.exportCsv(r,i)}),za(this,"exportShortUrls",r=>{r.length&&this.exportCsv("short_urls.csv",r)}),za(this,"exportCsv",(r,i)=>{const o=this.jsonToCsv(i);y$e(this.window,o,r)}),this.window=t,this.jsonToCsv=n}}function x$e(e){e.constant("window",window),e.constant("fetch",window.fetch.bind(window)),e.service("ImageDownloader",b$e,"fetch","window"),e.service("ColorGenerator",g$e,"TagColorsStorage"),e.constant("jsonToCsv",s$e),e.service("ReportExporter",_$e,"window","jsonToCsv"),e.serviceFactory("useTimeoutToggle",()=>pD)}const Op=({visits:e,shortUrl:t,children:n,title:r})=>m.jsx("header",{children:m.jsxs(Dr,{body:!0,children:[m.jsxs("h2",{className:"d-flex justify-content-between align-items-center mb-0",children:[m.jsx(mb,{}),m.jsx("span",{className:"text-center d-none d-sm-block",children:m.jsx("small",{children:r})}),m.jsxs("span",{className:"badge badge-main ms-3",children:["Visits:"," ",m.jsx(rU,{visitsCount:e.length,shortUrl:t})]})]}),m.jsx("h3",{className:"text-center d-block d-sm-none mb-0 mt-3",children:m.jsx("small",{children:r})}),n&&m.jsx("div",{className:"mt-md-2",children:n})]})}),gb=({children:e,className:t})=>m.jsx("div",{className:Oe("d-flex justify-content-between align-items-center",t),children:e}),jU=({title:e,footer:t,children:n})=>m.jsxs(Dr,{role:"document",children:[m.jsx(np,{className:"chart-card__header",children:e}),m.jsx(tp,{children:n}),t&&m.jsx(QI,{className:"chart-card__footer--sticky",children:t})]}),AU={color:"white",background:"rgb(0 0 0 / .9)",border:"none",borderRadius:"5px"},w$e={marginBottom:"5px",fontWeight:"bold"},kU={contentStyle:AU,labelStyle:w$e,itemStyle:{padding:0}},S4=["#97BBCD","#F7464A","#46BFBD","#FDB45C","#949FB1","#57A773","#414066","#08B2E3","#B6C454","#DCDCDC","#463730"],NU=e=>S4[e%S4.length],Cy=()=>ap()?"#46e587":"#1DAA58",O$e=()=>ap()?"rgba(70, 229, 135, 0.4)":"rgba(29, 170, 88, 0.4)",S$e=({chartData:e,showNumbers:t})=>m.jsx("ul",{className:"doughnut-chart-legend",children:e.map(({name:n,color:r,value:i})=>m.jsxs("li",{className:"doughnut-chart-legend__item d-flex",children:[m.jsx("div",{className:"doughnut-chart-legend__item-color",style:{backgroundColor:r}}),m.jsxs("small",{className:"doughnut-chart-legend__item-text flex-fill",children:[n,t&&m.jsxs("b",{children:[" (",qt(i),")"]})]})]},n))}),P4=e=>M.useMemo(()=>Object.entries(e).map(([t,n],r)=>({name:t,value:n,color:NU(r)})),[e]),P$e=({stats:e,prevStats:t,showNumbersInLegend:n,dimensions:r})=>{const i=P4(e),o=P4(t),a=o.length>0,s=ap()?Jre:Qre;return m.jsxs("div",{className:"row align-items-center",children:[m.jsx("div",{className:"col-sm-12 col-md-7",children:m.jsx("div",{style:r??{width:"100%",height:300},children:m.jsx(r?M.Fragment:wE,{children:m.jsxs(fMe,{...r,children:[m.jsx(Yr,{formatter:qt,contentStyle:AU,itemStyle:{color:"white"}}),m.jsx(fo,{data:i,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"100%",innerRadius:a?"65%":"50%",animationBegin:0,children:i.map((l,c)=>m.jsx(Fa,{fill:l.color,stroke:s},`${l.name}-${c}`))}),a&&m.jsx(fo,{data:o,dataKey:"value",nameKey:"name",startAngle:360,endAngle:0,outerRadius:"55%",innerRadius:"20%",animationBegin:0,stroke:s,fill:Cy()})]})})})}),m.jsx("div",{className:"col-sm-12 col-md-5",children:m.jsx(S$e,{chartData:i,showNumbers:n})})]})},E4=({title:e,...t})=>{const[n,r]=Lt(!1);return m.jsx(jU,{title:m.jsxs(gb,{children:[e,m.jsx("div",{children:m.jsx(Vo,{checked:n,onChange:r,children:"Show numbers"})})]}),children:m.jsx(P$e,{...t,showNumbersInLegend:n})})},E$e=M.forwardRef(({visitsGroups:e},t)=>{const n=M.useMemo(()=>Object.entries(e),[e]);return n.length===0?null:m.jsx("ul",{className:"list-unstyled mb-0 mt-2 d-flex flex-wrap justify-content-center gap-3",ref:t,children:n.map(([r,i],o)=>m.jsxs("li",{className:"d-inline",children:[m.jsx(gU,{color:MU(i)}),m.jsxs("strong",{children:[r," (",qt(i.length),")"]})]},`${r}${o}`))})}),C$e={monthly:"Month",weekly:"Week",daily:"Day",hourly:"Hour"},T$e={hourly:e=>({hours:e}),daily:e=>({days:e}),weekly:e=>({weeks:e}),monthly:e=>({months:e})},j$e={hourly:foe,daily:m0,weekly:uoe,monthly:hg},CC={hourly:e=>pg(e,"yyyy-MM-dd HH:00"),daily:e=>Ta(e),weekly(e){const t=Ta(ah(e)),n=Ta(boe(e));return`${t} - ${n}`},monthly:e=>pg(e,"yyyy-MM")},A$e=e=>{var t;const n=Object.values(e).filter(a=>a.length>0);if(n.length===0)return"monthly";const r=new Date,i=n.map(a=>Ka(a[a.length-1].date)),o=DD(i);return((t=[[()=>m0(r,o)<=2,"hourly"],[()=>hg(r,o)<=1,"daily"],[()=>hg(r,o)<=6,"weekly"]].find(([a])=>a()))==null?void 0:t[1])??"monthly"},k$e=(e,t)=>Object.keys(t).reduce((n,r)=>(n[r]=MD(t[r],i=>CC[e](Ka(i.date))),n),{}),N$e=(e,t)=>t.reduce((n,r)=>{const i=CC[e](Ka(r.date));return n[i]=n[i]??[],n[i].push(r),n},{}),M$e=(e,t)=>{const n=Object.values(t).filter(f=>f.length>0).map(f=>[...f].reverse());if(n.length===0)return[];const r=j$e[e],i=CC[e],o=T$e[e],a=n.flat(),s=Ka(a[0].date),l=Ka(a[a.length-1].date),c=r(l,s)||1;return[{formattedDate:i(s),date:s},...yC(c,f=>{const d=ioe(s,o(f));return{formattedDate:i(d),date:d}})]},MU=e=>{if(e.color)return e.color;const t={main:nh,highlighted:e2,previous:Cy()};return e.type?t[e.type]:nh},C4=(e,t)=>M.useMemo(()=>Object.values(e).find(n=>n.type===t)??[],[e,t]),L$e=(e,t,n)=>{const r=C4(e,"main"),i=C4(e,"highlighted"),o=M.useMemo(()=>n?N$e(t,r):{},[n,t,r]),a=M.useCallback((s,{payload:l})=>{const c=o[l.formattedDate]??[];n==null||n(c===i?[]:c)},[o,i,n]);return n&&{cursor:"pointer",onClick:a}},T4=e=>{var t,n;return(n=(t=e.activePayload)==null?void 0:t[0])==null?void 0:n.payload},LU=({visitsGroups:e,setSelectedVisits:t,dimensions:n,matchMedia:r,onDateRangeChange:i})=>{const[o,a]=M.useState(A$e(e)),s=_C(767,r??window.matchMedia),l=M.useMemo(()=>{const D=k$e(o,e),K=Object.keys(D);return M$e(o,e).map(({formattedDate:W,date:X})=>({date:X,formattedDate:W,...K.reduce((Q,te)=>(Q[te]=D[te][W]??0,Q),{})}))},[o,e]),c=L$e(e,o,t),[f,d,,p]=Lt(),v=Mi(),y=M.useId(),g=Mi(),[x,_]=M.useState(s?300:400);M.useLayoutEffect(()=>{if(!f)return _(s?300:400),()=>{};const D=new ResizeObserver(()=>{const{height:K}=v.current.getBoundingClientRect(),{height:W}=g.current.getBoundingClientRect();_(K-W-48)});return D.observe(v.current),D.observe(g.current),()=>D.disconnect()},[v,f,s,g]),vLe("Escape",p,f);const b=n?M.Fragment:wE,w=M.useMemo(()=>n?{}:{width:"100%",height:x},[n,x]),[S,P]=M.useState(),[E,T]=M.useState(),j=M.useCallback(()=>{P(void 0),T(void 0)},[]),F=M.useCallback((D,K)=>{const W=T4(D);K.button===0&&W&&P(W)},[]),k=M.useCallback(D=>{const K=T4(D);S&&K&&T(K)},[S]),I=M.useCallback(()=>{if(!S||!E)return;const D=[S.date,E.date],K=soe(D),W=DD(D);j(),i({startDate:K,endDate:W})},[i,j,E,S]);return m.jsxs(Dr,{className:Oe({"fixed-top fixed-bottom":f}),"data-testid":"line-chart-card",children:[m.jsxs(np,{role:"heading","aria-level":4,className:"d-flex justify-content-between align-items-center",children:["Visits over time",m.jsxs("div",{className:"d-flex align-content-center gap-1",children:[m.jsx(qe,{"aria-label":f?"Collapse":"Expand","aria-expanded":f,"aria-controls":y,size:"sm",color:"link",onClick:d,children:m.jsx(je,{icon:f?Zq:HK})}),m.jsxs(rp,{className:"d-flex align-items-center",children:[m.jsx(Jo,{caret:!0,color:"link",className:"btn-sm p-0",children:"Group by"}),m.jsx(os,{end:!0,children:Object.entries(C$e).map(([D,K])=>m.jsx(Ne,{active:o===D,onClick:()=>a(D),children:K},D))})]})]})]}),m.jsxs(tp,{innerRef:v,id:y,children:[m.jsx(b,{...w,children:m.jsxs(uMe,{className:"user-select-none",data:l,...n,onMouseDown:F,onMouseMove:k,onMouseUp:I,children:[m.jsx(Ju,{dataKey:"formattedDate"}),m.jsx(ef,{tickFormatter:qt,yAxisId:"1"}),m.jsx(Yr,{formatter:qt,...kU}),m.jsx(iC,{strokeOpacity:ap()?.1:.9}),Object.entries(e).map(([D,K])=>K.length>0&&m.jsx(Qu,{yAxisId:"1",dataKey:D,type:"monotone",stroke:MU(K),strokeWidth:2,activeDot:K.type==="previous"?void 0:c,strokeDasharray:K.type==="previous"?"8 3":void 0},D)),S&&E&&m.jsx(vp,{yAxisId:"1",x1:S.formattedDate,x2:E.formattedDate})]})}),m.jsx(E$e,{visitsGroups:e,ref:g})]})]})},R$e=({toggleClassName:e,ranges:t,value:n,setValue:r})=>m.jsxs(rp,{children:[m.jsx(Jo,{caret:!0,color:"link",className:e,children:"Paginate"}),m.jsxs(os,{end:!0,children:[t.map(i=>m.jsxs(Ne,{active:i===n,onClick:()=>r(i),children:[m.jsx("b",{children:i})," items per page"]},i)),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{disabled:n===1/0,onClick:()=>r(1/0),children:m.jsx("i",{children:"Clear pagination"})})]})]}),j4=e=>e.startsWith("hidden_"),$$e=({stats:e,prevStats:t,highlightedStats:n,highlightedLabel:r,max:i,onClick:o,dimensions:a})=>{const s=M.useMemo(()=>Object.entries(e).map(([d,p])=>{const v=(n==null?void 0:n[d])??0,y=(t==null?void 0:t[d])??0,g=j4(d);return{name:d,amount:Math.max(p,y),nonHighlightedAmount:g?null:p-v,highlightedAmount:g?null:v,prevAmount:g?null:y}}),[e,t,n]),l=M.useMemo(()=>{const d=s.reduce((p,{name:v})=>p>v.length?p:v.length,0);return Math.min(150,d*7)},[s]),c=a?M.Fragment:wE,f=M.useMemo(()=>a?{}:{width:"100%",height:Math.max(300,s.length*(t?44:22))},[a,s.length,t]);return m.jsx(c,{...f,children:m.jsxs(dMe,{layout:"vertical",data:s,barCategoryGap:3,...a,children:[m.jsx(Ju,{type:"number",dataKey:"amount",tickFormatter:qt,domain:i?[0,i]:void 0}),m.jsx(ef,{type:"category",dataKey:"name",width:l,interval:0,style:{fontSize:".8rem"},tickFormatter:d=>j4(d)?"":d}),m.jsx(iC,{strokeOpacity:ap()?.05:.9}),m.jsx(Yr,{filterNull:!0,...kU,formatter:(d,p)=>[qt(d),p==="highlightedAmount"?r:p==="prevAmount"?"Previous period":n?"Non-selected":"Visits"]}),m.jsx(Lo,{dataKey:"nonHighlightedAmount",stackId:"main",cursor:"pointer",fill:nh,onClick:({name:d})=>o==null?void 0:o(d),children:s.map(d=>m.jsx(Fa,{fill:Zre,stroke:nh,strokeWidth:2},d.name))}),n&&m.jsx(Lo,{dataKey:"highlightedAmount",stackId:"main",cursor:"pointer",fill:e2,onClick:({name:d})=>o==null?void 0:o(d),children:s.map(d=>m.jsx(Fa,{fill:Xre,stroke:e2,strokeWidth:2},d.name))}),t&&m.jsx(Lo,{dataKey:"prevAmount",fill:Cy(),children:s.map(d=>m.jsx(Fa,{fill:O$e(),stroke:Cy(),strokeWidth:2},d.name))})]})})},I$e=e=>typeof e=="string"?e.toLowerCase():e,D$e=([e])=>e,F$e=([,e])=>e,Mm=({stats:e,prevStats:t,highlightedStats:n,title:r,sortingItems:i,extraHeaderContent:o,withPagination:a=!0,...s})=>{const[l,c]=M.useState({}),[f,d]=M.useState(1),[p,v]=M.useState(50),y=M.useCallback((j,F)=>{const k=Object.entries(j),I=l.field?toe(k,([D,K])=>I$e(l.field===Object.keys(F)[0]?D:K)):k;return!l.dir||l.dir==="ASC"?I:[...I].reverse()},[l.dir,l.field]),g=M.useCallback(j=>{const F=j[f-1];if(f[`hidden_${I}`,0])]},[f]),x=M.useCallback(j=>m.jsx(EC,{currentPage:f,pagesCount:j,setCurrentPage:d}),[f]),_=M.useCallback((j,F,k,I)=>{const D=y(j,F),K=D.map(D$e),W=k&&Object.entries({...S3(K,K.map(()=>0)),...k}),X=I&&Object.entries({...S3(K,K.map(()=>0)),...I});if(D.length<=p)return{currentPageStats:Object.fromEntries(D),currentPageHighlightedStats:W&&Object.fromEntries(W),currentPagePrevStats:X&&Object.fromEntries(X)};const Q=Ac(D,p),te=W&&Ac(W,p),Z=X&&Ac(X,p);return{currentPageStats:Object.fromEntries(g(Q)),currentPageHighlightedStats:te&&Object.fromEntries(g(te)),currentPagePrevStats:Z&&Object.fromEntries(g(Z)),pagination:x(Q.length),max:$Le(Math.max(...D.map(F$e)))}},[g,y,p,x]),{currentPageStats:b,currentPagePrevStats:w,currentPageHighlightedStats:S,pagination:P,max:E}=M.useMemo(()=>_(e,i,n&&Object.keys(n).length>0?n:void 0,t&&Object.keys(t).length>0?t:void 0),[_,n,t,i,e]),T=M.useMemo(()=>Object.keys(b),[b]);return m.jsx(jU,{title:m.jsxs(gb,{children:[r,m.jsxs("div",{className:"d-flex gap-3",children:[o==null?void 0:o(P?T:void 0),a&&Object.keys(e).length>50&&m.jsx(R$e,{toggleClassName:"btn-sm p-0",ranges:[50,100,200,500],value:p,setValue:j=>{v(j),d(1)}}),m.jsx(op,{isButton:!1,right:!0,items:i,order:l,onChange:(j,F)=>{c({field:j,dir:F}),d(1)}})]})]}),footer:P,children:m.jsx($$e,{stats:b,prevStats:w,highlightedStats:S,max:E,...s})})},A4=(e,t)=>{if(!(!t||!(e in t)))return t[e]&&Qa(t[e])||""},RU=()=>{const e=po(),t=$u(),{startDate:n,endDate:r,orphanVisitsType:i,excludeBots:o,loadPrevInterval:a,...s}=t,l=M.useMemo(()=>({dateRange:n!=null||r!=null?dB(n,r):void 0,visitsFilter:{orphanVisitsType:i,excludeBots:o!==void 0?o==="true":void 0},loadPrevInterval:a!==void 0?a==="true":void 0}),[r,o,a,i,n]),c=M.useCallback(f=>{const{dateRange:d,visitsFilter:p={},loadPrevInterval:v}=p0(l,f),{excludeBots:y,orphanVisitsType:g}=p,x={...s,startDate:A4("startDate",d),endDate:A4("endDate",d),excludeBots:y===void 0?void 0:KO(y),orphanVisitsType:g,loadPrevInterval:v===void 0?void 0:KO(v)},_=s0(x),b=_?`?${_}`:"";e(b,{replace:!0,relative:"route"})},[l,e,s]);return[l,c]},B$e=()=>m.jsx(jMe,{attribution:'© OpenStreetMap contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),U$e=e=>{if(e.length===0)return{};if(e.length>1)return{bounds:e.map(({latLong:n})=>n)};const[{latLong:t}]=e;return{zoom:10,center:t}},$U=({toggle:e,isOpen:t,title:n,locations:r=[]})=>m.jsx(vr,{toggle:e,isOpen:t,className:"map-modal__modal",contentClassName:"map-modal__modal-content",children:m.jsxs(Li,{className:"map-modal__modal-body",children:[m.jsxs(gb,{className:"map-modal__modal-title fs-4",children:[n,m.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:e})]}),m.jsxs(EMe,{...U$e(r),children:[m.jsx(B$e,{}),r.map(({cityName:i,latLong:o,count:a},s)=>m.jsx(CMe,{position:o,children:m.jsxs(TMe,{children:[m.jsx("b",{children:a})," visit",a>1?"s":""," from ",m.jsx("b",{children:i})]})},s))]})]})}),z$e=({modalTitle:e,activeCities:t,locations:n=[]})=>{const[r,,i,o]=Lt(),[a,s]=Lt(),[l,c]=M.useState([]),f=M.useCallback(d=>{c(d?n.filter(d):n),i()},[n,i]);return m.jsxs(m.Fragment,{children:[!t&&m.jsx(qe,{color:"link",className:"p-0",onClick:()=>f(),"aria-label":"Show in map",title:"Show in map",children:m.jsx(je,{icon:bx})}),t&&m.jsxs(is,{isOpen:a,toggle:s,children:[m.jsx(Jo,{color:"link",className:"p-0",title:"Show in map",children:m.jsx(je,{icon:bx})}),m.jsxs(os,{end:!0,children:[m.jsx(Ne,{onClick:()=>f(),children:"Show all locations"}),m.jsx(Ne,{onClick:()=>f(({cityName:d})=>t.includes(d)),children:"Show locations in current page"})]})]}),m.jsx($U,{toggle:o,isOpen:r,title:e,locations:l})]})},IU=({onChange:e,selected:t={},className:n,isOrphanVisits:r=!1,withPrevInterval:i=!1,disabled:o})=>{const{orphanVisitsType:a,excludeBots:s=!1,loadPrevInterval:l=!1}=t,c=p=>({active:a===p,onClick:()=>e({...t,orphanVisitsType:p===a?void 0:p})}),f=M.useCallback(()=>e({...t,excludeBots:!s}),[s,e,t]),d=M.useCallback(()=>e({...t,loadPrevInterval:!l}),[l,e,t]);return m.jsxs(ea,{disabled:o,text:"More",dropdownClassName:n,end:!0,minWidth:250,children:[i&&m.jsxs(m.Fragment,{children:[m.jsx(Ne,{active:l,onClick:d,children:"Compare with previous period"}),m.jsx(Ne,{divider:!0,tag:"hr"})]}),m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Bots:"}),m.jsx(Ne,{active:s,onClick:f,children:"Exclude potential bots"}),r&&m.jsxs(m.Fragment,{children:[m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{header:!0,"aria-hidden":!0,children:"Orphan visits type:"}),m.jsx(Ne,{...c("base_url"),children:"Base URL"}),m.jsx(Ne,{...c("invalid_short_url"),children:"Invalid short URL"}),m.jsx(Ne,{...c("regular_404"),children:"Regular 404"})]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsx(Ne,{disabled:t.excludeBots===void 0&&t.loadPrevInterval===void 0&&t.orphanVisitsType===void 0,onClick:()=>e({excludeBots:void 0,loadPrevInterval:void 0,orphanVisitsType:void 0}),children:m.jsx("i",{children:"Reset to defaults"})})]})},DU=({info:e})=>{const{loading:t,errorData:n,progress:r}=e;return m.jsxs(m.Fragment,{children:[t&&r===null&&m.jsx(zo,{loading:!0}),t&&r!==null&&m.jsxs(zo,{loading:!0,children:["This is going to take a while... :S",m.jsx(rD,{value:r,striped:r>=100,className:"mt-3"})]}),n&&m.jsx(Zn,{type:"error",children:m.jsx(ho,{errorData:n,fallbackMessage:"An error occurred while loading visits :("})})]})},av=({children:e,showFallback:t})=>m.jsxs(m.Fragment,{children:[t&&m.jsx(zo,{className:"mt-3",children:"There are no visits matching current filter"}),!t&&m.jsx(m.Fragment,{children:e})]}),V$e=({visitsDeletion:e,deleteVisits:t})=>{const{deleting:n}=e,[r,,i]=Lt();return m.jsx(gt,{title:m.jsx("span",{className:"text-danger fw-bold",children:"Danger zone"}),children:m.jsxs(gb,{children:[m.jsxs("dl",{className:"m-0 me-3",children:[m.jsx("dt",{children:"Delete visits."}),m.jsxs("dd",{className:"m-0",children:["This will delete ",m.jsx("b",{children:"all"})," visits, not only the ones matching current filter."]})]}),!r&&m.jsx(qe,{color:"danger",className:"indivisible",onClick:i,children:"Delete visits"}),r&&m.jsxs(qe,{color:"danger",disabled:n,className:"indivisible",onClick:t,innerRef:o=>{o==null||o.focus()},children:[!n&&m.jsx(m.Fragment,{children:"Click again to confirm"}),n&&m.jsx(m.Fragment,{children:"Deleting..."})]})]})})},Lm="Others",W$e=["Android Browser","Chrome","Chromium","Firefox","Internet Explorer","Microsoft Edge","Opera","Safari","Samsung Internet for Android","Vivaldi","WeChat"],H$e=e=>{if(!Rs(e))return{browser:Lm,os:Lm};const{browser:{name:t},os:{name:n}}=RMe.parse(e);return{os:n??Lm,browser:t&&W$e.includes(t)?t:Lm}},G$e=e=>{var t;return Rs(e)?((t=e.split("/")[e.includes("://")?2:0])==null?void 0:t.split(":")[0])??"":"Direct"},FU=(e,t)=>e[t]!==void 0,k4=e=>typeof e=="number"?e:e?parseFloat(e):0,q$e=(e,{os:t})=>{e[t]=(e[t]||0)+1},K$e=(e,{browser:t})=>{e[t]=(e[t]||0)+1},Y$e=(e,{referer:t})=>{e[t]=(e[t]||0)+1},BU=e=>(t,n)=>{const r=FU(n,e)?n[e]:"Unknown";t[r]=(t[r]||0)+1},Z$e=BU("country"),X$e=BU("city"),Q$e=(e,t)=>{if(!FU(t,"city")||t.city==="Unknown")return;const{city:n,latitude:r,longitude:i}=t,o=e[n]||{cityName:n,count:0,latLong:[k4(r),k4(i)]};o.count+=1,e[n]=o},J$e=(e,t)=>{if(!QMe(t))return;const{visitedUrl:n}=t;e[n]=(e[n]||0)+1},eS=e=>e.reduce((t,n)=>(q$e(t.os,n),K$e(t.browsers,n),Y$e(t.referrers,n),Z$e(t.countries,n),X$e(t.cities,n),Q$e(t.citiesForMap,n),J$e(t.visitedUrls,n),t),{os:{},browsers:{},referrers:{},countries:{},cities:{},citiesForMap:{},visitedUrls:{}}),Ty=e=>e.map(t=>{const{userAgent:n,date:r,referer:i,visitLocation:o,potentialBot:a}=t;return{date:r,potentialBot:a,userAgent:n,...H$e(n),referer:G$e(i),country:(o==null?void 0:o.countryName)||"Unknown",city:(o==null?void 0:o.cityName)||"Unknown",latitude:o==null?void 0:o.latitude,longitude:o==null?void 0:o.longitude,visitedUrl:t.visitedUrl,type:gC(t)?t.type:void 0}}),e6e=Object.freeze(Object.defineProperty({__proto__:null,normalizeVisits:Ty,processStatsFromVisits:eS},Symbol.toStringTag,{value:"Module"})),Jf=20,t6e=({browser:e,os:t,referer:n,country:r,city:i,userAgent:o,...a},s,l)=>{const c=l?o:`${r} ${i}`;return`${e} ${t} ${n} ${c} ${a.visitedUrl}`.toLowerCase().includes(s.toLowerCase())},n6e=(e,t,n)=>t.filter(r=>t6e(r,e,n)),r6e=(e,t)=>vD(t,e),i6e=({visits:e,searchTerm:t,order:n,searchInRawUserAgent:r})=>{const i=t?n6e(t,e,r):[...e],o=r6e(n,i),a=o.length;return{visitsGroups:Ac(o,Jf),total:a}},Gi="visits-table__header-cell visits-table__sticky",o6e=({visits:e,selectedVisits:t=[],setSelectedVisits:n,matchMedia:r=window.matchMedia})=>{var i;const o=_C(767,r),[a,s]=M.useState(),l=M.useCallback(j=>{s(j),x(1),n([])},[n]),[c,f]=M.useState({}),[d,p]=Lt(),v=M.useCallback(()=>{p(),f({})},[p]),y=M.useMemo(()=>i6e({visits:e,searchTerm:a,order:c,searchInRawUserAgent:d}),[e,a,c,d]),[g,x]=M.useState(1),_=g*Jf,b=_-Jf,w=M.useMemo(()=>{var j,F;return!!((F=(j=y.visitsGroups[g-1])==null?void 0:j[0])!=null&&F.visitedUrl)},[g,y.visitsGroups]),S=6+Number(w)+(d?1:2),P=y.total>0,E=j=>f({field:j,dir:c0(j,c.field,c.dir)}),T=j=>m.jsx(Cd,{currentOrder:c,field:j,className:"visits-table__header-icon"});return m.jsx(gt,{className:"mt-3",bodyClassName:"p-0 pb-1",title:m.jsxs("div",{className:"d-flex justify-content-between align-items-center",children:["Visits list",m.jsx(Vo,{checked:d,onChange:v,children:"Show user agent"})]}),children:m.jsx("div",{className:"table-responsive-md",children:m.jsxs("table",{className:Oe("table table-sm position-relative m-0 visits-table",{"table-hover":P}),children:[m.jsxs("thead",{className:"visits-table__header",children:[m.jsxs("tr",{children:[m.jsxs("th",{className:`${Gi} text-center`,onClick:()=>n(t.length0})})]}),m.jsxs("th",{className:`${Gi} text-center`,onClick:()=>E("potentialBot"),children:[m.jsx("span",{className:"sr-only",children:"Is bot"}),m.jsx(je,{icon:iA}),T("potentialBot")]}),m.jsxs("th",{className:Gi,onClick:()=>E("date"),children:["Date",T("date")]}),m.jsxs("th",{className:Gi,onClick:()=>E("country"),children:["Country",T("country")]}),m.jsxs("th",{className:Gi,onClick:()=>E("city"),children:["City",T("city")]}),d?m.jsxs("th",{className:Gi,onClick:()=>E("userAgent"),children:["User agent",T("userAgent")]}):m.jsxs(m.Fragment,{children:[m.jsxs("th",{className:Gi,onClick:()=>E("browser"),children:["Browser",T("browser")]}),m.jsxs("th",{className:Gi,onClick:()=>E("os"),children:["OS",T("os")]})]}),m.jsxs("th",{className:Gi,onClick:()=>E("referer"),children:["Referrer",T("referer")]}),w&&m.jsxs("th",{className:Gi,onClick:()=>E("visitedUrl"),children:["Visited URL",T("visitedUrl")]})]}),m.jsx("tr",{children:m.jsx("td",{colSpan:S,className:"p-0",children:m.jsx(ip,{noBorder:!0,large:!1,onChange:l})})})]}),m.jsxs("tbody",{children:[!P&&m.jsx("tr",{children:m.jsx("td",{colSpan:S,className:"text-center",children:"There are no visits matching current filter"})}),(i=y.visitsGroups[g-1])==null?void 0:i.map((j,F)=>{const k=t.includes(j);return m.jsxs("tr",{style:{cursor:"pointer"},className:Oe({"table-active":k}),onClick:()=>n(k?t.filter(I=>I!==j):[...t,j]),children:[m.jsx("td",{className:"text-center",children:k&&m.jsx(je,{icon:qd,className:"text-primary"})}),m.jsx("td",{className:"text-center",children:j.potentialBot&&m.jsxs(m.Fragment,{children:[m.jsx(je,{icon:iA,id:`botIcon${F}`}),m.jsx(Fr,{placement:"right",target:`botIcon${F}`,children:"Potentially a visit from a bot or crawler"})]})}),m.jsx("td",{children:m.jsx(Py,{date:j.date})}),m.jsx("td",{children:j.country}),m.jsx("td",{children:j.city}),d?m.jsx("td",{children:j.userAgent}):m.jsxs(m.Fragment,{children:[m.jsx("td",{children:j.browser}),m.jsx("td",{children:j.os})]}),m.jsx("td",{children:j.referer}),j.visitedUrl&&m.jsx("td",{children:j.visitedUrl})]},F)})]}),y.total>Jf&&m.jsx("tfoot",{children:m.jsx("tr",{children:m.jsx("td",{colSpan:S,className:"visits-table__footer-cell visits-table__sticky",children:m.jsxs("div",{className:"d-flex flex-column flex-md-row justify-content-between align-items-center gap-3 p-2",children:[m.jsx(EC,{pagesCount:Math.ceil(y.total/Jf),currentPage:g,setCurrentPage:x,centered:o}),m.jsxs("div",{children:["Visits ",m.jsx("b",{children:qt(b+1)})," to"," ",m.jsx("b",{children:qt(Math.min(_,y.total))})," of"," ",m.jsx("b",{children:qt(y.total)})]})]})})})})]})})})},pa={byTime:{title:"By time",subPath:"by-time",icon:Qq},byContext:{title:"By context",subPath:"by-context",icon:lP},byLocation:{title:"By location",subPath:"by-location",icon:bx},list:{title:"List",subPath:"list",icon:L6},options:{title:"Options",subPath:"options",icon:F6,shouldRender:({deletion:e})=>!!e}};Object.freeze(pa);const __=({display:e})=>e&&m.jsx("div",{className:"mt-3 mx-auto w-75",children:m.jsx(gt,{children:m.jsxs("div",{className:"d-flex gap-2",children:[m.jsx(je,{icon:ZK,className:"mt-1"}),m.jsx("i",{children:"Could not calculate previous period because selected one does not have a strictly defined start date."})]})})});let Rm;const Sp=e=>{const{children:t,visitsInfo:n,getVisits:r,cancelGetVisits:i,deletion:o,exportCsv:a,isOrphanVisits:s=!1}=e,{visits:l,prevVisits:c,loading:f,errorData:d,fallbackInterval:p}=n,[{dateRange:v,visitsFilter:y,loadPrevInterval:g},x]=RU(),_=nr("visits"),[b,w]=M.useState(),S=M.useCallback(({startDate:A,endDate:N},U)=>{x({dateRange:{startDate:A??void 0,endDate:N??void 0}}),w(U)},[x]),P=M.useRef(v??p??(_==null?void 0:_.defaultInterval)??"last30Days"),[E,T]=M.useState([]),[j,F]=M.useState(),k=M.useRef(!0),{search:I}=pr(),D=M.useCallback(A=>A?`${A}${I}`:I,[I]),K=M.useMemo(()=>Ty(l),[l]),W=M.useMemo(()=>c&&Ty(c),[c]),{os:X,browsers:Q,referrers:te,countries:Z,cities:z,citiesForMap:B,visitedUrls:H}=M.useMemo(()=>eS(K),[K]),ee=M.useMemo(()=>eS(W??[]),[W]),q=M.useMemo(()=>Object.fromEntries([["Visits",Object.assign(K,{type:"main"})],W&&["Previous period",Object.assign(W,{type:"previous"})],E.length>0&&[j??"Selected",Object.assign(E,{type:"highlighted"})]].filter(Boolean)),[j,E,W,K]),ne=M.useMemo(()=>({...y,excludeBots:y.excludeBots??(_==null?void 0:_.excludeBots),loadPrevInterval:g??(_==null?void 0:_.loadPrevInterval)}),[g,y,_==null?void 0:_.excludeBots,_==null?void 0:_.loadPrevInterval]),re=M.useMemo(()=>Object.values(B),[B]),ae=M.useCallback(A=>{Rm=void 0,T(A)},[]),ue=M.useCallback((A,N)=>{const U=`${A}_${N}`;Rm===U?(T([]),F(void 0),Rm=void 0):(T(K.filter(J=>J[A]===N)),F(N),Rm=U)},[K]);return M.useEffect(()=>i,[i]),M.useEffect(()=>{const A=v??mB(P.current),{loadPrevInterval:N,...U}=ne,J={doIntervalFallback:k.current,loadPrevInterval:N};r({dateRange:A,filter:U},J),ae([]),k.current=!1},[v,y,r,ne,ae]),M.useEffect(()=>{p&&P.current===((_==null?void 0:_.defaultInterval)??"last30Days")&&(P.current=p)},[p,_==null?void 0:_.defaultInterval]),m.jsxs(m.Fragment,{children:[t,m.jsx("section",{className:"mt-3",children:m.jsxs("div",{className:"row flex-md-row-reverse",children:[m.jsx("div",{className:"col-lg-7 col-xl-6",children:m.jsxs("div",{className:"d-md-flex",children:[m.jsx("div",{className:"flex-grow-1",children:m.jsx(OC,{disabled:f,dateRangeOrInterval:b??v??P.current,defaultText:"All visits",onDatesChange:S})}),m.jsx(IU,{disabled:f,className:"ms-0 ms-md-2 mt-3 mt-md-0",isOrphanVisits:s,withPrevInterval:!0,selected:ne,onChange:({loadPrevInterval:A,...N})=>x({visitsFilter:N,loadPrevInterval:A})})]})}),l.length>0&&m.jsx("div",{className:"col-lg-5 col-xl-6 mt-3 mt-lg-0",children:m.jsxs("div",{className:"d-flex",children:[m.jsx(JB,{className:"btn-md-block",amount:K.length,onClick:()=>a(K)}),m.jsxs(qe,{outline:!0,disabled:E.length===0,className:"btn-md-block ms-2",onClick:()=>ae([]),children:["Clear selection ",E.length>0&&m.jsxs(m.Fragment,{children:["(",qt(E.length),")"]})]})]})})]})}),m.jsxs("section",{className:"mt-3",children:[m.jsx(DU,{info:n}),!f&&!d&&m.jsxs(m.Fragment,{children:[m.jsx(mD,{fill:!0,children:Object.values(pa).map(({title:A,icon:N,subPath:U,shouldRender:J},Y)=>!J||J(e)?m.jsxs(md,{to:D(U),replace:!0,children:[m.jsx(je,{icon:N}),m.jsx("span",{className:"ms-2 d-none d-lg-inline",children:A})]},Y):void 0).filter(Boolean)}),m.jsx(Pr,{children:m.jsxs(Xy,{children:[m.jsx(ot,{path:pa.byTime.subPath,element:m.jsxs(av,{showFallback:l.length===0,children:[m.jsx("div",{className:"col-12 mt-3","data-testid":"line-chart-container",children:m.jsx(LU,{visitsGroups:q,setSelectedVisits:ae,onDateRangeChange:S})}),m.jsx(__,{display:!!ne.loadPrevInterval&&!c})]})}),m.jsx(ot,{path:pa.byContext.subPath,element:m.jsxs(av,{showFallback:l.length===0,children:[m.jsx("div",{className:Oe("mt-3 col-lg-6",{"col-xl-4":!s}),children:m.jsx(E4,{title:"Operating systems",stats:X,prevStats:ee.os})}),m.jsx("div",{className:Oe("mt-3 col-lg-6",{"col-xl-4":!s}),children:m.jsx(E4,{title:"Browsers",stats:Q,prevStats:ee.browsers})}),m.jsx("div",{className:Oe("mt-3",{"col-xl-4":!s,"col-lg-6":s}),children:m.jsx(Mm,{title:"Referrers",withPagination:!1,stats:te,prevStats:ee.referrers,highlightedStats:jm(E,"referer"),highlightedLabel:j,sortingItems:{name:"Referrer name",amount:"Visits amount"},onClick:A=>ue("referer",A)})}),s&&m.jsx("div",{className:"mt-3 col-lg-6",children:m.jsx(Mm,{title:"Visited URLs",stats:H,prevStats:ee.visitedUrls,highlightedStats:jm(E,"visitedUrl"),highlightedLabel:j,sortingItems:{visitedUrl:"Visited URL",amount:"Visits amount"},onClick:A=>ue("visitedUrl",A)})}),m.jsx("div",{className:"col-12",children:m.jsx(__,{display:!!ne.loadPrevInterval&&!c})})]})}),m.jsx(ot,{path:pa.byLocation.subPath,element:m.jsxs(av,{showFallback:l.length===0,children:[m.jsx("div",{className:"col-lg-6 mt-3",children:m.jsx(Mm,{title:"Countries",stats:Z,prevStats:ee.countries,highlightedStats:jm(E,"country"),highlightedLabel:j,sortingItems:{name:"Country name",amount:"Visits amount"},onClick:A=>ue("country",A)})}),m.jsx("div",{className:"col-lg-6 mt-3",children:m.jsx(Mm,{title:"Cities",stats:z,prevStats:ee.cities,highlightedStats:jm(E,"city"),highlightedLabel:j,extraHeaderContent:A=>re.length>0&&m.jsx(z$e,{modalTitle:"Cities",locations:re,activeCities:A}),sortingItems:{name:"City name",amount:"Visits amount"},onClick:A=>ue("city",A)})}),m.jsx("div",{className:"col-12",children:m.jsx(__,{display:!!ne.loadPrevInterval&&!c})})]})}),m.jsx(ot,{path:pa.list.subPath,element:m.jsx("div",{className:"col-12",children:m.jsx(o6e,{visits:K,selectedVisits:E,setSelectedVisits:ae})})}),o&&m.jsx(ot,{path:pa.options.subPath,element:m.jsx("div",{className:"col-12 mt-3",children:m.jsx(V$e,{...o})})}),m.jsx(ot,{path:"*",element:m.jsx(eP,{replace:!0,to:D(pa.byTime.subPath)})})]})})]})]})]})},UU=Di(({getDomainVisits:e,domainVisits:t,cancelGetDomainVisits:n})=>{const{ReportExporter:r}=Rt(UU),{domain:i=""}=Mu(),[o,a=o]=i.split("_"),s=M.useCallback((c,f)=>e({domain:a,options:f,params:c}),[a,e]),l=M.useCallback(c=>r.exportVisits(`domain_${o}_visits.csv`,c),[o,r]);return m.jsx(Sp,{getVisits:s,cancelGetVisits:n,visitsInfo:t,exportCsv:l,children:m.jsx(Op,{visits:t.visits,title:`"${o}" visits`})})},()=>[Jn.visits]),a6e=$t(UU,["ReportExporter"]),zU=Di(({getNonOrphanVisits:e,nonOrphanVisits:t,cancelGetNonOrphanVisits:n})=>{const{ReportExporter:r}=Rt(zU),i=M.useCallback(a=>r.exportVisits("non_orphan_visits.csv",a),[r]),o=M.useCallback((a,s)=>e({options:s,params:a}),[e]);return m.jsx(Sp,{getVisits:o,cancelGetVisits:n,visitsInfo:t,exportCsv:i,children:m.jsx(Op,{title:"Non-orphan visits",visits:t.visits})})},()=>[Jn.visits]),s6e=$t(zU,["ReportExporter"]),VU=Di(({getOrphanVisits:e,orphanVisits:t,cancelGetOrphanVisits:n,deleteOrphanVisits:r,orphanVisitsDeletion:i})=>{const o=Ko("orphanVisitsDeletion"),{ReportExporter:a}=Rt(VU),s=M.useCallback(f=>a.exportVisits("orphan_visits.csv",f),[a]),l=M.useCallback((f,d)=>{var p;return e({options:d,params:f,orphanVisitsType:(p=f.filter)==null?void 0:p.orphanVisitsType})},[e]),c=M.useMemo(()=>o?{deleteVisits:r,visitsDeletion:i}:void 0,[r,i,o]);return m.jsx(Sp,{getVisits:l,cancelGetVisits:n,visitsInfo:t,exportCsv:s,deletion:c,isOrphanVisits:!0,children:m.jsx(Op,{title:"Orphan visits",visits:t.visits})})},()=>[Jn.orphanVisits]),l6e=$t(VU,["ReportExporter"]),WU="shlink/orphanVisits",c6e={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},u6e=e=>_p({typePrefix:`${WU}/getNonOrphanVisits`,createLoaders:({options:t})=>{const n=e(),{doIntervalFallback:r=!1}=t,i=async a=>n.getNonOrphanVisits(a),o=bp(r,a=>n.getNonOrphanVisits(a));return{visitsLoader:i,lastVisitLoader:o}},shouldCancel:t=>t().orphanVisits.cancelLoad}),f6e=e=>xp({name:WU,initialState:c6e,asyncThunkCreator:e,filterCreatedVisits:({params:t},n)=>{const{startDate:r,endDate:i}=(t==null?void 0:t.dateRange)??{};return n.filter(({visit:o})=>yp(o.date,r,i))}}),HU="shlink/orphanVisits",d6e={visits:[],loading:!1,cancelLoad:!1,errorData:null,progress:null},h6e=(e,t)=>!t||t===e.type,p6e=({data:e,...t},n)=>{const r=e.filter(i=>gC(i)&&h6e(i,n));return{...t,data:r}},m6e=e=>_p({typePrefix:`${HU}/getOrphanVisits`,createLoaders:({orphanVisitsType:t,options:n})=>{const r=e(),{doIntervalFallback:i=!1}=n,o=async s=>r.getOrphanVisits({...s,type:t}).then(l=>p6e(l,t)),a=bp(i,s=>r.getOrphanVisits(s));return{visitsLoader:o,lastVisitLoader:a}},shouldCancel:t=>t().orphanVisits.cancelLoad}),v6e=(e,t)=>xp({name:HU,initialState:d6e,asyncThunkCreator:e,extraReducers:n=>{n.addCase(t.fulfilled,r=>({...r,visits:[]}))},filterCreatedVisits:({params:n},r)=>{const{startDate:i,endDate:o}=(n==null?void 0:n.dateRange)??{};return r.filter(({visit:a,shortUrl:s})=>!s&&yp(a.date,i,o))}}),GU="shlink/orphanVisitsDeletion",N4={deletedVisits:0,deleting:!1,error:!1},g6e=e=>fn(`${GU}/deleteOrphanVisits`,()=>e().deleteOrphanVisits()),y6e=e=>Qt({name:GU,initialState:N4,reducers:{},extraReducers:t=>{t.addCase(e.pending,n=>({...n,deleting:!0,error:!1})),t.addCase(e.rejected,(n,{error:r})=>({...n,deleting:!1,error:!0,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>{const{deletedVisits:i}=r;return{...N4,deletedVisits:i}})}}),qU="shlink/shortUrlVisits",b6e={visits:[],shortCode:"",loading:!1,errorData:null,cancelLoad:!1,progress:null},_6e=e=>_p({typePrefix:`${qU}/getShortUrlVisits`,createLoaders:({shortCode:t,domain:n,options:r})=>{const i=e(),{doIntervalFallback:o=!1}=r,a=l=>i.getShortUrlVisits(t,{...l,domain:n}),s=bp(o,l=>i.getShortUrlVisits(t,{...l,domain:n}));return{visitsLoader:a,lastVisitLoader:s}},shouldCancel:t=>t().shortUrlVisits.cancelLoad}),x6e=(e,t)=>xp({name:qU,initialState:b6e,asyncThunkCreator:e,extraReducers:n=>{n.addCase(t.fulfilled,(r,{payload:i})=>r.shortCode===i.shortCode&&r.domain===i.domain?{...r,visits:[]}:r)},filterCreatedVisits:({shortCode:n,domain:r,params:i},o)=>gB(o,{shortCode:n,domain:r},i==null?void 0:i.dateRange)}),KU="shlink/shortUrlVisitsDeletion",M4={shortCode:"",deletedVisits:0,deleting:!1,error:!1},w6e=e=>fn(`${KU}/deleteShortUrlVisits`,async({shortCode:t,domain:n})=>({...await e().deleteShortUrlVisits(t,n),shortCode:t,domain:n})),O6e=e=>Qt({name:KU,initialState:M4,reducers:{},extraReducers:t=>{t.addCase(e.pending,n=>({...n,deleting:!0,error:!1})),t.addCase(e.rejected,(n,{error:r})=>({...n,deleting:!1,error:!0,errorData:Br(r)})),t.addCase(e.fulfilled,(n,{payload:r})=>{const{shortCode:i,domain:o,deletedVisits:a}=r;return{...M4,shortCode:i,domain:o,deletedVisits:a}})}}),YU="shlink/tagVisits",S6e={visits:[],tag:"",loading:!1,cancelLoad:!1,errorData:null,progress:null},P6e=e=>_p({typePrefix:`${YU}/getTagVisits`,createLoaders:({tag:t,options:n})=>{const r=e(),{doIntervalFallback:i=!1}=n,o=s=>r.getTagVisits(t,s),a=bp(i,async s=>r.getTagVisits(t,s));return{visitsLoader:o,lastVisitLoader:a}},shouldCancel:t=>t().tagVisits.cancelLoad}),E6e=e=>xp({name:YU,initialState:S6e,asyncThunkCreator:e,filterCreatedVisits:({tag:t,params:n},r)=>bB(r,t,n==null?void 0:n.dateRange)}),ZU="shlink/visitsOverview",$m={nonOrphanVisits:{total:0},orphanVisits:{total:0},loading:!1,error:!1},L4=e=>e.filter(({visit:t})=>t.potentialBot).length,C6e=e=>fn(`${ZU}/loadVisitsOverview`,()=>e().getVisitsOverview().then(({nonOrphanVisits:t,visitsCount:n=0,orphanVisits:r,orphanVisitsCount:i=0})=>({nonOrphanVisits:{total:(t==null?void 0:t.total)??n,nonBots:t==null?void 0:t.nonBots,bots:t==null?void 0:t.bots},orphanVisits:{total:(r==null?void 0:r.total)??i,nonBots:r==null?void 0:r.nonBots,bots:r==null?void 0:r.bots}}))),T6e=e=>Qt({name:ZU,initialState:$m,reducers:{},extraReducers:t=>{t.addCase(e.pending,()=>({...$m,loading:!0})),t.addCase(e.rejected,()=>({...$m,error:!0})),t.addCase(e.fulfilled,(n,{payload:r})=>({...$m,...r})),t.addCase(tf,({nonOrphanVisits:n,orphanVisits:r,...i},{payload:o})=>{const{nonOrphanVisits:a,orphanVisits:s}=JMe(o.createdVisits),l=a.length,c=L4(a),f=l-c,d=s.length,p=L4(s),v=d-p;return{...i,nonOrphanVisits:{total:n.total+l,bots:n.bots&&n.bots+c,nonBots:n.nonBots&&n.nonBots+f},orphanVisits:{total:r.total+d,bots:r.bots&&r.bots+p,nonBots:r.nonBots&&r.nonBots+v}}})}}),j6e=({shortUrl:e,loading:t,shortUrlVisits:n})=>{const{visits:r}=n,i=(e==null?void 0:e.shortUrl)??"",o=(e==null?void 0:e.longUrl)??"",a=e==null?void 0:e.title;return m.jsxs(Op,{title:m.jsxs(m.Fragment,{children:["Visits for ",m.jsx(hr,{href:i})]}),visits:r,shortUrl:e,children:[m.jsx("hr",{}),m.jsxs("div",{children:["Created: ",e?m.jsxs("span",{children:[m.jsx("b",{id:"created",className:"short-url-visits-header__created-at",children:m.jsx(Py,{date:e.dateCreated,relative:!0})}),m.jsx(Fr,{placement:"bottom",target:"created",children:m.jsx(Py,{date:e.dateCreated})})]}):m.jsx("small",{children:"Loading..."})]}),m.jsxs("div",{className:"long-url-container",children:[`${a?"Title":"Long URL"}: `,t&&m.jsx("small",{children:"Loading..."}),!t&&m.jsx(hr,{href:o,children:a??o})]})]})},XU=Di(({shortUrlVisits:e,shortUrlVisitsDeletion:t,shortUrlsDetails:n,getShortUrlVisits:r,getShortUrlsDetails:i,deleteShortUrlVisits:o,cancelGetShortUrlVisits:a})=>{const s=Ko("shortUrlVisitsDeletion"),{ReportExporter:l}=Rt(XU),c=wC(),f=M.useMemo(()=>{var y;return(y=n.shortUrls)==null?void 0:y.get(c)},[c,n.shortUrls]),d=M.useCallback((y,g)=>r({...c,options:g,params:y}),[r,c]),p=M.useCallback(y=>l.exportVisits(`short-url_${f==null?void 0:f.shortUrl.replace(/https?:\/\//g,"")}_visits.csv`,y),[l,f==null?void 0:f.shortUrl]),v=M.useMemo(()=>s?{deleteVisits:()=>o(c),visitsDeletion:t}:void 0,[o,c,t,s]);return M.useEffect(()=>{i([c])},[c,i]),m.jsx(Sp,{getVisits:d,cancelGetVisits:a,visitsInfo:e,exportCsv:p,deletion:v,children:m.jsx(j6e,{shortUrl:f,loading:n.loading,shortUrlVisits:e})})},e=>e.shortCode?[Jn.shortUrlVisits(hC(e.shortCode))]:[]),A6e=$t(XU,["ReportExporter"]),k6e=({tagVisits:e,colorGenerator:t})=>{const{visits:n,tag:r}=e;return m.jsx(Op,{title:m.jsxs("span",{className:"d-flex align-items-center justify-content-center",children:[m.jsx("span",{className:"me-2",children:"Visits for"}),m.jsx(vb,{text:r,colorGenerator:t})]}),visits:n})},QU=Di(({getTagVisits:e,tagVisits:t,cancelGetTagVisits:n})=>{const{ColorGenerator:r,ReportExporter:i}=Rt(QU),{tag:o=""}=Mu(),a=M.useCallback((l,c)=>e({tag:o,params:l,options:c}),[e,o]),s=M.useCallback(l=>i.exportVisits(`tag_${o}_visits.csv`,l),[i,o]);return m.jsx(Sp,{getVisits:a,cancelGetVisits:n,visitsInfo:t,exportCsv:s,children:m.jsx(k6e,{tagVisits:t,colorGenerator:r})})},()=>[Jn.visits]),N6e=$t(QU,["ColorGenerator","ReportExporter"]),TC=({title:e,colors:t,getVisitsForComparison:n,visitsComparisonInfo:r,cancelGetVisitsComparison:i})=>{const{loading:o,visitsGroups:a}=r,s=nr("visits"),l=M.useMemo(()=>Object.keys(a).reduce((b,w,S)=>(b[w]=Object.assign(Ty(a[w]),{color:(t==null?void 0:t[w])??NU(S)}),b),{}),[t,a]),c=M.useMemo(()=>Object.values(a).every(b=>b.length===0),[a]),[{dateRange:f,visitsFilter:d},p]=RU(),[v,y]=M.useState(),g=M.useCallback(({startDate:b,endDate:w},S)=>{p({dateRange:{startDate:b??void 0,endDate:w??void 0}}),y(S)},[p]),x=M.useRef(f??(s==null?void 0:s.defaultInterval)??"last30Days"),_=M.useMemo(()=>({...d,excludeBots:d.excludeBots??(s==null?void 0:s.excludeBots)}),[d,s==null?void 0:s.excludeBots]);return M.useEffect(()=>{const b=f??mB(x.current);return n({params:{dateRange:b,filter:_}}),i},[i,f,n,_]),m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"mb-3",children:m.jsxs(gt,{bodyClassName:"d-flex",children:[m.jsx(mb,{}),m.jsx("h3",{className:"mb-0 flex-grow-1 text-center",children:e})]})}),m.jsx("div",{className:"col-lg-7 col-xl-6 offset-lg-5 offset-xl-6 mb-3",children:m.jsxs("div",{className:"d-md-flex",children:[m.jsx("div",{className:"flex-grow-1",children:m.jsx(OC,{disabled:o,defaultText:"All visits",dateRangeOrInterval:v??f??x.current,onDatesChange:g})}),m.jsx(IU,{disabled:o,className:"ms-0 ms-md-2 mt-3 mt-md-0",selected:_,onChange:({orphanVisitsType:b,excludeBots:w})=>p({visitsFilter:{orphanVisitsType:b,excludeBots:w}})})]})}),m.jsx(DU,{info:r}),!o&&m.jsx(av,{showFallback:c,children:m.jsx(LU,{visitsGroups:l,onDateRangeChange:g})})]})},M6e=Di(({getDomainVisitsForComparison:e,domainVisitsComparison:t,cancelGetDomainVisitsComparison:n})=>{const r=bC("domains"),i=M.useCallback(o=>e({...o,domains:r}),[r,e]);return m.jsx(TC,{title:`Comparing "${r.join('", "')}"`,getVisitsForComparison:i,visitsComparisonInfo:t,cancelGetVisitsComparison:n})},()=>[Jn.visits]),L6e=({visitsLoaders:e,shouldCancel:t,progressChanged:n})=>{const r=Object.keys(e),i=Math.max(1,Math.round(4/r.length)),o=Object.fromEntries(r.map(l=>[l,0])),a=(l,c)=>{o[l]=c;const f=Object.values(o),d=f.reduce((p,v)=>p+v,0);n(d/f.length)},s=Object.entries(e).map(([l,c])=>[l,_B({visitsLoader:c,batchSize:i,shouldCancel:t,progressChanged:f=>a(l,f)})]);return async l=>{const c=await Promise.all(s.map(async([f,d])=>{const p=await d(l);return[f,p]}));return Object.fromEntries(c)}},jC=({typePrefix:e,createLoaders:t,shouldCancel:n})=>{const r=Xn(`${e}/progressChanged`),i=fn(e,async(o,{getState:a,dispatch:s})=>{const l=t(o),c=await L6e({visitsLoaders:l,shouldCancel:()=>n(a),progressChanged:f=>s(r(f))})(qO(o.params));return{...o,visitsGroups:c}});return Object.assign(i,{progressChanged:r})},AC=({name:e,asyncThunkCreator:t,initialState:n,filterCreatedVisitsForGroup:r})=>{const{pending:i,rejected:o,fulfilled:a,progressChanged:s}=t,{reducer:l,actions:c}=Qt({name:e,initialState:n,reducers:{cancelGetVisits:d=>({...d,cancelLoad:!0})},extraReducers:d=>{d.addCase(i,()=>({...n,loading:!0})),d.addCase(o,(p,{error:v})=>({...n,errorData:Br(v)??null})),d.addCase(a,(p,{payload:v})=>({...p,...v,loading:!1,progress:null,errorData:null})),d.addCase(s,(p,{payload:v})=>({...p,progress:v})),d.addCase(tf,(p,{payload:v})=>{const{visitsGroups:y,...g}=p,x=Object.keys(y).map(b=>{const w=r({...g,groupKey:b},v.createdVisits).map(({visit:S})=>S);return[b,[...w,...y[b]]]}),_=Object.fromEntries(x);return{...g,visitsGroups:_}})}}),{cancelGetVisits:f}=c;return{reducer:l,cancelGetVisits:f}},JU="shlink/domainVisitsComparison",R6e={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},$6e=e=>jC({typePrefix:`${JU}/getDomainVisitsForComparison`,createLoaders:({domains:t})=>{const n=e(),r=t.map(i=>[i,o=>n.getDomainVisits(i,o)]);return Object.fromEntries(r)},shouldCancel:t=>t().domainVisitsComparison.cancelLoad}),I6e=e=>AC({name:JU,initialState:R6e,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:n},r)=>yB(r,t,n==null?void 0:n.dateRange)}),e9="shlink/shortUrlVisitsComparison",D6e={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},F6e=e=>jC({typePrefix:`${e9}/getShortUrlVisitsForComparison`,createLoaders:({shortUrls:t})=>{const n=e(),r=t.map(i=>[pC(i),o=>n.getShortUrlVisits(i.shortCode,{...o,domain:i.domain})]);return Object.fromEntries(r)},shouldCancel:t=>t().shortUrlVisitsComparison.cancelLoad}),B6e=e=>AC({name:e9,initialState:D6e,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:n},r)=>gB(r,lB(t),n==null?void 0:n.dateRange)}),t9="shlink/tagVisitsComparison",U6e={visitsGroups:{},loading:!1,cancelLoad:!1,errorData:null,progress:null},z6e=e=>jC({typePrefix:`${t9}/getTagVisitsForComparison`,createLoaders:({tags:t})=>{const n=e(),r=t.map(i=>[i,o=>n.getTagVisits(i,o)]);return Object.fromEntries(r)},shouldCancel:t=>t().tagVisitsComparison.cancelLoad}),V6e=e=>AC({name:t9,initialState:U6e,asyncThunkCreator:e,filterCreatedVisitsForGroup:({groupKey:t,params:n},r)=>bB(r,t,n==null?void 0:n.dateRange)}),W6e=Di(({getShortUrlVisitsForComparison:e,shortUrlVisitsComparison:t,cancelGetShortUrlVisitsComparison:n,shortUrlsDetails:r,getShortUrlsDetails:i})=>{const o=bC("short-urls"),a=M.useMemo(()=>o.map(lB),[o]),s=M.useCallback(f=>e({...f,shortUrls:a}),[e,a]),l=M.useMemo(()=>{var f;return[...((f=r.shortUrls)==null?void 0:f.values())??[]]},[r.shortUrls]),c=M.useMemo(()=>{const{visitsGroups:f,loading:d,...p}=t,v=l.reduce((y,g)=>(y[g.shortUrl]=f[pC(g)]??[],y),{});return{...p,visitsGroups:v,loading:d||r.loading}},[t,r.loading,l]);return M.useEffect(()=>{a.length>0&&i(a)},[i,a]),m.jsx(TC,{title:m.jsx("span",{"data-testid":"title",children:r.loading?"Loading...":`Comparing ${l.length} short URLs`}),getVisitsForComparison:s,visitsComparisonInfo:c,cancelGetVisitsComparison:n})},()=>[Jn.visits]),n9=Di(({getTagVisitsForComparison:e,tagVisitsComparison:t,cancelGetTagVisitsComparison:n})=>{const{ColorGenerator:r}=Rt(n9),i=bC("tags"),o=M.useCallback(l=>e({...l,tags:i}),[e,i]),{visitsGroups:a}=t,s=M.useMemo(()=>Object.keys(a).reduce((l,c)=>(l[c]=r.getColorForKey(c),l),{}),[r,a]);return m.jsx(TC,{title:m.jsxs(m.Fragment,{children:["Comparing ",i.map(l=>m.jsx(vb,{colorGenerator:r,text:l},l))]}),getVisitsForComparison:o,visitsComparisonInfo:t,cancelGetVisitsComparison:n,colors:s})},()=>[Jn.visits]),H6e=$t(n9,["ColorGenerator"]),G6e=(e,t)=>{const n=(r,i)=>t([...r,"mercureInfo"],[...i,"createNewVisits","loadMercureInfo"]);e.serviceFactory("MapModal",()=>$U),e.factory("ShortUrlVisits",A6e),e.decorator("ShortUrlVisits",t(["shortUrlVisits","shortUrlVisitsDeletion","shortUrlsDetails","mercureInfo"],["getShortUrlVisits","deleteShortUrlVisits","getShortUrlsDetails","cancelGetShortUrlVisits","createNewVisits","loadMercureInfo"])),e.factory("TagVisits",N6e),e.decorator("TagVisits",n(["tagVisits"],["getTagVisits","cancelGetTagVisits"])),e.factory("TagVisitsComparison",H6e),e.decorator("TagVisitsComparison",n(["tagVisitsComparison"],["getTagVisitsForComparison","cancelGetTagVisitsForComparison"])),e.serviceFactory("DomainVisitsComparison",()=>M6e),e.decorator("DomainVisitsComparison",n(["domainVisitsComparison"],["getDomainVisitsForComparison","cancelGetDomainVisitsForComparison"])),e.serviceFactory("ShortUrlVisitsComparison",()=>W6e),e.decorator("ShortUrlVisitsComparison",n(["shortUrlVisitsComparison","shortUrlsDetails"],["getShortUrlVisitsForComparison","cancelGetShortUrlVisitsForComparison","getShortUrlsDetails"])),e.factory("DomainVisits",a6e),e.decorator("DomainVisits",n(["domainVisits"],["getDomainVisits","cancelGetDomainVisits"])),e.factory("OrphanVisits",l6e),e.decorator("OrphanVisits",n(["orphanVisits","orphanVisitsDeletion"],["getOrphanVisits","cancelGetOrphanVisits","deleteOrphanVisits"])),e.factory("NonOrphanVisits",s6e),e.decorator("NonOrphanVisits",n(["nonOrphanVisits"],["getNonOrphanVisits","cancelGetNonOrphanVisits"])),e.serviceFactory("VisitsParser",()=>e6e),e.serviceFactory("getShortUrlVisits",_6e,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisits",r=>r.cancelGetVisits,"shortUrlVisitsReducerCreator"),e.serviceFactory("getShortUrlVisitsForComparison",F6e,"apiClientFactory"),e.serviceFactory("cancelGetShortUrlVisitsForComparison",r=>r.cancelGetVisits,"shortUrlVisitsComparisonReducerCreator"),e.serviceFactory("deleteShortUrlVisits",w6e,"apiClientFactory"),e.serviceFactory("getTagVisits",P6e,"apiClientFactory"),e.serviceFactory("cancelGetTagVisits",r=>r.cancelGetVisits,"tagVisitsReducerCreator"),e.serviceFactory("getTagVisitsForComparison",z6e,"apiClientFactory"),e.serviceFactory("cancelGetTagVisitsForComparison",r=>r.cancelGetVisits,"tagVisitsComparisonReducerCreator"),e.serviceFactory("getDomainVisits",lLe,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisits",r=>r.cancelGetVisits,"domainVisitsReducerCreator"),e.serviceFactory("getDomainVisitsForComparison",$6e,"apiClientFactory"),e.serviceFactory("cancelGetDomainVisitsForComparison",r=>r.cancelGetVisits,"domainVisitsComparisonReducerCreator"),e.serviceFactory("getOrphanVisits",m6e,"apiClientFactory"),e.serviceFactory("cancelGetOrphanVisits",r=>r.cancelGetVisits,"orphanVisitsReducerCreator"),e.serviceFactory("deleteOrphanVisits",g6e,"apiClientFactory"),e.serviceFactory("getNonOrphanVisits",u6e,"apiClientFactory"),e.serviceFactory("cancelGetNonOrphanVisits",r=>r.cancelGetVisits,"nonOrphanVisitsReducerCreator"),e.serviceFactory("createNewVisits",()=>tf),e.serviceFactory("loadVisitsOverview",C6e,"apiClientFactory"),e.serviceFactory("visitsOverviewReducerCreator",T6e,"loadVisitsOverview"),e.serviceFactory("visitsOverviewReducer",r=>r.reducer,"visitsOverviewReducerCreator"),e.serviceFactory("domainVisitsReducerCreator",cLe,"getDomainVisits"),e.serviceFactory("domainVisitsReducer",r=>r.reducer,"domainVisitsReducerCreator"),e.serviceFactory("nonOrphanVisitsReducerCreator",f6e,"getNonOrphanVisits"),e.serviceFactory("nonOrphanVisitsReducer",r=>r.reducer,"nonOrphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsReducerCreator",v6e,"getOrphanVisits","deleteOrphanVisits"),e.serviceFactory("orphanVisitsReducer",r=>r.reducer,"orphanVisitsReducerCreator"),e.serviceFactory("orphanVisitsDeletionReducerCreator",y6e,"deleteOrphanVisits"),e.serviceFactory("orphanVisitsDeletionReducer",r=>r.reducer,"orphanVisitsDeletionReducerCreator"),e.serviceFactory("shortUrlVisitsReducerCreator",x6e,"getShortUrlVisits","deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsReducer",r=>r.reducer,"shortUrlVisitsReducerCreator"),e.serviceFactory("shortUrlVisitsDeletionReducerCreator",O6e,"deleteShortUrlVisits"),e.serviceFactory("shortUrlVisitsDeletionReducer",r=>r.reducer,"shortUrlVisitsDeletionReducerCreator"),e.serviceFactory("tagVisitsReducerCreator",E6e,"getTagVisits"),e.serviceFactory("tagVisitsReducer",r=>r.reducer,"tagVisitsReducerCreator"),e.serviceFactory("tagVisitsComparisonReducerCreator",V6e,"getTagVisitsForComparison"),e.serviceFactory("tagVisitsComparisonReducer",r=>r.reducer,"tagVisitsComparisonReducerCreator"),e.serviceFactory("domainVisitsComparisonReducerCreator",I6e,"getDomainVisitsForComparison"),e.serviceFactory("domainVisitsComparisonReducer",r=>r.reducer,"domainVisitsComparisonReducerCreator"),e.serviceFactory("shortUrlVisitsComparisonReducerCreator",B6e,"getShortUrlVisitsForComparison"),e.serviceFactory("shortUrlVisitsComparisonReducer",r=>r.reducer,"shortUrlVisitsComparisonReducerCreator")},zf=({children:e,to:t,className:n,...r})=>m.jsx(b6,{className:({isActive:i})=>Oe("aside-menu__item",n,{"aside-menu__item--selected":i}),to:t,...r,children:e}),q6e=({routePrefix:e,showOnMobile:t=!1})=>{const{pathname:n}=pr(),r=Oe("aside-menu",{"aside-menu--hidden":!t}),i=o=>`${e}${o}`;return m.jsx("aside",{className:r,children:m.jsxs("nav",{className:"nav flex-column aside-menu__nav",children:[m.jsxs(zf,{to:i("/overview"),children:[m.jsx(je,{fixedWidth:!0,icon:TK}),m.jsx("span",{className:"aside-menu__item-text",children:"Overview"})]}),m.jsxs(zf,{to:i("/list-short-urls/1"),className:Oe({"aside-menu__item--selected":n.match("/list-short-urls")!==null}),children:[m.jsx(je,{fixedWidth:!0,icon:L6}),m.jsx("span",{className:"aside-menu__item-text",children:"List short URLs"})]}),m.jsxs(zf,{to:i("/create-short-url"),children:[m.jsx(je,{fixedWidth:!0,icon:LK,flip:"horizontal"}),m.jsx("span",{className:"aside-menu__item-text",children:"Create short URL"})]}),m.jsxs(zf,{to:i("/manage-tags"),children:[m.jsx(je,{fixedWidth:!0,icon:R6}),m.jsx("span",{className:"aside-menu__item-text",children:"Manage tags"})]}),m.jsxs(zf,{to:i("/manage-domains"),children:[m.jsx(je,{fixedWidth:!0,icon:sK}),m.jsx("span",{className:"aside-menu__item-text",children:"Manage domains"})]})]})})},r9=({createNotFound:e})=>{const{TagsList:t,ShortUrlsList:n,CreateShortUrl:r,ShortUrlVisits:i,TagVisits:o,DomainVisits:a,OrphanVisits:s,NonOrphanVisits:l,Overview:c,EditShortUrl:f,ManageDomains:d,TagVisitsComparison:p,DomainVisitsComparison:v,ShortUrlVisitsComparison:y,ShortUrlRedirectRules:g}=Rt(r9),x=pr(),_=ds(),[b,w,S,P]=Lt();M.useEffect(()=>P(),[x,P]);const E=Oe("shlink-layout__burger-icon",{"shlink-layout__burger-icon--active":b}),T=hLe(S,P),j=Ko("shortUrlRedirectRules");return m.jsxs(m.Fragment,{children:[m.jsx(je,{icon:nK,className:E,onClick:w}),m.jsx("div",{...T,className:"shlink-layout__swipeable",children:m.jsxs("div",{className:"shlink-layout__swipeable-inner",children:[m.jsx(q6e,{routePrefix:_,showOnMobile:b}),m.jsx("div",{className:"shlink-layout__container",onPointerDown:()=>P(),children:m.jsx("div",{className:"container-xl",children:m.jsxs(Xy,{children:[m.jsx(ot,{index:!0,element:m.jsx(eP,{replace:!0,to:"overview"})}),m.jsx(ot,{path:"/overview",element:m.jsx(c,{})}),m.jsx(ot,{path:"/list-short-urls/:page",element:m.jsx(n,{})}),m.jsx(ot,{path:"/create-short-url",element:m.jsx(r,{})}),m.jsx(ot,{path:"/short-code/:shortCode/visits/*",element:m.jsx(i,{})}),m.jsx(ot,{path:"/short-code/:shortCode/edit",element:m.jsx(f,{})}),j&&m.jsx(ot,{path:"/short-code/:shortCode/redirect-rules",element:m.jsx(g,{})}),m.jsx(ot,{path:"/short-urls/compare-visits",element:m.jsx(y,{})}),m.jsx(ot,{path:"/tag/:tag/visits/*",element:m.jsx(o,{})}),m.jsx(ot,{path:"/tags/compare-visits",element:m.jsx(p,{})}),m.jsx(ot,{path:"/domain/:domain/visits/*",element:m.jsx(a,{})}),m.jsx(ot,{path:"/orphan-visits/*",element:m.jsx(s,{})}),m.jsx(ot,{path:"/non-orphan-visits/*",element:m.jsx(l,{})}),m.jsx(ot,{path:"/manage-tags",element:m.jsx(t,{})}),m.jsx(ot,{path:"/manage-domains",element:m.jsx(d,{})}),m.jsx(ot,{path:"/domains/compare-visits",element:m.jsx(v,{})}),e&&m.jsx(ot,{path:"*",element:e("/list-short-urls/1")})]})})})]})})]})},K6e=$t(r9,["TagsList","ShortUrlsList","CreateShortUrl","ShortUrlVisits","TagVisits","DomainVisits","OrphanVisits","NonOrphanVisits","Overview","EditShortUrl","ManageDomains","TagVisitsComparison","DomainVisitsComparison","ShortUrlVisitsComparison","ShortUrlRedirectRules"]),Y6e=!0,Z6e=e=>AD({devTools:!Y6e,reducer:UP({mercureInfo:e.mercureInfoReducer,shortUrlsList:e.shortUrlsListReducer,shortUrlCreation:e.shortUrlCreationReducer,shortUrlDeletion:e.shortUrlDeletionReducer,shortUrlEdition:e.shortUrlEditionReducer,shortUrlsDetails:e.shortUrlsDetailsReducer,shortUrlVisits:e.shortUrlVisitsReducer,shortUrlVisitsDeletion:e.shortUrlVisitsDeletionReducer,shortUrlVisitsComparison:e.shortUrlVisitsComparisonReducer,tagVisits:e.tagVisitsReducer,tagVisitsComparison:e.tagVisitsComparisonReducer,domainVisits:e.domainVisitsReducer,domainVisitsComparison:e.domainVisitsComparisonReducer,orphanVisits:e.orphanVisitsReducer,orphanVisitsDeletion:e.orphanVisitsDeletionReducer,nonOrphanVisits:e.nonOrphanVisitsReducer,tagsList:e.tagsListReducer,tagDelete:e.tagDeleteReducer,tagEdit:e.tagEditReducer,domainsList:e.domainsListReducer,visitsOverview:e.visitsOverviewReducer,shortUrlRedirectRules:e.shortUrlRedirectRulesReducer,shortUrlRedirectRulesSaving:e.setShortUrlRedirectRulesReducer}),middleware:t=>t({immutableCheck:!1,serializableCheck:!1})}),X6e=e=>{e.factory("Main",K6e),e.factory("store",Z6e)},Fi=new A6,{container:Q6e}=Fi,J6e=e=>t=>Object.fromEntries(e.map(n=>[n,t[n]])),eIe=(e,t)=>(...n)=>e[t](...n),tIe=(e,t)=>({...e,[t]:eIe(Q6e,t)}),nf=(e,t=[])=>a6(e?J6e(e):null,t.reduce(tIe,{}));X6e(Fi);$Re(Fi,nf);o$e(Fi,nf);G6e(Fi,nf);CLe(Fi);SLe(Fi,nf);DLe(Fi,nf);x$e(Fi);Z4e(Fi,nf);let R4;const nIe=e=>({serverVersion:t,apiClient:n,settings:r,routesPrefix:i="",createNotFound:o,tagColorsStorage:a})=>{const s=U4e(t),l=M.useRef(),[c,f]=M.useState(),d=wl(),p=M.useMemo(()=>d?M.Fragment:y6,[d]);return M.useEffect(()=>{R4=n,e.value("apiClientFactory",()=>R4),a&&e.value("TagColorsStorage",a);const{container:v}=e,{Main:y,store:g,loadMercureInfo:x,listTags:_,listDomains:b}=v;l.current=m.jsx(y,{createNotFound:o}),f(g),g.dispatch(x(r)),g.dispatch(_()),g.dispatch(b())},[n,o,r,a]),c?m.jsx(s6,{store:c,children:m.jsx(KD,{value:r??{},children:m.jsx(B4e,{value:s,children:m.jsx(UMe,{value:i,children:m.jsx(p,{children:l.current})})})})}):m.jsx(m.Fragment,{})},rIe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAApCAYAAADAk4LOAAAFgUlEQVR4Aa1XA5BjWRTN2oW17d3YaZtr2962HUzbDNpjszW24mRt28p47v7zq/bXZtrp/lWnXr337j3nPCe85NcypgSFdugCpW5YoDAMRaIMqRi6aKq5E3YqDQO3qAwjVWrD8Ncq/RBpykd8oZUb/kaJutow8r1aP9II0WmLKLIsJyv1w/kqw9Ch2MYdB++12Onxee/QMwvf4/Dk/Lfp/i4nxTXtOoQ4pW5Aj7wpici1A9erdAN2OH64x8OSP9j3Ft3b7aWkTg/Fm91siTra0f9on5sQr9INejH6CUUUpavjFNq1B+Oadhxmnfa8RfEmN8VNAsQhPqF55xHkMzz3jSmChWU6f7/XZKNH+9+hBLOHYozuKQPxyMPUKkrX/K0uWnfFaJGS1QPRtZsOPtr3NsW0uyh6NNCOkU3Yz+bXbT3I8G3xE5EXLXtCXbbqwCO9zPQYPRTZ5vIDXD7U+w7rFDEoUUf7ibHIR4y6bLVPXrz8JVZEql13trxwue/uDivd3fkWRbS6/IA2bID4uk0UpF1N8qLlbBlXs4Ee7HLTfV1j54APvODnSfOWBqtKVvjgLKzF5YdEk5ewRkGlK0i33Eofffc7HT56jD7/6U+qH3Cx7SBLNntH5YIPvODnyfIXZYRVDPqgHtLs5ABHD3YzLuespb7t79FY34DjMwrVrcTuwlT55YMPvOBnRrJ4VXTdNnYug5ucHLBjEpt30701A3Ts+HEa73u6dT3FNWwflY86eMHPk+Yu+i6pzUpRrW7SNDg5JHR4KapmM5Wv2E8Tfcb1HoqqHMHU+uWDD7zg54mz5/2BSnizi9T1Dg4QQXLToGNCkb6tb1NU+QAlGr1++eADrzhn/u8Q2YZhQVlZ5+CAOtqfbhmaUCS1ezNFVm2imDbPmPng5wmz+gwh+oHDce0eUtQ6OGDIyR0uUhUsoO3vfDmmgOezH0mZN59x7MBi++WDL1g/eEiU3avlidO671bkLfwbw5XV2P8Pzo0ydy4t2/0eu33xYSOMOD8hTf4CrBtGMSoXfPLchX+J0ruSePw3LZeK0juPJbYzrhkH0io7B3k164hiGvawhOKMLkrQLyVpZg8rHFW7E2uHOL888IBPlNZ1FPzstSJM694fWr6RwpvcJK60+0HCILTBzZLFNdtAzJaohze60T8qBzyh5ZuOg5e7uwQppofEmf2++DYvmySqGBuKaicF1blQjhuHdvCIMvp8whTTfZzI7RldpwtSzL+F1+wkdZ2TBOW2gIF88PBTzD/gpeREAMEbxnJcaJHNHrpzji0gQCS6hdkEeYt9DF/2qPcEC8RM28Hwmr3sdNyht00byAut2k3gufWNtgtOEOFGUwcXWNDbdNbpgBGxEvKkOQsxivJx33iow0Vw5S6SVTrpVq11ysA2Rp7gTfPfktc6zhtXBBC+adRLshf6sG2RfHPZ5EAc4sVZ83yCN00Fk/4kggu40ZTvIEm5g24qtU4KjBrx/BTTH8ifVASAG7gKrnWxJDcU7x8X6Ecczhm3o6YicvsLXWfh3Ch1W0k8x0nXF+0fFxgt4phz8QvypiwCCFKMqXCnqXExjq10beH+UUA7+nG6mdG/Pu0f3LgFcGrl2s0kNNjpmoJ9o4B29CMO8dMT4Q5ox8uitF6fqsrJOr8qnwNbRzv6hSnG5wP+64C7h9lp30hKNtKdWjtdkbuPA19nJ7Tz3zR/ibgARbhb4AlhavcBebmTHcFl2fvYEnW0ox9xMxKBS8btJ+KiEbq9zA4RthQXDhPa0T9TEe69gWupwc6uBUphquXgf+/FrIjweHQS4/pduMe5ERUMHUd9xv8ZR98CxkS4F2n3EUrUZ10EYNw7BWm9x1GiPssi3GgiGRDKWRYZfXlON+dfNbM+GgIwYdwAAAAASUVORK5CYII=",iIe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABSCAMAAAAhFXfZAAAC91BMVEVMaXEzeak2f7I4g7g3g7cua5gzeKg8hJo3grY4g7c3grU0gLI2frE0daAubJc2gbQwd6QzeKk2gLMtd5sxdKIua5g1frA2f7IydaM0e6w2fq41fK01eqo3grgubJgta5cxdKI1f7AydaQydaMxc6EubJgvbJkwcZ4ubZkwcJwubZgubJcydqUydKIxapgubJctbJcubZcubJcvbJYubJcvbZkubJctbJctbZcubJg2f7AubJcrbZcubJcubJcua5g3grY0fq8ubJcubJdEkdEwhsw6i88vhswuhcsuhMtBjMgthMsrg8srgss6is8qgcs8i9A9iMYtg8spgcoogMo7hcMngMonf8olfso4gr8kfck5iM8jfMk4iM8he8k1fro7itAgesk2hs8eecgzfLcofssdeMg0hc4cd8g2hcsxeLQbdsgZdcgxeLImfcszhM0vda4xgckzhM4xg84wf8Yxgs4udKsvfcQucqhUndROmdM1fK0wcZ8vb5w0eqpQm9MzeKhXoNVcpdYydKNWn9VZotVKltJFjsIwcJ1Rms9OlslLmtH///8+kc9epdYzd6dbo9VHkMM2f7FHmNBClM8ydqVcpNY9hro3gLM9hLczealQmcw3fa46f7A8gLMxc6I3eagyc6FIldJMl9JSnNRSntNNl9JPnNJFi75UnM9ZodVKksg8kM45jc09e6ZHltFBk883gbRBh7pDk9EwcaBzn784g7dKkcY2i81Om9M7j85Llc81is09g7Q4grY/j9A0eqxKmdFFltBEjcXf6fFImdBCiLxJl9FGlNFBi78yiMxVndEvbpo6js74+vx+psPP3+o/ks5HkcpGmNCjwdZCkNDM3ehYoNJEls+lxNkxh8xHks0+jdC1zd5Lg6r+/v/H2ufz9/o3jM3t8/edvdM/k89Th61OiLBSjbZklbaTt9BfptdjmL1AicBHj8hGk9FAgK1dkLNTjLRekrdClc/k7fM0icy0y9tgp9c4jc2NtM9Dlc8zicxeXZn3AAAAQ3RSTlMAHDdTb4yPA+LtnEQmC4L2EmHqB7XA0d0sr478x4/Yd5i1zOfyPkf1sLVq4Nh3FvjxopQ2/STNuFzUwFIwxKaejILpIBEV9wAABhVJREFUeF6s1NdyFEcYBeBeoQIhRAkLlRDGrhIgY3BJL8CVeKzuyXFzzjkn5ZxzzuScg3PO8cKzu70JkO0LfxdTU//pM9vTu7Xgf6KqOVTb9X7toRrVEfBf1HTVjZccrT/2by1VV928Yty9ZbVuucdz90frG8DBjl9pVApbOstvmMuvVgaNXSfAAd6pGxpy6yxf5ph43pS/4f3uoaGm2rdu72S9xzOvMymkZFq/ptDrk90mhW7e4zl7HLzhxGWPR20xmSxJ/VqldG5m9XhaVOA1DadsNh3Pu5L2N6QtPO/32JpqQBVVk20oy/Pi2s23WEvyfHbe1thadVQttvm7Llf65gGmXK67XtupyoM7HQhmXdLS8oGWJNeOJ3C5fG5XCEJnkez3/oFdsvgJ4l2ANZwhrJKk/7OSXa+3Vw2WJMlKnGkobouYk6T0TyX30klOUnTD9HJ5qpckL3EW/w4XF3Xd0FGywXUrstrclVsqz5Pd/sXFYyDnPdrLcQODmGOK47IZb4CmibmMn+MYRzFZ5jg33ZL/EJrWcszHmANy3ARBK/IXtciJy8VsitPSdE3uuHxzougojcUdr8/32atnz/ev3f/K5wtpxUTpcaI45zusVDpYtZi+jg0oU9b3x74h7+n9ABvYEZeKaVq0sh0AtLKsFtqNBdeT0MrSzwwlq9+x6xAO4tgOtSzbCjrNQQiNvQUbUEubvzBUeGw26yDCsRHCoLkTHDa7IdOLIThs/gHvChszh2CimE8peRs47cxANI0lYNB5y1DljpOF0IhzBDPOZnDOqYYbeGKECbPzWnXludPphw5c2YBq5zlwXphIbO4VDCZ0gnPfUO1TwZoYwAs2ExPCedAu9DAjfQUjzITQb3jNj0KG2Sgt6BHaQUdYzWz+XmBktOHwanXjaSTcwwziBcuMOtwBmqPrTOxFQR/DRKKPqyur0aiW6cULYsx6tBm0jXpR/AUWR6HRq9WVW6MRhIq5jLyjbaCTDCijyYJNpCajdyobP/eTw0iexBAKkJ3gA5KcQb2zBXsIBckn+xVv8jkZSaEFHE+jFEleAEfayRU0MouNoBmB/L50Ai/HSLIHxcrpCvnhSQAuakKp2C/YbCylJjXRVy/z3+Kv/RrNcCo+WUzlVEhzKffnTQnxeN9fWF88fiNCUdSTsaufaChKWInHeysygfpIqagoakW+vV20J8uyl6TyNKEZWV4oRSPyCkWpgOLSbkCObT8o2r6tlG58HQquf6O0v50tB7JM7F4EORd2dx/K0w/KHsVkLPaoYrwgP/y7krr3SSMA4zj+OBgmjYkxcdIJQyQRKgg2viX9Hddi9UBb29LrKR7CVVEEEXWojUkXNyfTNDE14W9gbHJNuhjDettN3ZvbOvdOqCD3Jp/9l+/wJE+9PkYGjx/fqkys3S2rMozM/o2106rfMUINo6hVqz+eu/hd1c4xTg0TAfy5kV+4UG6+IthHTU9woWmxuKNbTfuCSfovBCxq7EtHqvYL4Sm6F8GVxsSXHMQ07TOi1DKtZxjWaaIyi4CXWjxPccUw8WVbMYY5wxC1mzEyXMJWkllpRloi+Kkoq69sxBTlElF6aAxYUbjXNlhlDZilDnM4U5SlN5biRsRHnbx3mbeWjEh4mEyiuJDl5XcWVmX5GvNkFgLWZM5qwsop4/AWfLhU1cR7k1VVvcYCWRkOI6Xy5gmnphCYIkvzuNYzHzosq2oNk2RtSs8khfUOfHIDgR6ysYBaMpl4uEgk2U/oJTs9AaTSwma7dT69geAE2ZpEjUsn2ieJNHeKfrI3EcAGJ2ZaNgVuC8EBctCLc57P5u5led6IOBkIYkuQMrmmjChs4VkfOerHqSBkPzZlhe06RslZ3zMjk2sscqKwY0RcjKK+LWbzd7KiHhkncs/siFJ+V5eXxD34B8nVuJEpGJNmxN2gH3vSvp7J70tF+D1Ej8qUJD1TkErAND2GZwTFg/LubvmgiBG3SOvdlsqFQrkEzJCL1rstlnVFROixZoDDSuXQFHESwVGlcuQcMb/b42NgjLowh5MTDFE3vNB5qStRIErdCQEh6pLPR92anSUb/wAIhldAaDMpGgAAAABJRU5ErkJggg==",oIe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAApCAQAAAACach9AAACMUlEQVR4Ae3ShY7jQBAE0Aoz/f9/HTMzhg1zrdKUrJbdx+Kd2nD8VNudfsL/Th///dyQN2TH6f3y/BGpC379rV+S+qqetBOxImNQXL8JCAr2V4iMQXHGNJxeCfZXhSRBcQMfvkOWUdtfzlLgAENmZDcmo2TVmt8OSM2eXxBp3DjHSMFutqS7SbmemzBiR+xpKCNUIRkdkkYxhAkyGoBvyQFEJEefwSmmvBfJuJ6aKqKWnAkvGZOaZXTUgFqYULWNSHUckZuR1HIIimUExutRxwzOLROIG4vKmCKQt364mIlhSyzAf1m9lHZHJZrlAOMMztRRiKimp/rpdJDc9Awry5xTZCte7FHtuS8wJgeYGrex28xNTd086Dik7vUMscQOa8y4DoGtCCSkAKlNwpgNtphjrC6MIHUkR6YWxxs6Sc5xqn222mmCRFzIt8lEdKx+ikCtg91qS2WpwVfBelJCiQJwvzixfI9cxZQWgiSJelKnwBElKYtDOb2MFbhmUigbReQBV0Cg4+qMXSxXSyGUn4UbF8l+7qdSGnTC0XLCmahIgUHLhLOhpVCtw4CzYXvLQWQbJNmxoCsOKAxSgBJno75avolkRw8iIAFcsdc02e9iyCd8tHwmeSSoKTowIgvscSGZUOA7PuCN5b2BX9mQM7S0wYhMNU74zgsPBj3HU7wguAfnxxjFQGBE6pwN+GjME9zHY7zGp8wVxMShYX9NXvEWD3HbwJf4giO4CFIQxXScH1/TM+04kkBiAAAAAElFTkSuQmCC",aIe=()=>{delete QL.Icon.Default.prototype._getIconUrl,QL.Icon.Default.mergeOptions({iconRetinaUrl:iIe,iconUrl:rIe,shadowUrl:oIe})};aIe();const sIe=nIe(Fi);function jy(e){return t=>{const{resetSelectedServer:n}=t;return M.useEffect(()=>{n()},[n]),m.jsx(e,{...t})}}let lIe=class extends M.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(t){const{console:n=globalThis.console}=this.props;n.error(t)}render(){const{hasError:t}=this.state,{location:n=globalThis.location}=this.props;if(t)return m.jsx("div",{className:"home",children:m.jsxs(gt,{className:"p-4",children:[m.jsx("h1",{children:"Oops! This is awkward :S"}),m.jsx("p",{children:"It seems that something went wrong. Try refreshing the page or just click this button."}),m.jsx("br",{}),m.jsx(qe,{outline:!0,color:"primary",onClick:()=>n.reload(),children:"Take me back"})]})});const{children:r}=this.props;return r}};const cIe=({id:e,name:t})=>m.jsxs(lD,{tag:At,to:`/server/${e}`,className:"servers-list__server-item",children:[t,m.jsx(je,{icon:FK,className:"servers-list__server-item-icon"})]}),i9=({servers:e,children:t,embedded:n=!1})=>m.jsxs(m.Fragment,{children:[t&&m.jsx("div",{"data-testid":"title",className:"mb-0 fs-5 fw-normal lh-sm",children:t}),e.length>0&&m.jsx(aD,{"data-testid":"list",tag:"div",className:Oe("servers-list__list-group",{"servers-list__list-group--embedded":n}),children:e.map(({id:r,name:i})=>m.jsx(cIe,{id:r,name:i},r))})]}),o9=({color:e=nh,className:t})=>m.jsx("svg",{className:t,viewBox:"0 0 512 512",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:m.jsxs("g",{fill:e,children:[m.jsx("path",{d:" M 23.71 85.08 C 17.22 49.81 49.44 14.86 85.08 18.12 C 118.83 19.21 145.72 53.33 139.45 86.37 C 155.64 102.30 171.32 118.83 187.87 134.36 C 198.32 111.73 208.84 89.12 219.57 66.62 C 226.05 53.84 243.47 48.74 255.73 56.27 C 263.76 62.10 270.34 69.69 277.25 76.75 C 286.28 86.61 285.72 102.89 276.31 112.31 C 223.38 165.37 170.38 218.37 117.35 271.34 C 107.72 280.99 91.01 281.25 81.11 271.86 C 74.39 264.94 66.82 258.69 61.24 250.77 C 53.72 238.52 58.85 221.07 71.64 214.62 C 94.11 203.87 116.72 193.38 139.33 182.91 C 123.81 166.36 107.30 150.68 91.37 134.49 C 60.20 140.28 27.37 116.78 23.71 85.08 Z"}),m.jsx("path",{d:" M 205.21 201.23 C 225.32 181.36 260.88 181.11 281.14 200.86 C 299.25 218.75 317.37 236.65 335.10 254.93 C 356.73 278.01 352.01 318.70 326.03 336.56 C 320.07 330.47 313.73 324.65 308.12 318.28 C 323.86 309.39 328.76 286.18 316.63 272.39 C 301.73 256.95 286.30 242.03 271.24 226.75 C 264.49 219.65 256.80 212.00 246.37 211.52 C 224.65 208.64 205.52 233.36 214.49 253.58 C 221.09 266.81 234.22 275.12 243.62 286.24 C 240.43 295.96 238.09 306.13 238.29 316.46 C 225.55 304.29 213.16 291.73 200.89 279.09 C 180.97 257.57 183.10 220.45 205.21 201.23 Z"}),m.jsx("path",{d:" M 273.90 352.07 C 252.28 328.99 256.98 288.31 282.96 270.46 C 288.93 276.54 295.26 282.36 300.88 288.72 C 285.14 297.62 280.23 320.82 292.38 334.61 C 307.27 350.05 322.70 364.96 337.75 380.25 C 344.51 387.35 352.20 395.00 362.64 395.48 C 384.35 398.37 403.49 373.64 394.51 353.42 C 387.92 340.18 374.78 331.88 365.38 320.76 C 368.56 311.04 370.91 300.86 370.71 290.54 C 383.45 302.70 395.84 315.27 408.11 327.91 C 428.03 349.43 425.90 386.55 403.78 405.77 C 383.68 425.64 348.13 425.89 327.86 406.14 C 309.75 388.25 291.60 370.37 273.90 352.07 Z"}),m.jsx("path",{d:" M 422.11 403.83 C 431.96 394.07 441.60 384.06 451.66 374.51 C 460.90 383.74 471.89 392.70 474.89 406.11 C 480.16 429.97 484.08 454.13 488.76 478.12 C 490.00 483.41 484.47 488.29 479.35 486.63 C 454.66 481.52 429.55 478.12 405.14 471.84 C 393.17 467.97 385.20 457.75 376.55 449.27 C 386.39 439.49 396.13 429.60 406.06 419.91 C 416.37 433.45 435.74 414.00 422.11 403.83 Z"})]})}),uIe=({servers:e})=>{const t=po(),n=Object.values(e),r=n.length>0;return M.useEffect(()=>{const i=n.find(({autoConnect:o})=>o);i&&t(`/server/${i.id}`)},[n,t]),m.jsx("div",{className:"w-100",children:m.jsx(Dr,{className:"mx-auto",style:{maxWidth:"720px"},children:m.jsxs("div",{className:"d-flex flex-column flex-md-row",children:[m.jsx("div",{className:"p-4 d-none d-md-flex align-items-center",style:{width:"40%"},children:m.jsx("div",{className:"w-100",children:m.jsx(o9,{})})}),m.jsxs("div",{className:"home__servers-container flex-grow-1",children:[m.jsx("h1",{className:Oe("home__title p-4 text-center m-0",{"border-bottom":!r}),style:{borderColor:"var(--border-color) !important"},children:"Welcome!"}),m.jsx(i9,{embedded:!0,servers:n,children:!r&&m.jsxs("div",{className:"p-4 text-center d-flex flex-column gap-5",children:[m.jsx("p",{className:"mb-0",children:"This application will help you manage your Shlink servers."}),m.jsx("p",{className:"mb-0",children:m.jsxs(At,{to:"/server/create",className:"btn btn-outline-primary btn-lg me-2",children:[m.jsx(je,{icon:Zh})," ",m.jsx("span",{className:"ms-1",children:"Add a server"})]})}),m.jsx("p",{className:"mb-0",children:m.jsx(hr,{href:"https://shlink.io/documentation",children:m.jsxs("small",{children:[m.jsx("span",{className:"me-2",children:"Learn more about Shlink"}),m.jsx(je,{icon:bK})]})})})]})})]})]})})})},a9=()=>{const{ServersDropdown:e}=Ri(a9),[t,n,,r]=Lt(),i=pr(),{pathname:o}=i;M.useEffect(r,[i,r]);const a="/settings",s=Oe("main-header__toggle-icon",{"main-header__toggle-icon--opened":t});return m.jsxs(jI,{color:"primary",dark:!0,fixed:"top",className:"main-header",expand:"md",children:[m.jsxs(AI,{tag:At,to:"/",children:[m.jsx(o9,{className:"main-header__brand-logo",color:"white"})," Shlink"]}),m.jsx(kI,{onClick:n,children:m.jsx(je,{icon:IK,className:s})}),m.jsx(LP,{navbar:!0,isOpen:t,children:m.jsxs(SP,{navbar:!0,className:"ms-auto",children:[m.jsx(PP,{children:m.jsxs(EP,{tag:At,to:a,active:o.startsWith(a),children:[m.jsx(je,{icon:zK}),"  Settings"]})}),m.jsx(e,{})]})})]})},fIe=$i(a9,["ServersDropdown"]),dIe=({children:e})=>{const t=pr();return M.useEffect(()=>{scrollTo(0,0)},[t]),m.jsx(m.Fragment,{children:e})},s9=RD(e=>e,e=>{try{return u2(e,e,"=")}catch{return!1}}),l9=e=>s9(e)?`v${e}`:e,c9=(e,t="latest")=>s9(e)?e:t,hIe="%_VERSION_%",pIe=e=>l9(c9(e)),$4=({project:e,version:t})=>m.jsx(hr,{href:`https://github.com/shlinkio/${e}/releases/${t}`,className:"text-muted",children:m.jsx("b",{children:t})}),mIe=({selectedServer:e,clientVersion:t=hIe})=>{const n=pIe(t);return m.jsxs("small",{className:"text-muted",children:[oP(e)&&m.jsxs(m.Fragment,{children:["Server: ",m.jsx($4,{project:"shlink",version:e.printableVersion})," - "]}),"Client: ",m.jsx($4,{project:"shlink-web-client",version:n})]})},vIe=({selectedServer:e})=>m.jsx("div",{className:Oe("text-center",{"shlink-versions-container--with-sidebar":oP(e)}),children:m.jsx(mIe,{selectedServer:e})}),rf=({children:e,className:t})=>m.jsx("div",{className:Oe("no-menu-wrapper container-xl",t),children:e});function u9(e){const t=n=>{const{ServerError:r}=Ri(t),i=Mu(),{selectServer:o,selectedServer:a}=n;return M.useEffect(()=>{i.serverId&&o(i.serverId)},[i.serverId,o]),a?zq(a)?m.jsx(r,{}):m.jsx(e,{...n}):m.jsx(rf,{children:m.jsx(zo,{loading:!0})})};return t}const f9=u9(M.memo(({selectedServer:e,settings:t})=>{const{buildShlinkApiClient:n,TagColorsStorage:r,ShlinkWebComponent:i,ServerError:o}=Ri(f9);if(!oP(e))return m.jsx(o,{});const a=`/server/${e.id}`;return m.jsx(i,{serverVersion:e.version,apiClient:n(e),settings:t,routesPrefix:a,tagColorsStorage:r,createNotFound:s=>m.jsx(gD,{to:`${a}${s}`,children:"List short URLs"})})})),gIe=$i(f9,["buildShlinkApiClient","TagColorsStorage","ShlinkWebComponent","ServerError"]),yIe=(e,t)=>{e.constant("window",window),e.constant("console",console),e.constant("fetch",window.fetch.bind(window)),e.service("HttpClient",eoe,"fetch"),e.serviceFactory("ScrollToTop",()=>dIe),e.factory("MainHeader",fIe),e.serviceFactory("Home",()=>uIe),e.decorator("Home",jy),e.decorator("Home",t(["servers"],["resetSelectedServer"])),e.serviceFactory("ShlinkWebComponent",()=>sIe),e.factory("ShlinkWebComponentContainer",gIe),e.decorator("ShlinkWebComponentContainer",t(["selectedServer","settings"],["selectServer"])),e.serviceFactory("ShlinkVersionsContainer",()=>vIe),e.decorator("ShlinkVersionsContainer",t(["selectedServer"])),e.serviceFactory("ErrorHandler",()=>lIe)},d9=()=>{const e=po();return M.useCallback(()=>e(-1),[e])};function bIe(e){let t=e.url;try{const{host:n,pathname:r}=new URL(t);t=n;const i=r.substring(1);i.length>0&&(t=`${t} ${i}`)}catch{}return`${e.name} ${t}`.toLowerCase().replace(/[^a-zA-Z0-9-_.~]/g,"-")}function _Ie(e){const t={};return e.forEach(n=>{t[n.id]=n}),t}const xIe=(e,{url:t,apiKey:n})=>e.some(r=>r.url===t&&r.apiKey===n);function wIe(e,t){const n=Object.values(e),{duplicatedServers:r=[],newServers:i=[]}=LD(t,o=>xIe(n,o)?"duplicatedServers":"newServers");return{duplicatedServers:r,newServers:i}}function Ay(e,t){const n=new Set(Object.keys(e)),r=[];return t.forEach(i=>{const o=bIe(i);let a=o,s=1;for(;n.has(a);)a=`${o}-${s}`,s++;r.push({...i,id:a}),n.add(a)}),r}const h9=({isOpen:e,duplicatedServers:t,onDiscard:n,onSave:r})=>{const i=t.length>1;return m.jsxs(vr,{centered:!0,isOpen:e,children:[m.jsxs(mo,{children:["Duplicated server",i&&"s"]}),m.jsxs(Li,{children:[m.jsx("p",{children:i?"The next servers already exist:":"There is already a server with:"}),m.jsx("ul",{children:t.map(({url:o,apiKey:a},s)=>i?m.jsxs("li",{children:[m.jsx("b",{children:o})," - ",m.jsx("b",{children:a})]},s):m.jsxs(M.Fragment,{children:[m.jsxs("li",{children:["URL: ",m.jsx("b",{children:o})]}),m.jsxs("li",{children:["API key: ",m.jsx("b",{children:a})]})]},s))}),m.jsxs("span",{children:[i?"Do you want to ignore duplicated servers":"Do you want to save this server anyway","?"]})]}),m.jsxs(as,{children:[m.jsx(qe,{color:"link",onClick:n,children:i?"Ignore duplicates":"Discard"}),m.jsx(qe,{color:"primary",onClick:r,children:"Save anyway"})]})]})},OIe=e=>t=>{t.preventDefault(),e()},p9=({onSubmit:e,initialValues:t,children:n,title:r})=>{const[i,o]=M.useState((t==null?void 0:t.name)??""),[a,s]=M.useState((t==null?void 0:t.url)??""),[l,c]=M.useState((t==null?void 0:t.apiKey)??""),f=OIe(()=>e({name:i,url:a,apiKey:l}));return m.jsxs("form",{className:"server-form",name:"serverForm",onSubmit:f,children:[m.jsxs(gt,{className:"mb-3",title:r,children:[m.jsx(ev,{value:i,onChange:o,children:"Name"}),m.jsx(ev,{type:"url",value:a,onChange:s,children:"URL"}),m.jsx(ev,{value:l,onChange:c,children:"API key"})]}),m.jsx("div",{className:"text-end",children:n})]})},I4=4e3,D4=({type:e})=>m.jsx("div",{className:"mt-3",children:m.jsxs(Zn,{type:e,children:[e==="success"&&"Servers properly imported. You can now select one from the list :)",e==="error"&&"The servers could not be imported. Make sure the format is correct."]})}),m9=({servers:e,createServers:t})=>{const{ImportServersBtn:n,useTimeoutToggle:r}=Ri(m9),i=po(),o=d9(),a=!!Object.keys(e).length,[s,l]=r(!1,I4),[c,f]=r(!1,I4),[d,p]=Lt(),[v,y]=M.useState(),g=M.useCallback(_=>{const[b]=Ay(e,[_]);t([b]),i(`/server/${b.id}`)},[t,i,e]),x=M.useCallback(_=>{y(_),Object.values(e).some(({url:w,apiKey:S})=>_.url===w&&_.apiKey===S)?p():g(_)},[g,e,p]);return m.jsxs(rf,{children:[m.jsxs(p9,{title:m.jsx("h5",{className:"mb-0",children:"Add new server"}),onSubmit:x,children:[!a&&m.jsx(n,{tooltipPlacement:"top",onImport:l,onImportError:f}),a&&m.jsx(qe,{outline:!0,onClick:o,children:"Cancel"}),m.jsx(qe,{outline:!0,color:"primary",className:"ms-2",children:"Create server"})]}),s&&m.jsx(D4,{type:"success"}),c&&m.jsx(D4,{type:"error"}),m.jsx(h9,{isOpen:d,duplicatedServers:v?[v]:[],onDiscard:o,onSave:()=>v&&g(v)})]})},SIe=$i(m9,["ImportServersBtn","useTimeoutToggle"]),v9=({server:e,className:t,children:n,textClassName:r})=>{const{DeleteServerModal:i}=Ri(v9),[o,,a,s]=Lt();return m.jsxs(m.Fragment,{children:[m.jsxs("button",{type:"button",className:Oe(t,"p-0 bg-transparent border-0"),onClick:a,children:[!n&&m.jsx(je,{fixedWidth:!0,icon:aP}),m.jsx("span",{className:r,children:n??"Remove this server"})]}),m.jsx(i,{server:e,isOpen:o,toggle:s})]})},PIe=$i(v9,["DeleteServerModal"]),EIe=({server:e,toggle:t,isOpen:n,deleteServer:r,redirectHome:i=!0})=>{const o=po(),a=M.useRef(!1),s=()=>{a.current=!0,t()},l=()=>{a.current&&(r(e),i&&o("/"))};return m.jsxs(vr,{isOpen:n,toggle:t,centered:!0,onClosed:l,children:[m.jsx(mo,{toggle:t,className:"text-danger",children:"Remove server"}),m.jsxs(Li,{children:[m.jsxs("p",{children:["Are you sure you want to remove ",m.jsx("b",{children:e?e.name:""}),"?"]}),m.jsx("p",{children:m.jsx("i",{children:"No data will be deleted, only the access to this server will be removed from this device. You can create it again at any moment."})})]}),m.jsxs(as,{children:[m.jsx(qe,{color:"link",onClick:t,children:"Cancel"}),m.jsx(qe,{color:"danger",onClick:s,children:"Delete"})]})]})},CIe=u9(({editServer:e,selectedServer:t,selectServer:n})=>{const r=d9(),{reconnect:i}=$u();if(!cd(t))return null;const o=a=>{e(t.id,a),i==="true"&&n(t.id),r()};return m.jsx(rf,{children:m.jsxs(p9,{title:m.jsxs("h5",{className:"mb-0",children:['Edit "',t.name,'"']}),initialValues:t,onSubmit:o,children:[m.jsx(qe,{outline:!0,className:"me-2",onClick:r,children:"Cancel"}),m.jsx(qe,{outline:!0,color:"primary",children:"Save"})]})})}),TIe=$i(CIe,["ServerError"]),g9=({createServers:e,servers:t,children:n,onImport:r=()=>{},onImportError:i=()=>{},tooltipPlacement:o="bottom",className:a=""})=>{const{ServersImporter:s}=Ri(g9),l=Mi(),[c,f]=M.useState([]),[d,,p,v]=Lt(),y=M.useRef([]),g=M.useRef([]),x=M.useCallback(S=>{e(S),r()},[e,r]),_=M.useCallback(async({target:S})=>{var P;return s.importServersFromFile((P=S.files)==null?void 0:P[0]).then(E=>{const{duplicatedServers:T,newServers:j}=wIe(t,E);y.current=Ay(t,E),g.current=Ay(t,j),T.length===0?x(y.current):(f(T),p())}).then(()=>{S.value=null}).catch(i)},[x,i,t,s,p]),b=M.useCallback(()=>{x(y.current),v()},[x,v]),w=M.useCallback(()=>{x(g.current),v()},[x,v]);return m.jsxs(m.Fragment,{children:[m.jsxs(qe,{outline:!0,id:"importBtn",className:a,onClick:()=>{var S;return(S=l.current)==null?void 0:S.click()},children:[m.jsx(je,{icon:uK,fixedWidth:!0})," ",n??"Import from file"]}),m.jsxs(Fr,{placement:o,target:"importBtn",children:["You can create servers by importing a CSV file with ",m.jsx("b",{children:"name"}),", ",m.jsx("b",{children:"apiKey"})," and ",m.jsx("b",{children:"url"})," columns."]}),m.jsx("input",{type:"file",accept:".csv",className:"d-none","aria-hidden":!0,ref:l,onChange:_,"data-testid":"csv-file-input"}),m.jsx(h9,{isOpen:d,duplicatedServers:c,onDiscard:w,onSave:b})]})},jIe=$i(g9,["ServersImporter"]),y9=({servers:e,selectedServer:t})=>{const{DeleteServerButton:n}=Ri(y9);return m.jsx(rf,{children:m.jsxs("div",{className:"server-error__container flex-column",children:[m.jsxs(zo,{className:"w-100 mb-3 mb-md-5",type:"error",fullWidth:!0,children:[!cd(t)&&"Could not find this Shlink server.",cd(t)&&m.jsxs(m.Fragment,{children:[m.jsx("p",{children:"Oops! Could not connect to this Shlink server."}),"Make sure you have internet connection, and the server is properly configured and on-line."]})]}),m.jsx(i9,{servers:Object.values(e),children:m.jsxs("p",{className:"mb-md-3",children:["These are the Shlink servers currently configured. Choose one of them or ",m.jsx(At,{to:"/server/create",children:"add a new one"}),"."]})}),cd(t)&&m.jsx("div",{className:"container mt-3 mt-md-5",children:m.jsxs("p",{className:"fs-5 fw-normal lh-sm",children:["Alternatively, if you think you may have miss-configured this server, you can ",m.jsx(n,{server:t,className:"server-error__delete-btn",children:"remove it"})," or ",m.jsx(At,{to:`/server/${t.id}/edit?reconnect=true`,children:"edit it"}),"."]})})]})})},AIe=$i(y9,["DeleteServerButton"]),kIe=4e3,b9=({servers:e})=>{const{ServersExporter:t,ImportServersBtn:n,useTimeoutToggle:r,ManageServersRow:i}=Ri(b9),[o,a]=M.useState(""),s=M.useMemo(()=>Object.values(e),[e]),l=M.useMemo(()=>s.filter(({name:p,url:v})=>`${p} ${v}`.toLowerCase().match(o.toLowerCase())),[s,o]),c=s.some(({autoConnect:p})=>!!p),[f,d]=r(!1,kIe);return m.jsxs(rf,{className:"d-flex flex-column gap-3",children:[m.jsx(ip,{onChange:a}),m.jsxs("div",{className:"d-flex flex-column flex-md-row gap-2",children:[m.jsxs("div",{className:"d-flex gap-2",children:[m.jsx(n,{className:"flex-fill",onImportError:d,children:"Import servers"}),l.length>0&&m.jsxs(qe,{outline:!0,className:"flex-fill",onClick:async()=>t.exportServers(),children:[m.jsx(je,{icon:I6,fixedWidth:!0})," Export servers"]})]}),m.jsxs(qe,{outline:!0,color:"primary",className:"ms-md-auto",tag:At,to:"/server/create",children:[m.jsx(je,{icon:Zh,fixedWidth:!0})," Add a server"]})]}),m.jsx(gt,{children:m.jsxs("table",{className:"table table-hover responsive-table mb-0",children:[m.jsx("thead",{className:"responsive-table__header",children:m.jsxs("tr",{children:[c&&m.jsx("th",{style:{width:"50px"},children:m.jsx("span",{className:"sr-only",children:"Auto-connect"})}),m.jsx("th",{children:"Name"}),m.jsx("th",{children:"Base URL"}),m.jsx("th",{children:m.jsx("span",{className:"sr-only",children:"Options"})})]})}),m.jsxs("tbody",{children:[!l.length&&m.jsx("tr",{className:"text-center",children:m.jsx("td",{colSpan:4,children:"No servers found."})}),l.map(p=>m.jsx(i,{server:p,hasAutoConnect:c},p.id))]})]})}),f&&m.jsx("div",{children:m.jsx(Zn,{type:"error",children:"The servers could not be imported. Make sure the format is correct."})})]})},NIe=$i(b9,["ServersExporter","ImportServersBtn","useTimeoutToggle","ManageServersRow"]),_9=({server:e,hasAutoConnect:t})=>{const{ManageServersRowDropdown:n}=Ri(_9);return m.jsxs("tr",{className:"responsive-table__row",children:[t&&m.jsx("td",{className:"responsive-table__cell","data-th":"Auto-connect",children:e.autoConnect&&m.jsxs(m.Fragment,{children:[m.jsx(je,{icon:qd,className:"text-primary",id:"autoConnectIcon"}),m.jsx(Fr,{target:"autoConnectIcon",placement:"right",children:"Auto-connect to this server"})]})}),m.jsx("th",{className:"responsive-table__cell","data-th":"Name",children:m.jsx(At,{to:`/server/${e.id}`,children:e.name})}),m.jsx("td",{className:"responsive-table__cell","data-th":"Base URL",children:e.url}),m.jsx("td",{className:"responsive-table__cell text-end",children:m.jsx(n,{server:e})})]})},MIe=$i(_9,["ManageServersRowDropdown"]),x9=({server:e,setAutoConnect:t})=>{const{DeleteServerModal:n}=Ri(x9),[r,,i,o]=Lt(),a=`/server/${e.id}`,{autoConnect:s}=e,l=s?lK:cse;return m.jsxs(l0,{minWidth:s?210:170,children:[m.jsxs(Ne,{tag:At,to:a,children:[m.jsx(je,{icon:aK,fixedWidth:!0})," Connect"]}),m.jsxs(Ne,{tag:At,to:`${a}/edit`,children:[m.jsx(je,{icon:sP,fixedWidth:!0})," Edit server"]}),m.jsxs(Ne,{onClick:()=>t(e,!s),children:[m.jsx(je,{icon:l,fixedWidth:!0})," ",s?"Do not a":"A","uto-connect"]}),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{className:"dropdown-item--danger",onClick:i,children:[m.jsx(je,{icon:aP,fixedWidth:!0})," Remove server"]}),m.jsx(n,{redirectHome:!1,server:e,isOpen:r,toggle:o})]})},LIe=$i(x9,["DeleteServerModal"]),w9=(e,t)=>ND(e,t,{serializeError:n=>n}),RIe={},{actions:$Ie,reducer:IIe}=Qt({name:"shlink/servers",initialState:RIe,reducers:{editServer:{prepare:(e,t)=>({payload:{serverId:e,serverData:t}}),reducer:(e,{payload:t})=>{const{serverId:n,serverData:r}=t;return e[n]?{...e,[n]:{...e[n],...r}}:e}},deleteServer:(e,{payload:t})=>(delete e[t.id],e),setAutoConnect:{prepare:({id:e},t)=>({payload:{serverId:e,autoConnect:t}}),reducer:(e,{payload:t})=>{const{serverId:n,autoConnect:r}=t;return e[n]?r?Object.fromEntries(Object.entries(e).map(([i,o])=>[i,{...o,autoConnect:i===n}])):{...e,[n]:{...e[n],autoConnect:r}}:e}},createServers:{prepare:e=>({payload:_Ie(e)}),reducer:(e,{payload:t})=>({...e,...t})}}}),{editServer:DIe,deleteServer:FIe,setAutoConnect:BIe,createServers:O9}=$Ie,UIe=IIe,zIe=e=>Ay({},Array.isArray(e)?e.filter(k6):[]),VIe=e=>w9("shlink/remoteServers/fetchServers",async(t,{dispatch:n})=>{const r=await e.jsonRequest(`${$v.homepage}/servers.json`),i=zIe(r);n(O9(i))}),kC="shlink/selectedServer",WIe="1.0.0",HIe="999.999.999",GIe="latest",qIe=e=>c9(e===GIe?HIe:e,WIe),KIe=RD(e=>`${e.id}_${e.url}_${e.apiKey}`,async(e,t)=>t().then(({version:n})=>({version:qIe(n),printableVersion:l9(n)}))),F4=null,NC=Xn(`${kC}/resetSelectedServer`),YIe=e=>w9(`${kC}/selectServer`,async(t,{dispatch:n,getState:r})=>{n(NC());const{servers:i}=r(),o=i[t];if(!o)return{serverNotFound:!0};try{const a=e(o),{version:s,printableVersion:l}=await KIe(o,()=>a.health());return{...o,version:s,printableVersion:l}}catch{return{...o,serverNotReachable:!0}}}),ZIe=e=>Qt({name:kC,initialState:F4,reducers:{},extraReducers:t=>{t.addCase(NC,()=>F4),t.addCase(e.fulfilled,(n,{payload:r})=>r)}}),XIe=({servers:e,selectedServer:t})=>{const n=Object.values(e),r=()=>n.length===0?m.jsxs(Ne,{tag:At,to:"/server/create",children:[m.jsx(je,{icon:Zh})," ",m.jsx("span",{className:"ms-1",children:"Add a server"})]}):m.jsxs(m.Fragment,{children:[n.map(({name:i,id:o})=>m.jsx(Ne,{tag:At,to:`/server/${o}`,active:Vq(t)===o,children:i},o)),m.jsx(Ne,{divider:!0,tag:"hr"}),m.jsxs(Ne,{tag:At,to:"/manage-servers",children:[m.jsx(je,{icon:nA})," ",m.jsx("span",{className:"ms-1",children:"Manage servers"})]})]});return m.jsxs(rp,{nav:!0,inNavbar:!0,children:[m.jsxs(Jo,{nav:!0,caret:!0,children:[m.jsx(je,{icon:nA})," ",m.jsx("span",{className:"ms-1",children:"Servers"})]}),m.jsx(os,{end:!0,style:{right:0},children:r()})]})},QIe=({document:e},t,n)=>{const r=e.createElement("a");r.setAttribute("href",t),r.setAttribute("download",n),r.style.visibility="hidden",e.body.appendChild(r),r.click(),e.body.removeChild(r)},JIe=(e,t,n)=>{const r=new Blob([t],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(r);QIe(e,i,n)},eDe="shlink-servers.csv";class tDe{constructor(t,n,r){Fl(this,"exportServers",async()=>{const t=Object.values(this.storage.get("servers")??{}).map(Wq);try{const n=this.jsonToCsv(t);JIe(this.window,n,eDe)}catch(n){console.error(n)}});this.storage=t,this.window=n,this.jsonToCsv=r}}const nDe=e=>typeof e.url=="string"&&typeof e.apiKey=="string"&&typeof e.name=="string",rDe=e=>Array.isArray(e)&&e.every(nDe);class iDe{constructor(t){this.csvToJson=t}async importServersFromFile(t){if(!t)throw new Error("No file provided");const n=await t.text(),r=await this.csvToJson(n);if(!rDe(r))throw new Error("Provided file does not have the right format.");return r}}const oDe=(e,t)=>{e.factory("ManageServers",NIe),e.decorator("ManageServers",jy),e.decorator("ManageServers",t(["selectedServer","servers"],["resetSelectedServer"])),e.factory("ManageServersRow",MIe),e.factory("ManageServersRowDropdown",LIe),e.decorator("ManageServersRowDropdown",t(null,["setAutoConnect"])),e.factory("CreateServer",SIe),e.decorator("CreateServer",jy),e.decorator("CreateServer",t(["selectedServer","servers"],["createServers","resetSelectedServer"])),e.factory("EditServer",TIe),e.decorator("EditServer",t(["selectedServer"],["editServer","selectServer","resetSelectedServer"])),e.serviceFactory("ServersDropdown",()=>XIe),e.decorator("ServersDropdown",t(["servers","selectedServer"])),e.serviceFactory("DeleteServerModal",()=>EIe),e.decorator("DeleteServerModal",t(null,["deleteServer"])),e.factory("DeleteServerButton",PIe),e.factory("ImportServersBtn",jIe),e.decorator("ImportServersBtn",t(["servers"],["createServers"])),e.factory("ServerError",AIe),e.decorator("ServerError",t(["servers","selectedServer"])),e.service("ServersImporter",iDe,"csvToJson"),e.service("ServersExporter",tDe,"Storage","window","jsonToCsv"),e.serviceFactory("selectServer",YIe,"buildShlinkApiClient","loadMercureInfo"),e.serviceFactory("createServers",()=>O9),e.serviceFactory("deleteServer",()=>FIe),e.serviceFactory("editServer",()=>DIe),e.serviceFactory("setAutoConnect",()=>BIe),e.serviceFactory("fetchServers",VIe,"HttpClient"),e.serviceFactory("resetSelectedServer",()=>NC),e.serviceFactory("selectedServerReducerCreator",ZIe,"selectServer"),e.serviceFactory("selectedServerReducer",n=>n.reducer,"selectedServerReducerCreator")},S9={field:"dateCreated",dir:"DESC"},aDe={realTimeUpdates:{enabled:!0},shortUrlCreation:{validateUrls:!1},ui:{theme:FP()},visits:{defaultInterval:"last30Days"},shortUrlsList:{defaultOrdering:S9}},{reducer:sDe,actions:lDe}=Qt({name:"shlink/settings",initialState:aDe,reducers:{setSettings:(e,{payload:t})=>p0(e,t)}}),{setSettings:cDe}=lDe,uDe=sDe,fDe=({settings:e,setSettings:t})=>m.jsx(rf,{children:m.jsx(ase,{settings:e,updateSettings:t,defaultShortUrlsListOrdering:S9})}),dDe=(e,t)=>{e.serviceFactory("Settings",()=>fDe),e.decorator("Settings",jy),e.decorator("Settings",t(["settings"],["setSettings","resetSelectedServer"])),e.serviceFactory("setSettings",()=>cDe)};var hDe=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(r,i,o){n.o(r,i)||Object.defineProperty(r,i,{enumerable:!0,get:o})},n.r=function(r){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})},n.t=function(r,i){if(1&i&&(r=n(r)),8&i||4&i&&typeof r=="object"&&r&&r.__esModule)return r;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:r}),2&i&&typeof r!="string")for(var a in r)n.d(o,a,(function(s){return r[s]}).bind(null,a));return o},n.n=function(r){var i=r&&r.__esModule?function(){return r.default}:function(){return r};return n.d(i,"a",i),i},n.o=function(r,i){return Object.prototype.hasOwnProperty.call(r,i)},n.p="",n(n.s=32)}([function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch{typeof window=="object"&&(n=window)}e.exports=n},function(e,t,n){var r=n(6),i=Object.keys||function(y){var g=[];for(var x in y)g.push(x);return g};e.exports=d;var o=n(5);o.inherits=n(2);var a=n(23),s=n(14);o.inherits(d,a);for(var l=i(s.prototype),c=0;c diff --git a/feature/predictable-server-ids/index.html b/feature/predictable-server-ids/index.html index 53e36b2f..335112db 100644 --- a/feature/predictable-server-ids/index.html +++ b/feature/predictable-server-ids/index.html @@ -79,7 +79,7 @@ Shlink — The URL shortener - + diff --git a/feature/predictable-server-ids/service-worker.js b/feature/predictable-server-ids/service-worker.js index 0b880921..7943c0cd 100644 --- a/feature/predictable-server-ids/service-worker.js +++ b/feature/predictable-server-ids/service-worker.js @@ -1,2 +1,2 @@ try{self["workbox:core:7.0.0"]&&_()}catch{}const G=(s,...e)=>{let t=s;return e.length>0&&(t+=` :: ${JSON.stringify(e)}`),t},Q=G;class h extends Error{constructor(e,t){const n=Q(e,t);super(n),this.name=e,this.details=t}}const B=new Set;function z(s){B.add(s)}const d={googleAnalytics:"googleAnalytics",precache:"precache-v2",prefix:"workbox",runtime:"runtime",suffix:typeof registration<"u"?registration.scope:""},k=s=>[d.prefix,s,d.suffix].filter(e=>e&&e.length>0).join("-"),J=s=>{for(const e of Object.keys(d))s(e)},x={updateDetails:s=>{J(e=>{typeof s[e]=="string"&&(d[e]=s[e])})},getGoogleAnalyticsName:s=>s||k(d.googleAnalytics),getPrecacheName:s=>s||k(d.precache),getPrefix:()=>d.prefix,getRuntimeName:s=>s||k(d.runtime),getSuffix:()=>d.suffix};function K(s,e){const t=new URL(s);for(const n of e)t.searchParams.delete(n);return t.href}async function X(s,e,t,n){const i=K(e.url,t);if(e.url===i)return s.match(e,n);const r=Object.assign(Object.assign({},n),{ignoreSearch:!0}),a=await s.keys(e,r);for(const c of a){const o=K(c.url,t);if(i===o)return s.match(c,n)}}let m;function Y(){if(m===void 0){const s=new Response("");if("body"in s)try{new Response(s.body),m=!0}catch{m=!1}m=!1}return m}function q(s){s.then(()=>{})}class Z{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}async function ee(){for(const s of B)await s()}const te=s=>new URL(String(s),location.href).href.replace(new RegExp(`^${location.origin}`),"");function se(s){return new Promise(e=>setTimeout(e,s))}function A(s,e){const t=e();return s.waitUntil(t),t}async function ne(s,e){let t=null;if(s.url&&(t=new URL(s.url).origin),t!==self.location.origin)throw new h("cross-origin-copy-response",{origin:t});const n=s.clone(),r={headers:new Headers(n.headers),status:n.status,statusText:n.statusText},a=Y()?n.body:await n.blob();return new Response(a,r)}function ie(){self.addEventListener("activate",()=>self.clients.claim())}const re=(s,e)=>e.some(t=>s instanceof t);let j,O;function ae(){return j||(j=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function ce(){return O||(O=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const F=new WeakMap,U=new WeakMap,H=new WeakMap,v=new WeakMap,P=new WeakMap;function oe(s){const e=new Promise((t,n)=>{const i=()=>{s.removeEventListener("success",r),s.removeEventListener("error",a)},r=()=>{t(f(s.result)),i()},a=()=>{n(s.error),i()};s.addEventListener("success",r),s.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&F.set(t,s)}).catch(()=>{}),P.set(e,s),e}function le(s){if(U.has(s))return;const e=new Promise((t,n)=>{const i=()=>{s.removeEventListener("complete",r),s.removeEventListener("error",a),s.removeEventListener("abort",a)},r=()=>{t(),i()},a=()=>{n(s.error||new DOMException("AbortError","AbortError")),i()};s.addEventListener("complete",r),s.addEventListener("error",a),s.addEventListener("abort",a)});U.set(s,e)}let T={get(s,e,t){if(s instanceof IDBTransaction){if(e==="done")return U.get(s);if(e==="objectStoreNames")return s.objectStoreNames||H.get(s);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return f(s[e])},set(s,e,t){return s[e]=t,!0},has(s,e){return s instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in s}};function he(s){T=s(T)}function ue(s){return s===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const n=s.call(E(this),e,...t);return H.set(n,e.sort?e.sort():[e]),f(n)}:ce().includes(s)?function(...e){return s.apply(E(this),e),f(F.get(this))}:function(...e){return f(s.apply(E(this),e))}}function de(s){return typeof s=="function"?ue(s):(s instanceof IDBTransaction&&le(s),re(s,ae())?new Proxy(s,T):s)}function f(s){if(s instanceof IDBRequest)return oe(s);if(v.has(s))return v.get(s);const e=de(s);return e!==s&&(v.set(s,e),P.set(e,s)),e}const E=s=>P.get(s);function fe(s,e,{blocked:t,upgrade:n,blocking:i,terminated:r}={}){const a=indexedDB.open(s,e),c=f(a);return n&&a.addEventListener("upgradeneeded",o=>{n(f(a.result),o.oldVersion,o.newVersion,f(a.transaction),o)}),t&&a.addEventListener("blocked",o=>t(o.oldVersion,o.newVersion,o)),c.then(o=>{r&&o.addEventListener("close",()=>r()),i&&o.addEventListener("versionchange",l=>i(l.oldVersion,l.newVersion,l))}).catch(()=>{}),c}function pe(s,{blocked:e}={}){const t=indexedDB.deleteDatabase(s);return e&&t.addEventListener("blocked",n=>e(n.oldVersion,n)),f(t).then(()=>{})}const ge=["get","getKey","getAll","getAllKeys","count"],me=["put","add","delete","clear"],D=new Map;function S(s,e){if(!(s instanceof IDBDatabase&&!(e in s)&&typeof e=="string"))return;if(D.get(e))return D.get(e);const t=e.replace(/FromIndex$/,""),n=e!==t,i=me.includes(t);if(!(t in(n?IDBIndex:IDBObjectStore).prototype)||!(i||ge.includes(t)))return;const r=async function(a,...c){const o=this.transaction(a,i?"readwrite":"readonly");let l=o.store;return n&&(l=l.index(c.shift())),(await Promise.all([l[t](...c),i&&o.done]))[0]};return D.set(e,r),r}he(s=>({...s,get:(e,t,n)=>S(e,t)||s.get(e,t,n),has:(e,t)=>!!S(e,t)||s.has(e,t)}));try{self["workbox:expiration:7.0.0"]&&_()}catch{}const we="workbox-expiration",w="cache-entries",W=s=>{const e=new URL(s,location.href);return e.hash="",e.href};class ye{constructor(e){this._db=null,this._cacheName=e}_upgradeDb(e){const t=e.createObjectStore(w,{keyPath:"id"});t.createIndex("cacheName","cacheName",{unique:!1}),t.createIndex("timestamp","timestamp",{unique:!1})}_upgradeDbAndDeleteOldDbs(e){this._upgradeDb(e),this._cacheName&&pe(this._cacheName)}async setTimestamp(e,t){e=W(e);const n={url:e,timestamp:t,cacheName:this._cacheName,id:this._getId(e)},r=(await this.getDb()).transaction(w,"readwrite",{durability:"relaxed"});await r.store.put(n),await r.done}async getTimestamp(e){const n=await(await this.getDb()).get(w,this._getId(e));return n==null?void 0:n.timestamp}async expireEntries(e,t){const n=await this.getDb();let i=await n.transaction(w).store.index("timestamp").openCursor(null,"prev");const r=[];let a=0;for(;i;){const o=i.value;o.cacheName===this._cacheName&&(e&&o.timestamp=t?r.push(i.value):a++),i=await i.continue()}const c=[];for(const o of r)await n.delete(w,o.id),c.push(o.url);return c}_getId(e){return this._cacheName+"|"+W(e)}async getDb(){return this._db||(this._db=await fe(we,1,{upgrade:this._upgradeDbAndDeleteOldDbs.bind(this)})),this._db}}class _e{constructor(e,t={}){this._isRunning=!1,this._rerunRequested=!1,this._maxEntries=t.maxEntries,this._maxAgeSeconds=t.maxAgeSeconds,this._matchOptions=t.matchOptions,this._cacheName=e,this._timestampModel=new ye(e)}async expireEntries(){if(this._isRunning){this._rerunRequested=!0;return}this._isRunning=!0;const e=this._maxAgeSeconds?Date.now()-this._maxAgeSeconds*1e3:0,t=await this._timestampModel.expireEntries(e,this._maxEntries),n=await self.caches.open(this._cacheName);for(const i of t)await n.delete(i,this._matchOptions);this._isRunning=!1,this._rerunRequested&&(this._rerunRequested=!1,q(this.expireEntries()))}async updateTimestamp(e){await this._timestampModel.setTimestamp(e,Date.now())}async isURLExpired(e){if(this._maxAgeSeconds){const t=await this._timestampModel.getTimestamp(e),n=Date.now()-this._maxAgeSeconds*1e3;return t!==void 0?t{if(!r)return null;const a=this._isResponseDateFresh(r),c=this._getCacheExpiration(i);q(c.expireEntries());const o=c.updateTimestamp(n.url);if(t)try{t.waitUntil(o)}catch{}return a?r:null},this.cacheDidUpdate=async({cacheName:t,request:n})=>{const i=this._getCacheExpiration(t);await i.updateTimestamp(n.url),await i.expireEntries()},this._config=e,this._maxAgeSeconds=e.maxAgeSeconds,this._cacheExpirations=new Map,e.purgeOnQuotaError&&z(()=>this.deleteCacheAndMetadata())}_getCacheExpiration(e){if(e===x.getRuntimeName())throw new h("expire-custom-caches-only");let t=this._cacheExpirations.get(e);return t||(t=new _e(e,this._config),this._cacheExpirations.set(e,t)),t}_isResponseDateFresh(e){if(!this._maxAgeSeconds)return!0;const t=this._getDateHeaderTimestamp(e);if(t===null)return!0;const n=Date.now();return t>=n-this._maxAgeSeconds*1e3}_getDateHeaderTimestamp(e){if(!e.headers.has("date"))return null;const t=e.headers.get("date"),i=new Date(t).getTime();return isNaN(i)?null:i}async deleteCacheAndMetadata(){for(const[e,t]of this._cacheExpirations)await self.caches.delete(e),await t.delete();this._cacheExpirations=new Map}}try{self["workbox:precaching:7.0.0"]&&_()}catch{}const Re="__WB_REVISION__";function Ce(s){if(!s)throw new h("add-to-cache-list-unexpected-type",{entry:s});if(typeof s=="string"){const r=new URL(s,location.href);return{cacheKey:r.href,url:r.href}}const{revision:e,url:t}=s;if(!t)throw new h("add-to-cache-list-unexpected-type",{entry:s});if(!e){const r=new URL(t,location.href);return{cacheKey:r.href,url:r.href}}const n=new URL(t,location.href),i=new URL(t,location.href);return n.searchParams.set(Re,e),{cacheKey:n.href,url:i.href}}class xe{constructor(){this.updatedURLs=[],this.notUpdatedURLs=[],this.handlerWillStart=async({request:e,state:t})=>{t&&(t.originalRequest=e)},this.cachedResponseWillBeUsed=async({event:e,state:t,cachedResponse:n})=>{if(e.type==="install"&&t&&t.originalRequest&&t.originalRequest instanceof Request){const i=t.originalRequest.url;n?this.notUpdatedURLs.push(i):this.updatedURLs.push(i)}return n}}}class ke{constructor({precacheController:e}){this.cacheKeyWillBeUsed=async({request:t,params:n})=>{const i=(n==null?void 0:n.cacheKey)||this._precacheController.getCacheKeyForURL(t.url);return i?new Request(i,{headers:t.headers}):t},this._precacheController=e}}try{self["workbox:strategies:7.0.0"]&&_()}catch{}function R(s){return typeof s=="string"?new Request(s):s}class ve{constructor(e,t){this._cacheKeys={},Object.assign(this,t),this.event=t.event,this._strategy=e,this._handlerDeferred=new Z,this._extendLifetimePromises=[],this._plugins=[...e.plugins],this._pluginStateMap=new Map;for(const n of this._plugins)this._pluginStateMap.set(n,{});this.event.waitUntil(this._handlerDeferred.promise)}async fetch(e){const{event:t}=this;let n=R(e);if(n.mode==="navigate"&&t instanceof FetchEvent&&t.preloadResponse){const a=await t.preloadResponse;if(a)return a}const i=this.hasCallback("fetchDidFail")?n.clone():null;try{for(const a of this.iterateCallbacks("requestWillFetch"))n=await a({request:n.clone(),event:t})}catch(a){if(a instanceof Error)throw new h("plugin-error-request-will-fetch",{thrownErrorMessage:a.message})}const r=n.clone();try{let a;a=await fetch(n,n.mode==="navigate"?void 0:this._strategy.fetchOptions);for(const c of this.iterateCallbacks("fetchDidSucceed"))a=await c({event:t,request:r,response:a});return a}catch(a){throw i&&await this.runCallbacks("fetchDidFail",{error:a,event:t,originalRequest:i.clone(),request:r.clone()}),a}}async fetchAndCachePut(e){const t=await this.fetch(e),n=t.clone();return this.waitUntil(this.cachePut(e,n)),t}async cacheMatch(e){const t=R(e);let n;const{cacheName:i,matchOptions:r}=this._strategy,a=await this.getCacheKey(t,"read"),c=Object.assign(Object.assign({},r),{cacheName:i});n=await caches.match(a,c);for(const o of this.iterateCallbacks("cachedResponseWillBeUsed"))n=await o({cacheName:i,matchOptions:r,cachedResponse:n,request:a,event:this.event})||void 0;return n}async cachePut(e,t){const n=R(e);await se(0);const i=await this.getCacheKey(n,"write");if(!t)throw new h("cache-put-with-no-response",{url:te(i.url)});const r=await this._ensureResponseSafeToCache(t);if(!r)return!1;const{cacheName:a,matchOptions:c}=this._strategy,o=await self.caches.open(a),l=this.hasCallback("cacheDidUpdate"),g=l?await X(o,i.clone(),["__WB_REVISION__"],c):null;try{await o.put(i,l?r.clone():r)}catch(u){if(u instanceof Error)throw u.name==="QuotaExceededError"&&await ee(),u}for(const u of this.iterateCallbacks("cacheDidUpdate"))await u({cacheName:a,oldResponse:g,newResponse:r.clone(),request:i,event:this.event});return!0}async getCacheKey(e,t){const n=`${e.url} | ${t}`;if(!this._cacheKeys[n]){let i=e;for(const r of this.iterateCallbacks("cacheKeyWillBeUsed"))i=R(await r({mode:t,request:i,event:this.event,params:this.params}));this._cacheKeys[n]=i}return this._cacheKeys[n]}hasCallback(e){for(const t of this._strategy.plugins)if(e in t)return!0;return!1}async runCallbacks(e,t){for(const n of this.iterateCallbacks(e))await n(t)}*iterateCallbacks(e){for(const t of this._strategy.plugins)if(typeof t[e]=="function"){const n=this._pluginStateMap.get(t);yield r=>{const a=Object.assign(Object.assign({},r),{state:n});return t[e](a)}}}waitUntil(e){return this._extendLifetimePromises.push(e),e}async doneWaiting(){let e;for(;e=this._extendLifetimePromises.shift();)await e}destroy(){this._handlerDeferred.resolve(null)}async _ensureResponseSafeToCache(e){let t=e,n=!1;for(const i of this.iterateCallbacks("cacheWillUpdate"))if(t=await i({request:this.request,response:t,event:this.event})||void 0,n=!0,!t)break;return n||t&&t.status!==200&&(t=void 0),t}}class V{constructor(e={}){this.cacheName=x.getRuntimeName(e.cacheName),this.plugins=e.plugins||[],this.fetchOptions=e.fetchOptions,this.matchOptions=e.matchOptions}handle(e){const[t]=this.handleAll(e);return t}handleAll(e){e instanceof FetchEvent&&(e={event:e,request:e.request});const t=e.event,n=typeof e.request=="string"?new Request(e.request):e.request,i="params"in e?e.params:void 0,r=new ve(this,{event:t,request:n,params:i}),a=this._getResponse(r,n,t),c=this._awaitComplete(a,r,n,t);return[a,c]}async _getResponse(e,t,n){await e.runCallbacks("handlerWillStart",{event:n,request:t});let i;try{if(i=await this._handle(t,e),!i||i.type==="error")throw new h("no-response",{url:t.url})}catch(r){if(r instanceof Error){for(const a of e.iterateCallbacks("handlerDidError"))if(i=await a({error:r,event:n,request:t}),i)break}if(!i)throw r}for(const r of e.iterateCallbacks("handlerWillRespond"))i=await r({event:n,request:t,response:i});return i}async _awaitComplete(e,t,n,i){let r,a;try{r=await e}catch{}try{await t.runCallbacks("handlerDidRespond",{event:i,request:n,response:r}),await t.doneWaiting()}catch(c){c instanceof Error&&(a=c)}if(await t.runCallbacks("handlerDidComplete",{event:i,request:n,response:r,error:a}),t.destroy(),a)throw a}}class p extends V{constructor(e={}){e.cacheName=x.getPrecacheName(e.cacheName),super(e),this._fallbackToNetwork=e.fallbackToNetwork!==!1,this.plugins.push(p.copyRedirectedCacheableResponsesPlugin)}async _handle(e,t){const n=await t.cacheMatch(e);return n||(t.event&&t.event.type==="install"?await this._handleInstall(e,t):await this._handleFetch(e,t))}async _handleFetch(e,t){let n;const i=t.params||{};if(this._fallbackToNetwork){const r=i.integrity,a=e.integrity,c=!a||a===r;n=await t.fetch(new Request(e,{integrity:e.mode!=="no-cors"?a||r:void 0})),r&&c&&e.mode!=="no-cors"&&(this._useDefaultCacheabilityPluginIfNeeded(),await t.cachePut(e,n.clone()))}else throw new h("missing-precache-entry",{cacheName:this.cacheName,url:e.url});return n}async _handleInstall(e,t){this._useDefaultCacheabilityPluginIfNeeded();const n=await t.fetch(e);if(!await t.cachePut(e,n.clone()))throw new h("bad-precaching-response",{url:e.url,status:n.status});return n}_useDefaultCacheabilityPluginIfNeeded(){let e=null,t=0;for(const[n,i]of this.plugins.entries())i!==p.copyRedirectedCacheableResponsesPlugin&&(i===p.defaultPrecacheCacheabilityPlugin&&(e=n),i.cacheWillUpdate&&t++);t===0?this.plugins.push(p.defaultPrecacheCacheabilityPlugin):t>1&&e!==null&&this.plugins.splice(e,1)}}p.defaultPrecacheCacheabilityPlugin={async cacheWillUpdate({response:s}){return!s||s.status>=400?null:s}};p.copyRedirectedCacheableResponsesPlugin={async cacheWillUpdate({response:s}){return s.redirected?await ne(s):s}};class Ee{constructor({cacheName:e,plugins:t=[],fallbackToNetwork:n=!0}={}){this._urlsToCacheKeys=new Map,this._urlsToCacheModes=new Map,this._cacheKeysToIntegrities=new Map,this._strategy=new p({cacheName:x.getPrecacheName(e),plugins:[...t,new ke({precacheController:this})],fallbackToNetwork:n}),this.install=this.install.bind(this),this.activate=this.activate.bind(this)}get strategy(){return this._strategy}precache(e){this.addToCacheList(e),this._installAndActiveListenersAdded||(self.addEventListener("install",this.install),self.addEventListener("activate",this.activate),this._installAndActiveListenersAdded=!0)}addToCacheList(e){const t=[];for(const n of e){typeof n=="string"?t.push(n):n&&n.revision===void 0&&t.push(n.url);const{cacheKey:i,url:r}=Ce(n),a=typeof n!="string"&&n.revision?"reload":"default";if(this._urlsToCacheKeys.has(r)&&this._urlsToCacheKeys.get(r)!==i)throw new h("add-to-cache-list-conflicting-entries",{firstEntry:this._urlsToCacheKeys.get(r),secondEntry:i});if(typeof n!="string"&&n.integrity){if(this._cacheKeysToIntegrities.has(i)&&this._cacheKeysToIntegrities.get(i)!==n.integrity)throw new h("add-to-cache-list-conflicting-integrities",{url:r});this._cacheKeysToIntegrities.set(i,n.integrity)}if(this._urlsToCacheKeys.set(r,i),this._urlsToCacheModes.set(r,a),t.length>0){const c=`Workbox is precaching URLs without revision info: ${t.join(", ")} -This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return A(e,async()=>{const t=new xe;this.strategy.plugins.push(t);for(const[r,a]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(a),o=this._urlsToCacheModes.get(r),l=new Request(r,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:a},request:l,event:e}))}const{updatedURLs:n,notUpdatedURLs:i}=t;return{updatedURLs:n,notUpdatedURLs:i}})}activate(e){return A(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),n=await t.keys(),i=new Set(this._urlsToCacheKeys.values()),r=[];for(const a of n)i.has(a.url)||(await t.delete(a),r.push(a.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n)return(await self.caches.open(this.strategy.cacheName)).match(n)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new h("non-precached-url",{url:e});return n=>(n.request=new Request(e),n.params=Object.assign({cacheKey:t},n.params),this.strategy.handle(n))}}let L;const I=()=>(L||(L=new Ee),L);try{self["workbox:routing:7.0.0"]&&_()}catch{}const $="GET",C=s=>s&&typeof s=="object"?s:{handle:s};class b{constructor(e,t,n=$){this.handler=C(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=C(e)}}class De extends b{constructor(e,t,n){const i=({url:r})=>{const a=e.exec(r.href);if(a&&!(r.origin!==location.origin&&a.index!==0))return a.slice(1)};super(i,t,n)}}class Le{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",e=>{const{request:t}=e,n=this.handleRequest({request:t,event:e});n&&e.respondWith(n)})}addCacheListener(){self.addEventListener("message",e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(i=>{typeof i=="string"&&(i=[i]);const r=new Request(...i);return this.handleRequest({request:r,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}})}handleRequest({request:e,event:t}){const n=new URL(e.url,location.href);if(!n.protocol.startsWith("http"))return;const i=n.origin===location.origin,{params:r,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:i,url:n});let c=a&&a.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let l;try{l=c.handle({url:n,request:e,event:t,params:r})}catch(u){l=Promise.reject(u)}const g=a&&a.catchHandler;return l instanceof Promise&&(this._catchHandler||g)&&(l=l.catch(async u=>{if(g)try{return await g.handle({url:n,request:e,event:t,params:r})}catch(N){N instanceof Error&&(u=N)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw u})),l}findMatchingRoute({url:e,sameOrigin:t,request:n,event:i}){const r=this._routes.get(n.method)||[];for(const a of r){let c;const o=a.match({url:e,sameOrigin:t,request:n,event:i});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:a,params:c}}return{}}setDefaultHandler(e,t=$){this._defaultHandlerMap.set(t,C(e))}setCatchHandler(e){this._catchHandler=C(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new h("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new h("unregister-route-route-not-registered")}}let y;const Ue=()=>(y||(y=new Le,y.addFetchListener(),y.addCacheListener()),y);function M(s,e,t){let n;if(typeof s=="string"){const r=new URL(s,location.href),a=({url:c})=>c.href===r.href;n=new b(a,e,t)}else if(s instanceof RegExp)n=new De(s,e,t);else if(typeof s=="function")n=new b(s,e,t);else if(s instanceof b)n=s;else throw new h("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return Ue().registerRoute(n),n}function Te(s,e=[]){for(const t of[...s.searchParams.keys()])e.some(n=>n.test(t))&&s.searchParams.delete(t);return s}function*Pe(s,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:n=!0,urlManipulation:i}={}){const r=new URL(s,location.href);r.hash="",yield r.href;const a=Te(r,e);if(yield a.href,t&&a.pathname.endsWith("/")){const c=new URL(a.href);c.pathname+=t,yield c.href}if(n){const c=new URL(a.href);c.pathname+=".html",yield c.href}if(i){const c=i({url:r});for(const o of c)yield o.href}}class Ie extends b{constructor(e,t){const n=({request:i})=>{const r=e.getURLsToCacheKeys();for(const a of Pe(i.url,t)){const c=r.get(a);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(n,e.strategy)}}function Me(s){const e=I(),t=new Ie(e,s);M(t)}function Ne(s){return I().createHandlerBoundToURL(s)}function Ke(s){I().precache(s)}function Ae(s,e){Ke(s),Me(e)}const je={cacheWillUpdate:async({response:s})=>s.status===200||s.status===0?s:null};class Oe extends V{constructor(e={}){super(e),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(je)}async _handle(e,t){const n=t.fetchAndCachePut(e).catch(()=>{});t.waitUntil(n);let i=await t.cacheMatch(e),r;if(!i)try{i=await n}catch(a){a instanceof Error&&(r=a)}if(!i)throw new h("no-response",{url:e.url,error:r});return i}}const Se="shlink-web-client",We="A React-based progressive web application for shlink",Be="/shlink-web-client/feature/predictable-server-ids",qe="https://github.com/shlinkio/shlink-web-client",Fe="MIT",He="module",Ve={lint:"node --run lint:css && node --run lint:js","lint:css":"stylelint src/*.scss src/**/*.scss","lint:js":"eslint src test config/test","lint:fix":"node --run lint:css:fix && node --run lint:js:fix","lint:css:fix":"node --run lint:css -- --fix","lint:js:fix":"node --run lint:js -- --fix",types:"tsc",start:"vite serve --host=0.0.0.0",preview:"vite preview --host=0.0.0.0",build:"node --run types && vite build && node scripts/replace-version.mjs","build:dist":"node --run build && node scripts/create-dist-file.mjs",test:"vitest run --run","test:watch":"vitest --watch","test:ci":"node --run test -- --coverage","test:verbose":"node --run test -- --verbose"},$e={"@fortawesome/fontawesome-free":"^6.6.0","@fortawesome/fontawesome-svg-core":"^6.6.0","@fortawesome/free-brands-svg-icons":"^6.6.0","@fortawesome/free-regular-svg-icons":"^6.6.0","@fortawesome/free-solid-svg-icons":"^6.6.0","@fortawesome/react-fontawesome":"^0.2.2","@json2csv/plainjs":"^7.0.6","@reduxjs/toolkit":"^2.3.0","@shlinkio/data-manipulation":"^1.0.3","@shlinkio/shlink-frontend-kit":"^0.6.0","@shlinkio/shlink-js-sdk":"^1.2.0","@shlinkio/shlink-web-component":"^0.10.1",bootstrap:"5.2.3",bottlejs:"^2.0.1",clsx:"^2.1.1","compare-versions":"^6.1.1",csvtojson:"^2.0.10","date-fns":"^4.1.0",react:"^18.3.1","react-dom":"^18.3.1","react-external-link":"^2.3.1","react-redux":"^9.1.2","react-router-dom":"^6.27.0",reactstrap:"^9.2.3","redux-localstorage-simple":"^2.5.1","workbox-core":"^7.1.0","workbox-expiration":"^7.1.0","workbox-precaching":"^7.1.0","workbox-routing":"^7.1.0","workbox-strategies":"^7.1.0"},Ge={"@shlinkio/eslint-config-js-coding-standard":"~3.2.1","@shlinkio/stylelint-config-css-coding-standard":"~1.1.1","@stylistic/eslint-plugin":"^2.9.0","@testing-library/jest-dom":"^6.5.0","@testing-library/react":"^16.0.1","@testing-library/user-event":"^14.5.2","@total-typescript/shoehorn":"^0.1.2","@types/react":"^18.3.12","@types/react-dom":"^18.3.1","@types/uuid":"^10.0.0","@vitejs/plugin-react":"^4.3.3","@vitest/coverage-v8":"^2.1.3","adm-zip":"^0.5.16","axe-core":"^4.10.2",chalk:"^5.3.0",eslint:"^9.13.0","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-react":"^7.37.2","eslint-plugin-react-hooks":"^5.0.0","eslint-plugin-simple-import-sort":"^12.1.1",history:"^5.3.0",jsdom:"^25.0.1",sass:"^1.80.4",stylelint:"^15.11.0",typescript:"^5.6.3","typescript-eslint":"^8.11.0",vite:"^5.4.10","vite-plugin-pwa":"^0.20.5",vitest:"^2.0.2"},Qe=[">0.2%","not dead","not ie <= 11","not op_mini all"],ze={name:Se,description:We,private:!1,homepage:Be,repository:qe,license:Fe,type:He,scripts:Ve,dependencies:$e,devDependencies:Ge,browserslist:Qe};ie();Ae([{"revision":null,"url":"assets/index-75rZeHHF.js"},{"revision":null,"url":"assets/index-Bv0Tm1UB.css"},{"revision":"1dd2a3aa6d964de8a0439b4d7f0281cd","url":"index.html"},{"revision":"583b223ad8e20f05aaa64923d7db2e46","url":"icons/icon-1024x1024.png"},{"revision":"2dff586aaefa4c8d17f4c0bcbdef8b53","url":"icons/icon-114x114.png"},{"revision":"8e28257a68ef1c55bc68bfff80e1a310","url":"icons/icon-120x120.png"},{"revision":"0059b6f0c97fa871a5c29643b2857585","url":"icons/icon-128x128.png"},{"revision":"41478c2456281f61e54d714718743ecc","url":"icons/icon-144x144.png"},{"revision":"625251910295f33a578ae6d8117711c9","url":"icons/icon-150x150.png"},{"revision":"19b71508b1d05defe32cf16a7d453001","url":"icons/icon-152x152.png"},{"revision":"9d029a32a54ba3084c67acd5d74f8ac4","url":"icons/icon-160x160.png"},{"revision":"6ec104aeaf745f003ecdaef2edddce97","url":"icons/icon-167x167.png"},{"revision":"3e8169a112865ef0d76bba4e2dfd3a89","url":"icons/icon-16x16.png"},{"revision":"871d67907434ed0ddf5d2a6c220e09af","url":"icons/icon-180x180.png"},{"revision":"cee2529402074d73b2135e2ddee25f6b","url":"icons/icon-192x192.png"},{"revision":"85055b452284c0193142936dee7d2cd1","url":"icons/icon-196x196.png"},{"revision":"f471155dd70b99924422dd9dd87ea94d","url":"icons/icon-228x228.png"},{"revision":"20f0b51945ae3c973420e31d6b4d43c1","url":"icons/icon-24x24.png"},{"revision":"4d896c5c7025582605de31fb74f0316b","url":"icons/icon-256x256.png"},{"revision":"d99b49e5bcad41968313c3e132e7c661","url":"icons/icon-310x310.png"},{"revision":"4c9695cfb4cea403c1b66bbb7b4f7420","url":"icons/icon-32x32.png"},{"revision":"f9597636bef677327c3abc0fd1a743c4","url":"icons/icon-384x384.png"},{"revision":"f74edb9cc54ac938c1589876f8da9f21","url":"icons/icon-40x40.png"},{"revision":"52933970fac8498311687de13549b014","url":"icons/icon-48x48.png"},{"revision":"de22c0eb9e08d3576df5cedb568ca56b","url":"icons/icon-512x512.png"},{"revision":"40209a194f29b21882571c77bd2bd906","url":"icons/icon-60x60.png"},{"revision":"c8ba5a8c1da76d74c7bb21827fcf975c","url":"icons/icon-64x64.png"},{"revision":"ae3435baceb494f9c966e2c2c736ea35","url":"icons/icon-72x72.png"},{"revision":"850aa5b026fd1452af6c1ddd9d71850f","url":"icons/icon-76x76.png"},{"revision":"8c62535e6b7a498ece1f6c6ae62ede59","url":"icons/icon-96x96.png"},{"revision":"58e309a1f3e55d0adab77c739b01312a","url":"manifest.json"}]);const Je=new RegExp("/[^/?]+\\.[^/]+$");M(({request:s,url:e})=>!(s.mode!=="navigate"||e.pathname.startsWith("/_")||e.pathname.match(Je)),Ne(`${ze.homepage}/index.html`));M(({url:s})=>s.origin===self.location.origin&&s.pathname.endsWith(".png"),new Oe({cacheName:"images",plugins:[new be({maxEntries:50})]}));self.addEventListener("message",s=>{s.data&&s.data.type==="SKIP_WAITING"&&self.skipWaiting()}); +This is generally NOT safe. Learn more at https://bit.ly/wb-precache`;console.warn(c)}}}install(e){return A(e,async()=>{const t=new xe;this.strategy.plugins.push(t);for(const[r,a]of this._urlsToCacheKeys){const c=this._cacheKeysToIntegrities.get(a),o=this._urlsToCacheModes.get(r),l=new Request(r,{integrity:c,cache:o,credentials:"same-origin"});await Promise.all(this.strategy.handleAll({params:{cacheKey:a},request:l,event:e}))}const{updatedURLs:n,notUpdatedURLs:i}=t;return{updatedURLs:n,notUpdatedURLs:i}})}activate(e){return A(e,async()=>{const t=await self.caches.open(this.strategy.cacheName),n=await t.keys(),i=new Set(this._urlsToCacheKeys.values()),r=[];for(const a of n)i.has(a.url)||(await t.delete(a),r.push(a.url));return{deletedURLs:r}})}getURLsToCacheKeys(){return this._urlsToCacheKeys}getCachedURLs(){return[...this._urlsToCacheKeys.keys()]}getCacheKeyForURL(e){const t=new URL(e,location.href);return this._urlsToCacheKeys.get(t.href)}getIntegrityForCacheKey(e){return this._cacheKeysToIntegrities.get(e)}async matchPrecache(e){const t=e instanceof Request?e.url:e,n=this.getCacheKeyForURL(t);if(n)return(await self.caches.open(this.strategy.cacheName)).match(n)}createHandlerBoundToURL(e){const t=this.getCacheKeyForURL(e);if(!t)throw new h("non-precached-url",{url:e});return n=>(n.request=new Request(e),n.params=Object.assign({cacheKey:t},n.params),this.strategy.handle(n))}}let L;const I=()=>(L||(L=new Ee),L);try{self["workbox:routing:7.0.0"]&&_()}catch{}const $="GET",C=s=>s&&typeof s=="object"?s:{handle:s};class b{constructor(e,t,n=$){this.handler=C(t),this.match=e,this.method=n}setCatchHandler(e){this.catchHandler=C(e)}}class De extends b{constructor(e,t,n){const i=({url:r})=>{const a=e.exec(r.href);if(a&&!(r.origin!==location.origin&&a.index!==0))return a.slice(1)};super(i,t,n)}}class Le{constructor(){this._routes=new Map,this._defaultHandlerMap=new Map}get routes(){return this._routes}addFetchListener(){self.addEventListener("fetch",e=>{const{request:t}=e,n=this.handleRequest({request:t,event:e});n&&e.respondWith(n)})}addCacheListener(){self.addEventListener("message",e=>{if(e.data&&e.data.type==="CACHE_URLS"){const{payload:t}=e.data,n=Promise.all(t.urlsToCache.map(i=>{typeof i=="string"&&(i=[i]);const r=new Request(...i);return this.handleRequest({request:r,event:e})}));e.waitUntil(n),e.ports&&e.ports[0]&&n.then(()=>e.ports[0].postMessage(!0))}})}handleRequest({request:e,event:t}){const n=new URL(e.url,location.href);if(!n.protocol.startsWith("http"))return;const i=n.origin===location.origin,{params:r,route:a}=this.findMatchingRoute({event:t,request:e,sameOrigin:i,url:n});let c=a&&a.handler;const o=e.method;if(!c&&this._defaultHandlerMap.has(o)&&(c=this._defaultHandlerMap.get(o)),!c)return;let l;try{l=c.handle({url:n,request:e,event:t,params:r})}catch(u){l=Promise.reject(u)}const g=a&&a.catchHandler;return l instanceof Promise&&(this._catchHandler||g)&&(l=l.catch(async u=>{if(g)try{return await g.handle({url:n,request:e,event:t,params:r})}catch(N){N instanceof Error&&(u=N)}if(this._catchHandler)return this._catchHandler.handle({url:n,request:e,event:t});throw u})),l}findMatchingRoute({url:e,sameOrigin:t,request:n,event:i}){const r=this._routes.get(n.method)||[];for(const a of r){let c;const o=a.match({url:e,sameOrigin:t,request:n,event:i});if(o)return c=o,(Array.isArray(c)&&c.length===0||o.constructor===Object&&Object.keys(o).length===0||typeof o=="boolean")&&(c=void 0),{route:a,params:c}}return{}}setDefaultHandler(e,t=$){this._defaultHandlerMap.set(t,C(e))}setCatchHandler(e){this._catchHandler=C(e)}registerRoute(e){this._routes.has(e.method)||this._routes.set(e.method,[]),this._routes.get(e.method).push(e)}unregisterRoute(e){if(!this._routes.has(e.method))throw new h("unregister-route-but-not-found-with-method",{method:e.method});const t=this._routes.get(e.method).indexOf(e);if(t>-1)this._routes.get(e.method).splice(t,1);else throw new h("unregister-route-route-not-registered")}}let y;const Ue=()=>(y||(y=new Le,y.addFetchListener(),y.addCacheListener()),y);function M(s,e,t){let n;if(typeof s=="string"){const r=new URL(s,location.href),a=({url:c})=>c.href===r.href;n=new b(a,e,t)}else if(s instanceof RegExp)n=new De(s,e,t);else if(typeof s=="function")n=new b(s,e,t);else if(s instanceof b)n=s;else throw new h("unsupported-route-type",{moduleName:"workbox-routing",funcName:"registerRoute",paramName:"capture"});return Ue().registerRoute(n),n}function Te(s,e=[]){for(const t of[...s.searchParams.keys()])e.some(n=>n.test(t))&&s.searchParams.delete(t);return s}function*Pe(s,{ignoreURLParametersMatching:e=[/^utm_/,/^fbclid$/],directoryIndex:t="index.html",cleanURLs:n=!0,urlManipulation:i}={}){const r=new URL(s,location.href);r.hash="",yield r.href;const a=Te(r,e);if(yield a.href,t&&a.pathname.endsWith("/")){const c=new URL(a.href);c.pathname+=t,yield c.href}if(n){const c=new URL(a.href);c.pathname+=".html",yield c.href}if(i){const c=i({url:r});for(const o of c)yield o.href}}class Ie extends b{constructor(e,t){const n=({request:i})=>{const r=e.getURLsToCacheKeys();for(const a of Pe(i.url,t)){const c=r.get(a);if(c){const o=e.getIntegrityForCacheKey(c);return{cacheKey:c,integrity:o}}}};super(n,e.strategy)}}function Me(s){const e=I(),t=new Ie(e,s);M(t)}function Ne(s){return I().createHandlerBoundToURL(s)}function Ke(s){I().precache(s)}function Ae(s,e){Ke(s),Me(e)}const je={cacheWillUpdate:async({response:s})=>s.status===200||s.status===0?s:null};class Oe extends V{constructor(e={}){super(e),this.plugins.some(t=>"cacheWillUpdate"in t)||this.plugins.unshift(je)}async _handle(e,t){const n=t.fetchAndCachePut(e).catch(()=>{});t.waitUntil(n);let i=await t.cacheMatch(e),r;if(!i)try{i=await n}catch(a){a instanceof Error&&(r=a)}if(!i)throw new h("no-response",{url:e.url,error:r});return i}}const Se="shlink-web-client",We="A React-based progressive web application for shlink",Be="/shlink-web-client/feature/predictable-server-ids",qe="https://github.com/shlinkio/shlink-web-client",Fe="MIT",He="module",Ve={lint:"node --run lint:css && node --run lint:js","lint:css":"stylelint src/*.scss src/**/*.scss","lint:js":"eslint src test config/test","lint:fix":"node --run lint:css:fix && node --run lint:js:fix","lint:css:fix":"node --run lint:css -- --fix","lint:js:fix":"node --run lint:js -- --fix",types:"tsc",start:"vite serve --host=0.0.0.0",preview:"vite preview --host=0.0.0.0",build:"node --run types && vite build && node scripts/replace-version.mjs","build:dist":"node --run build && node scripts/create-dist-file.mjs",test:"vitest run --run","test:watch":"vitest --watch","test:ci":"node --run test -- --coverage","test:verbose":"node --run test -- --verbose"},$e={"@fortawesome/fontawesome-free":"^6.6.0","@fortawesome/fontawesome-svg-core":"^6.6.0","@fortawesome/free-brands-svg-icons":"^6.6.0","@fortawesome/free-regular-svg-icons":"^6.6.0","@fortawesome/free-solid-svg-icons":"^6.6.0","@fortawesome/react-fontawesome":"^0.2.2","@json2csv/plainjs":"^7.0.6","@reduxjs/toolkit":"^2.3.0","@shlinkio/data-manipulation":"^1.0.3","@shlinkio/shlink-frontend-kit":"^0.6.0","@shlinkio/shlink-js-sdk":"^1.2.0","@shlinkio/shlink-web-component":"^0.10.1",bootstrap:"5.2.3",bottlejs:"^2.0.1",clsx:"^2.1.1","compare-versions":"^6.1.1",csvtojson:"^2.0.10","date-fns":"^4.1.0",react:"^18.3.1","react-dom":"^18.3.1","react-external-link":"^2.3.1","react-redux":"^9.1.2","react-router-dom":"^6.27.0",reactstrap:"^9.2.3","redux-localstorage-simple":"^2.5.1","workbox-core":"^7.1.0","workbox-expiration":"^7.1.0","workbox-precaching":"^7.1.0","workbox-routing":"^7.1.0","workbox-strategies":"^7.1.0"},Ge={"@shlinkio/eslint-config-js-coding-standard":"~3.2.1","@shlinkio/stylelint-config-css-coding-standard":"~1.1.1","@stylistic/eslint-plugin":"^2.9.0","@testing-library/jest-dom":"^6.5.0","@testing-library/react":"^16.0.1","@testing-library/user-event":"^14.5.2","@total-typescript/shoehorn":"^0.1.2","@types/react":"^18.3.12","@types/react-dom":"^18.3.1","@types/uuid":"^10.0.0","@vitejs/plugin-react":"^4.3.3","@vitest/coverage-v8":"^2.1.3","adm-zip":"^0.5.16","axe-core":"^4.10.2",chalk:"^5.3.0",eslint:"^9.13.0","eslint-plugin-jsx-a11y":"^6.10.2","eslint-plugin-react":"^7.37.2","eslint-plugin-react-hooks":"^5.0.0","eslint-plugin-simple-import-sort":"^12.1.1",history:"^5.3.0",jsdom:"^25.0.1",sass:"^1.80.4",stylelint:"^15.11.0",typescript:"^5.6.3","typescript-eslint":"^8.11.0",vite:"^5.4.10","vite-plugin-pwa":"^0.20.5",vitest:"^2.0.2"},Qe=[">0.2%","not dead","not ie <= 11","not op_mini all"],ze={name:Se,description:We,private:!1,homepage:Be,repository:qe,license:Fe,type:He,scripts:Ve,dependencies:$e,devDependencies:Ge,browserslist:Qe};ie();Ae([{"revision":null,"url":"assets/index-a1IVSAfq.js"},{"revision":null,"url":"assets/index-Bv0Tm1UB.css"},{"revision":"96224c711241fa60d5f362f2fede371a","url":"index.html"},{"revision":"583b223ad8e20f05aaa64923d7db2e46","url":"icons/icon-1024x1024.png"},{"revision":"2dff586aaefa4c8d17f4c0bcbdef8b53","url":"icons/icon-114x114.png"},{"revision":"8e28257a68ef1c55bc68bfff80e1a310","url":"icons/icon-120x120.png"},{"revision":"0059b6f0c97fa871a5c29643b2857585","url":"icons/icon-128x128.png"},{"revision":"41478c2456281f61e54d714718743ecc","url":"icons/icon-144x144.png"},{"revision":"625251910295f33a578ae6d8117711c9","url":"icons/icon-150x150.png"},{"revision":"19b71508b1d05defe32cf16a7d453001","url":"icons/icon-152x152.png"},{"revision":"9d029a32a54ba3084c67acd5d74f8ac4","url":"icons/icon-160x160.png"},{"revision":"6ec104aeaf745f003ecdaef2edddce97","url":"icons/icon-167x167.png"},{"revision":"3e8169a112865ef0d76bba4e2dfd3a89","url":"icons/icon-16x16.png"},{"revision":"871d67907434ed0ddf5d2a6c220e09af","url":"icons/icon-180x180.png"},{"revision":"cee2529402074d73b2135e2ddee25f6b","url":"icons/icon-192x192.png"},{"revision":"85055b452284c0193142936dee7d2cd1","url":"icons/icon-196x196.png"},{"revision":"f471155dd70b99924422dd9dd87ea94d","url":"icons/icon-228x228.png"},{"revision":"20f0b51945ae3c973420e31d6b4d43c1","url":"icons/icon-24x24.png"},{"revision":"4d896c5c7025582605de31fb74f0316b","url":"icons/icon-256x256.png"},{"revision":"d99b49e5bcad41968313c3e132e7c661","url":"icons/icon-310x310.png"},{"revision":"4c9695cfb4cea403c1b66bbb7b4f7420","url":"icons/icon-32x32.png"},{"revision":"f9597636bef677327c3abc0fd1a743c4","url":"icons/icon-384x384.png"},{"revision":"f74edb9cc54ac938c1589876f8da9f21","url":"icons/icon-40x40.png"},{"revision":"52933970fac8498311687de13549b014","url":"icons/icon-48x48.png"},{"revision":"de22c0eb9e08d3576df5cedb568ca56b","url":"icons/icon-512x512.png"},{"revision":"40209a194f29b21882571c77bd2bd906","url":"icons/icon-60x60.png"},{"revision":"c8ba5a8c1da76d74c7bb21827fcf975c","url":"icons/icon-64x64.png"},{"revision":"ae3435baceb494f9c966e2c2c736ea35","url":"icons/icon-72x72.png"},{"revision":"850aa5b026fd1452af6c1ddd9d71850f","url":"icons/icon-76x76.png"},{"revision":"8c62535e6b7a498ece1f6c6ae62ede59","url":"icons/icon-96x96.png"},{"revision":"58e309a1f3e55d0adab77c739b01312a","url":"manifest.json"}]);const Je=new RegExp("/[^/?]+\\.[^/]+$");M(({request:s,url:e})=>!(s.mode!=="navigate"||e.pathname.startsWith("/_")||e.pathname.match(Je)),Ne(`${ze.homepage}/index.html`));M(({url:s})=>s.origin===self.location.origin&&s.pathname.endsWith(".png"),new Oe({cacheName:"images",plugins:[new be({maxEntries:50})]}));self.addEventListener("message",s=>{s.data&&s.data.type==="SKIP_WAITING"&&self.skipWaiting()});