@nside/wefa 0.1.0-rc3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/{LegalConsent-GeSaAVS1.cjs → LegalConsent-CT1w5kme.cjs} +1 -1
  2. package/dist/{LegalConsent-CJmBf_dh.js → LegalConsent-D1MwmijD.js} +2 -2
  3. package/dist/{LegalDocument-0Qeu21YK.cjs → LegalDocument-BIlRd478.cjs} +14 -14
  4. package/dist/{LegalDocument-D6q5xxka.js → LegalDocument-Cg2xX6Mz.js} +4 -4
  5. package/dist/apiClient-Bd4jmhT7.cjs +1 -0
  6. package/dist/{apiClient-BVTjfFf0.js → apiClient-WXmPkrC5.js} +16 -16
  7. package/dist/{axios-C7yNV7KF.js → axios-C8xtaJSd.js} +157 -139
  8. package/dist/{axios-BompFBxL.cjs → axios-_3J2k8TN.cjs} +6 -6
  9. package/dist/{index-9I6MBBVe.cjs → index-BLnxyq8L.cjs} +1 -1
  10. package/dist/{index-CS4hUwBJ.cjs → index-BZN-ifZE.cjs} +1 -1
  11. package/dist/{index-syJrQasA.cjs → index-CS8kqiJC.cjs} +1 -1
  12. package/dist/{index-Z_ITvhTj.js → index-DIyoXwWo.js} +1 -1
  13. package/dist/{index-Dx9O6tmw.js → index-DclCrvhX.js} +1 -1
  14. package/dist/{index-DKHhlA6W.js → index-_75ekX9o.js} +1 -1
  15. package/dist/{lib-CNCjqOo9.cjs → lib-B0OhMW6t.cjs} +4 -4
  16. package/dist/{lib-a417Oeyw.js → lib-I1PMgFxW.js} +17 -14
  17. package/dist/lib.cjs +1 -1
  18. package/dist/lib.d.ts +6 -3
  19. package/dist/lib.js +1 -1
  20. package/dist/network.cjs +1 -1
  21. package/dist/network.d.ts +2 -2
  22. package/dist/network.js +3 -3
  23. package/package.json +34 -34
  24. package/src/components/PlotlyComponent/PlotlyFromTableComponent.mdx +182 -108
  25. package/src/components/PlotlyComponent/PlotlyFromTableComponent.spec.ts +24 -17
  26. package/src/components/PlotlyComponent/PlotlyFromTableComponent.stories.ts +99 -36
  27. package/src/components/PlotlyComponent/PlotlyFromTableComponent.vue +18 -10
  28. package/src/components/TableComponent/TableComponent.spec.ts +0 -1
  29. package/src/network/typedApiClient.ts +3 -2
  30. package/src/plugins/legalConsent/views/__tests__/LegalConsent.test.ts +9 -4
  31. package/src/utils/componentRegistry.ts +0 -1
  32. package/dist/apiClient-D5dnUKXi.cjs +0 -1
@@ -20,8 +20,12 @@ const sampleTableData = [
20
20
  ]
21
21
 
22
22
  const basicConfig = {
23
- x: 'month',
24
- y: 'consumption',
23
+ data: [
24
+ {
25
+ xKey: 'month',
26
+ yKey: 'consumption',
27
+ },
28
+ ],
25
29
  layout: {
26
30
  title: 'Test Chart',
27
31
  xaxis: { title: 'Month' },
@@ -87,13 +91,15 @@ describe('PlotlyFromTableComponent', () => {
87
91
 
88
92
  it('applies trace configuration correctly', () => {
89
93
  const configWithTrace = {
90
- x: 'month',
91
- y: 'consumption',
92
- traceConfig: {
93
- type: 'bar',
94
- name: 'Monthly Consumption',
95
- marker: { color: 'blue' },
96
- },
94
+ data: [
95
+ {
96
+ xKey: 'month',
97
+ yKey: 'consumption',
98
+ type: 'bar',
99
+ name: 'Monthly Consumption',
100
+ marker: { color: 'blue' },
101
+ },
102
+ ],
97
103
  }
98
104
 
99
105
  const wrapper = mount(PlotlyFromTableComponent, {
@@ -135,8 +141,12 @@ describe('PlotlyFromTableComponent', () => {
135
141
 
136
142
  it('passes config configuration to PlotlyComponent', () => {
137
143
  const configWithPlotlyConfig = {
138
- x: 'month',
139
- y: 'consumption',
144
+ data: [
145
+ {
146
+ xKey: 'month',
147
+ yKey: 'consumption',
148
+ },
149
+ ],
140
150
  config: {
141
151
  displayModeBar: false,
142
152
  responsive: true,
@@ -161,8 +171,7 @@ describe('PlotlyFromTableComponent', () => {
161
171
 
162
172
  it('handles missing columns gracefully', () => {
163
173
  const configWithMissingColumn = {
164
- x: 'nonexistent',
165
- y: 'consumption',
174
+ data: [{ xKey: 'nonexistent', yKey: 'consumption' }],
166
175
  }
167
176
 
168
177
  const wrapper = mount(PlotlyFromTableComponent, {
@@ -221,8 +230,7 @@ describe('PlotlyFromTableComponent', () => {
221
230
 
222
231
  // Change to different columns
223
232
  const newConfig = {
224
- x: 'temperature',
225
- y: 'consumption',
233
+ data: [{ xKey: 'temperature', yKey: 'consumption' }],
226
234
  }
227
235
 
228
236
  await wrapper.setProps({ config: newConfig })
@@ -263,8 +271,7 @@ describe('PlotlyFromTableComponent', () => {
263
271
  ]
264
272
 
265
273
  const numericConfig = {
266
- x: 'x_val',
267
- y: 'y_val',
274
+ data: [{ xKey: 'x_val', yKey: 'y_val' }],
268
275
  }
269
276
 
270
277
  const wrapper = mount(PlotlyFromTableComponent, {
@@ -66,12 +66,27 @@ const timeSeriesData = [
66
66
  { timestamp: '2024-01-01T05:00:00Z', power: 1080, voltage: 232 },
67
67
  ]
68
68
 
69
+ const timeSeriesData2 = [
70
+ { timestamp: '2024-01-01T00:00:00Z', forecast: 1200, actual: 1100 },
71
+ { timestamp: '2024-01-01T01:00:00Z', forecast: 1120, actual: 1050 },
72
+ { timestamp: '2024-01-01T02:00:00Z', forecast: 1100, actual: 1250 },
73
+ { timestamp: '2024-01-01T03:00:00Z', forecast: 1050, actual: 1200 },
74
+ { timestamp: '2024-01-01T04:00:00Z', forecast: 1100, actual: 1250 },
75
+ { timestamp: '2024-01-01T05:00:00Z', forecast: 1080, actual: 1200 },
76
+ { timestamp: '2024-01-01T06:00:00Z', forecast: 1000 },
77
+ { timestamp: '2024-01-01T07:00:00Z', forecast: 1080 },
78
+ ]
79
+
69
80
  export const BasicLineChart: Story = {
70
81
  args: {
71
82
  value: energyConsumptionData,
72
83
  config: {
73
- x: 'month',
74
- y: 'consumption',
84
+ data: [
85
+ {
86
+ xKey: 'month',
87
+ yKey: 'consumption',
88
+ },
89
+ ],
75
90
  layout: {
76
91
  title: { text: 'plot.title.text', subtitle: { text: 'plot.title.subtitle' } },
77
92
  xaxis: { title: { text: 'plot.xaxis.title' } },
@@ -107,14 +122,16 @@ export const ScatterPlot: Story = {
107
122
  args: {
108
123
  value: energyConsumptionData,
109
124
  config: {
110
- x: 'temperature',
111
- y: 'consumption',
112
- traceConfig: {
113
- mode: 'markers',
114
- type: 'scatter',
115
- name: 'Temperature vs Consumption',
116
- marker: { size: 8, color: 'blue' },
117
- },
125
+ data: [
126
+ {
127
+ xKey: 'temperature',
128
+ yKey: 'consumption',
129
+ mode: 'markers',
130
+ type: 'scatter',
131
+ name: 'Temperature vs Consumption',
132
+ marker: { size: 8, color: 'blue' },
133
+ },
134
+ ],
118
135
  layout: {
119
136
  title: { text: 'Energy Consumption vs Temperature' },
120
137
  xaxis: { title: { text: 'Temperature (°C)' } },
@@ -134,13 +151,15 @@ export const BarChart: Story = {
134
151
  args: {
135
152
  value: salesData,
136
153
  config: {
137
- x: 'product',
138
- y: 'sales',
139
- traceConfig: {
140
- type: 'bar',
141
- name: 'Product Sales',
142
- marker: { color: 'green' },
143
- },
154
+ data: [
155
+ {
156
+ xKey: 'product',
157
+ yKey: 'sales',
158
+ type: 'bar',
159
+ name: 'Product Sales',
160
+ marker: { color: 'green' },
161
+ },
162
+ ],
144
163
  layout: {
145
164
  title: { text: 'Product Sales by Category' },
146
165
  xaxis: { title: { text: 'Product' } },
@@ -160,14 +179,16 @@ export const TimeSeriesChart: Story = {
160
179
  args: {
161
180
  value: timeSeriesData,
162
181
  config: {
163
- x: 'timestamp',
164
- y: 'power',
165
- traceConfig: {
166
- type: 'scatter',
167
- mode: 'lines+markers',
168
- name: 'Power Output',
169
- line: { color: 'red' },
170
- },
182
+ data: [
183
+ {
184
+ xKey: 'timestamp',
185
+ yKey: 'power',
186
+ type: 'scatter',
187
+ mode: 'lines+markers',
188
+ name: 'Power Output',
189
+ line: { color: 'red' },
190
+ },
191
+ ],
171
192
  layout: {
172
193
  title: { text: 'Power Output Over Time' },
173
194
  xaxis: {
@@ -186,22 +207,64 @@ export const TimeSeriesChart: Story = {
186
207
  },
187
208
  }
188
209
 
210
+ export const MultipleTraces: Story = {
211
+ args: {
212
+ value: timeSeriesData2,
213
+ config: {
214
+ data: [
215
+ {
216
+ xKey: 'timestamp',
217
+ yKey: 'forecast',
218
+ type: 'scatter',
219
+ mode: 'lines+markers',
220
+ name: 'Forecast',
221
+ line: { color: 'red' },
222
+ },
223
+ {
224
+ xKey: 'timestamp',
225
+ yKey: 'actual',
226
+ type: 'scatter',
227
+ mode: 'lines',
228
+ name: 'Actual',
229
+ line: { color: 'green', shape: 'spline' },
230
+ },
231
+ ],
232
+ layout: {
233
+ title: { text: 'Power Forecast and Actuals' },
234
+ xaxis: {
235
+ title: { text: 'Time' },
236
+ type: 'date',
237
+ },
238
+ yaxis: { title: { text: 'Power (W)' } },
239
+ },
240
+ },
241
+ },
242
+ play: async ({ canvasElement }) => {
243
+ const canvas = within(canvasElement)
244
+ await waitFor(() => {
245
+ expect(canvas.getByText('Power Forecast and Actuals')).toBeInTheDocument()
246
+ })
247
+ },
248
+ }
249
+
189
250
  export const CustomConfiguration: Story = {
190
251
  args: {
191
252
  value: salesData,
192
253
  config: {
193
- x: 'sales',
194
- y: 'profit',
195
- traceConfig: {
196
- type: 'scatter',
197
- mode: 'markers',
198
- name: 'Sales vs Profit',
199
- marker: {
200
- size: 12,
201
- color: 'purple',
202
- opacity: 0.7,
254
+ data: [
255
+ {
256
+ xKey: 'sales',
257
+ yKey: 'profit',
258
+ type: 'scatter',
259
+ mode: 'markers',
260
+ name: 'Sales vs Profit',
261
+ marker: {
262
+ size: 12,
263
+ color: 'purple',
264
+ opacity: 0.7,
265
+ },
203
266
  },
204
- },
267
+ ],
205
268
  layout: {
206
269
  title: { text: 'Sales vs Profit Analysis' },
207
270
  xaxis: { title: { text: 'Units Sold' } },
@@ -9,10 +9,15 @@ import PlotlyComponent from '@/components/PlotlyComponent/PlotlyComponent.vue'
9
9
  import { useI18nLib } from '@/locales'
10
10
  import { applyTranslations } from '@/utils/translations'
11
11
 
12
+ // Ideally we'd like to Omit 'x' and 'y' from DataFromTable,
13
+ // but this causes issues with optional fields coming from Data.
14
+ export type DataFromTable = {
15
+ xKey: string
16
+ yKey: string
17
+ } & Data
18
+
12
19
  export interface PlotlyFromTableComponentConfig {
13
- x: string
14
- y: string
15
- traceConfig?: Partial<Data>
20
+ data: DataFromTable[]
16
21
  layout?: Partial<Layout>
17
22
  config?: Partial<Config>
18
23
  }
@@ -60,12 +65,15 @@ const processedLayout: ComputedRef<Partial<Layout> | undefined> = computed(() =>
60
65
  )
61
66
 
62
67
  const plotlyData: ComputedRef<Data[]> = computed(() => {
63
- return [
64
- {
65
- x: value.map((row) => row[config.x]),
66
- y: value.map((row) => row[config.y]),
67
- ...(config.traceConfig ?? {}),
68
- },
69
- ] as Data[]
68
+ return config.data.map((trace) => {
69
+ const { xKey, yKey, ...other } = trace
70
+ return {
71
+ ...other,
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ x: value.map((row) => row[xKey] as any),
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
+ y: value.map((row) => row[yKey] as any),
76
+ }
77
+ })
70
78
  })
71
79
  </script>
@@ -1,4 +1,3 @@
1
- // cspell:ignore datatable
2
1
  import { describe, it, expect, beforeEach } from 'vitest'
3
2
  import { mount } from '@vue/test-utils'
4
3
  import TableComponent from './TableComponent.vue'
@@ -1,4 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /* eslint-disable jsdoc/escape-inline-tags */
2
3
  // Typed API Client, based on TanStack useQuery and useMutation
3
4
  // Integrates with OpenAPI specs using @hey-api/openapi-ts
4
5
 
@@ -16,8 +17,8 @@ import type { Ref } from 'vue'
16
17
  * Attaches the axios singleton to an OpenAPI Client/SDK,
17
18
  * autogenerated by @hey-api/openapi-ts.
18
19
  * You need to call this during application startup to have a working OpenAPI Client
19
- * E.g if you're running : npx @hey-api/openapi-ts --input .path/to/openapi.yaml --output ./src/openapi
20
- * Then you will have your generated code in @/openapi, and then you can :
20
+ * E.g., if you're running: npx @hey-api/openapi-ts --input .path/to/openapi.yaml --output ./src/openapi
21
+ * Then you will have your generated code in @/openapi, and then you can:
21
22
  * import { client } from '@/openapi/client.gen'
22
23
  * import { typedApiClient } from '@nside/wefa/network'
23
24
  * typedApiClient.setupOpenApiClient(client)
@@ -1,9 +1,14 @@
1
- import { describe, it, expect, vi, beforeEach, type MockInstance } from 'vitest'
1
+ import { describe, it, expect, vi, beforeEach } from 'vitest'
2
2
  import { mount, RouterLinkStub } from '@vue/test-utils'
3
3
  import { nextTick } from 'vue'
4
4
 
5
5
  const flushPromises = () => new Promise((resolve) => setTimeout(resolve))
6
6
 
7
+ // Minimal local type for a Vitest spy used in this file
8
+ // Avoids importing incompatible vitest types across versions and satisfies ESLint no-explicit-any
9
+ // Use the shape from vi.fn() to ensure compatibility with spies
10
+ type PushSpy = Pick<ReturnType<typeof vi.fn>, 'mock' | 'mockResolvedValue'>
11
+
7
12
  // Mock i18n util to return the key itself for easier assertions
8
13
  vi.mock('@/locales', () => ({
9
14
  useI18nLib: () => ({ t: (key: string) => key }),
@@ -24,8 +29,8 @@ vi.mock('@/plugins/legalConsent', () => ({
24
29
  }))
25
30
 
26
31
  // Mock PrimeVue toast and confirm composables
27
- const toastAddSpy: ReturnType<typeof vi.fn> = vi.fn()
28
- const confirmRequireSpy: ReturnType<typeof vi.fn> = vi.fn()
32
+ const toastAddSpy = vi.fn()
33
+ const confirmRequireSpy = vi.fn()
29
34
  vi.mock('primevue/usetoast', () => ({
30
35
  useToast: () => ({ add: (...args: unknown[]) => toastAddSpy(...args) }),
31
36
  }))
@@ -63,7 +68,7 @@ import LegalConsent from '../LegalConsent.vue'
63
68
 
64
69
  describe('LegalConsent.vue', () => {
65
70
  let router: Router
66
- let pushSpy: MockInstance
71
+ let pushSpy: PushSpy
67
72
 
68
73
  beforeEach(() => {
69
74
  acceptLegalConsentSpy.mockReset()
@@ -1,4 +1,3 @@
1
- // cspell:ignore inputtext inputnumber
2
1
  import { defineAsyncComponent } from 'vue'
3
2
 
4
3
  import type { Component } from 'vue'
@@ -1 +0,0 @@
1
- "use strict";const u=require("vue"),Y=require("./axios-BompFBxL.cjs");var Q=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},et={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},st=class{#e=et;#t=!1;setTimeoutProvider(t){process.env.NODE_ENV!=="production"&&this.#t&&t!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:t}),this.#e=t,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(t,e)}clearTimeout(t){this.#e.clearTimeout(t)}setInterval(t,e){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(t,e)}clearInterval(t){this.#e.clearInterval(t)}},T=new st;function it(t){setTimeout(t,0)}var F=typeof window>"u"||"Deno"in globalThis;function nt(){}function q(t){return typeof t=="number"&&t>=0&&t!==1/0}function rt(t,e){return Math.max(t+(e||0)-Date.now(),0)}function E(t,e){return typeof t=="function"?t(e):t}function y(t,e){return typeof t=="function"?t(e):t}function K(t){return JSON.stringify(t,(e,s)=>U(s)?Object.keys(s).sort().reduce((n,i)=>(n[i]=s[i],n),{}):s)}var ot=Object.prototype.hasOwnProperty;function P(t,e){if(t===e)return t;const s=z(t)&&z(e);if(!s&&!(U(t)&&U(e)))return e;const i=(s?t:Object.keys(t)).length,r=s?e:Object.keys(e),c=r.length,o=s?new Array(c):{};let f=0;for(let p=0;p<c;p++){const a=s?p:r[p],d=t[a],h=e[a];if(d===h){o[a]=d,(s?p<i:ot.call(t,a))&&f++;continue}if(d===null||h===null||typeof d!="object"||typeof h!="object"){o[a]=h;continue}const l=P(d,h);o[a]=l,l===d&&f++}return i===c&&f===i?t:o}function M(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(const s in t)if(t[s]!==e[s])return!1;return!0}function z(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function U(t){if(!$(t))return!1;const e=t.constructor;if(e===void 0)return!0;const s=e.prototype;return!(!$(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function $(t){return Object.prototype.toString.call(t)==="[object Object]"}function B(t,e,s){if(typeof s.structuralSharing=="function")return s.structuralSharing(t,e);if(s.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return P(t,e)}catch(n){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${s.queryHash}]: ${n}`),n}return P(t,e)}return e}function D(t,e){return typeof t=="function"?t(...e):!!t}var at=class extends Q{#e;#t;#s;constructor(){super(),this.#s=t=>{if(!F&&window.addEventListener){const e=()=>t();return window.addEventListener("visibilitychange",e,!1),()=>{window.removeEventListener("visibilitychange",e)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(e=>{typeof e=="boolean"?this.setFocused(e):this.onFocus()})}setFocused(t){this.#e!==t&&(this.#e=t,this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(e=>{e(t)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},ut=new at;function W(){let t,e;const s=new Promise((i,r)=>{t=i,e=r});s.status="pending",s.catch(()=>{});function n(i){Object.assign(s,i),delete s.resolve,delete s.reject}return s.resolve=i=>{n({status:"fulfilled",value:i}),t(i)},s.reject=i=>{n({status:"rejected",reason:i}),e(i)},s}var ct=it;function ht(){let t=[],e=0,s=o=>{o()},n=o=>{o()},i=ct;const r=o=>{e?t.push(o):i(()=>{s(o)})},c=()=>{const o=t;t=[],o.length&&i(()=>{n(()=>{o.forEach(f=>{s(f)})})})};return{batch:o=>{let f;e++;try{f=o()}finally{e--,e||c()}return f},batchCalls:o=>(...f)=>{r(()=>{o(...f)})},schedule:r,setNotifyFunction:o=>{s=o},setBatchNotifyFunction:o=>{n=o},setScheduler:o=>{i=o}}}var Z=ht(),lt=class extends Q{#e=!0;#t;#s;constructor(){super(),this.#s=t=>{if(!F&&window.addEventListener){const e=()=>t(!0),s=()=>t(!1);return window.addEventListener("online",e,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",e),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(t){this.#s=t,this.#t?.(),this.#t=t(this.setOnline.bind(this))}setOnline(t){this.#e!==t&&(this.#e=t,this.listeners.forEach(s=>{s(t)}))}isOnline(){return this.#e}},ft=new lt;function dt(t){return(t??"online")==="online"?ft.isOnline():!0}function pt(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:dt(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}var bt=class extends Q{constructor(t,e){super(),this.options=e,this.#e=t,this.#a=null,this.#o=W(),this.bindMethods(),this.setOptions(e)}#e;#t=void 0;#s=void 0;#i=void 0;#n;#r;#o;#a;#b;#f;#d;#c;#h;#u;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),H(this.#t,this.options)?this.#l():this.updateResult(),this.#g())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return x(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return x(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#O(),this.#w(),this.#t.removeObserver(this)}setOptions(t){const e=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof y(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#R(),this.#t.setOptions(this.options),e._defaulted&&!M(this.options,e)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const n=this.hasListeners();n&&J(this.#t,s,this.options,e)&&this.#l(),this.updateResult(),n&&(this.#t!==s||y(this.options.enabled,this.#t)!==y(e.enabled,this.#t)||E(this.options.staleTime,this.#t)!==E(e.staleTime,this.#t))&&this.#v();const i=this.#y();n&&(this.#t!==s||y(this.options.enabled,this.#t)!==y(e.enabled,this.#t)||i!==this.#u)&&this.#m(i)}getOptimisticResult(t){const e=this.#e.getQueryCache().build(this.#e,t),s=this.createResult(e,t);return yt(this,s)&&(this.#i=s,this.#r=this.options,this.#n=this.#t.state),s}getCurrentResult(){return this.#i}trackResult(t,e){return new Proxy(t,{get:(s,n)=>(this.trackProp(n),e?.(n),n==="promise"&&!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(s,n))})}trackProp(t){this.#p.add(t)}getCurrentQuery(){return this.#t}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const e=this.#e.defaultQueryOptions(t),s=this.#e.getQueryCache().build(this.#e,e);return s.fetch().then(()=>this.createResult(s,e))}fetch(t){return this.#l({...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#l(t){this.#R();let e=this.#t.fetch(this.options,t);return t?.throwOnError||(e=e.catch(nt)),e}#v(){this.#O();const t=E(this.options.staleTime,this.#t);if(F||this.#i.isStale||!q(t))return;const s=rt(this.#i.dataUpdatedAt,t)+1;this.#c=T.setTimeout(()=>{this.#i.isStale||this.updateResult()},s)}#y(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#m(t){this.#w(),this.#u=t,!(F||y(this.options.enabled,this.#t)===!1||!q(this.#u)||this.#u===0)&&(this.#h=T.setInterval(()=>{(this.options.refetchIntervalInBackground||ut.isFocused())&&this.#l()},this.#u))}#g(){this.#v(),this.#m(this.#y())}#O(){this.#c&&(T.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#h&&(T.clearInterval(this.#h),this.#h=void 0)}createResult(t,e){const s=this.#t,n=this.options,i=this.#i,r=this.#n,c=this.#r,f=t!==s?t.state:this.#s,{state:p}=t;let a={...p},d=!1,h;if(e._optimisticResults){const b=this.hasListeners(),I=!b&&H(t,e),R=b&&J(t,s,e,n);(I||R)&&(a={...a,...pt(p.data,t.options)}),e._optimisticResults==="isRestoring"&&(a.fetchStatus="idle")}let{error:l,errorUpdatedAt:g,status:v}=a;h=a.data;let S=!1;if(e.placeholderData!==void 0&&h===void 0&&v==="pending"){let b;i?.isPlaceholderData&&e.placeholderData===c?.placeholderData?(b=i.data,S=!0):b=typeof e.placeholderData=="function"?e.placeholderData(this.#d?.state.data,this.#d):e.placeholderData,b!==void 0&&(v="success",h=B(i?.data,b,e),d=!0)}if(e.select&&h!==void 0&&!S)if(i&&h===r?.data&&e.select===this.#b)h=this.#f;else try{this.#b=e.select,h=e.select(h),h=B(i?.data,h,e),this.#f=h,this.#a=null}catch(b){this.#a=b}this.#a&&(l=this.#a,h=this.#f,g=Date.now(),v="error");const O=a.fetchStatus==="fetching",w=v==="pending",L=v==="error",A=w&&O,V=h!==void 0,m={status:v,fetchStatus:a.fetchStatus,isPending:w,isSuccess:v==="success",isError:L,isInitialLoading:A,isLoading:A,data:h,dataUpdatedAt:a.dataUpdatedAt,error:l,errorUpdatedAt:g,failureCount:a.fetchFailureCount,failureReason:a.fetchFailureReason,errorUpdateCount:a.errorUpdateCount,isFetched:a.dataUpdateCount>0||a.errorUpdateCount>0,isFetchedAfterMount:a.dataUpdateCount>f.dataUpdateCount||a.errorUpdateCount>f.errorUpdateCount,isFetching:O,isRefetching:O&&!w,isLoadingError:L&&!V,isPaused:a.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:L&&V,isStale:_(t,e),refetch:this.refetch,promise:this.#o,isEnabled:y(e.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const b=j=>{m.status==="error"?j.reject(m.error):m.data!==void 0&&j.resolve(m.data)},I=()=>{const j=this.#o=m.promise=W();b(j)},R=this.#o;switch(R.status){case"pending":t.queryHash===s.queryHash&&b(R);break;case"fulfilled":(m.status==="error"||m.data!==R.value)&&I();break;case"rejected":(m.status!=="error"||m.error!==R.reason)&&I();break}}return m}updateResult(){const t=this.#i,e=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#r=this.options,this.#n.data!==void 0&&(this.#d=this.#t),M(e,t))return;this.#i=e;const s=()=>{if(!t)return!0;const{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!this.#p.size)return!0;const r=new Set(i??this.#p);return this.options.throwOnError&&r.add("error"),Object.keys(this.#i).some(c=>{const o=c;return this.#i[o]!==t[o]&&r.has(o)})};this.#S({listeners:s()})}#R(){const t=this.#e.getQueryCache().build(this.#e,this.options);if(t===this.#t)return;const e=this.#t;this.#t=t,this.#s=t.state,this.hasListeners()&&(e?.removeObserver(this),t.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#g()}#S(t){Z.batch(()=>{t.listeners&&this.listeners.forEach(e=>{e(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function vt(t,e){return y(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&e.retryOnMount===!1)}function H(t,e){return vt(t,e)||t.state.data!==void 0&&x(t,e,e.refetchOnMount)}function x(t,e,s){if(y(e.enabled,t)!==!1&&E(e.staleTime,t)!=="static"){const n=typeof s=="function"?s(t):s;return n==="always"||n!==!1&&_(t,e)}return!1}function J(t,e,s,n){return(t!==e||y(n.enabled,t)===!1)&&(!s.suspense||t.state.status!=="error")&&_(t,s)}function _(t,e){return y(e.enabled,t)!==!1&&t.isStaleByTime(E(e.staleTime,t))}function yt(t,e){return!M(t.getCurrentResult(),e)}function mt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var gt=class extends Q{#e;#t=void 0;#s;#i;constructor(t,e){super(),this.#e=t,this.setOptions(e),this.bindMethods(),this.#n()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){const e=this.options;this.options=this.#e.defaultMutationOptions(t),M(this.options,e)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),e?.mutationKey&&this.options.mutationKey&&K(e.mutationKey)!==K(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(t){this.#n(),this.#r(t)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#n(),this.#r()}mutate(t,e){return this.#i=e,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(t)}#n(){const t=this.#s?.state??mt();this.#t={...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset}}#r(t){Z.batch(()=>{if(this.#i&&this.hasListeners()){const e=this.#t.variables,s=this.#t.context,n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};t?.type==="success"?(this.#i.onSuccess?.(t.data,e,s,n),this.#i.onSettled?.(t.data,null,e,s,n)):t?.type==="error"&&(this.#i.onError?.(t.error,e,s,n),this.#i.onSettled?.(void 0,t.error,e,s,n))}this.listeners.forEach(e=>{e(this.#t)})})}},Ot="VUE_QUERY_CLIENT";function wt(t){const e=t?`:${t}`:"";return`${Ot}${e}`}function N(t,e){Object.keys(t).forEach(s=>{t[s]=e[s]})}function k(t,e,s="",n=0){if(e){const i=e(t,s,n);if(i===void 0&&u.isRef(t)||i!==void 0)return i}if(Array.isArray(t))return t.map((i,r)=>k(i,e,String(r),n+1));if(typeof t=="object"&&St(t)){const i=Object.entries(t).map(([r,c])=>[r,k(c,e,r,n+1)]);return Object.fromEntries(i)}return t}function Rt(t,e){return k(t,e)}function C(t,e=!1){return Rt(t,(s,n,i)=>{if(i===1&&n==="queryKey")return C(s,!0);if(e&&Et(s))return C(s(),e);if(u.isRef(s))return C(u.unref(s),e)})}function St(t){if(Object.prototype.toString.call(t)!=="[object Object]")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Et(t){return typeof t=="function"}function X(t=""){if(!u.hasInjectionContext())throw new Error("vue-query hooks can only be used inside setup() function or functions that support injection context.");const e=wt(t),s=u.inject(e);if(!s)throw new Error("No 'queryClient' found in Vue context, use 'VueQueryPlugin' to properly initialize the library.");return s}function Ct(t,e,s){process.env.NODE_ENV==="development"&&(u.getCurrentScope()||console.warn('vue-query composable like "useQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.'));const n=X(),i=u.computed(()=>{const l=C(e);typeof l.enabled=="function"&&(l.enabled=l.enabled());const g=n.defaultQueryOptions(l);return g._optimisticResults=n.isRestoring?.value?"isRestoring":"optimistic",g}),r=new t(n,i.value),c=i.value.shallow?u.shallowReactive(r.getCurrentResult()):u.reactive(r.getCurrentResult());let o=()=>{};n.isRestoring&&u.watch(n.isRestoring,l=>{l||(o(),o=r.subscribe(g=>{N(c,g)}))},{immediate:!0});const f=()=>{r.setOptions(i.value),N(c,r.getCurrentResult())};u.watch(i,f),u.onScopeDispose(()=>{o()});const p=(...l)=>(f(),c.refetch(...l)),a=()=>new Promise((l,g)=>{let v=()=>{};const S=()=>{if(i.value.enabled!==!1){r.setOptions(i.value);const O=r.getOptimisticResult(i.value);O.isStale?(v(),r.fetchOptimistic(i.value).then(l,w=>{D(i.value.throwOnError,[w,r.getCurrentQuery()])?g(w):l(r.getCurrentResult())})):(v(),l(O))}};S(),v=u.watch(i,S)});u.watch(()=>c.error,l=>{if(c.isError&&!c.isFetching&&D(i.value.throwOnError,[l,r.getCurrentQuery()]))throw l});const d=i.value.shallow?u.shallowReadonly(c):u.readonly(c),h=u.toRefs(d);for(const l in c)typeof c[l]=="function"&&(h[l]=c[l]);return h.suspense=a,h.refetch=p,h}function G(t,e){return Ct(bt,t)}function tt(t,e){process.env.NODE_ENV==="development"&&(u.getCurrentScope()||console.warn('vue-query composable like "useQuery()" should only be used inside a "setup()" function or a running effect scope. They might otherwise lead to memory leaks.'));const s=X(),n=u.computed(()=>s.defaultMutationOptions(C(t))),i=new gt(s,n.value),r=n.value.shallow?u.shallowReactive(i.getCurrentResult()):u.reactive(i.getCurrentResult()),c=i.subscribe(a=>{N(r,a)}),o=(a,d)=>{i.mutate(a,d).catch(()=>{})};u.watch(n,()=>{i.setOptions(n.value)}),u.onScopeDispose(()=>{c()});const f=n.value.shallow?u.shallowReadonly(r):u.readonly(r),p=u.toRefs(f);return u.watch(()=>r.error,a=>{if(a&&D(n.value.throwOnError,[a]))throw a}),{...p,mutate:o,mutateAsync:r.mutate,reset:r.reset}}function It(t,e){return G({queryKey:[t],queryFn:async()=>t.value?(await Y.axiosInstance.get(t.value)).data:void 0,enabled:()=>!!t.value,...e})}function jt(t,e){return tt({mutationFn:async s=>t.value?(await Y.axiosInstance.post(t.value,s)).data:void 0,...e})}const Tt={query:It,mutation:jt};exports.apiClient=Tt;exports.useMutation=tt;exports.useQuery=G;