@dismissible/react-client 1.0.0 → 2.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.
@@ -1,59 +1,59 @@
1
1
  var he = Object.defineProperty, me = Object.defineProperties;
2
2
  var ye = Object.getOwnPropertyDescriptors;
3
- var M = Object.getOwnPropertySymbols;
4
- var re = Object.prototype.hasOwnProperty, ne = Object.prototype.propertyIsEnumerable;
5
- var te = (e, r, t) => r in e ? he(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, b = (e, r) => {
3
+ var J = Object.getOwnPropertySymbols;
4
+ var te = Object.prototype.hasOwnProperty, re = Object.prototype.propertyIsEnumerable;
5
+ var ee = (e, r, t) => r in e ? he(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, b = (e, r) => {
6
6
  for (var t in r || (r = {}))
7
- re.call(r, t) && te(e, t, r[t]);
8
- if (M)
9
- for (var t of M(r))
10
- ne.call(r, t) && te(e, t, r[t]);
7
+ te.call(r, t) && ee(e, t, r[t]);
8
+ if (J)
9
+ for (var t of J(r))
10
+ re.call(r, t) && ee(e, t, r[t]);
11
11
  return e;
12
12
  }, E = (e, r) => me(e, ye(r));
13
- var Q = (e, r) => {
13
+ var G = (e, r) => {
14
14
  var t = {};
15
15
  for (var n in e)
16
- re.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
17
- if (e != null && M)
18
- for (var n of M(e))
19
- r.indexOf(n) < 0 && ne.call(e, n) && (t[n] = e[n]);
16
+ te.call(e, n) && r.indexOf(n) < 0 && (t[n] = e[n]);
17
+ if (e != null && J)
18
+ for (var n of J(e))
19
+ r.indexOf(n) < 0 && re.call(e, n) && (t[n] = e[n]);
20
20
  return t;
21
21
  };
22
22
  var $ = (e, r, t) => new Promise((n, o) => {
23
23
  var s = (f) => {
24
24
  try {
25
- l(t.next(f));
25
+ c(t.next(f));
26
26
  } catch (d) {
27
27
  o(d);
28
28
  }
29
29
  }, i = (f) => {
30
30
  try {
31
- l(t.throw(f));
31
+ c(t.throw(f));
32
32
  } catch (d) {
33
33
  o(d);
34
34
  }
35
- }, l = (f) => f.done ? n(f.value) : Promise.resolve(f.value).then(s, i);
36
- l((t = t.apply(e, r)).next());
35
+ }, c = (f) => f.done ? n(f.value) : Promise.resolve(f.value).then(s, i);
36
+ c((t = t.apply(e, r)).next());
37
37
  });
38
38
  import { jsx as U, jsxs as be } from "react/jsx-runtime";
39
- import { createContext as pe, useContext as we, useMemo as Y, useRef as J, useState as W, useCallback as V, useEffect as _ } from "react";
40
- const ge = /\{[^{}]+\}/g, Ee = () => {
39
+ import { createContext as pe, useContext as we, useMemo as X, useRef as W, useState as z, useCallback as K, useEffect as Q } from "react";
40
+ const ge = /\{[^{}]+\}/g, ve = () => {
41
41
  var e, r;
42
42
  return typeof process == "object" && Number.parseInt((r = (e = process == null ? void 0 : process.versions) == null ? void 0 : e.node) == null ? void 0 : r.substring(0, 2)) >= 18 && process.versions.undici;
43
43
  };
44
- function Re() {
44
+ function Ee() {
45
45
  return Math.random().toString(36).slice(2, 11);
46
46
  }
47
- function ve(e) {
48
- let A = b({}, e), {
47
+ function Re(e) {
48
+ let j = b({}, e), {
49
49
  baseUrl: r = "",
50
50
  Request: t = globalThis.Request,
51
51
  fetch: n = globalThis.fetch,
52
52
  querySerializer: o,
53
53
  bodySerializer: s,
54
54
  headers: i,
55
- requestInitExt: l = void 0
56
- } = A, f = Q(A, [
55
+ requestInitExt: c = void 0
56
+ } = j, f = G(j, [
57
57
  "baseUrl",
58
58
  "Request",
59
59
  "fetch",
@@ -62,23 +62,23 @@ function ve(e) {
62
62
  "headers",
63
63
  "requestInitExt"
64
64
  ]);
65
- l = Ee() ? l : void 0, r = ie(r);
65
+ c = ve() ? c : void 0, r = oe(r);
66
66
  const d = [];
67
- function g(u, a) {
67
+ function g(l, a) {
68
68
  return $(this, null, function* () {
69
- var ee;
70
- const Z = a || {}, {
69
+ var Z;
70
+ const Y = a || {}, {
71
71
  baseUrl: R,
72
- fetch: C = n,
73
- Request: O = t,
74
- headers: x,
72
+ fetch: x = n,
73
+ Request: I = t,
74
+ headers: C,
75
75
  params: v = {},
76
- parseAs: j = "json",
76
+ parseAs: A = "json",
77
77
  querySerializer: S,
78
- bodySerializer: P = s != null ? s : xe,
79
- body: z,
80
- middleware: k = []
81
- } = Z, c = Q(Z, [
78
+ bodySerializer: k = s != null ? s : xe,
79
+ body: F,
80
+ middleware: u = []
81
+ } = Y, y = G(Y, [
82
82
  "baseUrl",
83
83
  "fetch",
84
84
  "Request",
@@ -90,58 +90,58 @@ function ve(e) {
90
90
  "body",
91
91
  "middleware"
92
92
  ]);
93
- let y = r;
94
- R && (y = (ee = ie(R)) != null ? ee : r);
95
- let h = typeof o == "function" ? o : se(o);
96
- S && (h = typeof S == "function" ? S : se(b(b({}, typeof o == "object" ? o : {}), S)));
97
- const H = z === void 0 ? void 0 : P(
98
- z,
93
+ let h = r;
94
+ R && (h = (Z = oe(R)) != null ? Z : r);
95
+ let H = typeof o == "function" ? o : ne(o);
96
+ S && (H = typeof S == "function" ? S : ne(b(b({}, typeof o == "object" ? o : {}), S)));
97
+ const P = F === void 0 ? void 0 : k(
98
+ F,
99
99
  // Note: we declare mergeHeaders() both here and below because it’s a bit of a chicken-or-egg situation:
100
100
  // bodySerializer() needs all headers so we aren’t dropping ones set by the user, however,
101
101
  // the result of this ALSO sets the lowest-priority content-type header. So we re-merge below,
102
102
  // setting the content-type at the very beginning to be overwritten.
103
103
  // Lastly, based on the way headers work, it’s not a simple “present-or-not” check becauase null intentionally un-sets headers.
104
- oe(i, x, v.header)
105
- ), G = oe(
104
+ se(i, C, v.header)
105
+ ), fe = se(
106
106
  // with no body, we should not to set Content-Type
107
- H === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
108
- H instanceof FormData ? {} : {
107
+ P === void 0 || // if serialized body is FormData; browser will correctly set Content-Type & boundary expression
108
+ P instanceof FormData ? {} : {
109
109
  "Content-Type": "application/json"
110
110
  },
111
111
  i,
112
- x,
112
+ C,
113
113
  v.header
114
- ), D = [...d, ...k], de = E(b(b({
114
+ ), D = [...d, ...u], de = E(b(b({
115
115
  redirect: "follow"
116
- }, f), c), {
117
- body: H,
118
- headers: G
116
+ }, f), y), {
117
+ body: P,
118
+ headers: fe
119
119
  });
120
- let F, L, T = new O(
121
- Se(u, { baseUrl: y, params: v, querySerializer: h }),
120
+ let L, N, T = new I(
121
+ Se(l, { baseUrl: h, params: v, querySerializer: H }),
122
122
  de
123
123
  ), m;
124
- for (const w in c)
125
- w in T || (T[w] = c[w]);
124
+ for (const w in y)
125
+ w in T || (T[w] = y[w]);
126
126
  if (D.length) {
127
- F = Re(), L = Object.freeze({
128
- baseUrl: y,
129
- fetch: C,
130
- parseAs: j,
131
- querySerializer: h,
132
- bodySerializer: P
127
+ L = Ee(), N = Object.freeze({
128
+ baseUrl: h,
129
+ fetch: x,
130
+ parseAs: A,
131
+ querySerializer: H,
132
+ bodySerializer: k
133
133
  });
134
134
  for (const w of D)
135
135
  if (w && typeof w == "object" && typeof w.onRequest == "function") {
136
136
  const p = yield w.onRequest({
137
137
  request: T,
138
- schemaPath: u,
138
+ schemaPath: l,
139
139
  params: v,
140
- options: L,
141
- id: F
140
+ options: N,
141
+ id: L
142
142
  });
143
143
  if (p)
144
- if (p instanceof O)
144
+ if (p instanceof I)
145
145
  T = p;
146
146
  else if (p instanceof Response) {
147
147
  m = p;
@@ -152,28 +152,28 @@ function ve(e) {
152
152
  }
153
153
  if (!m) {
154
154
  try {
155
- m = yield C(T, l);
155
+ m = yield x(T, c);
156
156
  } catch (w) {
157
157
  let p = w;
158
158
  if (D.length)
159
159
  for (let q = D.length - 1; q >= 0; q--) {
160
- const N = D[q];
161
- if (N && typeof N == "object" && typeof N.onError == "function") {
162
- const I = yield N.onError({
160
+ const M = D[q];
161
+ if (M && typeof M == "object" && typeof M.onError == "function") {
162
+ const O = yield M.onError({
163
163
  request: T,
164
164
  error: p,
165
- schemaPath: u,
165
+ schemaPath: l,
166
166
  params: v,
167
- options: L,
168
- id: F
167
+ options: N,
168
+ id: L
169
169
  });
170
- if (I) {
171
- if (I instanceof Response) {
172
- p = void 0, m = I;
170
+ if (O) {
171
+ if (O instanceof Response) {
172
+ p = void 0, m = O;
173
173
  break;
174
174
  }
175
- if (I instanceof Error) {
176
- p = I;
175
+ if (O instanceof Error) {
176
+ p = O;
177
177
  continue;
178
178
  }
179
179
  throw new Error("onError: must return new Response() or instance of Error");
@@ -190,10 +190,10 @@ function ve(e) {
190
190
  const q = yield p.onResponse({
191
191
  request: T,
192
192
  response: m,
193
- schemaPath: u,
193
+ schemaPath: l,
194
194
  params: v,
195
- options: L,
196
- id: F
195
+ options: N,
196
+ id: L
197
197
  });
198
198
  if (q) {
199
199
  if (!(q instanceof Response))
@@ -206,54 +206,54 @@ function ve(e) {
206
206
  if (m.status === 204 || T.method === "HEAD" || m.headers.get("Content-Length") === "0")
207
207
  return m.ok ? { data: void 0, response: m } : { error: void 0, response: m };
208
208
  if (m.ok)
209
- return j === "stream" ? { data: m.body, response: m } : { data: yield m[j](), response: m };
210
- let K = yield m.text();
209
+ return A === "stream" ? { data: m.body, response: m } : { data: yield m[A](), response: m };
210
+ let B = yield m.text();
211
211
  try {
212
- K = JSON.parse(K);
212
+ B = JSON.parse(B);
213
213
  } catch (w) {
214
214
  }
215
- return { error: K, response: m };
215
+ return { error: B, response: m };
216
216
  });
217
217
  }
218
218
  return {
219
- request(u, a, R) {
220
- return g(a, E(b({}, R), { method: u.toUpperCase() }));
219
+ request(l, a, R) {
220
+ return g(a, E(b({}, R), { method: l.toUpperCase() }));
221
221
  },
222
222
  /** Call a GET endpoint */
223
- GET(u, a) {
224
- return g(u, E(b({}, a), { method: "GET" }));
223
+ GET(l, a) {
224
+ return g(l, E(b({}, a), { method: "GET" }));
225
225
  },
226
226
  /** Call a PUT endpoint */
227
- PUT(u, a) {
228
- return g(u, E(b({}, a), { method: "PUT" }));
227
+ PUT(l, a) {
228
+ return g(l, E(b({}, a), { method: "PUT" }));
229
229
  },
230
230
  /** Call a POST endpoint */
231
- POST(u, a) {
232
- return g(u, E(b({}, a), { method: "POST" }));
231
+ POST(l, a) {
232
+ return g(l, E(b({}, a), { method: "POST" }));
233
233
  },
234
234
  /** Call a DELETE endpoint */
235
- DELETE(u, a) {
236
- return g(u, E(b({}, a), { method: "DELETE" }));
235
+ DELETE(l, a) {
236
+ return g(l, E(b({}, a), { method: "DELETE" }));
237
237
  },
238
238
  /** Call a OPTIONS endpoint */
239
- OPTIONS(u, a) {
240
- return g(u, E(b({}, a), { method: "OPTIONS" }));
239
+ OPTIONS(l, a) {
240
+ return g(l, E(b({}, a), { method: "OPTIONS" }));
241
241
  },
242
242
  /** Call a HEAD endpoint */
243
- HEAD(u, a) {
244
- return g(u, E(b({}, a), { method: "HEAD" }));
243
+ HEAD(l, a) {
244
+ return g(l, E(b({}, a), { method: "HEAD" }));
245
245
  },
246
246
  /** Call a PATCH endpoint */
247
- PATCH(u, a) {
248
- return g(u, E(b({}, a), { method: "PATCH" }));
247
+ PATCH(l, a) {
248
+ return g(l, E(b({}, a), { method: "PATCH" }));
249
249
  },
250
250
  /** Call a TRACE endpoint */
251
- TRACE(u, a) {
252
- return g(u, E(b({}, a), { method: "TRACE" }));
251
+ TRACE(l, a) {
252
+ return g(l, E(b({}, a), { method: "TRACE" }));
253
253
  },
254
254
  /** Register middleware */
255
- use(...u) {
256
- for (const a of u)
255
+ use(...l) {
256
+ for (const a of l)
257
257
  if (a) {
258
258
  if (typeof a != "object" || !("onRequest" in a || "onResponse" in a || "onError" in a))
259
259
  throw new Error("Middleware must be an object with one of `onRequest()`, `onResponse() or `onError()`");
@@ -261,15 +261,15 @@ function ve(e) {
261
261
  }
262
262
  },
263
263
  /** Unregister middleware */
264
- eject(...u) {
265
- for (const a of u) {
264
+ eject(...l) {
265
+ for (const a of l) {
266
266
  const R = d.indexOf(a);
267
267
  R !== -1 && d.splice(R, 1);
268
268
  }
269
269
  }
270
270
  };
271
271
  }
272
- function B(e, r, t) {
272
+ function _(e, r, t) {
273
273
  if (r == null)
274
274
  return "";
275
275
  if (typeof r == "object")
@@ -278,7 +278,7 @@ function B(e, r, t) {
278
278
  );
279
279
  return `${e}=${(t == null ? void 0 : t.allowReserved) === !0 ? r : encodeURIComponent(r)}`;
280
280
  }
281
- function le(e, r, t) {
281
+ function ce(e, r, t) {
282
282
  if (!r || typeof r != "object")
283
283
  return "";
284
284
  const n = [], o = {
@@ -287,8 +287,8 @@ function le(e, r, t) {
287
287
  matrix: ";"
288
288
  }[t.style] || "&";
289
289
  if (t.style !== "deepObject" && t.explode === !1) {
290
- for (const l in r)
291
- n.push(l, t.allowReserved === !0 ? r[l] : encodeURIComponent(r[l]));
290
+ for (const c in r)
291
+ n.push(c, t.allowReserved === !0 ? r[c] : encodeURIComponent(r[c]));
292
292
  const i = n.join(",");
293
293
  switch (t.style) {
294
294
  case "form":
@@ -302,17 +302,17 @@ function le(e, r, t) {
302
302
  }
303
303
  }
304
304
  for (const i in r) {
305
- const l = t.style === "deepObject" ? `${e}[${i}]` : i;
306
- n.push(B(l, r[i], t));
305
+ const c = t.style === "deepObject" ? `${e}[${i}]` : i;
306
+ n.push(_(c, r[i], t));
307
307
  }
308
308
  const s = n.join(o);
309
309
  return t.style === "label" || t.style === "matrix" ? `${o}${s}` : s;
310
310
  }
311
- function ue(e, r, t) {
311
+ function le(e, r, t) {
312
312
  if (!Array.isArray(r))
313
313
  return "";
314
314
  if (t.explode === !1) {
315
- const s = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[t.style] || ",", i = (t.allowReserved === !0 ? r : r.map((l) => encodeURIComponent(l))).join(s);
315
+ const s = { form: ",", spaceDelimited: "%20", pipeDelimited: "|" }[t.style] || ",", i = (t.allowReserved === !0 ? r : r.map((c) => encodeURIComponent(c))).join(s);
316
316
  switch (t.style) {
317
317
  case "simple":
318
318
  return i;
@@ -328,10 +328,10 @@ function ue(e, r, t) {
328
328
  }
329
329
  const n = { simple: ",", label: ".", matrix: ";" }[t.style] || "&", o = [];
330
330
  for (const s of r)
331
- t.style === "simple" || t.style === "label" ? o.push(t.allowReserved === !0 ? s : encodeURIComponent(s)) : o.push(B(e, s, t));
331
+ t.style === "simple" || t.style === "label" ? o.push(t.allowReserved === !0 ? s : encodeURIComponent(s)) : o.push(_(e, s, t));
332
332
  return t.style === "label" || t.style === "matrix" ? `${n}${o.join(n)}` : o.join(n);
333
333
  }
334
- function se(e) {
334
+ function ne(e) {
335
335
  return function(t) {
336
336
  const n = [];
337
337
  if (t && typeof t == "object")
@@ -342,7 +342,7 @@ function se(e) {
342
342
  if (s.length === 0)
343
343
  continue;
344
344
  n.push(
345
- ue(o, s, E(b({
345
+ le(o, s, E(b({
346
346
  style: "form",
347
347
  explode: !0
348
348
  }, e == null ? void 0 : e.array), {
@@ -353,7 +353,7 @@ function se(e) {
353
353
  }
354
354
  if (typeof s == "object") {
355
355
  n.push(
356
- le(o, s, E(b({
356
+ ce(o, s, E(b({
357
357
  style: "deepObject",
358
358
  explode: !0
359
359
  }, e == null ? void 0 : e.object), {
@@ -362,7 +362,7 @@ function se(e) {
362
362
  );
363
363
  continue;
364
364
  }
365
- n.push(B(o, s, e));
365
+ n.push(_(o, s, e));
366
366
  }
367
367
  }
368
368
  return n.join("&");
@@ -372,23 +372,23 @@ function Ce(e, r) {
372
372
  var n;
373
373
  let t = e;
374
374
  for (const o of (n = e.match(ge)) != null ? n : []) {
375
- let s = o.substring(1, o.length - 1), i = !1, l = "simple";
376
- if (s.endsWith("*") && (i = !0, s = s.substring(0, s.length - 1)), s.startsWith(".") ? (l = "label", s = s.substring(1)) : s.startsWith(";") && (l = "matrix", s = s.substring(1)), !r || r[s] === void 0 || r[s] === null)
375
+ let s = o.substring(1, o.length - 1), i = !1, c = "simple";
376
+ if (s.endsWith("*") && (i = !0, s = s.substring(0, s.length - 1)), s.startsWith(".") ? (c = "label", s = s.substring(1)) : s.startsWith(";") && (c = "matrix", s = s.substring(1)), !r || r[s] === void 0 || r[s] === null)
377
377
  continue;
378
378
  const f = r[s];
379
379
  if (Array.isArray(f)) {
380
- t = t.replace(o, ue(s, f, { style: l, explode: i }));
380
+ t = t.replace(o, le(s, f, { style: c, explode: i }));
381
381
  continue;
382
382
  }
383
383
  if (typeof f == "object") {
384
- t = t.replace(o, le(s, f, { style: l, explode: i }));
384
+ t = t.replace(o, ce(s, f, { style: c, explode: i }));
385
385
  continue;
386
386
  }
387
- if (l === "matrix") {
388
- t = t.replace(o, `;${B(s, f)}`);
387
+ if (c === "matrix") {
388
+ t = t.replace(o, `;${_(s, f)}`);
389
389
  continue;
390
390
  }
391
- t = t.replace(o, l === "label" ? `.${encodeURIComponent(f)}` : encodeURIComponent(f));
391
+ t = t.replace(o, c === "label" ? `.${encodeURIComponent(f)}` : encodeURIComponent(f));
392
392
  }
393
393
  return t;
394
394
  }
@@ -403,7 +403,7 @@ function Se(e, r) {
403
403
  let n = r.querySerializer((s = r.params.query) != null ? s : {});
404
404
  return n.startsWith("?") && (n = n.substring(1)), n && (t += `?${n}`), t;
405
405
  }
406
- function oe(...e) {
406
+ function se(...e) {
407
407
  const r = new Headers();
408
408
  for (const t of e) {
409
409
  if (!t || typeof t != "object")
@@ -419,10 +419,10 @@ function oe(...e) {
419
419
  }
420
420
  return r;
421
421
  }
422
- function ie(e) {
422
+ function oe(e) {
423
423
  return e.endsWith("/") ? e.substring(0, e.length - 1) : e;
424
424
  }
425
- const ae = (e, r, t) => {
425
+ const ie = (e, r, t) => {
426
426
  try {
427
427
  const n = `${r}_${e}`, o = localStorage.getItem(n);
428
428
  if (!o) return null;
@@ -431,7 +431,7 @@ const ae = (e, r, t) => {
431
431
  } catch (n) {
432
432
  return null;
433
433
  }
434
- }, X = (e, r, t) => {
434
+ }, V = (e, r, t) => {
435
435
  try {
436
436
  const n = `${t}_${e}`, o = {
437
437
  data: r,
@@ -441,91 +441,90 @@ const ae = (e, r, t) => {
441
441
  } catch (n) {
442
442
  console.warn("Failed to cache dismissible item:", n);
443
443
  }
444
- }, ce = (e, r) => {
444
+ }, ae = (e, r) => {
445
445
  try {
446
446
  const t = `${r}_${e}`;
447
447
  localStorage.removeItem(t);
448
448
  } catch (t) {
449
449
  console.warn("Failed to remove cached dismissible item:", t);
450
450
  }
451
- }, fe = pe(
451
+ }, ue = pe(
452
452
  null
453
- ), $e = () => {
454
- const e = we(fe);
453
+ ), Ae = () => {
454
+ const e = we(ue);
455
455
  if (!e)
456
456
  throw new Error(
457
457
  "useDismissibleContext must be used within a DismissibleProvider"
458
458
  );
459
459
  return e;
460
- }, Ae = "dismissible", je = (e, r = {}) => {
461
- var k;
460
+ }, $e = "dismissible", je = (e, r = {}) => {
462
461
  const {
463
462
  initialData: t,
464
463
  enableCache: n = !0,
465
- cachePrefix: o = Ae,
464
+ cachePrefix: o = $e,
466
465
  cacheExpiration: s
467
- } = r, i = $e(), { userId: l } = i, f = Y(() => ve({
466
+ } = r, i = Ae(), { userId: c } = i, f = X(() => Re({
468
467
  baseUrl: i.baseUrl,
469
468
  headers: {}
470
- }), [i.baseUrl]), d = Y(() => `${l}-${e}`, [l, e]), g = J({
469
+ }), [i.baseUrl]), d = X(() => `${c}-${e}`, [c, e]), g = W({
471
470
  enableCache: n,
472
471
  cachePrefix: o,
473
472
  cacheExpiration: s
474
- }), A = J(e), u = J(d), a = J(null), [R, C] = W(!1), [O, x] = W(null), [v, j] = W(() => {
473
+ }), j = W(e), l = W(d), a = W(null), [R, x] = z(!1), [I, C] = z(), [v, A] = z(() => {
475
474
  if (t) return t;
476
475
  if (n) {
477
- const c = ae(
476
+ const u = ie(
478
477
  d,
479
478
  o,
480
479
  s
481
480
  );
482
- if (c) return c;
481
+ if (u) return u;
483
482
  }
484
- }), S = V(() => $(null, null, function* () {
483
+ }), S = K(() => $(null, null, function* () {
485
484
  var y;
486
485
  if (n) {
487
- const h = ae(
486
+ const h = ie(
488
487
  d,
489
488
  o,
490
489
  s
491
490
  );
492
491
  if (h != null && h.dismissedAt) {
493
- j(h), C(!1);
492
+ A(h), x(!1);
494
493
  return;
495
494
  }
496
495
  }
497
496
  (y = a.current) == null || y.abort();
498
- const c = new AbortController();
499
- a.current = c, C(!0), x(null);
497
+ const u = new AbortController();
498
+ a.current = u, x(!0), C(void 0);
500
499
  try {
501
- const h = yield i.getAuthHeaders(), { data: H, error: G } = yield f.GET(
500
+ const h = yield i.getAuthHeaders(), { data: H, error: P } = yield f.GET(
502
501
  "/v1/users/{userId}/items/{itemId}",
503
502
  {
504
503
  params: {
505
504
  path: {
506
- userId: l,
505
+ userId: c,
507
506
  itemId: e
508
507
  }
509
508
  },
510
509
  headers: h,
511
- signal: c.signal
510
+ signal: u.signal
512
511
  }
513
512
  );
514
- if (G || !H)
513
+ if (P || !H)
515
514
  throw new Error("Failed to fetch dismissible item");
516
- j(H.data), n && X(d, H.data, o);
515
+ A(H.data), n && V(d, H.data, o);
517
516
  } catch (h) {
518
517
  if (h instanceof Error && h.name === "AbortError")
519
518
  return;
520
- x(
519
+ C(
521
520
  h instanceof Error ? h : new Error("Unknown error occurred")
522
521
  );
523
522
  } finally {
524
- C(!1);
523
+ x(!1);
525
524
  }
526
525
  }), [
527
526
  e,
528
- l,
527
+ c,
529
528
  d,
530
529
  n,
531
530
  o,
@@ -533,77 +532,77 @@ const ae = (e, r, t) => {
533
532
  f,
534
533
  i
535
534
  ]);
536
- _(() => {
537
- const c = A.current !== e, y = u.current !== d;
538
- c || y ? (A.current = e, u.current = d, S()) : t || S();
539
- }, [e, d, t, S]), _(() => () => {
540
- var c;
541
- (c = a.current) == null || c.abort();
542
- }, []), _(() => {
543
- const c = g.current;
544
- (c.enableCache !== n || c.cachePrefix !== o || c.cacheExpiration !== s) && (c.cachePrefix !== o && ce(d, c.cachePrefix), !n && c.enableCache && ce(d, c.cachePrefix), g.current = {
535
+ Q(() => {
536
+ const u = j.current !== e, y = l.current !== d;
537
+ u || y ? (j.current = e, l.current = d, S()) : t || S();
538
+ }, [e, d, t, S]), Q(() => () => {
539
+ var u;
540
+ (u = a.current) == null || u.abort();
541
+ }, []), Q(() => {
542
+ const u = g.current;
543
+ (u.enableCache !== n || u.cachePrefix !== o || u.cacheExpiration !== s) && (u.cachePrefix !== o && ae(d, u.cachePrefix), !n && u.enableCache && ae(d, u.cachePrefix), g.current = {
545
544
  enableCache: n,
546
545
  cachePrefix: o,
547
546
  cacheExpiration: s
548
547
  }, S());
549
548
  }, [n, o, s, d, S]);
550
- const P = V(() => $(null, null, function* () {
551
- x(null);
549
+ const k = K(() => $(null, null, function* () {
550
+ C(void 0);
552
551
  try {
553
- const c = yield i.getAuthHeaders(), { data: y, error: h } = yield f.DELETE(
552
+ const u = yield i.getAuthHeaders(), { data: y, error: h } = yield f.DELETE(
554
553
  "/v1/users/{userId}/items/{itemId}",
555
554
  {
556
555
  params: {
557
556
  path: {
558
- userId: l,
557
+ userId: c,
559
558
  itemId: e
560
559
  }
561
560
  },
562
- headers: c
561
+ headers: u
563
562
  }
564
563
  );
565
564
  if (h || !y)
566
565
  throw new Error("Failed to dismiss item");
567
- j(y.data), n && X(d, y.data, o);
568
- } catch (c) {
569
- throw x(
570
- c instanceof Error ? c : new Error("Failed to dismiss item")
571
- ), c;
566
+ A(y.data), n && V(d, y.data, o);
567
+ } catch (u) {
568
+ throw C(
569
+ u instanceof Error ? u : new Error("Failed to dismiss item")
570
+ ), u;
572
571
  }
573
572
  }), [
574
573
  e,
575
- l,
574
+ c,
576
575
  d,
577
576
  n,
578
577
  o,
579
578
  f,
580
579
  i
581
- ]), z = V(() => $(null, null, function* () {
582
- x(null);
580
+ ]), F = K(() => $(null, null, function* () {
581
+ C(void 0);
583
582
  try {
584
- const c = yield i.getAuthHeaders(), { data: y, error: h } = yield f.POST(
583
+ const u = yield i.getAuthHeaders(), { data: y, error: h } = yield f.POST(
585
584
  "/v1/users/{userId}/items/{itemId}",
586
585
  {
587
586
  params: {
588
587
  path: {
589
- userId: l,
588
+ userId: c,
590
589
  itemId: e
591
590
  }
592
591
  },
593
- headers: c
592
+ headers: u
594
593
  }
595
594
  );
596
595
  if (h || !y)
597
596
  throw new Error("Failed to restore item");
598
- j(y.data), n && X(d, y.data, o);
599
- } catch (c) {
600
- throw x(
601
- c instanceof Error ? c : new Error("Failed to restore item")
602
- ), c;
597
+ A(y.data), n && V(d, y.data, o);
598
+ } catch (u) {
599
+ throw C(
600
+ u instanceof Error ? u : new Error("Failed to restore item")
601
+ ), u;
603
602
  }
604
603
  }), [
605
604
  e,
606
- l,
605
+ c,
607
606
  d,
608
607
  n,
609
608
  o,
@@ -611,11 +610,11 @@ const ae = (e, r, t) => {
611
610
  i
612
611
  ]);
613
612
  return {
614
- dismissedOn: (k = v == null ? void 0 : v.dismissedAt) != null ? k : null,
615
- dismiss: P,
616
- restore: z,
613
+ dismissedAt: v == null ? void 0 : v.dismissedAt,
614
+ dismiss: k,
615
+ restore: F,
617
616
  isLoading: R,
618
- error: O,
617
+ error: I,
619
618
  item: v
620
619
  };
621
620
  }, De = () => /* @__PURE__ */ U("div", { className: "dismissible-loading", "aria-live": "polite", children: "Loading..." }), Te = () => /* @__PURE__ */ U("div", { className: "dismissible-error", role: "alert", children: "Unable to load content. Please try again later." }), Ue = ({ onDismiss: e, ariaLabel: r }) => /* @__PURE__ */ U(
@@ -635,35 +634,33 @@ const ae = (e, r, t) => {
635
634
  ErrorComponent: o = Te,
636
635
  DismissButtonComponent: s = Ue,
637
636
  enableCache: i,
638
- cachePrefix: l,
637
+ cachePrefix: c,
639
638
  cacheExpiration: f,
640
639
  ignoreErrors: d = !1
641
640
  }) => {
642
- const { dismissedOn: g, isLoading: A, error: u, dismiss: a } = je(
641
+ const { dismissedAt: g, isLoading: j, error: l, dismiss: a } = je(
643
642
  e,
644
643
  {
645
644
  enableCache: i,
646
- cachePrefix: l,
645
+ cachePrefix: c,
647
646
  cacheExpiration: f
648
647
  }
649
- ), [R, C] = W(!1);
650
- _(() => {
651
- C(!1);
652
- }, [e]);
653
- const O = () => $(null, null, function* () {
654
- C(!0);
648
+ ), [R, x] = z(!1), [I, C] = z(e);
649
+ e !== I && (C(e), x(!1));
650
+ const v = () => $(null, null, function* () {
651
+ x(!0);
655
652
  try {
656
653
  yield a(), t == null || t();
657
- } catch (x) {
658
- C(!1);
654
+ } catch (A) {
655
+ x(!1);
659
656
  }
660
657
  });
661
- return A && n ? /* @__PURE__ */ U(n, { itemId: e }) : A && !n ? null : u && o && !d ? /* @__PURE__ */ U(o, { itemId: e, error: u }) : g || R ? null : /* @__PURE__ */ be("div", { className: "dismissible-container", children: [
658
+ return j && n ? /* @__PURE__ */ U(n, { itemId: e }) : j && !n ? null : l && o && !d ? /* @__PURE__ */ U(o, { itemId: e, error: l }) : g || R ? null : /* @__PURE__ */ be("div", { className: "dismissible-container", children: [
662
659
  /* @__PURE__ */ U("div", { className: "dismissible-content", children: r }),
663
660
  s ? /* @__PURE__ */ U(
664
661
  s,
665
662
  {
666
- onDismiss: O,
663
+ onDismiss: v,
667
664
  ariaLabel: `Dismiss ${e}`
668
665
  }
669
666
  ) : null
@@ -681,7 +678,7 @@ const ae = (e, r, t) => {
681
678
  }), qe = (e) => $(null, null, function* () {
682
679
  const r = yield He(e);
683
680
  return r ? { Authorization: `Bearer ${r}` } : {};
684
- }), Oe = (e) => {
681
+ }), Ie = (e) => {
685
682
  try {
686
683
  const r = new URL(e), t = r.hostname === "localhost" || r.hostname === "127.0.0.1" || r.hostname === "[::1]", n = r.protocol === "https:";
687
684
  return { isSecure: n || t, isLocalhost: t, isHttps: n };
@@ -694,11 +691,11 @@ const ae = (e, r, t) => {
694
691
  baseUrl: t,
695
692
  children: n
696
693
  }) => {
697
- const { isSecure: o } = Oe(t);
694
+ const { isSecure: o } = Ie(t);
698
695
  o || console.warn(
699
696
  `[dismissible] Insecure baseUrl "${t}". Use https:// in production (or localhost for development). JWT tokens may be exposed over insecure connections.`
700
697
  );
701
- const s = Y(
698
+ const s = X(
702
699
  () => ({
703
700
  userId: e,
704
701
  jwt: r,
@@ -709,14 +706,14 @@ const ae = (e, r, t) => {
709
706
  }),
710
707
  [e, r, t]
711
708
  );
712
- return /* @__PURE__ */ U(fe.Provider, { value: s, children: n });
709
+ return /* @__PURE__ */ U(ue.Provider, { value: s, children: n });
713
710
  };
714
711
  export {
715
712
  ke as Dismissible,
716
- fe as DismissibleContext,
713
+ ue as DismissibleContext,
717
714
  Fe as DismissibleProvider,
718
715
  qe as getAuthHeaders,
719
716
  He as resolveJwt,
720
- $e as useDismissibleContext,
717
+ Ae as useDismissibleContext,
721
718
  je as useDismissibleItem
722
719
  };