@pluno/product-agent-web 0.1.274 → 0.1.275

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.
@@ -9,16 +9,16 @@ function bt(t, e, s) {
9
9
  clearTimeout(n), t.removeEventListener("abort", i);
10
10
  });
11
11
  }
12
- const xs = ["main-chat-omnibox-hint", "main-chat-whatsapp-hint"], Ps = "pluno.productAgent.deviceHints", Un = ["pluno.productAgent.omniboxHintDismissed", "pluno.productAgent.whatsappHintDismissed"], Nn = "pluno.productAgent.mainChatPromptDecisions";
13
- function Ms(t) {
14
- const e = JSON.parse(t.getItem(Ps) ?? "{}"), s = JSON.parse(t.getItem(Nn) ?? "[]"), n = Object.fromEntries(xs.map((i, r) => [i, e[i] === !0 || t.getItem(Un[r]) === "true" || s.some((a) => a.scope.level === "device" && a.scope.key === "main-web-chat" && (a.promptKey === i || a.action === "dont_show_again" && a.category === (r ? "connections" : "product-tips")) && ["dismiss", "never", "dont_show_again"].includes(a.action))]));
15
- t.setItem(Ps, JSON.stringify(n));
12
+ const xs = ["main-chat-omnibox-hint", "main-chat-whatsapp-hint"], Ms = "pluno.productAgent.deviceHints", Un = ["pluno.productAgent.omniboxHintDismissed", "pluno.productAgent.whatsappHintDismissed"], Nn = "pluno.productAgent.mainChatPromptDecisions";
13
+ function Ps(t) {
14
+ const e = JSON.parse(t.getItem(Ms) ?? "{}"), s = JSON.parse(t.getItem(Nn) ?? "[]"), n = Object.fromEntries(xs.map((i, r) => [i, e[i] === !0 || t.getItem(Un[r]) === "true" || s.some((a) => a.scope.level === "device" && a.scope.key === "main-web-chat" && (a.promptKey === i || a.action === "dont_show_again" && a.category === (r ? "connections" : "product-tips")) && ["dismiss", "never", "dont_show_again"].includes(a.action))]));
15
+ t.setItem(Ms, JSON.stringify(n));
16
16
  for (const i of Un) t.removeItem(i);
17
17
  return t.setItem(Nn, JSON.stringify(s.filter((i) => !xs.includes(i.promptKey)))), n;
18
18
  }
19
19
  function Fr(t, e) {
20
20
  if (!xs.includes(e)) throw new Error("Unknown device hint.");
21
- t.setItem(Ps, JSON.stringify({ ...Ms(t), [e]: !0 }));
21
+ t.setItem(Ms, JSON.stringify({ ...Ps(t), [e]: !0 }));
22
22
  }
23
23
  function es(t, e, s, n) {
24
24
  if (s.authorityId !== t.account.authority?.authorityId || s.generation !== t.account.authority.generation) return t;
@@ -210,7 +210,7 @@ const xi = {
210
210
  function X(t, e) {
211
211
  return zr[t][e] === !0;
212
212
  }
213
- function Pi(t, e, s = null, n = !0) {
213
+ function Mi(t, e, s = null, n = !0) {
214
214
  const i = (a, o) => ({ operation: e, allowed: a === "allowed", reason: a, recovery: o }), r = t.authority;
215
215
  if (!r) return i("authentication", "login");
216
216
  if (!X(r.profile, xi[e])) return i("capability", "none");
@@ -234,7 +234,7 @@ function fe(t) {
234
234
  if (!e) throw new Error("Display timestamps must retain the backend UTC precision.");
235
235
  return `${e[1]}.${(e[2] ?? "").padEnd(6, "0")}`;
236
236
  }
237
- function Pt(t) {
237
+ function Mt(t) {
238
238
  return "revision" in t.data ? t.data.revision : null;
239
239
  }
240
240
  function ye(t) {
@@ -290,8 +290,8 @@ function Y(t) {
290
290
  if (!je(t)) throw new Error("Conversation inputs must be JSON-safe values.");
291
291
  return JSON.parse(JSON.stringify(t));
292
292
  }
293
- function Mi(t = "", e = 0) {
294
- return G({ authorityId: t, generation: e, pendingRestoration: {}, proactiveQuestions: {}, sessions: {}, submissions: {}, submissionOrder: [], stops: {}, requests: {}, requestSequence: 0, deliveries: {}, operations: {}, effectsEnabled: !1, checkpointEffectId: null, checkpointError: null });
293
+ function Pi(t = "", e = 0) {
294
+ return G({ authorityId: t, generation: e, pendingRestoration: {}, proactiveQuestions: {}, sessions: {}, submissions: {}, submissionOrder: [], stops: {}, requests: {}, requestSequence: 0, deliveries: {}, operations: {}, effectsEnabled: !1, durableSubmissionIds: [], checkpointEffectId: null, checkpointError: null });
295
295
  }
296
296
  function Us(t) {
297
297
  return {
@@ -314,47 +314,47 @@ function Hr(t, e) {
314
314
  return s && n >= 0 ? s.slice(0, n + 1) : [e];
315
315
  }
316
316
  function Ie(t, e, s) {
317
- const n = t.submissionOrder.map((k) => t.submissions[k]).filter((k) => k.conversationScopeId === s), i = e.selections[s]?.sessionId ?? n.find((k) => !k.cancelled && k.sessionId !== null)?.sessionId ?? null, r = i ? t.sessions[i] : void 0, a = t.submissionOrder.map((k) => t.submissions[k]).filter((k) => i ? k.sessionId === i || k.sessionId === null && k.conversationScopeId === s : k.conversationScopeId === s), o = Object.values(r?.items ?? {}).sort((k, x) => {
318
- const U = fe(k.created_at), H = fe(x.created_at);
319
- return U < H ? -1 : U > H ? 1 : k.id < x.id ? -1 : k.id > x.id ? 1 : 0;
320
- }), c = a.filter((k) => (!k.cancelled || k.conversationScopeId === s && (k.sessionId === null || k.sessionId === i || i === null && k === a[a.length - 1])) && !r?.items[k.userMessageId] && !r?.removedItems[k.userMessageId]), d = {};
321
- for (const k of o) {
322
- const x = Pt(k);
317
+ const n = t.submissionOrder.map((S) => t.submissions[S]).filter((S) => S.conversationScopeId === s), i = e.selections[s]?.sessionId ?? n.find((S) => !S.cancelled && S.sessionId !== null)?.sessionId ?? null, r = i ? t.sessions[i] : void 0, a = t.submissionOrder.map((S) => t.submissions[S]).filter((S) => i ? S.sessionId === i || S.sessionId === null && S.conversationScopeId === s : S.conversationScopeId === s), o = Object.values(r?.items ?? {}).sort((S, x) => {
318
+ const U = fe(S.created_at), H = fe(x.created_at);
319
+ return U < H ? -1 : U > H ? 1 : S.id < x.id ? -1 : S.id > x.id ? 1 : 0;
320
+ }), c = a.filter((S) => (!S.cancelled || S.conversationScopeId === s && (S.sessionId === null || S.sessionId === i || i === null && S === a[a.length - 1])) && !r?.items[S.userMessageId] && !r?.removedItems[S.userMessageId]), d = {};
321
+ for (const S of o) {
322
+ const x = Mt(S);
323
323
  if (x === null) continue;
324
- const U = r?.streams[k.id];
325
- d[k.id] = U ? U.state === "open" ? "open" : x < U.revision ? "awaiting_content" : U.state : "open";
324
+ const U = r?.streams[S.id];
325
+ d[S.id] = U ? U.state === "open" ? "open" : x < U.revision ? "awaiting_content" : U.state : "open";
326
326
  }
327
327
  const l = [];
328
- for (const k of o)
329
- if (k.type === "user_message")
330
- l.push({ id: k.id, userMessageId: k.id, activityIds: [], outcomeIds: [], collapsed: !1 });
328
+ for (const S of o)
329
+ if (S.type === "user_message")
330
+ l.push({ id: S.id, userMessageId: S.id, activityIds: [], outcomeIds: [], collapsed: !1 });
331
331
  else {
332
- l.length || l.push({ id: `leading:${k.id}`, userMessageId: null, activityIds: [], outcomeIds: [], collapsed: !1 });
333
- const x = l.length - 1, U = l[x], H = k.type === "commentary" || k.type === "tool_summary" ? "activityIds" : "outcomeIds";
334
- l[x] = { ...U, [H]: [...U[H], k.id] };
332
+ l.length || l.push({ id: `leading:${S.id}`, userMessageId: null, activityIds: [], outcomeIds: [], collapsed: !1 });
333
+ const x = l.length - 1, U = l[x], H = S.type === "commentary" || S.type === "tool_summary" ? "activityIds" : "outcomeIds";
334
+ l[x] = { ...U, [H]: [...U[H], S.id] };
335
335
  }
336
- for (const k of c) {
336
+ for (const S of c) {
337
337
  const x = l.findIndex((U) => {
338
338
  const H = a.find((at) => at.userMessageId === U.userMessageId), $e = r?.items[U.userMessageId ?? U.activityIds[0] ?? U.outcomeIds[0]];
339
- return (H?.submittedAt ?? ($e ? Date.parse($e.created_at) : 1 / 0)) > k.submittedAt;
339
+ return (H?.submittedAt ?? ($e ? Date.parse($e.created_at) : 1 / 0)) > S.submittedAt;
340
340
  });
341
341
  l.splice(x < 0 ? l.length : x, 0, {
342
- id: k.userMessageId,
343
- userMessageId: k.userMessageId,
342
+ id: S.userMessageId,
343
+ userMessageId: S.userMessageId,
344
344
  activityIds: [],
345
345
  outcomeIds: [],
346
346
  collapsed: !1
347
347
  });
348
348
  }
349
- const u = r?.execution, h = a.filter((k) => !k.cancelled && k.delivery !== "failed"), p = h.filter((k) => k.delivery !== "accepted" && k.executionVersion === null), m = h.filter((k) => k.delivery === "accepted" && k.executionVersion === null), f = h[h.length - 1], y = p.length > 0, I = f !== void 0 && m.includes(f);
349
+ const u = r?.execution, h = a.filter((S) => !S.cancelled && S.delivery !== "failed"), p = h.filter((S) => S.delivery !== "accepted" && S.executionVersion === null), m = h.filter((S) => S.delivery === "accepted" && S.executionVersion === null), f = h[h.length - 1], y = p.length > 0, I = f !== void 0 && m.includes(f);
350
350
  let _ = y ? "submitting" : I ? "awaiting_execution" : u?.phase ?? "idle";
351
- const S = Object.entries(t.stops).filter(([k]) => k === s || i !== null && e.selections[k]?.sessionId === i).map(([, k]) => k).find((k) => (!a.length || k.userMessageIds.includes(a[a.length - 1].userMessageId) || !y && !I && le(u).some((x) => k.userMessageIds.includes(x))) && (!u || u.version <= k.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(u.phase) || a.some((x) => x.cancelled && x.executionVersion === null && k.userMessageIds.includes(x.userMessageId)))), g = u && ["thinking", "steering", "queued", "stopping"].includes(u.phase) || a.some((k) => k.delivery === "accepted" && k.executionVersion === null && S?.userMessageIds.includes(k.userMessageId));
352
- S && g && !y && (!u || !["thinking", "steering", "queued", "stopping"].includes(u.phase) || le(u).every((k) => S.userMessageIds.includes(k))) && (_ = "stopping"), S && !g && !y && a.some((k) => k.cancelled && k.executionVersion === null && S.userMessageIds.includes(k.userMessageId)) && (_ = a.some((k) => S.userMessageIds.includes(k.userMessageId) && ["sending", "uncertain"].includes(k.delivery)) ? "stopping" : "stopped");
353
- const b = ["thinking", "steering", "queued"].includes(_), v = t.stops[s] ?? S, w = v?.userMessageIds.filter((k) => !["completed", "failed"].includes(r?.executionByUserMessage[k]?.phase ?? "")) ?? [], R = w.some((k) => {
354
- const x = a.find((H) => H.userMessageId === k);
355
- return !Object.values(t.operations).some((H) => H.command.type === "run.stop" && H.command.payload.expectedUserMessageId === k && H.phase === "done") && (x?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(x.delivery) || !!(u && le(u).includes(k) && ["thinking", "steering", "queued", "stopping"].includes(u.phase)));
356
- }), q = u?.user_message_ids ?? [], C = y || I ? f?.userMessageId ?? null : q[q.length - 1] ?? null, E = l.find((k) => k.userMessageId === C), T = b ? [...E?.activityIds ?? []].reverse().find((k) => d[k] === "open") ?? null : null, O = i !== null && !!e.selections[s]?.provisionalId && o.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
357
- (!r?.execution || r.execution.phase === "idle" && r.execution.user_message_ids.length === 0) && Object.values(t.operations).some((k) => k.conversationScopeId === s && k.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(k.command.type) && !k.command.payload.sessionId && k.result?.sessionId === i);
351
+ const k = Object.entries(t.stops).filter(([S]) => S === s || i !== null && e.selections[S]?.sessionId === i).map(([, S]) => S).find((S) => (!a.length || S.userMessageIds.includes(a[a.length - 1].userMessageId) || !y && !I && le(u).some((x) => S.userMessageIds.includes(x))) && (!u || u.version <= S.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(u.phase) || a.some((x) => x.cancelled && x.executionVersion === null && S.userMessageIds.includes(x.userMessageId)))), g = u && ["thinking", "steering", "queued", "stopping"].includes(u.phase) || a.some((S) => S.delivery === "accepted" && S.executionVersion === null && k?.userMessageIds.includes(S.userMessageId));
352
+ k && g && !y && (!u || !["thinking", "steering", "queued", "stopping"].includes(u.phase) || le(u).every((S) => k.userMessageIds.includes(S))) && (_ = "stopping"), k && !g && !y && a.some((S) => S.cancelled && S.executionVersion === null && k.userMessageIds.includes(S.userMessageId)) && (_ = a.some((S) => k.userMessageIds.includes(S.userMessageId) && ["sending", "uncertain"].includes(S.delivery)) ? "stopping" : "stopped");
353
+ const b = ["thinking", "steering", "queued"].includes(_), v = t.stops[s] ?? k, w = v?.userMessageIds.filter((S) => !["completed", "failed"].includes(r?.executionByUserMessage[S]?.phase ?? "")) ?? [], R = w.some((S) => {
354
+ const x = a.find((H) => H.userMessageId === S);
355
+ return !Object.values(t.operations).some((H) => H.command.type === "run.stop" && H.command.payload.expectedUserMessageId === S && H.phase === "done") && (x?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(x.delivery) || !!(u && le(u).includes(S) && ["thinking", "steering", "queued", "stopping"].includes(u.phase)));
356
+ }), q = u?.user_message_ids ?? [], C = y || I ? f?.userMessageId ?? null : q[q.length - 1] ?? null, E = l.find((S) => S.userMessageId === C), T = b ? [...E?.activityIds ?? []].reverse().find((S) => d[S] === "open") ?? null : null, O = i !== null && !!e.selections[s]?.provisionalId && o.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
357
+ (!r?.execution || r.execution.phase === "idle" && r.execution.user_message_ids.length === 0) && Object.values(t.operations).some((S) => S.conversationScopeId === s && S.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(S.command.type) && !S.command.payload.sessionId && S.result?.sessionId === i);
358
358
  return G({
359
359
  historyRefreshFailure: r?.historyRefreshFailure ?? null,
360
360
  selectionKey: s ? JSON.stringify([t.authorityId, t.generation, s]) : void 0,
@@ -365,17 +365,17 @@ function Ie(t, e, s) {
365
365
  optimistic: c,
366
366
  submissions: a,
367
367
  followUps: r?.followUps ?? [],
368
- isRetrying: Object.values(t.operations).some((k) => k.command.type === "chat.retry_last_user_message" && k.command.payload.sessionId === i && ["waiting", "running", "uncertain"].includes(k.phase)),
369
- deliveries: Object.fromEntries(a.filter((k) => t.deliveries[k.userMessageId]).map((k) => [k.userMessageId, t.deliveries[k.userMessageId]])),
368
+ isRetrying: Object.values(t.operations).some((S) => S.command.type === "chat.retry_last_user_message" && S.command.payload.sessionId === i && ["waiting", "running", "uncertain"].includes(S.phase)),
369
+ deliveries: Object.fromEntries(a.filter((S) => t.deliveries[S.userMessageId]).map((S) => [S.userMessageId, t.deliveries[S.userMessageId]])),
370
370
  removedItems: r?.removedItems ?? {},
371
371
  streamStates: d,
372
372
  preparation: r?.preparation ?? null,
373
373
  stop: v ? { ...v, userMessageIds: w, pending: R } : null,
374
- segments: l.map((k, x) => ({ ...k, collapsed: b ? k.userMessageId !== C : x < l.length - 1 || k.activityIds.length > 0 })),
374
+ segments: l.map((S, x) => ({ ...S, collapsed: b ? S.userMessageId !== C : x < l.length - 1 || S.activityIds.length > 0 })),
375
375
  activity: { phase: _, activeItemId: T, userMessageId: C, executionKey: JSON.stringify([...le(u)].sort()) },
376
376
  // Staging transfers the immutable input to the core. Waiting for backend acceptance leaves
377
377
  // the same submitted text in the optimistic transcript and composer during delivery.
378
- receipts: n.filter((k) => !k.cancelled && e.clients[k.clientScopeId] === s).map((k) => ({ viewId: k.viewId, userMessageId: k.userMessageId, acceptedRendererRevision: k.rendererRevision }))
378
+ receipts: n.filter((S) => !S.cancelled && e.clients[S.clientScopeId] === s).map((S) => ({ viewId: S.viewId, userMessageId: S.userMessageId, acceptedRendererRevision: S.rendererRevision, durable: t.durableSubmissionIds.includes(S.userMessageId) || S.delivery === "accepted" }))
379
379
  });
380
380
  }
381
381
  function Ui(t, e) {
@@ -468,7 +468,7 @@ function Kr(t, e, s) {
468
468
  if (!s.sessionId || !l || l.sessionId !== s.sessionId || !Oi(t, s.conversationScopeId, c) || t.features.refreshRequired && !l.shown[c] || n.profile === "main_web_chat" && !t.interactions.bridgeReady && !l.shown[c]) continue;
469
469
  const u = Ye(t, c), h = t.interactions.preferencePrompts[c], p = t.interactions.deviceFacts[c], m = `preference:${c}`, f = u === null;
470
470
  if (u === !1 || t.features.desiredPreferences[c] === !1 || f && h.snoozedUntil && Date.parse(h.snoozedUntil) > a || !f && (p.permission !== "missing" || p.snoozedUntil && Date.parse(p.snoozedUntil) > a)) continue;
471
- const y = Object.values(t.interactions.devicePending).some((S) => S.feature === c), I = o([m, `preferenceSnooze:${c}`, `preferenceAcknowledge:${c}`]), _ = I.error ?? t.interactions.deviceErrors[c] ?? (l.shown[c] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
471
+ const y = Object.values(t.interactions.devicePending).some((k) => k.feature === c), I = o([m, `preferenceSnooze:${c}`, `preferenceAcknowledge:${c}`]), _ = I.error ?? t.interactions.deviceErrors[c] ?? (l.shown[c] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
472
472
  r.push({
473
473
  id: m,
474
474
  category: f ? "preference" : "permission",
@@ -615,7 +615,7 @@ function Wr(t, e, s, n) {
615
615
  if (f?.status === "error" && f.error?.code !== "interaction_not_started") throw new Error("Reconcile the previous action before trying again.");
616
616
  if (e.action !== "edit") {
617
617
  if (a.profile.startsWith("extension_") && !e.origin) throw new Error("Task submission requires the current page origin.");
618
- const _ = Pi(i.account, "send_message", e.origin ?? null);
618
+ const _ = Mi(i.account, "send_message", e.origin ?? null);
619
619
  if (!_.allowed) throw new Error(`Task submission unavailable: ${_.reason}.`);
620
620
  }
621
621
  const y = i.interactions.welcome[u.id], I = y.category === "morning_report" ? y.tasks[e.taskIndex ?? 0] : y.text;
@@ -713,9 +713,9 @@ function Gr(t, e, s, n) {
713
713
  return { state: i, effects: r };
714
714
  }
715
715
  const y = d(h), I = (i.appearanceEpochs[h] ?? 0) + 1, _ = { ...i.pending };
716
- for (const [S, g] of Object.entries(_)) {
716
+ for (const [k, g] of Object.entries(_)) {
717
717
  if (g.mode !== "query" || !c(g.operation, h)) continue;
718
- delete _[S];
718
+ delete _[k];
719
719
  const b = o("query", g.requestId, I);
720
720
  _[b] = { ...g, effectId: b, status: "queued" };
721
721
  }
@@ -879,11 +879,11 @@ function Ls(t, e, s) {
879
879
  const c = (g, b) => {
880
880
  const v = { ...n.features.contextObservers }, w = v[g];
881
881
  if (b === null ? delete v[g] : v[g] = ie(o, { kind: "originContext", clientScopeId: g, origin: b, pageUrl: "" }), r({ contextObservers: v }), !w || Object.values(v).includes(w)) return;
882
- const R = { ...n.features.queries }, q = { ...n.features.polls }, C = { ...n.features.contextReads }, E = { ...n.features.originContextQueries }, T = { ...n.features.pending }, O = E[w]?.origin, k = { ...n.features.contextRunOrigins };
883
- for (const [x, U] of Object.entries(k)) U === O && delete k[x];
882
+ const R = { ...n.features.queries }, q = { ...n.features.polls }, C = { ...n.features.contextReads }, E = { ...n.features.originContextQueries }, T = { ...n.features.pending }, O = E[w]?.origin, S = { ...n.features.contextRunOrigins };
883
+ for (const [x, U] of Object.entries(S)) U === O && delete S[x];
884
884
  delete R[w], delete q[w], delete C[w], delete E[w];
885
885
  for (const [x, U] of Object.entries(T)) U.mode === "query" && U.key === w && delete T[x];
886
- r({ queries: R, polls: q, contextReads: C, originContextQueries: E, contextRunOrigins: k, pending: T });
886
+ r({ queries: R, polls: q, contextReads: C, originContextQueries: E, contextRunOrigins: S, pending: T });
887
887
  };
888
888
  if (e.type === "stage7.account_fallback") return { state: { ...n, account: {
889
889
  ...n.account,
@@ -1265,7 +1265,7 @@ function Ls(t, e, s) {
1265
1265
  for (const [T, O] of Object.entries(n.features.originContextQueries))
1266
1266
  if (O.origin === w) {
1267
1267
  R[T] = { ...R[T], data: v, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, C[T] = { settledAt: e.output.completedAt, failures: 0 }, delete E[T];
1268
- for (const [k, x] of Object.entries(q)) x.mode === "query" && x.key === T && delete q[k];
1268
+ for (const [S, x] of Object.entries(q)) x.mode === "query" && x.key === T && delete q[S];
1269
1269
  ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(v.value.status) && (E[T] = { query: { ...O, kind: "originContext", trigger: "poll" }, deadline: n.features.now + 5e3 });
1270
1270
  }
1271
1271
  r({ queries: R, pending: q, contextReads: C, polls: E });
@@ -1338,18 +1338,18 @@ function Ls(t, e, s) {
1338
1338
  ...Object.values(n.interactions.decisions).map((g) => g.nextEligibleAt ? Date.parse(g.nextEligibleAt) : null),
1339
1339
  ...Object.values(n.interactions.preferencePrompts).map((g) => g.snoozedUntil ? Date.parse(g.snoozedUntil) : null),
1340
1340
  ...Object.values(n.interactions.deviceFacts).map((g) => g.snoozedUntil ? Date.parse(g.snoozedUntil) : null)
1341
- ].filter((g) => g !== null && g > n.features.now), S = _.length ? Math.min(..._) : null;
1342
- if (S !== n.features.timerDeadline && !n.features.schedulerError) {
1343
- const g = n.features.timerRevision + 1, b = S === null ? null : Se(o, "wait", `${g}:${S}`);
1344
- r({ timerId: b, timerDeadline: S, timerRevision: g }), S !== null && b && i.push({ kind: "stage7.wait", id: b, input: { authority: o, deadline: S } });
1341
+ ].filter((g) => g !== null && g > n.features.now), k = _.length ? Math.min(..._) : null;
1342
+ if (k !== n.features.timerDeadline && !n.features.schedulerError) {
1343
+ const g = n.features.timerRevision + 1, b = k === null ? null : Se(o, "wait", `${g}:${k}`);
1344
+ r({ timerId: b, timerDeadline: k, timerRevision: g }), k !== null && b && i.push({ kind: "stage7.wait", id: b, input: { authority: o, deadline: k } });
1345
1345
  }
1346
1346
  return { state: n, effects: i };
1347
1347
  }
1348
- function Mt(t, e) {
1348
+ function Pt(t, e) {
1349
1349
  return t.account.authority ? t.features.queries[ie(t.account.authority, e)] ?? null : null;
1350
1350
  }
1351
1351
  function Xr(t, e) {
1352
- const s = Mt(t, e);
1352
+ const s = Pt(t, e);
1353
1353
  return s?.status === "loading" || s?.status === "refreshing" || !!(t.account.authority && t.features.polls[ie(t.account.authority, e)]);
1354
1354
  }
1355
1355
  const Yr = {
@@ -1493,12 +1493,12 @@ function N(t) {
1493
1493
  if (!t || typeof t != "object" || Array.isArray(t)) throw new Error("Invalid feature response object.");
1494
1494
  return t;
1495
1495
  }
1496
- function M(t) {
1496
+ function P(t) {
1497
1497
  if (typeof t != "string") throw new Error("Invalid feature response string.");
1498
1498
  return t;
1499
1499
  }
1500
1500
  function de(t) {
1501
- return t == null ? null : M(t);
1501
+ return t == null ? null : P(t);
1502
1502
  }
1503
1503
  function xe(t) {
1504
1504
  if (typeof t != "number" || !Number.isSafeInteger(t) || t < 0) throw new Error("Invalid feature revision.");
@@ -1513,7 +1513,7 @@ function ns(t) {
1513
1513
  }
1514
1514
  function It(t) {
1515
1515
  if (!Array.isArray(t)) throw new Error("Invalid feature string list.");
1516
- return t.map(M);
1516
+ return t.map(P);
1517
1517
  }
1518
1518
  function Dt(t) {
1519
1519
  const e = de(t);
@@ -1541,19 +1541,19 @@ function to(t) {
1541
1541
  return { notifications: Ut(e.notifications), tab_grouping: Ut(e.tabGrouping) };
1542
1542
  }
1543
1543
  function $n(t) {
1544
- const e = N(t), s = N(e.request), n = M(s.category), i = M(s.action), r = { category: n, action: i, promptKey: M(s.promptKey), expectedRevision: xe(s.expectedRevision) };
1544
+ const e = N(t), s = N(e.request), n = P(s.category), i = P(s.action), r = { category: n, action: i, promptKey: P(s.promptKey), expectedRevision: xe(s.expectedRevision) };
1545
1545
  dn(r);
1546
- const a = M(e.outcome);
1546
+ const a = P(e.outcome);
1547
1547
  if (!["resolved", "snoozed", "suppressed"].includes(a)) throw new Error("Invalid decision outcome.");
1548
1548
  const o = Dt(e.decidedAt);
1549
1549
  if (o === null) throw new Error("Missing decision acceptance time.");
1550
1550
  const c = Dt(e.nextEligibleAt);
1551
1551
  if (a === "snoozed" && c === null) throw new Error("Missing decision deadline.");
1552
1552
  return {
1553
- decisionKey: M(e.decisionKey),
1553
+ decisionKey: P(e.decisionKey),
1554
1554
  revision: xe(e.revision),
1555
1555
  decidedAt: o,
1556
- request: { ...r, requestId: M(s.requestId) },
1556
+ request: { ...r, requestId: P(s.requestId) },
1557
1557
  outcome: a,
1558
1558
  nextEligibleAt: c
1559
1559
  };
@@ -1561,16 +1561,16 @@ function $n(t) {
1561
1561
  function is(t) {
1562
1562
  const e = N(t);
1563
1563
  return {
1564
- eventTypeRegex: M(e.eventTypeRegex),
1565
- urlRegex: M(e.urlRegex),
1566
- ...e.targetRoleRegex == null ? {} : { targetRoleRegex: M(e.targetRoleRegex) },
1567
- ...e.targetNameRegex == null ? {} : { targetNameRegex: M(e.targetNameRegex) },
1568
- ...e.targetAncestorRegex == null ? {} : { targetAncestorRegex: M(e.targetAncestorRegex) }
1564
+ eventTypeRegex: P(e.eventTypeRegex),
1565
+ urlRegex: P(e.urlRegex),
1566
+ ...e.targetRoleRegex == null ? {} : { targetRoleRegex: P(e.targetRoleRegex) },
1567
+ ...e.targetNameRegex == null ? {} : { targetNameRegex: P(e.targetNameRegex) },
1568
+ ...e.targetAncestorRegex == null ? {} : { targetAncestorRegex: P(e.targetAncestorRegex) }
1569
1569
  };
1570
1570
  }
1571
1571
  function so(t) {
1572
- const e = N(t), s = N(e.condition), n = { id: M(e.id), suggestedQuery: M(e.suggestedQuery) };
1573
- if (s.template === "page_visit") return { ...n, condition: { template: s.template, urlRegex: M(s.urlRegex) } };
1572
+ const e = N(t), s = N(e.condition), n = { id: P(e.id), suggestedQuery: P(e.suggestedQuery) };
1573
+ if (s.template === "page_visit") return { ...n, condition: { template: s.template, urlRegex: P(s.urlRegex) } };
1574
1574
  if (s.template === "semantic_interaction") return { ...n, condition: { template: s.template, event: is(s.event) } };
1575
1575
  if (s.template === "event_sequence") {
1576
1576
  if (!Array.isArray(s.steps)) throw new Error("Invalid proactive sequence.");
@@ -1579,23 +1579,23 @@ function so(t) {
1579
1579
  if (s.template === "page_state_after_event") {
1580
1580
  const i = N(s.state);
1581
1581
  return { ...n, condition: { template: s.template, event: is(s.event), withinSeconds: xe(s.withinSeconds), state: {
1582
- urlRegex: M(i.urlRegex),
1583
- ...i.textRegex == null ? {} : { textRegex: M(i.textRegex) },
1584
- ...i.roleRegex == null ? {} : { roleRegex: M(i.roleRegex) },
1585
- ...i.nameRegex == null ? {} : { nameRegex: M(i.nameRegex) }
1582
+ urlRegex: P(i.urlRegex),
1583
+ ...i.textRegex == null ? {} : { textRegex: P(i.textRegex) },
1584
+ ...i.roleRegex == null ? {} : { roleRegex: P(i.roleRegex) },
1585
+ ...i.nameRegex == null ? {} : { nameRegex: P(i.nameRegex) }
1586
1586
  } } };
1587
1587
  }
1588
1588
  throw new Error("Invalid proactive condition.");
1589
1589
  }
1590
1590
  function Ve(t, e) {
1591
1591
  const s = N(e);
1592
- if (t === "contextRun") return { kind: t, value: { status: M(s.status), runId: M(s.id), updatedAt: de(s.completedAt ?? s.createdAt), hasContext: null } };
1592
+ if (t === "contextRun") return { kind: t, value: { status: P(s.status), runId: P(s.id), updatedAt: de(s.completedAt ?? s.createdAt), hasContext: null } };
1593
1593
  const n = s.latestRun === null || s.latestRun === void 0 ? null : N(s.latestRun), i = de(s.activeRefreshRunId);
1594
1594
  return { kind: t, value: {
1595
- ...s.origin === void 0 ? {} : { origin: M(s.origin) },
1596
- ...n?.createdAt === void 0 ? {} : { latestRun: { id: M(n.id), status: M(n.status), createdAt: M(n.createdAt), completedAt: de(n.completedAt), error: de(n.error) } },
1597
- status: i ? "running" : n ? M(n.status) : "idle",
1598
- runId: i ?? (n ? M(n.id) : null),
1595
+ ...s.origin === void 0 ? {} : { origin: P(s.origin) },
1596
+ ...n?.createdAt === void 0 ? {} : { latestRun: { id: P(n.id), status: P(n.status), createdAt: P(n.createdAt), completedAt: de(n.completedAt), error: de(n.error) } },
1597
+ status: i ? "running" : n ? P(n.status) : "idle",
1598
+ runId: i ?? (n ? P(n.id) : null),
1599
1599
  updatedAt: de(s.latestSnapshotUpdatedAt),
1600
1600
  hasContext: Be(s.hasContext)
1601
1601
  } };
@@ -1603,11 +1603,11 @@ function Ve(t, e) {
1603
1603
  function lt(t, e) {
1604
1604
  const s = N(t), n = s.style === null ? null : N(s.style), i = n && N(n.style ?? n);
1605
1605
  if (!i) return { kind: "appearance", origin: e, value: null };
1606
- const r = M(i.colorScheme);
1606
+ const r = P(i.colorScheme);
1607
1607
  if (r !== "light" && r !== "dark") throw new Error("Invalid appearance color scheme.");
1608
1608
  const a = n?.metadata ?? null;
1609
1609
  if (!je(a)) throw new Error("Invalid appearance metadata.");
1610
- return { kind: "appearance", origin: e, ...n?.createdAt === void 0 ? {} : { stored: { createdAt: M(n.createdAt), updatedAt: M(n.updatedAt), metadata: a } }, value: { accent: M(i.accent), colorScheme: r, fontFamily: M(i.fontFamily), scribbleStyle: Be(i.scribbleStyle) } };
1610
+ return { kind: "appearance", origin: e, ...n?.createdAt === void 0 ? {} : { stored: { createdAt: P(n.createdAt), updatedAt: P(n.updatedAt), metadata: a } }, value: { accent: P(i.accent), colorScheme: r, fontFamily: P(i.fontFamily), scribbleStyle: Be(i.scribbleStyle) } };
1611
1611
  }
1612
1612
  function ut(t) {
1613
1613
  const e = N(t);
@@ -1674,7 +1674,7 @@ function no(t) {
1674
1674
  kind: "userSuggestedTasks",
1675
1675
  prompts: It(d.starterPrompts),
1676
1676
  morningReportOpening: de(d.morningReportOpening),
1677
- signupAt: M(d.signupAt),
1677
+ signupAt: P(d.signupAt),
1678
1678
  proactiveSuggestions: d.proactiveSuggestions.map(so)
1679
1679
  };
1680
1680
  break;
@@ -1756,7 +1756,7 @@ function no(t) {
1756
1756
  case "refreshContext": {
1757
1757
  const d = N(await o("/context/refresh", { origin: i.origin, community_id: i.communityId })), l = Ve("originContext", d.status);
1758
1758
  if (l.kind !== "originContext") throw new Error("Invalid origin context result.");
1759
- c = { ...l, value: { ...l.value, runId: M(d.runId), status: d.queued === !0 ? "queued" : l.value.status } };
1759
+ c = { ...l, value: { ...l.value, runId: P(d.runId), status: d.queued === !0 ? "queued" : l.value.status } };
1760
1760
  break;
1761
1761
  }
1762
1762
  case "refreshUserContext":
@@ -1851,7 +1851,7 @@ function $i(t, e, s) {
1851
1851
  }
1852
1852
  const f = Object.values(m.features.pending).find((y) => y.requestId === r);
1853
1853
  if (!f && e.type === "stage7.query") {
1854
- const y = Mt(m, e.query);
1854
+ const y = Pt(m, e.query);
1855
1855
  y?.status === "error" ? h(y.error) : y?.status === "ready" && y.data && h(null, y.data);
1856
1856
  }
1857
1857
  f?.status === "error" ? h(f.error) : f?.status === "done" && h(null, f.result);
@@ -1880,12 +1880,12 @@ async function co(t, e, s = crypto.randomUUID()) {
1880
1880
  y.status === "error" ? h(y.error) : y.status === "done" && h();
1881
1881
  return;
1882
1882
  }
1883
- const I = Object.values(f.features.pending).find((S) => S.requestId === r);
1883
+ const I = Object.values(f.features.pending).find((k) => k.requestId === r);
1884
1884
  if (I) {
1885
1885
  I.status === "error" ? h(I.error) : I.status === "done" && h();
1886
1886
  return;
1887
1887
  }
1888
- if (Object.values(f.interactions.devicePending).some((S) => S.requestId === r)) return;
1888
+ if (Object.values(f.interactions.devicePending).some((k) => k.requestId === r)) return;
1889
1889
  const _ = e.interactionId === "preference:notifications" ? "notifications" : e.interactionId === "preference:tab_grouping" ? "tab_grouping" : null;
1890
1890
  h(_ ? f.interactions.deviceErrors[_] : void 0);
1891
1891
  };
@@ -1949,7 +1949,7 @@ function ho(t, e = null) {
1949
1949
  paymentIssue: null,
1950
1950
  pricingUrl: "",
1951
1951
  earnCreditsUrl: ""
1952
- }, i = Pi(t, "send_message"), r = i.reason === "unavailable" && n.submissionGate?.allowed === !1, a = t.refusal ?? (i.allowed ? n.submissionGate ?? { allowed: !0, reason: "allowed", actions: [] } : r ? n.submissionGate : {
1952
+ }, i = Mi(t, "send_message"), r = i.reason === "unavailable" && n.submissionGate?.allowed === !1, a = t.refusal ?? (i.allowed ? n.submissionGate ?? { allowed: !0, reason: "allowed", actions: [] } : r ? n.submissionGate : {
1953
1953
  allowed: !1,
1954
1954
  reason: i.reason === "workspace" ? "workspace_required" : i.reason === "authentication" ? "authentication_required" : i.reason === "unavailable" ? "connection_required" : n.submissionGate?.reason ?? "credits_exhausted",
1955
1955
  actions: n.submissionGate?.actions ?? []
@@ -1960,7 +1960,7 @@ function ho(t, e = null) {
1960
1960
  } : void 0);
1961
1961
  return { ...n, ...o ? { auth: o } : {}, submissionGate: a, usingPaidCreditFallback: e ? t.paidFallbackBySession[e] ?? !1 : !1 };
1962
1962
  }
1963
- const po = "0.1.274", Lt = {
1963
+ const po = "0.1.275", Lt = {
1964
1964
  version: po
1965
1965
  }, ln = (t) => t.selectedModel ?? t.historyModel ?? t.defaultModel, fo = (t, e) => t.scopes[e];
1966
1966
  function Ft(t) {
@@ -1971,14 +1971,14 @@ function Fs(t, e) {
1971
1971
  if (t.removedItems[e.id]) return t;
1972
1972
  const s = fe(e.created_at);
1973
1973
  fe(e.updated_at);
1974
- const n = Pt(e);
1974
+ const n = Mt(e);
1975
1975
  n !== null && Ft(n);
1976
1976
  const i = t.streams[e.id];
1977
1977
  if (n !== null && i && (i.state === "stopped" || i.state === "finished") && n > i.revision) return t;
1978
1978
  const r = t.items[e.id];
1979
1979
  if (r) {
1980
1980
  if (fe(r.created_at) !== s) throw new Error("Display shell timestamp changed.");
1981
- const a = Pt(r);
1981
+ const a = Mt(r);
1982
1982
  if (a !== null && n !== null) {
1983
1983
  if (n <= a) return t;
1984
1984
  } else if (fe(e.updated_at) <= fe(r.updated_at)) return t;
@@ -2004,7 +2004,7 @@ function $s(t, e) {
2004
2004
  function go(t) {
2005
2005
  const e = /* @__PURE__ */ new Set();
2006
2006
  for (const s of Object.values(t.items)) {
2007
- const n = Pt(s), i = t.streams[s.id];
2007
+ const n = Mt(s), i = t.streams[s.id];
2008
2008
  n !== null && (!i || i.state === "open" || n < i.revision) && e.add(s.id);
2009
2009
  }
2010
2010
  for (const s of [...Object.keys(t.streams), ...Object.values(t.removedItems)])
@@ -2049,7 +2049,7 @@ function Hs(t, e) {
2049
2049
  }
2050
2050
  function Vs(t, e, s = !1) {
2051
2051
  if (t.authorityId !== (e.authorityId ?? "") || t.generation !== e.generation) {
2052
- const r = Mi(e.authorityId ?? void 0, e.generation);
2052
+ const r = Pi(e.authorityId ?? void 0, e.generation);
2053
2053
  if (!s || t.authorityId) return r;
2054
2054
  const a = Object.fromEntries(Object.entries(t.submissions).filter(([o, c]) => c.sessionId === null && !c.cancelled && t.deliveries[o]?.acceptance === "unissued" && e.clients[c.clientScopeId] === c.conversationScopeId));
2055
2055
  return {
@@ -2183,11 +2183,11 @@ function mo(t, e, s, n) {
2183
2183
  if (s.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
2184
2184
  const { type: o, authorityId: c, generation: d, prepareContext: l, waitForAuthentication: u, ...h } = e, p = t.submissions[e.userMessageId];
2185
2185
  if (p) {
2186
- const { contextPreparation: S, requestedModel: g, sessionId: b, delivery: v, cancelled: w, cancellationReason: R, error: q, executionVersion: C, ...E } = p;
2186
+ const { contextPreparation: k, requestedModel: g, sessionId: b, delivery: v, cancelled: w, cancellationReason: R, error: q, executionVersion: C, ...E } = p;
2187
2187
  if (ht(E) !== ht(h)) throw new Error("User-message identity cannot be reused with different input.");
2188
2188
  return { state: t, effects: r };
2189
2189
  }
2190
- const m = s.selections[e.conversationScopeId], f = Object.values(t.submissions).find((S) => S.conversationScopeId === e.conversationScopeId && !S.cancelled && S.sessionId !== null), y = n.scopes[e.clientScopeId], I = {
2190
+ const m = s.selections[e.conversationScopeId], f = Object.values(t.submissions).find((k) => k.conversationScopeId === e.conversationScopeId && !k.cancelled && k.sessionId !== null), y = n.scopes[e.clientScopeId], I = {
2191
2191
  ...Y(h),
2192
2192
  ...l ? { contextPreparation: null } : {},
2193
2193
  // Extension staging can await page context after the picker has already changed.
@@ -2468,7 +2468,7 @@ function Gs(t) {
2468
2468
  function vo(t, e, s, n) {
2469
2469
  let i = t, r = e;
2470
2470
  if (e.type === "effect.completed" || e.type === "effect.failed") {
2471
- e.effectKind === "conversation.checkpoint" && e.effectId === t.checkpointEffectId && (i = { ...i, checkpointEffectId: null, checkpointError: e.type === "effect.failed" ? e.error : null });
2471
+ e.effectKind === "conversation.checkpoint" && e.effectId === t.checkpointEffectId && (i = { ...i, checkpointEffectId: null, checkpointError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed" && e.effectKind === "conversation.checkpoint" && e.output && e.output.authorityId === t.authorityId && e.output.generation === t.generation && (i = { ...i, durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...e.output.submissionIds])].filter((h) => !!t.submissions[h]) });
2472
2472
  const l = Object.keys(t.deliveries).find((h) => t.deliveries[h].effectId === e.effectId), u = Object.keys(t.operations).find((h) => t.operations[h].effectId === e.effectId);
2473
2473
  if (l) {
2474
2474
  const h = t.deliveries[l], p = t.submissions[l];
@@ -2493,9 +2493,9 @@ function vo(t, e, s, n) {
2493
2493
  if (f.attachment.id !== y.sourceId || f.attachment.size_bytes !== y.sizeBytes || p.sessionId !== null && p.sessionId !== f.sessionId)
2494
2494
  throw new Error("Upload does not match the captured attachment or conversation.");
2495
2495
  m = { ...m, allocation: "resolved", uploads: [...h.uploads, f.attachment] };
2496
- const I = Object.fromEntries(Object.entries(i.submissions).map(([_, S]) => [
2496
+ const I = Object.fromEntries(Object.entries(i.submissions).map(([_, k]) => [
2497
2497
  _,
2498
- S.conversationScopeId === p.conversationScopeId && (_ === l || !S.cancelled && !p.cancelled) ? { ...S, sessionId: f.sessionId } : S
2498
+ k.conversationScopeId === p.conversationScopeId && (_ === l || !k.cancelled && !p.cancelled) ? { ...k, sessionId: f.sessionId } : k
2499
2499
  ]));
2500
2500
  i = { ...i, submissions: I };
2501
2501
  } else if (e.effectKind === "conversation.receipt")
@@ -2557,36 +2557,37 @@ function vo(t, e, s, n) {
2557
2557
  l,
2558
2558
  !u.cancelled && u.delivery === "failed" && ["unauthorized", "401", "auth_reconnecting"].includes(u.error?.code ?? "") ? { ...u, error: { code: "message_delivery_failed", message: "Pluno is connected. Retry this message to send it.", retryable: !0 } } : u
2559
2559
  ])) }), e.type === "conversation.restore_delivery") {
2560
- const l = Y(e.checkpoint), u = t.submissionOrder.every((S) => t.deliveries[S]?.acceptance === "unissued" && t.submissions[S].delivery === "failed" && ["unauthorized", "auth_reconnecting"].includes(t.submissions[S].error?.code ?? ""));
2560
+ const l = Y(e.checkpoint), u = t.submissionOrder.every((k) => t.deliveries[k]?.acceptance === "unissued" && t.submissions[k].delivery === "failed" && ["unauthorized", "auth_reconnecting"].includes(t.submissions[k].error?.code ?? ""));
2561
2561
  if (l.schema !== 1 || l.authorityId !== t.authorityId || !u || Object.keys(t.operations).length)
2562
2562
  throw new Error("Delivery restoration requires an empty engine with the same authenticated authority.");
2563
2563
  const h = { ...t.submissions, ...l.submissions };
2564
- for (const [S, g] of Object.entries(t.submissions))
2565
- g.cancelled && (h[S] = { ...h[S], cancelled: !0, cancellationReason: g.cancellationReason });
2564
+ for (const [k, g] of Object.entries(t.submissions))
2565
+ g.cancelled && (h[k] = { ...h[k], cancelled: !0, cancellationReason: g.cancellationReason });
2566
2566
  const p = {
2567
2567
  ...l,
2568
2568
  submissions: h,
2569
2569
  stops: { ...l.stops, ...t.stops },
2570
2570
  deliveries: { ...t.deliveries, ...l.deliveries },
2571
2571
  submissionOrder: [.../* @__PURE__ */ new Set([...l.submissionOrder, ...t.submissionOrder])]
2572
- }, { schema: m, authorityId: f, ...y } = p, I = Y(e.pendingRestoration ?? {}), _ = (S) => !s.clients[S.clientScopeId] && I[S.clientScopeId] === S.conversationScopeId;
2572
+ }, { schema: m, authorityId: f, ...y } = p, I = Y(e.pendingRestoration ?? {}), _ = (k) => !s.clients[k.clientScopeId] && I[k.clientScopeId] === k.conversationScopeId;
2573
2573
  i = {
2574
2574
  ...t,
2575
2575
  ...y,
2576
+ durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...Object.keys(l.submissions)])],
2576
2577
  pendingRestoration: I,
2577
2578
  requestSequence: Math.max(t.requestSequence, p.requestSequence),
2578
2579
  effectsEnabled: !0,
2579
- submissions: Object.fromEntries(Object.entries(p.submissions).map(([S, g]) => [S, {
2580
+ submissions: Object.fromEntries(Object.entries(p.submissions).map(([k, g]) => [k, {
2580
2581
  ...g,
2581
2582
  executionVersion: null,
2582
2583
  cancelled: g.cancelled || !_(g) && !Hs(g, s),
2583
2584
  ...!g.cancelled && !_(g) && !Hs(g, s) ? { cancellationReason: "owner_lost" } : {},
2584
- delivery: (g.contextPreparation === null || !p.deliveries[S]) && !g.cancelled && g.delivery !== "accepted" ? "failed" : g.delivery === "sending" ? "uncertain" : g.delivery,
2585
- error: g.contextPreparation === null && !g.cancelled && !["unauthorized", "auth_reconnecting"].includes(g.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !p.deliveries[S] && g.delivery !== "accepted" && !g.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : g.error
2585
+ delivery: (g.contextPreparation === null || !p.deliveries[k]) && !g.cancelled && g.delivery !== "accepted" ? "failed" : g.delivery === "sending" ? "uncertain" : g.delivery,
2586
+ error: g.contextPreparation === null && !g.cancelled && !["unauthorized", "auth_reconnecting"].includes(g.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !p.deliveries[k] && g.delivery !== "accepted" && !g.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : g.error
2586
2587
  }])),
2587
- deliveries: Object.fromEntries(Object.entries(p.submissions).map(([S, g], b) => {
2588
- const v = p.deliveries[S], w = g.contextPreparation === null, R = g.delivery === "accepted" ? "accepted" : v?.acceptance ?? (v && (v.step === "send" || v.step === "receipt") ? "uncertain" : "unissued");
2589
- return [S, {
2588
+ deliveries: Object.fromEntries(Object.entries(p.submissions).map(([k, g], b) => {
2589
+ const v = p.deliveries[k], w = g.contextPreparation === null, R = g.delivery === "accepted" ? "accepted" : v?.acceptance ?? (v && (v.step === "send" || v.step === "receipt") ? "uncertain" : "unissued");
2590
+ return [k, {
2590
2591
  ...zn(g, b),
2591
2592
  ...v,
2592
2593
  acceptance: R,
@@ -2599,7 +2600,7 @@ function vo(t, e, s, n) {
2599
2600
  phase: R === "accepted" ? "done" : w || !v ? "failed" : ["running", "waiting"].includes(v.phase) ? "uncertain" : v.phase
2600
2601
  }];
2601
2602
  })),
2602
- operations: Object.fromEntries(Object.entries(p.operations).map(([S, g]) => [S, {
2603
+ operations: Object.fromEntries(Object.entries(p.operations).map(([k, g]) => [k, {
2603
2604
  ...g,
2604
2605
  effectId: null,
2605
2606
  phase: ["running", "waiting"].includes(g.phase) ? "uncertain" : g.phase
@@ -3060,14 +3061,14 @@ function xo(t, e = Math.random, s = Math.random) {
3060
3061
  "activeUsers.wait": ({ milliseconds: i }) => new Promise((r) => setTimeout(() => r(null), i + Math.round((e() - 0.5) * 1e3)))
3061
3062
  };
3062
3063
  }
3063
- async function Po(t, e = fetch) {
3064
+ async function Mo(t, e = fetch) {
3064
3065
  const s = await e(new URL("/api/product-agent/embed/active-users", t), { cache: "no-store", credentials: "omit" });
3065
3066
  if (!s.ok) throw new Error(`Active users request failed (${s.status})`);
3066
3067
  const n = await s.json();
3067
3068
  if (typeof n.count != "number" || !Number.isFinite(n.count) || n.count < 0) throw new Error("Invalid active users count");
3068
3069
  return Math.round(n.count);
3069
3070
  }
3070
- function Mo(t) {
3071
+ function Po(t) {
3071
3072
  const e = {
3072
3073
  sidepanel: "extension_sidepanel",
3073
3074
  browser_extension_page_ui: "extension_widget",
@@ -3290,7 +3291,7 @@ function No(t) {
3290
3291
  clearTimeout(u), m(), f();
3291
3292
  });
3292
3293
  },
3293
- "conversation.checkpoint": async (o) => (ee(t, o), await s(o.checkpoint, t.saveCancellation(o.checkpoint)).catch((c) => n(c, { operation: "conversation.checkpoint" })), ee(t, o), null),
3294
+ "conversation.checkpoint": async (o) => (ee(t, o), await s(o.checkpoint, t.saveCancellation(o.checkpoint)).catch((c) => n(c, { operation: "conversation.checkpoint" })), ee(t, o), { ...t.authority, submissionIds: Object.keys(o.checkpoint.submissions) }),
3294
3295
  "conversation.receipt": (o) => Q(t.onTiming, {
3295
3296
  operation: "send",
3296
3297
  layer: "http",
@@ -3443,9 +3444,9 @@ function No(t) {
3443
3444
  ownerId: c.engine.getDiagnostics().ownerId,
3444
3445
  authorityGeneration: o.generation
3445
3446
  } }
3446
- ).catch((S) => {
3447
- if (p.length === 0) throw S;
3448
- const g = ke(S);
3447
+ ).catch((k) => {
3448
+ if (p.length === 0) throw k;
3449
+ const g = ke(k);
3449
3450
  throw Object.assign(g, { details: { ...g.details, successfulRequests: p.length } });
3450
3451
  });
3451
3452
  if (ee(t, o), _.conversation_id !== o.sessionId) throw new Error("Snapshot conversation identity mismatch.");
@@ -3726,7 +3727,7 @@ function ds(t, e, s, n) {
3726
3727
  loading: !1,
3727
3728
  ...typeof w.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: w.error.details.securitySettingsUrl } : {}
3728
3729
  }] : [v];
3729
- }), y = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, I = y ? null : e?.error ?? null, _ = l?.delivery === "failed" && !l.cancelled && !p ? l.error : I, S = {
3730
+ }), y = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, I = y ? null : e?.error ?? null, _ = l?.delivery === "failed" && !l.cancelled && !p ? l.error : I, k = {
3730
3731
  isRetrying: t.isRetrying ?? !1,
3731
3732
  historyRefreshFailure: _ === e?.error ? t.historyRefreshFailure ?? null : null,
3732
3733
  conversationDiagnostics: {
@@ -3767,7 +3768,7 @@ function ds(t, e, s, n) {
3767
3768
  lastErrorCode: _?.code ?? null,
3768
3769
  lastErrorSecuritySettingsUrl: typeof _?.details?.securitySettingsUrl == "string" ? _.details.securitySettingsUrl : null
3769
3770
  };
3770
- let g = S;
3771
+ let g = k;
3771
3772
  for (const v of t.optimistic.filter((w) => w.cancelled && !t.stop?.userMessageIds.includes(w.userMessageId))) {
3772
3773
  const w = Js(g, "", "stopped", [v.userMessageId], Jn(v.cancellationReason));
3773
3774
  g = { ...g, messages: w.messages, segments: w.segments };
@@ -3780,7 +3781,7 @@ function ds(t, e, s, n) {
3780
3781
  t.stop.userMessageIds,
3781
3782
  Jn(t.stop.reason ?? "user_requested")
3782
3783
  );
3783
- return { ...S, messages: b.messages, segments: b.segments };
3784
+ return { ...k, messages: b.messages, segments: b.segments };
3784
3785
  }
3785
3786
  function Jn(t) {
3786
3787
  switch (t) {
@@ -5135,7 +5136,7 @@ function qt(t, e, s) {
5135
5136
  }
5136
5137
  return t;
5137
5138
  }
5138
- function Pa(t, e) {
5139
+ function Ma(t, e) {
5139
5140
  return t.data = Zs(t.data, e), delete t.attachments, t;
5140
5141
  }
5141
5142
  function Zs(t, e) {
@@ -5153,7 +5154,7 @@ function Zs(t, e) {
5153
5154
  Object.prototype.hasOwnProperty.call(t, s) && (t[s] = Zs(t[s], e));
5154
5155
  return t;
5155
5156
  }
5156
- const Ma = [
5157
+ const Pa = [
5157
5158
  "connect",
5158
5159
  // used on the client side
5159
5160
  "connect_error",
@@ -5167,10 +5168,10 @@ const Ma = [
5167
5168
  "removeListener"
5168
5169
  // used by the Node.js EventEmitter
5169
5170
  ];
5170
- var P;
5171
+ var M;
5171
5172
  (function(t) {
5172
5173
  t[t.CONNECT = 0] = "CONNECT", t[t.DISCONNECT = 1] = "DISCONNECT", t[t.EVENT = 2] = "EVENT", t[t.ACK = 3] = "ACK", t[t.CONNECT_ERROR = 4] = "CONNECT_ERROR", t[t.BINARY_EVENT = 5] = "BINARY_EVENT", t[t.BINARY_ACK = 6] = "BINARY_ACK";
5173
- })(P || (P = {}));
5174
+ })(M || (M = {}));
5174
5175
  class Da {
5175
5176
  /**
5176
5177
  * Encoder constructor
@@ -5187,8 +5188,8 @@ class Da {
5187
5188
  * @param {Object} obj - packet object
5188
5189
  */
5189
5190
  encode(e) {
5190
- return (e.type === P.EVENT || e.type === P.ACK) && Et(e) ? this.encodeAsBinary({
5191
- type: e.type === P.EVENT ? P.BINARY_EVENT : P.BINARY_ACK,
5191
+ return (e.type === M.EVENT || e.type === M.ACK) && Et(e) ? this.encodeAsBinary({
5192
+ type: e.type === M.EVENT ? M.BINARY_EVENT : M.BINARY_ACK,
5192
5193
  nsp: e.nsp,
5193
5194
  data: e.data,
5194
5195
  id: e.id
@@ -5199,7 +5200,7 @@ class Da {
5199
5200
  */
5200
5201
  encodeAsString(e) {
5201
5202
  let s = "" + e.type;
5202
- return (e.type === P.BINARY_EVENT || e.type === P.BINARY_ACK) && (s += e.attachments + "-"), e.nsp && e.nsp !== "/" && (s += e.nsp + ","), e.id != null && (s += e.id), e.data != null && (s += JSON.stringify(e.data, this.replacer)), s;
5203
+ return (e.type === M.BINARY_EVENT || e.type === M.BINARY_ACK) && (s += e.attachments + "-"), e.nsp && e.nsp !== "/" && (s += e.nsp + ","), e.id != null && (s += e.id), e.data != null && (s += JSON.stringify(e.data, this.replacer)), s;
5203
5204
  }
5204
5205
  /**
5205
5206
  * Encode packet as 'buffer sequence' by removing blobs, and
@@ -5232,8 +5233,8 @@ class In extends F {
5232
5233
  if (this.reconstructor)
5233
5234
  throw new Error("got plaintext data when reconstructing a packet");
5234
5235
  s = this.decodeString(e);
5235
- const n = s.type === P.BINARY_EVENT;
5236
- n || s.type === P.BINARY_ACK ? (s.type = n ? P.EVENT : P.ACK, this.reconstructor = new Ua(s)) : super.emitReserved("decoded", s);
5236
+ const n = s.type === M.BINARY_EVENT;
5237
+ n || s.type === M.BINARY_ACK ? (s.type = n ? M.EVENT : M.ACK, this.reconstructor = new Ua(s)) : super.emitReserved("decoded", s);
5237
5238
  } else if (bn(e) || e.base64)
5238
5239
  if (this.reconstructor)
5239
5240
  s = this.reconstructor.takeBinaryData(e), s && (this.reconstructor = null, super.emitReserved("decoded", s));
@@ -5253,9 +5254,9 @@ class In extends F {
5253
5254
  const n = {
5254
5255
  type: Number(e.charAt(0))
5255
5256
  };
5256
- if (P[n.type] === void 0)
5257
+ if (M[n.type] === void 0)
5257
5258
  throw new Error("unknown packet type " + n.type);
5258
- if (n.type === P.BINARY_EVENT || n.type === P.BINARY_ACK) {
5259
+ if (n.type === M.BINARY_EVENT || n.type === M.BINARY_ACK) {
5259
5260
  const r = s + 1;
5260
5261
  for (; e.charAt(++s) !== "-" && s != e.length; )
5261
5262
  ;
@@ -5308,17 +5309,17 @@ class In extends F {
5308
5309
  }
5309
5310
  static isPayloadValid(e, s) {
5310
5311
  switch (e) {
5311
- case P.CONNECT:
5312
+ case M.CONNECT:
5312
5313
  return ti(s);
5313
- case P.DISCONNECT:
5314
+ case M.DISCONNECT:
5314
5315
  return s === void 0;
5315
- case P.CONNECT_ERROR:
5316
+ case M.CONNECT_ERROR:
5316
5317
  return typeof s == "string" || ti(s);
5317
- case P.EVENT:
5318
- case P.BINARY_EVENT:
5319
- return Array.isArray(s) && (typeof s[0] == "number" || typeof s[0] == "string" && Ma.indexOf(s[0]) === -1);
5320
- case P.ACK:
5321
- case P.BINARY_ACK:
5318
+ case M.EVENT:
5319
+ case M.BINARY_EVENT:
5320
+ return Array.isArray(s) && (typeof s[0] == "number" || typeof s[0] == "string" && Pa.indexOf(s[0]) === -1);
5321
+ case M.ACK:
5322
+ case M.BINARY_ACK:
5322
5323
  return Array.isArray(s);
5323
5324
  }
5324
5325
  }
@@ -5343,7 +5344,7 @@ class Ua {
5343
5344
  */
5344
5345
  takeBinaryData(e) {
5345
5346
  if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
5346
- const s = Pa(this.reconPack, this.buffers);
5347
+ const s = Ma(this.reconPack, this.buffers);
5347
5348
  return this.finishedReconstruction(), s;
5348
5349
  }
5349
5350
  return null;
@@ -5366,7 +5367,7 @@ const ja = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5366
5367
  Decoder: In,
5367
5368
  Encoder: Da,
5368
5369
  get PacketType() {
5369
- return P;
5370
+ return M;
5370
5371
  }
5371
5372
  }, Symbol.toStringTag, { value: "Module" }));
5372
5373
  function ce(t, e, s) {
@@ -5504,7 +5505,7 @@ class ar extends F {
5504
5505
  if (s.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
5505
5506
  return this._addToQueue(s), this;
5506
5507
  const a = {
5507
- type: P.EVENT,
5508
+ type: M.EVENT,
5508
5509
  data: s
5509
5510
  };
5510
5511
  if (a.options = {}, a.options.compress = this.flags.compress !== !1, typeof s[s.length - 1] == "function") {
@@ -5612,7 +5613,7 @@ class ar extends F {
5612
5613
  */
5613
5614
  _sendConnectPacket(e) {
5614
5615
  this.packet({
5615
- type: P.CONNECT,
5616
+ type: M.CONNECT,
5616
5617
  data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, e) : e
5617
5618
  });
5618
5619
  }
@@ -5658,21 +5659,21 @@ class ar extends F {
5658
5659
  onpacket(e) {
5659
5660
  if (e.nsp === this.nsp)
5660
5661
  switch (e.type) {
5661
- case P.CONNECT:
5662
+ case M.CONNECT:
5662
5663
  e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
5663
5664
  break;
5664
- case P.EVENT:
5665
- case P.BINARY_EVENT:
5665
+ case M.EVENT:
5666
+ case M.BINARY_EVENT:
5666
5667
  this.onevent(e);
5667
5668
  break;
5668
- case P.ACK:
5669
- case P.BINARY_ACK:
5669
+ case M.ACK:
5670
+ case M.BINARY_ACK:
5670
5671
  this.onack(e);
5671
5672
  break;
5672
- case P.DISCONNECT:
5673
+ case M.DISCONNECT:
5673
5674
  this.ondisconnect();
5674
5675
  break;
5675
- case P.CONNECT_ERROR:
5676
+ case M.CONNECT_ERROR:
5676
5677
  this.destroy();
5677
5678
  const n = new Error(e.data.message);
5678
5679
  n.data = e.data.data, this.emitReserved("connect_error", n);
@@ -5707,7 +5708,7 @@ class ar extends F {
5707
5708
  let n = !1;
5708
5709
  return function(...i) {
5709
5710
  n || (n = !0, s.packet({
5710
- type: P.ACK,
5711
+ type: M.ACK,
5711
5712
  id: e,
5712
5713
  data: i
5713
5714
  }));
@@ -5776,7 +5777,7 @@ class ar extends F {
5776
5777
  * @return self
5777
5778
  */
5778
5779
  disconnect() {
5779
- return this.connected && this.packet({ type: P.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
5780
+ return this.connected && this.packet({ type: M.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
5780
5781
  }
5781
5782
  /**
5782
5783
  * Alias for {@link disconnect()}.
@@ -6676,7 +6677,7 @@ class cr {
6676
6677
  h.signal.aborted || (p.trigger = E, h.abort());
6677
6678
  }, f = () => m("transport_disposed"), y = () => m(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
6678
6679
  this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", y, { once: !0 });
6679
- const I = r === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && i === "POST", _ = /^\/conversations(?:\/[^/]+)?$/.test(e) && (i ?? (n === void 0 ? "GET" : "POST")) === "GET", S = setTimeout(() => m("deadline"), _ ? 6e4 : I ? 3e4 : 15e3), g = za(), b = Date.now();
6680
+ const I = r === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && i === "POST", _ = /^\/conversations(?:\/[^/]+)?$/.test(e) && (i ?? (n === void 0 ? "GET" : "POST")) === "GET", k = setTimeout(() => m("deadline"), _ ? 6e4 : I ? 3e4 : 15e3), g = za(), b = Date.now();
6680
6681
  let v = null, w = !1, R = null, q = null, C = null;
6681
6682
  try {
6682
6683
  const E = await Promise.resolve(fetch(l, {
@@ -6703,7 +6704,7 @@ class cr {
6703
6704
  ...typeof O.blockedOrigin == "string" ? { blockedOrigin: O.blockedOrigin } : {},
6704
6705
  ...typeof O.securitySettingsUrl == "string" ? { securitySettingsUrl: O.securitySettingsUrl } : {}
6705
6706
  }, r === "conversations" && e === "/commands");
6706
- const k = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, x = E.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(k) ? { requestId: g, authTransport: "http", authEndpoint: `${r ?? (d ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: k, retryable: k === "token_expired" && (O === "Token expired" || O.retryable === !0) } : void 0;
6707
+ const S = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, x = E.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(S) ? { requestId: g, authTransport: "http", authEndpoint: `${r ?? (d ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: S, retryable: S === "token_expired" && (O === "Token expired" || O.retryable === !0) } : void 0;
6707
6708
  throw new A(E.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : E.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${E.status})`, T, !1, x);
6708
6709
  }
6709
6710
  return await E.json();
@@ -6730,24 +6731,24 @@ class cr {
6730
6731
  };
6731
6732
  he(O) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(O) : console.warn("Product Agent HTTP request failed", O)).catch(() => {
6732
6733
  });
6733
- const k = he(O) ? { httpRequest: O } : void 0;
6734
+ const S = he(O) ? { httpRequest: O } : void 0;
6734
6735
  if (T !== null) {
6735
6736
  const x = T !== "deadline" && T !== "unexpected_abort";
6736
6737
  throw new A(
6737
6738
  x ? "The request was cancelled." : T === "deadline" ? "The request timed out. Please try again." : "The connection was interrupted. Please try again.",
6738
6739
  x ? "request_cancelled" : T === "deadline" ? "request_timed_out" : "connection_interrupted",
6739
6740
  !0,
6740
- k
6741
+ S
6741
6742
  );
6742
6743
  }
6743
- throw E instanceof A && k ? new A(E.message, E.code, E.outcomeUnknown, { ...E.detail, ...k }, E.backendRefusal) : k ? new A(
6744
+ throw E instanceof A && S ? new A(E.message, E.code, E.outcomeUnknown, { ...E.detail, ...S }, E.backendRefusal) : S ? new A(
6744
6745
  w ? "The connection was interrupted. Please try again." : I ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
6745
6746
  "connection_interrupted",
6746
6747
  !0,
6747
- k
6748
+ S
6748
6749
  ) : E;
6749
6750
  } finally {
6750
- clearTimeout(S), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", y);
6751
+ clearTimeout(k), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", y);
6751
6752
  }
6752
6753
  }
6753
6754
  }
@@ -8258,7 +8259,7 @@ class mc {
8258
8259
  interactions: G(js()),
8259
8260
  modelSelection: ic(),
8260
8261
  directory: dr(),
8261
- conversation: Mi(),
8262
+ conversation: Pi(),
8262
8263
  activeUsers: hr()
8263
8264
  }) }),
8264
8265
  reducer: (r, a) => {
@@ -8283,14 +8284,14 @@ class mc {
8283
8284
  if (pc(o)) {
8284
8285
  const d = vo(r.slices.conversation, o, r.slices.directory, r.slices.modelSelection);
8285
8286
  let l = r.slices.directory;
8286
- for (const [_, S] of Object.entries(d.state.operations)) {
8287
- if (!["runtime.warmup", "attachment.prepare"].includes(S.command.type) || !S.conversationScopeId || S.phase !== "done" || r.slices.conversation.operations[_]?.phase === "done") continue;
8288
- const g = S.result, b = l.selections[S.conversationScopeId];
8289
- g?.sessionId && b?.provisionalId && b.sessionId === null && Object.values(l.clients).includes(S.conversationScopeId) && (l = Te(l, {
8287
+ for (const [_, k] of Object.entries(d.state.operations)) {
8288
+ if (!["runtime.warmup", "attachment.prepare"].includes(k.command.type) || !k.conversationScopeId || k.phase !== "done" || r.slices.conversation.operations[_]?.phase === "done") continue;
8289
+ const g = k.result, b = l.selections[k.conversationScopeId];
8290
+ g?.sessionId && b?.provisionalId && b.sessionId === null && Object.values(l.clients).includes(k.conversationScopeId) && (l = Te(l, {
8290
8291
  authorityId: d.state.authorityId,
8291
8292
  generation: d.state.generation,
8292
8293
  type: "directory.accepted",
8293
- conversationScopeId: S.conversationScopeId,
8294
+ conversationScopeId: k.conversationScopeId,
8294
8295
  provisionalId: b.provisionalId,
8295
8296
  sessionId: g.sessionId
8296
8297
  }).state);
@@ -8589,13 +8590,13 @@ function xc() {
8589
8590
  }
8590
8591
  function yr() {
8591
8592
  return {
8592
- storage: Pc(),
8593
- channel: Mc(),
8593
+ storage: Mc(),
8594
+ channel: Pc(),
8594
8595
  randomUUID: () => crypto.randomUUID(),
8595
8596
  settle: () => new Promise((t) => Tc(t, qc))
8596
8597
  };
8597
8598
  }
8598
- function Pc() {
8599
+ function Mc() {
8599
8600
  return {
8600
8601
  getItem: (t) => {
8601
8602
  try {
@@ -8613,7 +8614,7 @@ function Pc() {
8613
8614
  }
8614
8615
  };
8615
8616
  }
8616
- function Mc() {
8617
+ function Pc() {
8617
8618
  if (typeof BroadcastChannel < "u") {
8618
8619
  const t = new BroadcastChannel(Ec);
8619
8620
  return {
@@ -9260,7 +9261,7 @@ class cu {
9260
9261
  const a = this.getState();
9261
9262
  (a.user?.id !== e.user?.id || a.selectionKey !== void 0 && a.selectionKey !== e.selectionKey || a.selectionKey === void 0 && a.sessionId !== null && a.sessionId !== e.sessionId) && (this.cancelPendingSubmissions(), this.submissionPreviews.clear());
9262
9263
  for (const o of e.messages)
9263
- o.role === "user" && this.submissionPreviews.delete(o.id);
9264
+ o.role === "user" && e.receipts?.find((c) => c.userMessageId === o.id)?.durable !== !1 && this.submissionPreviews.delete(o.id);
9264
9265
  this.state = _s(e);
9265
9266
  for (const [o, c] of this.stopPreviews) {
9266
9267
  const d = e.activity?.executionKey;
@@ -9728,7 +9729,7 @@ function Ss(t) {
9728
9729
  }
9729
9730
  return { ...e, ...Oo(t) };
9730
9731
  }
9731
- function Pe(t, e, s) {
9732
+ function Me(t, e, s) {
9732
9733
  if (typeof window > "u")
9733
9734
  return;
9734
9735
  const n = window.__PLUNO_PRODUCT_AGENT_TRACE_ID__;
@@ -9831,7 +9832,7 @@ class Kt {
9831
9832
  onError: (i) => this.handleDirectoryTransportError(i)
9832
9833
  }), void 0, xo(async () => {
9833
9834
  if (!this.token || !this.state.user || this.state.status === "closed") throw new Error("Product Agent is not authenticated");
9834
- return this.options.activeUsersLoader ? (await this.options.activeUsersLoader()).count : Po(this.options.backendUrl);
9835
+ return this.options.activeUsersLoader ? (await this.options.activeUsersLoader()).count : Mo(this.options.backendUrl);
9835
9836
  })), this.modelClientScopeId = Bc(e.clientId, () => crypto.randomUUID()), this.directoryConversationScopeId = `conversation:${this.modelClientScopeId}`, this.createDirectoryAdapters(), this.clientRuntime.engine.dispatch({
9836
9837
  type: "model.scope_open",
9837
9838
  clientScopeId: this.modelClientScopeId,
@@ -9963,7 +9964,7 @@ class Kt {
9963
9964
  backendUrl: Nd(e.backendUrl ?? nd),
9964
9965
  clientId: e.clientId ?? tl(),
9965
9966
  productVariant: e.productVariant ?? "customer_embedded",
9966
- entrySurface: Mo(e.entrySurface)
9967
+ entrySurface: Po(e.entrySurface)
9967
9968
  }, n);
9968
9969
  try {
9969
9970
  await i.initializeDirectory(), await i.initializeConversation(), wc().catch((r) => {
@@ -10042,10 +10043,10 @@ class Kt {
10042
10043
  requestId: f.requestId,
10043
10044
  clientMessageId: f.userMessageId,
10044
10045
  sessionId: f.sessionId
10045
- }), S = (b, v) => _.measure(b, () => bt(I, v));
10046
+ }), k = (b, v) => _.measure(b, () => bt(I, v));
10046
10047
  let g = f.contextPreparation ?? { pageContent: "", sessionTabs: [] };
10047
10048
  if (f.contextPreparation === null) {
10048
- await S("first_frame", () => new Promise((v) => {
10049
+ await k("first_frame", () => new Promise((v) => {
10049
10050
  if (document.visibilityState !== "visible") {
10050
10051
  setTimeout(v, 0);
10051
10052
  return;
@@ -10059,9 +10060,9 @@ class Kt {
10059
10060
  }));
10060
10061
  const b = f.context.page;
10061
10062
  if (ae().url !== b.url) throw Object.assign(new Error("The page changed before preparation completed. Send this message again."), { code: "context_preparation_interrupted", retryable: !1 });
10062
- g = { pageContent: await S("page_capture", async () => An()), sessionTabs: [] };
10063
+ g = { pageContent: await k("page_capture", async () => An()), sessionTabs: [] };
10063
10064
  }
10064
- if (await S("authentication", () => this.waitForAuthentication()), !n() || s !== this.directoryAuthority || this.clientRuntime.isDisposed) throw new Error("Submission authority was retired.");
10065
+ if (await k("authentication", () => this.waitForAuthentication()), !n() || s !== this.directoryAuthority || this.clientRuntime.isDisposed) throw new Error("Submission authority was retired.");
10065
10066
  for (const b of y)
10066
10067
  if (!b.uploaded && (await bt(I, () => (this.attachmentPersistence.get(b.sourceId) ?? Promise.resolve()).catch(() => {
10067
10068
  throw Object.assign(new Error("Attachment files could not be stored. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
@@ -10097,7 +10098,7 @@ class Kt {
10097
10098
  onTiming: (f) => {
10098
10099
  n() && this.reportOperationTiming(f);
10099
10100
  },
10100
- onCommand: (f) => Pe("client_event", f.type, Ss({ ...f.payload, type: f.type })),
10101
+ onCommand: (f) => Me("client_event", f.type, Ss({ ...f.payload, type: f.type })),
10101
10102
  onError: (f, y) => {
10102
10103
  if (this.options.productVariant === "customer_embedded" && y.operation === "conversation.snapshot" && f instanceof A && f.code === "conversation_access_denied") {
10103
10104
  y.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
@@ -10110,9 +10111,9 @@ class Kt {
10110
10111
  const c = this.clientRuntime.engine.getState().slices.conversation, d = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null : cs(i);
10111
10112
  if (this.authenticatedUserId && !c.submissionOrder.length && !Object.keys(c.operations).length) {
10112
10113
  const f = this.queuedClientEvents.filter((_) => _.type === "chat.user_message"), y = d ? JSON.parse(d) : f.length ? Do(c, f.map((_) => {
10113
- const { type: S, ...g } = _, b = this.clientRuntime.engine.getState().slices.directory, v = b.clients[this.modelClientScopeId];
10114
+ const { type: k, ...g } = _, b = this.clientRuntime.engine.getState().slices.directory, v = b.clients[this.modelClientScopeId];
10114
10115
  return {
10115
- command: { type: S, request_id: _.clientMessageId, payload: JSON.parse(JSON.stringify(g)) },
10116
+ command: { type: k, request_id: _.clientMessageId, payload: JSON.parse(JSON.stringify(g)) },
10116
10117
  requestedModel: _.model ?? null,
10117
10118
  clientScopeId: this.modelClientScopeId,
10118
10119
  conversationScopeId: v,
@@ -10161,8 +10162,8 @@ class Kt {
10161
10162
  for (const I of f)
10162
10163
  if (I.content.trim() && (I.role === "assistant" || I.dataType === "commentary_history" || I.dataType === "tool_summary")) {
10163
10164
  const _ = y ? this.clientRuntime.engine.getState().slices.conversation.sessions[y] : void 0;
10164
- for (const S of I.respondsToUserMessageId ? Hr(_, I.respondsToUserMessageId) : [])
10165
- this.clearFirstResponseTimer(S, !0, y);
10165
+ for (const k of I.respondsToUserMessageId ? Hr(_, I.respondsToUserMessageId) : [])
10166
+ this.clearFirstResponseTimer(k, !0, y);
10166
10167
  }
10167
10168
  }
10168
10169
  };
@@ -10172,34 +10173,34 @@ class Kt {
10172
10173
  h = f.conversation, ko(y, f.conversation, this.operationTimingReporter, "sdk");
10173
10174
  const I = m !== f.directory.clients[this.modelClientScopeId];
10174
10175
  m = f.directory.clients[this.modelClientScopeId], p !== f.directory.selections && (p = f.directory.selections, this.directoryScope.persist());
10175
- for (const S of Object.values(f.conversation.submissions)) {
10176
- if (S.delivery === "accepted" && y.submissions[S.userMessageId]?.delivery !== "accepted") {
10177
- const g = this.firstResponseTimersByClientMessageId.get(S.userMessageId);
10178
- g && (g.sessionId = S.sessionId), this.emit("ack", { clientMessageId: S.userMessageId, sessionId: S.sessionId });
10179
- const b = S.sessionId;
10176
+ for (const k of Object.values(f.conversation.submissions)) {
10177
+ if (k.delivery === "accepted" && y.submissions[k.userMessageId]?.delivery !== "accepted") {
10178
+ const g = this.firstResponseTimersByClientMessageId.get(k.userMessageId);
10179
+ g && (g.sessionId = k.sessionId), this.emit("ack", { clientMessageId: k.userMessageId, sessionId: k.sessionId });
10180
+ const b = k.sessionId;
10180
10181
  b && this.getState().sessionId === b && this.directoryHttp.request(`/sessions/${encodeURIComponent(b)}/history`, { limit: 200 }).then((v) => {
10181
10182
  n() && this.getState().sessionId === b && this.state.status !== "closed" && Is(this.clientRuntime, this.modelClientScopeId, b, v.turns);
10182
10183
  }).catch((v) => {
10183
10184
  n() && this.getState().sessionId === b && this.handleDirectoryTransportError(v);
10184
10185
  });
10185
10186
  }
10186
- (S.cancelled || S.delivery === "failed") && this.clearFirstResponseTimer(S.userMessageId);
10187
+ (k.cancelled || k.delivery === "failed") && this.clearFirstResponseTimer(k.userMessageId);
10187
10188
  }
10188
- for (const [S, g] of Object.entries(f.directory.clients)) {
10189
- if (!S.startsWith(`background:${this.modelClientScopeId}:`)) continue;
10189
+ for (const [k, g] of Object.entries(f.directory.clients)) {
10190
+ if (!k.startsWith(`background:${this.modelClientScopeId}:`)) continue;
10190
10191
  const b = Ie(f.conversation, f.directory, g), v = b.sessionId ? f.conversation.sessions[b.sessionId] : void 0;
10191
10192
  if (this.firstResponseTimersByClientMessageId.size && (l(ds(b, v?.queries.current, this.options.backendUrl).messages, b.sessionId), ["failed", "stopped"].includes(b.activity.phase)))
10192
10193
  for (const R of le(v?.execution)) this.clearFirstResponseTimer(R);
10193
10194
  const w = b.activity.phase === "completed" && le(v?.execution).some((R) => this.firstResponseTimersByClientMessageId.has(R));
10194
- (I && b.sessionId === this.getState().sessionId || !w && ["completed", "failed", "stopped"].includes(b.activity.phase)) && this.directoryScope.detach(S);
10195
+ (I && b.sessionId === this.getState().sessionId || !w && ["completed", "failed", "stopped"].includes(b.activity.phase)) && this.directoryScope.detach(k);
10195
10196
  }
10196
10197
  const _ = this.getState();
10197
10198
  l(_.messages, _.sessionId);
10198
- for (const S of _.messages) {
10199
- const g = u.get(S.id);
10200
- (!g || g.content !== S.content || g.loading !== S.loading) && this.emit("message", S), S.content.trim() && S.content !== g?.content && (S.role === "assistant" || S.dataType === "commentary_history") && S.content.startsWith(g?.content ?? "") && this.emit("delta", S.content.slice(g?.content.length ?? 0));
10199
+ for (const k of _.messages) {
10200
+ const g = u.get(k.id);
10201
+ (!g || g.content !== k.content || g.loading !== k.loading) && this.emit("message", k), k.content.trim() && k.content !== g?.content && (k.role === "assistant" || k.dataType === "commentary_history") && k.content.startsWith(g?.content ?? "") && this.emit("delta", k.content.slice(g?.content.length ?? 0));
10201
10202
  }
10202
- u = new Map(_.messages.map((S) => [S.id, S])), this.rebuildRuntimeInteractions(), this.emit("state", _);
10203
+ u = new Map(_.messages.map((k) => [k.id, k])), this.rebuildRuntimeInteractions(), this.emit("state", _);
10203
10204
  }), this.conversationObservation.wake();
10204
10205
  }
10205
10206
  async initializeDirectory() {
@@ -10259,7 +10260,7 @@ class Kt {
10259
10260
  n.sessionId ? e.conversation.sessions[n.sessionId]?.queries.current : void 0,
10260
10261
  this.options.backendUrl,
10261
10262
  this.clientRuntime.engine.getDiagnostics({ clientScopeId: this.modelClientScopeId, scopeId: s, sessionId: n.sessionId })
10262
- ), r = { clientScopeId: this.modelClientScopeId, origin: location.origin, pageUrl: location.href }, a = this.options.productVariant === "personal" ? { kind: "userSuggestedTasks" } : { kind: "starterPrompts", ...r, includeUserSuggestions: !1 }, o = Mt(e, a), c = Mt(e, { kind: "appearance", ...r }), d = c?.data?.kind === "appearance" ? c.data.value : null;
10263
+ ), r = { clientScopeId: this.modelClientScopeId, origin: location.origin, pageUrl: location.href }, a = this.options.productVariant === "personal" ? { kind: "userSuggestedTasks" } : { kind: "starterPrompts", ...r, includeUserSuggestions: !1 }, o = Pt(e, a), c = Pt(e, { kind: "appearance", ...r }), d = c?.data?.kind === "appearance" ? c.data.value : null;
10263
10264
  return {
10264
10265
  ...this.platformState,
10265
10266
  ...i,
@@ -10613,17 +10614,17 @@ class Kt {
10613
10614
  });
10614
10615
  const f = this.directoryAuthority;
10615
10616
  return this.clientRuntime.isDisposed ? null : new Promise((y, I) => {
10616
- let _ = null, S = null;
10617
+ let _ = null, k = null;
10617
10618
  const g = () => {
10618
10619
  const b = this.clientRuntime.engine.getState().slices.conversation.submissions[r];
10619
10620
  if (!(b && !b.cancelled && b.delivery !== "accepted" && b.delivery !== "failed"))
10620
- if (_?.(), S?.(), b?.delivery === "failed" && !b.cancelled) I(new Error(b.error?.message ?? "Message delivery failed."));
10621
+ if (_?.(), k?.(), b?.delivery === "failed" && !b.cancelled) I(new Error(b.error?.message ?? "Message delivery failed."));
10621
10622
  else {
10622
10623
  const v = b?.invocation === "user" && b.contextPreparation?.pageContent ? b.context.page?.url : null;
10623
10624
  b?.delivery === "accepted" && !b.cancelled && typeof v == "string" && c === this.submissionIntentRevision && f === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === m && (this.lastUserMessagePageUrl = v), y(b?.delivery === "accepted" && !b.cancelled ? r : null);
10624
10625
  }
10625
10626
  };
10626
- _ = this.clientRuntime.engine.subscribe(g), S = this.clientRuntime.onDispose(() => {
10627
+ _ = this.clientRuntime.engine.subscribe(g), k = this.clientRuntime.onDispose(() => {
10627
10628
  _?.(), y(null);
10628
10629
  }), g();
10629
10630
  });
@@ -10763,7 +10764,7 @@ class Kt {
10763
10764
  let a = !1;
10764
10765
  return jl(async () => {
10765
10766
  let o = await r(!1);
10766
- if (i(), !o.ok && $l(o.status) && this.options.tokenProvider && !a && (a = !0, o = await r(!0), i()), !o.ok) throw new Pr("Failed to prepare attachment upload", o.status);
10767
+ if (i(), !o.ok && $l(o.status) && this.options.tokenProvider && !a && (a = !0, o = await r(!0), i()), !o.ok) throw new Mr("Failed to prepare attachment upload", o.status);
10767
10768
  return await o.json();
10768
10769
  }, "Failed to prepare attachment upload");
10769
10770
  }
@@ -11123,7 +11124,7 @@ class Kt {
11123
11124
  this.clientRuntime.onDispose(() => c?.()), ro(this.clientRuntime, () => Date.now());
11124
11125
  const d = () => {
11125
11126
  const l = this.clientRuntime.engine.getState().slices.account.authority;
11126
- l?.profile === "main_web_chat" && this.options.entrySurface === "main_web_chat" && this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: l, now: Date.now(), hints: Ms(localStorage) });
11127
+ l?.profile === "main_web_chat" && this.options.entrySurface === "main_web_chat" && this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: l, now: Date.now(), hints: Ps(localStorage) });
11127
11128
  };
11128
11129
  window.addEventListener("storage", d), this.clientRuntime.onDispose(() => window.removeEventListener("storage", d)), this.clientRuntime.onDispose(() => {
11129
11130
  e.dispose(), o(), this.options.runtimeAdapters?.featurePermissions?.dispose?.();
@@ -11158,7 +11159,7 @@ class Kt {
11158
11159
  })), !0;
11159
11160
  }
11160
11161
  try {
11161
- return s.send(JSON.stringify(e)), Pe("client_event", e.type, Ss(e)), !0;
11162
+ return s.send(JSON.stringify(e)), Me("client_event", e.type, Ss(e)), !0;
11162
11163
  } catch (n) {
11163
11164
  return V("web-sdk.agent", "Pluno socket send failed; scheduling reconnect", {
11164
11165
  message: n instanceof Error ? n.message : String(n),
@@ -11207,8 +11208,8 @@ class Kt {
11207
11208
  ...s,
11208
11209
  ...s.renderedError?.runId ? { runId: s.renderedError.runId } : {}
11209
11210
  }, { errorDiagnostic: a, responseDiagnostics: o, renderedError: c, uiInvariant: d, timings: l, httpRequest: u, historyRefreshFailure: h, ...p } = r;
11210
- for (const m of l ?? []) Pe("client_event", "operation_timing", { ...m });
11211
- if (Pe("client_event", "runtime.health", {
11211
+ for (const m of l ?? []) Me("client_event", "operation_timing", { ...m });
11212
+ if (Me("client_event", "runtime.health", {
11212
11213
  ...p,
11213
11214
  signalName: e,
11214
11215
  ...h ? { historyRefreshConsecutiveFailures: h.consecutiveFailures, historyRefreshEpisodeId: h.episodeId } : {}
@@ -11303,7 +11304,7 @@ class Kt {
11303
11304
  ...s,
11304
11305
  connectionAttemptId: i
11305
11306
  };
11306
- this.transportDiagnosticEpisodes.set(r, c), this.transportDiagnosticEpisodes.size > 20 && this.transportDiagnosticEpisodes.delete(this.transportDiagnosticEpisodes.keys().next().value), e.startsWith("auth_") && Pe("client_event", "authentication_diagnostic", { ...c }), [1, 3, 10, 30, 100].includes(c.occurrenceCount) && (this.pendingTransportDiagnostics = [
11307
+ this.transportDiagnosticEpisodes.set(r, c), this.transportDiagnosticEpisodes.size > 20 && this.transportDiagnosticEpisodes.delete(this.transportDiagnosticEpisodes.keys().next().value), e.startsWith("auth_") && Me("client_event", "authentication_diagnostic", { ...c }), [1, 3, 10, 30, 100].includes(c.occurrenceCount) && (this.pendingTransportDiagnostics = [
11307
11308
  ...this.pendingTransportDiagnostics.filter((d) => d.id !== c.id),
11308
11309
  c
11309
11310
  ], this.pendingTransportDiagnostics.splice(0, Math.max(0, this.pendingTransportDiagnostics.length - 20)), this.flushClientDiagnostics());
@@ -11451,7 +11452,7 @@ class Kt {
11451
11452
  }
11452
11453
  };
11453
11454
  if (oo(this.clientRuntime, d, Date.now()).then(async () => {
11454
- this.options.entrySurface === "main_web_chat" && d.profile === "main_web_chat" && await this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: d, now: Date.now(), hints: Ms(localStorage) }), await this.refreshStarterPromptsForCurrentUrl();
11455
+ this.options.entrySurface === "main_web_chat" && d.profile === "main_web_chat" && await this.clientRuntime.engine.dispatch({ type: "stage7.device_hints", authority: d, now: Date.now(), hints: Ps(localStorage) }), await this.refreshStarterPromptsForCurrentUrl();
11455
11456
  }).catch(() => {
11456
11457
  }), r || a) {
11457
11458
  const l = this.directoryAuthority;
@@ -11503,7 +11504,7 @@ class Kt {
11503
11504
  }
11504
11505
  }
11505
11506
  handleServerEvent(e) {
11506
- if (Pe("server_event", e.type, Ss(e)), ["conversation.item.updated", "conversation.item.removed", "conversation.item.stream_finished", "conversation.execution.updated", "conversation.interaction.updated", "conversation.follow_ups.updated"].includes(e.type)) {
11507
+ if (Me("server_event", e.type, Ss(e)), ["conversation.item.updated", "conversation.item.removed", "conversation.item.stream_finished", "conversation.execution.updated", "conversation.interaction.updated", "conversation.follow_ups.updated"].includes(e.type)) {
11507
11508
  this.conversationObservation?.receive(e);
11508
11509
  return;
11509
11510
  }
@@ -11723,7 +11724,7 @@ class Kt {
11723
11724
  this.cleanupSessionBrowserApis(), this.sessionBrowserApisCleanup = Rd();
11724
11725
  }
11725
11726
  cleanupSessionBrowserApis() {
11726
- this.sessionBrowserApisCleanup && (Pd(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
11727
+ this.sessionBrowserApisCleanup && (Md(this.sessionBrowserApisCleanup), this.sessionBrowserApisCleanup = null);
11727
11728
  }
11728
11729
  async executeRuntimeHelper() {
11729
11730
  if (!this.runtimeHelperJavascript?.trim())
@@ -11739,7 +11740,7 @@ class Kt {
11739
11740
  }));
11740
11741
  }
11741
11742
  enqueueNetworkEvent(e) {
11742
- this.queuedNetworkEvents.length >= hd || (this.queuedNetworkEvents.push(Ml(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
11743
+ this.queuedNetworkEvents.length >= hd || (this.queuedNetworkEvents.push(Pl(e)), this.networkBatchTimer === null && (this.networkBatchTimer = window.setTimeout(() => {
11743
11744
  this.networkBatchTimer = null;
11744
11745
  const s = this.queuedNetworkEvents.splice(0, this.queuedNetworkEvents.length);
11745
11746
  s.length === 0 || this.socket?.readyState !== WebSocket.OPEN || this.sendNow({
@@ -11965,13 +11966,13 @@ function _d() {
11965
11966
  throw I;
11966
11967
  }
11967
11968
  try {
11968
- const I = p instanceof Request ? p : null, _ = Cl(p, I), S = Or(m?.headers ?? I?.headers);
11969
- if (!Me(_, S, m?.body)) {
11969
+ const I = p instanceof Request ? p : null, _ = Cl(p, I), k = Or(m?.headers ?? I?.headers);
11970
+ if (!Pe(_, k, m?.body)) {
11970
11971
  const b = {
11971
11972
  requestId: Os("fetch"),
11972
11973
  url: ge(_, As),
11973
11974
  method: (m?.method ?? I?.method ?? "GET").toUpperCase(),
11974
- requestHeaders: S,
11975
+ requestHeaders: k,
11975
11976
  requestBody: Ti(m?.body),
11976
11977
  resourceType: "fetch",
11977
11978
  startedAt: new Date(f).toISOString()
@@ -11999,23 +12000,23 @@ function _d() {
11999
12000
  }
12000
12001
  return y;
12001
12002
  }, o = function(p, m, f, y, I) {
12002
- const _ = n.call(this, p, m, f ?? !0, y ?? void 0, I ?? void 0), S = typeof m == "string" ? m : m.toString();
12003
+ const _ = n.call(this, p, m, f ?? !0, y ?? void 0, I ?? void 0), k = typeof m == "string" ? m : m.toString();
12003
12004
  return Ts.set(this, {
12004
12005
  requestId: Os("xhr"),
12005
12006
  method: String(p ?? "GET").toUpperCase(),
12006
- url: ge(S, As),
12007
+ url: ge(k, As),
12007
12008
  requestHeaders: {},
12008
12009
  startedAtMs: Date.now(),
12009
12010
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
12010
- excluded: Me(S)
12011
+ excluded: Pe(k)
12011
12012
  }), _;
12012
12013
  }, c = function(p, m) {
12013
12014
  const f = i.call(this, p, m), y = Ts.get(this);
12014
- return y && Object.keys(y.requestHeaders).length < Rn && (y.requestHeaders[p] = Tn(p, m), y.excluded = y.excluded || Me(y.url, y.requestHeaders)), f;
12015
+ return y && Object.keys(y.requestHeaders).length < Rn && (y.requestHeaders[p] = Tn(p, m), y.excluded = y.excluded || Pe(y.url, y.requestHeaders)), f;
12015
12016
  }, d = function(p) {
12016
12017
  try {
12017
12018
  const m = Ts.get(this);
12018
- m && (m.excluded = m.excluded || Me(m.url, m.requestHeaders, p), m.requestBody = Ti(p), m.excluded || this.addEventListener(
12019
+ m && (m.excluded = m.excluded || Pe(m.url, m.requestHeaders, p), m.requestBody = Ti(p), m.excluded || this.addEventListener(
12019
12020
  "loadend",
12020
12021
  () => {
12021
12022
  queueMicrotask(() => {
@@ -12030,7 +12031,7 @@ function _d() {
12030
12031
  resourceType: "xhr",
12031
12032
  responseStatus: this.status,
12032
12033
  responseHeaders: f,
12033
- responseBody: Pl(this, f),
12034
+ responseBody: Ml(this, f),
12034
12035
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
12035
12036
  startedAt: m.startedAt,
12036
12037
  durationMs: Date.now() - m.startedAtMs
@@ -12067,7 +12068,7 @@ function _d() {
12067
12068
  l = new PerformanceObserver((h) => {
12068
12069
  for (const p of h.getEntries()) {
12069
12070
  const m = p;
12070
- if (m.initiatorType === "fetch" || m.initiatorType === "xmlhttprequest" || Me(m.name))
12071
+ if (m.initiatorType === "fetch" || m.initiatorType === "xmlhttprequest" || Pe(m.name))
12071
12072
  continue;
12072
12073
  const f = performance.timeOrigin + m.startTime;
12073
12074
  e({
@@ -12169,7 +12170,7 @@ async function Td(t) {
12169
12170
  ok: !0,
12170
12171
  mimeType: t.type,
12171
12172
  sizeBytes: t.size,
12172
- dataUrl: await Md(t)
12173
+ dataUrl: await Pd(t)
12173
12174
  } : { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : typeof t != "string" ? { ok: !1, error: "Page image must be an image Blob or complete data:image/* URL." } : Cd(t);
12174
12175
  }
12175
12176
  function Cd(t) {
@@ -12200,13 +12201,13 @@ function Od(t) {
12200
12201
  function xd(t) {
12201
12202
  return (typeof t == "string" ? t.trim() : "") || "Page image";
12202
12203
  }
12203
- function Pd(t) {
12204
+ function Md(t) {
12204
12205
  try {
12205
12206
  t();
12206
12207
  } catch {
12207
12208
  }
12208
12209
  }
12209
- function Md(t) {
12210
+ function Pd(t) {
12210
12211
  return new Promise((e, s) => {
12211
12212
  const n = new FileReader();
12212
12213
  n.onload = () => {
@@ -12506,19 +12507,19 @@ function Hd(t, e) {
12506
12507
  ], d = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: l, priorityTargets: u } = Vd(), h = new Set(t);
12507
12508
  e && h.add(e);
12508
12509
  let p = 0;
12509
- const m = (S) => {
12510
- const g = S.getAttribute("role");
12510
+ const m = (k) => {
12511
+ const g = k.getAttribute("role");
12511
12512
  return g && !a.has(g) ? g : "";
12512
- }, f = (S) => {
12513
- const g = S.getAttribute("data-testid") || S.getAttribute("data-test") || S.getAttribute("data-qa") || S.getAttribute("data-cy") || "";
12514
- return `${S.tagName.toLowerCase()}|${m(S)}|${g}`;
12515
- }, y = (S, g, b) => {
12513
+ }, f = (k) => {
12514
+ const g = k.getAttribute("data-testid") || k.getAttribute("data-test") || k.getAttribute("data-qa") || k.getAttribute("data-cy") || "";
12515
+ return `${k.tagName.toLowerCase()}|${m(k)}|${g}`;
12516
+ }, y = (k, g, b) => {
12516
12517
  const v = (w, R) => {
12517
12518
  const q = w.tagName.toLowerCase(), C = window.getComputedStyle(w), E = l.has(w);
12518
12519
  if (p >= 1e3 && !E || b.has(w) || r.has(q) || w.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || C.display === "none" || C.visibility === "hidden")
12519
12520
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
12520
12521
  p += 1;
12521
- const T = m(w), O = kr(w), k = o.has(T) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(q) || q === "a" && w.hasAttribute("href"), x = Array.from(w.children).filter((D) => D instanceof HTMLElement), U = /* @__PURE__ */ new Map();
12522
+ const T = m(w), O = kr(w), S = o.has(T) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(q) || q === "a" && w.hasAttribute("href"), x = Array.from(w.children).filter((D) => D instanceof HTMLElement), U = /* @__PURE__ */ new Map();
12522
12523
  for (const D of x) {
12523
12524
  const $ = f(D);
12524
12525
  U.set($, (U.get($) ?? 0) + 1);
@@ -12530,8 +12531,8 @@ function Hd(t, e) {
12530
12531
  }
12531
12532
  const at = /* @__PURE__ */ new Map(), Cn = /* @__PURE__ */ new Set(), Gt = [], On = [];
12532
12533
  for (const D of x) {
12533
- const $ = f(D), ve = U.get($) ?? 0, Mn = at.get($) ?? 0;
12534
- if (at.set($, Mn + 1), ve > 8 && Mn >= 6 && !l.has(D)) {
12534
+ const $ = f(D), ve = U.get($) ?? 0, Pn = at.get($) ?? 0;
12535
+ if (at.set($, Pn + 1), ve > 8 && Pn >= 6 && !l.has(D)) {
12535
12536
  Cn.has($) || (Gt.push([`… ${H.get($) ?? 0} similar siblings omitted`]), Cn.add($));
12536
12537
  continue;
12537
12538
  }
@@ -12542,9 +12543,9 @@ function Hd(t, e) {
12542
12543
  if (w.shadowRoot)
12543
12544
  for (const D of Array.from(w.shadowRoot.children))
12544
12545
  D instanceof HTMLElement && Jt.push(v(D, R + 1));
12545
- const ct = [...On, ...Jt], Qt = O.length > 0 || k || ct.some((D) => D.hasUsefulContent), xn = Le(
12546
+ const ct = [...On, ...Jt], Qt = O.length > 0 || S || ct.some((D) => D.hasUsefulContent), xn = Le(
12546
12547
  [O, ...ct.map((D) => D.textPreview)].filter(Boolean).join(" ")
12547
- ).slice(0, 180), Lr = w.hasAttribute("contenteditable") && (O.length > 0 || !w.querySelector("[contenteditable]")), Pn = d.some((D) => w.hasAttribute(D)) || !!T || Lr, Xt = (w.getClientRects().length > 0 || C.display === "contents") && (s.has(q) || Pn || E) && (Qt || E) && (!i.has(q) || Qt || Pn || E), Yt = Xt ? 1 : 0, ze = [];
12548
+ ).slice(0, 180), Lr = w.hasAttribute("contenteditable") && (O.length > 0 || !w.querySelector("[contenteditable]")), Mn = d.some((D) => w.hasAttribute(D)) || !!T || Lr, Xt = (w.getClientRects().length > 0 || C.display === "contents") && (s.has(q) || Mn || E) && (Qt || E) && (!i.has(q) || Qt || Mn || E), Yt = Xt ? 1 : 0, ze = [];
12548
12549
  if (Xt) {
12549
12550
  const D = ct.some((ve) => ve.containsTextElement), $ = n.has(q) && !D ? xn : O;
12550
12551
  ze.push(Sr(w, c, a, $.slice(0, 180)));
@@ -12569,16 +12570,16 @@ function Hd(t, e) {
12569
12570
  containsTextElement: n.has(q) || ct.some((D) => D.containsTextElement)
12570
12571
  };
12571
12572
  };
12572
- return [`--- ${g} ---`, ...v(S, 0).lines].join(`
12573
+ return [`--- ${g} ---`, ...v(k, 0).lines].join(`
12573
12574
  `);
12574
12575
  }, I = [], _ = Le(window.getSelection()?.toString() ?? "");
12575
12576
  _ && I.push(`--- selected text ---
12576
12577
  ${JSON.stringify(_)}`), u.length > 0 && I.push(Kd(u, s, c, a));
12577
- for (const S of t.slice(0, 3))
12578
- I.push(y(S, "active overlay DOM", /* @__PURE__ */ new Set()));
12578
+ for (const k of t.slice(0, 3))
12579
+ I.push(y(k, "active overlay DOM", /* @__PURE__ */ new Set()));
12579
12580
  if (e && I.push(y(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
12580
- const S = e || t.length ? "other visible DOM" : "visible DOM";
12581
- I.push(y(document.body, S, h));
12581
+ const k = e || t.length ? "other visible DOM" : "visible DOM";
12582
+ I.push(y(document.body, k, h));
12582
12583
  }
12583
12584
  return I.join(`
12584
12585
 
@@ -13390,7 +13391,7 @@ async function xl(t) {
13390
13391
  s !== null && window.clearTimeout(s);
13391
13392
  }
13392
13393
  }
13393
- function Pl(t, e) {
13394
+ function Ml(t, e) {
13394
13395
  if (xr(new Headers(e)))
13395
13396
  try {
13396
13397
  return t.responseType === "" || t.responseType === "text" ? ge(t.responseText ?? "") : void 0;
@@ -13402,7 +13403,7 @@ function Ti(t) {
13402
13403
  if (typeof t == "string")
13403
13404
  return ge(t);
13404
13405
  }
13405
- function Ml(t) {
13406
+ function Pl(t) {
13406
13407
  return ne({
13407
13408
  ...t,
13408
13409
  requestBody: Ci(t.requestBody),
@@ -13427,7 +13428,7 @@ function xr(t) {
13427
13428
  const e = t.get("content-type")?.toLowerCase() ?? "", s = t.get("content-length"), n = Number(s);
13428
13429
  return s !== null && Number.isInteger(n) && n >= 0 && n <= kn && (e.startsWith("text/") || e.includes("json") || e.includes("javascript"));
13429
13430
  }
13430
- function Me(t, e = {}, s) {
13431
+ function Pe(t, e = {}, s) {
13431
13432
  if (Ul(s))
13432
13433
  return !0;
13433
13434
  const n = Object.entries(e).find(([i]) => i.toLowerCase() === "content-type")?.[1]?.toLowerCase();
@@ -13444,7 +13445,7 @@ function Me(t, e = {}, s) {
13444
13445
  }
13445
13446
  }
13446
13447
  function Dl(t, e) {
13447
- if (Me(t))
13448
+ if (Pe(t))
13448
13449
  return !0;
13449
13450
  try {
13450
13451
  const s = new URL(t, location.href), n = new URL(e);
@@ -13475,7 +13476,7 @@ function ge(t, e = kn) {
13475
13476
  function Os(t) {
13476
13477
  return `${t}-${Date.now()}-${Math.random().toString(16).slice(2)}`;
13477
13478
  }
13478
- class Pr extends Error {
13479
+ class Mr extends Error {
13479
13480
  constructor(e, s) {
13480
13481
  super(`${e} (${s})`), this.status = s, this.name = "AttachmentUploadHttpError", this.code = String(s);
13481
13482
  }
@@ -13500,7 +13501,7 @@ function Bl(t) {
13500
13501
  });
13501
13502
  }
13502
13503
  function Ll(t) {
13503
- return t instanceof Pr ? Fl(t.status) : t instanceof TypeError;
13504
+ return t instanceof Mr ? Fl(t.status) : t instanceof TypeError;
13504
13505
  }
13505
13506
  function Fl(t) {
13506
13507
  return t === 408 || t === 409 || t === 429 || t >= 500;
@@ -13508,7 +13509,7 @@ function Fl(t) {
13508
13509
  function $l(t) {
13509
13510
  return t === 401 || t === 403;
13510
13511
  }
13511
- const Wt = "[REDACTED_SECRET]", me = "[REDACTED_TOKEN]", zl = "[REDACTED_SIGNED_URL]", Hl = 20, Vl = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Mr = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Dr = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ur = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Nr = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, Kl = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Wl = /\bhttps?:\/\/[^\s"'<>]+/gi, Gl = /[),.;\]]+$/;
13512
+ const Wt = "[REDACTED_SECRET]", me = "[REDACTED_TOKEN]", zl = "[REDACTED_SIGNED_URL]", Hl = 20, Vl = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Pr = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, Dr = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, Ur = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, Nr = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, Kl = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, Wl = /\bhttps?:\/\/[^\s"'<>]+/gi, Gl = /[),.;\]]+$/;
13512
13513
  function ne(t) {
13513
13514
  return jt(t, 0, /* @__PURE__ */ new WeakSet());
13514
13515
  }
@@ -13546,10 +13547,10 @@ function Br(t) {
13546
13547
  }
13547
13548
  }
13548
13549
  function Bt(t) {
13549
- return t.replace(Kl, zl).replace(Wl, Xl).replace(Mr, `Bearer ${me}`).replace(Dr, `Basic ${me}`).replace(Ur, me).replace(Nr, (e, s) => `${s}: ${Wt}`);
13550
+ return t.replace(Kl, zl).replace(Wl, Xl).replace(Pr, `Bearer ${me}`).replace(Dr, `Basic ${me}`).replace(Ur, me).replace(Nr, (e, s) => `${s}: ${Wt}`);
13550
13551
  }
13551
13552
  function Ql(t) {
13552
- return t.replace(Mr, `Bearer ${me}`).replace(Dr, `Basic ${me}`).replace(Ur, me).replace(Nr, (e, s) => `${s}: ${Wt}`);
13553
+ return t.replace(Pr, `Bearer ${me}`).replace(Dr, `Basic ${me}`).replace(Ur, me).replace(Nr, (e, s) => `${s}: ${Wt}`);
13553
13554
  }
13554
13555
  function Xl(t) {
13555
13556
  const e = t.match(Gl)?.[0] ?? "", s = e ? t.slice(0, -e.length) : t;