import e from"@babel/runtime/helpers/slicedToArray";import{useCallback as r}from"react";import{MapConfig as t}from"../constants.js";var i=function(i){var o=i.mapRef,a=i.isViewOnly,l=i.isRadiusToolActive,s=i.radiusDrawingHandlers,n=i.shouldSuppressClickRef,u=i.handleChangeOffsetWell;return r((function(r){var i;if(!a)if(n.current)n.current=!1;else if(l)s.handleMapClick(r);else{var f=r.features;if(null!=f&&f.length){var d=f[0],p=null===(i=d.layer)||void 0===i?void 0:i.id;if(p!==t.LayerIds.WellsClusters){if(p===t.LayerIds.WellsUnclustered){var c=d.properties;if(c){var m={id:c.id,name:c.name,formation:c.formation,totalDepth:c.totalDepth,rigReleaseDate:c.rigReleaseDate};u(m,!c.isOffsetWell)}}}else!function(r){var i,o,a=r.mapRef,l=r.feature,s=null===(i=a.current)||void 0===i?void 0:i.getMap(),n=null===(o=l.properties)||void 0===o?void 0:o.cluster_id;if(s&&void 0!==n&&"Point"===l.geometry.type){var u=e(l.geometry.coordinates,2),f=u[0],d=u[1],p=s.getSource(t.SourceIds.WellsClustered);p&&p.getClusterExpansionZoom(n,(function(e,r){e||void 0===r||s.easeTo({center:[f,d],zoom:(null!=r?r:0)+.5,duration:300})}))}}({mapRef:o,feature:d})}}}),[a,n,l,s,u,o])};export{i as useMapClickHandler};
//# sourceMappingURL=useMapClickHandler.js.map
