let e=!1;const t=[],o=void 0!==window.ontouchstart;
/**
* @file ext-overview_window.js
*
* @license MIT
*
* @copyright 2013 James Sacksteder
*
*/
var i={name:"overview_window",init(i){const l=this,{$id:n,$click:r}=l.svgCanvas,p={};n("sidepanel_content").insertAdjacentHTML("beforeend",'
');const updateViewBox=()=>{const{workarea:e}=l,t=parseFloat(getComputedStyle(e,null).height.replace("px","")),o=parseFloat(getComputedStyle(e,null).width.replace("px","")),i=e.scrollLeft,r=e.scrollTop,p=parseFloat(getComputedStyle(n("svgcanvas"),null).width.replace("px","")),a=parseFloat(getComputedStyle(n("svgcanvas"),null).height.replace("px","")),s=parseFloat(getComputedStyle(n("overviewMiniView"),null).width.replace("px","")),w=parseFloat(getComputedStyle(n("overviewMiniView"),null).height.replace("px","")),v=i/p*s,d=r/a*w,u=o/p*s,c=t/a*w;n("overview_window_view_box").style.minWidth=u+"px",n("overview_window_view_box").style.minHeight=c+"px",n("overview_window_view_box").style.top=d+"px",n("overview_window_view_box").style.left=v+"px"};n("workarea").addEventListener("scroll",(()=>{p.viewBoxDragging||updateViewBox()})),n("workarea").addEventListener("resize",updateViewBox),updateViewBox();const updateViewDimensions=function(){const e=parseFloat(getComputedStyle(n("svgroot"),null).width.replace("px","")),t=parseFloat(getComputedStyle(n("svgroot"),null).height.replace("px","")),o=t/e*parseFloat(getComputedStyle(n("overviewMiniView"),null).width.replace("px",""));n("overviewMiniView").setAttribute("viewBox","640 480 "+e+" "+t),n("overviewMiniView").setAttribute("height",o),updateViewBox()};updateViewDimensions(),p.viewBoxDragging=!1;const updateViewPortFromViewBox=function(){const e=parseFloat(getComputedStyle(n("svgcanvas"),null).width.replace("px","")),t=parseFloat(getComputedStyle(n("svgcanvas"),null).height.replace("px","")),o=parseFloat(getComputedStyle(n("overviewMiniView"),null).width.replace("px","")),i=parseFloat(getComputedStyle(n("overviewMiniView"),null).height.replace("px","")),l=parseFloat(getComputedStyle(n("overview_window_view_box"),null).getPropertyValue("left").replace("px",""))/o*e,r=parseFloat(getComputedStyle(n("overview_window_view_box"),null).getPropertyValue("top").replace("px",""))/i*t;n("workarea").scrollLeft=l,n("workarea").scrollTop=r},a=document.querySelector("#overview_window_view_box");return function(i,l,n,r,p,a){e||document.addEventListener(o?"touchmove":"mousemove",(function(e){let o=e;e.touches&&(o=e.touches[0]);for(let e=0;e=window.innerWidth-i.offsetWidth)return;if(c<1||c>=window.innerHeight-i.offsetHeight)return}i.style.left=u+"px",i.style.top=c+"px"}}))}(a,a,document.querySelector("#overviewMiniView"),(()=>{p.viewBoxDragging=!0,updateViewPortFromViewBox()}),((e,t,o,i)=>{e.offsetLeft+e.offsetWidth>parseFloat(getComputedStyle(t,null).width.replace("px",""))?e.style.left=parseFloat(getComputedStyle(t,null).width.replace("px",""))-e.offsetWidth+"px":e.offsetLeft<0&&(e.style.left="0px"),e.offsetTop+e.offsetHeight>parseFloat(getComputedStyle(t,null).height.replace("px",""))?e.style.top=parseFloat(getComputedStyle(t,null).height.replace("px",""))-e.offsetHeight+"px":e.offsetTop<0&&(e.style.top="0px"),p.viewBoxDragging=!1,updateViewPortFromViewBox()}),(function(){updateViewPortFromViewBox()})),r(n("overviewMiniView"),(e=>{const t=e.offsetX||e.originalEvent.layerX,o=e.offsetY||e.originalEvent.layerY,i=parseFloat(getComputedStyle(n("overviewMiniView"),null).width.replace("px","")),l=parseFloat(getComputedStyle(n("overviewMiniView"),null).height.replace("px","")),r=parseFloat(getComputedStyle(n("overview_window_view_box"),null).getPropertyValue("min-width").replace("px","")),p=parseFloat(getComputedStyle(n("overview_window_view_box"),null).getPropertyValue("min-height").replace("px",""));let a=t-.5*r,s=o-.5*p;a<0&&(a=0),s<0&&(s=0),a+r>i&&(a=i-r),s+p>l&&(s=l-p),n("overview_window_view_box").style.top=s+"px",n("overview_window_view_box").style.left=a+"px",updateViewPortFromViewBox()})),{name:"overview window",canvasUpdated:updateViewDimensions,workareaResized:updateViewBox}}};export{i as default};
//# sourceMappingURL=ext-overview_window.js.map