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