function e(e){return typeof e==`string`?e:typeof e==`number`&&!isNaN(e)||typeof e==`boolean`?String(e):``}function t(t){let n=new URLSearchParams;for(let[r,i]of Object.entries(t)){if(Array.isArray(i)){for(let t of i)n.append(r,e(t));continue}n.set(r,e(i))}return n}function n(e,t){let n=e.indexOf(`?`);if(n===-1)return t;let r=e.slice(n+1).split(`#`)[0];if(!r)return t;let i=t.indexOf(`#`),a=i===-1?t:t.slice(0,i),o=i===-1?``:t.slice(i),s=a.indexOf(`?`),c=s===-1?a:a.slice(0,s),l=s===-1?``:a.slice(s+1),u=new URLSearchParams(r),d=new URLSearchParams(l),f=new Set;for(let e of d.keys())f.add(e);for(let e of f)u.delete(e);for(let[e,t]of d)u.append(e,t);let p=u.toString();return`${c}${p?`?${p}`:``}${o}`}function r(e,t){let n=e.indexOf(`#`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n),a=r.indexOf(`?`),o=a===-1?r:r.slice(0,a),s=a===-1?``:r.slice(a+1),c=new URLSearchParams(s);for(let[e,n]of t)c.append(e,n);let l=c.toString();return`${o}${l?`?${l}`:``}${i}`}export{n,t as r,r as t};