/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../../core/maybe","../../../../chunks/vec3","../../../../chunks/vec3f64","../../../../geometry/support/ray","../../../../chunks/sphere","./common"],(function(e,t,n,r,i,o,c){"use strict";function a(e,t,n=c.defaultApplyOptions){if(!e.state.isLocal)return 0;const r=e.state.constraints.distance;if(!e.pointsOfInterest.surfaceOrigin.renderLocation||r===1/0)return 0;p.min=0,p.max=r,u(e,n,p);const i=f(e,t),o=p.max-i;return o>=-1e-6?0:o}function s(e,r,s=c.defaultApplyOptions){const u=a(e,r,s);if(0===u)return!1;const p=e.pointsOfInterest.surfaceOrigin,I=f(e,r)+u,C=n.copy(y,r.eye),x=c.interactionDirectionTowardsConstraintMinimization(r,s.interactionDirection,d(e,r,O),l);if(!o.intersectRay(o.fromCenterAndRadius(p.renderLocation,I),i.wrap(r.eye,x),g))return!1;r.eye=g;const T=n.subtract(m,r.eye,C);r.center=n.add(g,r.center,T);const A=e.renderCoordsHelper.getAltitude(r.center),L=e.renderCoordsHelper.intersectInfiniteManifold(r.ray,A,g);return t.isSome(L)&&(r.center=L),!0}function u(e,t,n){const r=t.interactionType;if(r===c.InteractionType.NONE)return;const{min:i,max:o}=n,{interactionStartCamera:s,interactionFactor:u}=t,d=r===c.InteractionType.ZOOM||r===c.InteractionType.PAN,p=a(e,s),y=0===p?0:f(e,s);n.min=i,n.max=o;const m=.05*y;c.adjustRangeForInteraction(p,y,d,u,m,n)}function f(e,t){const r=e.pointsOfInterest.surfaceOrigin;return n.distance(t.eye,r.renderLocation)}function d(e,t,r){const i=e.pointsOfInterest.surfaceOrigin;return n.direction(r,t.eye,i.renderLocation)}const p={min:0,max:0},y=r.create(),m=r.create(),l=r.create(),O=r.create(),g=r.create();e.applyDistanceConstraint=s,e.getDistanceConstraintError=a,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
