import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/regenerator";import{useQuery as n}from"@tanstack/react-query";import{useMemo as o}from"react";import{getQueryKey as a,PADS_URL as c,baseQuery as i,deserializePads as u}from"../constants.js";import{corvaAPI as s}from"../../../clients/index.js";import{mapPad as l}from"./mapPad.js";function p(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function m(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){e(r,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}var f=function(e){var p,f=e.companyId,d=e.well,b=e.wells,y=e.selectedOffsetWellIds,O=o((function(){return a("padsSelected",f,d,b,y)}),[f,d,b,y]),j=n({queryKey:O,queryFn:(p=r(t.mark((function e(r){var n,o,a;return t.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=r.signal,e.next=3,s.get(c,m(m({},i),{},{company:Number(f),well_ids:(d?[Number(d.id)]:null!==(n=null==b?void 0:b.map((function(e){return Number(e.id)})))&&void 0!==n?n:[]).concat(y)}),{signal:o});case 3:return a=e.sent,e.abrupt("return",a);case 5:case"end":return e.stop()}}),e)}))),function(e){return p.apply(this,arguments)}),initialData:{data:[],included:[]},select:function(e){return u(e.data,e.included).map((function(e){return l(e)})).sort((function(e,r){return e.name.localeCompare(r.name)}))},enabled:!!f});return{selectedPads:j.data,isSelectedPadsLoading:j.isFetching}};export{f as useSelectedPads};
//# sourceMappingURL=useSelectedPads.js.map
