"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),t=require("../../../../utils/tile-math.js"),n=require("../constants.js"),r=require("./getViewportBounds.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=o(e),a=function(e){return Array.isArray(e)?[e[0],e[1]]:"lng"in e?[e.lng,e.lat]:"lon"in e?[e.lon,e.lat]:[0,0]},u=function(e,o,i,a){for(var u=Math.max(o,n.ClusterConfig.unclusteredMinZoom),l=0;l<5;l+=1){var s=r.getViewportBounds(e,u,i,a),d=t.estimateTileCount(s);if(d<=t.MAX_VIEWPORT_TILES_FOR_FETCH)break;u+=t.getZoomIncreaseForTileLimit(d)}return u};exports.MIN_ZOOM_DELTA=.01,exports.computeCurrentTileSafeZoom=function(e){var t=e.getCenter(),n=e.getCanvas(),r=n.clientWidth,o=n.clientHeight;return r<=0||o<=0?null:u([t.lng,t.lat],e.getZoom(),r,o)},exports.computeTileSafeZoom=u,exports.normalizeLngLat=a,exports.smartFitBounds=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o=r.padding,l=void 0===o?n.MapConfig.FitBounds.Padding:o,s=r.duration,d=void 0===s?700:s,c=i.default(t,4),g=c[0],f=c[1],m=c[2],p=c[3],v=[[g,f],[m,p]],T=e.cameraForBounds(v,{padding:l});if(null!=(null==T?void 0:T.zoom)&&T.center){var C=a(T.center),h=e.getCanvas(),_=u(C,T.zoom,h.clientWidth,h.clientHeight);e.flyTo({center:C,zoom:_,duration:d})}else e.fitBounds(v,{padding:l,duration:d})};
//# sourceMappingURL=smartFitBounds.js.map
