@luzmo/analytics-components-kit 1.0.1-alpha.84 → 1.0.1-alpha.85

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 (237) hide show
  1. package/angular/components/droppable-slot.component.ts +2 -2
  2. package/angular/esm/components/droppable-slot.component.d.ts +2 -2
  3. package/angular/esm/types.d.ts +1 -1
  4. package/angular/types.ts +2 -2
  5. package/components/ai-chat-messages-container/index.cjs +1 -1
  6. package/components/ai-chat-messages-container/index.js +2 -2
  7. package/components/ai-interaction-textarea/index.cjs +50 -0
  8. package/components/ai-interaction-textarea/index.d.ts +1 -1
  9. package/components/ai-interaction-textarea/index.js +152 -0
  10. package/components/area-chart-options.config-Bl8bhhOo.cjs +20 -0
  11. package/components/{area-chart-options.config-_J0sG4NF.js → area-chart-options.config-u8itidsi.js} +14 -26
  12. package/components/bar-chart-options.config-CePAqM83.cjs +20 -0
  13. package/components/{bar-chart-options.config-D1mb5TDl.js → bar-chart-options.config-DIirbAJ0.js} +21 -35
  14. package/components/box-plot-options.config-BVNrV2eD.cjs +20 -0
  15. package/components/{box-plot-options.config-xu_i6ms7.js → box-plot-options.config-BWROiguA.js} +52 -88
  16. package/components/{bubble-chart-options.config-BacgXkJ_.js → bubble-chart-options.config-4QD8VPhU.js} +9 -18
  17. package/components/bubble-chart-options.config-BDgOe3GQ.cjs +20 -0
  18. package/components/{bullet-chart-options.config-CDPpX1yc.js → bullet-chart-options.config-3bH7uekx.js} +1 -1
  19. package/components/{bullet-chart-options.config-DfS4Bwds.cjs → bullet-chart-options.config-tWb6Fio-.cjs} +1 -1
  20. package/components/calculate-data-item-icon-C8CbsMQf.js +139 -0
  21. package/components/{calculate-data-item-icon-DjW1_RI1.cjs → calculate-data-item-icon-CX4VW9Km.cjs} +1 -1
  22. package/components/{choropleth-map-options.config-B_W9-rhe.js → choropleth-map-options.config-CMxx3ORp.js} +63 -84
  23. package/components/choropleth-map-options.config-CWJACFd0.cjs +20 -0
  24. package/components/circular-gauge-options.config-BMxgq3zH.cjs +20 -0
  25. package/components/{circular-gauge-options.config-DAIjz4Rl.js → circular-gauge-options.config-DhIKn44k.js} +23 -36
  26. package/components/{color-DuJ4-73S.js → color-B7m0j8lX.js} +941 -950
  27. package/components/color-Czp4Im5q.cjs +20 -0
  28. package/components/{color-range-utils-Bvo9sm5A.js → color-range-utils-BSfqtB3A.js} +31 -32
  29. package/components/color-range-utils-DYYR-iwx.cjs +20 -0
  30. package/components/column-chart-options.config-BV9R3ssH.cjs +20 -0
  31. package/components/{column-chart-options.config-B5SjBVdy.js → column-chart-options.config-D5-yR7iq.js} +27 -37
  32. package/components/conditional-number-options.config-Co099Qfm.cjs +20 -0
  33. package/components/{conditional-number-options.config-BCEpSK9J.js → conditional-number-options.config-DPYsdML5.js} +24 -40
  34. package/components/dataset-selector-list/index.cjs +11 -11
  35. package/components/dataset-selector-list/index.js +65 -69
  36. package/components/dataset-selector-row/dataset-selector-row.d.ts +1 -0
  37. package/components/dataset-selector-row/index.cjs +79 -0
  38. package/components/dataset-selector-row/index.d.ts +1 -1
  39. package/components/dataset-selector-row/index.js +209 -0
  40. package/components/{date-comparison-filter-options.config-JA_yYpJa.js → date-comparison-filter-options.config-CSwGyuBg.js} +3 -6
  41. package/components/{date-comparison-filter-options.config-DAVncmi0.cjs → date-comparison-filter-options.config-QaoWaFUn.cjs} +1 -1
  42. package/components/{date-filter-options.config-DBRxlTWy.js → date-filter-options.config-BTVyHRkp.js} +3 -6
  43. package/components/{date-filter-options.config-CWPMtA18.cjs → date-filter-options.config-n-zhWaYa.cjs} +1 -1
  44. package/components/display-settings/index.cjs +1 -1
  45. package/components/display-settings/index.js +1 -1
  46. package/components/display-settings-binning/index.cjs +5 -5
  47. package/components/display-settings-binning/index.js +29 -30
  48. package/components/display-settings-datetime/index.cjs +29 -29
  49. package/components/display-settings-datetime/index.js +112 -120
  50. package/components/display-settings-grand-totals/index.cjs +4 -4
  51. package/components/display-settings-grand-totals/index.js +23 -24
  52. package/components/display-settings-numeric/index.cjs +48 -48
  53. package/components/display-settings-numeric/index.js +194 -211
  54. package/components/display-settings-period-over-period/index.cjs +16 -16
  55. package/components/display-settings-period-over-period/index.js +91 -97
  56. package/components/{donut-chart-options.config-BulUEiaH.js → donut-chart-options.config-3ZqX8Cbb.js} +21 -37
  57. package/components/donut-chart-options.config-BQyPgnC9.cjs +20 -0
  58. package/components/draggable-data-item/index.cjs +8 -8
  59. package/components/draggable-data-item/index.js +44 -45
  60. package/components/draggable-data-item-level/index.cjs +11 -11
  61. package/components/draggable-data-item-level/index.js +89 -92
  62. package/components/{dropdown-filter-options.config-D9dvPypF.js → dropdown-filter-options.config-CGJTtgAX.js} +7 -10
  63. package/components/{dropdown-filter-options.config-DS-MORmq.cjs → dropdown-filter-options.config-DJvfCTk7.cjs} +1 -1
  64. package/components/droppable-slot/droppable-slot.d.ts +2 -2
  65. package/components/droppable-slot/index.cjs +20 -20
  66. package/components/droppable-slot/index.js +167 -181
  67. package/components/edit-item/index.cjs +9 -9
  68. package/components/edit-item/index.js +116 -119
  69. package/components/edit-option/index.cjs +1 -1
  70. package/components/edit-option/index.js +1 -1
  71. package/components/edit-option-action-button-group/index.cjs +8 -8
  72. package/components/edit-option-action-button-group/index.js +52 -53
  73. package/components/{edit-option-base-DIc7iC-b.js → edit-option-base-Bh29-Cak.js} +1 -1
  74. package/components/{edit-option-base-VhTih9T1.cjs → edit-option-base-tFr8Qg2B.cjs} +1 -1
  75. package/components/edit-option-color-palette-picker/index.cjs +1 -1
  76. package/components/edit-option-color-palette-picker/index.js +1 -1
  77. package/components/edit-option-color-picker/index.cjs +1 -1
  78. package/components/edit-option-color-picker/index.js +1 -1
  79. package/components/edit-option-color-range/index.cjs +19 -19
  80. package/components/edit-option-color-range/index.js +106 -117
  81. package/components/edit-option-multi-language-field/index.cjs +3 -3
  82. package/components/edit-option-multi-language-field/index.js +26 -27
  83. package/components/edit-option-number-field/index.cjs +1 -1
  84. package/components/edit-option-number-field/index.js +1 -1
  85. package/components/edit-option-picker/index.cjs +5 -5
  86. package/components/edit-option-picker/index.js +7 -7
  87. package/components/edit-option-position-picker/index.cjs +4 -4
  88. package/components/edit-option-position-picker/index.js +21 -25
  89. package/components/edit-option-positions-number-field/index.cjs +9 -9
  90. package/components/edit-option-positions-number-field/index.js +76 -81
  91. package/components/edit-option-radio-button-group/index.cjs +6 -6
  92. package/components/edit-option-radio-button-group/index.js +21 -22
  93. package/components/edit-option-slider/index.cjs +1 -1
  94. package/components/edit-option-slider/index.js +1 -1
  95. package/components/edit-option-switch/index.cjs +1 -1
  96. package/components/edit-option-switch/index.js +1 -1
  97. package/components/edit-option-text-field/index.cjs +2 -2
  98. package/components/edit-option-text-field/index.js +22 -23
  99. package/components/en--a5SfjnM.cjs +20 -0
  100. package/components/en-CtCctD2c.js +1483 -0
  101. package/components/{en-GB-DG6uS3sM.cjs → en-GB-CXVKFWyH.cjs} +1 -1
  102. package/components/{en-GB-CEHEs8F2.js → en-GB-CbNfyZMo.js} +1 -1
  103. package/components/{evolution-number-options.config-DzkfeoIN.js → evolution-number-options.config-BIPO_4n3.js} +11 -14
  104. package/components/{evolution-number-options.config-BgIZY4gQ.cjs → evolution-number-options.config-Bc9eKYnn.cjs} +1 -1
  105. package/components/{extrapolate-color-0j_AeYkz.cjs → extrapolate-color-C0n1UDs-.cjs} +1 -1
  106. package/components/{extrapolate-color-CC9CURf6.js → extrapolate-color-v1PimdQr.js} +1 -1
  107. package/components/filter-data-item-picker/index.cjs +7 -7
  108. package/components/filter-data-item-picker/index.js +85 -86
  109. package/components/filter-expression-picker/index.cjs +1 -1
  110. package/components/filter-expression-picker/index.js +1 -1
  111. package/components/filter-item/index.cjs +6 -6
  112. package/components/filter-item/index.js +109 -119
  113. package/components/filter-value-picker/index.cjs +2 -2
  114. package/components/filter-value-picker/index.js +34 -36
  115. package/components/filter-value-picker-datetime/index.cjs +8 -8
  116. package/components/filter-value-picker-datetime/index.js +56 -71
  117. package/components/filter-value-picker-hierarchy/index.cjs +12 -12
  118. package/components/filter-value-picker-hierarchy/index.js +113 -124
  119. package/components/filter-value-picker-numeric/index.cjs +8 -8
  120. package/components/filter-value-picker-numeric/index.js +101 -110
  121. package/components/{focusable-DCIFkpiW.js → focusable-BS2pbY7w.js} +24 -26
  122. package/components/focusable-QLh-LlNt.cjs +20 -0
  123. package/components/{funnel-chart-options.config-C_VjTOvD.js → funnel-chart-options.config-CrJy2U7_.js} +5 -20
  124. package/components/funnel-chart-options.config-DrP4AFgk.cjs +20 -0
  125. package/components/{get-css-variable-DLiZYZEi.cjs → get-css-variable-CuDaWSjr.cjs} +2 -2
  126. package/components/{get-css-variable-YlLiVgo8.js → get-css-variable-DEf4GhTH.js} +4 -4
  127. package/components/grid/index.cjs +46 -46
  128. package/components/grid/index.js +2612 -1873
  129. package/components/heat-map-options.config-CIHnPdYE.cjs +20 -0
  130. package/components/{heat-map-options.config-BnLWe8jS.js → heat-map-options.config-CmL87j1j.js} +35 -41
  131. package/components/{heat-table-options.config-CUsDdgUr.js → heat-table-options.config-BrCYAgYD.js} +60 -88
  132. package/components/heat-table-options.config-DTlZRc_i.cjs +20 -0
  133. package/components/helpers-9I0oLoUB.cjs +20 -0
  134. package/components/helpers-bR8Ibjqh.js +79 -0
  135. package/components/{hexbin-map-options.config-F-7uCqxb.js → hexbin-map-options.config-BguV1w8q.js} +20 -38
  136. package/components/hexbin-map-options.config-CKnn3VAB.cjs +20 -0
  137. package/components/{index-Do7O9azB.js → index-3WsfvkZF.js} +112 -123
  138. package/components/{index-PMDgRSzR.js → index-BDFBUGBc.js} +94 -104
  139. package/components/index-BGb_wRRW.js +1766 -0
  140. package/components/{index-BPNsFiyq.cjs → index-BNAmjOkm.cjs} +4 -4
  141. package/components/index-BUal0r_D.cjs +121 -0
  142. package/components/index-D1Y5TRsH.cjs +20 -0
  143. package/components/index-DvkzMbLt.cjs +249 -0
  144. package/components/{index-CdIUfo-L.js → index-haa7WNrl.js} +453 -481
  145. package/components/index.cjs +1 -60
  146. package/components/index.js +102 -281
  147. package/components/item-options-configs.cjs +1 -1
  148. package/components/item-options-configs.js +37 -37
  149. package/components/{line-chart-options.config-DB3IsXXr.js → line-chart-options.config-BhirTGqD.js} +13 -28
  150. package/components/line-chart-options.config-Cqwou5u6.cjs +20 -0
  151. package/components/{localize-r7ALOUy_.cjs → localize-C4zNlrwK.cjs} +1 -1
  152. package/components/{localize-BX7q0S0M.js → localize-CcDpq940.js} +10 -10
  153. package/components/{marker-map-options.config-DPJ955tt.js → marker-map-options.config-Bx17jmiq.js} +1 -1
  154. package/components/{marker-map-options.config-_FYZzRwA.cjs → marker-map-options.config-CvhCylSC.cjs} +1 -1
  155. package/components/{pivot-table-options.config-DNK_AIG7.js → pivot-table-options.config-CFc7y0IT.js} +15 -24
  156. package/components/pivot-table-options.config-uZDAertf.cjs +20 -0
  157. package/components/{pyramid-chart-options.config-CcVMatYx.js → pyramid-chart-options.config-2Waxb11l.js} +29 -43
  158. package/components/pyramid-chart-options.config-DoGfEvzU.cjs +20 -0
  159. package/components/{radar-chart-options.config-CUZn_3Fd.js → radar-chart-options.config-CPN5fOl8.js} +11 -23
  160. package/components/radar-chart-options.config-CtNUMN1l.cjs +20 -0
  161. package/components/{regular-table-options.config-BoLZsBry.js → regular-table-options.config-CFKCJQK1.js} +17 -23
  162. package/components/{regular-table-options.config-DTx3RTnS.cjs → regular-table-options.config-YRuoijIk.cjs} +1 -1
  163. package/components/route-map-options.config-CVTk5RVL.cjs +20 -0
  164. package/components/{route-map-options.config-CN86T7c0.js → route-map-options.config-CyolTJfK.js} +87 -109
  165. package/components/{sankey-diagram-options.config-RFB83YLZ.cjs → sankey-diagram-options.config-D7OSvSqm.cjs} +1 -1
  166. package/components/{sankey-diagram-options.config-tVLKy_Zn.js → sankey-diagram-options.config-Ldjk84ro.js} +7 -10
  167. package/components/scatter-plot-options.config-5gN7pMTm.cjs +20 -0
  168. package/components/{scatter-plot-options.config-Corlzno1.js → scatter-plot-options.config-CfxEfkQ1.js} +56 -86
  169. package/components/{search-filter-options.config-BE3JhR-F.js → search-filter-options.config-C0syQmP4.js} +3 -6
  170. package/components/{search-filter-options.config-BCaDlYqZ.cjs → search-filter-options.config-Oqco9BKj.cjs} +1 -1
  171. package/components/{set-locale-B-Tz2sdI.js → set-locale-nv7fWEtl.js} +1 -8
  172. package/components/slicer-filter-options.config-CrusP6a0.cjs +20 -0
  173. package/components/{slicer-filter-options.config-3JZZcw5C.js → slicer-filter-options.config-DmOe3440.js} +9 -18
  174. package/components/{slider-filter-options.config-DH4SS8wH.js → slider-filter-options.config-B1M8RcDs.js} +1 -1
  175. package/components/{slider-filter-options.config-_8Z2zKmU.cjs → slider-filter-options.config-k45I-t6G.cjs} +1 -1
  176. package/components/slot-contents-picker/index.cjs +33 -33
  177. package/components/slot-contents-picker/index.js +194 -205
  178. package/components/slot-menu/index.cjs +12 -12
  179. package/components/slot-menu/index.js +171 -184
  180. package/components/slot-menu-list/index.cjs +3 -3
  181. package/components/slot-menu-list/index.js +97 -103
  182. package/components/speedometer-chart-options.config-B4ceg_qI.cjs +20 -0
  183. package/components/{speedometer-chart-options.config-SL581yOa.js → speedometer-chart-options.config-CzOmuEF8.js} +31 -53
  184. package/components/spike-map-options.config-BkkDqb4g.cjs +20 -0
  185. package/components/{spike-map-options.config-C5KewecZ.js → spike-map-options.config-Cbt1YUw6.js} +91 -122
  186. package/components/{sunburst-chart-options.config-AbNjWS6t.cjs → sunburst-chart-options.config-Yrxc2i57.cjs} +1 -1
  187. package/components/{sunburst-chart-options.config-CNauGQJv.js → sunburst-chart-options.config-_dyLQxPJ.js} +9 -20
  188. package/components/{symbol-map-options.config-DdDA4aa7.js → symbol-map-options.config-BORL1NSU.js} +11 -20
  189. package/components/symbol-map-options.config-NpBKm64d.cjs +20 -0
  190. package/components/{treemap-chart-options.config-D5AJaF_u.js → treemap-chart-options.config-B9i9qIm_.js} +20 -37
  191. package/components/treemap-chart-options.config-x4J54WSw.cjs +20 -0
  192. package/components/utils.cjs +1 -1
  193. package/components/utils.js +64 -65
  194. package/components/{video-options.config-CGsDTwHc.cjs → video-options.config-B0asgYt8.cjs} +1 -1
  195. package/components/{video-options.config-Dk36zJ1B.js → video-options.config-UX-9MDfS.js} +7 -10
  196. package/components/{wordcloud-chart-options.config-vGfCW8kE.cjs → wordcloud-chart-options.config-BKtJT8Va.cjs} +1 -1
  197. package/components/{wordcloud-chart-options.config-w2NUIWVA.js → wordcloud-chart-options.config-BoB_KuhA.js} +4 -7
  198. package/custom-elements.json +22 -2
  199. package/index.d.ts +1 -0
  200. package/package.json +5 -5
  201. package/types.d.ts +1 -1
  202. package/components/area-chart-options.config-C7sMAHco.cjs +0 -20
  203. package/components/bar-chart-options.config-DcxEkOT5.cjs +0 -20
  204. package/components/box-plot-options.config-SrrbDEYW.cjs +0 -20
  205. package/components/bubble-chart-options.config-Ihn6eVQI.cjs +0 -20
  206. package/components/calculate-data-item-icon-DZDqb3xu.js +0 -139
  207. package/components/choropleth-map-options.config-ZW8yoZH2.cjs +0 -20
  208. package/components/circular-gauge-options.config-msZ4mfpN.cjs +0 -20
  209. package/components/color-B6LaL8qz.cjs +0 -20
  210. package/components/color-range-utils-C5yXW7ZC.cjs +0 -20
  211. package/components/column-chart-options.config-BjDvA7i9.cjs +0 -20
  212. package/components/conditional-number-options.config-DgzUo0xi.cjs +0 -20
  213. package/components/donut-chart-options.config-tNpqBZfR.cjs +0 -20
  214. package/components/en-BKBhKBXY.cjs +0 -20
  215. package/components/en-BOTjhwEc.js +0 -1488
  216. package/components/focusable-B3E_hQmm.cjs +0 -20
  217. package/components/funnel-chart-options.config-D7H7gFcx.cjs +0 -20
  218. package/components/heat-map-options.config-DVH-Bb5-.cjs +0 -20
  219. package/components/heat-table-options.config-B12JEYnp.cjs +0 -20
  220. package/components/helpers-DXQwEH1P.cjs +0 -20
  221. package/components/helpers-v1bPALRP.js +0 -91
  222. package/components/hexbin-map-options.config-DZERRhM8.cjs +0 -20
  223. package/components/index-BPN3bG9X.js +0 -1733
  224. package/components/index-CQ9ck-BO.cjs +0 -249
  225. package/components/index-CXn67vdn.cjs +0 -121
  226. package/components/index-cfj52IbK.cjs +0 -20
  227. package/components/line-chart-options.config-DSugoe0t.cjs +0 -20
  228. package/components/pivot-table-options.config-BiJXKSFR.cjs +0 -20
  229. package/components/pyramid-chart-options.config-C4zbFS26.cjs +0 -20
  230. package/components/radar-chart-options.config-EqQu6PTh.cjs +0 -20
  231. package/components/route-map-options.config-D7NJePTu.cjs +0 -20
  232. package/components/scatter-plot-options.config-CFfGJXsV.cjs +0 -20
  233. package/components/slicer-filter-options.config-DNI-XevE.cjs +0 -20
  234. package/components/speedometer-chart-options.config-BX9LTQBH.cjs +0 -20
  235. package/components/spike-map-options.config-DoBFXPmN.cjs +0 -20
  236. package/components/symbol-map-options.config-m-lwLTtu.cjs +0 -20
  237. package/components/treemap-chart-options.config-C0Q9aQ1Z.cjs +0 -20
@@ -1,1733 +0,0 @@
1
- /*! * A kit of modern Luzmo Web Components for analytics in your web application.
2
- *
3
- * Copyright © 2025 Luzmo
4
- * All rights reserved.
5
- * Luzmo web components (“Luzmo Web Components”)
6
- * must be used according to the Luzmo Terms of Service.
7
- * This license allows users with a current active Luzmo account
8
- * to use the Luzmo Web Components. This license terminates
9
- * automatically if a user no longer has an active Luzmo account.
10
- * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
11
- *
12
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
- * SOFTWARE.
19
- * */
20
- var Fe = (s) => {
21
- throw TypeError(s);
22
- };
23
- var be = (s, e, t) => e.has(s) || Fe("Cannot " + t);
24
- 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);
25
- var pe = (s, e, t, i) => ({
26
- set _(n) {
27
- o(s, e, n, t);
28
- },
29
- get _() {
30
- return r(s, e, i);
31
- }
32
- });
33
- var ge = class {
34
- constructor() {
35
- this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
36
- }
37
- subscribe(s) {
38
- return this.listeners.add(s), this.onSubscribe(), () => {
39
- this.listeners.delete(s), this.onUnsubscribe();
40
- };
41
- }
42
- hasListeners() {
43
- return this.listeners.size > 0;
44
- }
45
- onSubscribe() {
46
- }
47
- onUnsubscribe() {
48
- }
49
- }, we = typeof window > "u" || "Deno" in globalThis;
50
- function M() {
51
- }
52
- function ze(s, e) {
53
- return typeof s == "function" ? s(e) : s;
54
- }
55
- function Be(s) {
56
- return typeof s == "number" && s >= 0 && s !== 1 / 0;
57
- }
58
- function We(s, e) {
59
- return Math.max(s + (e || 0) - Date.now(), 0);
60
- }
61
- function Se(s, e) {
62
- return typeof s == "function" ? s(e) : s;
63
- }
64
- function Xe(s, e) {
65
- return typeof s == "function" ? s(e) : s;
66
- }
67
- function De(s, e) {
68
- const {
69
- type: t = "all",
70
- exact: i,
71
- fetchStatus: n,
72
- predicate: u,
73
- queryKey: h,
74
- stale: a
75
- } = s;
76
- if (h) {
77
- if (i) {
78
- if (e.queryHash !== Ce(h, e.options))
79
- return !1;
80
- } else if (!ce(e.queryKey, h))
81
- return !1;
82
- }
83
- if (t !== "all") {
84
- const l = e.isActive();
85
- if (t === "active" && !l || t === "inactive" && l)
86
- return !1;
87
- }
88
- return !(typeof a == "boolean" && e.isStale() !== a || n && n !== e.state.fetchStatus || u && !u(e));
89
- }
90
- function Ae(s, e) {
91
- const { exact: t, status: i, predicate: n, mutationKey: u } = s;
92
- if (u) {
93
- if (!e.options.mutationKey)
94
- return !1;
95
- if (t) {
96
- if (oe(e.options.mutationKey) !== oe(u))
97
- return !1;
98
- } else if (!ce(e.options.mutationKey, u))
99
- return !1;
100
- }
101
- return !(i && e.state.status !== i || n && !n(e));
102
- }
103
- function Ce(s, e) {
104
- return ((e == null ? void 0 : e.queryKeyHashFn) || oe)(s);
105
- }
106
- function oe(s) {
107
- return JSON.stringify(
108
- s,
109
- (e, t) => qe(t) ? Object.keys(t).sort().reduce((i, n) => (i[n] = t[n], i), {}) : t
110
- );
111
- }
112
- function ce(s, e) {
113
- 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;
114
- }
115
- function He(s, e) {
116
- if (s === e)
117
- return s;
118
- const t = Ee(s) && Ee(e);
119
- if (t || qe(s) && qe(e)) {
120
- const i = t ? s : Object.keys(s), n = i.length, u = t ? e : Object.keys(e), h = u.length, a = t ? [] : {};
121
- let l = 0;
122
- for (let y = 0; y < h; y++) {
123
- const p = t ? y : u[y];
124
- (!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++);
125
- }
126
- return n === h && l === n ? s : a;
127
- }
128
- return e;
129
- }
130
- function Ee(s) {
131
- return Array.isArray(s) && s.length === Object.keys(s).length;
132
- }
133
- function qe(s) {
134
- if (!Qe(s))
135
- return !1;
136
- const e = s.constructor;
137
- if (e === void 0)
138
- return !0;
139
- const t = e.prototype;
140
- return !(!Qe(t) || !t.hasOwnProperty("isPrototypeOf") || Object.getPrototypeOf(s) !== Object.prototype);
141
- }
142
- function Qe(s) {
143
- return Object.prototype.toString.call(s) === "[object Object]";
144
- }
145
- function Ye(s) {
146
- return new Promise((e) => {
147
- setTimeout(e, s);
148
- });
149
- }
150
- function Ze(s, e, t) {
151
- return typeof t.structuralSharing == "function" ? t.structuralSharing(s, e) : t.structuralSharing !== !1 ? He(s, e) : e;
152
- }
153
- function et(s, e, t = 0) {
154
- const i = [...s, e];
155
- return t && i.length > t ? i.slice(1) : i;
156
- }
157
- function tt(s, e, t = 0) {
158
- const i = [e, ...s];
159
- return t && i.length > t ? i.slice(0, -1) : i;
160
- }
161
- var Oe = Symbol();
162
- function Ge(s, e) {
163
- return !s.queryFn && (e != null && e.initialPromise) ? () => e.initialPromise : !s.queryFn || s.queryFn === Oe ? () => Promise.reject(new Error(`Missing queryFn: '${s.queryHash}'`)) : s.queryFn;
164
- }
165
- var z, G, Z, Re, st = (Re = class extends ge {
166
- constructor() {
167
- super();
168
- f(this, z);
169
- f(this, G);
170
- f(this, Z);
171
- o(this, Z, (e) => {
172
- if (!we && window.addEventListener) {
173
- const t = () => e();
174
- return window.addEventListener("visibilitychange", t, !1), () => {
175
- window.removeEventListener("visibilitychange", t);
176
- };
177
- }
178
- });
179
- }
180
- onSubscribe() {
181
- r(this, G) || this.setEventListener(r(this, Z));
182
- }
183
- onUnsubscribe() {
184
- var e;
185
- this.hasListeners() || ((e = r(this, G)) == null || e.call(this), o(this, G, void 0));
186
- }
187
- setEventListener(e) {
188
- var t;
189
- o(this, Z, e), (t = r(this, G)) == null || t.call(this), o(this, G, e((i) => {
190
- typeof i == "boolean" ? this.setFocused(i) : this.onFocus();
191
- }));
192
- }
193
- setFocused(e) {
194
- r(this, z) !== e && (o(this, z, e), this.onFocus());
195
- }
196
- onFocus() {
197
- const e = this.isFocused();
198
- this.listeners.forEach((t) => {
199
- t(e);
200
- });
201
- }
202
- isFocused() {
203
- var e;
204
- return typeof r(this, z) == "boolean" ? r(this, z) : ((e = globalThis.document) == null ? void 0 : e.visibilityState) !== "hidden";
205
- }
206
- }, z = new WeakMap(), G = new WeakMap(), Z = new WeakMap(), Re), Ne = new st(), ee, N, te, Ke, it = (Ke = class extends ge {
207
- constructor() {
208
- super();
209
- f(this, ee, !0);
210
- f(this, N);
211
- f(this, te);
212
- o(this, te, (e) => {
213
- if (!we && window.addEventListener) {
214
- const t = () => e(!0), i = () => e(!1);
215
- return window.addEventListener("online", t, !1), window.addEventListener("offline", i, !1), () => {
216
- window.removeEventListener("online", t), window.removeEventListener("offline", i);
217
- };
218
- }
219
- });
220
- }
221
- onSubscribe() {
222
- r(this, N) || this.setEventListener(r(this, te));
223
- }
224
- onUnsubscribe() {
225
- var e;
226
- this.hasListeners() || ((e = r(this, N)) == null || e.call(this), o(this, N, void 0));
227
- }
228
- setEventListener(e) {
229
- var t;
230
- o(this, te, e), (t = r(this, N)) == null || t.call(this), o(this, N, e(this.setOnline.bind(this)));
231
- }
232
- setOnline(e) {
233
- r(this, ee) !== e && (o(this, ee, e), this.listeners.forEach((i) => {
234
- i(e);
235
- }));
236
- }
237
- isOnline() {
238
- return r(this, ee);
239
- }
240
- }, ee = new WeakMap(), N = new WeakMap(), te = new WeakMap(), Ke), ve = new it();
241
- function rt() {
242
- let s, e;
243
- const t = new Promise((n, u) => {
244
- s = n, e = u;
245
- });
246
- t.status = "pending", t.catch(() => {
247
- });
248
- function i(n) {
249
- Object.assign(t, n), delete t.resolve, delete t.reject;
250
- }
251
- return t.resolve = (n) => {
252
- i({
253
- status: "fulfilled",
254
- value: n
255
- }), s(n);
256
- }, t.reject = (n) => {
257
- i({
258
- status: "rejected",
259
- reason: n
260
- }), e(n);
261
- }, t;
262
- }
263
- function nt(s) {
264
- return Math.min(1e3 * 2 ** s, 3e4);
265
- }
266
- function Ve(s) {
267
- return (s ?? "online") === "online" ? ve.isOnline() : !0;
268
- }
269
- var $e = class extends Error {
270
- constructor(s) {
271
- super("CancelledError"), this.revert = s == null ? void 0 : s.revert, this.silent = s == null ? void 0 : s.silent;
272
- }
273
- };
274
- function Pe(s) {
275
- return s instanceof $e;
276
- }
277
- function Je(s) {
278
- let e = !1, t = 0, i = !1, n;
279
- const u = rt(), h = (d) => {
280
- var v;
281
- i || (m(new $e(d)), (v = s.abort) == null || v.call(s));
282
- }, a = () => {
283
- e = !0;
284
- }, l = () => {
285
- e = !1;
286
- }, y = () => Ne.isFocused() && (s.networkMode === "always" || ve.isOnline()) && s.canRun(), p = () => Ve(s.networkMode) && s.canRun(), c = (d) => {
287
- var v;
288
- i || (i = !0, (v = s.onSuccess) == null || v.call(s, d), n == null || n(), u.resolve(d));
289
- }, m = (d) => {
290
- var v;
291
- i || (i = !0, (v = s.onError) == null || v.call(s, d), n == null || n(), u.reject(d));
292
- }, S = () => new Promise((d) => {
293
- var v;
294
- n = (D) => {
295
- (i || y()) && d(D);
296
- }, (v = s.onPause) == null || v.call(s);
297
- }).then(() => {
298
- var d;
299
- n = void 0, i || (d = s.onContinue) == null || d.call(s);
300
- }), C = () => {
301
- if (i)
302
- return;
303
- let d;
304
- const v = t === 0 ? s.initialPromise : void 0;
305
- try {
306
- d = v ?? s.fn();
307
- } catch (D) {
308
- d = Promise.reject(D);
309
- }
310
- Promise.resolve(d).then(c).catch((D) => {
311
- var j;
312
- if (i)
313
- return;
314
- 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);
315
- if (e || !K) {
316
- m(D);
317
- return;
318
- }
319
- t++, (j = s.onFail) == null || j.call(s, t, D), Ye(A).then(() => y() ? void 0 : S()).then(() => {
320
- e ? m(D) : C();
321
- });
322
- });
323
- };
324
- return {
325
- promise: u,
326
- cancel: h,
327
- continue: () => (n == null || n(), u),
328
- cancelRetry: a,
329
- continueRetry: l,
330
- canStart: p,
331
- start: () => (p() ? C() : S().then(C), u)
332
- };
333
- }
334
- var at = (s) => setTimeout(s, 0);
335
- function ut() {
336
- let s = [], e = 0, t = (a) => {
337
- a();
338
- }, i = (a) => {
339
- a();
340
- }, n = at;
341
- const u = (a) => {
342
- e ? s.push(a) : n(() => {
343
- t(a);
344
- });
345
- }, h = () => {
346
- const a = s;
347
- s = [], a.length && n(() => {
348
- i(() => {
349
- a.forEach((l) => {
350
- t(l);
351
- });
352
- });
353
- });
354
- };
355
- return {
356
- batch: (a) => {
357
- let l;
358
- e++;
359
- try {
360
- l = a();
361
- } finally {
362
- e--, e || h();
363
- }
364
- return l;
365
- },
366
- /**
367
- * All calls to the wrapped function will be batched.
368
- */
369
- batchCalls: (a) => (...l) => {
370
- u(() => {
371
- a(...l);
372
- });
373
- },
374
- schedule: u,
375
- /**
376
- * Use this method to set a custom notify function.
377
- * This can be used to for example wrap notifications with `React.act` while running tests.
378
- */
379
- setNotifyFunction: (a) => {
380
- t = a;
381
- },
382
- /**
383
- * Use this method to set a custom function to batch notifications together into a single tick.
384
- * By default React Query will use the batch function provided by ReactDOM or React Native.
385
- */
386
- setBatchNotifyFunction: (a) => {
387
- i = a;
388
- },
389
- setScheduler: (a) => {
390
- n = a;
391
- }
392
- };
393
- }
394
- var F = ut(), B, je, _e = (je = class {
395
- constructor() {
396
- f(this, B);
397
- }
398
- destroy() {
399
- this.clearGcTimeout();
400
- }
401
- scheduleGc() {
402
- this.clearGcTimeout(), Be(this.gcTime) && o(this, B, setTimeout(() => {
403
- this.optionalRemove();
404
- }, this.gcTime));
405
- }
406
- updateGcTime(s) {
407
- this.gcTime = Math.max(
408
- this.gcTime || 0,
409
- s ?? (we ? 1 / 0 : 5 * 60 * 1e3)
410
- );
411
- }
412
- clearGcTimeout() {
413
- r(this, B) && (clearTimeout(r(this, B)), o(this, B, void 0));
414
- }
415
- }, B = new WeakMap(), je), se, ie, E, W, q, le, X, T, L, ke, ht = (ke = class extends _e {
416
- constructor(e) {
417
- super();
418
- f(this, T);
419
- f(this, se);
420
- f(this, ie);
421
- f(this, E);
422
- f(this, W);
423
- f(this, q);
424
- f(this, le);
425
- f(this, X);
426
- 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();
427
- }
428
- get meta() {
429
- return this.options.meta;
430
- }
431
- get promise() {
432
- var e;
433
- return (e = r(this, q)) == null ? void 0 : e.promise;
434
- }
435
- setOptions(e) {
436
- this.options = { ...r(this, le), ...e }, this.updateGcTime(this.options.gcTime);
437
- }
438
- optionalRemove() {
439
- !this.observers.length && this.state.fetchStatus === "idle" && r(this, E).remove(this);
440
- }
441
- setData(e, t) {
442
- const i = Ze(this.state.data, e, this.options);
443
- return P(this, T, L).call(this, {
444
- data: i,
445
- type: "success",
446
- dataUpdatedAt: t == null ? void 0 : t.updatedAt,
447
- manual: t == null ? void 0 : t.manual
448
- }), i;
449
- }
450
- setState(e, t) {
451
- P(this, T, L).call(this, { type: "setState", state: e, setStateOptions: t });
452
- }
453
- cancel(e) {
454
- var i, n;
455
- const t = (i = r(this, q)) == null ? void 0 : i.promise;
456
- return (n = r(this, q)) == null || n.cancel(e), t ? t.then(M).catch(M) : Promise.resolve();
457
- }
458
- destroy() {
459
- super.destroy(), this.cancel({ silent: !0 });
460
- }
461
- reset() {
462
- this.destroy(), this.setState(r(this, se));
463
- }
464
- isActive() {
465
- return this.observers.some(
466
- (e) => Xe(e.options.enabled, this) !== !1
467
- );
468
- }
469
- isDisabled() {
470
- return this.getObserversCount() > 0 ? !this.isActive() : this.options.queryFn === Oe || this.state.dataUpdateCount + this.state.errorUpdateCount === 0;
471
- }
472
- isStale() {
473
- return this.state.isInvalidated ? !0 : this.getObserversCount() > 0 ? this.observers.some(
474
- (e) => e.getCurrentResult().isStale
475
- ) : this.state.data === void 0;
476
- }
477
- isStaleByTime(e = 0) {
478
- return this.state.isInvalidated || this.state.data === void 0 || !We(this.state.dataUpdatedAt, e);
479
- }
480
- onFocus() {
481
- var t;
482
- const e = this.observers.find((i) => i.shouldFetchOnWindowFocus());
483
- e == null || e.refetch({ cancelRefetch: !1 }), (t = r(this, q)) == null || t.continue();
484
- }
485
- onOnline() {
486
- var t;
487
- const e = this.observers.find((i) => i.shouldFetchOnReconnect());
488
- e == null || e.refetch({ cancelRefetch: !1 }), (t = r(this, q)) == null || t.continue();
489
- }
490
- addObserver(e) {
491
- this.observers.includes(e) || (this.observers.push(e), this.clearGcTimeout(), r(this, E).notify({ type: "observerAdded", query: this, observer: e }));
492
- }
493
- removeObserver(e) {
494
- 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 }));
495
- }
496
- getObserversCount() {
497
- return this.observers.length;
498
- }
499
- invalidate() {
500
- this.state.isInvalidated || P(this, T, L).call(this, { type: "invalidate" });
501
- }
502
- fetch(e, t) {
503
- var l, y, p;
504
- if (this.state.fetchStatus !== "idle") {
505
- if (this.state.data !== void 0 && (t != null && t.cancelRefetch))
506
- this.cancel({ silent: !0 });
507
- else if (r(this, q))
508
- return r(this, q).continueRetry(), r(this, q).promise;
509
- }
510
- if (e && this.setOptions(e), !this.options.queryFn) {
511
- const c = this.observers.find((m) => m.options.queryFn);
512
- c && this.setOptions(c.options);
513
- }
514
- const i = new AbortController(), n = (c) => {
515
- Object.defineProperty(c, "signal", {
516
- enumerable: !0,
517
- get: () => (o(this, X, !0), i.signal)
518
- });
519
- }, u = () => {
520
- const c = Ge(this.options, t), m = {
521
- client: r(this, W),
522
- queryKey: this.queryKey,
523
- meta: this.meta
524
- };
525
- return n(m), o(this, X, !1), this.options.persister ? this.options.persister(
526
- c,
527
- m,
528
- this
529
- ) : c(m);
530
- }, h = {
531
- fetchOptions: t,
532
- options: this.options,
533
- queryKey: this.queryKey,
534
- client: r(this, W),
535
- state: this.state,
536
- fetchFn: u
537
- };
538
- n(h), (l = this.options.behavior) == null || l.onFetch(
539
- h,
540
- this
541
- ), 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 });
542
- const a = (c) => {
543
- var m, S, C, d;
544
- Pe(c) && c.silent || P(this, T, L).call(this, {
545
- type: "error",
546
- error: c
547
- }), Pe(c) || ((S = (m = r(this, E).config).onError) == null || S.call(
548
- m,
549
- c,
550
- this
551
- ), (d = (C = r(this, E).config).onSettled) == null || d.call(
552
- C,
553
- this.state.data,
554
- c,
555
- this
556
- )), this.scheduleGc();
557
- };
558
- return o(this, q, Je({
559
- initialPromise: t == null ? void 0 : t.initialPromise,
560
- fn: h.fetchFn,
561
- abort: i.abort.bind(i),
562
- onSuccess: (c) => {
563
- var m, S, C, d;
564
- if (c === void 0) {
565
- a(new Error(`${this.queryHash} data is undefined`));
566
- return;
567
- }
568
- try {
569
- this.setData(c);
570
- } catch (v) {
571
- a(v);
572
- return;
573
- }
574
- (S = (m = r(this, E).config).onSuccess) == null || S.call(m, c, this), (d = (C = r(this, E).config).onSettled) == null || d.call(
575
- C,
576
- c,
577
- this.state.error,
578
- this
579
- ), this.scheduleGc();
580
- },
581
- onError: a,
582
- onFail: (c, m) => {
583
- P(this, T, L).call(this, { type: "failed", failureCount: c, error: m });
584
- },
585
- onPause: () => {
586
- P(this, T, L).call(this, { type: "pause" });
587
- },
588
- onContinue: () => {
589
- P(this, T, L).call(this, { type: "continue" });
590
- },
591
- retry: h.options.retry,
592
- retryDelay: h.options.retryDelay,
593
- networkMode: h.options.networkMode,
594
- canRun: () => !0
595
- })), r(this, q).start();
596
- }
597
- }, 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) {
598
- const t = (i) => {
599
- switch (e.type) {
600
- case "failed":
601
- return {
602
- ...i,
603
- fetchFailureCount: e.failureCount,
604
- fetchFailureReason: e.error
605
- };
606
- case "pause":
607
- return {
608
- ...i,
609
- fetchStatus: "paused"
610
- };
611
- case "continue":
612
- return {
613
- ...i,
614
- fetchStatus: "fetching"
615
- };
616
- case "fetch":
617
- return {
618
- ...i,
619
- ...ot(i.data, this.options),
620
- fetchMeta: e.meta ?? null
621
- };
622
- case "success":
623
- return {
624
- ...i,
625
- data: e.data,
626
- dataUpdateCount: i.dataUpdateCount + 1,
627
- dataUpdatedAt: e.dataUpdatedAt ?? Date.now(),
628
- error: null,
629
- isInvalidated: !1,
630
- status: "success",
631
- ...!e.manual && {
632
- fetchStatus: "idle",
633
- fetchFailureCount: 0,
634
- fetchFailureReason: null
635
- }
636
- };
637
- case "error":
638
- const n = e.error;
639
- return Pe(n) && n.revert && r(this, ie) ? { ...r(this, ie), fetchStatus: "idle" } : {
640
- ...i,
641
- error: n,
642
- errorUpdateCount: i.errorUpdateCount + 1,
643
- errorUpdatedAt: Date.now(),
644
- fetchFailureCount: i.fetchFailureCount + 1,
645
- fetchFailureReason: n,
646
- fetchStatus: "idle",
647
- status: "error"
648
- };
649
- case "invalidate":
650
- return {
651
- ...i,
652
- isInvalidated: !0
653
- };
654
- case "setState":
655
- return {
656
- ...i,
657
- ...e.state
658
- };
659
- }
660
- };
661
- this.state = t(this.state), F.batch(() => {
662
- this.observers.forEach((i) => {
663
- i.onQueryUpdate();
664
- }), r(this, E).notify({ query: this, type: "updated", action: e });
665
- });
666
- }, ke);
667
- function ot(s, e) {
668
- return {
669
- fetchFailureCount: 0,
670
- fetchFailureReason: null,
671
- fetchStatus: Ve(e.networkMode) ? "fetching" : "paused",
672
- ...s === void 0 && {
673
- error: null,
674
- status: "pending"
675
- }
676
- };
677
- }
678
- function ct(s) {
679
- 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;
680
- return {
681
- data: e,
682
- dataUpdateCount: 0,
683
- dataUpdatedAt: t ? i ?? Date.now() : 0,
684
- error: null,
685
- errorUpdateCount: 0,
686
- errorUpdatedAt: 0,
687
- fetchFailureCount: 0,
688
- fetchFailureReason: null,
689
- fetchMeta: null,
690
- isInvalidated: !1,
691
- status: t ? "success" : "pending",
692
- fetchStatus: "idle"
693
- };
694
- }
695
- var k, Ue, lt = (Ue = class extends ge {
696
- constructor(e = {}) {
697
- super();
698
- f(this, k);
699
- this.config = e, o(this, k, /* @__PURE__ */ new Map());
700
- }
701
- build(e, t, i) {
702
- const n = t.queryKey, u = t.queryHash ?? Ce(n, t);
703
- let h = this.get(u);
704
- return h || (h = new ht({
705
- client: e,
706
- queryKey: n,
707
- queryHash: u,
708
- options: e.defaultQueryOptions(t),
709
- state: i,
710
- defaultOptions: e.getQueryDefaults(n)
711
- }), this.add(h)), h;
712
- }
713
- add(e) {
714
- r(this, k).has(e.queryHash) || (r(this, k).set(e.queryHash, e), this.notify({
715
- type: "added",
716
- query: e
717
- }));
718
- }
719
- remove(e) {
720
- const t = r(this, k).get(e.queryHash);
721
- t && (e.destroy(), t === e && r(this, k).delete(e.queryHash), this.notify({ type: "removed", query: e }));
722
- }
723
- clear() {
724
- F.batch(() => {
725
- this.getAll().forEach((e) => {
726
- this.remove(e);
727
- });
728
- });
729
- }
730
- get(e) {
731
- return r(this, k).get(e);
732
- }
733
- getAll() {
734
- return [...r(this, k).values()];
735
- }
736
- find(e) {
737
- const t = { exact: !0, ...e };
738
- return this.getAll().find(
739
- (i) => De(t, i)
740
- );
741
- }
742
- findAll(e = {}) {
743
- const t = this.getAll();
744
- return Object.keys(e).length > 0 ? t.filter((i) => De(e, i)) : t;
745
- }
746
- notify(e) {
747
- F.batch(() => {
748
- this.listeners.forEach((t) => {
749
- t(e);
750
- });
751
- });
752
- }
753
- onFocus() {
754
- F.batch(() => {
755
- this.getAll().forEach((e) => {
756
- e.onFocus();
757
- });
758
- });
759
- }
760
- onOnline() {
761
- F.batch(() => {
762
- this.getAll().forEach((e) => {
763
- e.onOnline();
764
- });
765
- });
766
- }
767
- }, k = new WeakMap(), Ue), U, O, Y, I, H, Ie, dt = (Ie = class extends _e {
768
- constructor(e) {
769
- super();
770
- f(this, I);
771
- f(this, U);
772
- f(this, O);
773
- f(this, Y);
774
- this.mutationId = e.mutationId, o(this, O, e.mutationCache), o(this, U, []), this.state = e.state || ft(), this.setOptions(e.options), this.scheduleGc();
775
- }
776
- setOptions(e) {
777
- this.options = e, this.updateGcTime(this.options.gcTime);
778
- }
779
- get meta() {
780
- return this.options.meta;
781
- }
782
- addObserver(e) {
783
- r(this, U).includes(e) || (r(this, U).push(e), this.clearGcTimeout(), r(this, O).notify({
784
- type: "observerAdded",
785
- mutation: this,
786
- observer: e
787
- }));
788
- }
789
- removeObserver(e) {
790
- o(this, U, r(this, U).filter((t) => t !== e)), this.scheduleGc(), r(this, O).notify({
791
- type: "observerRemoved",
792
- mutation: this,
793
- observer: e
794
- });
795
- }
796
- optionalRemove() {
797
- r(this, U).length || (this.state.status === "pending" ? this.scheduleGc() : r(this, O).remove(this));
798
- }
799
- continue() {
800
- var e;
801
- return ((e = r(this, Y)) == null ? void 0 : e.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
802
- this.execute(this.state.variables);
803
- }
804
- async execute(e) {
805
- var u, h, a, l, y, p, c, m, S, C, d, v, D, Q, w, A, K, j, fe, he;
806
- const t = () => {
807
- P(this, I, H).call(this, { type: "continue" });
808
- };
809
- o(this, Y, Je({
810
- fn: () => this.options.mutationFn ? this.options.mutationFn(e) : Promise.reject(new Error("No mutationFn found")),
811
- onFail: (b, ye) => {
812
- P(this, I, H).call(this, { type: "failed", failureCount: b, error: ye });
813
- },
814
- onPause: () => {
815
- P(this, I, H).call(this, { type: "pause" });
816
- },
817
- onContinue: t,
818
- retry: this.options.retry ?? 0,
819
- retryDelay: this.options.retryDelay,
820
- networkMode: this.options.networkMode,
821
- canRun: () => r(this, O).canRun(this)
822
- }));
823
- const i = this.state.status === "pending", n = !r(this, Y).canStart();
824
- try {
825
- if (i)
826
- t();
827
- else {
828
- 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(
829
- u,
830
- e,
831
- this
832
- ));
833
- const ye = await ((l = (a = this.options).onMutate) == null ? void 0 : l.call(a, e));
834
- ye !== this.state.context && P(this, I, H).call(this, {
835
- type: "pending",
836
- context: ye,
837
- variables: e,
838
- isPaused: n
839
- });
840
- }
841
- const b = await r(this, Y).start();
842
- return await ((p = (y = r(this, O).config).onSuccess) == null ? void 0 : p.call(
843
- y,
844
- b,
845
- e,
846
- this.state.context,
847
- this
848
- )), 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(
849
- S,
850
- b,
851
- null,
852
- this.state.variables,
853
- this.state.context,
854
- this
855
- )), 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;
856
- } catch (b) {
857
- try {
858
- throw await ((Q = (D = r(this, O).config).onError) == null ? void 0 : Q.call(
859
- D,
860
- b,
861
- e,
862
- this.state.context,
863
- this
864
- )), await ((A = (w = this.options).onError) == null ? void 0 : A.call(
865
- w,
866
- b,
867
- e,
868
- this.state.context
869
- )), await ((j = (K = r(this, O).config).onSettled) == null ? void 0 : j.call(
870
- K,
871
- void 0,
872
- b,
873
- this.state.variables,
874
- this.state.context,
875
- this
876
- )), await ((he = (fe = this.options).onSettled) == null ? void 0 : he.call(
877
- fe,
878
- void 0,
879
- b,
880
- e,
881
- this.state.context
882
- )), b;
883
- } finally {
884
- P(this, I, H).call(this, { type: "error", error: b });
885
- }
886
- } finally {
887
- r(this, O).runNext(this);
888
- }
889
- }
890
- }, U = new WeakMap(), O = new WeakMap(), Y = new WeakMap(), I = new WeakSet(), H = function(e) {
891
- const t = (i) => {
892
- switch (e.type) {
893
- case "failed":
894
- return {
895
- ...i,
896
- failureCount: e.failureCount,
897
- failureReason: e.error
898
- };
899
- case "pause":
900
- return {
901
- ...i,
902
- isPaused: !0
903
- };
904
- case "continue":
905
- return {
906
- ...i,
907
- isPaused: !1
908
- };
909
- case "pending":
910
- return {
911
- ...i,
912
- context: e.context,
913
- data: void 0,
914
- failureCount: 0,
915
- failureReason: null,
916
- error: null,
917
- isPaused: e.isPaused,
918
- status: "pending",
919
- variables: e.variables,
920
- submittedAt: Date.now()
921
- };
922
- case "success":
923
- return {
924
- ...i,
925
- data: e.data,
926
- failureCount: 0,
927
- failureReason: null,
928
- error: null,
929
- status: "success",
930
- isPaused: !1
931
- };
932
- case "error":
933
- return {
934
- ...i,
935
- data: void 0,
936
- error: e.error,
937
- failureCount: i.failureCount + 1,
938
- failureReason: e.error,
939
- isPaused: !1,
940
- status: "error"
941
- };
942
- }
943
- };
944
- this.state = t(this.state), F.batch(() => {
945
- r(this, U).forEach((i) => {
946
- i.onMutationUpdate(e);
947
- }), r(this, O).notify({
948
- mutation: this,
949
- type: "updated",
950
- action: e
951
- });
952
- });
953
- }, Ie);
954
- function ft() {
955
- return {
956
- context: void 0,
957
- data: void 0,
958
- error: null,
959
- failureCount: 0,
960
- failureReason: null,
961
- isPaused: !1,
962
- status: "idle",
963
- variables: void 0,
964
- submittedAt: 0
965
- };
966
- }
967
- var x, R, de, Le, yt = (Le = class extends ge {
968
- constructor(e = {}) {
969
- super();
970
- f(this, x);
971
- f(this, R);
972
- f(this, de);
973
- this.config = e, o(this, x, /* @__PURE__ */ new Set()), o(this, R, /* @__PURE__ */ new Map()), o(this, de, 0);
974
- }
975
- build(e, t, i) {
976
- const n = new dt({
977
- mutationCache: this,
978
- mutationId: ++pe(this, de)._,
979
- options: e.defaultMutationOptions(t),
980
- state: i
981
- });
982
- return this.add(n), n;
983
- }
984
- add(e) {
985
- r(this, x).add(e);
986
- const t = me(e);
987
- if (typeof t == "string") {
988
- const i = r(this, R).get(t);
989
- i ? i.push(e) : r(this, R).set(t, [e]);
990
- }
991
- this.notify({ type: "added", mutation: e });
992
- }
993
- remove(e) {
994
- if (r(this, x).delete(e)) {
995
- const t = me(e);
996
- if (typeof t == "string") {
997
- const i = r(this, R).get(t);
998
- if (i)
999
- if (i.length > 1) {
1000
- const n = i.indexOf(e);
1001
- n !== -1 && i.splice(n, 1);
1002
- } else i[0] === e && r(this, R).delete(t);
1003
- }
1004
- }
1005
- this.notify({ type: "removed", mutation: e });
1006
- }
1007
- canRun(e) {
1008
- const t = me(e);
1009
- if (typeof t == "string") {
1010
- const i = r(this, R).get(t), n = i == null ? void 0 : i.find(
1011
- (u) => u.state.status === "pending"
1012
- );
1013
- return !n || n === e;
1014
- } else
1015
- return !0;
1016
- }
1017
- runNext(e) {
1018
- var i;
1019
- const t = me(e);
1020
- if (typeof t == "string") {
1021
- const n = (i = r(this, R).get(t)) == null ? void 0 : i.find((u) => u !== e && u.state.isPaused);
1022
- return (n == null ? void 0 : n.continue()) ?? Promise.resolve();
1023
- } else
1024
- return Promise.resolve();
1025
- }
1026
- clear() {
1027
- F.batch(() => {
1028
- r(this, x).forEach((e) => {
1029
- this.notify({ type: "removed", mutation: e });
1030
- }), r(this, x).clear(), r(this, R).clear();
1031
- });
1032
- }
1033
- getAll() {
1034
- return Array.from(r(this, x));
1035
- }
1036
- find(e) {
1037
- const t = { exact: !0, ...e };
1038
- return this.getAll().find(
1039
- (i) => Ae(t, i)
1040
- );
1041
- }
1042
- findAll(e = {}) {
1043
- return this.getAll().filter((t) => Ae(e, t));
1044
- }
1045
- notify(e) {
1046
- F.batch(() => {
1047
- this.listeners.forEach((t) => {
1048
- t(e);
1049
- });
1050
- });
1051
- }
1052
- resumePausedMutations() {
1053
- const e = this.getAll().filter((t) => t.state.isPaused);
1054
- return F.batch(
1055
- () => Promise.all(
1056
- e.map((t) => t.continue().catch(M))
1057
- )
1058
- );
1059
- }
1060
- }, x = new WeakMap(), R = new WeakMap(), de = new WeakMap(), Le);
1061
- function me(s) {
1062
- var e;
1063
- return (e = s.options.scope) == null ? void 0 : e.id;
1064
- }
1065
- function Me(s) {
1066
- return {
1067
- onFetch: (e, t) => {
1068
- var p, c, m, S, C;
1069
- 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) || [];
1070
- let a = { pages: [], pageParams: [] }, l = 0;
1071
- const y = async () => {
1072
- let d = !1;
1073
- const v = (w) => {
1074
- Object.defineProperty(w, "signal", {
1075
- enumerable: !0,
1076
- get: () => (e.signal.aborted ? d = !0 : e.signal.addEventListener("abort", () => {
1077
- d = !0;
1078
- }), e.signal)
1079
- });
1080
- }, D = Ge(e.options, e.fetchOptions), Q = async (w, A, K) => {
1081
- if (d)
1082
- return Promise.reject();
1083
- if (A == null && w.pages.length)
1084
- return Promise.resolve(w);
1085
- const j = {
1086
- client: e.client,
1087
- queryKey: e.queryKey,
1088
- pageParam: A,
1089
- direction: K ? "backward" : "forward",
1090
- meta: e.options.meta
1091
- };
1092
- v(j);
1093
- const fe = await D(
1094
- j
1095
- ), { maxPages: he } = e.options, b = K ? tt : et;
1096
- return {
1097
- pages: b(w.pages, fe, he),
1098
- pageParams: b(w.pageParams, A, he)
1099
- };
1100
- };
1101
- if (n && u.length) {
1102
- const w = n === "backward", A = w ? pt : Te, K = {
1103
- pages: u,
1104
- pageParams: h
1105
- }, j = A(i, K);
1106
- a = await Q(K, j, w);
1107
- } else {
1108
- const w = s ?? u.length;
1109
- do {
1110
- const A = l === 0 ? h[0] ?? i.initialPageParam : Te(i, a);
1111
- if (l > 0 && A == null)
1112
- break;
1113
- a = await Q(a, A), l++;
1114
- } while (l < w);
1115
- }
1116
- return a;
1117
- };
1118
- e.options.persister ? e.fetchFn = () => {
1119
- var d, v;
1120
- return (v = (d = e.options).persister) == null ? void 0 : v.call(
1121
- d,
1122
- y,
1123
- {
1124
- client: e.client,
1125
- queryKey: e.queryKey,
1126
- meta: e.options.meta,
1127
- signal: e.signal
1128
- },
1129
- t
1130
- );
1131
- } : e.fetchFn = y;
1132
- }
1133
- };
1134
- }
1135
- function Te(s, { pages: e, pageParams: t }) {
1136
- const i = e.length - 1;
1137
- return e.length > 0 ? s.getNextPageParam(
1138
- e[i],
1139
- e,
1140
- t[i],
1141
- t
1142
- ) : void 0;
1143
- }
1144
- function pt(s, { pages: e, pageParams: t }) {
1145
- var i;
1146
- return e.length > 0 ? (i = s.getPreviousPageParam) == null ? void 0 : i.call(s, e[0], e, t[0], t) : void 0;
1147
- }
1148
- var g, V, $, re, ne, J, ae, ue, xe, mt = (xe = class {
1149
- constructor(s = {}) {
1150
- f(this, g);
1151
- f(this, V);
1152
- f(this, $);
1153
- f(this, re);
1154
- f(this, ne);
1155
- f(this, J);
1156
- f(this, ae);
1157
- f(this, ue);
1158
- o(this, g, s.queryCache || new lt()), o(this, V, s.mutationCache || new yt()), o(this, $, s.defaultOptions || {}), o(this, re, /* @__PURE__ */ new Map()), o(this, ne, /* @__PURE__ */ new Map()), o(this, J, 0);
1159
- }
1160
- mount() {
1161
- pe(this, J)._++, r(this, J) === 1 && (o(this, ae, Ne.subscribe(async (s) => {
1162
- s && (await this.resumePausedMutations(), r(this, g).onFocus());
1163
- })), o(this, ue, ve.subscribe(async (s) => {
1164
- s && (await this.resumePausedMutations(), r(this, g).onOnline());
1165
- })));
1166
- }
1167
- unmount() {
1168
- var s, e;
1169
- 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));
1170
- }
1171
- isFetching(s) {
1172
- return r(this, g).findAll({ ...s, fetchStatus: "fetching" }).length;
1173
- }
1174
- isMutating(s) {
1175
- return r(this, V).findAll({ ...s, status: "pending" }).length;
1176
- }
1177
- /**
1178
- * Imperative (non-reactive) way to retrieve data for a QueryKey.
1179
- * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
1180
- *
1181
- * Hint: Do not use this function inside a component, because it won't receive updates.
1182
- * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
1183
- */
1184
- getQueryData(s) {
1185
- var t;
1186
- const e = this.defaultQueryOptions({ queryKey: s });
1187
- return (t = r(this, g).get(e.queryHash)) == null ? void 0 : t.state.data;
1188
- }
1189
- ensureQueryData(s) {
1190
- const e = this.defaultQueryOptions(s), t = r(this, g).build(this, e), i = t.state.data;
1191
- return i === void 0 ? this.fetchQuery(s) : (s.revalidateIfStale && t.isStaleByTime(Se(e.staleTime, t)) && this.prefetchQuery(e), Promise.resolve(i));
1192
- }
1193
- getQueriesData(s) {
1194
- return r(this, g).findAll(s).map(({ queryKey: e, state: t }) => {
1195
- const i = t.data;
1196
- return [e, i];
1197
- });
1198
- }
1199
- setQueryData(s, e, t) {
1200
- const i = this.defaultQueryOptions({ queryKey: s }), n = r(this, g).get(
1201
- i.queryHash
1202
- ), u = n == null ? void 0 : n.state.data, h = ze(e, u);
1203
- if (h !== void 0)
1204
- return r(this, g).build(this, i).setData(h, { ...t, manual: !0 });
1205
- }
1206
- setQueriesData(s, e, t) {
1207
- return F.batch(
1208
- () => r(this, g).findAll(s).map(({ queryKey: i }) => [
1209
- i,
1210
- this.setQueryData(i, e, t)
1211
- ])
1212
- );
1213
- }
1214
- getQueryState(s) {
1215
- var t;
1216
- const e = this.defaultQueryOptions({ queryKey: s });
1217
- return (t = r(this, g).get(
1218
- e.queryHash
1219
- )) == null ? void 0 : t.state;
1220
- }
1221
- removeQueries(s) {
1222
- const e = r(this, g);
1223
- F.batch(() => {
1224
- e.findAll(s).forEach((t) => {
1225
- e.remove(t);
1226
- });
1227
- });
1228
- }
1229
- resetQueries(s, e) {
1230
- const t = r(this, g);
1231
- return F.batch(() => (t.findAll(s).forEach((i) => {
1232
- i.reset();
1233
- }), this.refetchQueries(
1234
- {
1235
- type: "active",
1236
- ...s
1237
- },
1238
- e
1239
- )));
1240
- }
1241
- cancelQueries(s, e = {}) {
1242
- const t = { revert: !0, ...e }, i = F.batch(
1243
- () => r(this, g).findAll(s).map((n) => n.cancel(t))
1244
- );
1245
- return Promise.all(i).then(M).catch(M);
1246
- }
1247
- invalidateQueries(s, e = {}) {
1248
- return F.batch(() => (r(this, g).findAll(s).forEach((t) => {
1249
- t.invalidate();
1250
- }), (s == null ? void 0 : s.refetchType) === "none" ? Promise.resolve() : this.refetchQueries(
1251
- {
1252
- ...s,
1253
- type: (s == null ? void 0 : s.refetchType) ?? (s == null ? void 0 : s.type) ?? "active"
1254
- },
1255
- e
1256
- )));
1257
- }
1258
- refetchQueries(s, e = {}) {
1259
- const t = {
1260
- ...e,
1261
- cancelRefetch: e.cancelRefetch ?? !0
1262
- }, i = F.batch(
1263
- () => r(this, g).findAll(s).filter((n) => !n.isDisabled()).map((n) => {
1264
- let u = n.fetch(void 0, t);
1265
- return t.throwOnError || (u = u.catch(M)), n.state.fetchStatus === "paused" ? Promise.resolve() : u;
1266
- })
1267
- );
1268
- return Promise.all(i).then(M);
1269
- }
1270
- fetchQuery(s) {
1271
- const e = this.defaultQueryOptions(s);
1272
- e.retry === void 0 && (e.retry = !1);
1273
- const t = r(this, g).build(this, e);
1274
- return t.isStaleByTime(
1275
- Se(e.staleTime, t)
1276
- ) ? t.fetch(e) : Promise.resolve(t.state.data);
1277
- }
1278
- prefetchQuery(s) {
1279
- return this.fetchQuery(s).then(M).catch(M);
1280
- }
1281
- fetchInfiniteQuery(s) {
1282
- return s.behavior = Me(s.pages), this.fetchQuery(s);
1283
- }
1284
- prefetchInfiniteQuery(s) {
1285
- return this.fetchInfiniteQuery(s).then(M).catch(M);
1286
- }
1287
- ensureInfiniteQueryData(s) {
1288
- return s.behavior = Me(s.pages), this.ensureQueryData(s);
1289
- }
1290
- resumePausedMutations() {
1291
- return ve.isOnline() ? r(this, V).resumePausedMutations() : Promise.resolve();
1292
- }
1293
- getQueryCache() {
1294
- return r(this, g);
1295
- }
1296
- getMutationCache() {
1297
- return r(this, V);
1298
- }
1299
- getDefaultOptions() {
1300
- return r(this, $);
1301
- }
1302
- setDefaultOptions(s) {
1303
- o(this, $, s);
1304
- }
1305
- setQueryDefaults(s, e) {
1306
- r(this, re).set(oe(s), {
1307
- queryKey: s,
1308
- defaultOptions: e
1309
- });
1310
- }
1311
- getQueryDefaults(s) {
1312
- const e = [...r(this, re).values()], t = {};
1313
- return e.forEach((i) => {
1314
- ce(s, i.queryKey) && Object.assign(t, i.defaultOptions);
1315
- }), t;
1316
- }
1317
- setMutationDefaults(s, e) {
1318
- r(this, ne).set(oe(s), {
1319
- mutationKey: s,
1320
- defaultOptions: e
1321
- });
1322
- }
1323
- getMutationDefaults(s) {
1324
- const e = [...r(this, ne).values()], t = {};
1325
- return e.forEach((i) => {
1326
- ce(s, i.mutationKey) && Object.assign(t, i.defaultOptions);
1327
- }), t;
1328
- }
1329
- defaultQueryOptions(s) {
1330
- if (s._defaulted)
1331
- return s;
1332
- const e = {
1333
- ...r(this, $).queries,
1334
- ...this.getQueryDefaults(s.queryKey),
1335
- ...s,
1336
- _defaulted: !0
1337
- };
1338
- return e.queryHash || (e.queryHash = Ce(
1339
- e.queryKey,
1340
- e
1341
- )), 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;
1342
- }
1343
- defaultMutationOptions(s) {
1344
- return s != null && s._defaulted ? s : {
1345
- ...r(this, $).mutations,
1346
- ...(s == null ? void 0 : s.mutationKey) && this.getMutationDefaults(s.mutationKey),
1347
- ...s,
1348
- _defaulted: !0
1349
- };
1350
- }
1351
- clear() {
1352
- r(this, g).clear(), r(this, V).clear();
1353
- }
1354
- }, g = new WeakMap(), V = new WeakMap(), $ = new WeakMap(), re = new WeakMap(), ne = new WeakMap(), J = new WeakMap(), ae = new WeakMap(), ue = new WeakMap(), xe);
1355
- class _ {
1356
- constructor(e = {}) {
1357
- 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({
1358
- defaultOptions: {
1359
- queries: {
1360
- staleTime: e.staleTime || 5 * 60 * 1e3,
1361
- // 5 minutes
1362
- gcTime: e.gcTime || 10 * 60 * 1e3,
1363
- // 10 minutes
1364
- retry: e.retry || 3,
1365
- retryDelay: e.retryDelay || ((t) => Math.min(1e3 * 2 ** t, 3e4))
1366
- }
1367
- }
1368
- }), this.initNetworkListeners();
1369
- }
1370
- /**
1371
- * Set API configuration
1372
- * @param config - API configuration
1373
- */
1374
- configure(e = {}) {
1375
- 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) {
1376
- const t = {};
1377
- e.staleTime && (t.staleTime = e.staleTime), e.gcTime && (t.gcTime = e.gcTime), e.retry && (t.retry = e.retry), this.queryClient.setDefaultOptions({
1378
- queries: {
1379
- ...this.queryClient.getDefaultOptions().queries,
1380
- ...t
1381
- }
1382
- });
1383
- }
1384
- }
1385
- /**
1386
- * Initialize network status listeners
1387
- */
1388
- initNetworkListeners() {
1389
- typeof window < "u" && window.addEventListener("online", () => {
1390
- console.warn("Network connection restored, refreshing data..."), this.refreshAll();
1391
- });
1392
- }
1393
- /**
1394
- * Get API headers
1395
- * @param additionalHeaders - Additional headers to include
1396
- * @returns Headers for API requests
1397
- */
1398
- getHeaders(e = {}) {
1399
- return {
1400
- "Content-Type": "application/json",
1401
- ...e
1402
- };
1403
- }
1404
- /**
1405
- * Make API request with advanced error handling
1406
- * Default method is POST and supports an optional JSON body
1407
- * @param endpoint - API endpoint
1408
- * @param jsonBody - Optional JSON body to send with request
1409
- * @param options - Additional fetch options
1410
- * @returns API response
1411
- * @throws {Error} If API request fails
1412
- */
1413
- async fetchApi(e, t, i = {}) {
1414
- const n = `${this.apiUrl}/${this.apiVersion}${e}`, h = {
1415
- method: i.method || "POST",
1416
- headers: this.getHeaders(i.headers),
1417
- mode: "cors",
1418
- ...i
1419
- };
1420
- t !== void 0 && (t.key = this.authKey, t.token = this.authToken, h.body = JSON.stringify(t));
1421
- try {
1422
- const a = await fetch(n, h);
1423
- if (!a.ok) {
1424
- const l = await a.json().catch(() => null);
1425
- throw a.status === 401 || a.status === 403 ? new Error(
1426
- "Authentication failed. Please check your API token."
1427
- ) : a.status === 404 ? new Error(`Resource not found: ${e}`) : a.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(
1428
- (l == null ? void 0 : l.message) || `API request failed with status ${a.status}`
1429
- );
1430
- }
1431
- return await a.json();
1432
- } catch (a) {
1433
- throw console.error(`API request to ${e} failed:`, a), a instanceof Error && (a.endpoint = e, a.timestamp = (/* @__PURE__ */ new Date()).toISOString()), a;
1434
- }
1435
- }
1436
- /**
1437
- * Fetch all available datasets with pagination support
1438
- * @param options - Pagination options
1439
- * @returns Paginated list of datasets
1440
- */
1441
- async fetchAllDatasets(e = {}) {
1442
- const t = e.offset || 0, i = e.limit || 50, n = ["datasets", t, i];
1443
- return await this.queryClient.fetchQuery({
1444
- queryKey: n,
1445
- queryFn: async () => {
1446
- const u = {
1447
- action: "get",
1448
- version: this.apiVersion,
1449
- find: {
1450
- where: {
1451
- type: "dataset"
1452
- },
1453
- limit: i,
1454
- offset: t
1455
- }
1456
- }, h = await this.fetchApi(
1457
- "/securable",
1458
- u
1459
- );
1460
- return {
1461
- data: (h == null ? void 0 : h.rows) || [],
1462
- pagination: {
1463
- offset: t,
1464
- limit: i,
1465
- total: (h == null ? void 0 : h.count) ?? 0,
1466
- pages: Math.ceil(((h == null ? void 0 : h.count) ?? 0) / i)
1467
- }
1468
- };
1469
- }
1470
- });
1471
- }
1472
- /**
1473
- * Search datasets by name or description
1474
- * @param query - Search query
1475
- * @returns List of matching datasets
1476
- */
1477
- async searchDatasets(e, t) {
1478
- if (!e) return [];
1479
- const i = ["datasets", "search", e, t];
1480
- return await this.queryClient.fetchQuery({
1481
- queryKey: i,
1482
- queryFn: async () => {
1483
- const n = {
1484
- action: "get",
1485
- version: this.apiVersion,
1486
- find: {
1487
- where: {
1488
- type: "dataset"
1489
- }
1490
- }
1491
- };
1492
- (e == null ? void 0 : e.length) > 0 && (n.find.search = {
1493
- match_types: ["name"],
1494
- keyphrase: e
1495
- }), 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);
1496
- const u = await this.fetchApi(
1497
- "/securable",
1498
- n
1499
- ), h = {
1500
- data: (u == null ? void 0 : u.rows) || []
1501
- };
1502
- return t != null && t.limit && (h.pagination = {
1503
- offset: (t == null ? void 0 : t.offset) ?? 0,
1504
- limit: t == null ? void 0 : t.limit,
1505
- total: (u == null ? void 0 : u.count) ?? 0,
1506
- pages: Math.ceil(((u == null ? void 0 : u.count) ?? 0) / (t == null ? void 0 : t.limit))
1507
- }), h;
1508
- }
1509
- });
1510
- }
1511
- /**
1512
- * Fetch a specific dataset by ID
1513
- * @param datasetId - Dataset ID
1514
- * @returns Dataset details
1515
- */
1516
- async fetchDatasetsWithColumnsAndFormulas(e) {
1517
- if (!e || e.length === 0)
1518
- throw new Error("At least one dataset ID is required");
1519
- const t = [
1520
- "datasets",
1521
- e,
1522
- this.authKey,
1523
- this.authToken
1524
- ];
1525
- return await this.queryClient.fetchQuery({
1526
- queryKey: t,
1527
- queryFn: async () => {
1528
- const i = {
1529
- action: "get",
1530
- version: this.apiVersion,
1531
- find: {
1532
- where: {
1533
- type: "dataset",
1534
- id: {
1535
- in: e
1536
- }
1537
- },
1538
- attributes: ["name", "id"],
1539
- include: [
1540
- {
1541
- model: "Column",
1542
- attributes: [
1543
- "id",
1544
- "name",
1545
- "description",
1546
- "type",
1547
- "subtype",
1548
- "format",
1549
- "hidden",
1550
- "lowestLevel",
1551
- "expression"
1552
- ],
1553
- separate: !0,
1554
- order: [["order", "asc"]],
1555
- include: [
1556
- {
1557
- model: "Column",
1558
- attributes: [
1559
- "id",
1560
- "securable_id",
1561
- "hierarchy_enabled",
1562
- "currency_id"
1563
- ],
1564
- as: "Joins"
1565
- }
1566
- ]
1567
- },
1568
- {
1569
- model: "Formula",
1570
- attributes: [
1571
- "id",
1572
- "name",
1573
- "description",
1574
- "type",
1575
- "subtype",
1576
- "format",
1577
- "hidden",
1578
- "lowestLevel",
1579
- "expression"
1580
- ]
1581
- }
1582
- ]
1583
- }
1584
- }, n = await this.fetchApi(
1585
- "/securable",
1586
- i
1587
- );
1588
- return (n == null ? void 0 : n.rows) || [];
1589
- }
1590
- });
1591
- }
1592
- /**
1593
- * Fetch a specific dataset by ID
1594
- * @param datasetId - Dataset ID
1595
- * @returns Dataset details
1596
- */
1597
- async fetchDataset(e) {
1598
- if (!e) throw new Error("Dataset ID is required");
1599
- const t = ["dataset", e];
1600
- return await this.queryClient.fetchQuery({
1601
- queryKey: t,
1602
- queryFn: async () => {
1603
- var u;
1604
- const i = {
1605
- action: "get",
1606
- version: this.apiVersion,
1607
- find: {
1608
- where: {
1609
- type: "dataset",
1610
- id: e
1611
- },
1612
- attributes: ["name", "id"],
1613
- include: [
1614
- {
1615
- model: "Column"
1616
- },
1617
- {
1618
- model: "Formula"
1619
- }
1620
- ]
1621
- }
1622
- }, n = await this.fetchApi(
1623
- "/securable",
1624
- i
1625
- );
1626
- return ((u = n == null ? void 0 : n.rows) == null ? void 0 : u[0]) || null;
1627
- }
1628
- });
1629
- }
1630
- /**
1631
- * Fetch data from a dataset with filtering
1632
- * @param datasetId - Dataset ID
1633
- * @param queryParams - Query parameters (filters, sort, etc.)
1634
- * @returns Dataset data
1635
- */
1636
- async fetchData(e) {
1637
- if (!e) throw new Error("Query is required");
1638
- const t = ["data", e];
1639
- return await this.queryClient.fetchQuery({
1640
- queryKey: t,
1641
- queryFn: async () => {
1642
- const i = {
1643
- action: "get",
1644
- version: this.apiVersion,
1645
- find: {
1646
- queries: [e]
1647
- }
1648
- }, n = await this.fetchApi("/data", i);
1649
- return {
1650
- data: (n == null ? void 0 : n.data) || [],
1651
- performance: (n == null ? void 0 : n.performance) || {}
1652
- };
1653
- }
1654
- });
1655
- }
1656
- /**
1657
- * Refresh all queries
1658
- */
1659
- refreshAll() {
1660
- this.queryClient.refetchQueries();
1661
- }
1662
- /**
1663
- * Invalidate cached data for a dataset
1664
- * @param datasetId - Dataset ID (optional)
1665
- */
1666
- invalidateDatasetData(e) {
1667
- e ? (this.queryClient.invalidateQueries({ queryKey: ["dataset", e] }), this.queryClient.invalidateQueries({ queryKey: ["columns", e] })) : this.queryClient.invalidateQueries({ queryKey: ["datasets"] });
1668
- }
1669
- /**
1670
- * Invalidate all cached data
1671
- */
1672
- invalidateAll() {
1673
- this.queryClient.clear();
1674
- }
1675
- /**
1676
- * Create a singleton instance
1677
- * @param config - API configuration
1678
- * @returns Singleton instance
1679
- */
1680
- static getInstance(e = {}) {
1681
- return _.instance ? Object.keys(e).length > 0 && _.instance.configure(e) : _.instance = new _(e), _.instance;
1682
- }
1683
- async fetchDatasetsRecursive(e) {
1684
- if (!e || e.length === 0)
1685
- throw new Error("At least one dataset ID is required");
1686
- const t = [...new Set(e)], i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map(), u = (h) => {
1687
- h && !i.has(h) && !t.includes(h) && t.push(h);
1688
- };
1689
- for (; t.length > 0; ) {
1690
- const h = [];
1691
- for (; t.length > 0 && h.length < 50; ) {
1692
- const a = t.shift();
1693
- i.has(a) || h.push(a);
1694
- }
1695
- if (h.length !== 0)
1696
- try {
1697
- (await this.fetchDatasetsWithColumnsAndFormulas(h)).forEach((l) => {
1698
- const y = this.postProcessDatasetMetadata(l);
1699
- 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) => {
1700
- u(c);
1701
- }), n.set(y.id, y), this.availableDatasets.some((c) => c.id === y.id) || this.availableDatasets.push({
1702
- id: y.id,
1703
- name: y.name,
1704
- columns: y.columns
1705
- });
1706
- });
1707
- } catch (a) {
1708
- console.error("Error fetching datasets recursively:", a);
1709
- }
1710
- }
1711
- return [...n.values()];
1712
- }
1713
- postProcessDatasetMetadata(e) {
1714
- var t;
1715
- e.dateLoaded = /* @__PURE__ */ new Date(), e.outgoingJoins = [];
1716
- for (const i of e.columns)
1717
- if (((t = i.joins) == null ? void 0 : t.length) > 0)
1718
- for (const n of i.joins)
1719
- e.outgoingJoins.push(n);
1720
- return e;
1721
- }
1722
- getAvailableDatasets() {
1723
- return this.availableDatasets;
1724
- }
1725
- getLinkedDatasetsIds(e) {
1726
- const t = this.queryClient.getQueryData(["dataset", e]);
1727
- return t ? (t.outgoingJoins ?? []).map((i) => i.securable_id).filter((i) => i && i !== e) : [];
1728
- }
1729
- }
1730
- const gt = _.getInstance();
1731
- export {
1732
- gt as d
1733
- };