function l(e){let t;try{t=new URL(e,"http://example.com").search.substring(1)}catch{}if(t)return t}function f(e){let t="";const i=Object.entries(e);let s;for(;s=i.shift();){let[o,r]=s;if(Array.isArray(r)||r&&r.constructor===Object){const c=Object.entries(r).reverse();for(const[a,u]of c)i.unshift([`${o}[${a}]`,u])}else r!==void 0&&(r===null&&(r=""),t+="&"+[o,String(r)].map(encodeURIComponent).join("="))}return t.substr(1)}function y(e){const t=/^\S+?(#[^\s\?]*)/.exec(e);if(t)return t[1]}function g(e){try{return decodeURIComponent(e)}catch{return e}}function p(e,t,i){const s=t.length,o=s-1;for(let r=0;r<s;r++){let n=t[r];!n&&Array.isArray(e)&&(n=e.length.toString()),n=["__proto__","constructor","prototype"].includes(n)?n.toUpperCase():n;const c=!isNaN(Number(t[r+1]));e[n]=r===o?i:e[n]||(c?[]:{}),Array.isArray(e[n])&&!c&&(e[n]={...e[n]}),e=e[n]}}function d(e){return(l(e)||"").replace(/\+/g,"%20").split("&").reduce((t,i)=>{const[s,o=""]=i.split("=").filter(Boolean).map(g);if(s){const r=s.replace(/\]/g,"").split("[");p(t,r,o)}return t},Object.create(null))}function m(e="",t){if(!t||!Object.keys(t).length)return e;const i=y(e)||"";let s=e.replace(i,"");const o=e.indexOf("?");return o!==-1&&(t=Object.assign(d(e),t),s=s.substr(0,o)),s+"?"+f(t)+i}export{m as a};
