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