/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","./functions"],(function(o,n){"use strict";function e(o,e){let t=s(o,e);const a={ascensionFactor:null!=e.ascensionFactor?e.ascensionFactor:.5,descensionFactor:null!=e.descensionFactor?e.descensionFactor:.5},i=0===a.ascensionFactor,c=0===a.descensionFactor,m=i?n.tAscensionZoomOnly:n.tAscensionZoomPan,r=i?n.dtAscensionZoomOnly:n.dtAscensionZoomPan,d=i?n.ddtAscensionZoomOnly:n.ddtAscensionZoomPan,l=c?n.tDescensionZoomOnly:n.tDescensionZoomPan,u=c?n.dtDescensionZoomOnly:n.dtDescensionZoomPan,Z=c?n.ddtDescensionZoomOnly:n.ddtDescensionZoomPan,P=e=>m(o,e,a)+n.tPanion(o,e,a)+l(o,e,a),D=e=>r(o,e,a)+n.dtPanion(o,e,a)+u(o,e,a),f=e=>d(o,e,a)+n.ddtPanion(o,e,a)+Z(o,e,a);let p=P(t);const x=n.tBaseLine(o);let F;const y=e.maximumIterations||20,A=null!=e.maximumDistance?e.maximumDistance:1/0;for(F=0;F<y;F++){const n=1e-6,e=(D(t)+n)/f(t);if(isNaN(e)||t>=A&&e<0){if(!isFinite(A))return null;t=A,p=P(t);break}if(t-=e,t<o.compared.sourceZoom||t<o.compared.targetZoom)return null;const s=P(t);if(Math.abs(s-p)/p<=.005)break;p=s}return p>x*(1-.3)||t<o.compared.sourceZoom||t<o.compared.targetZoom?null:t}function s(o,n){const e=Math.max(o.compared.sourceZoom,o.compared.targetZoom),s=o.source.zoomAtPixelsPerPan(o.desiredPixelFlow/o.compared.pan)/2;return s<e?null!=n.maximumDistance?e+(n.maximumDistance-e)/2:1.5*e:n.maximumDistance?Math.min(n.maximumDistance,s):s}o.optimalDistance=e,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
