/* COPYRIGHT Esri - https://js.arcgis.com/5.1.0/LICENSE.txt */
import{clamp as t}from"../../core/mathUtils.js";import n from"../../geometry/Extent.js";import e from"../../geometry/Multipoint.js";import r from"../../geometry/Point.js";import o from"../../geometry/Polygon.js";import i from"../../geometry/Polyline.js";import{e as s}from"../../chunks/intersectionOperator.js";import{videoSpatialReference as m,sampleExtent as a}from"./constants.js";const x=1920,p=1080;function y(t){if(!t)throw new Error("Missing View");return[t.on("drag",t=>t.stopPropagation()),t.on("key-down",t=>{t.key.startsWith("Arrow")&&t.stopPropagation()})]}const c=(t,n)=>{const e=(t-a.xmin)/(a.xmax-a.xmin),r=(a.ymax-n)/(a.ymax-a.ymin);return{x:e*x,y:r*p}},u=n=>({x:t((n.x+.5)*x,0,x),y:t((.5-n.y)*p,0,p)}),l=t=>h(u(t));function f(t){switch(t.type){case"point":return l(t);case"polyline":return new i({paths:t.paths.map(t=>t.map(([t,n])=>{const e=l({x:t,y:n});return[e.x,e.y]})),spatialReference:m});case"polygon":return new o({rings:t.rings.map(t=>t.map(([t,n])=>{const e=l({x:t,y:n});return[e.x,e.y]})),spatialReference:m});case"multipoint":return new e({points:t.points.map(([t,n])=>{const e=l({x:t,y:n});return[e.x,e.y]}),spatialReference:m});case"extent":{const n=f(o.fromExtent(t));return n?.extent??null}default:return null}}const g=e=>{const r=o.fromExtent(new n(a)),i=s(r,e);return i?i.rings[0].map(([n,e])=>{const{x:r,y:o}=c(n,e);return{x:t(r,0,x),y:t(o,0,p)}}):[]},w=t=>{const e=t.width/2,r=t.height/2,o=a.xmin+e,i=a.xmax-e,s=a.ymin+r,m=a.ymax-r;return o<i&&s<m?new n({xmin:o,ymin:s,xmax:i,ymax:m,spatialReference:a.spatialReference}):null},h=n=>{const e=t(n.x,0,x),o=t(n.y,0,p);return new r({x:a.xmin+e/x*(a.xmax-a.xmin),y:a.ymax-o/p*(a.ymax-a.ymin),spatialReference:a.spatialReference})};export{y as disableVideoZoomAndPan,c as geoToPixel,w as getUpdatedConstraints,g as getUpdatedExtentPoints,f as imageGeometryToVideoMapGeometry,l as imageMapPointToVideoMapPoint,h as pixelToVideoMapPoint,p as videoHeight,x as videoWidth};
