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