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