// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
var d=document.getElementById("open-pane"),c=document.getElementById("site-pane");if(!d||!c)throw Error("open-pane or site-pane not found");function m(t){"".concat(t," sitePane"),c==null||c.setAttribute("state",t)}function p(){m("open")}function u(){m("close")}var g=t=>t===d||t===c||c.contains(t);d.onmouseover=p,c.onmouseleave=u,document.onfocus=t=>{g(t.target)?p():u()},d.onclick=p,document.onclick=t=>{g(t.target)||u()};var s={x:null,y:null};document.ontouchstart=t=>{var e,n,o,a;s.x=(n=(e=t.touches[0])==null?void 0:e.clientX)!=null?n:null,s.y=(a=(o=t.touches[0])==null?void 0:o.clientY)!=null?a:null},document.ontouchmove=t=>{var a,r,i,h;if(s.x===null||s.y===null)return;let e=s.x-((r=(a=t.touches[0])==null?void 0:a.clientX)!=null?r:0),n=s.y-((h=(i=t.touches[0])==null?void 0:i.clientY)!=null?h:0);if(e===0&&n===0)return;s.x=null,s.y=null;let o=Math.max(12,.01*screen.width,n*1.5);Math.abs(e)>=o&&(e>0?p():u())};var l=String(location);function x(t){l=t}function w(t,e={},n=console.log,o=console.error,a="application/json"){return fetch(t,{method:"POST",body:JSON.stringify(e),headers:{Accept:a,"Content-Type":"application/json"}}).then(r=>r.json()).catch(o).then(n).catch(o)}function T(t,e={},n=console.log,o=console.error,a="application/json"){let r=new URLSearchParams(e).toString();return fetch(r?"".concat(t,"?").concat(r):t,{method:"GET",headers:{Accept:a}}).then(i=>i.json()).catch(o).then(n).catch(o)}var y={URLParamChange:()=>{location.reload()}};function E(t,e,n,o="URLParamChange",a=!0){return P([[t,e]],n,o,a)}function P(t,e,n="URLParamChange",o=!0){let a=new URLSearchParams(location.search);for(let[i,h]of t)a.set(i,h);let r="".concat(location.origin).concat(location.pathname,"?").concat(a.toString());return e.stateType=n,o&&r!==location.href?history.pushState(e,r,r):history.replaceState(e,r,r),l=location.href,r}function f(){if(location.hash==="")return;let t=document.getElementById("header");if(!t)return;let e=document.querySelector(location.hash);e&&scrollBy(0,e.getBoundingClientRect().top-Math.floor(parseFloat(getComputedStyle(t).height)))}setTimeout(f,4),window.onhashchange=f,window.onpopstate=t=>{if(l.split("#")[0]===location.href.split("#")[0]){l=location.href,f();return}if(t.state){let e=t.state,n=y[e.stateType];if(n){t.preventDefault(),n(t),l=location.href,f();return}else console.error("Couldn't find state handler for state",e)}console.error("Couldn't handle state. ",t.state),l=location.href,location.reload()};export{y as PopStateHandlers,T as get,u as hideSitePane,w as post,x as setLastLocation,P as setMultipleURLParams,E as setURLParam};
// @license-end
//# sourceMappingURL=utils.js.map
