@cloudlet/toast 1.0.0-rc.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +42 -7
  2. package/README.md +5 -4
  3. package/dist/contracts/events.d.ts +1 -1
  4. package/dist/contracts/events.d.ts.map +1 -1
  5. package/dist/core/bridge.d.ts +5 -0
  6. package/dist/core/bridge.d.ts.map +1 -0
  7. package/dist/core/bridge.js +277 -0
  8. package/dist/core/bridge.js.map +1 -0
  9. package/dist/core/controller.d.ts +113 -3
  10. package/dist/core/controller.d.ts.map +1 -1
  11. package/dist/core/controller.js +416 -583
  12. package/dist/core/controller.js.map +1 -1
  13. package/dist/react/announcer.d.ts.map +1 -1
  14. package/dist/react/announcer.js +29 -23
  15. package/dist/react/announcer.js.map +1 -1
  16. package/dist/react/bindings.d.ts +9 -0
  17. package/dist/react/bindings.d.ts.map +1 -1
  18. package/dist/react/bindings.js +32 -69
  19. package/dist/react/bindings.js.map +1 -1
  20. package/dist/react/card.d.ts +1 -1
  21. package/dist/react/card.js.map +1 -1
  22. package/dist/react/generators.d.ts +2 -2
  23. package/dist/react/generators.js.map +1 -1
  24. package/dist/react/gestures.js.map +1 -1
  25. package/dist/react/host.d.ts.map +1 -1
  26. package/dist/react/host.js +1 -1
  27. package/dist/react/host.js.map +1 -1
  28. package/dist/react/motion.d.ts +3 -3
  29. package/dist/react/motion.js.map +1 -1
  30. package/dist/react/plan.d.ts +1 -1
  31. package/dist/react/plan.d.ts.map +1 -1
  32. package/dist/react/plan.js.map +1 -1
  33. package/dist/react/renderer.d.ts +7 -0
  34. package/dist/react/renderer.d.ts.map +1 -0
  35. package/dist/react/renderer.js +62 -0
  36. package/dist/react/renderer.js.map +1 -0
  37. package/dist/react.d.ts +4 -4
  38. package/dist/react.d.ts.map +1 -1
  39. package/package.json +4 -2
  40. package/src/contracts/events.ts +2 -1
  41. package/src/core/bridge.ts +280 -0
  42. package/src/core/controller.ts +83 -268
  43. package/src/react/announcer.ts +9 -0
  44. package/src/react/bindings.tsx +28 -72
  45. package/src/react/card.tsx +3 -3
  46. package/src/react/generators.ts +2 -2
  47. package/src/react/gestures.ts +1 -1
  48. package/src/react/host.tsx +10 -4
  49. package/src/react/motion.ts +4 -4
  50. package/src/react/plan.ts +2 -2
  51. package/src/react/renderer.tsx +77 -0
  52. package/src/react.ts +4 -4
@@ -1,88 +1,78 @@
1
- import { copyContent as e, patchContent as t, validDelay as n, validateContent as r, validateOptions as i, validatePatch as a, validateSpec as o, validateTrackOptions as s } from "./validation.js";
2
- //#region src/core/controller.ts
3
- var c = 600, l = Object.freeze, u = /* @__PURE__ */ new WeakSet(), ee = /* @__PURE__ */ new WeakMap(), d = 0, f = l([]), te = l({
1
+ import { copyContent as e, patchContent as t, validateContent as n, validateOptions as r, validatePatch as i, validateSpec as a, validateTrackOptions as o } from "./validation.js";
2
+ var s = Object.freeze, c = /* @__PURE__ */ new WeakSet(), l = /* @__PURE__ */ new WeakMap(), u = 0, d = s([]), f = s({
4
3
  open: !1,
5
4
  reason: null,
6
5
  current: null
7
- }), p = l({
6
+ }), p = s({
8
7
  controller: null,
9
8
  revision: 0,
10
9
  disposed: !1,
11
- notifications: f,
12
- stack: f,
13
- island: te,
14
- overflow: l({
10
+ notifications: d,
11
+ stack: d,
12
+ island: f,
13
+ overflow: s({
15
14
  count: 0,
16
15
  pending: !1
17
16
  })
18
- }), m = l({
17
+ }), m = s({
19
18
  ...p,
20
19
  presentation: null,
21
20
  focusRequest: null,
22
- announcements: l({
23
- notifications: f,
21
+ announcements: s({
22
+ notifications: d,
24
23
  overflowCount: 0
25
24
  })
26
- }), h = l({ status: "idle" }), g = l({ status: "applied" }), _ = l({ status: "unchanged" }), v = (e) => ({
25
+ }), h = s({ status: "idle" }), g = s({ status: "applied" }), _ = s({ status: "unchanged" }), v = (e) => ({
27
26
  status: "rejected",
28
27
  reason: e
29
28
  });
30
29
  function y(e) {
31
- let t = ee.get(e);
30
+ let t = l.get(e);
32
31
  if (!t) throw TypeError("Controller was not created by this Cloudlet package instance");
33
32
  return t;
34
33
  }
35
- function b(f, y) {
36
- let b = i(f);
37
- if (!y?.clock || typeof y.clock.now != "function" || typeof y.clock.schedule != "function") throw TypeError("Cloudlet requires a monotonic clock");
38
- let x = y.clock;
39
- if (typeof y.createCancellation != "function") throw TypeError("Cloudlet requires a cancellation source factory");
40
- let S = `cloudlet-${++d}`, C = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Set(), O = [], k = null, A = null, j = null, M = null, ne = 0, re = 0, ie = 0, ae = 0, N = null, P = null, F, I, L = null, R = null, oe = 0, z = 0, B = 0, V = !1, se = !1, ce = null, le = 0, ue, de, H = () => `${S}:${++ne}`, fe = () => [...C.values()].reverse(), pe = () => fe()[0] ?? null, me = (e) => {
34
+ function b(d, m) {
35
+ let y = r(d);
36
+ if (!m?.clock || typeof m.clock.now != "function" || typeof m.clock.schedule != "function") throw TypeError("Cloudlet requires a monotonic clock");
37
+ let b = m.clock;
38
+ if (typeof m.createCancellation != "function") throw TypeError("Cloudlet requires a cancellation source factory");
39
+ let x = `cloudlet-${++u}`, S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Set(), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Set(), D = [], O = null, k = null, A = null, j = null, ee = 0, M = 0, N = 0, te = 0, P = null, F = null, I, L, R = null, z = null, ne = 0, B = 0, V = 0, H = !1, re = !1, ie = null, ae = 0, oe, se, U = () => `${x}:${++ee}`, ce = () => [...S.values()].reverse(), le = () => ce()[0] ?? null, ue = (e) => {
41
40
  let t = e.operation?.getSnapshot();
42
41
  return !!t?.canRetry && t.status !== "fulfilled";
43
- }, he = (e) => !!e.content.action || me(e) || e.content.attention === "open", ge = (e) => {
42
+ }, de = (e) => !!e.content.action || ue(e) || e.content.attention === "open", fe = (e) => {
44
43
  let t = e.content.attention ?? "auto";
45
- return t === "open" || t === "auto" && (he(e) || !!e.content.description);
46
- }, _e = () => D.has("hover") || D.has("focus") || [...C.values()].some((e) => e.pauses.has("gesture")), ve = (e) => {
47
- let t = e === P;
44
+ return t === "open" || t === "auto" && (de(e) || !!e.content.description);
45
+ }, pe = () => E.has("hover") || E.has("focus") || [...S.values()].some((e) => e.pauses.has("gesture")), me = (e) => {
46
+ let t = e === F;
48
47
  return [
49
48
  ...t ? [] : ["inactive"],
50
- ...j === null ? ["no-host"] : [],
49
+ ...A === null ? ["no-host"] : [],
51
50
  ...t && !e.readable ? ["presentation-pending"] : [],
52
- ...t && N && (N.reason === "user" || he(e)) ? ["island"] : [],
51
+ ...t && P && (P.reason === "user" || de(e)) ? ["island"] : [],
53
52
  ...e.action.status === "pending" ? ["action-pending"] : [],
54
- ...D,
53
+ ...E,
55
54
  ...e.pauses
56
55
  ];
57
- }, U = (e) => {
58
- if (V) return "disposed";
59
- if (typeof e != "object" || !e || !u.has(e)) return "invalid-handle";
60
- if (e.controller !== S) return "foreign-controller";
61
- if (C.get(e.id)?.handle !== e) return "stale-handle";
62
- }, ye = (e) => V ? "disposed" : j === null || e !== j ? "stale-lease" : void 0, be = (e) => U(e) ?? (C.get(e.id) === P ? void 0 : "not-current");
63
- function W(e) {
56
+ }, he = (e) => {
57
+ if (H) return "disposed";
58
+ if (typeof e != "object" || !e || !c.has(e)) return "invalid-handle";
59
+ if (e.controller !== x) return "foreign-controller";
60
+ if (S.get(e.id)?.handle !== e) return "stale-handle";
61
+ };
62
+ function ge(e) {
64
63
  return (t, ...n) => {
65
- let r = U(t);
66
- return r ? v(r) : e(C.get(t.id), ...n);
64
+ let r = he(t);
65
+ return r ? v(r) : e(S.get(t.id), ...n);
67
66
  };
68
67
  }
69
- function xe(e) {
70
- return W((t, ...n) => t === P ? e(t, ...n) : v("not-current"));
71
- }
72
- function Se(e) {
73
- return W((t, n, ...r) => {
74
- let i = t.operation;
75
- return i ? i.getSnapshot().token === n ? e(i, ...r) : v("stale-operation-token") : v("no-operation");
76
- });
77
- }
78
- function G(e) {
79
- q([{
68
+ function W(e) {
69
+ K([{
80
70
  type: "diagnostic",
81
- diagnostic: l({ ...e })
71
+ diagnostic: s({ ...e })
82
72
  }]);
83
73
  }
84
- function K(e, t, n, r) {
85
- G({
74
+ function G(e, t, n, r) {
75
+ W({
86
76
  code: e,
87
77
  source: t,
88
78
  message: `${t} failed`,
@@ -90,211 +80,211 @@ function b(f, y) {
90
80
  ...r ? { handle: r } : {}
91
81
  });
92
82
  }
93
- function Ce(e, t) {
83
+ function _e(e, t) {
94
84
  for (let n of [...e]) if (e.has(n)) try {
95
85
  n();
96
86
  } catch (e) {
97
- K("listener-error", t, e);
87
+ G("listener-error", t, e);
98
88
  }
99
89
  }
100
- function q(e, t = !1, n = x.now(), r = !1, i = !1) {
101
- if (O.push(() => {
102
- t && Ce(w, "subscribe");
90
+ function K(e, t = !1, n = b.now(), r = !1, i = !1) {
91
+ if (D.push(() => {
92
+ t && _e(C, "subscribe");
103
93
  for (let t of e) {
104
94
  if ("callback" in t) {
105
95
  try {
106
96
  t.callback();
107
97
  } catch (e) {
108
- K("callback-error", t.source, e, t.handle);
98
+ G("callback-error", t.source, e, t.handle);
109
99
  }
110
100
  continue;
111
101
  }
112
- let e = l({
102
+ let e = s({
113
103
  ...t,
114
- controller: S,
115
- sequence: ++ae,
116
- at: i ? x.now() : n
104
+ controller: x,
105
+ sequence: ++te,
106
+ at: i ? b.now() : n
117
107
  });
118
- for (let t of [...T]) if (T.has(t)) try {
108
+ for (let t of [...w]) if (w.has(t)) try {
119
109
  t(e);
120
110
  } catch (t) {
121
- e.type !== "diagnostic" && K("listener-error", "onEvent", t);
111
+ e.type !== "diagnostic" && G("listener-error", "onEvent", t);
122
112
  }
123
113
  if (e.type === "diagnostic") try {
124
- b.onDiagnostic?.(e.diagnostic);
114
+ y.onDiagnostic?.(e.diagnostic);
125
115
  } catch {}
126
116
  }
127
- if (r && q([{ type: "disposed" }], !1, n, !1, !0), i) {
128
- w.clear(), T.clear();
129
- for (let e of E.keys()) e.clear();
130
- E.clear();
117
+ if (r && K([{ type: "disposed" }], !1, n, !1, !0), i) {
118
+ C.clear(), w.clear();
119
+ for (let e of T.keys()) e.clear();
120
+ T.clear();
131
121
  }
132
- }), !se) {
133
- se = !0;
122
+ }), !re) {
123
+ re = !0;
134
124
  try {
135
125
  let e;
136
- for (; e = O.shift();) e();
126
+ for (; e = D.shift();) e();
137
127
  } finally {
138
- se = !1;
128
+ re = !1;
139
129
  }
140
130
  }
141
131
  }
142
- function J() {
143
- let e = x.now();
144
- for (let t of C.values()) t.activeSince !== null && t.remaining !== null && (t.remaining = Math.max(0, t.remaining - Math.max(0, e - t.activeSince)), t.activeSince = e);
132
+ function q() {
133
+ let e = b.now();
134
+ for (let t of S.values()) t.activeSince !== null && t.remaining !== null && (t.remaining = Math.max(0, t.remaining - Math.max(0, e - t.activeSince)), t.activeSince = e);
145
135
  return e;
146
136
  }
147
- function we() {
148
- ++le, ce?.(), ce = null;
137
+ function ve() {
138
+ ++ae, ie?.(), ie = null;
149
139
  }
150
- function Te(e) {
151
- we();
140
+ function ye(e) {
141
+ ve();
152
142
  let t = Infinity;
153
- for (let n of C.values()) {
154
- let r = n.remaining !== null && ve(n).length === 0 && !V;
143
+ for (let n of S.values()) {
144
+ let r = n.remaining !== null && me(n).length === 0 && !H;
155
145
  n.activeSince = r ? e : null, r && (t = Math.min(t, e + n.remaining));
156
146
  }
157
147
  if (!Number.isFinite(t)) return;
158
- let n = le;
159
- ce = x.schedule(t, () => {
160
- if (V || n !== le) return;
161
- let e = J(), t = [...C.values()].filter((e) => e.activeSince !== null && e.remaining === 0), r = [];
162
- for (let e of t) Pe(e, "timeout", r);
163
- t.length ? Y(r, e) : Te(e);
148
+ let n = ae;
149
+ ie = b.schedule(t, () => {
150
+ if (H || n !== ae) return;
151
+ let e = q(), t = [...S.values()].filter((e) => e.activeSince !== null && e.remaining === 0), r = [];
152
+ for (let e of t) Q(e, "timeout", r);
153
+ t.length ? J(r, e) : ye(e);
164
154
  });
165
155
  }
166
- function Ee() {
167
- let e = [...C.values()], t = l(e.map((e) => l({
156
+ function be() {
157
+ let e = [...S.values()], t = s(e.map((e) => s({
168
158
  handle: e.handle,
169
159
  kind: e.kind,
170
160
  content: e.content,
171
161
  priority: e.priority,
172
162
  occurrences: e.occurrences,
173
- location: e === P ? "current" : "stack",
163
+ location: e === F ? "current" : "stack",
174
164
  remainingMs: e.remaining,
175
- pauseReasons: l(ve(e)),
165
+ pauseReasons: s(me(e)),
176
166
  operation: e.operation?.getSnapshot() ?? null,
177
167
  action: e.action
178
168
  })));
179
- ue = l({
180
- controller: S,
181
- revision: ie,
182
- disposed: V,
169
+ oe = s({
170
+ controller: x,
171
+ revision: N,
172
+ disposed: H,
183
173
  notifications: t,
184
- stack: l(fe().map((e) => e.handle)),
185
- island: N ? l({
174
+ stack: s(ce().map((e) => e.handle)),
175
+ island: P ? s({
186
176
  open: !0,
187
- reason: N.reason,
188
- current: N.current.handle
189
- }) : te,
190
- overflow: l({
191
- count: z,
192
- pending: z > 0
177
+ reason: P.reason,
178
+ current: P.current.handle
179
+ }) : f,
180
+ overflow: s({
181
+ count: B,
182
+ pending: B > 0
193
183
  })
194
- }), de = l({
195
- ...ue,
196
- presentation: P ? l({
197
- handle: P.handle,
198
- token: P.presentation,
199
- readable: P.readable
184
+ }), se = s({
185
+ ...oe,
186
+ presentation: F ? s({
187
+ handle: F.handle,
188
+ token: F.presentation,
189
+ readable: F.readable
200
190
  }) : null,
201
- focusRequest: A,
202
- announcements: l({
203
- overflowCount: B,
204
- notifications: l(e.map((e) => l({
191
+ focusRequest: k,
192
+ announcements: s({
193
+ overflowCount: V,
194
+ notifications: s(e.map((e) => s({
205
195
  handle: e.handle,
206
196
  queued: e.queuedAnnounced,
207
197
  firstPresentation: e.firstAnnounced,
208
198
  occurrences: e.occurrencesAnnounced,
209
199
  action: e.actionAnnounced ?? null,
210
- operation: e.operation ? l({
200
+ operation: e.operation ? s({
211
201
  token: e.operation.getSnapshot().token,
212
- phases: l([...e.operationAnnounced])
202
+ phases: s([...e.operationAnnounced])
213
203
  }) : null
214
204
  })))
215
205
  })
216
206
  });
217
207
  }
218
- function Y(e = [], t = x.now(), n = !1) {
219
- ke(), Te(t), Me(t), ++ie, Ee(), q(e, !0, t, n);
208
+ function J(e = [], t = b.now(), n = !1) {
209
+ Ce(), ye(t), Ee(t), ++N, be(), K(e, !0, t, n);
220
210
  }
221
- function X(e, t = !1) {
222
- let n = J(), r = [];
223
- return e(r), Y(r, n, t), g;
211
+ function Y(e, t = !1) {
212
+ let n = q(), r = [];
213
+ return e(r), J(r, n, t), g;
224
214
  }
225
- function De(e) {
226
- e.readable = !1, e.presentation = j === null ? null : H();
215
+ function xe(e) {
216
+ e.readable = !1, e.presentation = A === null ? null : U();
227
217
  }
228
- function Oe(e) {
229
- e.presentation = null, e.readable = !1, e.pauses.clear(), k === e.handle && (k = null), A?.target.kind === "notification" && A.target.handle === e.handle && (A = null);
218
+ function Se(e) {
219
+ e.presentation = null, e.readable = !1, e.pauses.clear(), O === e.handle && (O = null), k?.target.kind === "notification" && k.target.handle === e.handle && (k = null);
230
220
  }
231
- function ke() {
232
- let e = N ? N.current : pe();
233
- e !== P && (P && Oe(P), P = e, e && De(e));
221
+ function Ce() {
222
+ let e = P ? P.current : le();
223
+ e !== F && (F && Se(F), F = e, e && xe(e));
234
224
  }
235
- function Ae() {
236
- ++oe, R?.(), R = null;
225
+ function we() {
226
+ ++ne, z?.(), z = null;
237
227
  }
238
- function je(e, t) {
239
- ge(e) && (L = {
228
+ function Te(e, t) {
229
+ fe(e) && (R = {
240
230
  record: e,
241
- due: t + (F ?? b.attentionDelay ?? c),
231
+ due: t + (I ?? y.attentionDelay ?? 600),
242
232
  waiting: !1
243
233
  });
244
234
  }
245
- function Me(e) {
246
- Ae();
247
- let t = L;
248
- if (!t || V) return;
249
- if (j === null) {
235
+ function Ee(e) {
236
+ we();
237
+ let t = R;
238
+ if (!t || H) return;
239
+ if (A === null) {
250
240
  t.waiting = !0;
251
241
  return;
252
242
  }
253
243
  if (t.waiting) {
254
- if (_e()) return;
255
- t.waiting = !1, t.due = e + (F ?? b.attentionDelay ?? c);
244
+ if (pe()) return;
245
+ t.waiting = !1, t.due = e + (I ?? y.attentionDelay ?? 600);
256
246
  }
257
- let n = oe;
258
- R = x.schedule(t.due, () => {
259
- if (V || n !== oe || L !== t) return;
260
- let e = x.now();
247
+ let n = ne;
248
+ z = b.schedule(t.due, () => {
249
+ if (H || n !== ne || R !== t) return;
250
+ let e = b.now();
261
251
  if (e < t.due) {
262
- Me(e);
252
+ Ee(e);
263
253
  return;
264
254
  }
265
- if (R = null, _e()) {
255
+ if (z = null, pe()) {
266
256
  t.waiting = !0;
267
257
  return;
268
258
  }
269
- L = null;
259
+ R = null;
270
260
  let r = t.record;
271
- ge(r) && N?.current !== r && X(() => {
272
- N ? N.current = r : N = {
261
+ fe(r) && P?.current !== r && Y(() => {
262
+ P ? P.current = r : P = {
273
263
  reason: "attention",
274
264
  current: r
275
265
  };
276
266
  });
277
267
  });
278
268
  }
279
- let Z = (e) => (e ?? b.autoDismiss) !== !1;
280
- function Ne(e) {
281
- let t = Z(e) !== Z(I);
282
- if (I = e, t) for (let e of C.values()) e.remaining = Q(e);
269
+ let X = (e) => (e ?? y.autoDismiss) !== !1;
270
+ function De(e) {
271
+ let t = X(e) !== X(L);
272
+ if (L = e, t) for (let e of S.values()) e.remaining = Z(e);
283
273
  }
284
- function Q(e) {
285
- return Z(I) ? e.content.duration === void 0 ? (e.kind === "info" || e.kind === "success") && !e.content.action ? 6e3 : null : e.content.duration : null;
274
+ function Z(e) {
275
+ return X(L) ? e.content.duration === void 0 ? (e.kind === "info" || e.kind === "success") && !e.content.action ? 6e3 : null : e.content.duration : null;
286
276
  }
287
- function Pe(e, t, n) {
288
- if (N?.current === e) {
289
- let t = fe(), n = t.indexOf(e), r = t[n + 1] ?? t[n - 1];
290
- r ? N.current = r : N = null;
277
+ function Q(e, t, n) {
278
+ if (P?.current === e) {
279
+ let t = ce(), n = t.indexOf(e), r = t[n + 1] ?? t[n - 1];
280
+ r ? P.current = r : P = null;
291
281
  }
292
- if (L?.record === e && (L = null), C.delete(e.handle.id), e.operation && n.push(e.operation.detach()), n.push({
282
+ if (R?.record === e && (R = null), S.delete(e.handle.id), e.operation && n.push(e.operation.detach()), n.push({
293
283
  type: "closed",
294
284
  handle: e.handle,
295
285
  reason: t
296
286
  }), e.onClose) {
297
- let r = e.onClose, i = l({
287
+ let r = e.onClose, i = s({
298
288
  handle: e.handle,
299
289
  reason: t
300
290
  });
@@ -305,39 +295,39 @@ function b(f, y) {
305
295
  });
306
296
  }
307
297
  }
308
- let Fe = W((e, t) => X((n) => Pe(e, t, n)));
309
- function Ie() {
310
- return V ? v("disposed") : z ? X((e) => {
298
+ let Oe = ge((e, t) => Y((n) => Q(e, t, n)));
299
+ function ke() {
300
+ return H ? v("disposed") : B ? Y((e) => {
311
301
  e.push({
312
302
  type: "overflow-acknowledged",
313
- count: z
314
- }), z = B = 0, A?.target.kind === "overflow" && (A = null);
303
+ count: B
304
+ }), B = V = 0, k?.target.kind === "overflow" && (k = null);
315
305
  }) : _;
316
306
  }
317
- function Le(e, t) {
307
+ function Ae(e, t) {
318
308
  if (typeof t != "function") throw TypeError("Listener must be a function");
319
- return V ? () => {} : (e.add(t), () => {
309
+ return H ? () => {} : (e.add(t), () => {
320
310
  e.delete(t);
321
311
  });
322
312
  }
323
- function Re(e) {
324
- if (V) return v("disposed");
325
- let t = o(e);
326
- return t.length ? (G({
313
+ function je(e) {
314
+ if (H) return v("disposed");
315
+ let t = a(e);
316
+ return t.length ? (W({
327
317
  code: "invalid-input",
328
318
  source: "show",
329
319
  message: "Invalid notification specification"
330
320
  }), {
331
321
  ...v("invalid-input"),
332
322
  issues: t
333
- }) : ze(e);
323
+ }) : Me(e);
334
324
  }
335
- function ze(t, n) {
336
- if (t.id !== void 0 && C.has(t.id)) return v("id-conflict");
337
- let r = t.dedupeKey === void 0 ? void 0 : [...C.values()].find((e) => e.dedupeKey === t.dedupeKey);
325
+ function Me(t, n) {
326
+ if (t.id !== void 0 && S.has(t.id)) return v("id-conflict");
327
+ let r = t.dedupeKey === void 0 ? void 0 : [...S.values()].find((e) => e.dedupeKey === t.dedupeKey);
338
328
  if (r) {
339
329
  let e = r.occurrences;
340
- return X((t) => {
330
+ return Y((t) => {
341
331
  e = r.occurrences = Math.min(2 ** 53 - 1, e + 1), t.push({
342
332
  type: "deduplicated",
343
333
  handle: r.handle,
@@ -349,31 +339,31 @@ function b(f, y) {
349
339
  occurrences: e
350
340
  };
351
341
  }
352
- if (C.size >= 100) return X((e) => {
353
- z = Math.min(2 ** 53 - 1, z + 1);
354
- let t = l({
355
- count: z,
342
+ if (S.size >= 100) return Y((e) => {
343
+ B = Math.min(2 ** 53 - 1, B + 1);
344
+ let t = s({
345
+ count: B,
356
346
  pending: !0
357
347
  });
358
348
  e.push({
359
349
  type: "overflow",
360
- count: z
361
- }), b.onOverflow && e.push({
362
- callback: () => b.onOverflow(t),
350
+ count: B
351
+ }), y.onOverflow && e.push({
352
+ callback: () => y.onOverflow(t),
363
353
  source: "onOverflow"
364
354
  });
365
355
  }), v("capacity");
366
- let i = J(), a = t.id;
356
+ let i = q(), a = t.id;
367
357
  if (a === void 0) do
368
- a = `${S}:notification-${++re}`;
369
- while (C.has(a));
370
- let o = l({
358
+ a = `${x}:notification-${++M}`;
359
+ while (S.has(a));
360
+ let o = s({
371
361
  id: a,
372
- controller: S,
373
- generation: H()
362
+ controller: x,
363
+ generation: U()
374
364
  });
375
- u.add(o);
376
- let s = {
365
+ c.add(o);
366
+ let l = {
377
367
  handle: o,
378
368
  dedupeKey: t.dedupeKey,
379
369
  onClose: t.onClose,
@@ -394,50 +384,50 @@ function b(f, y) {
394
384
  operationAnnounced: /* @__PURE__ */ new Set(),
395
385
  action: h
396
386
  };
397
- s.remaining = Q(s), C.set(a, s), n?.(s), je(s, i);
398
- let c = [{
387
+ l.remaining = Z(l), S.set(a, l), n?.(l), Te(l, i);
388
+ let u = [{
399
389
  type: "admitted",
400
390
  handle: o
401
391
  }];
402
- if (s.operation) {
403
- let e = s.operation.getSnapshot();
404
- c.push({
392
+ if (l.operation) {
393
+ let e = l.operation.getSnapshot();
394
+ u.push({
405
395
  type: "operation-started",
406
396
  handle: o,
407
397
  token: e.token,
408
398
  attempt: e.attempt
409
399
  });
410
400
  }
411
- return Y(c, i), {
401
+ return J(u, i), {
412
402
  status: "created",
413
403
  handle: o
414
404
  };
415
405
  }
416
- function Be(e) {
417
- V || q(e);
406
+ function Ne(e) {
407
+ H || K(e);
418
408
  }
419
- function Ve(e, t, n) {
420
- e.content = t, e.kind = n, e.remaining = n === "loading" ? null : Q(e), e.action = h, e === P && De(e), je(e, x.now()), A?.target.kind === "notification" && A.target.handle === e.handle && A.target.control === "action" && !t.action && (A = null);
409
+ function Pe(e, t, n) {
410
+ e.content = t, e.kind = n, e.remaining = n === "loading" ? null : Z(e), e.action = h, e === F && xe(e), Te(e, b.now()), k?.target.kind === "notification" && k.target.handle === e.handle && k.target.control === "action" && !t.action && (k = null);
421
411
  }
422
- function He(n, i) {
423
- let a = typeof n == "function" ? n : null, o;
424
- if (!a && (typeof n != "object" || !n || typeof (o = n.then) != "function")) throw TypeError("Operation source must be a factory or thenable");
425
- let c = s(i, a !== null), u = (e) => i && typeof i == "object" ? Object.getOwnPropertyDescriptor(i, e)?.value : void 0, ee = u("cancel"), d = !a && typeof ee == "function" ? ee : null, f = u("isCancellation"), te = typeof f == "function" ? f : null, p = c.length ? null : l({
412
+ function Fe(r, i) {
413
+ let a = typeof r == "function" ? r : null, c;
414
+ if (!a && (typeof r != "object" || !r || typeof (c = r.then) != "function")) throw TypeError("Operation source must be a factory or thenable");
415
+ let l = o(i, a !== null), u = (e) => i && typeof i == "object" ? Object.getOwnPropertyDescriptor(i, e)?.value : void 0, d = u("cancel"), f = !a && typeof d == "function" ? d : null, p = u("isCancellation"), h = typeof p == "function" ? p : null, g = l.length ? null : s({
426
416
  ...i,
427
417
  pending: e(i.pending),
428
418
  success: typeof i.success == "function" ? i.success : e(i.success),
429
419
  error: typeof i.error == "function" ? i.error : e(i.error),
430
420
  ...i.cancelled === void 0 ? {} : { cancelled: typeof i.cancelled == "function" ? i.cancelled : e(i.cancelled) }
431
- }), m = /* @__PURE__ */ new Set(), h = null, g = !1, _, x = 0;
432
- function S() {
433
- let e = y.createCancellation(), t = l({
421
+ }), _ = /* @__PURE__ */ new Set(), b = null, x = !1, C, w = 0;
422
+ function E() {
423
+ let e = m.createCancellation(), t = s({
434
424
  signal: e.signal,
435
- token: H(),
436
- attempt: ++x
425
+ token: U(),
426
+ attempt: ++w
437
427
  }), n, r, i = new Promise((e, t) => {
438
428
  n = e, r = t;
439
429
  }), a = {
440
- public: l({
430
+ public: s({
441
431
  token: t.token,
442
432
  attempt: t.attempt,
443
433
  result: i
@@ -449,506 +439,349 @@ function b(f, y) {
449
439
  status: "pending",
450
440
  cancelRequested: !1
451
441
  };
452
- return i.then((e) => M(a, "fulfilled", e), (e) => M(a, "rejected", e)).catch((e) => {
453
- V || K("callback-error", "operation-settlement", e);
442
+ return i.then((e) => N(a, "fulfilled", e), (e) => N(a, "rejected", e)).catch((e) => {
443
+ H || G("callback-error", "operation-settlement", e);
454
444
  }), a;
455
445
  }
456
- let w = S(), T = w;
457
- function D() {
446
+ let D = E(), O = D;
447
+ function k() {
458
448
  let e = {
459
- token: T.context.token,
460
- attempt: T.context.attempt,
461
- status: T.status,
462
- cancelRequested: T.cancelRequested,
463
- canCancel: !V && T.status === "pending" && !T.cancelRequested && (!!a || !!d),
464
- canRetry: !V && !!a && T.status !== "pending",
465
- notification: g && !V ? h : null
449
+ token: O.context.token,
450
+ attempt: O.context.attempt,
451
+ status: O.status,
452
+ cancelRequested: O.cancelRequested,
453
+ canCancel: !H && O.status === "pending" && !O.cancelRequested && (!!a || !!f),
454
+ canRetry: !H && !!a && O.status !== "pending",
455
+ notification: x && !H ? b : null
466
456
  };
467
- return (!_ || Object.keys(e).some((t) => e[t] !== _[t])) && (_ = l(e)), _;
457
+ return (!C || Object.keys(e).some((t) => e[t] !== C[t])) && (C = s(e)), C;
468
458
  }
469
- let O = {
459
+ let A = {
470
460
  source: "operation.subscribe",
471
- callback: () => Ce(m, "operation.subscribe")
461
+ callback: () => _e(_, "operation.subscribe")
472
462
  };
473
- function k(e) {
474
- if (V || T !== e || !g || !h) return;
475
- let t = C.get(h.id);
476
- return t?.handle === h && t.operation === N ? t : void 0;
463
+ function j(e) {
464
+ if (H || O !== e || !x || !b) return;
465
+ let t = S.get(b.id);
466
+ return t?.handle === b && t.operation === L ? t : void 0;
477
467
  }
478
- function A(e) {
468
+ function ee(e) {
479
469
  try {
480
- e.resolve(a ? a(e.context) : { then: o.bind(n) });
470
+ e.resolve(a ? a(e.context) : { then: c.bind(r) });
481
471
  } catch (t) {
482
472
  e.reject(t);
483
473
  }
484
474
  }
485
- function j(e, t) {
475
+ function M(e, t) {
486
476
  if (t) {
487
- let n = J();
488
- t(), Y(e, n);
489
- } else Be(e);
477
+ let n = q();
478
+ t(), J(e, n);
479
+ } else Ne(e);
490
480
  }
491
- function M(t, n, i) {
492
- if (t.status = n, n === "rejected") try {
493
- (te ? te(i, t.context) === !0 : t.cancelRequested && typeof i == "object" && i && "name" in i && i.name === "AbortError") && (t.status = "cancelled");
481
+ function N(t, r, i) {
482
+ if (t.status = r, r === "rejected") try {
483
+ (h ? h(i, t.context) === !0 : t.cancelRequested && typeof i == "object" && i && "name" in i && i.name === "AbortError") && (t.status = "cancelled");
494
484
  } catch (e) {
495
- V || K("cancellation-error", "isCancellation", e);
485
+ H || G("cancellation-error", "isCancellation", e);
496
486
  }
497
487
  let a;
498
- if (k(t) && p) {
499
- let n = t.status, o = n === "fulfilled" ? b.messages?.operationSuccess ?? "Completed" : n === "cancelled" ? b.messages?.operationCancelled ?? "Cancelled" : b.messages?.operationError ?? "Something went wrong";
488
+ if (j(t) && g) {
489
+ let r = t.status, o = r === "fulfilled" ? y.messages?.operationSuccess ?? "Completed" : r === "cancelled" ? y.messages?.operationCancelled ?? "Cancelled" : y.messages?.operationError ?? "Something went wrong";
500
490
  try {
501
- let t = n === "fulfilled" ? p.success : n === "cancelled" ? p.cancelled : p.error, s = typeof t == "function" ? t(i) : t ?? { title: o };
502
- if (r(s).length) throw TypeError("Invalid terminal notification content");
491
+ let t = r === "fulfilled" ? g.success : r === "cancelled" ? g.cancelled : g.error, s = typeof t == "function" ? t(i) : t ?? { title: o };
492
+ if (n(s).length) throw TypeError("Invalid terminal notification content");
503
493
  a = e(s);
504
494
  } catch (e) {
505
- a = l({
495
+ a = s({
506
496
  title: o,
507
497
  announcementPriority: "polite"
508
- }), V || K("mapper-error", `track.${n}`, e, h ?? void 0);
498
+ }), H || G("mapper-error", `track.${r}`, e, b ?? void 0);
509
499
  }
510
500
  }
511
- let o = k(t), s = !!o && !!a;
512
- j([...T === t ? [O] : [], {
501
+ let o = j(t), c = !!o && !!a;
502
+ M([...O === t ? [A] : [], {
513
503
  type: "operation-settled",
514
- handle: h,
504
+ handle: b,
515
505
  token: t.context.token,
516
506
  status: t.status,
517
- uiApplied: s
518
- }], o && a ? () => Ve(o, a, t.status === "fulfilled" ? "success" : t.status === "cancelled" ? "warning" : "error") : void 0);
507
+ uiApplied: c
508
+ }], o && a ? () => Pe(o, a, t.status === "fulfilled" ? "success" : t.status === "cancelled" ? "warning" : "error") : void 0);
519
509
  }
520
- function ne(e, n) {
510
+ function te(e, n) {
521
511
  e.cancelRequested = !0;
522
- let r = k(e);
523
- j([O, {
512
+ let r = j(e);
513
+ M([A, {
524
514
  type: "cancellation-requested",
525
- handle: h,
515
+ handle: b,
526
516
  token: e.context.token
527
517
  }], r ? () => {
528
- r.content = t(r.content, { title: b.messages?.cancellationRequested ?? "Cancellation requested" });
518
+ r.content = t(r.content, { title: y.messages?.cancellationRequested ?? "Cancellation requested" });
529
519
  } : void 0);
530
520
  try {
531
- e.abort(n), d?.(n);
521
+ e.abort(n), f?.(n);
532
522
  } catch (e) {
533
- V || K("cancellation-error", "cancel", e, h ?? void 0);
523
+ H || G("cancellation-error", "cancel", e, b ?? void 0);
534
524
  }
535
525
  }
536
- function re() {
526
+ function P() {
537
527
  let e = /* @__PURE__ */ Error("Cancellation requested");
538
528
  return e.name = "AbortError", e;
539
529
  }
540
- function ie(e = re()) {
541
- return V ? v("disposed") : T.status === "pending" ? !a && !d ? v("not-cancellable") : T.cancelRequested ? {
530
+ function F(e = P()) {
531
+ return H ? v("disposed") : O.status === "pending" ? !a && !f ? v("not-cancellable") : O.cancelRequested ? {
542
532
  status: "unchanged",
543
533
  reason: "already-requested"
544
- } : (ne(T, e), { status: "requested" }) : {
534
+ } : (te(O, e), { status: "requested" }) : {
545
535
  status: "unchanged",
546
536
  reason: "settled"
547
537
  };
548
538
  }
549
- function ae(e) {
550
- if (V) return v("disposed");
539
+ function I(e) {
540
+ if (H) return v("disposed");
551
541
  if (!a) return v("not-retryable");
552
- if (T.status === "pending" && !e) return v("already-pending");
553
- let t = T, n = S();
554
- T = n;
555
- let r = k(n);
556
- return j([O, {
542
+ if (O.status === "pending" && !e) return v("already-pending");
543
+ let t = O, n = E();
544
+ O = n;
545
+ let r = j(n);
546
+ return M([A, {
557
547
  type: "operation-started",
558
- handle: h,
548
+ handle: b,
559
549
  token: n.context.token,
560
550
  attempt: n.context.attempt
561
- }], r && p ? () => {
562
- r.operationAnnounced.clear(), Ve(r, p.pending, "loading");
563
- } : void 0), t.status === "pending" && !t.cancelRequested && ne(t, re()), A(n), {
551
+ }], r && g ? () => {
552
+ r.operationAnnounced.clear(), Pe(r, g.pending, "loading");
553
+ } : void 0), t.status === "pending" && !t.cancelRequested && te(t, P()), ee(n), {
564
554
  status: "started",
565
555
  attempt: n.public
566
556
  };
567
557
  }
568
- let N = {
569
- getSnapshot: D,
570
- retry: () => ae(!1),
571
- cancel: ie,
572
- detach: () => (g = !1, O)
573
- }, P;
574
- if (V) P = v("disposed");
575
- else if (!p) P = {
558
+ let L = {
559
+ getSnapshot: k,
560
+ retry: () => I(!1),
561
+ cancel: F,
562
+ detach: () => (x = !1, A)
563
+ }, R;
564
+ if (H) R = v("disposed");
565
+ else if (!g) R = {
576
566
  ...v("invalid-input"),
577
- issues: c
578
- }, G({
567
+ issues: l
568
+ }, W({
579
569
  code: "invalid-input",
580
570
  source: "track",
581
571
  message: "Invalid operation options"
582
572
  });
583
573
  else {
584
- let e = ze({
585
- ...p.pending,
586
- ...p,
574
+ let e = Me({
575
+ ...g.pending,
576
+ ...g,
587
577
  kind: "loading"
588
578
  }, (e) => {
589
- h = e.handle, g = !0, e.operation = N;
579
+ b = e.handle, x = !0, e.operation = L;
590
580
  });
591
581
  if (e.status === "deduplicated") throw Error("Tracked operation cannot be deduplicated");
592
- P = e;
582
+ R = e;
593
583
  }
594
- return P.status === "rejected" && Be([{
584
+ return R.status === "rejected" && Ne([{
595
585
  type: "operation-started",
596
586
  handle: null,
597
- token: w.context.token,
587
+ token: D.context.token,
598
588
  attempt: 1
599
- }]), A(w), l({
600
- ...w.public,
601
- admission: l(P),
602
- getSnapshot: D,
589
+ }]), ee(D), s({
590
+ ...D.public,
591
+ admission: s(R),
592
+ getSnapshot: k,
603
593
  subscribe(e) {
604
- let t = Le(m, e);
605
- return m.size && E.set(m, O), () => {
606
- t(), m.size || E.delete(m);
594
+ let t = Ae(_, e);
595
+ return _.size && T.set(_, A), () => {
596
+ t(), _.size || T.delete(_);
607
597
  };
608
598
  },
609
- cancel: ie,
610
- retry: () => ae(!1),
611
- restart: () => ae(!0)
599
+ cancel: F,
600
+ retry: () => I(!1),
601
+ restart: () => I(!0)
612
602
  });
613
603
  }
614
- let Ue = l({
615
- show: (e) => Re(e),
616
- track: He,
617
- update: W((e, n) => {
618
- let r = e.handle, i = a(n);
619
- if (i.length) return G({
604
+ let $ = s({
605
+ show: (e) => je(e),
606
+ track: Fe,
607
+ update: ge((e, n) => {
608
+ let r = e.handle, a = i(n);
609
+ if (a.length) return W({
620
610
  code: "invalid-input",
621
611
  source: "update",
622
612
  message: "Invalid notification patch",
623
613
  handle: r
624
614
  }), {
625
615
  ...v("invalid-input"),
626
- issues: i
616
+ issues: a
627
617
  };
628
618
  if (e.action.status === "pending" && Object.prototype.hasOwnProperty.call(n, "action")) return v("action-pending");
629
619
  if (e.operation && (Object.prototype.hasOwnProperty.call(n, "kind") || e.operation.getSnapshot().status === "pending" && Object.prototype.hasOwnProperty.call(n, "duration"))) return v("operation-owned");
630
620
  let o = t(e.content, n), s = n.kind ?? e.kind, c = n.priority ?? e.priority, l = Object.prototype.hasOwnProperty.call(n, "duration");
631
- return o === e.content && s === e.kind && c === e.priority && !l && !(Object.prototype.hasOwnProperty.call(n, "action") && e.action.status === "failed") ? _ : X((t) => {
632
- let i = Q(e);
621
+ return o === e.content && s === e.kind && c === e.priority && !l && !(Object.prototype.hasOwnProperty.call(n, "action") && e.action.status === "failed") ? _ : Y((t) => {
622
+ let i = Z(e);
633
623
  e.content = o, Object.prototype.hasOwnProperty.call(n, "action") && (e.action = h), e.kind = s, e.priority = c;
634
- let a = Q(e);
635
- (l || i !== a) && (e.remaining = a), A?.target.kind === "notification" && A.target.handle === r && A.target.control === "action" && !o.action && (A = null), L?.record === e && !ge(e) && (L = null), t.push({
624
+ let a = Z(e);
625
+ (l || i !== a) && (e.remaining = a), k?.target.kind === "notification" && k.target.handle === r && k.target.control === "action" && !o.action && (k = null), R?.record === e && !fe(e) && (R = null), t.push({
636
626
  type: "updated",
637
627
  handle: r
638
628
  });
639
629
  });
640
630
  }),
641
- getHandle: (e) => !V && typeof e == "string" ? C.get(e)?.handle : void 0,
642
- dismiss: (e) => Fe(e, "programmatic"),
631
+ getHandle: (e) => !H && typeof e == "string" ? S.get(e)?.handle : void 0,
632
+ dismiss: (e) => Oe(e, "programmatic"),
643
633
  clear() {
644
- if (V) return v("disposed");
645
- let e = C.size;
646
- return e && X((e) => {
647
- for (let t of C.values()) Pe(t, "clear", e);
634
+ if (H) return v("disposed");
635
+ let e = S.size;
636
+ return e && Y((e) => {
637
+ for (let t of S.values()) Q(t, "clear", e);
648
638
  }), {
649
639
  status: "cleared",
650
640
  count: e
651
641
  };
652
642
  },
653
643
  requestFocus(e = { kind: "anchor" }) {
654
- if (V) return v("disposed");
644
+ if (H) return v("disposed");
655
645
  if (e?.kind === "notification") {
656
- let t = U(e.handle);
646
+ let t = he(e.handle);
657
647
  if (t) return v(t);
658
648
  }
659
- if (!j) return v("no-host");
649
+ if (!A) return v("no-host");
660
650
  if (!e || ![
661
651
  "anchor",
662
652
  "notification",
663
653
  "overflow"
664
654
  ].includes(e.kind)) return v("unavailable");
665
655
  if (e.kind === "notification") {
666
- let t = C.get(e.handle.id);
667
- if (t !== P) return v("not-visible");
656
+ let t = S.get(e.handle.id);
657
+ if (t !== F) return v("not-visible");
668
658
  if (e.control !== void 0 && !["action", "close"].includes(e.control) || e.control === "action" && !t.content.action) return v("unavailable");
669
- if (e.control !== void 0 && !N) return v("not-visible");
659
+ if (e.control !== void 0 && !P) return v("not-visible");
670
660
  }
671
- return e.kind === "overflow" && !z ? v("unavailable") : (X(() => {
672
- let t = e.kind === "notification" ? l({
661
+ return e.kind === "overflow" && !B ? v("unavailable") : (Y(() => {
662
+ let t = e.kind === "notification" ? s({
673
663
  kind: e.kind,
674
664
  handle: e.handle,
675
665
  ...e.control ? { control: e.control } : {}
676
- }) : l({ kind: e.kind });
677
- A = l({
678
- token: H(),
666
+ }) : s({ kind: e.kind });
667
+ k = s({
668
+ token: U(),
679
669
  target: t
680
670
  });
681
671
  }), { status: "requested" });
682
672
  },
683
- acknowledgeOverflow: Ie,
684
- getSnapshot: () => ue,
673
+ acknowledgeOverflow: ke,
674
+ getSnapshot: () => oe,
685
675
  getServerSnapshot: () => p,
686
- subscribe: (e) => Le(w, e),
687
- onEvent: (e) => Le(T, e),
676
+ subscribe: (e) => Ae(C, e),
677
+ onEvent: (e) => Ae(w, e),
688
678
  dispose() {
689
- V || X((e) => {
690
- V = !0;
691
- for (let t of C.values()) Pe(t, "dispose", e);
692
- for (let t of E.values()) e.includes(t) || e.push(t);
693
- j = M = null, N = null, L = null, Ae(), A = null, D.clear(), z = B = 0;
679
+ H || Y((e) => {
680
+ H = !0;
681
+ for (let t of S.values()) Q(t, "dispose", e);
682
+ for (let t of T.values()) e.includes(t) || e.push(t);
683
+ A = j = null, P = null, R = null, we(), k = null, E.clear(), B = V = 0;
694
684
  }, !0);
695
685
  }
696
686
  });
697
- function We(e) {
698
- return e === void 0 || typeof e == "object" && !!e && Object.keys(e).every((e) => e === "attentionDelay") && (e.attentionDelay === void 0 || n(e.attentionDelay));
699
- }
700
- function $(e) {
701
- return (t, ...n) => {
702
- let r = ye(t);
703
- return r ? v(r) : e(...n);
704
- };
705
- }
706
- let Ge = l({
707
- renderError: b.messages?.renderError ?? "Content unavailable",
708
- reportInvalidContainer(e, t) {
709
- V || G({
710
- code: "invalid-container",
711
- source: "Toaster.container",
712
- message: e,
713
- ...t === void 0 ? {} : { error: t }
714
- });
687
+ return be(), l.set($, s({
688
+ options: y,
689
+ clock: b,
690
+ records: S,
691
+ globalPauses: E,
692
+ subscribe: $.subscribe,
693
+ onEvent: $.onEvent,
694
+ get disposed() {
695
+ return H;
715
696
  },
716
- attach(e) {
717
- if (V) return v("disposed");
718
- if (j !== null) return G({
719
- code: "second-host",
720
- source: "attach",
721
- message: "A renderer is already attached"
722
- }), v("host-exists");
723
- if (!We(e)) return v("invalid-input");
724
- let t = H();
725
- return X(() => {
726
- j = M = t, F = e?.attentionDelay, P && De(P);
727
- }), {
728
- status: "attached",
729
- lease: t
730
- };
697
+ get presented() {
698
+ return F;
731
699
  },
732
- detach(e) {
733
- if (V) return v("disposed");
734
- if (j === null && M !== null && e === M) return _;
735
- let t = ye(e);
736
- return t ? v(t) : X(() => {
737
- j = null, F = void 0, Ne(void 0), A = null, k = null, D.clear();
738
- for (let e of C.values()) e.pauses.clear(), e.readable = !1, e.presentation = null;
739
- });
700
+ get rendererSnapshot() {
701
+ return se;
740
702
  },
741
- getSnapshot: () => de,
742
- getServerSnapshot: () => m,
743
- subscribe: Ue.subscribe,
744
- onEvent: Ue.onEvent,
745
- openIsland: $((e, t) => {
746
- if (e !== "user" && e !== "attention") return v("invalid-input");
747
- let n;
748
- if (t === void 0) n = pe();
749
- else {
750
- let e = U(t);
751
- if (e) return v(e);
752
- n = C.get(t.id);
753
- }
754
- if (!n) return v("empty");
755
- let r = n;
756
- return N?.current === r ? _ : X(() => {
757
- N ? N.current = r : N = {
758
- reason: e,
759
- current: r
760
- };
761
- });
762
- }),
763
- collapseIsland: $(() => N ? X(() => {
764
- N = null;
765
- }) : _),
766
- setAutoDismiss: $((e) => e !== void 0 && typeof e != "boolean" ? v("invalid-input") : Z(e) === Z(I) ? (I = e, _) : X(() => Ne(e))),
767
- navigate: $(W((e) => N ? N.current === e ? _ : X(() => {
768
- N.current = e, L?.record === e ? L = null : L && (L.waiting = !1, L.due = x.now() + (F ?? b.attentionDelay ?? c));
769
- }) : v("island-closed"))),
770
- setPause: $((e) => {
771
- if (!e || typeof e.active != "boolean") return v("invalid-input");
772
- let t;
773
- if (e.scope === "host") {
774
- if (![
775
- "hover",
776
- "focus",
777
- "document-hidden",
778
- "window-blur"
779
- ].includes(e.reason)) return v("invalid-input");
780
- t = D;
781
- } else if (e.scope === "notification") {
782
- let n = be(e.handle);
783
- if (n) return v(n);
784
- if (!["gesture", "content-transition"].includes(e.reason)) return v("invalid-input");
785
- t = C.get(e.handle.id).pauses;
786
- } else return v("invalid-input");
787
- return t.has(e.reason) === e.active ? _ : X(() => {
788
- e.active ? t.add(e.reason) : t.delete(e.reason);
703
+ get overflow() {
704
+ return B;
705
+ },
706
+ get lease() {
707
+ return A;
708
+ },
709
+ set lease(e) {
710
+ A = e;
711
+ },
712
+ get lastLease() {
713
+ return j;
714
+ },
715
+ set lastLease(e) {
716
+ j = e;
717
+ },
718
+ get hostDelay() {
719
+ return I;
720
+ },
721
+ set hostDelay(e) {
722
+ I = e;
723
+ },
724
+ get hostAutoDismiss() {
725
+ return L;
726
+ },
727
+ set hostAutoDismiss(e) {
728
+ L = e;
729
+ },
730
+ get island() {
731
+ return P;
732
+ },
733
+ set island(e) {
734
+ P = e;
735
+ },
736
+ get attention() {
737
+ return R;
738
+ },
739
+ set attention(e) {
740
+ R = e;
741
+ },
742
+ get focusRequest() {
743
+ return k;
744
+ },
745
+ set focusRequest(e) {
746
+ k = e;
747
+ },
748
+ get focused() {
749
+ return O;
750
+ },
751
+ set focused(e) {
752
+ O = e;
753
+ },
754
+ get overflowAnnounced() {
755
+ return V;
756
+ },
757
+ set overflowAnnounced(e) {
758
+ V = e;
759
+ },
760
+ token: U,
761
+ diagnostic: W,
762
+ failure: G,
763
+ mutate: Y,
764
+ commit: J,
765
+ settle: q,
766
+ assign: xe,
767
+ newest: le,
768
+ handleError: he,
769
+ withRecord: ge,
770
+ autoDismissing: X,
771
+ setHostAutoDismiss: De,
772
+ dismiss: Oe,
773
+ acknowledgeOverflow: ke,
774
+ reportRendererLoadError(e) {
775
+ H || W({
776
+ code: "renderer-load-error",
777
+ source: "Toaster",
778
+ message: "Toaster renderer failed to load",
779
+ error: e
789
780
  });
790
- }),
791
- setFocused: $((e) => {
792
- let t = e === null ? void 0 : be(e);
793
- return t ? v(t) : k === e ? _ : (k = e, g);
794
- }),
795
- beginPresentation: $(xe((e, t) => {
796
- if (e.presentation !== t) return v("stale-presentation");
797
- let n = H();
798
- return X(() => {
799
- e.presentation = n, e.readable = !1;
800
- }), {
801
- status: "started",
802
- token: n
803
- };
804
- })),
805
- acknowledgePresentation: $(xe((e, t) => e.presentation === t ? e.readable ? _ : X((t) => {
806
- t.push({
807
- type: "presented",
808
- handle: e.handle,
809
- firstPresentation: !e.everPresented
810
- }), e.readable = e.everPresented = !0;
811
- }) : v("stale-presentation"))),
812
- acknowledgeFocus: $((e, t) => A?.token === e ? t !== "focused" && t !== "unavailable" ? v("invalid-input") : X(() => {
813
- A = null;
814
- }) : v("stale-focus-request")),
815
- acknowledgeOverflow: $(() => Ie()),
816
- acknowledgeAnnouncements: $((e) => Ke(e)),
817
- dismiss: $((e, t) => {
818
- let n = U(e);
819
- return n ? v(n) : [
820
- "close-button",
821
- "swipe",
822
- "navigation"
823
- ].includes(t) ? Fe(e, t) : v("invalid-input");
824
- }),
825
- invokeAction: $(W((e) => {
826
- let t = e.handle, n = e.content.action;
827
- if (!n || n.kind !== "command") return v("no-command");
828
- if (e.action.status === "pending") return v("already-pending");
829
- let r = H(), i = () => !V && C.get(t.id) === e && e.action.status === "pending" && e.action.token === r, a = J();
830
- e.action = l({
831
- status: "pending",
832
- token: r
833
- }), Y([{
834
- type: "action-started",
835
- handle: t,
836
- token: r
837
- }], a);
838
- function o(a) {
839
- if (!i()) return;
840
- let o = b.messages?.actionError ?? "Action failed";
841
- if (n?.kind === "command" && n.errorMessage) try {
842
- let e = n.errorMessage(a);
843
- if (typeof e != "string" || !e.trim()) throw TypeError("Invalid action error message");
844
- o = e;
845
- } catch (e) {
846
- V || K("mapper-error", "action.errorMessage", e, t);
847
- }
848
- if (!i()) return;
849
- let s = J();
850
- e.action = l({
851
- status: "failed",
852
- token: r,
853
- message: o
854
- }), Y([{
855
- type: "action-failed",
856
- handle: t,
857
- token: r,
858
- message: o
859
- }], s);
860
- }
861
- let s;
862
- try {
863
- s = Promise.resolve(n.run(l({
864
- handle: t,
865
- token: r
866
- })));
867
- } catch (e) {
868
- s = Promise.reject(e);
869
- }
870
- return s.then(() => {
871
- i() && Fe(t, "action-success");
872
- }, o).catch((e) => {
873
- V || K("callback-error", "action-settlement", e, t);
874
- }), { status: "started" };
875
- })),
876
- retryOperation: $(Se((e) => {
877
- let t = e.retry();
878
- return t.status === "started" ? {
879
- status: "started",
880
- token: t.attempt.token
881
- } : t;
882
- })),
883
- cancelOperation: $(Se((e, t) => e.cancel(t))),
884
- reportDiagnostic: $((e) => !e || typeof e.source != "string" || typeof e.message != "string" || ![
885
- "invalid-input",
886
- "second-host",
887
- "stale-host",
888
- "mapper-error",
889
- "callback-error",
890
- "listener-error",
891
- "cancellation-error",
892
- "slot-error",
893
- "formatter-error",
894
- "invalid-container"
895
- ].includes(e.code) ? v("invalid-input") : (G(e), g))
896
- });
897
- function Ke(e) {
898
- if (!Array.isArray(e)) return v("invalid-input");
899
- let t = [], n = (e, t) => Number.isSafeInteger(e) && e >= 0 && e <= t;
900
- for (let r of e) {
901
- if (!r || typeof r != "object") return v("invalid-input");
902
- if (r.kind === "overflow") {
903
- if (!n(r.count, z)) return v("invalid-input");
904
- r.count > B && t.push(() => {
905
- B = Math.max(B, r.count);
906
- });
907
- continue;
908
- }
909
- let e = U(r.handle);
910
- if (e) return v(e);
911
- let i = C.get(r.handle.id);
912
- if (r.kind === "operation") {
913
- let e = i.operation?.getSnapshot();
914
- if (!e || e.token !== r.token) return v("stale-operation-token");
915
- if (![
916
- "started",
917
- "fulfilled",
918
- "rejected",
919
- "cancelled",
920
- "cancel-requested"
921
- ].includes(r.phase) || (r.phase === "cancel-requested" ? !e.cancelRequested : r.phase !== "started" && r.phase !== e.status)) return v("invalid-input");
922
- i.operationAnnounced.has(r.phase) || t.push(() => {
923
- i.operationAnnounced.add(r.phase);
924
- });
925
- } else if (r.kind === "action") {
926
- if (i.action.status === "idle" || i.action.token !== r.token || i.action.status !== r.status) return v("invalid-input");
927
- (i.actionAnnounced?.token !== r.token || i.actionAnnounced?.status !== r.status) && t.push(() => {
928
- i.actionAnnounced = l({
929
- token: r.token,
930
- status: r.status
931
- });
932
- });
933
- } else if (r.kind === "occurrences") {
934
- if (!n(r.count, i.occurrences)) return v("invalid-input");
935
- r.count > i.occurrencesAnnounced && t.push(() => {
936
- i.occurrencesAnnounced = Math.max(i.occurrencesAnnounced, r.count);
937
- });
938
- } else if (r.kind === "queued" || r.kind === "first-presentation") {
939
- let e = r.kind === "queued" ? "queuedAnnounced" : "firstAnnounced";
940
- i[e] || t.push(() => {
941
- i[e] = !0;
942
- });
943
- } else return v("invalid-input");
944
781
  }
945
- return t.length ? X(() => {
946
- for (let e of t) e();
947
- }) : _;
948
- }
949
- return Ee(), ee.set(Ue, Ge), Ue;
782
+ })), $;
950
783
  }
951
784
  //#endregion
952
- export { b as createCloudletCore, y as getRendererBridge };
785
+ export { g as APPLIED, m as RENDERER_SERVER, _ as UNCHANGED, b as createCloudletCore, y as getControllerKernel, v as reject };
953
786
 
954
787
  //# sourceMappingURL=controller.js.map