@uwrl/qc-utils 0.0.17 → 0.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/README.md +56 -0
  2. package/dist/index.js +2149 -893
  3. package/dist/index.umd.cjs +15 -5
  4. package/dist/types/index.d.ts +38 -16
  5. package/dist/utils/format.d.ts +0 -1
  6. package/dist/utils/index.d.ts +1 -0
  7. package/dist/utils/plotting/__tests__/calibration.spec.d.ts +16 -0
  8. package/dist/utils/plotting/__tests__/observation-record-paths.spec.d.ts +21 -0
  9. package/dist/utils/plotting/__tests__/operation-cores.spec.d.ts +12 -0
  10. package/dist/utils/plotting/__tests__/workerMocks.d.ts +119 -0
  11. package/dist/utils/plotting/__tests__/workers.spec.d.ts +18 -0
  12. package/dist/utils/plotting/add-data.worker.d.ts +1 -0
  13. package/dist/utils/plotting/calibration.d.ts +99 -0
  14. package/dist/utils/plotting/change.worker.d.ts +1 -0
  15. package/dist/utils/plotting/delete-data.worker.d.ts +1 -0
  16. package/dist/utils/plotting/drift-correction.worker.d.ts +1 -0
  17. package/dist/utils/plotting/fill-gaps.worker.d.ts +1 -0
  18. package/dist/utils/plotting/find-gaps.worker.d.ts +1 -0
  19. package/dist/utils/plotting/interpolate.worker.d.ts +1 -0
  20. package/dist/utils/plotting/observation-record.d.ts +153 -27
  21. package/dist/utils/plotting/operation-cores.d.ts +139 -0
  22. package/dist/utils/plotting/persistence.worker.d.ts +1 -0
  23. package/dist/utils/plotting/rate-of-change.worker.d.ts +1 -0
  24. package/dist/utils/plotting/shift-datetimes.worker.d.ts +1 -0
  25. package/dist/utils/plotting/value-threshold.worker.d.ts +1 -0
  26. package/package.json +61 -56
  27. /package/dist/utils/plotting/{__tests__/delete-data.worker.spec.d.ts → change-values.worker.d.ts} +0 -0
@@ -1,5 +1,15 @@
1
- (function(u,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(u=typeof globalThis<"u"?globalThis:u||self,S(u["@uwrl/qc-utils"]={}))})(this,function(u){"use strict";var S=(e=>(e.SECOND="s",e.MINUTE="m",e.HOUR="h",e.DAY="D",e.WEEK="W",e.MONTH="M",e.YEAR="Y",e))(S||{}),g=(e=>(e.ADD_POINTS="ADD_POINTS",e.CHANGE_VALUES="CHANGE_VALUES",e.DELETE_POINTS="DELETE_POINTS",e.DRIFT_CORRECTION="DRIFT_CORRECTION",e.INTERPOLATE="INTERPOLATE",e.SHIFT_DATETIMES="SHIFT_DATETIMES",e.FILL_GAPS="FILL_GAPS",e))(g||{}),O=(e=>(e.FIND_GAPS="FIND_GAPS",e.PERSISTENCE="PERSISTENCE",e.CHANGE="CHANGE",e.RATE_OF_CHANGE="RATE_OF_CHANGE",e.VALUE_THRESHOLD="VALUE_THRESHOLD",e))(O||{}),ve=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e.START="Start datetime",e.END="End datetime",e))(ve||{});const Se={"Less than":(e,t)=>e<t,"Less than or equal to":(e,t)=>e<=t,"Greater than":(e,t)=>e>t,"Greater than or equal to":(e,t)=>e>=t,Equal:(e,t)=>e==t,"Start datetime":(e,t)=>e==t,"End datetime":(e,t)=>e==t};var L=(e=>(e.ADD="ADD",e.SUB="SUB",e.MULT="MULT",e.DIV="DIV",e.ASSIGN="ASSIGN",e))(L||{}),Ee=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(Ee||{});const V={"Less than":(e,t)=>e<t,"Less than or equal to":(e,t)=>e<=t,"Greater than":(e,t)=>e>t,"Greater than or equal to":(e,t)=>e>=t,Equal:(e,t)=>e==t};class _e{id;thingId;link;frequency;path;datastreamIds;publicResource;constructor(){this.id="",this.thingId="",this.link="",this.frequency=null,this.path="HydroShare",this.datastreamIds=[],this.publicResource=!1}}class Ze extends _e{resourceTitle;resourceAbstract;resourceKeywords;constructor(){super(),this.resourceTitle=void 0,this.resourceAbstract=void 0,this.resourceKeywords=void 0}}class $e{latitude;longitude;elevation_m;elevationDatum;state;county;country;constructor(){this.elevationDatum="WGS84",this.state="",this.county="",this.country=""}}class et{id;workspaceId;name;location=new $e;tags;hydroShareArchive;siteType;samplingFeatureCode;isPrivate;description;samplingFeatureType;dataDisclaimer;constructor(){this.id="",this.workspaceId="",this.name="",this.tags=[],this.siteType="",this.samplingFeatureCode="",this.isPrivate=!1,this.description="",this.samplingFeatureType="Site",this.dataDisclaimer=""}}class tt{id;workspaceId;name;description;thingId;observationType;resultType;status;sampledMedium;noDataValue;aggregationStatistic;unitId;observedPropertyId;sensorId;processingLevelId;isPrivate;isVisible;phenomenonBeginTime;phenomenonEndTime;intendedTimeSpacing;intendedTimeSpacingUnit;timeAggregationInterval;timeAggregationIntervalUnit;dataSourceId;valueCount;constructor(t){this.id="",this.workspaceId="",this.name="",this.description="",this.thingId=t||"",this.observationType="OM_Measurement",this.resultType="Time Series Coverage",this.sampledMedium="",this.noDataValue=-9999,this.aggregationStatistic="",this.unitId="",this.observedPropertyId="",this.sensorId="",this.processingLevelId="",this.timeAggregationInterval=null,this.timeAggregationIntervalUnit="seconds",this.isPrivate=!0,this.isVisible=!0,this.valueCount=0}}class rt{id;workspaceId;name;symbol;definition;type;constructor(){this.id="",this.workspaceId="",this.name="",this.symbol="",this.definition="",this.type=""}}class st{id;workspaceId;name;description;manufacturer;model;methodType;methodCode;methodLink;encodingType;modelLink;constructor(){this.id="",this.workspaceId="",this.name="",this.description="",this.manufacturer="",this.model="",this.methodType="Instrument Deployment",this.methodCode="",this.methodLink="",this.encodingType="application/json",this.modelLink=""}}class at{id;workspaceId;name;definition;description;type;code;constructor(){this.id="",this.workspaceId="",this.name="",this.definition="",this.description="",this.type="Hydrology",this.code=""}}class nt{id;workspaceId;code;definition;explanation;constructor(){this.id="",this.workspaceId="",this.code="",this.definition="",this.explanation=""}}class it{id;workspaceId;code;description;constructor(){this.id="",this.workspaceId="",this.code="",this.description=""}}class ot{name;code;type;description;link;constructor(){}}class ct{id;email;password;firstName;middleName;lastName;phone;address;organization;type;link;accountType;hydroShareConnected;constructor(){this.id="",this.email="",this.password="",this.firstName="",this.middleName="",this.lastName="",this.phone="",this.address="",this.type="",this.link="",this.accountType="standard",this.hydroShareConnected=!1}}class ut{id;name;iconLink;signupEnabled;connectEnabled;constructor(){this.id="",this.name="",this.iconLink="",this.signupEnabled=!0,this.connectEnabled=!0}}var Te=(e=>(e.Global="*",e.View="view",e.Create="create",e.Edit="edit",e.Delete="delete",e))(Te||{}),we=(e=>(e.Global="*",e.Workspace="Workspace",e.Collaborator="Collaborator",e.Thing="Thing",e.Datastream="Datastream",e.Sensor="Sensor",e.Unit="Unit",e.ObservedProperty="ObservedProperty",e.ProcessingLevel="ProcessingLevel",e.Observation="Observation",e))(we||{});class ht{id="";key="";name="";description="";isActive=!0;expiresAt="";createdAt="";lastUsed="";workspaceId="";role=null;constructor(t){Object.assign(this,t)}}class lt{id;name;isPrivate;owner;collaboratorRole;pendingTransferTo;constructor(){this.id="",this.name="",this.isPrivate=!1,this.owner=null,this.collaboratorRole=null,this.pendingTransferTo=null}}class dt{user;role;constructor(){this.user={phone:"",address:"",link:"",type:"",name:"",email:"",organizationName:""},this.role={name:"",description:"",id:"",isApikeyRole:!1,isUserRole:!1,workspaceId:"",permissions:[]}}}function z(){const e="csrftoken=",r=decodeURIComponent(document.cookie).split(";");for(const s of r){const a=s.trim();if(a.startsWith(e))return a.substring(e.length)}return null}function J(e){let t=e.headers?{...e.headers}:{},r;return e.body!==void 0&&(r=typeof e.body=="string"||e.body instanceof FormData?e.body:JSON.stringify(e.body)),t["X-CSRFToken"]=z()||"",{...e,headers:t,body:r,credentials:"omit"}}function Ae(e){if(Array.isArray(e?.errors)&&e.errors.length&&(e=e.errors[0]),typeof e!="object"||e===null)return"An unknown error occurred.";const t=["message","detail","error"];for(const r of t)if(e[r])return e[r];return"An unknown error occurred."}async function Q(e){if(e.headers.get("Content-Length")==="0"||e.statusText==="No Content")return null;const t=e.headers.get("content-type")||"";let r=null;if(t.includes("application/json"))try{r=await e.json()}catch(a){console.error("Failed to parse error JSON:",a)}else if(t.includes("text/csv"))try{r=await e.blob()}catch(a){console.error("Failed to parse error JSON:",a)}if(e.ok||e.status===401)return r;const s={status:e.status,message:Ae(r)};throw console.error("API response not OK:",s.message),s}var K=function(e,t){return K=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])},K(e,t)};function M(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");K(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Z(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ee(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),a,n=[],o;try{for(;(t===void 0||t-- >0)&&!(a=s.next()).done;)n.push(a.value)}catch(c){o={error:c}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function te(e,t,r){if(r||arguments.length===2)for(var s=0,a=t.length,n;s<a;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function T(e){return typeof e=="function"}function Oe(e){var t=function(s){Error.call(s),s.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var re=Oe(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
2
- `+r.map(function(s,a){return a+1+") "+s.toString()}).join(`
3
- `):"",this.name="UnsubscriptionError",this.errors=r}});function se(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Y=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,s,a,n;if(!this.closed){this.closed=!0;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var c=Z(o),h=c.next();!h.done;h=c.next()){var l=h.value;l.remove(this)}}catch(E){t={error:E}}finally{try{h&&!h.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}else o.remove(this);var f=this.initialTeardown;if(T(f))try{f()}catch(E){n=E instanceof re?E.errors:[E]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var y=Z(d),v=y.next();!v.done;v=y.next()){var F=v.value;try{De(F)}catch(E){n=n??[],E instanceof re?n=te(te([],ee(n)),ee(E.errors)):n.push(E)}}}catch(E){s={error:E}}finally{try{v&&!v.done&&(a=y.return)&&a.call(y)}finally{if(s)throw s.error}}}if(n)throw new re(n)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)De(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&se(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&se(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}(),Le=Y.EMPTY;function Ie(e){return e instanceof Y||e&&"closed"in e&&T(e.remove)&&T(e.add)&&T(e.unsubscribe)}function De(e){T(e)?e():e.unsubscribe()}var ft={Promise:void 0},pt={setTimeout:function(e,t){for(var r=[],s=2;s<arguments.length;s++)r[s-2]=arguments[s];return setTimeout.apply(void 0,te([e,t],ee(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function yt(e){pt.setTimeout(function(){throw e})}function ke(){}function H(e){e()}var Fe=function(e){M(t,e);function t(r){var s=e.call(this)||this;return s.isStopped=!1,r?(s.destination=r,Ie(r)&&r.add(s)):s.destination=bt,s}return t.create=function(r,s,a){return new ae(r,s,a)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Y),mt=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(s){j(s)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(s){j(s)}else j(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){j(r)}},e}(),ae=function(e){M(t,e);function t(r,s,a){var n=e.call(this)||this,o;return T(r)||!r?o={next:r??void 0,error:s??void 0,complete:a??void 0}:o=r,n.destination=new mt(o),n}return t}(Fe);function j(e){yt(e)}function gt(e){throw e}var bt={closed:!0,next:ke,error:gt,complete:ke},vt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function St(e){return e}function Et(e){return e.length===0?St:e.length===1?e[0]:function(r){return e.reduce(function(s,a){return a(s)},r)}}var Pe=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,s){var a=this,n=$t(t)?t:new ae(t,r,s);return H(function(){var o=a,c=o.operator,h=o.source;n.add(c?c.call(n,h):h?a._subscribe(n):a._trySubscribe(n))}),n},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var s=this;return r=Re(r),new r(function(a,n){var o=new ae({next:function(c){try{t(c)}catch(h){n(h),o.unsubscribe()}},error:n,complete:a});s.subscribe(o)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[vt]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return Et(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=Re(t),new t(function(s,a){var n;r.subscribe(function(o){return n=o},function(o){return a(o)},function(){return s(n)})})},e.create=function(t){return new e(t)},e}();function Re(e){var t;return(t=e??ft.Promise)!==null&&t!==void 0?t:Promise}function _t(e){return e&&T(e.next)&&T(e.error)&&T(e.complete)}function $t(e){return e&&e instanceof Fe||_t(e)&&Ie(e)}var Tt=Oe(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Ne=function(e){M(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var s=new Ce(this,this);return s.operator=r,s},t.prototype._throwIfClosed=function(){if(this.closed)throw new Tt},t.prototype.next=function(r){var s=this;H(function(){var a,n;if(s._throwIfClosed(),!s.isStopped){s.currentObservers||(s.currentObservers=Array.from(s.observers));try{for(var o=Z(s.currentObservers),c=o.next();!c.done;c=o.next()){var h=c.value;h.next(r)}}catch(l){a={error:l}}finally{try{c&&!c.done&&(n=o.return)&&n.call(o)}finally{if(a)throw a.error}}}})},t.prototype.error=function(r){var s=this;H(function(){if(s._throwIfClosed(),!s.isStopped){s.hasError=s.isStopped=!0,s.thrownError=r;for(var a=s.observers;a.length;)a.shift().error(r)}})},t.prototype.complete=function(){var r=this;H(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var s=r.observers;s.length;)s.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var s=this,a=this,n=a.hasError,o=a.isStopped,c=a.observers;return n||o?Le:(this.currentObservers=null,c.push(r),new Y(function(){s.currentObservers=null,se(c,r)}))},t.prototype._checkFinalizedStatuses=function(r){var s=this,a=s.hasError,n=s.thrownError,o=s.isStopped;a?r.error(n):o&&r.complete()},t.prototype.asObservable=function(){var r=new Pe;return r.source=this,r},t.create=function(r,s){return new Ce(r,s)},t}(Pe),Ce=function(e){M(t,e);function t(r,s){var a=e.call(this)||this;return a.destination=r,a.source=s,a}return t.prototype.next=function(r){var s,a;(a=(s=this.destination)===null||s===void 0?void 0:s.next)===null||a===void 0||a.call(s,r)},t.prototype.error=function(r){var s,a;(a=(s=this.destination)===null||s===void 0?void 0:s.error)===null||a===void 0||a.call(s,r)},t.prototype.complete=function(){var r,s;(s=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||s===void 0||s.call(r)},t.prototype._subscribe=function(r){var s,a;return(a=(s=this.source)===null||s===void 0?void 0:s.subscribe(r))!==null&&a!==void 0?a:Le},t}(Ne);const ne=3e3;var ie=(e=>(e.Warning="warning",e.Success="success",e.Error="error",e.Info="info",e))(ie||{}),oe=(e=>(e.Success="mdi-checkbox-marked-circle",e.Warning="mdi-alert",e.Error="mdi-alert-circle",e.Info="mdi-information",e.None="none",e))(oe||{}),ce=(e=>(e.Warning="Warning",e.Success="Success",e.Error="Error",e.Info="Info",e))(ce||{}),Ue=(e=>(e.Center="center",e.Left="left",e.Right="right",e.Bottom="bottom",e.Top="top",e))(Ue||{});class Be{constructor(t="",r="info",s="none",a="Info",n=ne,o="center",c=!1){this.message=t,this.color=r,this.icon=s,this.title=a,this.timeout=n,this.position=o,this.visible=c}}class Me{static subject=new Ne;static get snack$(){return this.subject.asObservable()}static createSnackbar(t,r){this.subject.next(new Be(t,ie[r],oe[r],ce[r],ne,"bottom",!0))}static success(t){this.createSnackbar(t,"Success")}static warn(t){this.createSnackbar(t,"Warning")}static error(t){this.createSnackbar(t,"Error")}static info(t){this.createSnackbar(t,"Info")}}function ue(e,t){const r={};for(let s in t)if(Array.isArray(t[s]))JSON.stringify(e[s])!==JSON.stringify(t[s])&&(r[s]=t[s]);else if(e[s]&&typeof e[s]=="object"&&t[s]&&typeof t[s]=="object"){const a=ue(e[s],t[s]);Object.keys(a).length>0&&(r[s]=a)}else JSON.stringify(e[s])!==JSON.stringify(t[s])&&(r[s]=t[s]);return r}function wt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var he,Ye;function At(){if(Ye)return he;Ye=1;class e{constructor(s){this.value=s,this.next=void 0}}class t{constructor(){this.clear()}enqueue(s){const a=new e(s);this._head?(this._tail.next=a,this._tail=a):(this._head=a,this._tail=a),this._size++}dequeue(){const s=this._head;if(s)return this._head=this._head.next,this._size--,s.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let s=this._head;for(;s;)yield s.value,s=s.next}}return he=t,he}var le,He;function Ot(){if(He)return le;He=1;const e=At();return le=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const s=new e;let a=0;const n=()=>{a--,s.size>0&&s.dequeue()()},o=async(l,f,...d)=>{a++;const y=(async()=>l(...d))();f(y);try{await y}catch{}n()},c=(l,f,...d)=>{s.enqueue(o.bind(null,l,f,...d)),(async()=>(await Promise.resolve(),a<r&&s.size>0&&s.dequeue()()))()},h=(l,...f)=>new Promise(d=>{c(l,d,...f)});return Object.defineProperties(h,{activeCount:{get:()=>a},pendingCount:{get:()=>s.size},clearQueue:{value:()=>{s.clear()}}}),h},le}var Lt=Ot();const I=wt(Lt)(10),It=1e3;async function P(e,t){const r=J(t);try{const s=await fetch(e,r);return await Q(s)}catch(s){throw s instanceof TypeError&&Me.error("Network error. Please check your connection."),s}}const i={async fetch(e,t={}){return t.method="GET",await I(()=>P(e,t))},async patch(e,t,r=null,s={}){if(s.method="PATCH",s.body=r?ue(r,t):t,Object.keys(s.body).length!==0)return await I(()=>P(e,s))},async post(e,t=void 0,r={}){return r.method="POST",r.body=t,await I(()=>P(e,r))},async put(e,t=void 0,r={}){return r.method="PUT",r.body=t,await I(()=>P(e,r))},async delete(e,t=void 0,r={}){return r.method="DELETE",r.body=t,await I(()=>P(e,r))},async paginatedFetch(e,t){const r=t??It,s=e.includes("?")?"&":"?",a=`${e}${s}page_size=${r}&page=1`,n=J({method:"GET"}),o=await I(()=>fetch(a,n)),c=Number(o.headers.get("x-total-pages"))||1,l=[...await Q(o)];for(let f=2;f<=c;f++){const d=`${e}${s}page_size=${r}&page=${f}`,y=await I(()=>P(d,{method:"GET"}));l.push(...y)}return l}},je={HTTP:{type:"HTTP",sourceUri:"",placeholderVariables:[]},local:{type:"local",sourceUri:"",placeholderVariables:[]}},Ge={JSON:{type:"JSON",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},JMESPath:""},CSV:{type:"CSV",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},headerRow:1,dataStartRow:2,delimiter:",",identifierType:"name"}},We={HydroServer:{type:"HydroServer"}};class Dt{name="";settings={type:"SDL",extractor:JSON.parse(JSON.stringify(je.local)),transformer:JSON.parse(JSON.stringify(Ge.CSV)),loader:JSON.parse(JSON.stringify(We.HydroServer)),payloads:[]};id="";workspaceId="";orchestrationSystem={id:"",name:"",workspaceId:"",type:""};schedule={interval:15,intervalUnits:"minutes"};status={paused:!0};datastreams=[];constructor(t){Object.assign(this,t)}switchExtractor(t){this.settings.extractor=JSON.parse(JSON.stringify(je[t]))}switchTransformer(t){this.settings.transformer=JSON.parse(JSON.stringify(Ge[t]))}switchLoader(t){this.settings.loader=JSON.parse(JSON.stringify(We[t]))}}function Xe(e){return{name:e.name,settings:e.settings,workspaceId:e.workspaceId,orchestrationSystemId:e.orchestrationSystem.id,schedule:e.schedule,status:e.status}}const _="https://lro.hydroserver.org/api",G=`${_}/auth`,$=`${G}/browser/account`,W=`${G}/browser/session`,U=`${G}/browser/provider`,m=`${_}/data/workspaces`,de=`${_}/data/roles`,b=`${_}/data/datastreams`,A=`${_}/data/sensors`,p=`${_}/data/things`,fe=`${p}/tags`,R=`${_}/data/orchestration-systems`,w=`${_}/data/data-sources`,D=`${_}/data/observed-properties`,N=`${_}/data/processing-levels`,B=`${_}/data/result-qualifiers`,k=`${_}/data/units`,kt=(e,t,r,s,a)=>{let n=`${b}/${e}/observations?format=column`;return n+=`&order_by=phenomenonTime&page_size=${t}`,n+=`&phenomenon_time_min=${encodeURIComponent(r)}`,s&&(n+=`&phenomenon_time_max=${encodeURIComponent(s)}`),a&&(n+=`&page=${a}`),n},Ft={fetchSession:async()=>i.fetch(`${W}`),login:async(e,t)=>i.post(`${W}`,{email:e,password:t}),logout:async()=>i.delete(`${W}`),fetchUser:async()=>i.fetch(`${$}`),signup:async e=>i.post(`${$}`,e),updateUser:async(e,t)=>i.patch(`${$}`,e,t),deleteUser:async()=>i.delete(`${$}`),sendVerificationEmail:async e=>i.put(`${$}/email/verify`,{email:e}),verifyEmailWithCode:async e=>i.post(`${$}/email/verify`,{key:e}),requestPasswordReset:async e=>i.post(`${$}/password/request`,{email:e}),resetPassword:async(e,t)=>i.post(`${$}/password/reset`,{key:e,password:t}),fetchWorkspaces:async()=>i.paginatedFetch(`${m}`),fetchAssociatedWorkspaces:async()=>i.paginatedFetch(`${m}?is_associated=true`),fetchWorkspace:async e=>i.fetch(`${m}/${e}`),createWorkspace:async e=>i.post(m,e),updateWorkspace:async(e,t=null)=>i.patch(`${m}/${e.id}`,e,t),deleteWorkspace:async e=>i.delete(`${m}/${e}`),transferWorkspace:async(e,t)=>i.post(`${m}/${e}/transfer`,{newOwner:t}),acceptWorkspaceTransfer:async e=>i.put(`${m}/${e}/transfer`),rejectWorkspaceTransfer:async e=>i.delete(`${m}/${e}/transfer`),getCollaboratorRoles:async e=>i.paginatedFetch(`${de}?is_user_role=true`),getAPIKeyRoles:async e=>i.paginatedFetch(`${de}?is_apikey_role=true`),getRole:async e=>i.fetch(`${de}/${e}`),getCollaborators:async e=>i.paginatedFetch(`${m}/${e}/collaborators`),addCollaborator:async(e,t,r)=>i.post(`${m}/${e}/collaborators`,{email:t,roleId:r}),updateCollaboratorRole:async(e,t,r)=>i.put(`${m}/${e}/collaborators`,{email:t,roleId:r}),removeCollaborator:async(e,t)=>i.delete(`${m}/${e}/collaborators`,{email:t}),fetchApiKeys:async e=>i.paginatedFetch(`${m}/${e}/api-keys?expand_related=true`),fetchApiKey:async(e,t)=>i.fetch(`${m}/${e}/api-keys/${t}?expand_related=true`),createApiKey:async e=>i.post(`${m}/${e.workspaceId}/api-keys?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id}),updateApiKey:async(e,t)=>i.patch(`${m}/${e.workspaceId}/api-keys/${e.id}?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id},t&&{name:t.name,description:t.description,isActive:!0,roleId:t.role.id}),regenerateApiKey:async(e,t)=>i.put(`${m}/${e}/api-keys/${t}/regenerate?expand_related=true`),deleteApiKey:async(e,t)=>i.delete(`${m}/${e}/api-keys/${t}`),fetchConnectedProviders:async()=>i.fetch(`${U}/connections`),providerRedirect:(e,t,r)=>{const s={provider:e,callback_url:t,process:r},a=z(),n=document.createElement("form");if(n.method="POST",n.action=`${U}/redirect`,a){const o=document.createElement("input");o.type="hidden",o.name="csrfmiddlewaretoken",o.value=a,n.appendChild(o)}for(const o in s){const c=document.createElement("input");c.type="hidden",c.name=o,c.value=s[o]||"",n.appendChild(c)}document.body.appendChild(n),n.submit()},providerSignup:async e=>i.post(`${U}/signup`,e),deleteProvider:async(e,t)=>i.delete(`${U}/connections`,{provider:e,account:t}),createUnit:async e=>i.post(k,e),fetchUnits:async()=>i.paginatedFetch(`${k}`),fetchWorkspaceUnits:async e=>i.paginatedFetch(`${k}?workspace_id=${e}`),updateUnit:async(e,t=null)=>i.patch(`${k}/${e.id}`,e,t),deleteUnit:async e=>i.delete(`${k}/${e}`),getUnit:async e=>i.fetch(`${k}/${e}`),removeThingOwner:async(e,t)=>i.patch(`${p}/${e}/ownership`,{email:t,removeOwner:!0}),addSecondaryOwner:async(e,t)=>i.patch(`${p}/${e}/ownership`,{email:t,makeOwner:!0}),transferPrimaryOwnership:async(e,t)=>i.patch(`${p}/${e}/ownership`,{email:t,transferPrimary:!0}),createThing:async e=>i.post(p,e),fetchThings:async()=>i.paginatedFetch(`${p}`),fetchThingsForWorkspace:async e=>i.paginatedFetch(`${p}?workspace_id=${e}`),fetchOwnedThings:async()=>i.paginatedFetch(`${p}?owned_only=true`),fetchThing:async e=>i.fetch(`${p}/${e}`),updateThing:async e=>i.patch(`${p}/${e.id}`,e),updateThingPrivacy:async(e,t)=>i.patch(`${p}/${e}`,{isPrivate:t}),deleteThing:async e=>i.delete(`${p}/${e}`),fetchMetadataForThingOwner:async e=>i.paginatedFetch(`${p}/${e}/metadata?include_assignable_metadata=true`),fetchMetadataForThing:async e=>i.fetch(`${p}/${e}/metadata`),uploadSitePhotos:async(e,t)=>i.post(`${p}/${e}/photos`,t),fetchSitePhotos:async e=>i.paginatedFetch(`${p}/${e}/photos`),deleteSitePhoto:async(e,t)=>i.delete(`${p}/${e}/photos`,{name:t}),createSiteTag:async(e,t)=>i.post(`${p}/${e}/tags`,t),editSiteTag:async(e,t)=>i.put(`${p}/${e}/tags`,t),fetchSiteTags:async e=>i.fetch(`${p}/${e}/tags`),fetchUsersSiteTags:async()=>i.fetch(`${fe}`),deleteSiteTag:async(e,t)=>i.delete(`${p}/${e}/tags`,t),fetchWorkspaceTags:async e=>i.fetch(`${fe}/keys?workspace_id=${e}`),createHydroShareArchive:async e=>i.post(`${p}/${e.thingId}/archive`,e),updateHydroShareArchive:async(e,t)=>i.patch(`${p}/${e.thingId}/archive`,e,t),fetchHydroShareArchive:async e=>i.fetch(`${p}/${e}/archive`),deleteHydroShareArchive:async e=>i.delete(`${p}/${e}/archive`),archiveToHydroShare:async e=>i.post(`${p}/${e}/archive/trigger`),createDatastream:async e=>i.post(b,e),fetchDatastreams:async e=>{const t=[];if(e)for(const[s,a]of Object.entries(e))t.push(`${encodeURIComponent(s)}=${encodeURIComponent(a)}`);const r=t.length?`?${t.join("&")}`:"";return i.paginatedFetch(`${b}${r}`)},fetchDatastreamsForThing:async e=>i.paginatedFetch(`${b}?thing_id=${e}`),fetchExpandedDatastreamsForThing:async e=>i.paginatedFetch(`${b}?thing_id=${e}&expand_related=true`),fetchDatastreamsForDataSource:async e=>i.paginatedFetch(`${b}?data_source_id=${e}`),fetchDatastream:async e=>i.fetch(`${b}/${e}`),fetchDatastreamExpanded:async e=>i.fetch(`${b}/${e}?expand_related=true`),fetchUsersDatastreams:async()=>i.paginatedFetch(`${b}?exclude_unowned=true`),updateDatastream:async(e,t=null)=>i.patch(`${b}/${e.id}`,e,t),deleteDatastream:async e=>i.delete(`${b}/${e}`),downloadDatastreamCSV:async e=>i.fetch(`${b}/${e}/csv`),createObservedProperty:async e=>i.post(D,e),fetchObservedProperty:async e=>i.fetch(`${D}/${e}`),fetchObservedProperties:async()=>i.paginatedFetch(`${D}`),fetchWorkspaceObservedProperties:async e=>i.paginatedFetch(`${D}?workspace_id=${e}`),updateObservedProperty:async(e,t=null)=>i.patch(`${D}/${e.id}`,e,t),deleteObservedProperty:async e=>i.delete(`${D}/${e}`),createProcessingLevel:async e=>i.post(N,e),fetchProcessingLevels:async()=>i.paginatedFetch(`${N}`),fetchProcessingLevel:async e=>i.fetch(`${N}/${e}`),fetchWorkspaceProcessingLevels:async e=>i.paginatedFetch(`${N}?workspace_id=${e}`),updateProcessingLevel:async(e,t=null)=>i.patch(`${N}/${e.id}`,e,t),deleteProcessingLevel:async e=>i.delete(`${N}/${e}`),createSensor:async e=>i.post(A,e),fetchSensors:async()=>i.paginatedFetch(`${A}`),fetchSensor:async e=>i.fetch(`${A}/${e}`),fetchWorkspaceSensors:async e=>i.paginatedFetch(`${A}?workspace_id=${e}`),updateSensor:async(e,t=null)=>i.patch(`${A}/${e.id}`,e,t),deleteSensor:async e=>i.delete(`${A}/${e}`),createResultQualifier:async e=>i.post(B,e),fetchResultQualifiers:async()=>i.paginatedFetch(`${B}`),fetchWorkspaceResultQualifiers:async e=>i.paginatedFetch(`${B}?workspace_id=${e}`),updateResultQualifier:async(e,t=null)=>i.patch(`${B}/${e.id}`,e,t),deleteResultQualifier:async e=>i.delete(`${B}/${e}`),createOrchestrationSystem:async e=>i.post(R,e),fetchOrchestrationSystems:async()=>i.paginatedFetch(R),fetchWorkspaceOrchestrationSystems:async e=>i.paginatedFetch(`${R}?workspace_id=${e}`),fetchOrchestrationSystem:async e=>i.fetch(`${R}/${e}`),updateOrchestrationSystem:async(e,t)=>i.patch(`${R}/${e}`,t),deleteOrchestrationSystem:async e=>i.delete(`${R}/${e}`),createDataSource:async e=>i.post(`${w}?expand_related=true`,Xe(e)),fetchDataSources:async()=>i.paginatedFetch(`${w}?expand_related=true`),fetchWorkspaceDataSources:async e=>i.paginatedFetch(`${w}?workspace_id=${e}&expand_related=true`),fetchDataSource:async e=>i.fetch(`${w}/${e}?expand_related=true`),updateDataSource:async e=>i.patch(`${w}/${e.id}?expand_related=true`,Xe(e)),updateDataSourcePartial:async e=>i.patch(`${w}/${e.id}?expand_related=true`,e),deleteDataSource:async e=>i.delete(`${w}/${e}`),linkDatastreamToDataSource:async(e,t)=>i.post(`${w}/${e}/datastreams/${t}`),unlinkDatastreamFromDataSource:async(e,t)=>i.delete(`${w}/${e}/datastreams/${t}`),fetchObservations:async e=>i.fetch(e),deleteObservationsForDatastream:async e=>i.post(`${b}/${e}/observations/bulk-delete`,{phenomenonTimeStart:null,phenomenonTimeEnd:null}),fetchUserTypes:async()=>i.fetch(`${$}/user-types`),fetchOrganizationTypes:async()=>i.fetch(`${$}/organization-types`),fetchSiteTypes:async()=>i.fetch(`${p}/site-types`),fetchSamplingFeatureTypes:async()=>i.paginatedFetch(`${p}/sampling-feature-types`),fetchSensorEncodingTypes:async()=>i.paginatedFetch(`${A}/encoding-types`),fetchMethodTypes:async()=>i.paginatedFetch(`${A}/method-types`),fetchVariableTypes:async()=>i.paginatedFetch(`${D}/variable-types`),fetchUnitTypes:async()=>i.paginatedFetch(`${k}/types`),fetchDatastreamStatuses:async()=>i.paginatedFetch(`${b}/statuses`),fetchDatastreamAggregations:async()=>i.paginatedFetch(`${b}/aggregation-statistics`),fetchSampledMediums:async()=>i.paginatedFetch(`${b}/sampled-mediums`)};class Pt{name="";mappings=[];extractorVariables={};constructor(t){Object.assign(this,t)}}const xe=1,X=xe*60,pe=X*60,ye=pe*24,Rt=ye*7,Nt=pe*30,Ct=ye*365,x={[S.SECOND]:xe,[S.MINUTE]:X,[S.HOUR]:pe,[S.DAY]:ye,[S.WEEK]:Rt,[S.MONTH]:Nt,[S.YEAR]:Ct},Ut=e=>e.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"}),Bt=e=>{let t,r;e>=X*1e3?(t=e/(X*1e3),r="m"):e>=1e3?(t=e/1e3,r="s"):(t=e,r="ms");let s;return r==="ms"?s=Math.round(t).toString():s=t.toFixed(2),`${s} ${r}`},qe=(e,t,r)=>{if(r===S.MONTH){const s=new Date(e);return s.setMonth(s.getMonth()+t),s.getTime()}else if(r===S.YEAR){const s=new Date(e);return s.setFullYear(s.getFullYear()+t),s.getTime()}else return e+t*x[r]*1e3},q=async(e,t)=>{t&&console.info(t);const r=performance.now(),s=await e(),a=performance.now();console.info(` Done in ${(a-r).toFixed(2)} ms`);const n=+(a-r);return{response:s,duration:n}};function Mt(e,t){const r=new Date(e);return r.setHours(r.getHours()-t),r.toISOString()}const Ve=(e,t)=>{let r=0,s=e.length;for(;r<s;){const a=r+s>>1;e[a]<t?r=a+1:s=a}return r},me=(e,t)=>{let r=0,s=e.length;for(;r<s;){const a=r+s>>1;e[a]>t?s=a:r=a+1}return r-1},ze=`(function(){"use strict";self.onmessage=o=>{const{bufferX:s,bufferY:n,outputBufferX:u,outputBufferY:f,start:l,end:y,deleteSegment:a,startTarget:c}=o.data,A=new Float64Array(s),d=new Float32Array(n),g=new Float64Array(u),p=new Float32Array(f);let e=0,r=c;for(let t=l;t<=y;t++)e<a.length&&t===a[e]?e++:(g[r]=A[t],p[r]=d[t],r++);self.postMessage("Done")}})();
4
- `,Je=typeof self<"u"&&self.Blob&&new Blob([ze],{type:"text/javascript;charset=utf-8"});function Yt(e){let t;try{if(t=Je&&(self.URL||self.webkitURL).createObjectURL(Je),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(ze),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const Qe=`(function(){"use strict";self.onmessage=function(e){const{bufferX:f,bufferY:t,outputBufferX:u,outputBufferY:s}=e.data;self.postMessage("Done")}})();
5
- `,Ke=typeof self<"u"&&self.Blob&&new Blob([Qe],{type:"text/javascript;charset=utf-8"});function Ht(e){let t;try{if(t=Ke&&(self.URL||self.webkitURL).createObjectURL(Ke),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Qe),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}const C=20*1e3,jt=["date","value","qualifier"];class Gt{dataset={dimensions:jt,source:{x:new Float64Array(new SharedArrayBuffer(C*Float64Array.BYTES_PER_ELEMENT,{maxByteLength:C*Float64Array.BYTES_PER_ELEMENT})),y:new Float32Array(new SharedArrayBuffer(C*Float32Array.BYTES_PER_ELEMENT,{maxByteLength:C*Float32Array.BYTES_PER_ELEMENT}))}};history=[];loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const r=await q(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=r.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const r=t*Float64Array.BYTES_PER_ELEMENT;let s=this.dataX.buffer.byteLength;for(;r>s;)s+=C*Float64Array.BYTES_PER_ELEMENT;if(s*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const a=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:s*Float64Array.BYTES_PER_ELEMENT}),n=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:s*Float32Array.BYTES_PER_ELEMENT}),o=new Float64Array(a),c=new Float32Array(n);o.set(this.dataX),c.set(this.dataY),this.dataset.source.x=o,this.dataset.source.y=c}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(this.dataX.buffer.grow(t*Float64Array.BYTES_PER_ELEMENT),this.dataY.buffer.grow(t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const r=this.history.slice(0,t+1);await this.reload(),await this.dispatch(r.map(s=>[s.method,...s.args||[]]))}async removeHistoryItem(t){const r=[...this.history];r.splice(t,1),await this.reload(),await this.dispatch(r.map(s=>[s.method,...s.args||[]]))}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatch(t,...r){const s={[g.ADD_POINTS]:this._addDataPoints,[g.CHANGE_VALUES]:this._changeValues,[g.DELETE_POINTS]:this._deleteDataPoints,[g.DRIFT_CORRECTION]:this._driftCorrection,[g.INTERPOLATE]:this._interpolate,[g.SHIFT_DATETIMES]:this._shift,[g.FILL_GAPS]:this._fillGaps},a={[g.ADD_POINTS]:"mdi-plus",[g.CHANGE_VALUES]:"mdi-pencil",[g.DELETE_POINTS]:"mdi-trash-can",[g.DRIFT_CORRECTION]:"mdi-chart-sankey",[g.INTERPOLATE]:"mdi-transit-connection-horizontal",[g.SHIFT_DATETIMES]:"mdi-calendar",[g.FILL_GAPS]:"mdi-keyboard-space"};let n=[];try{if(Array.isArray(t)){for(let o=0;o<t.length;o++){const c=t[o][0],h=t[o].slice(1,t[o].length),l={method:c,args:h,icon:a[c],isLoading:!1};this.history.push(l)}for(let o=this.history.length-t.length;o<this.history.length;o++){const c=this.history[o];c.isLoading=!0;const h=await q(async()=>await s[c.method].apply(this,c.args));c.duration=h.duration,c.isLoading=!1,n.push(h.response)}}else{const o={method:t,args:r,icon:a[t],isLoading:!0};this.history.push(o);const c=await q(async()=>await s[t].apply(this,r));n=c.response,o.duration=c.duration,o.isLoading=!1}}catch(o){console.log(`Failed to execute operation: ${t} with arguments: `,r),console.log(o)}return n}async dispatchFilter(t,...r){const s={[O.FIND_GAPS]:this._findGaps,[O.VALUE_THRESHOLD]:this._valueThreshold,[O.PERSISTENCE]:this._persistence,[O.CHANGE]:this._change,[O.RATE_OF_CHANGE]:this._rateOfChange};let a=[];try{if(Array.isArray(t))for(let n=0;n<t.length;n++){const o=t[n][0],c=t[n].slice(1,t[n].length),h=await s[o].apply(this,c);a.push(h)}else a=await s[t].apply(this,r)}catch(n){console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(n)}return a}_changeValues(t,r,s){const a=n=>{switch(r){case L.ADD:return n+s;case L.ASSIGN:return s;case L.DIV:return n/s;case L.MULT:return n*s;case L.SUB:return n-s;default:return n}};t.forEach(n=>{this.dataset.source.y[n]=a(this.dataset.source.y[n])})}_interpolate(t){this._getConsecutiveGroups(t).forEach(s=>{const a=s[0],n=s[s.length-1];let o=Math.max(0,a-1),c=Math.min(this.dataset.source.y.length-1,n+1);const h=this.dataset.source.x,l=this.dataset.source.y;for(let f=0;f<s.length;f++)this.dataset.source.y[s[f]]=this._interpolateLinear(h[s[f]],h[o],l[o],h[c],l[c])})}_interpolateLinear(t,r,s,a,n){return s+(t-r)*(n-s)/(a-r)}async _shift(t,r,s){const a=t.map(n=>[qe(this.dataX[n],r,s),this.dataY[n]]);await this._deleteDataPoints(t),await this._addDataPoints(a)}async _fillGapsV2(t,r,s,a){const n=navigator.hardwareConcurrency||1,o=[],c=[],h=this.dataX.length,l=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),f=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let d=0;d<n;d++)c.push(new Promise(y=>{const v=new Ht;o.push(v),v.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:l,outputBufferY:f}),v.onmessage=F=>{y(F.data)}}));await Promise.all(c),o.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(l),this.dataset.source.y=new Float32Array(f),this._resizeTo(h)}_fillGaps(t,r,s,a){const n=this._findGaps(t[0],t[1],a);for(let o=n.length-1;o>=0;o--){const c=n[o],h=this.dataX[c[0]],l=this.dataX[c[1]],f=[],d=r[0]*x[r[1]]*1e3;let y=h+d;for(;y<l;){const v=s?this._interpolateLinear(y,this.dataX[c[0]],this.dataY[c[0]],this.dataX[c[1]],this.dataY[c[1]]):-9999;f.push([y,v]),y+=d}this._addDataPoints(f)}}async _deleteDataPoints(t){const r=navigator.hardwareConcurrency||1,s=Math.ceil(this.dataX.length/r),a=[],n=[];for(let d=0;d<r;d++){const y=d*s,v=Math.min((d+1)*s-1,this.dataX.length-1),F=Ve(t,y),E=me(t,v),ge=t.slice(F,E+1);n.push({start:y,end:v,deleteSegment:ge})}const o=new Array(r).fill(0);for(let d=1;d<r;d++)o[d]=o[d-1]+n[d-1].deleteSegment.length;const c=[],h=this.dataX.length-t.length,l=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),f=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let d=0;d<r;d++){const{start:y,end:v,deleteSegment:F}=n[d],E=y-o[d];c.push(new Promise(ge=>{const be=new Yt;a.push(be),be.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:l,outputBufferY:f,start:y,end:v,deleteSegment:F,startTarget:E}),be.onmessage=Wt=>{ge(Wt.data)}}))}await Promise.all(c),a.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(l),this.dataset.source.y=new Float32Array(f),this._resizeTo(h)}_driftCorrection(t,r,s){const a=this.dataset.source.x,n=this.dataset.source.y,o=a[t],h=a[r]-o;for(let l=t;l<r;l++)this.dataset.source.y[l]=n[l]+s*((a[l]-o)/h)}_getConsecutiveGroups(t){const r=[[]];return t.reduce((s,a)=>{const n=s[s.length-1];return!n.length||a==n[n.length-1]+1?n.push(a):s.push([a]),s},r),r}async _addDataPoints(t){const r=this.dataX.length+t.length;this._growBuffer(r),t.sort((n,o)=>n[0]-o[0]);const s=t.map(n=>me(this.dataX,n[0])+1);this._resizeTo(r),s.push(this.dataX.length);let a=t.length;for(let n=s.length-1;n>0;n--){const o=s[n-1],c=s[n]-1;for(let h=c;h>=o;h--)this.dataX[h+a]=this.dataX[h],this.dataY[h+a]=this.dataY[h];a--,this.dataX[o+a]=t[n-1][0],this.dataY[o+a]=t[n-1][1]}}_valueThreshold(t){const r=[];return this.dataset.source.y.forEach((s,a)=>{Object.keys(t).some(n=>Se[n]?.(s,t[n]))&&r.push(a)}),r}_rateOfChange(t,r){const s=[],a=this.dataset.source.y;for(let n=1;n<a.length;n++){const o=a[n-1],h=(a[n]-o)/Math.abs(o);V[t]?.(h,r)&&s.push(n)}return s}_change(t,r){const s=[],a=this.dataset.source.y;for(let n=1;n<a.length;n++){const o=a[n-1],h=a[n]-o;V[t]?.(h,r)&&s.push(n)}return s}_findGaps(t,r,s){const a=[],n=this.dataset.source.x;let o=0,c=n.length;s?.[0]&&s?.[1]&&(o=s[0],c=s[1]);let h=n[o];for(let l=o+1;l<=c;l++){const f=n[l];f-h>t*x[r]*1e3&&a.push([l-1,l]),h=f}return a}_persistence(t,r){let s=[],a=this.dataset.source.y,n=0,o=a.length;r?.[0]&&r?.[1]&&(n=r[0],o=r[1]);let c=a[n],h=[];for(let l=n+1;l<o;l++)a[l]!=c||l===o?(h.length>=t&&(s=[...s,...h]),h=[]):h.push(l);return s}}u.ACCOUNT_BASE=$,u.AUTH_BASE=G,u.ApiKey=ht,u.BASE_URL=_,u.Collaborator=dt,u.DEFAULT_SNACK_DURATION=ne,u.DataSource=Dt,u.Datastream=tt,u.EnumEditOperations=g,u.EnumFilterOperations=O,u.FilterOperation=ve,u.FilterOperationFn=Se,u.HydroShareArchive=_e,u.INCREASE_AMOUNT=C,u.Location=$e,u.LogicalComparator=V,u.LogicalOperation=Ee,u.OAuthProvider=ut,u.ObservationRecord=Gt,u.ObservedProperty=at,u.Operator=L,u.Organization=ot,u.PROVIDER_BASE=U,u.Payload=Pt,u.PermissionAction=Te,u.PermissionResource=we,u.Position=Ue,u.PostHydroShareArchive=Ze,u.ProcessingLevel=nt,u.ResultQualifier=it,u.SESSION_BASE=W,u.Sensor=st,u.Snack=Be,u.SnackColor=ie,u.SnackIcon=oe,u.SnackTitle=ce,u.Snackbar=Me,u.TAG_BASE=fe,u.THINGS_BASE=p,u.Thing=et,u.TimeUnit=S,u.Unit=rt,u.User=ct,u.Workspace=lt,u.api=Ft,u.apiMethods=i,u.createPatchObject=ue,u.extractErrorMessage=Ae,u.findFirstGreaterOrEqual=Ve,u.findLastLessOrEqual=me,u.formatDate=Ut,u.formatDuration=Bt,u.getCSRFToken=z,u.getObservationsEndpoint=kt,u.measureEllapsedTime=q,u.requestInterceptor=J,u.responseInterceptor=Q,u.shiftDatetime=qe,u.subtractHours=Mt,u.timeUnitMultipliers=x,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})});
1
+ (function(m,O){typeof exports=="object"&&typeof module<"u"?O(exports):typeof define=="function"&&define.amd?define(["exports"],O):(m=typeof globalThis<"u"?globalThis:m||self,O(m["@uwrl/qc-utils"]={}))})(this,(function(m){"use strict";var O=(e=>(e.SECOND="s",e.MINUTE="m",e.HOUR="h",e.DAY="D",e.WEEK="W",e.MONTH="M",e.YEAR="Y",e))(O||{}),E=(e=>(e.ADD_POINTS="ADD_POINTS",e.CHANGE_VALUES="CHANGE_VALUES",e.ASSIGN_VALUES_BULK="ASSIGN_VALUES_BULK",e.DELETE_POINTS="DELETE_POINTS",e.DRIFT_CORRECTION="DRIFT_CORRECTION",e.INTERPOLATE="INTERPOLATE",e.SHIFT_DATETIMES="SHIFT_DATETIMES",e.ASSIGN_DATETIMES_BULK="ASSIGN_DATETIMES_BULK",e.FILL_GAPS="FILL_GAPS",e))(E||{}),v=(e=>(e.FIND_GAPS="FIND_GAPS",e.PERSISTENCE="PERSISTENCE",e.CHANGE="CHANGE",e.RATE_OF_CHANGE="RATE_OF_CHANGE",e.VALUE_THRESHOLD="VALUE_THRESHOLD",e.DATETIME_RANGE="DATETIME_RANGE",e.SELECTION="SELECTION",e))(v||{}),x=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(x||{}),ze=(e=>(e.ADD="ADD",e.SUB="SUB",e.MULT="MULT",e.DIV="DIV",e.ASSIGN="ASSIGN",e))(ze||{}),Xe=(e=>(e.LT="Less than",e.LTE="Less than or equal to",e.GT="Greater than",e.GTE="Greater than or equal to",e.E="Equal",e))(Xe||{});class Ve{id;thingId;link;frequency;path;datastreamIds;publicResource;constructor(){this.id="",this.thingId="",this.link="",this.frequency=null,this.path="HydroShare",this.datastreamIds=[],this.publicResource=!1}}class Vt extends Ve{resourceTitle;resourceAbstract;resourceKeywords;constructor(){super(),this.resourceTitle=void 0,this.resourceAbstract=void 0,this.resourceKeywords=void 0}}class qe{latitude;longitude;elevation_m;elevationDatum;state;county;country;constructor(){this.elevationDatum="WGS84",this.state="",this.county="",this.country=""}}class qt{id;workspaceId;name;location=new qe;tags;hydroShareArchive;siteType;samplingFeatureCode;isPrivate;description;samplingFeatureType;dataDisclaimer;constructor(){this.id="",this.workspaceId="",this.name="",this.tags=[],this.siteType="",this.samplingFeatureCode="",this.isPrivate=!1,this.description="",this.samplingFeatureType="Site",this.dataDisclaimer=""}}class Jt{id;workspaceId;name;description;thingId;observationType;resultType;status;sampledMedium;noDataValue;aggregationStatistic;unitId;observedPropertyId;sensorId;processingLevelId;isPrivate;isVisible;phenomenonBeginTime;phenomenonEndTime;intendedTimeSpacing;intendedTimeSpacingUnit;timeAggregationInterval;timeAggregationIntervalUnit;dataSourceId;valueCount;constructor(t){this.id="",this.workspaceId="",this.name="",this.description="",this.thingId=t||"",this.observationType="OM_Measurement",this.resultType="Time Series Coverage",this.sampledMedium="",this.noDataValue=-9999,this.aggregationStatistic="",this.unitId="",this.observedPropertyId="",this.sensorId="",this.processingLevelId="",this.timeAggregationInterval=null,this.timeAggregationIntervalUnit="seconds",this.isPrivate=!0,this.isVisible=!0,this.valueCount=0}}class Kt{id;workspaceId;name;symbol;definition;type;constructor(){this.id="",this.workspaceId="",this.name="",this.symbol="",this.definition="",this.type=""}}class Qt{id;workspaceId;name;description;manufacturer;model;methodType;methodCode;methodLink;encodingType;modelLink;constructor(){this.id="",this.workspaceId="",this.name="",this.description="",this.manufacturer="",this.model="",this.methodType="Instrument Deployment",this.methodCode="",this.methodLink="",this.encodingType="application/json",this.modelLink=""}}class Zt{id;workspaceId;name;definition;description;type;code;constructor(){this.id="",this.workspaceId="",this.name="",this.definition="",this.description="",this.type="Hydrology",this.code=""}}class er{id;workspaceId;code;definition;explanation;constructor(){this.id="",this.workspaceId="",this.code="",this.definition="",this.explanation=""}}class tr{id;workspaceId;code;description;constructor(){this.id="",this.workspaceId="",this.code="",this.description=""}}class rr{name;code;type;description;link;constructor(){}}class nr{id;email;password;firstName;middleName;lastName;phone;address;organization;type;link;accountType;hydroShareConnected;constructor(){this.id="",this.email="",this.password="",this.firstName="",this.middleName="",this.lastName="",this.phone="",this.address="",this.type="",this.link="",this.accountType="standard",this.hydroShareConnected=!1}}class sr{id;name;iconLink;signupEnabled;connectEnabled;constructor(){this.id="",this.name="",this.iconLink="",this.signupEnabled=!0,this.connectEnabled=!0}}var Je=(e=>(e.Global="*",e.View="view",e.Create="create",e.Edit="edit",e.Delete="delete",e))(Je||{}),Ke=(e=>(e.Global="*",e.Workspace="Workspace",e.Collaborator="Collaborator",e.Thing="Thing",e.Datastream="Datastream",e.Sensor="Sensor",e.Unit="Unit",e.ObservedProperty="ObservedProperty",e.ProcessingLevel="ProcessingLevel",e.Observation="Observation",e))(Ke||{});class ar{id="";key="";name="";description="";isActive=!0;expiresAt="";createdAt="";lastUsed="";workspaceId="";role=null;constructor(t){Object.assign(this,t)}}class or{id;name;isPrivate;owner;collaboratorRole;pendingTransferTo;constructor(){this.id="",this.name="",this.isPrivate=!1,this.owner=null,this.collaboratorRole=null,this.pendingTransferTo=null}}class ir{user;role;constructor(){this.user={phone:"",address:"",link:"",type:"",name:"",email:"",organizationName:""},this.role={name:"",description:"",id:"",isApikeyRole:!1,isUserRole:!1,workspaceId:"",permissions:[]}}}function ge(){const e="csrftoken=",r=decodeURIComponent(document.cookie).split(";");for(const n of r){const s=n.trim();if(s.startsWith(e))return s.substring(e.length)}return null}function me(e){let t=e.headers?{...e.headers}:{},r;return e.body!==void 0&&(r=typeof e.body=="string"||e.body instanceof FormData?e.body:JSON.stringify(e.body)),t["X-CSRFToken"]=ge()||"",{...e,headers:t,body:r,credentials:"omit"}}function Qe(e){if(Array.isArray(e?.errors)&&e.errors.length&&(e=e.errors[0]),typeof e!="object"||e===null)return"An unknown error occurred.";const t=["message","detail","error"];for(const r of t)if(e[r])return e[r];return"An unknown error occurred."}async function we(e){if(e.headers.get("Content-Length")==="0"||e.statusText==="No Content")return null;const t=e.headers.get("content-type")||"";let r=null;if(t.includes("application/json"))try{r=await e.json()}catch(s){console.error("Failed to parse error JSON:",s)}else if(t.includes("text/csv"))try{r=await e.blob()}catch(s){console.error("Failed to parse error JSON:",s)}if(e.ok||e.status===401)return r;const n={status:e.status,message:Qe(r)};throw console.error("API response not OK:",n.message),n}var be=function(e,t){return be=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(r[s]=n[s])},be(e,t)};function ne(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");be(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Se(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Ee(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),s,o=[],a;try{for(;(t===void 0||t-- >0)&&!(s=n.next()).done;)o.push(s.value)}catch(i){a={error:i}}finally{try{s&&!s.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function ke(e,t,r){if(r||arguments.length===2)for(var n=0,s=t.length,o;n<s;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}typeof SuppressedError=="function"&&SuppressedError;function P(e){return typeof e=="function"}function Ze(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var ve=Ze(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
2
+ `+r.map(function(n,s){return s+1+") "+n.toString()}).join(`
3
+ `):"",this.name="UnsubscriptionError",this.errors=r}});function _e(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var se=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,s,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var i=Se(a),l=i.next();!l.done;l=i.next()){var f=l.value;f.remove(this)}}catch(h){t={error:h}}finally{try{l&&!l.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}else a.remove(this);var u=this.initialTeardown;if(P(u))try{u()}catch(h){o=h instanceof ve?h.errors:[h]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var g=Se(p),y=g.next();!y.done;y=g.next()){var d=y.value;try{rt(d)}catch(h){o=o??[],h instanceof ve?o=ke(ke([],Ee(o)),Ee(h.errors)):o.push(h)}}}catch(h){n={error:h}}finally{try{y&&!y.done&&(s=g.return)&&s.call(g)}finally{if(n)throw n.error}}}if(o)throw new ve(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)rt(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&_e(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&_e(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),et=se.EMPTY;function tt(e){return e instanceof se||e&&"closed"in e&&P(e.remove)&&P(e.add)&&P(e.unsubscribe)}function rt(e){P(e)?e():e.unsubscribe()}var cr={Promise:void 0},lr={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,ke([e,t],Ee(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function ur(e){lr.setTimeout(function(){throw e})}function nt(){}function ae(e){e()}var st=(function(e){ne(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,tt(r)&&r.add(n)):n.destination=dr,n}return t.create=function(r,n,s){return new Ae(r,n,s)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(se),hr=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){oe(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){oe(n)}else oe(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){oe(r)}},e})(),Ae=(function(e){ne(t,e);function t(r,n,s){var o=e.call(this)||this,a;return P(r)||!r?a={next:r??void 0,error:n??void 0,complete:s??void 0}:a=r,o.destination=new hr(a),o}return t})(st);function oe(e){ur(e)}function fr(e){throw e}var dr={closed:!0,next:nt,error:fr,complete:nt},pr=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function yr(e){return e}function gr(e){return e.length===0?yr:e.length===1?e[0]:function(r){return e.reduce(function(n,s){return s(n)},r)}}var at=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var s=this,o=wr(t)?t:new Ae(t,r,n);return ae(function(){var a=s,i=a.operator,l=a.source;o.add(i?i.call(o,l):l?s._subscribe(o):s._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=ot(r),new r(function(s,o){var a=new Ae({next:function(i){try{t(i)}catch(l){o(l),a.unsubscribe()}},error:o,complete:s});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[pr]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return gr(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=ot(t),new t(function(n,s){var o;r.subscribe(function(a){return o=a},function(a){return s(a)},function(){return n(o)})})},e.create=function(t){return new e(t)},e})();function ot(e){var t;return(t=e??cr.Promise)!==null&&t!==void 0?t:Promise}function mr(e){return e&&P(e.next)&&P(e.error)&&P(e.complete)}function wr(e){return e&&e instanceof st||mr(e)&&tt(e)}var br=Ze(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),it=(function(e){ne(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new ct(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new br},t.prototype.next=function(r){var n=this;ae(function(){var s,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=Se(n.currentObservers),i=a.next();!i.done;i=a.next()){var l=i.value;l.next(r)}}catch(f){s={error:f}}finally{try{i&&!i.done&&(o=a.return)&&o.call(a)}finally{if(s)throw s.error}}}})},t.prototype.error=function(r){var n=this;ae(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var s=n.observers;s.length;)s.shift().error(r)}})},t.prototype.complete=function(){var r=this;ae(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,s=this,o=s.hasError,a=s.isStopped,i=s.observers;return o||a?et:(this.currentObservers=null,i.push(r),new se(function(){n.currentObservers=null,_e(i,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,s=n.hasError,o=n.thrownError,a=n.isStopped;s?r.error(o):a&&r.complete()},t.prototype.asObservable=function(){var r=new at;return r.source=this,r},t.create=function(r,n){return new ct(r,n)},t})(at),ct=(function(e){ne(t,e);function t(r,n){var s=e.call(this)||this;return s.destination=r,s.source=n,s}return t.prototype.next=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.next)===null||s===void 0||s.call(n,r)},t.prototype.error=function(r){var n,s;(s=(n=this.destination)===null||n===void 0?void 0:n.error)===null||s===void 0||s.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,s;return(s=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&s!==void 0?s:et},t})(it);const Le=3e3;var Te=(e=>(e.Warning="warning",e.Success="success",e.Error="error",e.Info="info",e))(Te||{}),$e=(e=>(e.Success="mdi-checkbox-marked-circle",e.Warning="mdi-alert",e.Error="mdi-alert-circle",e.Info="mdi-information",e.None="none",e))($e||{}),Re=(e=>(e.Warning="Warning",e.Success="Success",e.Error="Error",e.Info="Info",e))(Re||{}),lt=(e=>(e.Center="center",e.Left="left",e.Right="right",e.Bottom="bottom",e.Top="top",e))(lt||{});class ut{constructor(t="",r="info",n="none",s="Info",o=Le,a="center",i=!1){this.message=t,this.color=r,this.icon=n,this.title=s,this.timeout=o,this.position=a,this.visible=i}}class ht{static subject=new it;static get snack$(){return this.subject.asObservable()}static createSnackbar(t,r){this.subject.next(new ut(t,Te[r],$e[r],Re[r],Le,"bottom",!0))}static success(t){this.createSnackbar(t,"Success")}static warn(t){this.createSnackbar(t,"Warning")}static error(t){this.createSnackbar(t,"Error")}static info(t){this.createSnackbar(t,"Info")}}function Ie(e,t){const r={};for(let n in t)if(Array.isArray(t[n]))JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);else if(e[n]&&typeof e[n]=="object"&&t[n]&&typeof t[n]=="object"){const s=Ie(e[n],t[n]);Object.keys(s).length>0&&(r[n]=s)}else JSON.stringify(e[n])!==JSON.stringify(t[n])&&(r[n]=t[n]);return r}function Sr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Oe,ft;function Er(){if(ft)return Oe;ft=1;class e{constructor(n){this.value=n,this.next=void 0}}class t{constructor(){this.clear()}enqueue(n){const s=new e(n);this._head?(this._tail.next=s,this._tail=s):(this._head=s,this._tail=s),this._size++}dequeue(){const n=this._head;if(n)return this._head=this._head.next,this._size--,n.value}clear(){this._head=void 0,this._tail=void 0,this._size=0}get size(){return this._size}*[Symbol.iterator](){let n=this._head;for(;n;)yield n.value,n=n.next}}return Oe=t,Oe}var Ue,dt;function kr(){if(dt)return Ue;dt=1;const e=Er();return Ue=r=>{if(!((Number.isInteger(r)||r===1/0)&&r>0))throw new TypeError("Expected `concurrency` to be a number from 1 and up");const n=new e;let s=0;const o=()=>{s--,n.size>0&&n.dequeue()()},a=async(f,u,...p)=>{s++;const g=(async()=>f(...p))();u(g);try{await g}catch{}o()},i=(f,u,...p)=>{n.enqueue(a.bind(null,f,u,...p)),(async()=>(await Promise.resolve(),s<r&&n.size>0&&n.dequeue()()))()},l=(f,...u)=>new Promise(p=>{i(f,p,...u)});return Object.defineProperties(l,{activeCount:{get:()=>s},pendingCount:{get:()=>n.size},clearQueue:{value:()=>{n.clear()}}}),l},Ue}var vr=kr();const G=Sr(vr)(10),_r=1e3;async function V(e,t){const r=me(t);try{const n=await fetch(e,r);return await we(n)}catch(n){throw n instanceof TypeError&&ht.error("Network error. Please check your connection."),n}}const c={async fetch(e,t={}){return t.method="GET",await G(()=>V(e,t))},async patch(e,t,r=null,n={}){if(n.method="PATCH",n.body=r?Ie(r,t):t,Object.keys(n.body).length!==0)return await G(()=>V(e,n))},async post(e,t=void 0,r={}){return r.method="POST",r.body=t,await G(()=>V(e,r))},async put(e,t=void 0,r={}){return r.method="PUT",r.body=t,await G(()=>V(e,r))},async delete(e,t=void 0,r={}){return r.method="DELETE",r.body=t,await G(()=>V(e,r))},async paginatedFetch(e,t){const r=t??_r,n=e.includes("?")?"&":"?",s=`${e}${n}page_size=${r}&page=1`,o=me({method:"GET"}),a=await G(()=>fetch(s,o)),i=Number(a.headers.get("x-total-pages"))||1,f=[...await we(a)];for(let u=2;u<=i;u++){const p=`${e}${n}page_size=${r}&page=${u}`,g=await G(()=>V(p,{method:"GET"}));f.push(...g)}return f}},pt={HTTP:{type:"HTTP",sourceUri:"",placeholderVariables:[]},local:{type:"local",sourceUri:"",placeholderVariables:[]}},yt={JSON:{type:"JSON",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},JMESPath:""},CSV:{type:"CSV",timestamp:{key:"",format:"ISO8601",timezoneMode:"embeddedOffset"},headerRow:1,dataStartRow:2,delimiter:",",identifierType:"name"}},gt={HydroServer:{type:"HydroServer"}};class Ar{name="";settings={type:"SDL",extractor:JSON.parse(JSON.stringify(pt.local)),transformer:JSON.parse(JSON.stringify(yt.CSV)),loader:JSON.parse(JSON.stringify(gt.HydroServer)),payloads:[]};id="";workspaceId="";orchestrationSystem={id:"",name:"",workspaceId:"",type:""};schedule={interval:15,intervalUnits:"minutes"};status={paused:!0};datastreams=[];constructor(t){Object.assign(this,t)}switchExtractor(t){this.settings.extractor=JSON.parse(JSON.stringify(pt[t]))}switchTransformer(t){this.settings.transformer=JSON.parse(JSON.stringify(yt[t]))}switchLoader(t){this.settings.loader=JSON.parse(JSON.stringify(gt[t]))}}function mt(e){return{name:e.name,settings:e.settings,workspaceId:e.workspaceId,orchestrationSystemId:e.orchestrationSystem.id,schedule:e.schedule,status:e.status}}const C="https://lro.hydroserver.org/api",ie=`${C}/auth`,F=`${ie}/browser/account`,ce=`${ie}/browser/session`,Q=`${ie}/browser/provider`,R=`${C}/data/workspaces`,Me=`${C}/data/roles`,I=`${C}/data/datastreams`,j=`${C}/data/sensors`,_=`${C}/data/things`,Ce=`${_}/tags`,q=`${C}/data/orchestration-systems`,B=`${C}/data/data-sources`,Y=`${C}/data/observed-properties`,J=`${C}/data/processing-levels`,Z=`${C}/data/result-qualifiers`,H=`${C}/data/units`,Lr=(e,t,r,n,s)=>{let o=`${I}/${e}/observations?format=column`;return o+=`&order_by=phenomenonTime&page_size=${t}`,o+=`&phenomenon_time_min=${encodeURIComponent(r)}`,n&&(o+=`&phenomenon_time_max=${encodeURIComponent(n)}`),s&&(o+=`&page=${s}`),o},Tr={fetchSession:async()=>c.fetch(`${ce}`),login:async(e,t)=>c.post(`${ce}`,{email:e,password:t}),logout:async()=>c.delete(`${ce}`),fetchUser:async()=>c.fetch(`${F}`),signup:async e=>c.post(`${F}`,e),updateUser:async(e,t)=>c.patch(`${F}`,e,t),deleteUser:async()=>c.delete(`${F}`),sendVerificationEmail:async e=>c.put(`${F}/email/verify`,{email:e}),verifyEmailWithCode:async e=>c.post(`${F}/email/verify`,{key:e}),requestPasswordReset:async e=>c.post(`${F}/password/request`,{email:e}),resetPassword:async(e,t)=>c.post(`${F}/password/reset`,{key:e,password:t}),fetchWorkspaces:async()=>c.paginatedFetch(`${R}`),fetchAssociatedWorkspaces:async()=>c.paginatedFetch(`${R}?is_associated=true`),fetchWorkspace:async e=>c.fetch(`${R}/${e}`),createWorkspace:async e=>c.post(R,e),updateWorkspace:async(e,t=null)=>c.patch(`${R}/${e.id}`,e,t),deleteWorkspace:async e=>c.delete(`${R}/${e}`),transferWorkspace:async(e,t)=>c.post(`${R}/${e}/transfer`,{newOwner:t}),acceptWorkspaceTransfer:async e=>c.put(`${R}/${e}/transfer`),rejectWorkspaceTransfer:async e=>c.delete(`${R}/${e}/transfer`),getCollaboratorRoles:async e=>c.paginatedFetch(`${Me}?is_user_role=true`),getAPIKeyRoles:async e=>c.paginatedFetch(`${Me}?is_apikey_role=true`),getRole:async e=>c.fetch(`${Me}/${e}`),getCollaborators:async e=>c.paginatedFetch(`${R}/${e}/collaborators`),addCollaborator:async(e,t,r)=>c.post(`${R}/${e}/collaborators`,{email:t,roleId:r}),updateCollaboratorRole:async(e,t,r)=>c.put(`${R}/${e}/collaborators`,{email:t,roleId:r}),removeCollaborator:async(e,t)=>c.delete(`${R}/${e}/collaborators`,{email:t}),fetchApiKeys:async e=>c.paginatedFetch(`${R}/${e}/api-keys?expand_related=true`),fetchApiKey:async(e,t)=>c.fetch(`${R}/${e}/api-keys/${t}?expand_related=true`),createApiKey:async e=>c.post(`${R}/${e.workspaceId}/api-keys?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id}),updateApiKey:async(e,t)=>c.patch(`${R}/${e.workspaceId}/api-keys/${e.id}?expand_related=true`,{name:e.name,description:e.description,isActive:!0,roleId:e.role.id},t&&{name:t.name,description:t.description,isActive:!0,roleId:t.role.id}),regenerateApiKey:async(e,t)=>c.put(`${R}/${e}/api-keys/${t}/regenerate?expand_related=true`),deleteApiKey:async(e,t)=>c.delete(`${R}/${e}/api-keys/${t}`),fetchConnectedProviders:async()=>c.fetch(`${Q}/connections`),providerRedirect:(e,t,r)=>{const n={provider:e,callback_url:t,process:r},s=ge(),o=document.createElement("form");if(o.method="POST",o.action=`${Q}/redirect`,s){const a=document.createElement("input");a.type="hidden",a.name="csrfmiddlewaretoken",a.value=s,o.appendChild(a)}for(const a in n){const i=document.createElement("input");i.type="hidden",i.name=a,i.value=n[a]||"",o.appendChild(i)}document.body.appendChild(o),o.submit()},providerSignup:async e=>c.post(`${Q}/signup`,e),deleteProvider:async(e,t)=>c.delete(`${Q}/connections`,{provider:e,account:t}),createUnit:async e=>c.post(H,e),fetchUnits:async()=>c.paginatedFetch(`${H}`),fetchWorkspaceUnits:async e=>c.paginatedFetch(`${H}?workspace_id=${e}`),updateUnit:async(e,t=null)=>c.patch(`${H}/${e.id}`,e,t),deleteUnit:async e=>c.delete(`${H}/${e}`),getUnit:async e=>c.fetch(`${H}/${e}`),removeThingOwner:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,removeOwner:!0}),addSecondaryOwner:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,makeOwner:!0}),transferPrimaryOwnership:async(e,t)=>c.patch(`${_}/${e}/ownership`,{email:t,transferPrimary:!0}),createThing:async e=>c.post(_,e),fetchThings:async()=>c.paginatedFetch(`${_}`),fetchThingsForWorkspace:async e=>c.paginatedFetch(`${_}?workspace_id=${e}`),fetchOwnedThings:async()=>c.paginatedFetch(`${_}?owned_only=true`),fetchThing:async e=>c.fetch(`${_}/${e}`),updateThing:async e=>c.patch(`${_}/${e.id}`,e),updateThingPrivacy:async(e,t)=>c.patch(`${_}/${e}`,{isPrivate:t}),deleteThing:async e=>c.delete(`${_}/${e}`),fetchMetadataForThingOwner:async e=>c.paginatedFetch(`${_}/${e}/metadata?include_assignable_metadata=true`),fetchMetadataForThing:async e=>c.fetch(`${_}/${e}/metadata`),uploadSitePhotos:async(e,t)=>c.post(`${_}/${e}/photos`,t),fetchSitePhotos:async e=>c.paginatedFetch(`${_}/${e}/photos`),deleteSitePhoto:async(e,t)=>c.delete(`${_}/${e}/photos`,{name:t}),createSiteTag:async(e,t)=>c.post(`${_}/${e}/tags`,t),editSiteTag:async(e,t)=>c.put(`${_}/${e}/tags`,t),fetchSiteTags:async e=>c.fetch(`${_}/${e}/tags`),fetchUsersSiteTags:async()=>c.fetch(`${Ce}`),deleteSiteTag:async(e,t)=>c.delete(`${_}/${e}/tags`,t),fetchWorkspaceTags:async e=>c.fetch(`${Ce}/keys?workspace_id=${e}`),createHydroShareArchive:async e=>c.post(`${_}/${e.thingId}/archive`,e),updateHydroShareArchive:async(e,t)=>c.patch(`${_}/${e.thingId}/archive`,e,t),fetchHydroShareArchive:async e=>c.fetch(`${_}/${e}/archive`),deleteHydroShareArchive:async e=>c.delete(`${_}/${e}/archive`),archiveToHydroShare:async e=>c.post(`${_}/${e}/archive/trigger`),createDatastream:async e=>c.post(I,e),fetchDatastreams:async e=>{const t=[];if(e)for(const[n,s]of Object.entries(e))t.push(`${encodeURIComponent(n)}=${encodeURIComponent(s)}`);const r=t.length?`?${t.join("&")}`:"";return c.paginatedFetch(`${I}${r}`)},fetchDatastreamsForThing:async e=>c.paginatedFetch(`${I}?thing_id=${e}`),fetchExpandedDatastreamsForThing:async e=>c.paginatedFetch(`${I}?thing_id=${e}&expand_related=true`),fetchDatastreamsForDataSource:async e=>c.paginatedFetch(`${I}?data_source_id=${e}`),fetchDatastream:async e=>c.fetch(`${I}/${e}`),fetchDatastreamExpanded:async e=>c.fetch(`${I}/${e}?expand_related=true`),fetchUsersDatastreams:async()=>c.paginatedFetch(`${I}?exclude_unowned=true`),updateDatastream:async(e,t=null)=>c.patch(`${I}/${e.id}`,e,t),deleteDatastream:async e=>c.delete(`${I}/${e}`),downloadDatastreamCSV:async e=>c.fetch(`${I}/${e}/csv`),createObservedProperty:async e=>c.post(Y,e),fetchObservedProperty:async e=>c.fetch(`${Y}/${e}`),fetchObservedProperties:async()=>c.paginatedFetch(`${Y}`),fetchWorkspaceObservedProperties:async e=>c.paginatedFetch(`${Y}?workspace_id=${e}`),updateObservedProperty:async(e,t=null)=>c.patch(`${Y}/${e.id}`,e,t),deleteObservedProperty:async e=>c.delete(`${Y}/${e}`),createProcessingLevel:async e=>c.post(J,e),fetchProcessingLevels:async()=>c.paginatedFetch(`${J}`),fetchProcessingLevel:async e=>c.fetch(`${J}/${e}`),fetchWorkspaceProcessingLevels:async e=>c.paginatedFetch(`${J}?workspace_id=${e}`),updateProcessingLevel:async(e,t=null)=>c.patch(`${J}/${e.id}`,e,t),deleteProcessingLevel:async e=>c.delete(`${J}/${e}`),createSensor:async e=>c.post(j,e),fetchSensors:async()=>c.paginatedFetch(`${j}`),fetchSensor:async e=>c.fetch(`${j}/${e}`),fetchWorkspaceSensors:async e=>c.paginatedFetch(`${j}?workspace_id=${e}`),updateSensor:async(e,t=null)=>c.patch(`${j}/${e.id}`,e,t),deleteSensor:async e=>c.delete(`${j}/${e}`),createResultQualifier:async e=>c.post(Z,e),fetchResultQualifiers:async()=>c.paginatedFetch(`${Z}`),fetchWorkspaceResultQualifiers:async e=>c.paginatedFetch(`${Z}?workspace_id=${e}`),updateResultQualifier:async(e,t=null)=>c.patch(`${Z}/${e.id}`,e,t),deleteResultQualifier:async e=>c.delete(`${Z}/${e}`),createOrchestrationSystem:async e=>c.post(q,e),fetchOrchestrationSystems:async()=>c.paginatedFetch(q),fetchWorkspaceOrchestrationSystems:async e=>c.paginatedFetch(`${q}?workspace_id=${e}`),fetchOrchestrationSystem:async e=>c.fetch(`${q}/${e}`),updateOrchestrationSystem:async(e,t)=>c.patch(`${q}/${e}`,t),deleteOrchestrationSystem:async e=>c.delete(`${q}/${e}`),createDataSource:async e=>c.post(`${B}?expand_related=true`,mt(e)),fetchDataSources:async()=>c.paginatedFetch(`${B}?expand_related=true`),fetchWorkspaceDataSources:async e=>c.paginatedFetch(`${B}?workspace_id=${e}&expand_related=true`),fetchDataSource:async e=>c.fetch(`${B}/${e}?expand_related=true`),updateDataSource:async e=>c.patch(`${B}/${e.id}?expand_related=true`,mt(e)),updateDataSourcePartial:async e=>c.patch(`${B}/${e.id}?expand_related=true`,e),deleteDataSource:async e=>c.delete(`${B}/${e}`),linkDatastreamToDataSource:async(e,t)=>c.post(`${B}/${e}/datastreams/${t}`),unlinkDatastreamFromDataSource:async(e,t)=>c.delete(`${B}/${e}/datastreams/${t}`),fetchObservations:async e=>c.fetch(e),deleteObservationsForDatastream:async e=>c.post(`${I}/${e}/observations/bulk-delete`,{phenomenonTimeStart:null,phenomenonTimeEnd:null}),fetchUserTypes:async()=>c.fetch(`${F}/user-types`),fetchOrganizationTypes:async()=>c.fetch(`${F}/organization-types`),fetchSiteTypes:async()=>c.fetch(`${_}/site-types`),fetchSamplingFeatureTypes:async()=>c.paginatedFetch(`${_}/sampling-feature-types`),fetchSensorEncodingTypes:async()=>c.paginatedFetch(`${j}/encoding-types`),fetchMethodTypes:async()=>c.paginatedFetch(`${j}/method-types`),fetchVariableTypes:async()=>c.paginatedFetch(`${Y}/variable-types`),fetchUnitTypes:async()=>c.paginatedFetch(`${H}/types`),fetchDatastreamStatuses:async()=>c.paginatedFetch(`${I}/statuses`),fetchDatastreamAggregations:async()=>c.paginatedFetch(`${I}/aggregation-statistics`),fetchSampledMediums:async()=>c.paginatedFetch(`${I}/sampled-mediums`)};class $r{name="";mappings=[];extractorVariables={};constructor(t){Object.assign(this,t)}}const wt=1,le=wt*60,De=le*60,Fe=De*24,Rr=Fe*7,Ir=De*30,Or=Fe*365,ee={[O.SECOND]:wt,[O.MINUTE]:le,[O.HOUR]:De,[O.DAY]:Fe,[O.WEEK]:Rr,[O.MONTH]:Ir,[O.YEAR]:Or},Ur=e=>e.toLocaleString(void 0,{year:"numeric",month:"short",day:"2-digit",hour:"2-digit",hour12:!1,minute:"2-digit",second:"2-digit"}),Mr=e=>{let t,r;e>=le*1e3?(t=e/(le*1e3),r="m"):e>=1e3?(t=e/1e3,r="s"):(t=e,r="ms");let n;return r==="ms"?n=Math.round(t).toString():n=t.toFixed(2),`${n} ${r}`},ue=async(e,t)=>{t&&console.info(t);const r=performance.now(),n=await e(),s=performance.now();console.info(` Done in ${(s-r).toFixed(2)} ms`);const o=+(s-r);return{response:n,duration:o}};function Cr(e,t){const r=new Date(e);return r.setHours(r.getHours()-t),r.toISOString()}const te=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]<t?r=s+1:n=s}return r},he=(e,t)=>{let r=0,n=e.length;for(;r<n;){const s=r+n>>1;e[s]>t?n=s:r=s+1}return r-1},bt=`(function(){"use strict";function c(n,s,a,u,f,l,y,o){let r=0,e=o;for(let t=l;t<=y;t++)r<a.length&&t===a[r]?r++:(u[e]=n[t],f[e]=s[t],e++);return e-o}self.onmessage=n=>{const{bufferX:s,bufferY:a,outputBufferX:u,outputBufferY:f,start:l,end:y,deleteSegment:o,startTarget:r}=n.data,e=new Float64Array(s),t=new Float32Array(a),A=new Float64Array(u),g=new Float32Array(f);c(e,t,o,A,g,l,y,r),self.postMessage("Done")}})();
4
+ `,St=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",bt],{type:"text/javascript;charset=utf-8"});function Dr(e){let t;try{if(t=St&&(self.URL||self.webkitURL).createObjectURL(St),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(bt),{name:e?.name})}}const Et=`(function(){"use strict";function F(n,l,a,o,s,y,g,f,i,w,A){let e=0,t=f;for(let r=y;r<=g;r++)if(o[t]=n[r],s[t]=l[r],t++,e<a.length&&r===a[e][0]){const u=a[e][0],c=a[e][1],d=n[u],h=n[c],m=l[u],D=l[c],x=h-d,P=D-m;let p=d+i;for(;p<h;)o[t]=p,s[t]=w?m+(p-d)*P/x:A,t++,p+=i;e++}return t-f}self.onmessage=n=>{const{bufferX:l,bufferY:a,outputBufferX:o,outputBufferY:s,start:y,end:g,gapsSegment:f,startTarget:i,fillDelta:w,interpolate:A,fillValue:e}=n.data,t=new Float64Array(l),r=new Float32Array(a),u=new Float64Array(o),c=new Float32Array(s);F(t,r,f,u,c,y,g,i,w,A,e),self.postMessage("Done")}})();
5
+ `,kt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Et],{type:"text/javascript;charset=utf-8"});function Fr(e){let t;try{if(t=kt&&(self.URL||self.webkitURL).createObjectURL(kt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Et),{name:e?.name})}}const vt=`(function(){"use strict";function g(o,n,c){for(let s=0;s<c.length;s++){const{indexes:t,lowerIdx:l,upperIdx:r}=c[s],i=o[l],f=n[l],a=o[r],d=n[r],p=a-i,w=d-f;if(p===0){for(let e=0;e<t.length;e++)n[t[e]]=f;continue}for(let e=0;e<t.length;e++){const u=t[e];n[u]=f+(o[u]-i)*w/p}}}self.onmessage=o=>{const{bufferX:n,bufferY:c,groups:s}=o.data,t=new Float64Array(n),l=new Float32Array(c);g(t,l,s),self.postMessage("Done")}})();
6
+ `,_t=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",vt],{type:"text/javascript;charset=utf-8"});function Pr(e){let t;try{if(t=_t&&(self.URL||self.webkitURL).createObjectURL(_t),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(vt),{name:e?.name})}}const At=`(function(){"use strict";self.onmessage=r=>{const{bufferX:s,bufferY:o,jobs:a}=r.data,f=new Float64Array(s),n=new Float32Array(o);for(let e=0;e<a.length;e++){const{chunkStart:c,chunkEnd:l,startDatetime:u,value:i,extent:y}=a[e];for(let t=c;t<l;t++)n[t]=n[t]+i*((f[t]-u)/y)}self.postMessage("Done")}})();
7
+ `,Lt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",At],{type:"text/javascript;charset=utf-8"});function Br(e){let t;try{if(t=Lt&&(self.URL||self.webkitURL).createObjectURL(Lt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(At),{name:e?.name})}}const Tt=`(function(){"use strict";function u(f,o,a,n,l,c,s,i){let r=c,e=0,t=i;const w=a.length;for(;r<s&&e<w;){const y=a[e][0];f[r]<=y?(n[t]=f[r],l[t]=o[r],r++):(n[t]=y,l[t]=a[e][1],e++),t++}for(;r<s;)n[t]=f[r],l[t]=o[r],r++,t++;for(;e<w;)n[t]=a[e][0],l[t]=a[e][1],e++,t++;return t-i}self.onmessage=f=>{const{bufferX:o,bufferY:a,outputBufferX:n,outputBufferY:l,origStart:c,origEnd:s,insertions:i,outStart:r}=f.data,e=new Float64Array(o),t=new Float32Array(a),w=new Float64Array(n),y=new Float32Array(l);u(e,t,i,w,y,c,s,r),self.postMessage("Done")}})();
8
+ `,$t=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Tt],{type:"text/javascript;charset=utf-8"});function Nr(e){let t;try{if(t=$t&&(self.URL||self.webkitURL).createObjectURL($t),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Tt),{name:e?.name})}}const Rt=`(function(){"use strict";self.onmessage=i=>{const{bufferX:c,bufferY:g,outputBufferX:d,outputBufferY:y,indexes:n,outStart:r,amount:f,isMonth:Y,isYear:h,deltaMs:w}=i.data,s=new Float64Array(c),a=new Float32Array(g),l=new Float64Array(d),u=new Float32Array(y);if(Y)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setMonth(o.getMonth()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else if(h)for(let t=0;t<n.length;t++){const e=n[t],o=new Date(s[e]);o.setFullYear(o.getFullYear()+f),l[r+t]=o.getTime(),u[r+t]=a[e]}else for(let t=0;t<n.length;t++){const e=n[t];l[r+t]=s[e]+w,u[r+t]=a[e]}self.postMessage("Done")}})();
9
+ `,It=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Rt],{type:"text/javascript;charset=utf-8"});function jr(e){let t;try{if(t=It&&(self.URL||self.webkitURL).createObjectURL(It),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Rt),{name:e?.name})}}const Ot=`(function(){"use strict";function a(e,t,o,c){const n=[];let r=e[t];for(let s=t+1;s<=o;s++){const f=e[s];f-r>c&&n.push(s-1,s),r=f}return n}self.onmessage=e=>{const{bufferX:t,start:o,endInclusive:c,threshold:n}=e.data,r=new Float64Array(t);self.postMessage(a(r,o,c,n))}})();
10
+ `,Ut=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Ot],{type:"text/javascript;charset=utf-8"});function Wr(e){let t;try{if(t=Ut&&(self.URL||self.webkitURL).createObjectURL(Ut),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Ot),{name:e?.name})}}const Mt=`(function(){"use strict";function c(u,s,t){const n=[];if(s>=t)return n;let e=s,o=u[s];for(let r=s+1;r<t;r++){const f=u[r];f!==o&&(n.push(e,r-e,o),e=r,o=f)}return n.push(e,t-e,o),n}self.onmessage=u=>{const{bufferY:s,start:t,end:n}=u.data,e=new Float32Array(s);self.postMessage(c(e,t,n))}})();
11
+ `,Ct=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Mt],{type:"text/javascript;charset=utf-8"});function xr(e){let t;try{if(t=Ct&&(self.URL||self.webkitURL).createObjectURL(Ct),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Mt),{name:e?.name})}}const Dt=`(function(){"use strict";function o(s,i,t,n,l){const f=[];if(n==="Less than")for(let e=i;e<t;e++)s[e]-s[e-1]<l&&f.push(e);else if(n==="Less than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]<=l&&f.push(e);else if(n==="Greater than")for(let e=i;e<t;e++)s[e]-s[e-1]>l&&f.push(e);else if(n==="Greater than or equal to")for(let e=i;e<t;e++)s[e]-s[e-1]>=l&&f.push(e);else if(n==="Equal")for(let e=i;e<t;e++)s[e]-s[e-1]==l&&f.push(e);return f}self.onmessage=s=>{const{bufferY:i,start:t,end:n,comparator:l,value:f}=s.data,e=new Float32Array(i);self.postMessage(o(e,t,n,l,f))}})();
12
+ `,Ft=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Dt],{type:"text/javascript;charset=utf-8"});function Gr(e){let t;try{if(t=Ft&&(self.URL||self.webkitURL).createObjectURL(Ft),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Dt),{name:e?.name})}}const Pt=`(function(){"use strict";function l(t,i,n,o,h){const f=[];if(o==="Less than")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)<h&&f.push(e)}else if(o==="Less than or equal to")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)<=h&&f.push(e)}else if(o==="Greater than")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)>h&&f.push(e)}else if(o==="Greater than or equal to")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)>=h&&f.push(e)}else if(o==="Equal")for(let e=i;e<n;e++){const s=t[e-1];(t[e]-s)/Math.abs(s)==h&&f.push(e)}return f}self.onmessage=t=>{const{bufferY:i,start:n,end:o,comparator:h,value:f}=t.data,e=new Float32Array(i);self.postMessage(l(e,n,o,h,f))}})();
13
+ `,Bt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Pt],{type:"text/javascript;charset=utf-8"});function Yr(e){let t;try{if(t=Bt&&(self.URL||self.webkitURL).createObjectURL(Bt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Pt),{name:e?.name})}}const Nt=`(function(){"use strict";function k(i,l,u,r,c){const f=[],b=r.length;for(let a=l;a<u;a++){const t=i[a];let e=!1;for(let n=0;n<b;n++){const o=r[n],s=c[n];if(o===0){if(t<s){e=!0;break}}else if(o===1){if(t<=s){e=!0;break}}else if(o===2){if(t>s){e=!0;break}}else if(o===3){if(t>=s){e=!0;break}}else if(t==s){e=!0;break}}e&&f.push(a)}return f}self.onmessage=i=>{const{bufferY:l,start:u,end:r,ops:c,values:f}=i.data,b=new Float32Array(l);self.postMessage(k(b,u,r,c,f))}})();
14
+ `,jt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Nt],{type:"text/javascript;charset=utf-8"});function Pe(e){let t;try{if(t=jt&&(self.URL||self.webkitURL).createObjectURL(jt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Nt),{name:e?.name})}}const Wt=`(function(){"use strict";function e(l,t,o,s){const c=t.length;if(o==="ADD")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]+s;else if(o==="SUB")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]-s;else if(o==="MULT")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]*s;else if(o==="DIV")for(let f=0;f<c;f++)l[t[f]]=l[t[f]]/s;else if(o==="ASSIGN")for(let f=0;f<c;f++)l[t[f]]=s}self.onmessage=l=>{const{bufferY:t,indexes:o,operator:s,value:c}=l.data,f=new Float32Array(t);e(f,o,s,c),self.postMessage("Done")}})();
15
+ `,xt=typeof self<"u"&&self.Blob&&new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);",Wt],{type:"text/javascript;charset=utf-8"});function Hr(e){let t;try{if(t=xt&&(self.URL||self.webkitURL).createObjectURL(xt),!t)throw"";const r=new Worker(t,{name:e?.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch{return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(Wt),{name:e?.name})}}function Gt(e,t,r,n,s){const o=[],a=n.length;for(let i=t;i<r;i++){const l=e[i];let f=!1;for(let u=0;u<a;u++){const p=n[u],g=s[u];if(p===0){if(l<g){f=!0;break}}else if(p===1){if(l<=g){f=!0;break}}else if(p===2){if(l>g){f=!0;break}}else if(p===3){if(l>=g){f=!0;break}}else if(l==g){f=!0;break}}f&&o.push(i)}return o}function zr(e,t,r,n,s){const o=[];if(n==="Less than")for(let a=t;a<r;a++)e[a]-e[a-1]<s&&o.push(a);else if(n==="Less than or equal to")for(let a=t;a<r;a++)e[a]-e[a-1]<=s&&o.push(a);else if(n==="Greater than")for(let a=t;a<r;a++)e[a]-e[a-1]>s&&o.push(a);else if(n==="Greater than or equal to")for(let a=t;a<r;a++)e[a]-e[a-1]>=s&&o.push(a);else if(n==="Equal")for(let a=t;a<r;a++)e[a]-e[a-1]==s&&o.push(a);return o}function Xr(e,t,r,n,s){const o=[];if(n==="Less than")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)<s&&o.push(a)}else if(n==="Less than or equal to")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)<=s&&o.push(a)}else if(n==="Greater than")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)>s&&o.push(a)}else if(n==="Greater than or equal to")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)>=s&&o.push(a)}else if(n==="Equal")for(let a=t;a<r;a++){const i=e[a-1];(e[a]-i)/Math.abs(i)==s&&o.push(a)}return o}function Vr(e,t,r,n){const s=[];let o=e[t];for(let a=t+1;a<=r;a++){const i=e[a];i-o>n&&s.push(a-1,a),o=i}return s}function qr(e,t,r){const n=[];if(t>=r)return n;let s=t,o=e[t];for(let a=t+1;a<r;a++){const i=e[a];i!==o&&(n.push(s,a-s,o),s=a,o=i)}return n.push(s,r-s,o),n}function Jr(e,t,r,n,s,o,a,i,l,f,u){let p=0,g=i;for(let y=o;y<=a;y++)if(n[g]=e[y],s[g]=t[y],g++,p<r.length&&y===r[p][0]){const d=r[p][0],h=r[p][1],S=e[d],b=e[h],w=t[d],k=t[h],L=b-S,T=k-w;let $=S+l;for(;$<b;)n[g]=$,s[g]=f?w+($-S)*T/L:u,g++,$+=l;p++}return g-i}function Kr(e,t,r,n,s,o,a,i){let l=o,f=0,u=i;const p=r.length;for(;l<a&&f<p;){const g=r[f][0];e[l]<=g?(n[u]=e[l],s[u]=t[l],l++):(n[u]=g,s[u]=r[f][1],f++),u++}for(;l<a;)n[u]=e[l],s[u]=t[l],l++,u++;for(;f<p;)n[u]=r[f][0],s[u]=r[f][1],f++,u++;return u-i}function Qr(e,t,r,n,s,o,a,i){let l=0,f=i;for(let u=o;u<=a;u++)l<r.length&&u===r[l]?l++:(n[f]=e[u],s[f]=t[u],f++);return f-i}function Zr(e,t,r,n){const s=r.length,o=new Array(s);if(n.isMonth)for(let a=0;a<s;a++){const i=r[a],l=new Date(e[i]);l.setMonth(l.getMonth()+n.amount),o[a]=[l.getTime(),t[i]]}else if(n.isYear)for(let a=0;a<s;a++){const i=r[a],l=new Date(e[i]);l.setFullYear(l.getFullYear()+n.amount),o[a]=[l.getTime(),t[i]]}else for(let a=0;a<s;a++){const i=r[a];o[a]=[e[i]+n.deltaMs,t[i]]}return o}function en(e,t,r){for(let n=0;n<r.length;n++){const{indexes:s,lowerIdx:o,upperIdx:a}=r[n],i=e[o],l=t[o],f=e[a],u=t[a],p=f-i,g=u-l;if(p===0){for(let y=0;y<s.length;y++)t[s[y]]=l;continue}for(let y=0;y<s.length;y++){const d=s[y];t[d]=l+(e[d]-i)*g/p}}}function tn(e,t,r){for(let n=0;n<r.length;n++){const s=r[n][0],o=r[n][1],a=r[n][2];if(o<=s)continue;const i=e[s],l=e[o]-i;if(l!==0)for(let f=s;f<o;f++)t[f]=t[f]+a*((e[f]-i)/l)}}function Yt(e,t,r,n){const s=t.length;if(r==="ADD")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]+n;else if(r==="SUB")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]-n;else if(r==="MULT")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]*n;else if(r==="DIV")for(let o=0;o<s;o++)e[t[o]]=e[t[o]]/n;else if(r==="ASSIGN")for(let o=0;o<s;o++)e[t[o]]=n}const Be="qc-utils:calibration:v1",rn=720*60*60*1e3,fe=5e4,de=2e5,pe={spawnOverheadMs:50,inlineThroughput:5e4,workerThroughput:8e4,hwConcurrency:4,measuredAt:0,userAgent:"default"};let U=hn()??pe,Ne=null,re=null;const je=new Set,We={[v.VALUE_THRESHOLD]:{mode:"calibrated",weight:1,rationale:"O(n) single-pass scan; baseline reference"},[v.CHANGE]:{mode:"calibrated",weight:1.1,rationale:"O(n) with one subtraction per step"},[v.RATE_OF_CHANGE]:{mode:"calibrated",weight:1.4,rationale:"O(n) with division + abs per step"},[v.FIND_GAPS]:{mode:"calibrated",weight:.9,rationale:"O(n) on X only, mostly empty output"},[v.PERSISTENCE]:{mode:"calibrated",weight:1.3,rationale:"O(n) + chunk-boundary stitch"},[v.DATETIME_RANGE]:{mode:"always-inline",weight:0,rationale:"O(log n) binary search; never worth the worker hop"},[v.SELECTION]:{mode:"always-inline",weight:0,rationale:"Pure history bookkeeping"},[E.CHANGE_VALUES]:{mode:"calibrated",weight:.7,rationale:"O(k) in-place arithmetic on selection"},[E.ASSIGN_VALUES_BULK]:{mode:"always-inline",weight:0,rationale:"Single tight loop, already inline"},[E.ASSIGN_DATETIMES_BULK]:{mode:"always-inline",weight:0,rationale:"Composes delete+add which handle their own dispatch"},[E.INTERPOLATE]:{mode:"calibrated",weight:1.5,rationale:"Linear interp per consecutive group; in-place writes"},[E.DRIFT_CORRECTION]:{mode:"calibrated",weight:1.2,rationale:"O(range total) in-place math; one pass per range"},[E.SHIFT_DATETIMES]:{mode:"calibrated",weight:1.1,rationale:"O(k) per-point shift math; inline skips SAB allocation"},[E.ADD_POINTS]:{mode:"calibrated",weight:1.8,rationale:"Single merge pass over Y/X + insertions; fresh SAB per call"},[E.DELETE_POINTS]:{mode:"calibrated",weight:1.4,rationale:"Single skip-on-delete pass over Y/X; fresh SAB per call"},[E.FILL_GAPS]:{mode:"calibrated",weight:1.3,rationale:"Single copy-with-fills pass; fresh SAB sized to newLength"}};function D(e,t){const r=We[e];if(!r)return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:"unknown op; keeping default worker path"};if(r.mode==="always-inline")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:0,reason:r.rationale};if(typeof SharedArrayBuffer>"u")return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:1/0,reason:"SharedArrayBuffer unavailable; forced inline"};if(r.mode==="always-worker")return{useWorker:!0,predictedInlineMs:1/0,predictedWorkerMs:0,reason:r.rationale};const n=nn(e,t);if(n<=0)return{useWorker:!1,predictedInlineMs:0,predictedWorkerMs:U.spawnOverheadMs,reason:"zero work units"};const s=Math.max(1,Math.min(t.parallelism??U.hwConcurrency,U.hwConcurrency)),o=r.weight*n/U.inlineThroughput,a=U.spawnOverheadMs+r.weight*n/(U.workerThroughput*s),i=o>a;return{useWorker:i,predictedInlineMs:o,predictedWorkerMs:a,reason:i?`worker faster (${a.toFixed(1)} vs ${o.toFixed(1)} ms)`:`inline faster (${o.toFixed(1)} vs ${a.toFixed(1)} ms)`}}function nn(e,t){switch(e){case E.CHANGE_VALUES:case E.INTERPOLATE:case E.SHIFT_DATETIMES:case E.DRIFT_CORRECTION:return t.selectionSize??0;case E.DELETE_POINTS:return(t.selectionSize??0)+t.datasetSize*.25;case E.ADD_POINTS:{const r=Math.max(1,Math.log2(Math.max(t.datasetSize,2)));return t.datasetSize+(t.selectionSize??0)*r}default:return t.datasetSize}}function sn(e){return je.add(e),()=>je.delete(e)}function an(){return U}function on(){return Ne}function cn(){return Object.keys(We).map(e=>({op:e,...We[e]}))}function ln(){U=pe,Ne=null;try{localStorage.removeItem(Be)}catch{}}async function un(e={}){if(typeof window>"u"||!(e.force||U.measuredAt===0||Date.now()-U.measuredAt>rn))return U;if(re)await re;else{re=Ht().finally(()=>{re=null});const r=await re;U=r,fn(r),Ne=r;for(const n of je)n(U)}return U}async function Ht(){if(!(typeof SharedArrayBuffer<"u"))return{...pe,measuredAt:Date.now(),userAgent:navigator.userAgent,hwConcurrency:navigator.hardwareConcurrency||pe.hwConcurrency,sharedArrayBufferAvailable:!1,samples:{spawnRoundtripMs:[],inlineScanMs:[],workerScanMs:[]}};const t=navigator.hardwareConcurrency||4,r=new Float32Array(fe);for(let h=0;h<fe;h++)r[h]=Math.sin(h);const n=await xe(3,()=>{const h=performance.now();return Gt(r,0,fe,[2],[.5]),performance.now()-h}),s=Ge(n),o=fe/Math.max(s,.001),a=new SharedArrayBuffer(256*Float32Array.BYTES_PER_ELEMENT),i=await xe(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Pe;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:a,start:0,end:256,ops:[2],values:[.5]})}),performance.now()-h}),l=Ge(i),f=new SharedArrayBuffer(de*Float32Array.BYTES_PER_ELEMENT),u=new Float32Array(f);for(let h=0;h<de;h++)u[h]=Math.sin(h);const p=await xe(3,async()=>{const h=performance.now();return await new Promise(S=>{const b=new Pe;b.onmessage=()=>{b.terminate(),S()},b.postMessage({bufferY:f,start:0,end:de,ops:[2],values:[.5]})}),performance.now()-h}),g=Math.max(Ge(p)-l,.1),y=de/g;return{spawnOverheadMs:l,inlineThroughput:o,workerThroughput:y,hwConcurrency:t,measuredAt:Date.now(),userAgent:navigator.userAgent,sharedArrayBufferAvailable:!0,samples:{spawnRoundtripMs:i,inlineScanMs:n,workerScanMs:p}}}async function xe(e,t){const r=[];for(let n=0;n<e;n++)await new Promise(s=>setTimeout(s,0)),r.push(await t());return r}function Ge(e){if(!e.length)return 0;const t=[...e].sort((n,s)=>n-s),r=Math.floor(t.length/2);return t.length%2?t[r]:(t[r-1]+t[r])/2}function hn(){if(typeof localStorage>"u")return null;try{const e=localStorage.getItem(Be);if(!e)return null;const t=JSON.parse(e);return!t||typeof t.spawnOverheadMs!="number"?null:t}catch{return null}}function fn(e){if(!(typeof localStorage>"u"))try{const t={spawnOverheadMs:e.spawnOverheadMs,inlineThroughput:e.inlineThroughput,workerThroughput:e.workerThroughput,hwConcurrency:e.hwConcurrency,measuredAt:e.measuredAt,userAgent:e.userAgent};localStorage.setItem(Be,JSON.stringify(t))}catch{}}const K=20*1e3,dn=1024,pn=["date","value","qualifier"];class yn{dataset={dimensions:pn,source:{x:new Float64Array(new SharedArrayBuffer(K*Float64Array.BYTES_PER_ELEMENT,{maxByteLength:K*Float64Array.BYTES_PER_ELEMENT})),y:new Float32Array(new SharedArrayBuffer(K*Float32Array.BYTES_PER_ELEMENT,{maxByteLength:K*Float32Array.BYTES_PER_ELEMENT}))}};history=[];redoStack=[];_isReplaying=!1;_pendingExecutionMode="inline";loadingTime=null;isLoading=!0;rawData;constructor(t){this.history=[],this.rawData=t,this.loadData(this.rawData)}async loadData(t){if(!t)return;this.isLoading=!0;const r=await ue(()=>{this._growBuffer(t.datetimes.length),this._resizeTo(t.datetimes.length),this.dataX.set(t.datetimes),this.dataY.set(t.dataValues)});this.loadingTime=r.duration,this.history.length=0,this.isLoading=!1}get dataX(){return this.dataset.source.x}get dataY(){return this.dataset.source.y}_resizeTo(t){this.dataset.source.x=new Float64Array(this.dataset.source.x.buffer).subarray(0,t),this.dataset.source.y=new Float32Array(this.dataset.source.y.buffer).subarray(0,t)}_growBuffer(t){const r=t*Float64Array.BYTES_PER_ELEMENT;let n=this.dataX.buffer.byteLength;for(;r>n;)n+=K*Float64Array.BYTES_PER_ELEMENT;if(n*Float64Array.BYTES_PER_ELEMENT>this.dataX.buffer.maxByteLength){const s=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:n*Float64Array.BYTES_PER_ELEMENT}),o=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:n*Float32Array.BYTES_PER_ELEMENT}),a=new Float64Array(s),i=new Float32Array(o);a.set(this.dataX),i.set(this.dataY),this.dataset.source.x=a,this.dataset.source.y=i}this.dataX.buffer.byteLength<t*Float64Array.BYTES_PER_ELEMENT&&(this.dataX.buffer.grow(t*Float64Array.BYTES_PER_ELEMENT),this.dataY.buffer.grow(t*Float32Array.BYTES_PER_ELEMENT))}async reload(){this.loadingTime=null,this.isLoading=!0,this.history.length=0,await this.loadData(this.rawData)}async reloadHistory(t){const r=this.history.slice(0,t+1);return this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async removeHistoryItem(t){const r=[...this.history];return r.splice(t,1),this.redoStack.length=0,await this.reload(),await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}async undo(){if(!this.history.length)return[];const t=this.history[this.history.length-1],r=this.history.slice(0,-1);await this.reload(),this.redoStack.push(t),this._isReplaying=!0;try{return await this.dispatch(r.map(n=>[n.method,...n.args||[]]))}finally{this._isReplaying=!1}}async redo(){if(!this.redoStack.length)return[];const t=this.redoStack.pop();this._isReplaying=!0;try{return await this.dispatch([[t.method,...t.args||[]]])}finally{this._isReplaying=!1}}get beginTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[0]):null}get endTime(){return this.dataset.source.x.length?new Date(this.dataset.source.x[this.dataset.source.x.length-1]):null}async dispatchAction(t,...r){const n={[E.ADD_POINTS]:this._addDataPoints,[E.CHANGE_VALUES]:this._changeValues,[E.ASSIGN_VALUES_BULK]:this._assignValuesBulk,[E.DELETE_POINTS]:this._deleteDataPoints,[E.DRIFT_CORRECTION]:this._driftCorrection,[E.INTERPOLATE]:this._interpolate,[E.SHIFT_DATETIMES]:this._shift,[E.ASSIGN_DATETIMES_BULK]:this._assignDatetimesBulk,[E.FILL_GAPS]:this._fillGaps},s={[E.ADD_POINTS]:"mdi-plus",[E.CHANGE_VALUES]:"mdi-pencil",[E.ASSIGN_VALUES_BULK]:"mdi-pencil",[E.DELETE_POINTS]:"mdi-trash-can",[E.DRIFT_CORRECTION]:"mdi-chart-sankey",[E.INTERPOLATE]:"mdi-transit-connection-horizontal",[E.SHIFT_DATETIMES]:"mdi-calendar",[E.ASSIGN_DATETIMES_BULK]:"mdi-calendar",[E.FILL_GAPS]:"mdi-keyboard-space"};let o=[];try{this._isReplaying||(this.redoStack.length=0);const a={method:t,args:r,icon:s[t],isLoading:!0};this.history.push(a);const i=this.history.length-1;this._pendingExecutionMode="inline";const l=await ue(async()=>await n[t].apply(this,r));o=l.response;const f=this.history[i];f&&(f.duration=l.duration,f.executionMode=this._pendingExecutionMode,f.isLoading=!1)}catch(a){console.log(`Failed to execute operation: ${t} with arguments: `,r),console.log(a)}return o}async dispatch(t,...r){const n=async(s,o)=>v[s]?await this.dispatchFilter(s,...o):await this.dispatchAction(s,...o);if(Array.isArray(t)){let s=[];for(let o=0;o<t.length;o++){const a=t[o][0],i=t[o].slice(1,t[o].length);s=await n(a,i)}return s}else return await n(t,r)}async dispatchFilter(t,...r){const n={[v.FIND_GAPS]:this._findGaps,[v.VALUE_THRESHOLD]:this._valueThreshold,[v.DATETIME_RANGE]:this._datetimeRange,[v.PERSISTENCE]:this._persistence,[v.CHANGE]:this._change,[v.RATE_OF_CHANGE]:this._rateOfChange,[v.SELECTION]:this._selection},s={[v.FIND_GAPS]:"mdi-plus",[v.PERSISTENCE]:"mdi-plus",[v.CHANGE]:"mdi-plus",[v.RATE_OF_CHANGE]:"mdi-plus",[v.VALUE_THRESHOLD]:"mdi-plus",[v.DATETIME_RANGE]:"mdi-plus",[v.SELECTION]:"mdi-plus"};let o=[];try{this._isReplaying||(this.redoStack.length=0);const a={method:t,args:r,icon:s[t],isLoading:!0},i=this.history[this.history.length-1];let l;v[i?.method]?(l=this.history.length-1,this.history[l]=a):(this.history.push(a),l=this.history.length-1),this._pendingExecutionMode="inline";const f=await ue(async()=>await n[t].apply(this,r));o=f.response;const u=this.history[l];u&&(u.duration=f.duration,u.executionMode=this._pendingExecutionMode,u.selected=f.response,u.isLoading=!1)}catch(a){console.log(`Failed to execute filter operation: ${t} with arguments: `,r),console.log(a)}return o}async _changeValues(t,r){const n=this.history[this.history.length-2]?.selected;if(!n||n.length===0)return[];const s=n.length;if(!D(E.CHANGE_VALUES,{datasetSize:this.dataset.source.y.length,selectionSize:s}).useWorker||s<dn)return Yt(this.dataY,n,t,r),[];this._pendingExecutionMode="worker";const a=Math.min(navigator.hardwareConcurrency||1,s),i=Math.ceil(s/a),l=[],f=[];for(let u=0;u<a;u++){const p=u*i,g=Math.min((u+1)*i,s);if(p>=g)break;const y=n.slice(p,g);f.push(new Promise(d=>{const h=new Hr;l.push(h),h.postMessage({bufferY:this.dataY.buffer,indexes:y,operator:t,value:r}),h.onmessage=S=>{d(S.data)}}))}return await Promise.all(f),l.forEach(u=>u.terminate()),[]}_applyOperatorInPlace(t,r,n){Yt(this.dataY,t,r,n)}async _assignValuesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=this.dataY;for(let o=0;o<n;o++)s[r[o]]=t[o];return[]}async _assignDatetimesBulk(t){const r=this.history[this.history.length-2]?.selected;if(!r||!r.length||!t?.length)return[];const n=Math.min(r.length,t.length),s=new Array(n),o=new Array(n);for(let a=0;a<n;a++)s[a]=[t[a],this.dataY[r[a]]],o[a]=r[a];return o.sort((a,i)=>a-i),await this._deleteDataPoints(o),await this._addDataPoints(s),[]}async _interpolate(t){const r=this._getConsecutiveGroups(t);if(r.length===0||r[0].length===0)return;const n=this.dataset.source.y.length,s=r.map(u=>({indexes:u,lowerIdx:Math.max(0,u[0]-1),upperIdx:Math.min(n-1,u[u.length-1]+1)}));if(!D(E.INTERPOLATE,{datasetSize:n,selectionSize:t.length}).useWorker){en(this.dataX,this.dataY,s);return}this._pendingExecutionMode="worker";const a=Math.min(navigator.hardwareConcurrency||1,s.length),i=Math.ceil(s.length/a),l=[],f=[];for(let u=0;u<a;u++){const p=s.slice(u*i,(u+1)*i);if(p.length===0)break;f.push(new Promise(g=>{const y=new Pr;l.push(y),y.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,groups:p}),y.onmessage=d=>{g(d.data)}}))}await Promise.all(f),l.forEach(u=>u.terminate())}async _shift(t,r,n){if(t.length===0)return;const s=n===O.MONTH,o=n===O.YEAR,a=!s&&!o?r*ee[n]*1e3:0,i=t.length;if(!D(E.SHIFT_DATETIMES,{datasetSize:this.dataset.source.x.length,selectionSize:i}).useWorker){const w=Zr(this.dataX,this.dataY,t,{amount:r,isMonth:s,isYear:o,deltaMs:a});await this._deleteDataPoints(t),await this._addDataPoints(w);return}this._pendingExecutionMode="worker";const f=new SharedArrayBuffer(i*Float64Array.BYTES_PER_ELEMENT),u=new SharedArrayBuffer(i*Float32Array.BYTES_PER_ELEMENT),p=Math.min(navigator.hardwareConcurrency||1,i),g=Math.ceil(i/p),y=[],d=[];for(let w=0;w<p;w++){const k=w*g,L=Math.min((w+1)*g,i);if(k>=L)break;const T=t.slice(k,L);d.push(new Promise($=>{const M=new jr;y.push(M),M.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:f,outputBufferY:u,indexes:T,outStart:k,amount:r,isMonth:s,isYear:o,deltaMs:a}),M.onmessage=z=>{$(z.data)}}))}await Promise.all(d),y.forEach(w=>w.terminate());const h=new Float64Array(f),S=new Float32Array(u),b=new Array(i);for(let w=0;w<i;w++)b[w]=[h[w],S[w]];await this._deleteDataPoints(t),await this._addDataPoints(b)}async _fillGaps(t,r,n,s){const o=this.dataX.length;if(o===0)return;const a=t[0]*ee[t[1]]*1e3,i=r[0]*ee[r[1]]*1e3,l=-9999,f=s?.[0]??0,u=s?.[1]??o-1,p=this.dataX,g=[],y=[];let d=0;for(let A=f+1;A<=u;A++)if(p[A]-p[A-1]>a){let N=0,X=p[A-1]+i;for(;X<p[A];)N++,X+=i;N>0&&(g.push([A-1,A]),y.push(N),d+=N)}if(d===0)return;const h=o+d,S=h*Float64Array.BYTES_PER_ELEMENT,b=h*Float32Array.BYTES_PER_ELEMENT,w=new SharedArrayBuffer(S,{maxByteLength:Math.max(this.dataX.buffer.maxByteLength,S)}),k=new SharedArrayBuffer(b,{maxByteLength:Math.max(this.dataY.buffer.maxByteLength,b)});if(!D(E.FILL_GAPS,{datasetSize:o,selectionSize:d}).useWorker){const A=new Float64Array(w),W=new Float32Array(k);Jr(this.dataX,this.dataY,g,A,W,0,o-1,0,i,n,l),this.dataset.source.x=A,this.dataset.source.y=W,this._resizeTo(h);return}this._pendingExecutionMode="worker";const T=navigator.hardwareConcurrency||1,$=Math.ceil(o/T),M=[];let z=0;for(let A=0;A<T;A++){const W=A*$,N=Math.min((A+1)*$-1,o-1),X=[];let ye=0;for(;z<g.length&&g[z][0]<=N;)X.push(g[z]),ye+=y[z],z++;M.push({start:W,end:N,gapsSegment:X,fillsInSegment:ye})}const Ye=new Array(T).fill(0);for(let A=1;A<T;A++)Ye[A]=Ye[A-1]+M[A-1].fillsInSegment;const zt=[],Xt=[];for(let A=0;A<T;A++){const{start:W,end:N,gapsSegment:X}=M[A],ye=W+Ye[A];Xt.push(new Promise(gn=>{const He=new Fr;zt.push(He),He.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:w,outputBufferY:k,start:W,end:N,gapsSegment:X,startTarget:ye,fillDelta:i,interpolate:n,fillValue:l}),He.onmessage=mn=>{gn(mn.data)}}))}await Promise.all(Xt),zt.forEach(A=>A.terminate()),this.dataset.source.x=new Float64Array(w),this.dataset.source.y=new Float32Array(k),this._resizeTo(h)}async _deleteDataPoints(t){const r=this.dataX.length,n=r-t.length;if(!D(E.DELETE_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const y=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),d=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength}),h=new Float64Array(y),S=new Float32Array(d);Qr(this.dataX,this.dataY,t,h,S,0,r-1,0),this.dataset.source.x=h,this.dataset.source.y=S,this._resizeTo(n);return}this._pendingExecutionMode="worker";const o=navigator.hardwareConcurrency||1,a=Math.ceil(this.dataX.length/o),i=[],l=[];for(let y=0;y<o;y++){const d=y*a,h=Math.min((y+1)*a-1,this.dataX.length-1),S=te(t,d),b=he(t,h),w=t.slice(S,b+1);l.push({start:d,end:h,deleteSegment:w})}const f=new Array(o).fill(0);for(let y=1;y<o;y++)f[y]=f[y-1]+l[y-1].deleteSegment.length;const u=[],p=new SharedArrayBuffer(this.dataX.buffer.byteLength,{maxByteLength:this.dataX.buffer.maxByteLength}),g=new SharedArrayBuffer(this.dataY.buffer.byteLength,{maxByteLength:this.dataY.buffer.maxByteLength});for(let y=0;y<o;y++){const{start:d,end:h,deleteSegment:S}=l[y],b=d-f[y];u.push(new Promise(w=>{const k=new Dr;i.push(k),k.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:p,outputBufferY:g,start:d,end:h,deleteSegment:S,startTarget:b}),k.onmessage=L=>{w(L.data)}}))}await Promise.all(u),i.forEach(y=>y.terminate()),this.dataset.source.x=new Float64Array(p),this.dataset.source.y=new Float32Array(g),this._resizeTo(n)}async _driftCorrection(t){if(!t||t.length===0)return;const r=this.dataset.source.x,n=navigator.hardwareConcurrency||1;let s=0;for(const[p,g]of t)g>p&&(s+=g-p);if(!D(E.DRIFT_CORRECTION,{datasetSize:r.length,selectionSize:s}).useWorker){tn(r,this.dataY,t);return}this._pendingExecutionMode="worker";const a=[];for(const[p,g,y]of t){if(g<=p)continue;const d=r[p],h=r[g]-d;if(h===0)continue;const S=g-p,b=Math.max(1,Math.ceil(S/n));for(let w=p;w<g;w+=b)a.push({chunkStart:w,chunkEnd:Math.min(w+b,g),startDatetime:d,value:y,extent:h})}if(a.length===0)return;const i=Math.min(n,a.length),l=Array.from({length:i},()=>[]);a.forEach((p,g)=>l[g%i].push(p));const f=[],u=[];for(const p of l)p.length!==0&&u.push(new Promise(g=>{const y=new Br;f.push(y),y.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,jobs:p}),y.onmessage=d=>{g(d.data)}}));await Promise.all(u),f.forEach(p=>p.terminate())}_getConsecutiveGroups(t){const r=[[]];return t.reduce((n,s)=>{const o=n[n.length-1];return!o.length||s==o[o.length-1]+1?o.push(s):n.push([s]),n},r),r}async _addDataPoints(t){if(t.length===0)return;const r=this.dataX.length,n=r+t.length;t.sort((d,h)=>d[0]-h[0]);const s=n*Float64Array.BYTES_PER_ELEMENT,o=n*Float32Array.BYTES_PER_ELEMENT,a=new SharedArrayBuffer(s,{maxByteLength:Math.max(this.dataX.buffer.maxByteLength,s)}),i=new SharedArrayBuffer(o,{maxByteLength:Math.max(this.dataY.buffer.maxByteLength,o)});if(!D(E.ADD_POINTS,{datasetSize:r,selectionSize:t.length}).useWorker){const d=new Float64Array(a),h=new Float32Array(i);Kr(this.dataX,this.dataY,t,d,h,0,r,0),this.dataset.source.x=d,this.dataset.source.y=h,this._resizeTo(n);return}this._pendingExecutionMode="worker";const f=t.map(d=>he(this.dataX,d[0])+1),u=Math.max(1,Math.min(navigator.hardwareConcurrency||1,Math.max(r,1))),p=Math.ceil(Math.max(r,1)/u),g=[],y=[];for(let d=0;d<u;d++){const h=d*p,S=Math.min((d+1)*p,r),b=te(f,h),w=d===u-1?t.length:te(f,S),k=t.slice(b,w),L=h+b;h>=S&&k.length===0||y.push(new Promise(T=>{const $=new Nr;g.push($),$.postMessage({bufferX:this.dataX.buffer,bufferY:this.dataY.buffer,outputBufferX:a,outputBufferY:i,origStart:h,origEnd:S,insertions:k,outStart:L}),$.onmessage=M=>{T(M.data)}}))}await Promise.all(y),g.forEach(d=>d.terminate()),this.dataset.source.x=new Float64Array(a),this.dataset.source.y=new Float32Array(i),this._resizeTo(n)}async _valueThreshold(t){const r=Object.keys(t);if(r.length===0)return[];const n={[x.LT]:0,[x.LTE]:1,[x.GT]:2,[x.GTE]:3,[x.E]:4},s=r.map(h=>n[h]??4),o=r.map(h=>t[h]),a=this.dataset.source.y,i=a.length;if(i===0)return[];if(!D(v.VALUE_THRESHOLD,{datasetSize:i}).useWorker)return Gt(a,0,i,s,o);this._pendingExecutionMode="worker";const f=Math.min(navigator.hardwareConcurrency||1,i),u=Math.ceil(i/f),p=[],g=[];for(let h=0;h<f;h++){const S=h*u,b=Math.min((h+1)*u,i);if(S>=b)break;g.push(new Promise(w=>{const k=new Pe;p.push(k),k.postMessage({bufferY:this.dataY.buffer,start:S,end:b,ops:s,values:o}),k.onmessage=L=>{w(L.data)}}))}const y=await Promise.all(g);p.forEach(h=>h.terminate());const d=[];for(let h=0;h<y.length;h++){const S=y[h];for(let b=0;b<S.length;b++)d.push(S[b])}return d}async _rateOfChange(t,r){const n=this.dataset.source.y;if(n.length<2)return[];const s=1,o=n.length,a=o-s;if(!D(v.RATE_OF_CHANGE,{datasetSize:n.length}).useWorker)return Xr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,o);if(h>=S)break;p.push(new Promise(b=>{const w=new Yr;u.push(w),w.postMessage({bufferY:this.dataY.buffer,start:h,end:S,comparator:t,value:r}),w.onmessage=k=>{b(k.data)}}))}const g=await Promise.all(p);u.forEach(d=>d.terminate());const y=[];for(let d=0;d<g.length;d++){const h=g[d];for(let S=0;S<h.length;S++)y.push(h[S])}return y}async _datetimeRange(t,r){const n=this.dataset.source.x,s=n.length;if(s===0)return[];const o=t==null?0:te(n,t),a=r==null?s-1:he(n,r);if(o>a)return[];const i=new Array(a-o+1);for(let l=o;l<=a;l++)i[l-o]=l;return i}async _selection(t){return(!t||!t.length)&&this.history.pop(),t}async _change(t,r){const n=this.dataset.source.y;if(n.length<2)return[];const s=1,o=n.length,a=o-s;if(!D(v.CHANGE,{datasetSize:n.length}).useWorker)return zr(n,s,o,t,r);this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let d=0;d<l;d++){const h=s+d*f,S=Math.min(s+(d+1)*f,o);if(h>=S)break;p.push(new Promise(b=>{const w=new Gr;u.push(w),w.postMessage({bufferY:this.dataY.buffer,start:h,end:S,comparator:t,value:r}),w.onmessage=k=>{b(k.data)}}))}const g=await Promise.all(p);u.forEach(d=>d.terminate());const y=[];for(let d=0;d<g.length;d++){const h=g[d];for(let S=0;S<h.length;S++)y.push(h[S])}return y}async _findGaps(t,r,n){const s=this.dataset.source.x;let o=0,a=s.length;if(n?.[0]&&n?.[1]&&(o=n[0],a=n[1]),a<=o)return[];const i=t*ee[r]*1e3;if(!D(v.FIND_GAPS,{datasetSize:a-o}).useWorker){const S=Vr(s,o,a-1,i),b=new Set;for(let w=0;w<S.length;w++)b.add(S[w]);return[...b]}this._pendingExecutionMode="worker";const f=a-o,u=Math.min(navigator.hardwareConcurrency||1,f),p=Math.ceil(f/u),g=[],y=[];for(let S=0;S<u;S++){const b=o+S*p,w=Math.min(o+(S+1)*p,a);if(b>=w)break;y.push(new Promise(k=>{const L=new Wr;g.push(L),L.postMessage({bufferX:this.dataX.buffer,start:b,endInclusive:w,threshold:i}),L.onmessage=T=>{k(T.data)}}))}const d=await Promise.all(y);g.forEach(S=>S.terminate());const h=new Set;for(let S=0;S<d.length;S++){const b=d[S];for(let w=0;w<b.length;w++)h.add(b[w])}return[...h]}async _persistence(t,r){const n=this.dataset.source.y;let s=0,o=n.length;if(r?.[0]&&r?.[1]&&(s=r[0],o=r[1]),o<=s)return[];const a=o-s;if(!D(v.PERSISTENCE,{datasetSize:a}).useWorker){const b=qr(n,s,o),w=[];for(let k=0;k<b.length;k+=3){const L=b[k],T=b[k+1];if(T>=t)for(let $=0;$<T;$++)w.push(L+$)}return w}this._pendingExecutionMode="worker";const l=Math.min(navigator.hardwareConcurrency||1,a),f=Math.ceil(a/l),u=[],p=[];for(let b=0;b<l;b++){const w=s+b*f,k=Math.min(s+(b+1)*f,o);if(w>=k)break;p.push(new Promise(L=>{const T=new xr;u.push(T),T.postMessage({bufferY:this.dataY.buffer,start:w,end:k}),T.onmessage=$=>{L($.data)}}))}const g=await Promise.all(p);u.forEach(b=>b.terminate());const y=[],d=[],h=[];for(let b=0;b<g.length;b++){const w=g[b];for(let k=0;k<w.length;k+=3){const L=w[k],T=w[k+1],$=w[k+2],M=y.length-1;M>=0&&h[M]===$&&y[M]+d[M]===L?d[M]+=T:(y.push(L),d.push(T),h.push($))}}const S=[];for(let b=0;b<y.length;b++){const w=d[b];if(w>=t){const k=y[b];for(let L=0;L<w;L++)S.push(k+L)}}return S}}m.ACCOUNT_BASE=F,m.AUTH_BASE=ie,m.ApiKey=ar,m.BASE_URL=C,m.Collaborator=ir,m.DEFAULT_SNACK_DURATION=Le,m.DataSource=Ar,m.Datastream=Jt,m.EnumEditOperations=E,m.EnumFilterOperations=v,m.FilterOperation=x,m.HydroShareArchive=Ve,m.INCREASE_AMOUNT=K,m.Location=qe,m.LogicalOperation=Xe,m.OAuthProvider=sr,m.ObservationRecord=yn,m.ObservedProperty=Zt,m.Operator=ze,m.Organization=rr,m.PROVIDER_BASE=Q,m.Payload=$r,m.PermissionAction=Je,m.PermissionResource=Ke,m.Position=lt,m.PostHydroShareArchive=Vt,m.ProcessingLevel=er,m.ResultQualifier=tr,m.SESSION_BASE=ce,m.Sensor=Qt,m.Snack=ut,m.SnackColor=Te,m.SnackIcon=$e,m.SnackTitle=Re,m.Snackbar=ht,m.TAG_BASE=Ce,m.THINGS_BASE=_,m.Thing=qt,m.TimeUnit=O,m.Unit=Kt,m.User=nr,m.Workspace=or,m.api=Tr,m.apiMethods=c,m.clearCalibration=ln,m.createPatchObject=Ie,m.ensureCalibration=un,m.extractErrorMessage=Qe,m.findFirstGreaterOrEqual=te,m.findLastLessOrEqual=he,m.formatDate=Ur,m.formatDuration=Mr,m.getCSRFToken=ge,m.getCalibration=an,m.getLastBenchmarkDetail=on,m.getObservationsEndpoint=Lr,m.getOperationTable=cn,m.measureEllapsedTime=ue,m.onCalibrationChange=sn,m.requestInterceptor=me,m.responseInterceptor=we,m.runBenchmarks=Ht,m.shouldUseWorker=D,m.subtractHours=Cr,m.timeUnitMultipliers=ee,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"})}));
@@ -1,5 +1,5 @@
1
- import { DataSource } from '@/models';
2
- import { ObservationRecord } from '@/utils/plotting/observation-record';
1
+ import { DataSource } from "@/models";
2
+ import { ObservationRecord } from "@/utils/plotting/observation-record";
3
3
  export type EnumDictionary<T extends string | symbol | number, U> = {
4
4
  [K in T]: U;
5
5
  };
@@ -15,10 +15,23 @@ export declare enum TimeUnit {
15
15
  export declare enum EnumEditOperations {
16
16
  ADD_POINTS = "ADD_POINTS",
17
17
  CHANGE_VALUES = "CHANGE_VALUES",
18
+ /**
19
+ * Single-operation assignment of distinct values at distinct indices.
20
+ * Args: `(indices: number[], values: number[])` — parallel arrays where
21
+ * `values[i]` is written to `dataY[indices[i]]`. No workers, no per-row
22
+ * ceremony. Intended for table-driven edits.
23
+ */
24
+ ASSIGN_VALUES_BULK = "ASSIGN_VALUES_BULK",
18
25
  DELETE_POINTS = "DELETE_POINTS",
19
26
  DRIFT_CORRECTION = "DRIFT_CORRECTION",
20
27
  INTERPOLATE = "INTERPOLATE",
21
28
  SHIFT_DATETIMES = "SHIFT_DATETIMES",
29
+ /**
30
+ * Single-operation assignment of distinct datetimes at distinct indices.
31
+ * Args: `(indices: number[], datetimes: number[])` — parallel arrays of
32
+ * epoch-milliseconds. Runs one combined delete + add under the hood.
33
+ */
34
+ ASSIGN_DATETIMES_BULK = "ASSIGN_DATETIMES_BULK",
22
35
  FILL_GAPS = "FILL_GAPS"
23
36
  }
24
37
  export declare enum EnumFilterOperations {
@@ -26,18 +39,17 @@ export declare enum EnumFilterOperations {
26
39
  PERSISTENCE = "PERSISTENCE",
27
40
  CHANGE = "CHANGE",
28
41
  RATE_OF_CHANGE = "RATE_OF_CHANGE",
29
- VALUE_THRESHOLD = "VALUE_THRESHOLD"
42
+ VALUE_THRESHOLD = "VALUE_THRESHOLD",
43
+ DATETIME_RANGE = "DATETIME_RANGE",
44
+ SELECTION = "SELECTION"
30
45
  }
31
46
  export declare enum FilterOperation {
32
47
  LT = "Less than",
33
48
  LTE = "Less than or equal to",
34
49
  GT = "Greater than",
35
50
  GTE = "Greater than or equal to",
36
- E = "Equal",
37
- START = "Start datetime",
38
- END = "End datetime"
51
+ E = "Equal"
39
52
  }
40
- export declare const FilterOperationFn: EnumDictionary<FilterOperation, (value: number, toCompare: number) => boolean>;
41
53
  export declare enum Operator {
42
54
  ADD = "ADD",
43
55
  SUB = "SUB",
@@ -52,14 +64,24 @@ export declare enum LogicalOperation {
52
64
  GTE = "Greater than or equal to",
53
65
  E = "Equal"
54
66
  }
55
- export declare const LogicalComparator: EnumDictionary<LogicalOperation, (value: number, toCompare: number) => boolean>;
56
67
  export type HistoryItem = {
57
- method: EnumEditOperations;
68
+ method: EnumEditOperations | EnumFilterOperations;
58
69
  icon: string;
59
70
  isLoading: boolean;
60
71
  args?: any[];
61
72
  duration?: number;
62
- status?: 'success' | 'failed';
73
+ selected?: number[];
74
+ status?: "success" | "failed";
75
+ /**
76
+ * Whether the operation actually ran on a web worker or inline on
77
+ * the main thread. Populated by the `ObservationRecord` dispatch
78
+ * site based on the calibration decision and any always-inline /
79
+ * always-worker handler behaviour. Mainly useful in dev for
80
+ * verifying that the calibration layer is routing as expected —
81
+ * the qc-app surfaces a small badge per history entry when
82
+ * `import.meta.env.DEV` is truthy.
83
+ */
84
+ executionMode?: "worker" | "inline";
63
85
  };
64
86
  export type DataPoint = {
65
87
  date: Date;
@@ -73,12 +95,12 @@ export interface GraphSeries {
73
95
  yAxisLabel: string;
74
96
  seriesOption: any;
75
97
  }
76
- export type TimeSpacingUnit = 'seconds' | 'minutes' | 'hours' | 'days';
98
+ export type TimeSpacingUnit = "seconds" | "minutes" | "hours" | "days";
77
99
  export interface Tag {
78
100
  key: string;
79
101
  value: string;
80
102
  }
81
- export type Frequency = 'daily' | 'weekly' | 'monthly' | null;
103
+ export type Frequency = "daily" | "weekly" | "monthly" | null;
82
104
  export declare class HydroShareArchive {
83
105
  id: string;
84
106
  thingId: string;
@@ -96,9 +118,9 @@ export declare class PostHydroShareArchive extends HydroShareArchive {
96
118
  constructor();
97
119
  }
98
120
  export declare class Location {
99
- latitude?: number | '';
100
- longitude?: number | '';
101
- elevation_m?: number | '';
121
+ latitude?: number | "";
122
+ longitude?: number | "";
123
+ elevation_m?: number | "";
102
124
  elevationDatum: string;
103
125
  state: string;
104
126
  county: string;
@@ -252,7 +274,7 @@ export declare class User {
252
274
  organization?: Organization | null;
253
275
  type: string;
254
276
  link: string;
255
- accountType: 'admin' | 'standard' | 'limited';
277
+ accountType: "admin" | "standard" | "limited";
256
278
  hydroShareConnected: boolean;
257
279
  constructor();
258
280
  }
@@ -2,4 +2,3 @@ import { EnumDictionary, TimeUnit } from '@/types';
2
2
  export declare const timeUnitMultipliers: EnumDictionary<TimeUnit, number>;
3
3
  export declare const formatDate: (date: Date) => string;
4
4
  export declare const formatDuration: (duration: number) => string;
5
- export declare const shiftDatetime: (datetime: number, amount: number, unit: TimeUnit) => number;
@@ -3,3 +3,4 @@ export * from './ellapsed-time';
3
3
  export * from './notifications';
4
4
  export * from './observations';
5
5
  export * from './plotting/observation-record';
6
+ export * from './plotting/calibration';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Unit tests for the public surface of `calibration.ts`.
3
+ *
4
+ * The module imports `value-threshold.worker?worker&inline` eagerly, which
5
+ * Vite transforms in the app build but not in Vitest + happy-dom — so we
6
+ * substitute the same `MockValueThresholdWorker` used by
7
+ * `observation-record.spec.ts` to give `runBenchmarks()` a working worker
8
+ * constructor. The mock round-trips via `queueMicrotask`, which is enough
9
+ * for `ensureCalibration()` to complete synchronously-ish in tests.
10
+ *
11
+ * Module state (`activeProfile`, `lastBenchmarkDetail`, `listeners`,
12
+ * `localStorage`) lives at import scope, so every test begins with a
13
+ * `clearCalibration()` and a `localStorage.clear()` to avoid cross-
14
+ * pollination.
15
+ */
16
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Coverage-focused tests for `observation-record.ts` that exercise
3
+ * paths the baseline spec skips:
4
+ *
5
+ * 1. **Worker fan-out paths** — every `_operation` routes through
6
+ * `shouldUseWorker()` and falls back to an inline core for small
7
+ * inputs. The existing `observation-record.spec.ts` uses tiny
8
+ * datasets, so only the inline branches run. Here we mock
9
+ * `../calibration` so callers can flip `forceWorker = true` and
10
+ * drive the worker branches without needing multi-MB fixtures.
11
+ * 2. **Bulk assignment ops** — `ASSIGN_VALUES_BULK` and
12
+ * `ASSIGN_DATETIMES_BULK` aren't touched by the baseline spec.
13
+ * 3. **Undo / redo** — `undo()` / `redo()` have their own state
14
+ * machines that aren't driven by the `dispatch()` tests.
15
+ * 4. **DATETIME_RANGE, SELECTION pop** — the remaining filter ops.
16
+ *
17
+ * Mocks are hoisted via `vi.mock`; the real calibration module is
18
+ * wrapped so non-mocked helpers (getCalibration, etc.) still work if
19
+ * anything reaches for them.
20
+ */
21
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Direct unit tests for the pure kernels in `operation-cores.ts`. These
3
+ * functions are the shared source of truth for every `*.worker.ts` with an
4
+ * inline equivalent, so once they pass here the worker wrappers only need a
5
+ * thin "message in / message out" check (see `workers.spec.ts`).
6
+ *
7
+ * Cores are deliberately framework-free and accept plain typed arrays, so
8
+ * these tests build buffers from raw `Float32Array` / `Float64Array` rather
9
+ * than `SharedArrayBuffer`. Semantics are identical and happy-dom doesn't
10
+ * require the cross-origin-isolation headers SAB would.
11
+ */
12
+ export {};
@@ -0,0 +1,119 @@
1
+ /**
2
+ * In-process mock implementations of every worker used by `ObservationRecord`.
3
+ *
4
+ * The real workers are loaded via Vite's `?worker&inline` query, which is not
5
+ * available in Vitest + happy-dom. Each mock here re-implements the logic of
6
+ * the matching `*.worker.ts` file and runs synchronously via `queueMicrotask`,
7
+ * which is enough to exercise every code path in `observation-record.ts`
8
+ * end-to-end. The handler is scheduled via microtask so the caller has a chance
9
+ * to assign `onmessage` before the response is dispatched (matching the real
10
+ * Worker API contract).
11
+ */
12
+ export declare const MockDeleteDataWorker: {
13
+ new (): {
14
+ onmessage: ((event: {
15
+ data: any;
16
+ }) => void) | null;
17
+ postMessage(data: any): void;
18
+ terminate(): void;
19
+ };
20
+ };
21
+ export declare const MockAddDataWorker: {
22
+ new (): {
23
+ onmessage: ((event: {
24
+ data: any;
25
+ }) => void) | null;
26
+ postMessage(data: any): void;
27
+ terminate(): void;
28
+ };
29
+ };
30
+ export declare const MockChangeValuesWorker: {
31
+ new (): {
32
+ onmessage: ((event: {
33
+ data: any;
34
+ }) => void) | null;
35
+ postMessage(data: any): void;
36
+ terminate(): void;
37
+ };
38
+ };
39
+ export declare const MockInterpolateWorker: {
40
+ new (): {
41
+ onmessage: ((event: {
42
+ data: any;
43
+ }) => void) | null;
44
+ postMessage(data: any): void;
45
+ terminate(): void;
46
+ };
47
+ };
48
+ export declare const MockDriftCorrectionWorker: {
49
+ new (): {
50
+ onmessage: ((event: {
51
+ data: any;
52
+ }) => void) | null;
53
+ postMessage(data: any): void;
54
+ terminate(): void;
55
+ };
56
+ };
57
+ export declare const MockShiftDatetimesWorker: {
58
+ new (): {
59
+ onmessage: ((event: {
60
+ data: any;
61
+ }) => void) | null;
62
+ postMessage(data: any): void;
63
+ terminate(): void;
64
+ };
65
+ };
66
+ export declare const MockFillGapsWorker: {
67
+ new (): {
68
+ onmessage: ((event: {
69
+ data: any;
70
+ }) => void) | null;
71
+ postMessage(data: any): void;
72
+ terminate(): void;
73
+ };
74
+ };
75
+ export declare const MockFindGapsWorker: {
76
+ new (): {
77
+ onmessage: ((event: {
78
+ data: any;
79
+ }) => void) | null;
80
+ postMessage(data: any): void;
81
+ terminate(): void;
82
+ };
83
+ };
84
+ export declare const MockPersistenceWorker: {
85
+ new (): {
86
+ onmessage: ((event: {
87
+ data: any;
88
+ }) => void) | null;
89
+ postMessage(data: any): void;
90
+ terminate(): void;
91
+ };
92
+ };
93
+ export declare const MockChangeWorker: {
94
+ new (): {
95
+ onmessage: ((event: {
96
+ data: any;
97
+ }) => void) | null;
98
+ postMessage(data: any): void;
99
+ terminate(): void;
100
+ };
101
+ };
102
+ export declare const MockRateOfChangeWorker: {
103
+ new (): {
104
+ onmessage: ((event: {
105
+ data: any;
106
+ }) => void) | null;
107
+ postMessage(data: any): void;
108
+ terminate(): void;
109
+ };
110
+ };
111
+ export declare const MockValueThresholdWorker: {
112
+ new (): {
113
+ onmessage: ((event: {
114
+ data: any;
115
+ }) => void) | null;
116
+ postMessage(data: any): void;
117
+ terminate(): void;
118
+ };
119
+ };