@feedmepos/mf-inventory-portal 1.4.2 → 1.4.4-dev.1

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 (96) hide show
  1. package/dist/App-_rrlFpzI.js +309 -0
  2. package/dist/{ApprovalView-B6WmrP3R.js → ApprovalView-BA13wbQ-.js} +7 -7
  3. package/dist/{BindingsDialog-DAG2toHR.js → BindingsDialog-DMzMv881.js} +2 -2
  4. package/dist/{BindingsPicker-CPbNuwFq.js → BindingsPicker-BGxYZDn_.js} +2 -2
  5. package/dist/{BindingsTable-Hkkel0vq.js → BindingsTable-D7I6KyIQ.js} +3 -3
  6. package/dist/ClosingDraftView-osqh-QJ1.js +3649 -0
  7. package/dist/{ClosingHistoryView-D7GacAqj.js → ClosingHistoryView-DQoNfb5z.js} +5 -5
  8. package/dist/{ClosingTemplateView-DqpbjHK2.js → ClosingTemplateView-Ckq2Veyq.js} +14 -14
  9. package/dist/{DefaultView-BSm6fE5w.js → DefaultView-BYIk34PR.js} +2 -2
  10. package/dist/{DeliveryOrderPrintPreview-DFj56iJk.js → DeliveryOrderPrintPreview-BgHL-gvt.js} +2 -2
  11. package/dist/{FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-CaVUl6v3.js → FmFilterableMenuOptions.vue_vue_type_script_setup_true_lang-yqA2fgtH.js} +2 -2
  12. package/dist/{FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-FunJ5ZX5.js → FmInventoryTableToolbar.vue_vue_type_script_setup_true_lang-Bvma2A4K.js} +2 -2
  13. package/dist/{FmMultiselectDialog-DpekFj8a.js → FmMultiselectDialog-BmTCvmlw.js} +2 -2
  14. package/dist/{FmMultiselectDialog-BE2Tqm4H.js → FmMultiselectDialog-VPcV-FQV.js} +1 -1
  15. package/dist/{FmUnitInput.vue_vue_type_script_setup_true_lang-Bt_kCIFn.js → FmUnitInput.vue_vue_type_script_setup_true_lang-7dkCTYcT.js} +4 -4
  16. package/dist/{ImportView-CAcUO9Pv.js → ImportView-gzF9CWtM.js} +6 -6
  17. package/dist/{IngredientBindedItem.vue_vue_type_script_setup_true_lang-0Abq7FDN.js → IngredientBindedItem.vue_vue_type_script_setup_true_lang-BJKxFdjv.js} +1 -1
  18. package/dist/{IngredientGroupView-CeUfykez.js → IngredientGroupView-DkoVLdIi.js} +5 -5
  19. package/dist/{IngredientsView-Cdhgw3Tw.js → IngredientsView-NBpaVLDo.js} +15 -15
  20. package/dist/{IntegrationExplorerView-BioiObpU.js → IntegrationExplorerView-D4P5Sxcm.js} +5 -5
  21. package/dist/{IntegrationView-BHjOvMpX.js → IntegrationView-B5YN8TEE.js} +13 -13
  22. package/dist/{InventoryBindingForm-D892WEqV.js → InventoryBindingForm-B7VMypYy.js} +1 -1
  23. package/dist/{InventoryBindingForm.vue_vue_type_script_setup_true_lang-BMfmKcz8.js → InventoryBindingForm.vue_vue_type_script_setup_true_lang-DziCetjY.js} +5 -5
  24. package/dist/{InventoryBindingSummary-DOGWF0fo.js → InventoryBindingSummary-B9Vy49tr.js} +1 -1
  25. package/dist/{NumberPrecisionInput.vue_vue_type_script_setup_true_lang-B-dhMJ0F.js → NumberPrecisionInput.vue_vue_type_script_setup_true_lang-DXbiPSqB.js} +1 -1
  26. package/dist/{PremiumBadge.vue_vue_type_script_setup_true_lang-CKuIWTXZ.js → PremiumBadge.vue_vue_type_script_setup_true_lang-7ikbnzXX.js} +1 -1
  27. package/dist/{PublishView-Dh6OiaG1.js → PublishView-BwmWveBB.js} +3 -3
  28. package/dist/{PurchaseOrderPrintPreview-Cpme08gm.js → PurchaseOrderPrintPreview-kajF_P0m.js} +2 -2
  29. package/dist/{ReceiveRequestView-Dldwu3-H.js → ReceiveRequestView-DHYEENEf.js} +10550 -10507
  30. package/dist/{RecipeView-gkZuFdCP.js → RecipeView-BHwVXfLJ.js} +17 -17
  31. package/dist/{SettingsView-wOy_OATI.js → SettingsView-AdpIDPVs.js} +4 -4
  32. package/dist/{StockView-DeLcyQrC.js → StockView-C5AtoijI.js} +19 -19
  33. package/dist/{SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-C2Jax3tb.js → SubsidiaryTreeDialog.vue_vue_type_script_setup_true_lang-B3az_NVO.js} +1 -1
  34. package/dist/{SupplierView-Bf2AW8JH.js → SupplierView-D7Nr2RxT.js} +12 -12
  35. package/dist/{SurchargeView-CJtg87ol.js → SurchargeView-vJimp1Cv.js} +6 -6
  36. package/dist/{SystemTrailDialog.vue_vue_type_script_setup_true_lang-Bfzqxalj.js → SystemTrailDialog.vue_vue_type_script_setup_true_lang-CinFL3QM.js} +2 -2
  37. package/dist/{TemplatePublishDialog.vue_vue_type_script_setup_true_lang-CEz3Yc2Z.js → TemplatePublishDialog.vue_vue_type_script_setup_true_lang-D2SvRBN6.js} +1 -1
  38. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-DlEjTd8E.js +4353 -0
  39. package/dist/{TransferTemplateView-DpWFExzQ.js → TransferTemplateView-C6RmjS-v.js} +18 -18
  40. package/dist/{UnitCostHistoryView-PEexDaAO.js → UnitCostHistoryView-aC4aPr3L.js} +4 -4
  41. package/dist/{UnitDisplayControl.vue_vue_type_script_setup_true_lang-i8HZEphD.js → UnitDisplayControl.vue_vue_type_script_setup_true_lang-CuP7FMd1.js} +4 -4
  42. package/dist/{UnitView-BPyyMHKE.js → UnitView-BCGMlHCV.js} +7 -7
  43. package/dist/{WarehouseView-BmCech19.js → WarehouseView-O3gc_PiU.js} +5 -5
  44. package/dist/{WastageTemplateView-DJOBAWKd.js → WastageTemplateView-H9PA6ryl.js} +14 -14
  45. package/dist/api/purchase-order.d.ts +1 -0
  46. package/dist/api/sse.d.ts +3 -15
  47. package/dist/{app-D4P-koOR.js → app-CItiJtFw.js} +13 -11
  48. package/dist/app.js +1 -1
  49. package/dist/{closing-template-CCvXzoLm.js → closing-template-Cwj3O7Lm.js} +1 -1
  50. package/dist/composable/useSseClient.d.ts +5 -4
  51. package/dist/{date2-XHYHbI0K.js → date2-D00juOhc.js} +1 -1
  52. package/dist/{dayjs.min-pkE_kmHZ.js → dayjs.min-DmEufB_X.js} +1 -1
  53. package/dist/{decimal-CQ7SlCe0.js → decimal-Cfx4iNIN.js} +2 -2
  54. package/dist/{defineDeepModel-CZDkmNol.js → defineDeepModel-Dn4pcA76.js} +1 -1
  55. package/dist/{duplicate-template-BQ0bF_MO.js → duplicate-template-3GCMrDdJ.js} +1 -1
  56. package/dist/{export-CDIp6ydU.js → export-Taxbki8U.js} +2 -2
  57. package/dist/{feature-C4zPjstX.js → feature-CWFT4m6D.js} +426 -400
  58. package/dist/{format-time-from-id-D_USijTz.js → format-time-from-id-DBU5YJL6.js} +1 -1
  59. package/dist/{format-unit-display-CF6-yU7v.js → format-unit-display-Bcg7Sa60.js} +11 -11
  60. package/dist/{import-export.helper-iVXMr9yw.js → import-export.helper-DDM-pvFO.js} +6 -6
  61. package/dist/{index-BIG8c4oA.js → index-BMhosF1x.js} +3 -3
  62. package/dist/{index-EoaZ_eFV.js → index-DHnHIq4-.js} +1 -1
  63. package/dist/{index-CTNLpvtM.js → index-DK0BNrfa.js} +1 -1
  64. package/dist/{inventory-core-dart.default-D6cCA8tk.js → inventory-core-dart.default-B8aW6vKZ.js} +1 -1
  65. package/dist/{lodash-DR7t9CsC.js → lodash-raCw-gUe.js} +1 -1
  66. package/dist/{lz-string-DgqLqrsO.js → lz-string-eBAqN_g9.js} +1 -1
  67. package/dist/{netsuite-ByBZj6uf.js → netsuite-uRj2P-EH.js} +5 -6
  68. package/dist/{number-f4J4YlZT.js → number-C9o5tPfP.js} +3 -3
  69. package/dist/{predefined-templates-BlmLhRsh.js → predefined-templates-YPJMW8GJ.js} +1 -1
  70. package/dist/{purchase-order-template-BS94QDpg.js → purchase-order-template-B6aV2vdS.js} +1 -1
  71. package/dist/{recalculationUtils-D0wl-tgM.js → recalculationUtils-BiZ-pU6y.js} +1 -1
  72. package/dist/{rules-Cpi5Vduo.js → rules-01UCJome.js} +2 -2
  73. package/dist/{stock-BynB5KIH.js → stock-DTp9AhdZ.js} +1 -1
  74. package/dist/{stock-GYUDrBUF.js → stock-SuApOj2U.js} +3 -3
  75. package/dist/stores/feature.d.ts +15 -0
  76. package/dist/{supplier-BDpzWHvm.js → supplier-D60bDAuZ.js} +2 -2
  77. package/dist/{surcharge-ztZ3mUE2.js → surcharge-BWwSWZ1U.js} +1 -1
  78. package/dist/tsconfig.app.tsbuildinfo +1 -1
  79. package/dist/{use-ingredient-select-dialog-xx_W7OyU.js → use-ingredient-select-dialog-B4zci6JI.js} +2 -2
  80. package/dist/{use-inventory-binding-dialog-B_OV8CCL.js → use-inventory-binding-dialog-CgSz72ZS.js} +2 -2
  81. package/dist/{use-template-enabled-locations-ByOi4t2R.js → use-template-enabled-locations-DVLHfYM9.js} +2 -2
  82. package/dist/{use-transfer-locations-BOR-wq8s.js → use-transfer-locations-POSn3UDi.js} +2 -2
  83. package/dist/{useHrmPermission-BtXw89bp.js → useHrmPermission-B9ffPr7i.js} +1 -1
  84. package/dist/{useNavigationMenu-Ds6IBfYX.js → useNavigationMenu-dJYOEiud.js} +2 -2
  85. package/dist/views/receive-request/components/delivery-order-form/CreateFormProps.d.ts +2 -0
  86. package/dist/views/receive-request/components/delivery-order-form/EditFormProps.d.ts +1 -0
  87. package/dist/views/receive-request/helper/extra-items.d.ts +10 -0
  88. package/dist/views/receive-request/helper/extra-items.spec.d.ts +1 -0
  89. package/dist/{vue-i18n-C35dl24s.js → vue-i18n-CqFS0F9S.js} +477 -477
  90. package/dist/{xlsx-CzLrFB_A.js → xlsx-BY0_-lpm.js} +1 -1
  91. package/dist/{xlsx.util-osyDkxYO.js → xlsx.util-DR3_mTtm.js} +3 -3
  92. package/package.json +4 -4
  93. package/dist/App-D8p5pMar.js +0 -310
  94. package/dist/ClosingDraftView-JCtS2MZa.js +0 -3183
  95. package/dist/TransferDetails.vue_vue_type_script_setup_true_lang-CcpH12aM.js +0 -3874
  96. package/dist/useSseClient-q5d7Qjrq.js +0 -502
@@ -1,502 +0,0 @@
1
- import { m as ce } from "./app-D4P-koOR.js";
2
- import { useCoreStore as le } from "@feedmepos/mf-common";
3
- const he = ce((e, t) => ({
4
- getEventsUrl(n) {
5
- return `${e.inventoryBackendUrl}/sse/events?clientId=${encodeURIComponent(n)}`;
6
- },
7
- async addStream(n) {
8
- const r = `${e.inventoryBackendUrl}/sse/streams/add`;
9
- return t.post(r, n);
10
- },
11
- async removeStream(n) {
12
- const r = `${e.inventoryBackendUrl}/sse/streams/remove`;
13
- return t.post(r, n);
14
- }
15
- }));
16
- class ne extends Error {
17
- constructor(t, n) {
18
- super(t), this.name = "ParseError", this.type = n.type, this.field = n.field, this.value = n.value, this.line = n.line;
19
- }
20
- }
21
- function j(e) {
22
- }
23
- function de(e) {
24
- if (typeof e == "function")
25
- throw new TypeError(
26
- "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
27
- );
28
- const { onEvent: t = j, onError: n = j, onRetry: r = j, onComment: d } = e;
29
- let a = "", u = !0, E, y = "", i = "";
30
- function h(c) {
31
- const p = u ? c.replace(/^\xEF\xBB\xBF/, "") : c, [k, J] = ue(`${a}${p}`);
32
- for (const z of k)
33
- o(z);
34
- a = J, u = !1;
35
- }
36
- function o(c) {
37
- if (c === "") {
38
- _();
39
- return;
40
- }
41
- if (c.startsWith(":")) {
42
- d && d(c.slice(c.startsWith(": ") ? 2 : 1));
43
- return;
44
- }
45
- const p = c.indexOf(":");
46
- if (p !== -1) {
47
- const k = c.slice(0, p), J = c[p + 1] === " " ? 2 : 1, z = c.slice(p + J);
48
- m(k, z, c);
49
- return;
50
- }
51
- m(c, "", c);
52
- }
53
- function m(c, p, k) {
54
- switch (c) {
55
- case "event":
56
- i = p;
57
- break;
58
- case "data":
59
- y = `${y}${p}
60
- `;
61
- break;
62
- case "id":
63
- E = p.includes("\0") ? void 0 : p;
64
- break;
65
- case "retry":
66
- /^\d+$/.test(p) ? r(parseInt(p, 10)) : n(
67
- new ne(`Invalid \`retry\` value: "${p}"`, {
68
- type: "invalid-retry",
69
- value: p,
70
- line: k
71
- })
72
- );
73
- break;
74
- default:
75
- n(
76
- new ne(
77
- `Unknown field "${c.length > 20 ? `${c.slice(0, 20)}…` : c}"`,
78
- { type: "unknown-field", field: c, value: p, line: k }
79
- )
80
- );
81
- break;
82
- }
83
- }
84
- function _() {
85
- y.length > 0 && t({
86
- id: E,
87
- event: i || void 0,
88
- // If the data buffer's last character is a U+000A LINE FEED (LF) character,
89
- // then remove the last character from the data buffer.
90
- data: y.endsWith(`
91
- `) ? y.slice(0, -1) : y
92
- }), E = void 0, y = "", i = "";
93
- }
94
- function D(c = {}) {
95
- a && c.consume && o(a), u = !0, E = void 0, y = "", i = "", a = "";
96
- }
97
- return { feed: h, reset: D };
98
- }
99
- function ue(e) {
100
- const t = [];
101
- let n = "", r = 0;
102
- for (; r < e.length; ) {
103
- const d = e.indexOf("\r", r), a = e.indexOf(`
104
- `, r);
105
- let u = -1;
106
- if (d !== -1 && a !== -1 ? u = Math.min(d, a) : d !== -1 ? d === e.length - 1 ? u = -1 : u = d : a !== -1 && (u = a), u === -1) {
107
- n = e.slice(r);
108
- break;
109
- } else {
110
- const E = e.slice(r, u);
111
- t.push(E), r = u + 1, e[r - 1] === "\r" && e[r] === `
112
- ` && r++;
113
- }
114
- }
115
- return [t, n];
116
- }
117
- class se extends Event {
118
- /**
119
- * Constructs a new `ErrorEvent` instance. This is typically not called directly,
120
- * but rather emitted by the `EventSource` object when an error occurs.
121
- *
122
- * @param type - The type of the event (should be "error")
123
- * @param errorEventInitDict - Optional properties to include in the error event
124
- */
125
- constructor(t, n) {
126
- var r, d;
127
- super(t), this.code = (r = n == null ? void 0 : n.code) != null ? r : void 0, this.message = (d = n == null ? void 0 : n.message) != null ? d : void 0;
128
- }
129
- /**
130
- * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
131
- * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
132
- * we explicitly include the properties in the `inspect` method.
133
- *
134
- * This is automatically called by Node.js when you `console.log` an instance of this class.
135
- *
136
- * @param _depth - The current depth
137
- * @param options - The options passed to `util.inspect`
138
- * @param inspect - The inspect function to use (prevents having to import it from `util`)
139
- * @returns A string representation of the error
140
- */
141
- [Symbol.for("nodejs.util.inspect.custom")](t, n, r) {
142
- return r(re(this), n);
143
- }
144
- /**
145
- * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
146
- * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
147
- * we explicitly include the properties in the `inspect` method.
148
- *
149
- * This is automatically called by Deno when you `console.log` an instance of this class.
150
- *
151
- * @param inspect - The inspect function to use (prevents having to import it from `util`)
152
- * @param options - The options passed to `Deno.inspect`
153
- * @returns A string representation of the error
154
- */
155
- [Symbol.for("Deno.customInspect")](t, n) {
156
- return t(re(this), n);
157
- }
158
- }
159
- function pe(e) {
160
- const t = globalThis.DOMException;
161
- return typeof t == "function" ? new t(e, "SyntaxError") : new SyntaxError(e);
162
- }
163
- function H(e) {
164
- return e instanceof Error ? "errors" in e && Array.isArray(e.errors) ? e.errors.map(H).join(", ") : "cause" in e && e.cause instanceof Error ? `${e}: ${H(e.cause)}` : e.message : `${e}`;
165
- }
166
- function re(e) {
167
- return {
168
- type: e.type,
169
- message: e.message,
170
- code: e.code,
171
- defaultPrevented: e.defaultPrevented,
172
- cancelable: e.cancelable,
173
- timeStamp: e.timeStamp
174
- };
175
- }
176
- var oe = (e) => {
177
- throw TypeError(e);
178
- }, te = (e, t, n) => t.has(e) || oe("Cannot " + n), s = (e, t, n) => (te(e, t, "read from private field"), n ? n.call(e) : t.get(e)), f = (e, t, n) => t.has(e) ? oe("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(e) : t.set(e, n), l = (e, t, n, r) => (te(e, t, "write to private field"), t.set(e, n), n), w = (e, t, n) => (te(e, t, "access private method"), n), v, C, x, B, G, $, M, U, S, O, W, N, I, g, K, Y, Q, ie, V, X, R, Z, ee;
179
- class A extends EventTarget {
180
- constructor(t, n) {
181
- var r, d;
182
- super(), f(this, g), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, f(this, v), f(this, C), f(this, x), f(this, B), f(this, G), f(this, $), f(this, M), f(this, U, null), f(this, S), f(this, O), f(this, W, null), f(this, N, null), f(this, I, null), f(this, Y, async (a) => {
183
- var u;
184
- s(this, O).reset();
185
- const { body: E, redirected: y, status: i, headers: h } = a;
186
- if (i === 204) {
187
- w(this, g, R).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
188
- return;
189
- }
190
- if (y ? l(this, x, new URL(a.url)) : l(this, x, void 0), i !== 200) {
191
- w(this, g, R).call(this, `Non-200 status code (${i})`, i);
192
- return;
193
- }
194
- if (!(h.get("content-type") || "").startsWith("text/event-stream")) {
195
- w(this, g, R).call(this, 'Invalid content type, expected "text/event-stream"', i);
196
- return;
197
- }
198
- if (s(this, v) === this.CLOSED)
199
- return;
200
- l(this, v, this.OPEN);
201
- const o = new Event("open");
202
- if ((u = s(this, I)) == null || u.call(this, o), this.dispatchEvent(o), typeof E != "object" || !E || !("getReader" in E)) {
203
- w(this, g, R).call(this, "Invalid response body, expected a web ReadableStream", i), this.close();
204
- return;
205
- }
206
- const m = new TextDecoder(), _ = E.getReader();
207
- let D = !0;
208
- do {
209
- const { done: c, value: p } = await _.read();
210
- p && s(this, O).feed(m.decode(p, { stream: !c })), c && (D = !1, s(this, O).reset(), w(this, g, Z).call(this));
211
- } while (D);
212
- }), f(this, Q, (a) => {
213
- l(this, S, void 0), !(a.name === "AbortError" || a.type === "aborted") && w(this, g, Z).call(this, H(a));
214
- }), f(this, V, (a) => {
215
- typeof a.id == "string" && l(this, U, a.id);
216
- const u = new MessageEvent(a.event || "message", {
217
- data: a.data,
218
- origin: s(this, x) ? s(this, x).origin : s(this, C).origin,
219
- lastEventId: a.id || ""
220
- });
221
- s(this, N) && (!a.event || a.event === "message") && s(this, N).call(this, u), this.dispatchEvent(u);
222
- }), f(this, X, (a) => {
223
- l(this, $, a);
224
- }), f(this, ee, () => {
225
- l(this, M, void 0), s(this, v) === this.CONNECTING && w(this, g, K).call(this);
226
- });
227
- try {
228
- if (t instanceof URL)
229
- l(this, C, t);
230
- else if (typeof t == "string")
231
- l(this, C, new URL(t, fe()));
232
- else
233
- throw new Error("Invalid URL");
234
- } catch {
235
- throw pe("An invalid or illegal string was specified");
236
- }
237
- l(this, O, de({
238
- onEvent: s(this, V),
239
- onRetry: s(this, X)
240
- })), l(this, v, this.CONNECTING), l(this, $, 3e3), l(this, G, (r = n == null ? void 0 : n.fetch) != null ? r : globalThis.fetch), l(this, B, (d = n == null ? void 0 : n.withCredentials) != null ? d : !1), w(this, g, K).call(this);
241
- }
242
- /**
243
- * Returns the state of this EventSource object's connection. It can have the values described below.
244
- *
245
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
246
- *
247
- * Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
248
- * defined in the TypeScript `dom` library.
249
- *
250
- * @public
251
- */
252
- get readyState() {
253
- return s(this, v);
254
- }
255
- /**
256
- * Returns the URL providing the event stream.
257
- *
258
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
259
- *
260
- * @public
261
- */
262
- get url() {
263
- return s(this, C).href;
264
- }
265
- /**
266
- * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
267
- *
268
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
269
- */
270
- get withCredentials() {
271
- return s(this, B);
272
- }
273
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
274
- get onerror() {
275
- return s(this, W);
276
- }
277
- set onerror(t) {
278
- l(this, W, t);
279
- }
280
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
281
- get onmessage() {
282
- return s(this, N);
283
- }
284
- set onmessage(t) {
285
- l(this, N, t);
286
- }
287
- /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
288
- get onopen() {
289
- return s(this, I);
290
- }
291
- set onopen(t) {
292
- l(this, I, t);
293
- }
294
- addEventListener(t, n, r) {
295
- const d = n;
296
- super.addEventListener(t, d, r);
297
- }
298
- removeEventListener(t, n, r) {
299
- const d = n;
300
- super.removeEventListener(t, d, r);
301
- }
302
- /**
303
- * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
304
- *
305
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
306
- *
307
- * @public
308
- */
309
- close() {
310
- s(this, M) && clearTimeout(s(this, M)), s(this, v) !== this.CLOSED && (s(this, S) && s(this, S).abort(), l(this, v, this.CLOSED), l(this, S, void 0));
311
- }
312
- }
313
- v = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakSet(), /**
314
- * Connect to the given URL and start receiving events
315
- *
316
- * @internal
317
- */
318
- K = function() {
319
- l(this, v, this.CONNECTING), l(this, S, new AbortController()), s(this, G)(s(this, C), w(this, g, ie).call(this)).then(s(this, Y)).catch(s(this, Q));
320
- }, Y = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), /**
321
- * Get request options for the `fetch()` request
322
- *
323
- * @returns The request options
324
- * @internal
325
- */
326
- ie = function() {
327
- var e;
328
- const t = {
329
- // [spec] Let `corsAttributeState` be `Anonymous`…
330
- // [spec] …will have their mode set to "cors"…
331
- mode: "cors",
332
- redirect: "follow",
333
- headers: { Accept: "text/event-stream", ...s(this, U) ? { "Last-Event-ID": s(this, U) } : void 0 },
334
- cache: "no-store",
335
- signal: (e = s(this, S)) == null ? void 0 : e.signal
336
- };
337
- return "window" in globalThis && (t.credentials = this.withCredentials ? "include" : "same-origin"), t;
338
- }, V = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakMap(), /**
339
- * Handles the process referred to in the EventSource specification as "failing a connection".
340
- *
341
- * @param error - The error causing the connection to fail
342
- * @param code - The HTTP status code, if available
343
- * @internal
344
- */
345
- R = function(e, t) {
346
- var n;
347
- s(this, v) !== this.CLOSED && l(this, v, this.CLOSED);
348
- const r = new se("error", { code: t, message: e });
349
- (n = s(this, W)) == null || n.call(this, r), this.dispatchEvent(r);
350
- }, /**
351
- * Schedules a reconnection attempt against the EventSource endpoint.
352
- *
353
- * @param message - The error causing the connection to fail
354
- * @param code - The HTTP status code, if available
355
- * @internal
356
- */
357
- Z = function(e, t) {
358
- var n;
359
- if (s(this, v) === this.CLOSED)
360
- return;
361
- l(this, v, this.CONNECTING);
362
- const r = new se("error", { code: t, message: e });
363
- (n = s(this, W)) == null || n.call(this, r), this.dispatchEvent(r), l(this, M, setTimeout(s(this, ee), s(this, $)));
364
- }, ee = /* @__PURE__ */ new WeakMap(), /**
365
- * ReadyState representing an EventSource currently trying to connect
366
- *
367
- * @public
368
- */
369
- A.CONNECTING = 0, /**
370
- * ReadyState representing an EventSource connection that is open (eg connected)
371
- *
372
- * @public
373
- */
374
- A.OPEN = 1, /**
375
- * ReadyState representing an EventSource connection that is closed (eg disconnected)
376
- *
377
- * @public
378
- */
379
- A.CLOSED = 2;
380
- Object.defineProperty(A, Symbol.for("eventsource.supports-fetch-override"), {
381
- value: !0,
382
- writable: !1,
383
- configurable: !1,
384
- enumerable: !1
385
- });
386
- function fe() {
387
- const e = "document" in globalThis ? globalThis.document : void 0;
388
- return e && typeof e == "object" && "baseURI" in e && typeof e.baseURI == "string" ? e.baseURI : void 0;
389
- }
390
- const me = 3e3, L = ve(), T = /* @__PURE__ */ new Map();
391
- let b = null, F = null, q = !1, P = "";
392
- function ve() {
393
- var t, n;
394
- const e = (n = (t = globalThis.crypto) == null ? void 0 : t.randomUUID) == null ? void 0 : n.call(t);
395
- return e || `sse-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
396
- }
397
- function ae(e) {
398
- return `${e.type}:${JSON.stringify(e.params)}`;
399
- }
400
- function ge() {
401
- const e = he(), t = le();
402
- function n() {
403
- var h;
404
- const i = ((h = t.sessionUser.value) == null ? void 0 : h.token) ?? "";
405
- i && (q = !0, !(b && P === i) && (P = i, a()));
406
- }
407
- async function r(i, h) {
408
- const o = ae(i), m = T.get(o);
409
- if (m)
410
- return m.handlers.add(h), null;
411
- T.set(o, {
412
- subscription: i,
413
- handlers: /* @__PURE__ */ new Set([h])
414
- }), q || n();
415
- try {
416
- return await e.addStream({
417
- clientId: L,
418
- type: i.type,
419
- params: i.params
420
- });
421
- } catch (_) {
422
- return console.error("Failed to add stream subscription", _), null;
423
- }
424
- }
425
- async function d(i, h) {
426
- const o = ae(i), m = T.get(o);
427
- if (m && (m.handlers.delete(h), !(m.handlers.size > 0))) {
428
- T.delete(o);
429
- try {
430
- await e.removeStream({
431
- clientId: L,
432
- type: i.type,
433
- params: i.params
434
- });
435
- } catch (_) {
436
- console.error("Failed to remove stream subscription", _);
437
- }
438
- }
439
- }
440
- function a() {
441
- if (!P)
442
- return;
443
- y(), b && b.close();
444
- const i = new A(e.getEventsUrl(L), {
445
- fetch: (h, o) => fetch(h, {
446
- ...o,
447
- headers: {
448
- ...(o == null ? void 0 : o.headers) ?? {},
449
- authorization: `Bearer ${P}`
450
- }
451
- })
452
- });
453
- b = i, i.onopen = () => {
454
- console.log("SSE connection open"), u();
455
- }, i.onmessage = (h) => {
456
- try {
457
- if (!h.data) return;
458
- const o = JSON.parse(h.data);
459
- console.log("Received SSE message", o);
460
- const m = o.data ? typeof o.data == "string" ? JSON.parse(o.data) : o.data : o;
461
- E(m);
462
- } catch (o) {
463
- console.error("Failed to parse SSE message", o);
464
- }
465
- }, i.onerror = (h) => {
466
- console.error("SSE connection error", h), b === i && (b = null), i.close(), q && (F = setTimeout(() => {
467
- a();
468
- }, me));
469
- };
470
- }
471
- async function u() {
472
- for (const { subscription: i } of T.values())
473
- try {
474
- await e.addStream({
475
- clientId: L,
476
- type: i.type,
477
- params: i.params
478
- });
479
- } catch (h) {
480
- console.error("Failed to replay stream subscription", h);
481
- }
482
- }
483
- function E(i) {
484
- for (const h of T.values())
485
- for (const o of h.handlers)
486
- Promise.resolve(o(i)).catch((m) => {
487
- console.error("Failed to handle SSE message", m);
488
- });
489
- }
490
- function y() {
491
- F && (clearTimeout(F), F = null);
492
- }
493
- return {
494
- clientId: L,
495
- start: n,
496
- addStream: r,
497
- removeStream: d
498
- };
499
- }
500
- export {
501
- ge as u
502
- };