@luzmo/analytics-components-kit 1.0.1-alpha.50 → 1.0.1-alpha.52
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.
- package/components/display-settings/display-settings.d.ts +1 -0
- package/components/display-settings/index.cjs +1 -1
- package/components/display-settings/index.js +1 -1
- package/components/display-settings-numeric/helpers/constants.d.ts +1 -0
- package/components/display-settings-numeric/index.cjs +16 -10
- package/components/display-settings-numeric/index.js +52 -34
- package/components/draggable-data-item/draggable-data-item.d.ts +0 -1
- package/components/draggable-data-item/index.cjs +5 -8
- package/components/draggable-data-item/index.js +32 -38
- package/components/draggable-data-item-level/draggable-data-item-level.d.ts +1 -1
- package/components/draggable-data-item-level/index.cjs +6 -6
- package/components/draggable-data-item-level/index.js +106 -113
- package/components/droppable-slot/droppable-slot.d.ts +6 -1
- package/components/droppable-slot/index.cjs +14 -12
- package/components/droppable-slot/index.js +186 -160
- package/components/filter-item/index.cjs +1 -1
- package/components/filter-item/index.js +1 -1
- package/components/filter-value-picker-hierarchy/index.cjs +1 -1
- package/components/filter-value-picker-hierarchy/index.js +1 -1
- package/components/filter-value-picker-numeric/index.cjs +1 -1
- package/components/filter-value-picker-numeric/index.js +1 -1
- package/components/{index-DAoFunRy.cjs → index-3X8Iuo7y.cjs} +11 -11
- package/components/{index-Delpl7qa.js → index-Cyo2hwg7.js} +1 -1
- package/components/{index-eBsINoH9.cjs → index-DpHum3lw.cjs} +1 -1
- package/components/{index-Ct7UvUif.js → index-fmbD10nN.js} +123 -109
- package/components/index.cjs +1 -1
- package/components/index.js +1 -1
- package/components/slot-contents-picker/index.cjs +1 -1
- package/components/slot-contents-picker/index.js +1 -1
- package/components/slot-menu/index.cjs +11 -11
- package/components/slot-menu/index.js +186 -171
- package/components/slot-menu/slot-menu.d.ts +5 -1
- package/components/slot-menu-list/index.cjs +1 -1
- package/components/slot-menu-list/index.js +19 -16
- package/components/slot-menu-list/slot-menu-list.d.ts +1 -0
- package/custom-elements.json +29 -43
- package/item-definitions/box-plot/box-plot-options.config.d.ts +1 -1
- package/item-definitions/choropleth-map/choropleth-map-options.config.d.ts +1 -1
- package/item-definitions/hexbin-map/hexbin-map-options.config.d.ts +1 -1
- package/item-definitions/route-map/route-map-options.config.d.ts +1 -1
- package/item-definitions/spike-map/spike-map-options.config.d.ts +1 -1
- package/package.json +1 -1
- package/utils/data-broker/index.d.ts +1 -1
@@ -17,7 +17,7 @@
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
18
|
* SOFTWARE.
|
19
19
|
* */
|
20
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-1oIrlkAr.cjs");require("../index-cHKqEi5-.cjs");const u=require("../property-Cu4Q1hS4.cjs"),_=require("../set-locale-DCPlazsZ.cjs"),$=require("../localized-decorator-DIXYZ3RL.cjs"),L=require("../base-D76d76ww-tT6yr8eb.cjs");require("../focusable-BxtpnzWp-CkK9AeMt.cjs");const z=require("../index-
|
20
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-1oIrlkAr.cjs");require("../index-cHKqEi5-.cjs");const u=require("../property-Cu4Q1hS4.cjs"),_=require("../set-locale-DCPlazsZ.cjs"),$=require("../localized-decorator-DIXYZ3RL.cjs"),L=require("../base-D76d76ww-tT6yr8eb.cjs");require("../focusable-BxtpnzWp-CkK9AeMt.cjs");const z=require("../index-DpHum3lw.cjs"),k=require("../localize-r7ALOUy_.cjs"),y=require("../state-fyl3IYMu.cjs"),T=".missing-value{opacity:.4}:host{--var: blue}";var x=Object.defineProperty,F=Object.getOwnPropertyDescriptor,h=(b,e,r,t)=>{for(var i=t>1?void 0:t?F(e,r):e,l=b.length-1,n;l>=0;l--)(n=b[l])&&(i=(t?n(e,r,i):n(i))||i);return t&&i&&x(e,r,i),i};const H=5e3;exports.LuzmoFilterValuePickerHierarchy=class extends L.m(L.It,{validSizes:Object.values(L.d$1)}){constructor(){super(...arguments),this.language="en",this.contentLanguage="en",this._hierarchyValues=[],this._retrieving=!0,this._search="",this._error=null,this._allValuesRetrieved=!1,this._runningQueries=[]}static get styles(){return[u.r(T)]}connectedCallback(){super.connectedCallback();const e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),this.authKey&&this.authToken&&(e.authKey=this.authKey,e.authToken=this.authToken),z.dataBroker.configure(e)}willUpdate(e){var t,i,l,n,m,d,o,f,g,p,s,a,c,V;if(e.has("language")&&this.language!==_.getLocale()&&([..._.targetLocales].includes(this.language??"en")||this.language==="en")&&_.setLocale(this.language),e.has("filter")&&this.filter){const v=(t=e.get("filter"))==null?void 0:t.expression,P=((n=(l=(i=e.get("filter"))==null?void 0:i.parameters)==null?void 0:l[0])==null?void 0:n.columnId)||((o=(d=(m=e.get("filter"))==null?void 0:m.parameters)==null?void 0:d[0])==null?void 0:o.formulaId),S=((p=(g=(f=this.filter)==null?void 0:f.parameters)==null?void 0:g[0])==null?void 0:p.columnId)||((c=(a=(s=this.filter)==null?void 0:s.parameters)==null?void 0:a[0])==null?void 0:c.formulaId);P!==S&&(["? in ?","? not in ?","? = ?","? != ?"].includes((V=this.filter)==null?void 0:V.expression)||!["? in ?","? not in ?","? = ?","? != ?"].includes(v))&&(this._hierarchyValues=[],this._allValuesRetrieved=!1,this._retrieving=!0)}}async _fetchHierarchyValues(e=0){var g,p;if(this._allValuesRetrieved){this._retrieving=!1;return}if(!((p=(g=this.filter)==null?void 0:g.parameters)!=null&&p[0])){this._retrieving=!1,this._error="Missing column parameters";return}const r=this.filter.parameters[0],t=r.columnId,i=r.formulaId,l=r.datasetId;if(!t&&!i){this._retrieving=!1,this._error="Missing column id or formula id";return}else if(!l){this._retrieving=!1,this._error="Missing dataset id";return}this._retrieving=!0,this._error=null;const n={expression:"? like ?",parameters:[{column_id:t,formula_id:i,dataset_id:l},this._search]},m={dimensions:[{column_id:t,formula_id:i,dataset_id:l}],where:[],order:[{column_id:t,formula_id:i,dataset_id:l,order:"asc"}],limit:{by:H,offset:e}};this._search&&this._allValuesRetrieved&&m.where.push(n);const d=new AbortController,o=new Promise((s,a)=>{z.dataBroker.fetchData(m).then(s).catch(a),d.signal.addEventListener("abort",()=>{console.warn("Request aborted"),a({status:"aborted"})})}),f={promise:o,abortController:d};this._runningQueries.push(f);try{const s=await o,a=s&&Array.isArray(s.data)?s.data.map(c=>c[0]):[];this._search||(this._allValuesRetrieved=a.length<H),this._hierarchyValues=e>0?[...this._hierarchyValues,...a]:a}catch(s){if((s==null?void 0:s.status)==="aborted")return;this._error=s instanceof Error?s.message:"Unknown error",this._hierarchyValues=[]}finally{this._runningQueries=this._runningQueries.filter(s=>s.promise!==o),this._retrieving=!1}}_sendChangeEvent(){this.dispatchEvent(new CustomEvent("filter-value-changed",{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setHierarchy(e){var t,i,l,n,m,d,o,f;let r;["? in ?","? not in ?"].includes((t=this.filter)==null?void 0:t.expression)?r=(i=e==null?void 0:e.detail)==null?void 0:i.value:["? = ?","? != ?"].includes((l=this.filter)==null?void 0:l.expression)?r=(m=(n=e==null?void 0:e.detail)==null?void 0:n.value)==null?void 0:m[0]:r=(d=e==null?void 0:e.target)==null?void 0:d.value,this._value!==r&&(this._value=r,this.filter={...this.filter,parameters:[{...(f=(o=this.filter)==null?void 0:o.parameters)==null?void 0:f[0]},this._value]},this._sendChangeEvent())}onScrolled(e){var r;!this._retrieving&&!this._allValuesRetrieved&&((r=e==null?void 0:e.detail)==null?void 0:r.last)===this._hierarchyValues.length-1&&this._fetchHierarchyValues(this._hierarchyValues.length)}renderTextField(){var e,r;return u.x`<luzmo-text-field
|
21
21
|
.size=${this.size}
|
22
22
|
@change=${this.setHierarchy}
|
23
23
|
@input=${this.setHierarchy}
|
@@ -24,7 +24,7 @@ import { g as C, t as I, s as E, m as b } from "../set-locale-GI34z_M7.js";
|
|
24
24
|
import { l as H } from "../localized-decorator-Bl5gcI6n.js";
|
25
25
|
import { m as R, b as O, I as D } from "../base-D76d76ww-BGkuhs54.js";
|
26
26
|
import "../focusable-BxtpnzWp-DJQkL8Zv.js";
|
27
|
-
import { d as v } from "../index-
|
27
|
+
import { d as v } from "../index-Cyo2hwg7.js";
|
28
28
|
import { l as w } from "../localize-BX7q0S0M.js";
|
29
29
|
import { r as _ } from "../state-nDsQPund.js";
|
30
30
|
const $ = () => {
|
@@ -17,7 +17,7 @@
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
18
|
* SOFTWARE.
|
19
19
|
* */
|
20
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-MPM_B4re.cjs");require("../index-1oIrlkAr.cjs");const c=require("../property-Cu4Q1hS4.cjs"),d=require("../set-locale-DCPlazsZ.cjs"),F=require("../localized-decorator-DIXYZ3RL.cjs"),v=require("../base-D76d76ww-tT6yr8eb.cjs");require("../focusable-BxtpnzWp-CkK9AeMt.cjs");const z=require("../index-
|
20
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../index-MPM_B4re.cjs");require("../index-1oIrlkAr.cjs");const c=require("../property-Cu4Q1hS4.cjs"),d=require("../set-locale-DCPlazsZ.cjs"),F=require("../localized-decorator-DIXYZ3RL.cjs"),v=require("../base-D76d76ww-tT6yr8eb.cjs");require("../focusable-BxtpnzWp-CkK9AeMt.cjs");const z=require("../index-DpHum3lw.cjs"),b=require("../state-fyl3IYMu.cjs"),T=".missing-value{opacity:.4}:host{--var: blue}";var I=Object.defineProperty,w=Object.getOwnPropertyDescriptor,n=(V,e,t,r)=>{for(var i=r>1?void 0:r?w(e,t):e,s=V.length-1,a;s>=0;s--)(a=V[s])&&(i=(r?a(e,t,i):a(i))||i);return r&&i&&I(e,t,i),i};const k=5e3;exports.LuzmoFilterValuePickerNumeric=class extends v.m(v.It,{validSizes:Object.values(v.d$1)}){constructor(){super(...arguments),this.language="en",this.contentLanguage="en",this._numericValues=[],this._retrieving=!0,this._search="",this._error=null,this._allValuesRetrieved=!1,this._runningQueries=[]}static get styles(){return[c.r(T)]}connectedCallback(){super.connectedCallback();const e={};this.apiUrl&&(e.apiUrl=this.apiUrl),this.cacheTime&&(e.staleTime=this.cacheTime,e.gcTime=this.cacheTime*2),this.authKey&&this.authToken&&(e.authKey=this.authKey,e.authToken=this.authToken),z.dataBroker.configure(e)}willUpdate(e){var i,s,a,u,m,o,_,p,f,l,h,g,L,y;const t=e.has("filter");if(e.has("language")&&this.language!==d.getLocale()&&([...d.targetLocales].includes(this.language??"en")||this.language==="en")&&d.setLocale(this.language),t&&this.filter){const N=(i=e.get("filter"))==null?void 0:i.expression,S=(s=this.filter)==null?void 0:s.expression,P=((m=(u=(a=e.get("filter"))==null?void 0:a.parameters)==null?void 0:u[0])==null?void 0:m.columnId)||((p=(_=(o=e.get("filter"))==null?void 0:o.parameters)==null?void 0:_[0])==null?void 0:p.formulaId),$=((h=(l=(f=this.filter)==null?void 0:f.parameters)==null?void 0:l[0])==null?void 0:h.columnId)||((y=(L=(g=this.filter)==null?void 0:g.parameters)==null?void 0:L[0])==null?void 0:y.formulaId);(P!==$||!["? in ?","? not in ?"].includes(N))&&["? in ?","? not in ?"].includes(S)&&(this._numericValues=[],this._allValuesRetrieved=!1,this._retrieving=!0)}}async _fetchNumericValues(e=0){var p,f;if(this._allValuesRetrieved){this._retrieving=!1;return}if(!((f=(p=this.filter)==null?void 0:p.parameters)!=null&&f[0])){this._retrieving=!1,this._error="Missing column parameters";return}const t=this.filter.parameters[0],r=t.columnId,i=t.formulaId,s=t.datasetId;if(!r&&!i){this._retrieving=!1,this._error="Missing column id or formula id";return}else if(!s){this._retrieving=!1,this._error="Missing dataset id";return}this._retrieving=!0,this._error=null;const a={expression:"? like ?",parameters:[{dataset_id:s,expression:`CAST({${s}:${r??i}},hierarchy)`},this._search]},u={dimensions:[{column_id:r,formula_id:i,dataset_id:s}],where:[],order:[{column_id:r,formula_id:i,dataset_id:s,order:"asc"}],limit:{by:k,offset:e}};this._search&&!this._allValuesRetrieved&&u.where.push(a);const m=new AbortController,o=new Promise((l,h)=>{z.dataBroker.fetchData(u).then(l).catch(h),m.signal.addEventListener("abort",()=>{console.warn("Request aborted"),h({status:"aborted"})})}),_={promise:o,abortController:m};this._runningQueries.push(_);try{const l=await o,h=l&&Array.isArray(l.data)?l.data.map(g=>g[0]):[];this._search||(this._allValuesRetrieved=h.length<k),this._numericValues=e>0?[...this._numericValues,...h]:h}catch(l){if((l==null?void 0:l.status)==="aborted")return;this._error=l instanceof Error?l.message:"Unknown error",this._numericValues=[]}finally{this._runningQueries=this._runningQueries.filter(l=>l.promise!==o),this._retrieving=!1}}_sendChangeEvent(){this.dispatchEvent(new CustomEvent("filter-value-changed",{bubbles:!0,composed:!0,cancelable:!0,detail:{value:this._value}}))}setValue(e){var r,i,s,a,u;const t=["? in ?","? not in ?"].includes((r=this.filter)==null?void 0:r.expression)?(i=e==null?void 0:e.detail)==null?void 0:i.value:(s=e==null?void 0:e.target)==null?void 0:s.value;this._value!==t&&(this._value=t,this.filter={...this.filter,parameters:[{...(u=(a=this.filter)==null?void 0:a.parameters)==null?void 0:u[0]},t]},this._sendChangeEvent())}selectValue(e){var i,s,a;const r=(((i=e.detail)==null?void 0:i.value)??"").map(u=>Number.parseFloat(u));this.filter={...this.filter,parameters:[{...(a=(s=this.filter)==null?void 0:s.parameters)==null?void 0:a[0]},r]},this._value=r,this._sendChangeEvent()}onScrolled(e){var t;!this._retrieving&&!this._allValuesRetrieved&&((t=e==null?void 0:e.detail)==null?void 0:t.last)===this._numericValues.length-1&&this._fetchNumericValues(this._numericValues.length)}renderNumberField(){var e,t;return c.x`<luzmo-number-field
|
21
21
|
.size=${this.size}
|
22
22
|
@change=${this.setValue}
|
23
23
|
@input=${this.setValue}
|
@@ -24,7 +24,7 @@ import { g as T, t as E, s as N, m as z } from "../set-locale-GI34z_M7.js";
|
|
24
24
|
import { l as R } from "../localized-decorator-Bl5gcI6n.js";
|
25
25
|
import { m as O, b as D, I as Q } from "../base-D76d76ww-BGkuhs54.js";
|
26
26
|
import "../focusable-BxtpnzWp-DJQkL8Zv.js";
|
27
|
-
import { d as V } from "../index-
|
27
|
+
import { d as V } from "../index-Cyo2hwg7.js";
|
28
28
|
import { r as _ } from "../state-nDsQPund.js";
|
29
29
|
const C = () => {
|
30
30
|
if (typeof document < "u" && !document.querySelector("style[data-luzmo-vars]")) {
|
@@ -17,25 +17,25 @@
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
18
|
* SOFTWARE.
|
19
19
|
* */
|
20
|
-
"use strict";const c=require("./property-Cu4Q1hS4.cjs"),
|
20
|
+
"use strict";const c=require("./property-Cu4Q1hS4.cjs"),le=require("./task-CwmAXlv0.cjs");require("./index-DtohCwyO.cjs");require("./index-j8UKjHqY.cjs");require("./index-DSQyBS9Z.cjs");require("./index-Tx5oQjbt.cjs");require("./index-BKwbYw6x.cjs");require("./index-cHKqEi5-.cjs");require("./index-CYeQkVeJ.cjs");const ue=require("./state-fyl3IYMu.cjs"),ce=require("./query-D5qWDopr.cjs"),T=require("./luzmo-icons-DonyjSXg.cjs"),de=require("./focusable-DAGGGYyz.cjs"),V=require("./sized-mixin-j_7aJM4b.cjs");var pe=Object.defineProperty,he=(e,t,s)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,q=(e,t,s)=>(he(e,typeof t!="symbol"?t+"":t,s),s),me=(e,t,s)=>{if(!t.has(e))throw TypeError("Cannot "+s)},P=(e,t)=>{if(Object(t)!==t)throw TypeError('Cannot use the "in" operator on this value');return e.has(t)},N=(e,t,s)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,s)},B=(e,t,s)=>(me(e,t,"access private method"),s);/**
|
21
21
|
* @license
|
22
22
|
* Copyright Google LLC All Rights Reserved.
|
23
23
|
*
|
24
24
|
* Use of this source code is governed by an MIT-style license that can be
|
25
25
|
* found in the LICENSE file at https://angular.io/license
|
26
|
-
*/function
|
26
|
+
*/function G(e,t){return Object.is(e,t)}/**
|
27
27
|
* @license
|
28
28
|
* Copyright Google LLC All Rights Reserved.
|
29
29
|
*
|
30
30
|
* Use of this source code is governed by an MIT-style license that can be
|
31
31
|
* found in the LICENSE file at https://angular.io/license
|
32
|
-
*/let u=null,x=!1,E=1;const I=Symbol("SIGNAL");function _(e){const t=u;return u=e,t}function ge(){return u}function ve(){return x}const A={version:0,lastCleanEpoch:0,dirty:!1,producerNode:void 0,producerLastReadVersion:void 0,producerIndexOfThis:void 0,nextProducerIndex:0,liveConsumerNode:void 0,liveConsumerIndexOfThis:void 0,consumerAllowSignalWrites:!1,consumerIsAlwaysLive:!1,producerMustRecompute:()=>!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{}};function O(e){if(x)throw new Error(typeof ngDevMode<"u"&&ngDevMode?"Assertion error: signal read during notification phase":"");if(u===null)return;u.consumerOnSignalRead(e);const t=u.nextProducerIndex++;if(S(u),t<u.producerNode.length&&u.producerNode[t]!==e&&D(u)){const s=u.producerNode[t];k(s,u.producerIndexOfThis[t])}u.producerNode[t]!==e&&(u.producerNode[t]=e,u.producerIndexOfThis[t]=D(u)?
|
32
|
+
*/let u=null,x=!1,E=1;const I=Symbol("SIGNAL");function _(e){const t=u;return u=e,t}function ge(){return u}function ve(){return x}const A={version:0,lastCleanEpoch:0,dirty:!1,producerNode:void 0,producerLastReadVersion:void 0,producerIndexOfThis:void 0,nextProducerIndex:0,liveConsumerNode:void 0,liveConsumerIndexOfThis:void 0,consumerAllowSignalWrites:!1,consumerIsAlwaysLive:!1,producerMustRecompute:()=>!1,producerRecomputeValue:()=>{},consumerMarkedDirty:()=>{},consumerOnSignalRead:()=>{}};function O(e){if(x)throw new Error(typeof ngDevMode<"u"&&ngDevMode?"Assertion error: signal read during notification phase":"");if(u===null)return;u.consumerOnSignalRead(e);const t=u.nextProducerIndex++;if(S(u),t<u.producerNode.length&&u.producerNode[t]!==e&&D(u)){const s=u.producerNode[t];k(s,u.producerIndexOfThis[t])}u.producerNode[t]!==e&&(u.producerNode[t]=e,u.producerIndexOfThis[t]=D(u)?K(e,u,t):0),u.producerLastReadVersion[t]=e.version}function fe(){E++}function H(e){if(!(!e.dirty&&e.lastCleanEpoch===E)){if(!e.producerMustRecompute(e)&&!we(e)){e.dirty=!1,e.lastCleanEpoch=E;return}e.producerRecomputeValue(e),e.dirty=!1,e.lastCleanEpoch=E}}function J(e){if(e.liveConsumerNode===void 0)return;const t=x;x=!0;try{for(const s of e.liveConsumerNode)s.dirty||be(s)}finally{x=t}}function ye(){return(u==null?void 0:u.consumerAllowSignalWrites)!==!1}function be(e){var t;e.dirty=!0,J(e),(t=e.consumerMarkedDirty)==null||t.call(e.wrapper??e)}function ze(e){return e&&(e.nextProducerIndex=0),_(e)}function Ce(e,t){if(_(t),!(!e||e.producerNode===void 0||e.producerIndexOfThis===void 0||e.producerLastReadVersion===void 0)){if(D(e))for(let s=e.nextProducerIndex;s<e.producerNode.length;s++)k(e.producerNode[s],e.producerIndexOfThis[s]);for(;e.producerNode.length>e.nextProducerIndex;)e.producerNode.pop(),e.producerLastReadVersion.pop(),e.producerIndexOfThis.pop()}}function we(e){S(e);for(let t=0;t<e.producerNode.length;t++){const s=e.producerNode[t],o=e.producerLastReadVersion[t];if(o!==s.version||(H(s),o!==s.version))return!0}return!1}function K(e,t,s){var o;if(U(e),S(e),e.liveConsumerNode.length===0){(o=e.watched)==null||o.call(e.wrapper);for(let r=0;r<e.producerNode.length;r++)e.producerIndexOfThis[r]=K(e.producerNode[r],e,r)}return e.liveConsumerIndexOfThis.push(s),e.liveConsumerNode.push(t)-1}function k(e,t){var s;if(U(e),S(e),typeof ngDevMode<"u"&&ngDevMode&&t>=e.liveConsumerNode.length)throw new Error(`Assertion error: active consumer index ${t} is out of bounds of ${e.liveConsumerNode.length} consumers)`);if(e.liveConsumerNode.length===1){(s=e.unwatched)==null||s.call(e.wrapper);for(let r=0;r<e.producerNode.length;r++)k(e.producerNode[r],e.producerIndexOfThis[r])}const o=e.liveConsumerNode.length-1;if(e.liveConsumerNode[t]=e.liveConsumerNode[o],e.liveConsumerIndexOfThis[t]=e.liveConsumerIndexOfThis[o],e.liveConsumerNode.length--,e.liveConsumerIndexOfThis.length--,t<e.liveConsumerNode.length){const r=e.liveConsumerIndexOfThis[t],n=e.liveConsumerNode[t];S(n),n.producerIndexOfThis[r]=t}}function D(e){var t;return e.consumerIsAlwaysLive||(((t=e==null?void 0:e.liveConsumerNode)==null?void 0:t.length)??0)>0}function S(e){e.producerNode??(e.producerNode=[]),e.producerIndexOfThis??(e.producerIndexOfThis=[]),e.producerLastReadVersion??(e.producerLastReadVersion=[])}function U(e){e.liveConsumerNode??(e.liveConsumerNode=[]),e.liveConsumerIndexOfThis??(e.liveConsumerIndexOfThis=[])}/**
|
33
33
|
* @license
|
34
34
|
* Copyright Google LLC All Rights Reserved.
|
35
35
|
*
|
36
36
|
* Use of this source code is governed by an MIT-style license that can be
|
37
37
|
* found in the LICENSE file at https://angular.io/license
|
38
|
-
*/function
|
38
|
+
*/function Q(e){if(H(e),O(e),e.value===R)throw e.error;return e.value}function _e(e){const t=Object.create(Se);t.computation=e;const s=()=>Q(t);return s[I]=t,s}const L=Symbol("UNSET"),W=Symbol("COMPUTING"),R=Symbol("ERRORED"),Se={...A,value:L,dirty:!0,error:null,equal:G,producerMustRecompute(e){return e.value===L||e.value===W},producerRecomputeValue(e){if(e.value===W)throw new Error("Detected cycle in computations.");const t=e.value;e.value=W;const s=ze(e);let o,r=!1;try{o=e.computation.call(e.wrapper),r=t!==L&&t!==R&&e.equal.call(e.wrapper,t,o)}catch(n){o=R,e.error=n}finally{Ce(e,s)}if(r){e.value=t;return}e.value=o,e.version++}};/**
|
39
39
|
* @license
|
40
40
|
* Copyright Google LLC All Rights Reserved.
|
41
41
|
*
|
@@ -47,7 +47,7 @@
|
|
47
47
|
*
|
48
48
|
* Use of this source code is governed by an MIT-style license that can be
|
49
49
|
* found in the LICENSE file at https://angular.io/license
|
50
|
-
*/function Ne(e){const t=Object.create(Oe);t.value=e;const s=()=>(O(t),t.value);return s[I]=t,s}function Ee(){return O(this),this.value}function Ie(e,t){ye()||Te(),e.equal.call(e.wrapper,e.value,t)||(e.value=t,ke(e))}const Oe={...A,equal:
|
50
|
+
*/function Ne(e){const t=Object.create(Oe);t.value=e;const s=()=>(O(t),t.value);return s[I]=t,s}function Ee(){return O(this),this.value}function Ie(e,t){ye()||Te(),e.equal.call(e.wrapper,e.value,t)||(e.value=t,ke(e))}const Oe={...A,equal:G,value:void 0};function ke(e){e.version++,fe(),J(e)}/**
|
51
51
|
* @license
|
52
52
|
* Copyright 2024 Bloomberg Finance L.P.
|
53
53
|
*
|
@@ -62,11 +62,11 @@
|
|
62
62
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
63
63
|
* See the License for the specific language governing permissions and
|
64
64
|
* limitations under the License.
|
65
|
-
*/const p=Symbol("node");var y;(e=>{var t,s,o,r;class
|
65
|
+
*/const p=Symbol("node");var y;(e=>{var t,s,o,r;class n{constructor(z,m={}){N(this,s),q(this,t);const h=Ne(z)[I];if(this[p]=h,h.wrapper=this,m){const C=m.equals;C&&(h.equal=C),h.watched=m[e.subtle.watched],h.unwatched=m[e.subtle.unwatched]}}get(){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.get");return Ee.call(this[p])}set(z){if(!(0,e.isState)(this))throw new TypeError("Wrong receiver type for Signal.State.prototype.set");if(ve())throw new Error("Writes to signals not permitted during Watcher callback");const m=this[p];Ie(m,z)}}t=p,s=new WeakSet,e.isState=d=>typeof d=="object"&&P(s,d),e.State=n;class b{constructor(z,m){N(this,r),q(this,o);const h=_e(z)[I];if(h.consumerAllowSignalWrites=!0,this[p]=h,h.wrapper=this,m){const C=m.equals;C&&(h.equal=C),h.watched=m[e.subtle.watched],h.unwatched=m[e.subtle.unwatched]}}get(){if(!(0,e.isComputed)(this))throw new TypeError("Wrong receiver type for Signal.Computed.prototype.get");return Q(this[p])}}o=p,r=new WeakSet,e.isComputed=d=>typeof d=="object"&&P(r,d),e.Computed=b,(d=>{var z,m,w,h;function C(l){let a,i=null;try{i=_(null),a=l()}finally{_(i)}return a}d.untrack=C;function te(l){var a;if(!(0,e.isComputed)(l)&&!(0,e.isWatcher)(l))throw new TypeError("Called introspectSources without a Computed or Watcher argument");return((a=l[p].producerNode)==null?void 0:a.map(i=>i.wrapper))??[]}d.introspectSources=te;function se(l){var a;if(!(0,e.isComputed)(l)&&!(0,e.isState)(l))throw new TypeError("Called introspectSinks without a Signal argument");return((a=l[p].liveConsumerNode)==null?void 0:a.map(i=>i.wrapper))??[]}d.introspectSinks=se;function re(l){if(!(0,e.isComputed)(l)&&!(0,e.isState)(l))throw new TypeError("Called hasSinks without a Signal argument");const a=l[p].liveConsumerNode;return a?a.length>0:!1}d.hasSinks=re;function ie(l){if(!(0,e.isComputed)(l)&&!(0,e.isWatcher)(l))throw new TypeError("Called hasSources without a Computed or Watcher argument");const a=l[p].producerNode;return a?a.length>0:!1}d.hasSources=ie;class oe{constructor(a){N(this,m),N(this,w),q(this,z);let i=Object.create(A);i.wrapper=this,i.consumerMarkedDirty=a,i.consumerIsAlwaysLive=!0,i.consumerAllowSignalWrites=!1,i.producerNode=[],this[p]=i}watch(...a){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");B(this,w,h).call(this,a);const i=this[p];i.dirty=!1;const v=_(i);for(const $ of a)O($[p]);_(v)}unwatch(...a){if(!(0,e.isWatcher)(this))throw new TypeError("Called unwatch without Watcher receiver");B(this,w,h).call(this,a);const i=this[p];S(i);for(let v=i.producerNode.length-1;v>=0;v--)if(a.includes(i.producerNode[v].wrapper)){k(i.producerNode[v],i.producerIndexOfThis[v]);const $=i.producerNode.length-1;if(i.producerNode[v]=i.producerNode[$],i.producerIndexOfThis[v]=i.producerIndexOfThis[$],i.producerNode.length--,i.producerIndexOfThis.length--,i.nextProducerIndex--,v<i.producerNode.length){const ae=i.producerIndexOfThis[v],M=i.producerNode[v];U(M),M.liveConsumerIndexOfThis[ae]=v}}}getPending(){if(!(0,e.isWatcher)(this))throw new TypeError("Called getPending without Watcher receiver");return this[p].producerNode.filter(i=>i.dirty).map(i=>i.wrapper)}}z=p,m=new WeakSet,w=new WeakSet,h=function(l){for(const a of l)if(!(0,e.isComputed)(a)&&!(0,e.isState)(a))throw new TypeError("Called watch/unwatch without a Computed or State argument")},e.isWatcher=l=>P(m,l),d.Watcher=oe;function ne(){var l;return(l=ge())==null?void 0:l.wrapper}d.currentComputed=ne,d.watched=Symbol("watched"),d.unwatched=Symbol("unwatched")})(e.subtle||(e.subtle={}))})(y||(y={}));/**
|
66
66
|
* @license
|
67
67
|
* Copyright 2023 Google LLC
|
68
68
|
* SPDX-License-Identifier: BSD-3-Clause
|
69
|
-
*/const qe=Symbol("SignalWatcherBrand"),Pe=new FinalizationRegistry(({watcher:e,signal:t})=>{e.unwatch(t)}),F=new WeakMap;function
|
69
|
+
*/const qe=Symbol("SignalWatcherBrand"),Pe=new FinalizationRegistry(({watcher:e,signal:t})=>{e.unwatch(t)}),F=new WeakMap;function X(e){return e[qe]===!0?(console.warn("SignalWatcher should not be applied to the same class more than once."),e):class extends e{constructor(){super(...arguments),this._$St=new y.State(0),this._$Si=!1,this._$So=!0,this._$Sh=new Set}_$Sl(){if(this._$Su!==void 0)return;this._$Sv=new y.Computed(()=>{this._$St.get(),super.performUpdate()});const t=this._$Su=new y.subtle.Watcher(function(){const s=F.get(this);s!==void 0&&(s._$Si===!1&&s.requestUpdate(),this.watch())});F.set(t,this),Pe.register(this,{watcher:t,signal:this._$Sv}),t.watch(this._$Sv)}_$Sp(){this._$Su!==void 0&&(this._$Su.unwatch(this._$Sv),this._$Sv=void 0,this._$Su=void 0)}performUpdate(){this.isUpdatePending&&(this._$Sl(),this._$Si=!0,this._$St.set(this._$St.get()+1),this._$Si=!1,this._$Sv.get())}update(t){try{this._$So?(this._$So=!1,super.update(t)):this._$Sh.forEach(s=>s.commit())}finally{this.isUpdatePending=!1,this._$Sh.clear()}}requestUpdate(t,s,o){this._$So=!0,super.requestUpdate(t,s,o)}connectedCallback(){super.connectedCallback(),this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),queueMicrotask(()=>{this.isConnected===!1&&this._$Sp()})}_(t){this._$Sh.add(t);const s=this._$So;this.requestUpdate(),this._$So=s}m(t){this._$Sh.delete(t)}}}/**
|
70
70
|
* @license
|
71
71
|
* Copyright 2023 Google LLC
|
72
72
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -74,7 +74,7 @@
|
|
74
74
|
* @license
|
75
75
|
* Copyright 2021 Google LLC
|
76
76
|
* SPDX-License-Identifier: BSD-3-Clause
|
77
|
-
*/let
|
77
|
+
*/let Y=class extends Event{constructor(t,s,o,r){super("context-request",{bubbles:!0,composed:!0}),this.context=t,this.contextTarget=s,this.callback=o,this.subscribe=r??!1}};/**
|
78
78
|
* @license
|
79
79
|
* Copyright 2021 Google LLC
|
80
80
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -82,11 +82,11 @@
|
|
82
82
|
* @license
|
83
83
|
* Copyright 2021 Google LLC
|
84
84
|
* SPDX-License-Identifier: BSD-3-Clause
|
85
|
-
*/class j{constructor(t,s,o,r){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(
|
85
|
+
*/class j{constructor(t,s,o,r){if(this.subscribe=!1,this.provided=!1,this.value=void 0,this.t=(n,b)=>{this.unsubscribe&&(this.unsubscribe!==b&&(this.provided=!1,this.unsubscribe()),this.subscribe||this.unsubscribe()),this.value=n,this.host.requestUpdate(),this.provided&&!this.subscribe||(this.provided=!0,this.callback&&this.callback(n,b)),this.unsubscribe=b},this.host=t,s.context!==void 0){const n=s;this.context=n.context,this.callback=n.callback,this.subscribe=n.subscribe??!1}else this.context=s,this.callback=o,this.subscribe=r??!1;this.host.addController(this)}hostConnected(){this.dispatchRequest()}hostDisconnected(){this.unsubscribe&&(this.unsubscribe(),this.unsubscribe=void 0)}dispatchRequest(){this.host.dispatchEvent(new Y(this.context,this.host,this.t,this.subscribe))}}/**
|
86
86
|
* @license
|
87
87
|
* Copyright 2022 Google LLC
|
88
88
|
* SPDX-License-Identifier: BSD-3-Clause
|
89
|
-
*/function
|
89
|
+
*/function Z({context:e,subscribe:t}){return(s,o)=>{typeof o=="object"?o.addInitializer(function(){new j(this,{context:e,callback:r=>{s.set.call(this,r)},subscribe:t})}):s.constructor.addInitializer(r=>{new j(r,{context:e,callback:n=>{r[o]=n},subscribe:t})})}}const ee=Symbol("slot-store-context"),De=":host{font-family:var(--luzmo-display-settings-font-family, var(--luzmo-font-family));font-size:var(--luzmo-display-settings-font-size, var(--display-settings-font-size));color:var(--luzmo-display-settings-font-color, var(--luzmo-font-color))}.settings-container{display:flex;flex-direction:column;gap:var(--luzmo-spacing-2)}.settings-row{display:flex;justify-content:flex-start;align-items:center;gap:var(--luzmo-display-settings-gap, var(--display-settings-gap))}luzmo-divider{margin:var(--luzmo-display-settings-ids-container-vertical-margin, var(--display-settings-ids-container-vertical-margin)) 0}.setting{display:flex;align-items:center}.label-action-container{display:flex;align-items:center;justify-content:space-between;gap:var(--luzmo-display-settings-info-to-remove-icon-gap, var(--display-settings-info-to-remove-icon-gap))}.id-button,.remove-button{outline:none;cursor:pointer;border:none;background:none;font-size:var(--luzmo-display-settings-font-size, var(--display-settings-font-size));color:var(--luzmo-display-settings-font-color, var(--luzmo-font-color))}.remove-button{display:block;width:var(--luzmo-display-settings-remove-button-size, var(--display-settings-remove-button-size));height:var(--luzmo-display-settings-remove-button-size, var(--display-settings-remove-button-size));border-radius:var(--luzmo-display-settings-remove-button-border-radius, 50%)}.remove-button:hover{background-color:var(--luzmo-display-settings-remove-button-background-color-hover, var(--luzmo-background-color-hover))}.remove-button:active,.remove-button:focus{background-color:var(--luzmo-display-settings-remove-button-background-color-down, var(--luzmo-background-color-down))}.remove-button:focus-visible{box-shadow:0 0 0 var(--luzmo-display-settings-remove-button-indicator-thickness, var(--display-settings-remove-button-indicator-thickness)) var(--highcontrast-remove-button-indicator-color, var(--luzmo-display-settings-remove-button-indicator-color, var(--display-settings-remove-button-indicator-color)))}.ids-container{display:flex;flex-direction:column;gap:var(--luzmo-display-settings-gap, var(--display-settings-gap));border-radius:50%}.id-label{text-transform:var(--luzmo-display-settings-id-label-text-transform, var(--display-settings-id-label-text-transform));font-size:var(--luzmo-display-settings-id-label-font-size, var(--display-settings-id-label-font-size));color:var(--luzmo-display-settings-id-label-color, var(--display-settings-id-label-color))}:host{--display-settings-font-family: var(--luzmo-font-family);--display-settings-id-label-text-transform: uppercase;--display-settings-id-label-color: var(--luzmo-secondary);--display-settings-remove-button-indicator-color: var(--luzmo-primary);--display-settings-remove-button-indicator-thickness: var( --luzmo-border-width )}:host{--display-settings-font-size: var(--luzmo-font-size);--display-settings-id-label-font-size: var(--luzmo-font-size-s);--display-settings-gap: var(--luzmo-spacing-3);--display-settings-ids-container-vertical-margin: var(--luzmo-spacing-4);--display-settings-info-to-remove-icon-gap: var(--luzmo-spacing-5);--display-settings-remove-button-size: var(--luzmo-component-height)}:host([size=s]){--display-settings-id-label-font-size: var(--luzmo-font-size-s);--display-settings-font-size: var(--luzmo-font-size-s);--display-settings-gap: var(--luzmo-spacing-3);--display-settings-ids-container-vertical-margin: var(--luzmo-spacing-3);--display-settings-info-to-remove-icon-gap: var(--luzmo-spacing-4);--display-settings-remove-button-size: var(--luzmo-component-height-s)}:host([size=l]){--display-settings-id-label-font-size: var(--luzmo-font-size);--display-settings-font-size: var(--luzmo-font-size-l);--display-settings-gap: var(--luzmo-spacing-4);--display-settings-ids-container-vertical-margin: var(--luzmo-spacing-5);--display-settings-info-to-remove-icon-gap: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-1) );--display-settings-remove-button-size: var(--luzmo-component-height-l)}:host([size=xl]){--display-settings-id-label-font-size: var(--luzmo-font-size-l);--display-settings-font-size: var(--luzmo-font-size-xl);--display-settings-gap: var(--luzmo-spacing-5);--display-settings-ids-container-vertical-margin: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-1) );--display-settings-info-to-remove-icon-gap: calc( var(--luzmo-spacing-5) + var(--luzmo-spacing-2) );--display-settings-remove-button-size: var(--luzmo-component-height-xl)}";var Re=Object.defineProperty,f=(e,t,s,o)=>{for(var r=void 0,n=e.length-1,b;n>=0;n--)(b=e[n])&&(r=b(t,s,r)||r);return r&&Re(t,s,r),r};class g extends X(V.SizedMixin(de.LuzmoElement,{validSizes:Object.values(V.ElementSizes)})){constructor(){super(...arguments),this._loadDisplaySettings=new le.h(this,{task:async([t,s,o,r])=>{const n=[];this.grandTotals&&n.push("grandTotals"),r&&n.push("periodOverPeriod"),(s==="numeric"||s==="mixed"&&(t==null?void 0:t.type)==="numeric")&&n.push("numeric"),s!=="numeric"&&(t==null?void 0:t.type)==="datetime"&&n.push("datetime"),!["numeric","mixed"].includes(s??"")&&(t==null?void 0:t.type)==="numeric"&&!this.binningDisabled&&n.push("binning"),n.length>0&&!o&&(n.includes("numeric")&&!this._settingsTypeLoaded.numeric?(await Promise.resolve().then(()=>require("./display-settings-numeric/index.cjs")),this._settingsTypeLoaded.numeric=!0,n.includes("periodOverPeriod")&&!this._settingsTypeLoaded.periodOverPeriod&&(await Promise.resolve().then(()=>require("./display-settings-period-over-period/index.cjs")),this._settingsTypeLoaded.periodOverPeriod=!0)):n.includes("datetime")&&!this._settingsTypeLoaded.datetime?(await Promise.resolve().then(()=>require("./display-settings-datetime/index.cjs")),this._settingsTypeLoaded.datetime=!0):n.includes("binning")&&!this._settingsTypeLoaded.binning?(await Promise.resolve().then(()=>require("./display-settings-binning/index.cjs")),this._settingsTypeLoaded.binning=!0):n.includes("grandTotals")&&!this._settingsTypeLoaded.grandTotals&&(await Promise.resolve().then(()=>require("./display-settings-grand-totals/index.cjs")),this._settingsTypeLoaded.grandTotals=!0))},args:()=>[this.slotContent,this.slotType,this.hideDisplaySettings,this.periodOverPeriod]}),this.language="en",this.contentLanguage="en",this.slotType="numeric",this.slotContent={},this._showIds=!1,this.measureColumns=[],this._settingsTypeLoaded={binning:!1,datetime:!1,numeric:!1,grandTotals:!1,periodOverPeriod:!1,hierarchy:!0},this._currentSlotContent={}}static get styles(){return[c.r(De)]}willUpdate(){var s,o;const t=(s=this._store)==null?void 0:s.activeSlotContents.get();this.periodOverPeriod=(o=this._store)==null?void 0:o.periodOverPeriodEnabled.get(),t&&t!==this._currentSlotContent&&(this._currentSlotContent=structuredClone(t))}_onSlotContentChange(t){t.stopPropagation(),t.preventDefault(),this._currentSlotContent=structuredClone(t.detail.slotContent),this._sendEvent(),this.requestUpdate()}_onLabelChange(){this._currentSlotContent=structuredClone(this._currentSlotContent),this._currentSlotContent.label=this._multiLanguageFieldElement.value||{},this._sendEvent(),this.requestUpdate()}_sendEvent(){this.dispatchEvent(new CustomEvent("slot-content-changed",{bubbles:!0,composed:!0,cancelable:!0,detail:{slotContent:{...this._currentSlotContent}}})),this._store&&this._store.updateContent({...this._currentSlotContent})}_removeEvent(){this.dispatchEvent(new CustomEvent("remove-slot-content",{bubbles:!0,composed:!0,cancelable:!0,detail:{slotContent:this._currentSlotContent}}))}_toggleIds(){this._showIds=!this._showIds}_renderDisplaySettings(){return c.x`<div class="settings-container">
|
90
90
|
<div class="settings-row">
|
91
91
|
<div class="setting">
|
92
92
|
<div class="label-container">
|
@@ -171,4 +171,4 @@
|
|
171
171
|
</div>`:""}`}render(){return this._loadDisplaySettings.render({pending:()=>c.x`<luzmo-progress-circle
|
172
172
|
indeterminate
|
173
173
|
.size=${this.size}
|
174
|
-
></luzmo-progress-circle>`,complete:()=>this._renderDisplaySettings(),error:()=>this._renderDisplaySettings()})}}f([c.n({type:String})],g.prototype,"language");f([c.n({type:String,attribute:"content-language"})],g.prototype,"contentLanguage");f([c.n({type:Boolean,attribute:"hide-display-settings"})],g.prototype,"hideDisplaySettings");f([c.n({type:Boolean,attribute:"binning-disabled"})],g.prototype,"binningDisabled");f([c.n({type:Boolean,attribute:"grand-totals"})],g.prototype,"grandTotals");f([
|
174
|
+
></luzmo-progress-circle>`,complete:()=>this._renderDisplaySettings(),error:()=>this._renderDisplaySettings()})}disconnectedCallback(){var t,s,o;(t=super.disconnectedCallback)==null||t.call(this),(o=(s=this._loadDisplaySettings).abort)==null||o.call(s)}}f([c.n({type:String})],g.prototype,"language");f([c.n({type:String,attribute:"content-language"})],g.prototype,"contentLanguage");f([c.n({type:Boolean,attribute:"hide-display-settings"})],g.prototype,"hideDisplaySettings");f([c.n({type:Boolean,attribute:"binning-disabled"})],g.prototype,"binningDisabled");f([c.n({type:Boolean,attribute:"grand-totals"})],g.prototype,"grandTotals");f([c.n({type:Boolean})],g.prototype,"periodOverPeriod");f([c.n({type:Boolean,attribute:"show-remove-button"})],g.prototype,"showRemoveButton");f([c.n({type:String,attribute:"slot-type"})],g.prototype,"slotType");f([c.n()],g.prototype,"slotContent");f([ue.r()],g.prototype,"_showIds");f([c.n({type:Array,reflect:!1})],g.prototype,"measureColumns");f([ce.e("luzmo-multi-language-field")],g.prototype,"_multiLanguageFieldElement");f([Z({context:ee,subscribe:!0})],g.prototype,"_store");customElements.get("luzmo-display-settings")||customElements.define("luzmo-display-settings",g);exports.LuzmoDisplaySettings=g;exports.c=Z;exports.e=X;exports.i=We;exports.r=Le;exports.s=Y;exports.slotContext=ee;
|
@@ -1717,7 +1717,7 @@ class _ {
|
|
1717
1717
|
getAvailableDatasets() {
|
1718
1718
|
return this.availableDatasets;
|
1719
1719
|
}
|
1720
|
-
|
1720
|
+
getLinkedDatasetsIds(e) {
|
1721
1721
|
const t = this.queryClient.getQueryData(["dataset", e]);
|
1722
1722
|
return t ? (t.outgoingJoins ?? []).map((i) => i.securable_id).filter((i) => i && i !== e) : [];
|
1723
1723
|
}
|
@@ -17,4 +17,4 @@
|
|
17
17
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
18
18
|
* SOFTWARE.
|
19
19
|
* */
|
20
|
-
"use strict";var Fe=s=>{throw TypeError(s)};var be=(s,e,t)=>e.has(s)||Fe("Cannot "+t);var r=(s,e,t)=>(be(s,e,"read from private field"),t?t.call(s):e.get(s)),f=(s,e,t)=>e.has(s)?Fe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),o=(s,e,t,i)=>(be(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),P=(s,e,t)=>(be(s,e,"access private method"),t);var pe=(s,e,t,i)=>({set _(n){o(s,e,n,t)},get _(){return r(s,e,i)}});var ge=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(s){return this.listeners.add(s),this.onSubscribe(),()=>{this.listeners.delete(s),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},we=typeof window>"u"||"Deno"in globalThis;function M(){}function _e(s,e){return typeof s=="function"?s(e):s}function ze(s){return typeof s=="number"&&s>=0&&s!==1/0}function We(s,e){return Math.max(s+(e||0)-Date.now(),0)}function Se(s,e){return typeof s=="function"?s(e):s}function Xe(s,e){return typeof s=="function"?s(e):s}function De(s,e){const{type:t="all",exact:i,fetchStatus:n,predicate:u,queryKey:h,stale:a}=s;if(h){if(i){if(e.queryHash!==Ce(h,e.options))return!1}else if(!ce(e.queryKey,h))return!1}if(t!=="all"){const l=e.isActive();if(t==="active"&&!l||t==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||n&&n!==e.state.fetchStatus||u&&!u(e))}function Ae(s,e){const{exact:t,status:i,predicate:n,mutationKey:u}=s;if(u){if(!e.options.mutationKey)return!1;if(t){if(oe(e.options.mutationKey)!==oe(u))return!1}else if(!ce(e.options.mutationKey,u))return!1}return!(i&&e.state.status!==i||n&&!n(e))}function Ce(s,e){return((e==null?void 0:e.queryKeyHashFn)||oe)(s)}function oe(s){return JSON.stringify(s,(e,t)=>qe(t)?Object.keys(t).sort().reduce((i,n)=>(i[n]=t[n],i),{}):t)}function ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?Object.keys(e).every(t=>ce(s[t],e[t])):!1}function He(s,e){if(s===e)return s;const t=Ee(s)&&Ee(e);if(t||qe(s)&&qe(e)){const i=t?s:Object.keys(s),n=i.length,u=t?e:Object.keys(e),h=u.length,a=t?[]:{};let l=0;for(let y=0;y<h;y++){const p=t?y:u[y];(!t&&i.includes(p)||t)&&s[p]===void 0&&e[p]===void 0?(a[p]=void 0,l++):(a[p]=He(s[p],e[p]),a[p]===s[p]&&s[p]!==void 0&&l++)}return n===h&&l===n?s:a}return e}function Ee(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function qe(s){if(!Qe(s))return!1;const e=s.constructor;if(e===void 0)return!0;const t=e.prototype;return!(!Qe(t)||!t.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(s)!==Object.prototype)}function Qe(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ye(s){return new Promise(e=>{setTimeout(e,s)})}function Ze(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?He(s,e):e}function et(s,e,t=0){const i=[...s,e];return t&&i.length>t?i.slice(1):i}function tt(s,e,t=0){const i=[e,...s];return t&&i.length>t?i.slice(0,-1):i}var Oe=Symbol();function Ge(s,e){return!s.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!s.queryFn||s.queryFn===Oe?()=>Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)):s.queryFn}var _,G,Z,Re,st=(Re=class extends ge{constructor(){super();f(this,_);f(this,G);f(this,Z);o(this,Z,e=>{if(!we&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){r(this,G)||this.setEventListener(r(this,Z))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,G))==null||e.call(this),o(this,G,void 0))}setEventListener(e){var t;o(this,Z,e),(t=r(this,G))==null||t.call(this),o(this,G,e(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(e){r(this,_)!==e&&(o(this,_,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return typeof r(this,_)=="boolean"?r(this,_):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},_=new WeakMap,G=new WeakMap,Z=new WeakMap,Re),Ne=new st,ee,N,te,Ke,it=(Ke=class extends ge{constructor(){super();f(this,ee,!0);f(this,N);f(this,te);o(this,te,e=>{if(!we&&window.addEventListener){const t=()=>e(!0),i=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}}})}onSubscribe(){r(this,N)||this.setEventListener(r(this,te))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,N))==null||e.call(this),o(this,N,void 0))}setEventListener(e){var t;o(this,te,e),(t=r(this,N))==null||t.call(this),o(this,N,e(this.setOnline.bind(this)))}setOnline(e){r(this,ee)!==e&&(o(this,ee,e),this.listeners.forEach(i=>{i(e)}))}isOnline(){return r(this,ee)}},ee=new WeakMap,N=new WeakMap,te=new WeakMap,Ke),ve=new it;function rt(){let s,e;const t=new Promise((n,u)=>{s=n,e=u});t.status="pending",t.catch(()=>{});function i(n){Object.assign(t,n),delete t.resolve,delete t.reject}return t.resolve=n=>{i({status:"fulfilled",value:n}),s(n)},t.reject=n=>{i({status:"rejected",reason:n}),e(n)},t}function nt(s){return Math.min(1e3*2**s,3e4)}function Ve(s){return(s??"online")==="online"?ve.isOnline():!0}var $e=class extends Error{constructor(s){super("CancelledError"),this.revert=s==null?void 0:s.revert,this.silent=s==null?void 0:s.silent}};function Pe(s){return s instanceof $e}function Je(s){let e=!1,t=0,i=!1,n;const u=rt(),h=d=>{var v;i||(m(new $e(d)),(v=s.abort)==null||v.call(s))},a=()=>{e=!0},l=()=>{e=!1},y=()=>Ne.isFocused()&&(s.networkMode==="always"||ve.isOnline())&&s.canRun(),p=()=>Ve(s.networkMode)&&s.canRun(),c=d=>{var v;i||(i=!0,(v=s.onSuccess)==null||v.call(s,d),n==null||n(),u.resolve(d))},m=d=>{var v;i||(i=!0,(v=s.onError)==null||v.call(s,d),n==null||n(),u.reject(d))},S=()=>new Promise(d=>{var v;n=D=>{(i||y())&&d(D)},(v=s.onPause)==null||v.call(s)}).then(()=>{var d;n=void 0,i||(d=s.onContinue)==null||d.call(s)}),C=()=>{if(i)return;let d;const v=t===0?s.initialPromise:void 0;try{d=v??s.fn()}catch(D){d=Promise.reject(D)}Promise.resolve(d).then(c).catch(D=>{var j;if(i)return;const Q=s.retry??(we?0:3),w=s.retryDelay??nt,A=typeof w=="function"?w(t,D):w,K=Q===!0||typeof Q=="number"&&t<Q||typeof Q=="function"&&Q(t,D);if(e||!K){m(D);return}t++,(j=s.onFail)==null||j.call(s,t,D),Ye(A).then(()=>y()?void 0:S()).then(()=>{e?m(D):C()})})};return{promise:u,cancel:h,continue:()=>(n==null||n(),u),cancelRetry:a,continueRetry:l,canStart:p,start:()=>(p()?C():S().then(C),u)}}var at=s=>setTimeout(s,0);function ut(){let s=[],e=0,t=a=>{a()},i=a=>{a()},n=at;const u=a=>{e?s.push(a):n(()=>{t(a)})},h=()=>{const a=s;s=[],a.length&&n(()=>{i(()=>{a.forEach(l=>{t(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||h()}return l},batchCalls:a=>(...l)=>{u(()=>{a(...l)})},schedule:u,setNotifyFunction:a=>{t=a},setBatchNotifyFunction:a=>{i=a},setScheduler:a=>{n=a}}}var F=ut(),z,je,Be=(je=class{constructor(){f(this,z)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ze(this.gcTime)&&o(this,z,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(s){this.gcTime=Math.max(this.gcTime||0,s??(we?1/0:5*60*1e3))}clearGcTimeout(){r(this,z)&&(clearTimeout(r(this,z)),o(this,z,void 0))}},z=new WeakMap,je),se,ie,E,W,q,le,X,T,L,ke,ht=(ke=class extends Be{constructor(e){super();f(this,T);f(this,se);f(this,ie);f(this,E);f(this,W);f(this,q);f(this,le);f(this,X);o(this,X,!1),o(this,le,e.defaultOptions),this.setOptions(e.options),this.observers=[],o(this,W,e.client),o(this,E,r(this,W).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,o(this,se,ct(this.options)),this.state=e.state??r(this,se),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=r(this,q))==null?void 0:e.promise}setOptions(e){this.options={...r(this,le),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&r(this,E).remove(this)}setData(e,t){const i=Ze(this.state.data,e,this.options);return P(this,T,L).call(this,{data:i,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),i}setState(e,t){P(this,T,L).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var i,n;const t=(i=r(this,q))==null?void 0:i.promise;return(n=r(this,q))==null||n.cancel(e),t?t.then(M).catch(M):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(r(this,se))}isActive(){return this.observers.some(e=>Xe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oe||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!We(this.state.dataUpdatedAt,e)}onFocus(){var t;const e=this.observers.find(i=>i.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}onOnline(){var t;const e=this.observers.find(i=>i.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),r(this,E).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(r(this,q)&&(r(this,X)?r(this,q).cancel({revert:!0}):r(this,q).cancelRetry()),this.scheduleGc()),r(this,E).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||P(this,T,L).call(this,{type:"invalidate"})}fetch(e,t){var l,y,p;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(t!=null&&t.cancelRefetch))this.cancel({silent:!0});else if(r(this,q))return r(this,q).continueRetry(),r(this,q).promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(m=>m.options.queryFn);c&&this.setOptions(c.options)}const i=new AbortController,n=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(o(this,X,!0),i.signal)})},u=()=>{const c=Ge(this.options,t),m={client:r(this,W),queryKey:this.queryKey,meta:this.meta};return n(m),o(this,X,!1),this.options.persister?this.options.persister(c,m,this):c(m)},h={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:r(this,W),state:this.state,fetchFn:u};n(h),(l=this.options.behavior)==null||l.onFetch(h,this),o(this,ie,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((y=h.fetchOptions)==null?void 0:y.meta))&&P(this,T,L).call(this,{type:"fetch",meta:(p=h.fetchOptions)==null?void 0:p.meta});const a=c=>{var m,S,C,d;Pe(c)&&c.silent||P(this,T,L).call(this,{type:"error",error:c}),Pe(c)||((S=(m=r(this,E).config).onError)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,this.state.data,c,this)),this.scheduleGc()};return o(this,q,Je({initialPromise:t==null?void 0:t.initialPromise,fn:h.fetchFn,abort:i.abort.bind(i),onSuccess:c=>{var m,S,C,d;if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(v){a(v);return}(S=(m=r(this,E).config).onSuccess)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,m)=>{P(this,T,L).call(this,{type:"failed",failureCount:c,error:m})},onPause:()=>{P(this,T,L).call(this,{type:"pause"})},onContinue:()=>{P(this,T,L).call(this,{type:"continue"})},retry:h.options.retry,retryDelay:h.options.retryDelay,networkMode:h.options.networkMode,canRun:()=>!0})),r(this,q).start()}},se=new WeakMap,ie=new WeakMap,E=new WeakMap,W=new WeakMap,q=new WeakMap,le=new WeakMap,X=new WeakMap,T=new WeakSet,L=function(e){const t=i=>{switch(e.type){case"failed":return{...i,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...ot(i.data,this.options),fetchMeta:e.meta??null};case"success":return{...i,data:e.data,dataUpdateCount:i.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Pe(n)&&n.revert&&r(this,ie)?{...r(this,ie),fetchStatus:"idle"}:{...i,error:n,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...e.state}}};this.state=t(this.state),F.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),r(this,E).notify({query:this,type:"updated",action:e})})},ke);function ot(s,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ve(e.networkMode)?"fetching":"paused",...s===void 0&&{error:null,status:"pending"}}}function ct(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=e!==void 0,i=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var k,Ue,lt=(Ue=class extends ge{constructor(e={}){super();f(this,k);this.config=e,o(this,k,new Map)}build(e,t,i){const n=t.queryKey,u=t.queryHash??Ce(n,t);let h=this.get(u);return h||(h=new ht({client:e,queryKey:n,queryHash:u,options:e.defaultQueryOptions(t),state:i,defaultOptions:e.getQueryDefaults(n)}),this.add(h)),h}add(e){r(this,k).has(e.queryHash)||(r(this,k).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=r(this,k).get(e.queryHash);t&&(e.destroy(),t===e&&r(this,k).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){F.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return r(this,k).get(e)}getAll(){return[...r(this,k).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(i=>De(t,i))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(i=>De(e,i)):t}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){F.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){F.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},k=new WeakMap,Ue),U,O,Y,I,H,Ie,dt=(Ie=class extends Be{constructor(e){super();f(this,I);f(this,U);f(this,O);f(this,Y);this.mutationId=e.mutationId,o(this,O,e.mutationCache),o(this,U,[]),this.state=e.state||ft(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){r(this,U).includes(e)||(r(this,U).push(e),this.clearGcTimeout(),r(this,O).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){o(this,U,r(this,U).filter(t=>t!==e)),this.scheduleGc(),r(this,O).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){r(this,U).length||(this.state.status==="pending"?this.scheduleGc():r(this,O).remove(this))}continue(){var e;return((e=r(this,Y))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var u,h,a,l,y,p,c,m,S,C,d,v,D,Q,w,A,K,j,fe,he;const t=()=>{P(this,I,H).call(this,{type:"continue"})};o(this,Y,Je({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(b,ye)=>{P(this,I,H).call(this,{type:"failed",failureCount:b,error:ye})},onPause:()=>{P(this,I,H).call(this,{type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>r(this,O).canRun(this)}));const i=this.state.status==="pending",n=!r(this,Y).canStart();try{if(i)t();else{P(this,I,H).call(this,{type:"pending",variables:e,isPaused:n}),await((h=(u=r(this,O).config).onMutate)==null?void 0:h.call(u,e,this));const ye=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,e));ye!==this.state.context&&P(this,I,H).call(this,{type:"pending",context:ye,variables:e,isPaused:n})}const b=await r(this,Y).start();return await((p=(y=r(this,O).config).onSuccess)==null?void 0:p.call(y,b,e,this.state.context,this)),await((m=(c=this.options).onSuccess)==null?void 0:m.call(c,b,e,this.state.context)),await((C=(S=r(this,O).config).onSettled)==null?void 0:C.call(S,b,null,this.state.variables,this.state.context,this)),await((v=(d=this.options).onSettled)==null?void 0:v.call(d,b,null,e,this.state.context)),P(this,I,H).call(this,{type:"success",data:b}),b}catch(b){try{throw await((Q=(D=r(this,O).config).onError)==null?void 0:Q.call(D,b,e,this.state.context,this)),await((A=(w=this.options).onError)==null?void 0:A.call(w,b,e,this.state.context)),await((j=(K=r(this,O).config).onSettled)==null?void 0:j.call(K,void 0,b,this.state.variables,this.state.context,this)),await((he=(fe=this.options).onSettled)==null?void 0:he.call(fe,void 0,b,e,this.state.context)),b}finally{P(this,I,H).call(this,{type:"error",error:b})}}finally{r(this,O).runNext(this)}}},U=new WeakMap,O=new WeakMap,Y=new WeakMap,I=new WeakSet,H=function(e){const t=i=>{switch(e.type){case"failed":return{...i,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...i,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:e.error,failureCount:i.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),F.batch(()=>{r(this,U).forEach(i=>{i.onMutationUpdate(e)}),r(this,O).notify({mutation:this,type:"updated",action:e})})},Ie);function ft(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var x,R,de,Le,yt=(Le=class extends ge{constructor(e={}){super();f(this,x);f(this,R);f(this,de);this.config=e,o(this,x,new Set),o(this,R,new Map),o(this,de,0)}build(e,t,i){const n=new dt({mutationCache:this,mutationId:++pe(this,de)._,options:e.defaultMutationOptions(t),state:i});return this.add(n),n}add(e){r(this,x).add(e);const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);i?i.push(e):r(this,R).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(r(this,x).delete(e)){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);if(i)if(i.length>1){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}else i[0]===e&&r(this,R).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t),n=i==null?void 0:i.find(u=>u.state.status==="pending");return!n||n===e}else return!0}runNext(e){var i;const t=me(e);if(typeof t=="string"){const n=(i=r(this,R).get(t))==null?void 0:i.find(u=>u!==e&&u.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){F.batch(()=>{r(this,x).forEach(e=>{this.notify({type:"removed",mutation:e})}),r(this,x).clear(),r(this,R).clear()})}getAll(){return Array.from(r(this,x))}find(e){const t={exact:!0,...e};return this.getAll().find(i=>Ae(t,i))}findAll(e={}){return this.getAll().filter(t=>Ae(e,t))}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return F.batch(()=>Promise.all(e.map(t=>t.continue().catch(M))))}},x=new WeakMap,R=new WeakMap,de=new WeakMap,Le);function me(s){var e;return(e=s.options.scope)==null?void 0:e.id}function Me(s){return{onFetch:(e,t)=>{var p,c,m,S,C;const i=e.options,n=(m=(c=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:c.fetchMore)==null?void 0:m.direction,u=((S=e.state.data)==null?void 0:S.pages)||[],h=((C=e.state.data)==null?void 0:C.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const y=async()=>{let d=!1;const v=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},D=Ge(e.options,e.fetchOptions),Q=async(w,A,K)=>{if(d)return Promise.reject();if(A==null&&w.pages.length)return Promise.resolve(w);const j={client:e.client,queryKey:e.queryKey,pageParam:A,direction:K?"backward":"forward",meta:e.options.meta};v(j);const fe=await D(j),{maxPages:he}=e.options,b=K?tt:et;return{pages:b(w.pages,fe,he),pageParams:b(w.pageParams,A,he)}};if(n&&u.length){const w=n==="backward",A=w?pt:Te,K={pages:u,pageParams:h},j=A(i,K);a=await Q(K,j,w)}else{const w=s??u.length;do{const A=l===0?h[0]??i.initialPageParam:Te(i,a);if(l>0&&A==null)break;a=await Q(a,A),l++}while(l<w)}return a};e.options.persister?e.fetchFn=()=>{var d,v;return(v=(d=e.options).persister)==null?void 0:v.call(d,y,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t)}:e.fetchFn=y}}}function Te(s,{pages:e,pageParams:t}){const i=e.length-1;return e.length>0?s.getNextPageParam(e[i],e,t[i],t):void 0}function pt(s,{pages:e,pageParams:t}){var i;return e.length>0?(i=s.getPreviousPageParam)==null?void 0:i.call(s,e[0],e,t[0],t):void 0}var g,V,$,re,ne,J,ae,ue,xe,mt=(xe=class{constructor(s={}){f(this,g);f(this,V);f(this,$);f(this,re);f(this,ne);f(this,J);f(this,ae);f(this,ue);o(this,g,s.queryCache||new lt),o(this,V,s.mutationCache||new yt),o(this,$,s.defaultOptions||{}),o(this,re,new Map),o(this,ne,new Map),o(this,J,0)}mount(){pe(this,J)._++,r(this,J)===1&&(o(this,ae,Ne.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onFocus())})),o(this,ue,ve.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onOnline())})))}unmount(){var s,e;pe(this,J)._--,r(this,J)===0&&((s=r(this,ae))==null||s.call(this),o(this,ae,void 0),(e=r(this,ue))==null||e.call(this),o(this,ue,void 0))}isFetching(s){return r(this,g).findAll({...s,fetchStatus:"fetching"}).length}isMutating(s){return r(this,V).findAll({...s,status:"pending"}).length}getQueryData(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state.data}ensureQueryData(s){const e=this.defaultQueryOptions(s),t=r(this,g).build(this,e),i=t.state.data;return i===void 0?this.fetchQuery(s):(s.revalidateIfStale&&t.isStaleByTime(Se(e.staleTime,t))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(s){return r(this,g).findAll(s).map(({queryKey:e,state:t})=>{const i=t.data;return[e,i]})}setQueryData(s,e,t){const i=this.defaultQueryOptions({queryKey:s}),n=r(this,g).get(i.queryHash),u=n==null?void 0:n.state.data,h=_e(e,u);if(h!==void 0)return r(this,g).build(this,i).setData(h,{...t,manual:!0})}setQueriesData(s,e,t){return F.batch(()=>r(this,g).findAll(s).map(({queryKey:i})=>[i,this.setQueryData(i,e,t)]))}getQueryState(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state}removeQueries(s){const e=r(this,g);F.batch(()=>{e.findAll(s).forEach(t=>{e.remove(t)})})}resetQueries(s,e){const t=r(this,g);return F.batch(()=>(t.findAll(s).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...s},e)))}cancelQueries(s,e={}){const t={revert:!0,...e},i=F.batch(()=>r(this,g).findAll(s).map(n=>n.cancel(t)));return Promise.all(i).then(M).catch(M)}invalidateQueries(s,e={}){return F.batch(()=>(r(this,g).findAll(s).forEach(t=>{t.invalidate()}),(s==null?void 0:s.refetchType)==="none"?Promise.resolve():this.refetchQueries({...s,type:(s==null?void 0:s.refetchType)??(s==null?void 0:s.type)??"active"},e)))}refetchQueries(s,e={}){const t={...e,cancelRefetch:e.cancelRefetch??!0},i=F.batch(()=>r(this,g).findAll(s).filter(n=>!n.isDisabled()).map(n=>{let u=n.fetch(void 0,t);return t.throwOnError||(u=u.catch(M)),n.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(i).then(M)}fetchQuery(s){const e=this.defaultQueryOptions(s);e.retry===void 0&&(e.retry=!1);const t=r(this,g).build(this,e);return t.isStaleByTime(Se(e.staleTime,t))?t.fetch(e):Promise.resolve(t.state.data)}prefetchQuery(s){return this.fetchQuery(s).then(M).catch(M)}fetchInfiniteQuery(s){return s.behavior=Me(s.pages),this.fetchQuery(s)}prefetchInfiniteQuery(s){return this.fetchInfiniteQuery(s).then(M).catch(M)}ensureInfiniteQueryData(s){return s.behavior=Me(s.pages),this.ensureQueryData(s)}resumePausedMutations(){return ve.isOnline()?r(this,V).resumePausedMutations():Promise.resolve()}getQueryCache(){return r(this,g)}getMutationCache(){return r(this,V)}getDefaultOptions(){return r(this,$)}setDefaultOptions(s){o(this,$,s)}setQueryDefaults(s,e){r(this,re).set(oe(s),{queryKey:s,defaultOptions:e})}getQueryDefaults(s){const e=[...r(this,re).values()],t={};return e.forEach(i=>{ce(s,i.queryKey)&&Object.assign(t,i.defaultOptions)}),t}setMutationDefaults(s,e){r(this,ne).set(oe(s),{mutationKey:s,defaultOptions:e})}getMutationDefaults(s){const e=[...r(this,ne).values()],t={};return e.forEach(i=>{ce(s,i.mutationKey)&&Object.assign(t,i.defaultOptions)}),t}defaultQueryOptions(s){if(s._defaulted)return s;const e={...r(this,$).queries,...this.getQueryDefaults(s.queryKey),...s,_defaulted:!0};return e.queryHash||(e.queryHash=Ce(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Oe&&(e.enabled=!1),e}defaultMutationOptions(s){return s!=null&&s._defaulted?s:{...r(this,$).mutations,...(s==null?void 0:s.mutationKey)&&this.getMutationDefaults(s.mutationKey),...s,_defaulted:!0}}clear(){r(this,g).clear(),r(this,V).clear()}},g=new WeakMap,V=new WeakMap,$=new WeakMap,re=new WeakMap,ne=new WeakMap,J=new WeakMap,ae=new WeakMap,ue=new WeakMap,xe);class B{constructor(e={}){this.availableDatasets=[],this.apiUrl=e.apiUrl||"https://api.luzmo.com",this.apiVersion=e.apiVersion||"0.1.0",this.authKey=e.authKey||"",this.authToken=e.authToken||"",this.queryClient=new mt({defaultOptions:{queries:{staleTime:e.staleTime||5*60*1e3,gcTime:e.gcTime||10*60*1e3,retry:e.retry||3,retryDelay:e.retryDelay||(t=>Math.min(1e3*2**t,3e4))}}}),this.initNetworkListeners()}configure(e={}){if(e.apiVersion&&(this.apiVersion=e.apiVersion),e.apiUrl&&(this.apiUrl=e.apiUrl),e.authKey&&(this.authKey=e.authKey),e.authToken&&(this.authToken=e.authToken),e.staleTime||e.gcTime||e.retry){const t={};e.staleTime&&(t.staleTime=e.staleTime),e.gcTime&&(t.gcTime=e.gcTime),e.retry&&(t.retry=e.retry),this.queryClient.setDefaultOptions({queries:{...this.queryClient.getDefaultOptions().queries,...t}})}}initNetworkListeners(){typeof window<"u"&&window.addEventListener("online",()=>{console.warn("Network connection restored, refreshing data..."),this.refreshAll()})}getHeaders(e={}){return{"Content-Type":"application/json",...e}}async fetchApi(e,t,i={}){const n=`${this.apiUrl}/${this.apiVersion}${e}`,h={method:i.method||"POST",headers:this.getHeaders(i.headers),mode:"cors",...i};t!==void 0&&(t.key=this.authKey,t.token=this.authToken,h.body=JSON.stringify(t));try{const a=await fetch(n,h);if(!a.ok){const l=await a.json().catch(()=>null);throw a.status===401||a.status===403?new Error("Authentication failed. Please check your API token."):a.status===404?new Error(`Resource not found: ${e}`):a.status===429?new Error("Rate limit exceeded. Please try again later."):new Error((l==null?void 0:l.message)||`API request failed with status ${a.status}`)}return await a.json()}catch(a){throw console.error(`API request to ${e} failed:`,a),a instanceof Error&&(a.endpoint=e,a.timestamp=new Date().toISOString()),a}}async fetchAllDatasets(e={}){const t=e.offset||0,i=e.limit||50,n=["datasets",t,i];return await this.queryClient.fetchQuery({queryKey:n,queryFn:async()=>{const u={action:"get",version:this.apiVersion,find:{where:{type:"dataset"},limit:i,offset:t}},h=await this.fetchApi("/securable",u);return{data:(h==null?void 0:h.rows)||[],pagination:{offset:t,limit:i,total:(h==null?void 0:h.count)??0,pages:Math.ceil(((h==null?void 0:h.count)??0)/i)}}}})}async searchDatasets(e,t){if(!e)return[];const i=["datasets","search",e,t];return await this.queryClient.fetchQuery({queryKey:i,queryFn:async()=>{const n={action:"get",version:this.apiVersion,find:{where:{type:"dataset"}}};(e==null?void 0:e.length)>0&&(n.find.search={match_types:["name"],keyphrase:e}),t!=null&&t.offset&&(n.find.offset=t==null?void 0:t.offset),t!=null&&t.limit&&(n.find.limit=t==null?void 0:t.limit);const u=await this.fetchApi("/securable",n),h={data:(u==null?void 0:u.rows)||[]};return t!=null&&t.limit&&(h.pagination={offset:(t==null?void 0:t.offset)??0,limit:t==null?void 0:t.limit,total:(u==null?void 0:u.count)??0,pages:Math.ceil(((u==null?void 0:u.count)??0)/(t==null?void 0:t.limit))}),h}})}async fetchDatasetsWithColumnsAndFormulas(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=["datasets",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:{in:e}},attributes:["name","id"],include:[{model:"Column",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"],separate:!0,order:[["order","asc"]],include:[{model:"Column",attributes:["id","securable_id","hierarchy_enabled","currency_id"],as:"Joins"}]},{model:"Formula",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"]}]}},n=await this.fetchApi("/securable",i);return(n==null?void 0:n.rows)||[]}})}async fetchDataset(e){if(!e)throw new Error("Dataset ID is required");const t=["dataset",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{var u;const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:e},attributes:["name","id"],include:[{model:"Column"},{model:"Formula"}]}},n=await this.fetchApi("/securable",i);return((u=n==null?void 0:n.rows)==null?void 0:u[0])||null}})}async fetchData(e){if(!e)throw new Error("Query is required");const t=["data",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{queries:[e]}},n=await this.fetchApi("/data",i);return{data:(n==null?void 0:n.data)||[],performance:(n==null?void 0:n.performance)||{}}}})}refreshAll(){this.queryClient.refetchQueries()}invalidateDatasetData(e){e?(this.queryClient.invalidateQueries({queryKey:["dataset",e]}),this.queryClient.invalidateQueries({queryKey:["columns",e]})):this.queryClient.invalidateQueries({queryKey:["datasets"]})}invalidateAll(){this.queryClient.clear()}static getInstance(e={}){return B.instance?Object.keys(e).length>0&&B.instance.configure(e):B.instance=new B(e),B.instance}async fetchDatasetsRecursive(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=[...new Set(e)],i=new Set,n=new Map,u=h=>{h&&!i.has(h)&&!t.includes(h)&&t.push(h)};for(;t.length>0;){const h=[];for(;t.length>0&&h.length<50;){const a=t.shift();i.has(a)||h.push(a)}if(h.length!==0)try{(await this.fetchDatasetsWithColumnsAndFormulas(h)).forEach(l=>{const y=this.postProcessDatasetMetadata(l);i.add(y.id),this.queryClient.setQueryData(["dataset",y.id],y),(y.outgoingJoins??[]).map(c=>c.securable_id).filter(c=>c&&c!==y.id).forEach(c=>{u(c)}),n.set(y.id,y),this.availableDatasets.some(c=>c.id===y.id)||this.availableDatasets.push({id:y.id,name:y.name,columns:y.columns})})}catch(a){console.error("Error fetching datasets recursively:",a)}}return[...n.values()]}postProcessDatasetMetadata(e){var t;e.dateLoaded=new Date,e.outgoingJoins=[];for(const i of e.columns)if(((t=i.joins)==null?void 0:t.length)>0)for(const n of i.joins)e.outgoingJoins.push(n);return e}getAvailableDatasets(){return this.availableDatasets}getLinkedDatasetIds(e){const t=this.queryClient.getQueryData(["dataset",e]);return t?(t.outgoingJoins??[]).map(i=>i.securable_id).filter(i=>i&&i!==e):[]}}const vt=B.getInstance();exports.dataBroker=vt;
|
20
|
+
"use strict";var Fe=s=>{throw TypeError(s)};var be=(s,e,t)=>e.has(s)||Fe("Cannot "+t);var r=(s,e,t)=>(be(s,e,"read from private field"),t?t.call(s):e.get(s)),f=(s,e,t)=>e.has(s)?Fe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),o=(s,e,t,i)=>(be(s,e,"write to private field"),i?i.call(s,t):e.set(s,t),t),P=(s,e,t)=>(be(s,e,"access private method"),t);var pe=(s,e,t,i)=>({set _(n){o(s,e,n,t)},get _(){return r(s,e,i)}});var ge=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(s){return this.listeners.add(s),this.onSubscribe(),()=>{this.listeners.delete(s),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},we=typeof window>"u"||"Deno"in globalThis;function M(){}function _e(s,e){return typeof s=="function"?s(e):s}function ze(s){return typeof s=="number"&&s>=0&&s!==1/0}function We(s,e){return Math.max(s+(e||0)-Date.now(),0)}function Se(s,e){return typeof s=="function"?s(e):s}function Xe(s,e){return typeof s=="function"?s(e):s}function De(s,e){const{type:t="all",exact:i,fetchStatus:n,predicate:u,queryKey:h,stale:a}=s;if(h){if(i){if(e.queryHash!==Ce(h,e.options))return!1}else if(!ce(e.queryKey,h))return!1}if(t!=="all"){const l=e.isActive();if(t==="active"&&!l||t==="inactive"&&l)return!1}return!(typeof a=="boolean"&&e.isStale()!==a||n&&n!==e.state.fetchStatus||u&&!u(e))}function Ae(s,e){const{exact:t,status:i,predicate:n,mutationKey:u}=s;if(u){if(!e.options.mutationKey)return!1;if(t){if(oe(e.options.mutationKey)!==oe(u))return!1}else if(!ce(e.options.mutationKey,u))return!1}return!(i&&e.state.status!==i||n&&!n(e))}function Ce(s,e){return((e==null?void 0:e.queryKeyHashFn)||oe)(s)}function oe(s){return JSON.stringify(s,(e,t)=>qe(t)?Object.keys(t).sort().reduce((i,n)=>(i[n]=t[n],i),{}):t)}function ce(s,e){return s===e?!0:typeof s!=typeof e?!1:s&&e&&typeof s=="object"&&typeof e=="object"?Object.keys(e).every(t=>ce(s[t],e[t])):!1}function He(s,e){if(s===e)return s;const t=Ee(s)&&Ee(e);if(t||qe(s)&&qe(e)){const i=t?s:Object.keys(s),n=i.length,u=t?e:Object.keys(e),h=u.length,a=t?[]:{};let l=0;for(let y=0;y<h;y++){const p=t?y:u[y];(!t&&i.includes(p)||t)&&s[p]===void 0&&e[p]===void 0?(a[p]=void 0,l++):(a[p]=He(s[p],e[p]),a[p]===s[p]&&s[p]!==void 0&&l++)}return n===h&&l===n?s:a}return e}function Ee(s){return Array.isArray(s)&&s.length===Object.keys(s).length}function qe(s){if(!Qe(s))return!1;const e=s.constructor;if(e===void 0)return!0;const t=e.prototype;return!(!Qe(t)||!t.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(s)!==Object.prototype)}function Qe(s){return Object.prototype.toString.call(s)==="[object Object]"}function Ye(s){return new Promise(e=>{setTimeout(e,s)})}function Ze(s,e,t){return typeof t.structuralSharing=="function"?t.structuralSharing(s,e):t.structuralSharing!==!1?He(s,e):e}function et(s,e,t=0){const i=[...s,e];return t&&i.length>t?i.slice(1):i}function tt(s,e,t=0){const i=[e,...s];return t&&i.length>t?i.slice(0,-1):i}var Oe=Symbol();function Ge(s,e){return!s.queryFn&&(e!=null&&e.initialPromise)?()=>e.initialPromise:!s.queryFn||s.queryFn===Oe?()=>Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)):s.queryFn}var _,G,Z,Re,st=(Re=class extends ge{constructor(){super();f(this,_);f(this,G);f(this,Z);o(this,Z,e=>{if(!we&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}})}onSubscribe(){r(this,G)||this.setEventListener(r(this,Z))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,G))==null||e.call(this),o(this,G,void 0))}setEventListener(e){var t;o(this,Z,e),(t=r(this,G))==null||t.call(this),o(this,G,e(i=>{typeof i=="boolean"?this.setFocused(i):this.onFocus()}))}setFocused(e){r(this,_)!==e&&(o(this,_,e),this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){var e;return typeof r(this,_)=="boolean"?r(this,_):((e=globalThis.document)==null?void 0:e.visibilityState)!=="hidden"}},_=new WeakMap,G=new WeakMap,Z=new WeakMap,Re),Ne=new st,ee,N,te,Ke,it=(Ke=class extends ge{constructor(){super();f(this,ee,!0);f(this,N);f(this,te);o(this,te,e=>{if(!we&&window.addEventListener){const t=()=>e(!0),i=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",i,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",i)}}})}onSubscribe(){r(this,N)||this.setEventListener(r(this,te))}onUnsubscribe(){var e;this.hasListeners()||((e=r(this,N))==null||e.call(this),o(this,N,void 0))}setEventListener(e){var t;o(this,te,e),(t=r(this,N))==null||t.call(this),o(this,N,e(this.setOnline.bind(this)))}setOnline(e){r(this,ee)!==e&&(o(this,ee,e),this.listeners.forEach(i=>{i(e)}))}isOnline(){return r(this,ee)}},ee=new WeakMap,N=new WeakMap,te=new WeakMap,Ke),ve=new it;function rt(){let s,e;const t=new Promise((n,u)=>{s=n,e=u});t.status="pending",t.catch(()=>{});function i(n){Object.assign(t,n),delete t.resolve,delete t.reject}return t.resolve=n=>{i({status:"fulfilled",value:n}),s(n)},t.reject=n=>{i({status:"rejected",reason:n}),e(n)},t}function nt(s){return Math.min(1e3*2**s,3e4)}function Ve(s){return(s??"online")==="online"?ve.isOnline():!0}var $e=class extends Error{constructor(s){super("CancelledError"),this.revert=s==null?void 0:s.revert,this.silent=s==null?void 0:s.silent}};function Pe(s){return s instanceof $e}function Je(s){let e=!1,t=0,i=!1,n;const u=rt(),h=d=>{var v;i||(m(new $e(d)),(v=s.abort)==null||v.call(s))},a=()=>{e=!0},l=()=>{e=!1},y=()=>Ne.isFocused()&&(s.networkMode==="always"||ve.isOnline())&&s.canRun(),p=()=>Ve(s.networkMode)&&s.canRun(),c=d=>{var v;i||(i=!0,(v=s.onSuccess)==null||v.call(s,d),n==null||n(),u.resolve(d))},m=d=>{var v;i||(i=!0,(v=s.onError)==null||v.call(s,d),n==null||n(),u.reject(d))},S=()=>new Promise(d=>{var v;n=D=>{(i||y())&&d(D)},(v=s.onPause)==null||v.call(s)}).then(()=>{var d;n=void 0,i||(d=s.onContinue)==null||d.call(s)}),C=()=>{if(i)return;let d;const v=t===0?s.initialPromise:void 0;try{d=v??s.fn()}catch(D){d=Promise.reject(D)}Promise.resolve(d).then(c).catch(D=>{var j;if(i)return;const Q=s.retry??(we?0:3),w=s.retryDelay??nt,A=typeof w=="function"?w(t,D):w,K=Q===!0||typeof Q=="number"&&t<Q||typeof Q=="function"&&Q(t,D);if(e||!K){m(D);return}t++,(j=s.onFail)==null||j.call(s,t,D),Ye(A).then(()=>y()?void 0:S()).then(()=>{e?m(D):C()})})};return{promise:u,cancel:h,continue:()=>(n==null||n(),u),cancelRetry:a,continueRetry:l,canStart:p,start:()=>(p()?C():S().then(C),u)}}var at=s=>setTimeout(s,0);function ut(){let s=[],e=0,t=a=>{a()},i=a=>{a()},n=at;const u=a=>{e?s.push(a):n(()=>{t(a)})},h=()=>{const a=s;s=[],a.length&&n(()=>{i(()=>{a.forEach(l=>{t(l)})})})};return{batch:a=>{let l;e++;try{l=a()}finally{e--,e||h()}return l},batchCalls:a=>(...l)=>{u(()=>{a(...l)})},schedule:u,setNotifyFunction:a=>{t=a},setBatchNotifyFunction:a=>{i=a},setScheduler:a=>{n=a}}}var F=ut(),z,je,Be=(je=class{constructor(){f(this,z)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ze(this.gcTime)&&o(this,z,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(s){this.gcTime=Math.max(this.gcTime||0,s??(we?1/0:5*60*1e3))}clearGcTimeout(){r(this,z)&&(clearTimeout(r(this,z)),o(this,z,void 0))}},z=new WeakMap,je),se,ie,E,W,q,le,X,T,L,ke,ht=(ke=class extends Be{constructor(e){super();f(this,T);f(this,se);f(this,ie);f(this,E);f(this,W);f(this,q);f(this,le);f(this,X);o(this,X,!1),o(this,le,e.defaultOptions),this.setOptions(e.options),this.observers=[],o(this,W,e.client),o(this,E,r(this,W).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,o(this,se,ct(this.options)),this.state=e.state??r(this,se),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var e;return(e=r(this,q))==null?void 0:e.promise}setOptions(e){this.options={...r(this,le),...e},this.updateGcTime(this.options.gcTime)}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&r(this,E).remove(this)}setData(e,t){const i=Ze(this.state.data,e,this.options);return P(this,T,L).call(this,{data:i,type:"success",dataUpdatedAt:t==null?void 0:t.updatedAt,manual:t==null?void 0:t.manual}),i}setState(e,t){P(this,T,L).call(this,{type:"setState",state:e,setStateOptions:t})}cancel(e){var i,n;const t=(i=r(this,q))==null?void 0:i.promise;return(n=r(this,q))==null||n.cancel(e),t?t.then(M).catch(M):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(r(this,se))}isActive(){return this.observers.some(e=>Xe(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Oe||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStale(){return this.state.isInvalidated?!0:this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0}isStaleByTime(e=0){return this.state.isInvalidated||this.state.data===void 0||!We(this.state.dataUpdatedAt,e)}onFocus(){var t;const e=this.observers.find(i=>i.shouldFetchOnWindowFocus());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}onOnline(){var t;const e=this.observers.find(i=>i.shouldFetchOnReconnect());e==null||e.refetch({cancelRefetch:!1}),(t=r(this,q))==null||t.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),r(this,E).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(r(this,q)&&(r(this,X)?r(this,q).cancel({revert:!0}):r(this,q).cancelRetry()),this.scheduleGc()),r(this,E).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||P(this,T,L).call(this,{type:"invalidate"})}fetch(e,t){var l,y,p;if(this.state.fetchStatus!=="idle"){if(this.state.data!==void 0&&(t!=null&&t.cancelRefetch))this.cancel({silent:!0});else if(r(this,q))return r(this,q).continueRetry(),r(this,q).promise}if(e&&this.setOptions(e),!this.options.queryFn){const c=this.observers.find(m=>m.options.queryFn);c&&this.setOptions(c.options)}const i=new AbortController,n=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(o(this,X,!0),i.signal)})},u=()=>{const c=Ge(this.options,t),m={client:r(this,W),queryKey:this.queryKey,meta:this.meta};return n(m),o(this,X,!1),this.options.persister?this.options.persister(c,m,this):c(m)},h={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:r(this,W),state:this.state,fetchFn:u};n(h),(l=this.options.behavior)==null||l.onFetch(h,this),o(this,ie,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((y=h.fetchOptions)==null?void 0:y.meta))&&P(this,T,L).call(this,{type:"fetch",meta:(p=h.fetchOptions)==null?void 0:p.meta});const a=c=>{var m,S,C,d;Pe(c)&&c.silent||P(this,T,L).call(this,{type:"error",error:c}),Pe(c)||((S=(m=r(this,E).config).onError)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,this.state.data,c,this)),this.scheduleGc()};return o(this,q,Je({initialPromise:t==null?void 0:t.initialPromise,fn:h.fetchFn,abort:i.abort.bind(i),onSuccess:c=>{var m,S,C,d;if(c===void 0){a(new Error(`${this.queryHash} data is undefined`));return}try{this.setData(c)}catch(v){a(v);return}(S=(m=r(this,E).config).onSuccess)==null||S.call(m,c,this),(d=(C=r(this,E).config).onSettled)==null||d.call(C,c,this.state.error,this),this.scheduleGc()},onError:a,onFail:(c,m)=>{P(this,T,L).call(this,{type:"failed",failureCount:c,error:m})},onPause:()=>{P(this,T,L).call(this,{type:"pause"})},onContinue:()=>{P(this,T,L).call(this,{type:"continue"})},retry:h.options.retry,retryDelay:h.options.retryDelay,networkMode:h.options.networkMode,canRun:()=>!0})),r(this,q).start()}},se=new WeakMap,ie=new WeakMap,E=new WeakMap,W=new WeakMap,q=new WeakMap,le=new WeakMap,X=new WeakMap,T=new WeakSet,L=function(e){const t=i=>{switch(e.type){case"failed":return{...i,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...i,fetchStatus:"paused"};case"continue":return{...i,fetchStatus:"fetching"};case"fetch":return{...i,...ot(i.data,this.options),fetchMeta:e.meta??null};case"success":return{...i,data:e.data,dataUpdateCount:i.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const n=e.error;return Pe(n)&&n.revert&&r(this,ie)?{...r(this,ie),fetchStatus:"idle"}:{...i,error:n,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...i,isInvalidated:!0};case"setState":return{...i,...e.state}}};this.state=t(this.state),F.batch(()=>{this.observers.forEach(i=>{i.onQueryUpdate()}),r(this,E).notify({query:this,type:"updated",action:e})})},ke);function ot(s,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Ve(e.networkMode)?"fetching":"paused",...s===void 0&&{error:null,status:"pending"}}}function ct(s){const e=typeof s.initialData=="function"?s.initialData():s.initialData,t=e!==void 0,i=t?typeof s.initialDataUpdatedAt=="function"?s.initialDataUpdatedAt():s.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:t?i??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:t?"success":"pending",fetchStatus:"idle"}}var k,Ue,lt=(Ue=class extends ge{constructor(e={}){super();f(this,k);this.config=e,o(this,k,new Map)}build(e,t,i){const n=t.queryKey,u=t.queryHash??Ce(n,t);let h=this.get(u);return h||(h=new ht({client:e,queryKey:n,queryHash:u,options:e.defaultQueryOptions(t),state:i,defaultOptions:e.getQueryDefaults(n)}),this.add(h)),h}add(e){r(this,k).has(e.queryHash)||(r(this,k).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=r(this,k).get(e.queryHash);t&&(e.destroy(),t===e&&r(this,k).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){F.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return r(this,k).get(e)}getAll(){return[...r(this,k).values()]}find(e){const t={exact:!0,...e};return this.getAll().find(i=>De(t,i))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(i=>De(e,i)):t}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){F.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){F.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},k=new WeakMap,Ue),U,O,Y,I,H,Ie,dt=(Ie=class extends Be{constructor(e){super();f(this,I);f(this,U);f(this,O);f(this,Y);this.mutationId=e.mutationId,o(this,O,e.mutationCache),o(this,U,[]),this.state=e.state||ft(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){r(this,U).includes(e)||(r(this,U).push(e),this.clearGcTimeout(),r(this,O).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){o(this,U,r(this,U).filter(t=>t!==e)),this.scheduleGc(),r(this,O).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){r(this,U).length||(this.state.status==="pending"?this.scheduleGc():r(this,O).remove(this))}continue(){var e;return((e=r(this,Y))==null?void 0:e.continue())??this.execute(this.state.variables)}async execute(e){var u,h,a,l,y,p,c,m,S,C,d,v,D,Q,w,A,K,j,fe,he;const t=()=>{P(this,I,H).call(this,{type:"continue"})};o(this,Y,Je({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(new Error("No mutationFn found")),onFail:(b,ye)=>{P(this,I,H).call(this,{type:"failed",failureCount:b,error:ye})},onPause:()=>{P(this,I,H).call(this,{type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>r(this,O).canRun(this)}));const i=this.state.status==="pending",n=!r(this,Y).canStart();try{if(i)t();else{P(this,I,H).call(this,{type:"pending",variables:e,isPaused:n}),await((h=(u=r(this,O).config).onMutate)==null?void 0:h.call(u,e,this));const ye=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,e));ye!==this.state.context&&P(this,I,H).call(this,{type:"pending",context:ye,variables:e,isPaused:n})}const b=await r(this,Y).start();return await((p=(y=r(this,O).config).onSuccess)==null?void 0:p.call(y,b,e,this.state.context,this)),await((m=(c=this.options).onSuccess)==null?void 0:m.call(c,b,e,this.state.context)),await((C=(S=r(this,O).config).onSettled)==null?void 0:C.call(S,b,null,this.state.variables,this.state.context,this)),await((v=(d=this.options).onSettled)==null?void 0:v.call(d,b,null,e,this.state.context)),P(this,I,H).call(this,{type:"success",data:b}),b}catch(b){try{throw await((Q=(D=r(this,O).config).onError)==null?void 0:Q.call(D,b,e,this.state.context,this)),await((A=(w=this.options).onError)==null?void 0:A.call(w,b,e,this.state.context)),await((j=(K=r(this,O).config).onSettled)==null?void 0:j.call(K,void 0,b,this.state.variables,this.state.context,this)),await((he=(fe=this.options).onSettled)==null?void 0:he.call(fe,void 0,b,e,this.state.context)),b}finally{P(this,I,H).call(this,{type:"error",error:b})}}finally{r(this,O).runNext(this)}}},U=new WeakMap,O=new WeakMap,Y=new WeakMap,I=new WeakSet,H=function(e){const t=i=>{switch(e.type){case"failed":return{...i,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...i,isPaused:!0};case"continue":return{...i,isPaused:!1};case"pending":return{...i,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...i,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...i,data:void 0,error:e.error,failureCount:i.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),F.batch(()=>{r(this,U).forEach(i=>{i.onMutationUpdate(e)}),r(this,O).notify({mutation:this,type:"updated",action:e})})},Ie);function ft(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var x,R,de,Le,yt=(Le=class extends ge{constructor(e={}){super();f(this,x);f(this,R);f(this,de);this.config=e,o(this,x,new Set),o(this,R,new Map),o(this,de,0)}build(e,t,i){const n=new dt({mutationCache:this,mutationId:++pe(this,de)._,options:e.defaultMutationOptions(t),state:i});return this.add(n),n}add(e){r(this,x).add(e);const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);i?i.push(e):r(this,R).set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(r(this,x).delete(e)){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t);if(i)if(i.length>1){const n=i.indexOf(e);n!==-1&&i.splice(n,1)}else i[0]===e&&r(this,R).delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=me(e);if(typeof t=="string"){const i=r(this,R).get(t),n=i==null?void 0:i.find(u=>u.state.status==="pending");return!n||n===e}else return!0}runNext(e){var i;const t=me(e);if(typeof t=="string"){const n=(i=r(this,R).get(t))==null?void 0:i.find(u=>u!==e&&u.state.isPaused);return(n==null?void 0:n.continue())??Promise.resolve()}else return Promise.resolve()}clear(){F.batch(()=>{r(this,x).forEach(e=>{this.notify({type:"removed",mutation:e})}),r(this,x).clear(),r(this,R).clear()})}getAll(){return Array.from(r(this,x))}find(e){const t={exact:!0,...e};return this.getAll().find(i=>Ae(t,i))}findAll(e={}){return this.getAll().filter(t=>Ae(e,t))}notify(e){F.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return F.batch(()=>Promise.all(e.map(t=>t.continue().catch(M))))}},x=new WeakMap,R=new WeakMap,de=new WeakMap,Le);function me(s){var e;return(e=s.options.scope)==null?void 0:e.id}function Me(s){return{onFetch:(e,t)=>{var p,c,m,S,C;const i=e.options,n=(m=(c=(p=e.fetchOptions)==null?void 0:p.meta)==null?void 0:c.fetchMore)==null?void 0:m.direction,u=((S=e.state.data)==null?void 0:S.pages)||[],h=((C=e.state.data)==null?void 0:C.pageParams)||[];let a={pages:[],pageParams:[]},l=0;const y=async()=>{let d=!1;const v=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(e.signal.aborted?d=!0:e.signal.addEventListener("abort",()=>{d=!0}),e.signal)})},D=Ge(e.options,e.fetchOptions),Q=async(w,A,K)=>{if(d)return Promise.reject();if(A==null&&w.pages.length)return Promise.resolve(w);const j={client:e.client,queryKey:e.queryKey,pageParam:A,direction:K?"backward":"forward",meta:e.options.meta};v(j);const fe=await D(j),{maxPages:he}=e.options,b=K?tt:et;return{pages:b(w.pages,fe,he),pageParams:b(w.pageParams,A,he)}};if(n&&u.length){const w=n==="backward",A=w?pt:Te,K={pages:u,pageParams:h},j=A(i,K);a=await Q(K,j,w)}else{const w=s??u.length;do{const A=l===0?h[0]??i.initialPageParam:Te(i,a);if(l>0&&A==null)break;a=await Q(a,A),l++}while(l<w)}return a};e.options.persister?e.fetchFn=()=>{var d,v;return(v=(d=e.options).persister)==null?void 0:v.call(d,y,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},t)}:e.fetchFn=y}}}function Te(s,{pages:e,pageParams:t}){const i=e.length-1;return e.length>0?s.getNextPageParam(e[i],e,t[i],t):void 0}function pt(s,{pages:e,pageParams:t}){var i;return e.length>0?(i=s.getPreviousPageParam)==null?void 0:i.call(s,e[0],e,t[0],t):void 0}var g,V,$,re,ne,J,ae,ue,xe,mt=(xe=class{constructor(s={}){f(this,g);f(this,V);f(this,$);f(this,re);f(this,ne);f(this,J);f(this,ae);f(this,ue);o(this,g,s.queryCache||new lt),o(this,V,s.mutationCache||new yt),o(this,$,s.defaultOptions||{}),o(this,re,new Map),o(this,ne,new Map),o(this,J,0)}mount(){pe(this,J)._++,r(this,J)===1&&(o(this,ae,Ne.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onFocus())})),o(this,ue,ve.subscribe(async s=>{s&&(await this.resumePausedMutations(),r(this,g).onOnline())})))}unmount(){var s,e;pe(this,J)._--,r(this,J)===0&&((s=r(this,ae))==null||s.call(this),o(this,ae,void 0),(e=r(this,ue))==null||e.call(this),o(this,ue,void 0))}isFetching(s){return r(this,g).findAll({...s,fetchStatus:"fetching"}).length}isMutating(s){return r(this,V).findAll({...s,status:"pending"}).length}getQueryData(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state.data}ensureQueryData(s){const e=this.defaultQueryOptions(s),t=r(this,g).build(this,e),i=t.state.data;return i===void 0?this.fetchQuery(s):(s.revalidateIfStale&&t.isStaleByTime(Se(e.staleTime,t))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(s){return r(this,g).findAll(s).map(({queryKey:e,state:t})=>{const i=t.data;return[e,i]})}setQueryData(s,e,t){const i=this.defaultQueryOptions({queryKey:s}),n=r(this,g).get(i.queryHash),u=n==null?void 0:n.state.data,h=_e(e,u);if(h!==void 0)return r(this,g).build(this,i).setData(h,{...t,manual:!0})}setQueriesData(s,e,t){return F.batch(()=>r(this,g).findAll(s).map(({queryKey:i})=>[i,this.setQueryData(i,e,t)]))}getQueryState(s){var t;const e=this.defaultQueryOptions({queryKey:s});return(t=r(this,g).get(e.queryHash))==null?void 0:t.state}removeQueries(s){const e=r(this,g);F.batch(()=>{e.findAll(s).forEach(t=>{e.remove(t)})})}resetQueries(s,e){const t=r(this,g);return F.batch(()=>(t.findAll(s).forEach(i=>{i.reset()}),this.refetchQueries({type:"active",...s},e)))}cancelQueries(s,e={}){const t={revert:!0,...e},i=F.batch(()=>r(this,g).findAll(s).map(n=>n.cancel(t)));return Promise.all(i).then(M).catch(M)}invalidateQueries(s,e={}){return F.batch(()=>(r(this,g).findAll(s).forEach(t=>{t.invalidate()}),(s==null?void 0:s.refetchType)==="none"?Promise.resolve():this.refetchQueries({...s,type:(s==null?void 0:s.refetchType)??(s==null?void 0:s.type)??"active"},e)))}refetchQueries(s,e={}){const t={...e,cancelRefetch:e.cancelRefetch??!0},i=F.batch(()=>r(this,g).findAll(s).filter(n=>!n.isDisabled()).map(n=>{let u=n.fetch(void 0,t);return t.throwOnError||(u=u.catch(M)),n.state.fetchStatus==="paused"?Promise.resolve():u}));return Promise.all(i).then(M)}fetchQuery(s){const e=this.defaultQueryOptions(s);e.retry===void 0&&(e.retry=!1);const t=r(this,g).build(this,e);return t.isStaleByTime(Se(e.staleTime,t))?t.fetch(e):Promise.resolve(t.state.data)}prefetchQuery(s){return this.fetchQuery(s).then(M).catch(M)}fetchInfiniteQuery(s){return s.behavior=Me(s.pages),this.fetchQuery(s)}prefetchInfiniteQuery(s){return this.fetchInfiniteQuery(s).then(M).catch(M)}ensureInfiniteQueryData(s){return s.behavior=Me(s.pages),this.ensureQueryData(s)}resumePausedMutations(){return ve.isOnline()?r(this,V).resumePausedMutations():Promise.resolve()}getQueryCache(){return r(this,g)}getMutationCache(){return r(this,V)}getDefaultOptions(){return r(this,$)}setDefaultOptions(s){o(this,$,s)}setQueryDefaults(s,e){r(this,re).set(oe(s),{queryKey:s,defaultOptions:e})}getQueryDefaults(s){const e=[...r(this,re).values()],t={};return e.forEach(i=>{ce(s,i.queryKey)&&Object.assign(t,i.defaultOptions)}),t}setMutationDefaults(s,e){r(this,ne).set(oe(s),{mutationKey:s,defaultOptions:e})}getMutationDefaults(s){const e=[...r(this,ne).values()],t={};return e.forEach(i=>{ce(s,i.mutationKey)&&Object.assign(t,i.defaultOptions)}),t}defaultQueryOptions(s){if(s._defaulted)return s;const e={...r(this,$).queries,...this.getQueryDefaults(s.queryKey),...s,_defaulted:!0};return e.queryHash||(e.queryHash=Ce(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Oe&&(e.enabled=!1),e}defaultMutationOptions(s){return s!=null&&s._defaulted?s:{...r(this,$).mutations,...(s==null?void 0:s.mutationKey)&&this.getMutationDefaults(s.mutationKey),...s,_defaulted:!0}}clear(){r(this,g).clear(),r(this,V).clear()}},g=new WeakMap,V=new WeakMap,$=new WeakMap,re=new WeakMap,ne=new WeakMap,J=new WeakMap,ae=new WeakMap,ue=new WeakMap,xe);class B{constructor(e={}){this.availableDatasets=[],this.apiUrl=e.apiUrl||"https://api.luzmo.com",this.apiVersion=e.apiVersion||"0.1.0",this.authKey=e.authKey||"",this.authToken=e.authToken||"",this.queryClient=new mt({defaultOptions:{queries:{staleTime:e.staleTime||5*60*1e3,gcTime:e.gcTime||10*60*1e3,retry:e.retry||3,retryDelay:e.retryDelay||(t=>Math.min(1e3*2**t,3e4))}}}),this.initNetworkListeners()}configure(e={}){if(e.apiVersion&&(this.apiVersion=e.apiVersion),e.apiUrl&&(this.apiUrl=e.apiUrl),e.authKey&&(this.authKey=e.authKey),e.authToken&&(this.authToken=e.authToken),e.staleTime||e.gcTime||e.retry){const t={};e.staleTime&&(t.staleTime=e.staleTime),e.gcTime&&(t.gcTime=e.gcTime),e.retry&&(t.retry=e.retry),this.queryClient.setDefaultOptions({queries:{...this.queryClient.getDefaultOptions().queries,...t}})}}initNetworkListeners(){typeof window<"u"&&window.addEventListener("online",()=>{console.warn("Network connection restored, refreshing data..."),this.refreshAll()})}getHeaders(e={}){return{"Content-Type":"application/json",...e}}async fetchApi(e,t,i={}){const n=`${this.apiUrl}/${this.apiVersion}${e}`,h={method:i.method||"POST",headers:this.getHeaders(i.headers),mode:"cors",...i};t!==void 0&&(t.key=this.authKey,t.token=this.authToken,h.body=JSON.stringify(t));try{const a=await fetch(n,h);if(!a.ok){const l=await a.json().catch(()=>null);throw a.status===401||a.status===403?new Error("Authentication failed. Please check your API token."):a.status===404?new Error(`Resource not found: ${e}`):a.status===429?new Error("Rate limit exceeded. Please try again later."):new Error((l==null?void 0:l.message)||`API request failed with status ${a.status}`)}return await a.json()}catch(a){throw console.error(`API request to ${e} failed:`,a),a instanceof Error&&(a.endpoint=e,a.timestamp=new Date().toISOString()),a}}async fetchAllDatasets(e={}){const t=e.offset||0,i=e.limit||50,n=["datasets",t,i];return await this.queryClient.fetchQuery({queryKey:n,queryFn:async()=>{const u={action:"get",version:this.apiVersion,find:{where:{type:"dataset"},limit:i,offset:t}},h=await this.fetchApi("/securable",u);return{data:(h==null?void 0:h.rows)||[],pagination:{offset:t,limit:i,total:(h==null?void 0:h.count)??0,pages:Math.ceil(((h==null?void 0:h.count)??0)/i)}}}})}async searchDatasets(e,t){if(!e)return[];const i=["datasets","search",e,t];return await this.queryClient.fetchQuery({queryKey:i,queryFn:async()=>{const n={action:"get",version:this.apiVersion,find:{where:{type:"dataset"}}};(e==null?void 0:e.length)>0&&(n.find.search={match_types:["name"],keyphrase:e}),t!=null&&t.offset&&(n.find.offset=t==null?void 0:t.offset),t!=null&&t.limit&&(n.find.limit=t==null?void 0:t.limit);const u=await this.fetchApi("/securable",n),h={data:(u==null?void 0:u.rows)||[]};return t!=null&&t.limit&&(h.pagination={offset:(t==null?void 0:t.offset)??0,limit:t==null?void 0:t.limit,total:(u==null?void 0:u.count)??0,pages:Math.ceil(((u==null?void 0:u.count)??0)/(t==null?void 0:t.limit))}),h}})}async fetchDatasetsWithColumnsAndFormulas(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=["datasets",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:{in:e}},attributes:["name","id"],include:[{model:"Column",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"],separate:!0,order:[["order","asc"]],include:[{model:"Column",attributes:["id","securable_id","hierarchy_enabled","currency_id"],as:"Joins"}]},{model:"Formula",attributes:["id","name","description","type","subtype","format","hidden","lowestLevel","expression"]}]}},n=await this.fetchApi("/securable",i);return(n==null?void 0:n.rows)||[]}})}async fetchDataset(e){if(!e)throw new Error("Dataset ID is required");const t=["dataset",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{var u;const i={action:"get",version:this.apiVersion,find:{where:{type:"dataset",id:e},attributes:["name","id"],include:[{model:"Column"},{model:"Formula"}]}},n=await this.fetchApi("/securable",i);return((u=n==null?void 0:n.rows)==null?void 0:u[0])||null}})}async fetchData(e){if(!e)throw new Error("Query is required");const t=["data",e];return await this.queryClient.fetchQuery({queryKey:t,queryFn:async()=>{const i={action:"get",version:this.apiVersion,find:{queries:[e]}},n=await this.fetchApi("/data",i);return{data:(n==null?void 0:n.data)||[],performance:(n==null?void 0:n.performance)||{}}}})}refreshAll(){this.queryClient.refetchQueries()}invalidateDatasetData(e){e?(this.queryClient.invalidateQueries({queryKey:["dataset",e]}),this.queryClient.invalidateQueries({queryKey:["columns",e]})):this.queryClient.invalidateQueries({queryKey:["datasets"]})}invalidateAll(){this.queryClient.clear()}static getInstance(e={}){return B.instance?Object.keys(e).length>0&&B.instance.configure(e):B.instance=new B(e),B.instance}async fetchDatasetsRecursive(e){if(!e||e.length===0)throw new Error("At least one dataset ID is required");const t=[...new Set(e)],i=new Set,n=new Map,u=h=>{h&&!i.has(h)&&!t.includes(h)&&t.push(h)};for(;t.length>0;){const h=[];for(;t.length>0&&h.length<50;){const a=t.shift();i.has(a)||h.push(a)}if(h.length!==0)try{(await this.fetchDatasetsWithColumnsAndFormulas(h)).forEach(l=>{const y=this.postProcessDatasetMetadata(l);i.add(y.id),this.queryClient.setQueryData(["dataset",y.id],y),(y.outgoingJoins??[]).map(c=>c.securable_id).filter(c=>c&&c!==y.id).forEach(c=>{u(c)}),n.set(y.id,y),this.availableDatasets.some(c=>c.id===y.id)||this.availableDatasets.push({id:y.id,name:y.name,columns:y.columns})})}catch(a){console.error("Error fetching datasets recursively:",a)}}return[...n.values()]}postProcessDatasetMetadata(e){var t;e.dateLoaded=new Date,e.outgoingJoins=[];for(const i of e.columns)if(((t=i.joins)==null?void 0:t.length)>0)for(const n of i.joins)e.outgoingJoins.push(n);return e}getAvailableDatasets(){return this.availableDatasets}getLinkedDatasetsIds(e){const t=this.queryClient.getQueryData(["dataset",e]);return t?(t.outgoingJoins??[]).map(i=>i.securable_id).filter(i=>i&&i!==e):[]}}const vt=B.getInstance();exports.dataBroker=vt;
|