var c=t=>{try{return new URL(t),!0}catch{return!1}},i=t=>{if(c(t))return t;try{if(t.includes(".")&&!t.includes(" "))return new URL(`https://${t}`).toString()}catch{}return t},m=t=>{let e={};return new URL(t).searchParams.forEach(function(r,s){e[s]=r}),e},u=t=>{let e={};return new URL(t).searchParams.forEach(function(r,s){if(s in e){let n=e[s];Array.isArray(n)?n.push(r):e[s]=[n,r]}else e[s]=r}),e},p=t=>{if(!t)return{};try{let e=new URL(t).searchParams,r={};for(let[s,n]of e.entries())n&&n!==""&&(r[s]=n);return r}catch{return{}}},g=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"],l=(t,e)=>{if(!t)return"";try{let r=new URL(t);for(let[s,n]of Object.entries(e))n===""?r.searchParams.delete(s):r.searchParams.set(s,n);return r.toString()}catch{return""}},o=[{display:"Referral (ref)",key:"ref",examples:"twitter, facebook"},{display:"UTM Source",key:"utm_source",examples:"twitter, facebook"},{display:"UTM Medium",key:"utm_medium",examples:"social, email"},{display:"UTM Campaign",key:"utm_campaign",examples:"summer_sale"},{display:"UTM Term",key:"utm_term",examples:"blue_shoes"},{display:"UTM Content",key:"utm_content",examples:"logolink"}],f=t=>{try{let e=new URL(t);return o.forEach(r=>e.searchParams.delete(r.key)),e.toString()}catch{return t}},U=t=>t?t.replace(/(^\w+:|^)\/\//,"").replace("www.","").replace(/\/$/,""):"",d=(t,e,r)=>{if(e==="dub.co")return t;let s=new URL(t.startsWith("/")?`https://dub.co${t}`:t);return r&&Object.entries(r).forEach(([n,a])=>{s.searchParams.set(n,a)}),s.toString()};export{c as a,i as b,m as c,u as d,p as e,g as f,l as g,o as h,f as i,U as j,d as k};
