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