"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/helpers/toConsumableArray"),n=require("react"),o=require("lodash"),i=require("react-virtualized"),u=require("../constants.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(e),l=c(r),s=c(t);function f(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 p(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?f(Object(t),!0).forEach((function(r){a.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):f(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var d=function(e,r,t){var n=s.default(e),o=r===u.ColumnType.lastActive;return n.sort((function(e,n){var u=e[r],c=n[r],a=!u||"string"==typeof u&&"null"===u.toLowerCase(),l=!c||"string"==typeof c&&"null"===c.toLowerCase();return a&&(0!==u||o)?1:l&&(0!==c||o)?-1:"string"==typeof u&&"string"==typeof c?t===i.SortDirection.ASC?u.localeCompare(c):c.localeCompare(u):t===i.SortDirection.ASC?u>=c?1:-1:c>=u?1:-1})),n};exports.useSortedWells=function(e,r,t,c,a){var s=n.useState(u.ColumnType.distance),f=l.default(s,2),b=f[0],y=f[1],O=n.useState(i.SortDirection.ASC),m=l.default(O,2),v=m[0],j=m[1],S=n.useMemo((function(){if(!r)return null;var n=new Set(t.map((function(e){return e.id}))),i=n.size>0?n:new Set(a||[]),u=r.filter((function(r){return r.id!==(null==e?void 0:e.id)&&i.has(r.id)})),c=d(u,b,v),l=r.filter((function(e){return!i.has(e.id)})),s=d(l,b,v);return(e&&!o.isEmpty(e)?[e]:[]).concat(c).concat(s).map((function(e){return p(p({},e),{},{checked:i.has(e.id)})}))}),[r,b,v,e,t,a]);return n.useEffect((function(){null!==S&&c(!1)}),[S,c]),[b,y,v,j,S]};
//# sourceMappingURL=useSortedWells.js.map
