"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),s=require("react"),t=require("../constants.js"),u=require("../utils/selection-geometry.js");require("../../../../stores/selection-tool-store/SelectionToolStoreContext.js"),require("../../../../stores/selection-tool-store/SelectionToolStoreProvider.js"),require("zustand");var r=require("../../../../stores/selection-tool-store/useSelectionToolStore.js"),i=require("./utils/radius-geometry.js"),n=require("./useRadiusDrawingEffects.js"),o=require("./useRadiusMouseMove.js"),a=require("./useRadiusDragEnd.js"),l=require("./useRadiusActions.js"),d=require("./useRadiusClickHandlers.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=c(e);exports.clampRadius=function(e){return Math.max(t.MapConfig.Radius.Min,Math.min(e,t.MapConfig.Radius.Max))},exports.useRadiusDrawing=function(e){var t=e.mapRef,c=e.isActive,R=e.wells,g=e.onWellsSelected,M=e.subjectWellId,S=r.useSelectionToolStore((function(e){return e.setRadiusState})),v=r.useSelectionToolStore((function(e){return e.radiusState})),p=r.useSelectionToolStore((function(e){return e.setMode})),j=s.useState(null),q=f.default(j,2),C=q[0],I=q[1],h=s.useState(null),m=f.default(h,2),D=m[0],H=m[1],w=s.useState(!1),x=f.default(w,2),y=x[0],E=x[1],T=s.useState(!1),b=f.default(T,2),O=b[0],k=b[1],A=s.useState(!1),P=f.default(A,2),W=P[0],G=P[1],U=s.useRef("none"),_=s.useRef(null),z=s.useRef(null),J=s.useRef(null),N={setCenter:I,setRadiusMiles:H,setIsDragging:G,setIsHoveringEdge:E,setIsHoveringInside:k,centerRef:_,radiusMilesRef:z,dragModeRef:U,dragOffsetRef:J},B=s.useMemo((function(){return C&&D?u.getWellsInCircle(R,C,D,null!=M?M:void 0):[]}),[R,C,D,M]),F=s.useMemo((function(){return C&&D?i.createCircleGeoJSON(C,D):null}),[C,D]),K=d.useRadiusClickHandlers(c,v,C,D,y,O,I,G,S,_,U,J),L=K.handleMapClick,Q=K.handleMouseDown,V=o.useRadiusMouseMove(t,c,v,C,D,U,_,z,J,H,I,E,k),X=a.useRadiusDragEnd(U,_,z,J,G,S),Y=l.useRadiusActions(v,B,C,g,S,p,N),Z=Y.confirm,$=Y.cancel,ee=Y.setRadiusMilesExternal;return n.useGlobalRadiusMouseUp(X,U),n.useResetOnInactive(c,{setCenter:I,setRadiusMiles:H,setIsDragging:G,setIsHoveringEdge:E,setIsHoveringInside:k},{dragModeRef:U,centerRef:_,radiusMilesRef:z,dragOffsetRef:J}),n.useSyncPlacingCenter(v.phase,I,H,_,z),n.useSyncRadiusMilesRef(D,z),{radiusState:v,radiusMiles:D,setRadiusMiles:ee,wellsInRadiusCount:B.length,previewCircle:F,isHoveringEdge:y,isHoveringInside:O,isDragging:W,handlers:{handleMapClick:L,handleMouseMove:V,handleMouseDown:Q,handleMouseUp:X},confirm:Z,cancel:$}};
//# sourceMappingURL=useRadiusDrawing.js.map
