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