@pluno/product-agent-web 0.1.109 → 0.1.110

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.
@@ -199,12 +199,12 @@ async function Hi(e) {
199
199
  });
200
200
  if (!n.ok)
201
201
  throw new Error("Failed to load active users");
202
- const o = await n.json(), i = Vn(o.count), r = Vn(o.refreshAfterMs ?? o.refresh_after_ms);
202
+ const o = await n.json(), i = Kn(o.count), r = Kn(o.refreshAfterMs ?? o.refresh_after_ms);
203
203
  if (i === null || r === null)
204
204
  throw new Error("Invalid active users response");
205
205
  return { count: i, refreshAfterMs: r };
206
206
  }
207
- function Vn(e) {
207
+ function Kn(e) {
208
208
  return typeof e != "number" || !Number.isFinite(e) || e < 0 ? null : Math.round(e);
209
209
  }
210
210
  function Gi(e) {
@@ -240,14 +240,14 @@ const ji = [
240
240
  ".pluno-pa-widget__message",
241
241
  ".timeline-item"
242
242
  ].join(",");
243
- function Vi(e, t, n) {
244
- return e instanceof Element ? Ki(
243
+ function Ki(e, t, n) {
244
+ return e instanceof Element ? Vi(
245
245
  t,
246
246
  n,
247
247
  e.closest(ji) !== null
248
248
  ) : !1;
249
249
  }
250
- function Ki(e, t, n) {
250
+ function Vi(e, t, n) {
251
251
  return e === 1 && !t && !n;
252
252
  }
253
253
  function Yi(e, t, n) {
@@ -271,7 +271,7 @@ function Ji(e) {
271
271
  }
272
272
  const r = i.match(/^[ \t]{0,3}(`{3,}|~{3,})/);
273
273
  if (r) {
274
- t += Kn(n) + i, n = "", o = {
274
+ t += Vn(n) + i, n = "", o = {
275
275
  marker: r[1][0],
276
276
  length: r[1].length
277
277
  };
@@ -279,9 +279,9 @@ function Ji(e) {
279
279
  }
280
280
  n += i;
281
281
  }
282
- return t + Kn(n);
282
+ return t + Vn(n);
283
283
  }
284
- function Kn(e) {
284
+ function Vn(e) {
285
285
  let t = "", n = 0;
286
286
  for (const o of e.matchAll(Zi)) {
287
287
  const i = o.index ?? 0;
@@ -502,7 +502,7 @@ async function Ra(e = {}) {
502
502
  ".pluno-pa-widget__history"
503
503
  ), Le = i.querySelector(
504
504
  ".pluno-pa-widget__history-panel"
505
- ), K = i.querySelector(
505
+ ), V = i.querySelector(
506
506
  ".pluno-pa-widget__history-list"
507
507
  ), ut = i.querySelector(
508
508
  ".pluno-pa-widget__history-close"
@@ -531,22 +531,22 @@ async function Ra(e = {}) {
531
531
  ), oe = i.querySelector(
532
532
  ".pluno-pa-widget__tab-groups-suggestion-dismiss"
533
533
  );
534
- if (!P || !c || !m || !A || !ne || !W || !Xe || !Ue || !ge || !B || !x || !F || !$ || !Z || !Le || !K || !ut || !Te || !he || !me || !z || !Ze)
534
+ if (!P || !c || !m || !A || !ne || !W || !Xe || !Ue || !ge || !B || !x || !F || !$ || !Z || !Le || !V || !ut || !Te || !he || !me || !z || !Ze)
535
535
  throw new Error("Failed to mount Pluno widget");
536
536
  if (t.movableLauncher && !U)
537
537
  throw new Error("Failed to mount Pluno widget drag handle");
538
538
  B.hidden = !t.attachmentsEnabled, ge.disabled = !t.attachmentsEnabled, go(c), go(x);
539
- let f = [], E = null;
539
+ let w = [], E = null;
540
540
  const q = () => Xi(
541
541
  x,
542
542
  i.classList.contains("pluno-pa-widget--open") && !t.loginRequired && !t.signupRequired && !se(t.billingStatus)
543
543
  ), Be = () => {
544
544
  vr(
545
545
  Ue,
546
- f,
546
+ w,
547
547
  (a) => {
548
- f = f.filter(
549
- (d, w) => w !== a
548
+ w = w.filter(
549
+ (d, f) => f !== a
550
550
  ), Be(), O(b.getState()), j(), q();
551
551
  }
552
552
  );
@@ -605,31 +605,31 @@ async function Ra(e = {}) {
605
605
  }, li = (a = "jump") => {
606
606
  ae(!0, a), re(), pt(z, () => Ie.enabled), Ne = z.scrollTop;
607
607
  }, we = () => {
608
- if (Z.hidden = t.layout === "page" || t.loginRequired, Le.hidden = !X, Z.setAttribute("aria-expanded", String(X)), K.classList.toggle(
608
+ if (Z.hidden = t.layout === "page" || t.loginRequired, Le.hidden = !X, Z.setAttribute("aria-expanded", String(X)), V.classList.toggle(
609
609
  "pluno-pa-widget__history-list--center",
610
610
  fe && Ce.length === 0
611
- ), K.replaceChildren(), fe && Ce.length === 0) {
611
+ ), V.replaceChildren(), fe && Ce.length === 0) {
612
612
  const a = document.createElement("p");
613
- a.className = "pluno-pa-widget__history-loading", a.textContent = "Loading...", K.appendChild(a);
613
+ a.className = "pluno-pa-widget__history-loading", a.textContent = "Loading...", V.appendChild(a);
614
614
  }
615
615
  for (const a of Ce) {
616
616
  const d = document.createElement("button");
617
617
  d.type = "button", d.className = "pluno-pa-widget__history-item", d.disabled = fe;
618
- const w = document.createElement("span");
619
- w.className = "pluno-pa-widget__history-item-title", w.textContent = Qa(a);
618
+ const f = document.createElement("span");
619
+ f.className = "pluno-pa-widget__history-item-title", f.textContent = Qa(a);
620
620
  const v = document.createElement("time");
621
621
  v.className = "pluno-pa-widget__history-time", v.dateTime = a.lastActiveAt, v.textContent = tr(
622
622
  a.lastActiveAt,
623
623
  Date.now()
624
624
  );
625
625
  const N = document.createElement("small");
626
- N.className = "pluno-pa-widget__history-path", N.textContent = er(a), d.append(w, v, N), d.addEventListener("click", () => {
626
+ N.className = "pluno-pa-widget__history-path", N.textContent = er(a), d.append(f, v, N), d.addEventListener("click", () => {
627
627
  X = !1, Je = null, we(), ae(!0, "newSession"), re(), b.loadSession(a.id), O(b.getState()), q();
628
- }), K.appendChild(d);
628
+ }), V.appendChild(d);
629
629
  }
630
630
  if (fe && Ce.length > 0) {
631
631
  const a = document.createElement("p");
632
- a.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", a.textContent = "Loading...", K.appendChild(a);
632
+ a.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", a.textContent = "Loading...", V.appendChild(a);
633
633
  }
634
634
  Te.textContent = Je ?? (!fe && Ce.length === 0 ? "No recent chats for this page yet." : ""), Te.hidden = Te.textContent.length === 0;
635
635
  }, An = async (a) => {
@@ -651,7 +651,7 @@ async function Ra(e = {}) {
651
651
  }
652
652
  }
653
653
  }, si = () => {
654
- !zt || fe || K.scrollHeight - K.scrollTop - K.clientHeight <= 24 && An(zt);
654
+ !zt || fe || V.scrollHeight - V.scrollTop - V.clientHeight <= 24 && An(zt);
655
655
  }, Pn = () => {
656
656
  Y || typeof document > "u" || (yo(o, t.accentColor), n.isConnected || (t.mountTarget?.isConnected ? t.mountTarget.appendChild(n) : t.mountTarget || S.body?.appendChild(n)));
657
657
  }, In = new MutationObserver(Pn);
@@ -671,7 +671,7 @@ async function Ra(e = {}) {
671
671
  d
672
672
  );
673
673
  }, G = () => {
674
- const a = Ka(
674
+ const a = Va(
675
675
  o,
676
676
  c,
677
677
  x
@@ -705,7 +705,7 @@ async function Ra(e = {}) {
705
705
  )
706
706
  ), po(i), G(), d && mt("minimized");
707
707
  }, Re = (a, d = {}) => {
708
- Va(a, {
708
+ Ka(a, {
709
709
  debugVersion: Ia,
710
710
  launcherPosition: s,
711
711
  rootClasses: i.className,
@@ -762,7 +762,7 @@ async function Ra(e = {}) {
762
762
  D,
763
763
  Ot()
764
764
  );
765
- const w = kt(
765
+ const f = kt(
766
766
  h ?? nn(
767
767
  i,
768
768
  a,
@@ -771,9 +771,9 @@ async function Ra(e = {}) {
771
771
  ),
772
772
  d
773
773
  );
774
- h && (h = w), Mt(w, a), Re(
774
+ h && (h = f), Mt(f, a), Re(
775
775
  "Applied open panel position after viewport resize",
776
- { openPanelPosition: w }
776
+ { openPanelPosition: f }
777
777
  );
778
778
  } else s && Re(
779
779
  "Applied visible launcher position after viewport resize",
@@ -788,14 +788,14 @@ async function Ra(e = {}) {
788
788
  launcherDragHandle: U,
789
789
  getPosition: () => Qe(),
790
790
  setPosition: (a) => {
791
- const d = a, w = At(i), v = wn(
791
+ const d = a, f = At(i), v = wn(
792
792
  i,
793
793
  a,
794
- w
794
+ f
795
795
  );
796
796
  s = Ga(
797
797
  v,
798
- w
798
+ f
799
799
  ), Me(i, v), Re("Dragging closed launcher", {
800
800
  requestedPosition: d
801
801
  });
@@ -863,7 +863,7 @@ async function Ra(e = {}) {
863
863
  Ut = !1;
864
864
  }
865
865
  }
866
- }, be = (a = "", d = !0, w = !0) => {
866
+ }, be = (a = "", d = !0, f = !0) => {
867
867
  Dn(), ot && (ot = !1, Wt()), i.classList.contains("pluno-pa-widget--open") || (h = null), ie !== null && (window.clearTimeout(ie), ie = null), et("shown", !1), m.hidden = !1, A.hidden = !1, rn(
868
868
  D,
869
869
  Ot()
@@ -878,11 +878,11 @@ async function Ra(e = {}) {
878
878
  openPanelPosition: N,
879
879
  visibleLauncherPosition: v
880
880
  }), ae(!0, "open"), re(), !d) {
881
- i.classList.add("pluno-pa-widget--open"), P.hidden = !0, a && (x.value = a, lt(x)), pt(z, () => Ie.enabled), Ne = z.scrollTop, w && (x.focus(), x.setSelectionRange(x.value.length, x.value.length)), G(), mt("shown"), t.onPanelOpenChange?.(!0);
881
+ i.classList.add("pluno-pa-widget--open"), P.hidden = !0, a && (x.value = a, lt(x)), pt(z, () => Ie.enabled), Ne = z.scrollTop, f && (x.focus(), x.setSelectionRange(x.value.length, x.value.length)), G(), mt("shown"), t.onPanelOpenChange?.(!0);
882
882
  return;
883
883
  }
884
884
  window.requestAnimationFrame(() => {
885
- i.classList.add("pluno-pa-widget--open"), a && (x.value = a, lt(x)), pt(z, () => Ie.enabled), Ne = z.scrollTop, w && (x.focus(), x.setSelectionRange(x.value.length, x.value.length)), G(), mt("shown"), t.onPanelOpenChange?.(!0), ie = window.setTimeout(() => {
885
+ i.classList.add("pluno-pa-widget--open"), a && (x.value = a, lt(x)), pt(z, () => Ie.enabled), Ne = z.scrollTop, f && (x.focus(), x.setSelectionRange(x.value.length, x.value.length)), G(), mt("shown"), t.onPanelOpenChange?.(!0), ie = window.setTimeout(() => {
886
886
  P.hidden = !0, pt(z, () => Ie.enabled), Ne = z.scrollTop;
887
887
  }, 220);
888
888
  });
@@ -911,9 +911,9 @@ async function Ra(e = {}) {
911
911
  return null;
912
912
  let d = a;
913
913
  for (; d; ) {
914
- const w = d.closest(Jn);
915
- if (w)
916
- return w;
914
+ const f = d.closest(Jn);
915
+ if (f)
916
+ return f;
917
917
  const v = d.getRootNode();
918
918
  d = v instanceof ShadowRoot ? v.host : null;
919
919
  }
@@ -948,12 +948,12 @@ async function Ra(e = {}) {
948
948
  const d = Ft;
949
949
  if (Ft = null, d === null || Date.now() - d > fa)
950
950
  return;
951
- const w = ui(a.relatedTarget);
952
- if (!w)
951
+ const f = ui(a.relatedTarget);
952
+ if (!f)
953
953
  return;
954
954
  const v = Date.now();
955
955
  if (ft !== null && v - ft <= wa) {
956
- Mn(w);
956
+ Mn(f);
957
957
  return;
958
958
  }
959
959
  ft = v;
@@ -981,7 +981,7 @@ async function Ra(e = {}) {
981
981
  const a = nt(), d = We !== null;
982
982
  c.readOnly = !1, x.readOnly = !1, c.placeholder = d ? Qn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : ot ? "New update" : t.launcherLabel, x.placeholder = d ? Qn : a ? t.signupRequired ? t.signupButtonLabel : t.loginButtonLabel : de.launcherLabel, ne.hidden = a;
983
983
  }, j = () => {
984
- F.disabled = le() || se(t.billingStatus) || !b.getState().isThinking && x.value.trim().length === 0 && f.length === 0, B.disabled = nt() || le() || se(t.billingStatus);
984
+ F.disabled = le() || se(t.billingStatus) || !b.getState().isThinking && x.value.trim().length === 0 && w.length === 0, B.disabled = nt() || le() || se(t.billingStatus);
985
985
  };
986
986
  ze();
987
987
  const Wt = () => {
@@ -1017,10 +1017,10 @@ async function Ra(e = {}) {
1017
1017
  t.onSignupClick?.();
1018
1018
  return;
1019
1019
  }
1020
- le() || se(t.billingStatus) || (Se = !0, ae(!0, "send"), re(), f = an(
1020
+ le() || se(t.billingStatus) || (Se = !0, ae(!0, "send"), re(), w = an(
1021
1021
  b,
1022
1022
  x,
1023
- f,
1023
+ w,
1024
1024
  St
1025
1025
  ), Be(), j());
1026
1026
  });
@@ -1037,7 +1037,7 @@ async function Ra(e = {}) {
1037
1037
  if (!t.attachmentsEnabled || a.length === 0)
1038
1038
  return;
1039
1039
  const d = Er(b, a);
1040
- if (f = [...f, ...d], Be(), fi(), j(), O(b.getState()), !i.classList.contains("pluno-pa-widget--open")) {
1040
+ if (w = [...w, ...d], Be(), fi(), j(), O(b.getState()), !i.classList.contains("pluno-pa-widget--open")) {
1041
1041
  be();
1042
1042
  return;
1043
1043
  }
@@ -1065,17 +1065,17 @@ async function Ra(e = {}) {
1065
1065
  Ct(a.dataTransfer) && (a.stopPropagation(), it = Math.max(0, it - 1), it === 0 && i.classList.remove("pluno-pa-widget--drag-over"));
1066
1066
  }), i.addEventListener("drop", (a) => {
1067
1067
  const d = a.dataTransfer;
1068
- !t.attachmentsEnabled || !Ct(d) || t.loginRequired || le() || (a.preventDefault(), a.stopPropagation(), mi(), $t(d.files).catch((w) => {
1068
+ !t.attachmentsEnabled || !Ct(d) || t.loginRequired || le() || (a.preventDefault(), a.stopPropagation(), mi(), $t(d.files).catch((f) => {
1069
1069
  Gt(
1070
- w instanceof Error ? w.message : "Failed to attach file"
1070
+ f instanceof Error ? f.message : "Failed to attach file"
1071
1071
  ), J("web-sdk.widget", "Attachment failed", {
1072
- message: w instanceof Error ? w.message : String(w)
1072
+ message: f instanceof Error ? f.message : String(f)
1073
1073
  });
1074
1074
  }));
1075
1075
  }), i.addEventListener("paste", (a) => {
1076
1076
  a.stopPropagation();
1077
- const d = a.clipboardData, w = Array.from(d?.files ?? []);
1078
- !t.attachmentsEnabled || w.length === 0 || t.loginRequired || le() || (a.preventDefault(), $t(w).catch((v) => {
1077
+ const d = a.clipboardData, f = Array.from(d?.files ?? []);
1078
+ !t.attachmentsEnabled || f.length === 0 || t.loginRequired || le() || (a.preventDefault(), $t(f).catch((v) => {
1079
1079
  Gt(
1080
1080
  v instanceof Error ? v.message : "Failed to attach file"
1081
1081
  ), J("web-sdk.widget", "Attachment failed", {
@@ -1093,18 +1093,18 @@ async function Ra(e = {}) {
1093
1093
  }
1094
1094
  if (le())
1095
1095
  return;
1096
- const a = x.value.trim().length > 0 || f.length > 0;
1097
- Se = !0, ae(!0, "send"), re(), f = an(
1096
+ const a = x.value.trim().length > 0 || w.length > 0;
1097
+ Se = !0, ae(!0, "send"), re(), w = an(
1098
1098
  b,
1099
1099
  x,
1100
- f,
1100
+ w,
1101
1101
  St
1102
1102
  ), Be(), j(), O(b.getState()), a && q();
1103
1103
  }), Z.addEventListener("click", () => {
1104
1104
  X = !X, Je = null, we(), X && Ce.length === 0 && An(null), X || q();
1105
1105
  }), ut.addEventListener("click", () => {
1106
1106
  X = !1, we(), q();
1107
- }), K.addEventListener("scroll", si), x.addEventListener("input", () => {
1107
+ }), V.addEventListener("scroll", si), x.addEventListener("input", () => {
1108
1108
  lt(x), G(), j(), xi();
1109
1109
  }), x.addEventListener("keydown", (a) => {
1110
1110
  if (!(a.key !== "Enter" || a.shiftKey)) {
@@ -1112,10 +1112,10 @@ async function Ra(e = {}) {
1112
1112
  t.onLoginClick?.();
1113
1113
  return;
1114
1114
  }
1115
- le() || (Se = !0, ae(!0, "send"), re(), f = an(
1115
+ le() || (Se = !0, ae(!0, "send"), re(), w = an(
1116
1116
  b,
1117
1117
  x,
1118
- f,
1118
+ w,
1119
1119
  St
1120
1120
  ), Be(), j(), O(b.getState()));
1121
1121
  }
@@ -1123,7 +1123,7 @@ async function Ra(e = {}) {
1123
1123
  const d = a.target instanceof Element ? a.target : null;
1124
1124
  d?.closest("a[href]") && G(), X && Yi(d, Le, Z) && (X = !1, we());
1125
1125
  const v = window.getSelection(), N = !!(v && !v.isCollapsed && v.anchorNode && i.contains(v.anchorNode));
1126
- Vi(a.target, a.detail, N) && q();
1126
+ Ki(a.target, a.detail, N) && q();
1127
1127
  }), i.addEventListener("copy", (a) => {
1128
1128
  a.clipboardData && window.getSelection() && !window.getSelection()?.isCollapsed && window.getSelection()?.anchorNode && window.getSelection()?.focusNode && i.contains(window.getSelection()?.anchorNode ?? null) && i.contains(window.getSelection()?.focusNode ?? null) && window.getSelection()?.toString() && (a.clipboardData.clearData(), a.clipboardData.setData(
1129
1129
  "text/plain",
@@ -1190,13 +1190,13 @@ async function Ra(e = {}) {
1190
1190
  je = !1, yt();
1191
1191
  });
1192
1192
  }), yt();
1193
- let Ve = null, Wn = () => {
1193
+ let Ke = null, Wn = () => {
1194
1194
  };
1195
- const _i = !!t.socialPostDraftHandler, jt = /* @__PURE__ */ new Map(), Vt = () => x.value.trim().length > 0 || f.length > 0, xi = () => {
1196
- const a = Ve !== null && pn(b.getState(), Vt());
1197
- me.hidden = !a, a && Ve !== null && Wo(me, Ve);
1195
+ const _i = !!t.socialPostDraftHandler, jt = /* @__PURE__ */ new Map(), Kt = () => x.value.trim().length > 0 || w.length > 0, xi = () => {
1196
+ const a = Ke !== null && pn(b.getState(), Kt());
1197
+ me.hidden = !a, a && Ke !== null && Wo(me, Ke);
1198
1198
  };
1199
- let Ke = null;
1199
+ let Ve = null;
1200
1200
  const _e = /* @__PURE__ */ new Map(), vt = /* @__PURE__ */ new Set(), yi = async (a) => {
1201
1201
  if (t.integrationAuthHandler) {
1202
1202
  _e.set(a.authRequestId, { status: "connecting" }), O(b.getState());
@@ -1210,21 +1210,21 @@ async function Ra(e = {}) {
1210
1210
  }
1211
1211
  O(b.getState());
1212
1212
  }
1213
- }, Kt = (a = {}) => {
1214
- Se = !0, ae(!0, "newSession"), re(), X = !1, we(), b.startNewSession(a), Rt.clear(), _e.clear(), vt.clear(), x.value = "", f = [], Be(), lt(x), G(), j(), x.focus(), O(b.getState());
1213
+ }, Vt = (a = {}) => {
1214
+ Se = !0, ae(!0, "newSession"), re(), X = !1, we(), b.startNewSession(a), Rt.clear(), _e.clear(), vt.clear(), x.value = "", w = [], Be(), lt(x), G(), j(), x.focus(), O(b.getState());
1215
1215
  }, St = () => {
1216
- t.morningReport !== null && (t.morningReport = null, t.onMorningReportTaskStart?.(), Kt());
1216
+ t.morningReport !== null && (t.morningReport = null, t.onMorningReportTaskStart?.(), Vt());
1217
1217
  }, Yt = (a) => {
1218
1218
  if (!a || t.layout === "page") {
1219
- Ke?.remove(), Ke = null;
1219
+ Ve?.remove(), Ve = null;
1220
1220
  return;
1221
1221
  }
1222
- Ke || (Ke = It(
1222
+ Ve || (Ve = It(
1223
1223
  "pluno-pa-widget__new-chat",
1224
1224
  "New chat",
1225
1225
  hr(),
1226
1226
  !1
1227
- ), Ke.addEventListener("click", () => Kt()), $.insertBefore(Ke, Z));
1227
+ ), Ve.addEventListener("click", () => Vt()), $.insertBefore(Ve, Z));
1228
1228
  }, O = (a) => {
1229
1229
  if (we(), En(a.lastErrorCode) ? Ge = a.lastErrorCode : t.billingStatus?.creditsUsed !== null && !se(t.billingStatus) && (Ge = null), sn(
1230
1230
  Xe,
@@ -1256,7 +1256,7 @@ async function Ra(e = {}) {
1256
1256
  );
1257
1257
  return;
1258
1258
  }
1259
- const d = Za(a), w = d !== Tn;
1259
+ const d = Za(a), f = d !== Tn;
1260
1260
  Tn = d;
1261
1261
  const v = Se || Ie.enabled;
1262
1262
  Se = !1, Nr(
@@ -1266,8 +1266,8 @@ async function Ra(e = {}) {
1266
1266
  Yt,
1267
1267
  me,
1268
1268
  a,
1269
- Ve,
1270
- Ve !== null && pn(a, Vt()),
1269
+ Ke,
1270
+ Ke !== null && pn(a, Kt()),
1271
1271
  v,
1272
1272
  () => Ie.enabled,
1273
1273
  Rt,
@@ -1311,29 +1311,29 @@ async function Ra(e = {}) {
1311
1311
  Dt = !0, Fe.add(N.id), gt.add(N.id), G(), sl(t, !0), at = null, O(b.getState());
1312
1312
  }
1313
1313
  } : void 0
1314
- ), v ? (Ne = z.scrollTop, re()) : w && Ja(a) && ri();
1314
+ ), v ? (Ne = z.scrollTop, re()) : f && Ja(a) && ri();
1315
1315
  }, Hn = async (a) => {
1316
1316
  if (!t.integrationAuthStatusLoader)
1317
1317
  return;
1318
- const d = a.messages.map((w) => w.integrationAuthRequest).filter(
1319
- (w) => !!w
1318
+ const d = a.messages.map((f) => f.integrationAuthRequest).filter(
1319
+ (f) => !!f
1320
1320
  );
1321
1321
  await Promise.all(
1322
- d.map(async (w) => {
1323
- if (!(_e.has(w.authRequestId) || vt.has(w.authRequestId))) {
1324
- vt.add(w.authRequestId), _e.set(w.authRequestId, {
1322
+ d.map(async (f) => {
1323
+ if (!(_e.has(f.authRequestId) || vt.has(f.authRequestId))) {
1324
+ vt.add(f.authRequestId), _e.set(f.authRequestId, {
1325
1325
  status: "checking"
1326
1326
  }), O(b.getState());
1327
1327
  try {
1328
- const v = await t.integrationAuthStatusLoader(w);
1329
- _e.set(w.authRequestId, { status: v });
1328
+ const v = await t.integrationAuthStatusLoader(f);
1329
+ _e.set(f.authRequestId, { status: v });
1330
1330
  } catch (v) {
1331
- _e.set(w.authRequestId, {
1331
+ _e.set(f.authRequestId, {
1332
1332
  status: "error",
1333
- error: v instanceof Error ? v.message : `Could not load ${w.appName} connection status.`
1333
+ error: v instanceof Error ? v.message : `Could not load ${f.appName} connection status.`
1334
1334
  });
1335
1335
  } finally {
1336
- vt.delete(w.authRequestId);
1336
+ vt.delete(f.authRequestId);
1337
1337
  }
1338
1338
  Y || O(b.getState());
1339
1339
  }
@@ -1342,7 +1342,7 @@ async function Ra(e = {}) {
1342
1342
  };
1343
1343
  return Wn = Wi(
1344
1344
  (a) => {
1345
- Ve = a, !Y && pn(b.getState(), Vt()) && O(b.getState());
1345
+ Ke = a, !Y && pn(b.getState(), Kt()) && O(b.getState());
1346
1346
  },
1347
1347
  {
1348
1348
  backendUrl: t.backendUrl,
@@ -1371,7 +1371,7 @@ async function Ra(e = {}) {
1371
1371
  ), Xt({}, "agent.state.appearance-cleared")), O(a), Hn(a), j(), d && Dn();
1372
1372
  }), O(b.getState()), Hn(b.getState()), j(), Ht(), {
1373
1373
  agent: b,
1374
- startNewChat: Kt,
1374
+ startNewChat: Vt,
1375
1375
  host: n,
1376
1376
  updateAppearance: (a) => {
1377
1377
  a.scribbleStyle !== void 0 && (t.scribbleStyle = a.scribbleStyle), Xt(a, "widgetHandle.updateAppearance");
@@ -1393,7 +1393,8 @@ async function Ra(e = {}) {
1393
1393
  t.loginRequired = a.loginRequired === !0, t.signupRequired = a.signupRequired === !0, a.loginButtonLabel !== void 0 && (t.loginButtonLabel = a.loginButtonLabel), a.loginUrl !== void 0 && (t.loginUrl = a.loginUrl), a.signupButtonLabel !== void 0 && (t.signupButtonLabel = a.signupButtonLabel), a.signupUrl !== void 0 && (t.signupUrl = a.signupUrl), ze(), O(b.getState()), j(), d && !nt() && Ht();
1394
1394
  },
1395
1395
  openPanel: (a) => {
1396
- be(x.value, !1, a?.focusComposer !== !1);
1396
+ const d = typeof a == "string" ? a : x.value, f = typeof a == "object" ? a.focusComposer !== !1 : !0;
1397
+ be(d, !1, f);
1397
1398
  },
1398
1399
  closePanel: Bt,
1399
1400
  updateDisplayState: (a) => {
@@ -1433,19 +1434,19 @@ async function Ra(e = {}) {
1433
1434
  }
1434
1435
  }
1435
1436
  function Xt(a, d) {
1436
- const w = a.accentColor ?? t.accentColor, v = a.colorScheme ?? t.colorScheme, N = a.fontFamily ?? t.fontFamily, Zt = a.scribbleStyle ?? t.scribbleStyle;
1437
+ const f = a.accentColor ?? t.accentColor, v = a.colorScheme ?? t.colorScheme, N = a.fontFamily ?? t.fontFamily, Zt = a.scribbleStyle ?? t.scribbleStyle;
1437
1438
  r = io(
1438
- w,
1439
+ f,
1439
1440
  Zt
1440
1441
  ), ao(i, r, {
1441
- accentColor: w,
1442
+ accentColor: f,
1442
1443
  colorScheme: v,
1443
1444
  fontFamily: N,
1444
1445
  scribbleStyle: Zt
1445
1446
  }), J("web-sdk.widget", "Updated widget appearance", {
1446
1447
  source: d,
1447
1448
  inputAppearance: a,
1448
- appliedAccentColor: w,
1449
+ appliedAccentColor: f,
1449
1450
  appliedColorScheme: v,
1450
1451
  appliedFontFamily: N,
1451
1452
  appliedScribbleStyle: Zt,
@@ -1887,7 +1888,7 @@ function J(e, t, n) {
1887
1888
  new CustomEvent(ha, { detail: i })
1888
1889
  );
1889
1890
  }
1890
- function Va(e, t) {
1891
+ function Ka(e, t) {
1891
1892
  J("web-sdk.widget.position", e, t);
1892
1893
  }
1893
1894
  function an(e, t, n, o) {
@@ -1896,7 +1897,7 @@ function an(e, t, n, o) {
1896
1897
  attachments: n.length > 0 ? n.map(Xa) : void 0
1897
1898
  }), t.dispatchEvent(new Event("input", { bubbles: !0 })), []);
1898
1899
  }
1899
- function Ka(e, t, n) {
1900
+ function Va(e, t, n) {
1900
1901
  const o = e.activeElement;
1901
1902
  return o === n ? "composer" : o === t ? "launcher" : null;
1902
1903
  }
@@ -2884,7 +2885,7 @@ function sn(e, t, n = null) {
2884
2885
  }
2885
2886
  e.hidden = !1, e.replaceChildren(), e.className = "pluno-pa-widget__billing-status", se(t) || En(n) ? e.appendChild(
2886
2887
  Lr(t, n)
2887
- ) : Vo(t) && e.appendChild(Tr(t));
2888
+ ) : Ko(t) && e.appendChild(Tr(t));
2888
2889
  }
2889
2890
  function Lr(e, t) {
2890
2891
  const n = document.createElement("div");
@@ -2893,7 +2894,7 @@ function Lr(e, t) {
2893
2894
  i.textContent = o ? "Credits used up" : "Billing needs attention", n.appendChild(i);
2894
2895
  const r = document.createElement("span");
2895
2896
  return r.textContent = o ? "Earn bonus credits or upgrade to keep using Pluno on this product." : e.paymentIssue ?? "Open billing to keep using Pluno.", n.appendChild(r), n.appendChild(
2896
- Ko(
2897
+ Vo(
2897
2898
  e,
2898
2899
  "Upgrade plan",
2899
2900
  "pluno-pa-widget__billing-action-card-actions"
@@ -2907,7 +2908,7 @@ function Tr(e) {
2907
2908
  n.textContent = "Credits running low", t.appendChild(n);
2908
2909
  const o = document.createElement("span");
2909
2910
  return o.textContent = Pr(e) ?? "Credits are running low for this period.", t.appendChild(o), t.appendChild(
2910
- Ko(
2911
+ Vo(
2911
2912
  e,
2912
2913
  "Upgrade",
2913
2914
  "pluno-pa-widget__billing-action-card-actions"
@@ -2915,7 +2916,7 @@ function Tr(e) {
2915
2916
  ), t;
2916
2917
  }
2917
2918
  function _n(e, t) {
2918
- return e !== null && (se(e) || Vo(e) || En(t));
2919
+ return e !== null && (se(e) || Ko(e) || En(t));
2919
2920
  }
2920
2921
  function mo(e, t, n) {
2921
2922
  return _n(t, n) || Ar(t) ? !0 : !_n(e, n);
@@ -2929,7 +2930,7 @@ function se(e) {
2929
2930
  function En(e) {
2930
2931
  return e === "limit_exceeded" || e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required";
2931
2932
  }
2932
- function Vo(e) {
2933
+ function Ko(e) {
2933
2934
  return !se(e) && e.creditLimit !== null && e.creditLimit > 0 && e.creditsRemaining !== null && e.creditsRemaining > 0 && e.creditsRemaining / e.creditLimit <= 0.2;
2934
2935
  }
2935
2936
  function Pr(e) {
@@ -2940,7 +2941,7 @@ function Ir(e) {
2940
2941
  maximumFractionDigits: 0
2941
2942
  }).format(Math.ceil(e));
2942
2943
  }
2943
- function Ko(e, t, n) {
2944
+ function Vo(e, t, n) {
2944
2945
  const o = document.createElement("div");
2945
2946
  return o.className = n, o.appendChild(
2946
2947
  fo(t, e.pricingUrl)
@@ -2982,35 +2983,35 @@ function Nr(e, t, n, o, i, r, l, p, s, g, u, h, k, S, P, U, c, C, m, D, M, A) {
2982
2983
  S()
2983
2984
  );
2984
2985
  if (L.appendChild(I), y.appendChild(L), c) {
2985
- const f = document.createElement("h2");
2986
- f.className = "pluno-pa-widget__empty pluno-pa-widget__morning-report-title", f.textContent = c.opening, y.appendChild(f);
2986
+ const w = document.createElement("h2");
2987
+ w.className = "pluno-pa-widget__empty pluno-pa-widget__morning-report-title", w.textContent = c.opening, y.appendChild(w);
2987
2988
  } else
2988
2989
  y.appendChild(Fo());
2989
2990
  const ve = c?.prompts ?? r.starterPrompts, oe = document.createElement("div");
2990
2991
  if (oe.className = ve.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", ve.length === 0 && !r.starterPromptsLoading && oe.setAttribute("aria-hidden", "true"), ve.length > 0)
2991
- for (const f of ve) {
2992
+ for (const w of ve) {
2992
2993
  const E = document.createElement("button");
2993
- E.type = "button", E.className = "pluno-pa-widget__starter-prompt", E.textContent = `"${f}"`, E.addEventListener("click", () => {
2994
- P(f);
2994
+ E.type = "button", E.className = "pluno-pa-widget__starter-prompt", E.textContent = `"${w}"`, E.addEventListener("click", () => {
2995
+ P(w);
2995
2996
  }), oe.appendChild(E);
2996
2997
  }
2997
2998
  else if (r.starterPromptsLoading) {
2998
- const f = document.createElement("button");
2999
- f.type = "button", f.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder pluno-pa-widget__starter-prompt--loading", f.disabled = !0, f.tabIndex = -1, f.textContent = "Generating example tasks...", oe.appendChild(f);
2999
+ const w = document.createElement("button");
3000
+ w.type = "button", w.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder pluno-pa-widget__starter-prompt--loading", w.disabled = !0, w.tabIndex = -1, w.textContent = "Generating example tasks...", oe.appendChild(w);
3000
3001
  } else
3001
- for (let f = 0; f < ma; f += 1) {
3002
+ for (let w = 0; w < ma; w += 1) {
3002
3003
  const E = document.createElement("button");
3003
3004
  E.type = "button", E.className = "pluno-pa-widget__starter-prompt pluno-pa-widget__starter-prompt--placeholder", E.disabled = !0, E.tabIndex = -1, E.textContent = "", oe.appendChild(E);
3004
3005
  }
3005
3006
  if (y.appendChild(oe), c) {
3006
- const f = document.createElement("button");
3007
- f.type = "button", f.className = "pluno-pa-widget__morning-report-snooze", f.textContent = "Snooze morning report", f.addEventListener("click", C), y.appendChild(f);
3007
+ const w = document.createElement("button");
3008
+ w.type = "button", w.className = "pluno-pa-widget__morning-report-snooze", w.textContent = "Snooze morning report", w.addEventListener("click", C), y.appendChild(w);
3008
3009
  }
3009
3010
  h.clear(), B(y), B(t), wo(e, Ue);
3010
3011
  return;
3011
3012
  }
3012
3013
  let F = null, $ = null, Z = [], Le = [];
3013
- const K = W.length - 1, ut = K >= 0 && xn(W[K]), Te = Br(W);
3014
+ const V = W.length - 1, ut = V >= 0 && xn(W[V]), Te = Br(W);
3014
3015
  let he = !1;
3015
3016
  const me = () => {
3016
3017
  if (Z.length === 0)
@@ -3033,7 +3034,7 @@ function Nr(e, t, n, o, i, r, l, p, s, g, u, h, k, S, P, U, c, C, m, D, M, A) {
3033
3034
  for (let y = 0; y < W.length; y += 1) {
3034
3035
  const L = W[y];
3035
3036
  if (L.role === "tool" && L.integrationAuthRequest && M) {
3036
- const f = Rr(
3037
+ const w = Rr(
3037
3038
  L.integrationAuthRequest,
3038
3039
  M.states.get(
3039
3040
  L.integrationAuthRequest.authRequestId
@@ -3042,7 +3043,7 @@ function Nr(e, t, n, o, i, r, l, p, s, g, u, h, k, S, P, U, c, C, m, D, M, A) {
3042
3043
  },
3043
3044
  M.onConnect
3044
3045
  );
3045
- Le.push(f);
3046
+ Le.push(w);
3046
3047
  continue;
3047
3048
  }
3048
3049
  if (L.role === "tool") {
@@ -3050,7 +3051,7 @@ function Nr(e, t, n, o, i, r, l, p, s, g, u, h, k, S, P, U, c, C, m, D, M, A) {
3050
3051
  continue;
3051
3052
  }
3052
3053
  if (xn(L)) {
3053
- if (y !== K)
3054
+ if (y !== V)
3054
3055
  continue;
3055
3056
  if (me()) {
3056
3057
  if (!he) {
@@ -3066,22 +3067,22 @@ function Nr(e, t, n, o, i, r, l, p, s, g, u, h, k, S, P, U, c, C, m, D, M, A) {
3066
3067
  if (L.role === "system") {
3067
3068
  if (L.dataType === "run_error" || L.dataType === "run_status") {
3068
3069
  me();
3069
- const f = document.createElement("div"), E = L.dataType === "run_error";
3070
- if (f.className = E ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", f.textContent = yn(
3070
+ const w = document.createElement("div"), E = L.dataType === "run_error";
3071
+ if (w.className = E ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", w.textContent = yn(
3071
3072
  L.content
3072
3073
  ), E && L.securitySettingsUrl) {
3073
3074
  const q = document.createElement("a");
3074
- q.className = "pluno-pa-widget__error-retry", q.href = L.securitySettingsUrl, q.target = "_blank", q.rel = "noreferrer", q.textContent = "Security settings", f.appendChild(q);
3075
+ q.className = "pluno-pa-widget__error-retry", q.href = L.securitySettingsUrl, q.target = "_blank", q.rel = "noreferrer", q.textContent = "Security settings", w.appendChild(q);
3075
3076
  }
3076
- B(f), F = E ? f : null, $ = E ? null : f, z();
3077
+ B(w), F = E ? w : null, $ = E ? null : w, z();
3077
3078
  }
3078
3079
  continue;
3079
3080
  }
3080
3081
  L.role === "user" && z();
3081
3082
  const I = me(), ve = yn(L.content);
3082
3083
  if (L.role === "assistant" && !I) {
3083
- const f = Jo(S());
3084
- B(f), F = null, $ = f;
3084
+ const w = Jo(S());
3085
+ B(w), F = null, $ = w;
3085
3086
  }
3086
3087
  const oe = Dr(
3087
3088
  L,
@@ -3401,9 +3402,9 @@ function qr(e, t) {
3401
3402
  P.className = "pluno-pa-widget__share-dialog-hint", P.textContent = "Post draft opens prefilled on supported platforms.", k.appendChild(P);
3402
3403
  const U = document.createElement("footer");
3403
3404
  U.className = "pluno-pa-widget__share-dialog-platforms";
3404
- for (const c of Vr(e)) {
3405
+ for (const c of Kr(e)) {
3405
3406
  const C = document.createElement("a");
3406
- C.href = c.href, C.target = "_blank", C.rel = "noopener noreferrer", C.title = c.label, C.setAttribute("aria-label", `Open ${c.label}`), C.appendChild(Kr(c.id)), U.appendChild(C);
3407
+ C.href = c.href, C.target = "_blank", C.rel = "noopener noreferrer", C.title = c.label, C.setAttribute("aria-label", `Open ${c.label}`), C.appendChild(Vr(c.id)), U.appendChild(C);
3407
3408
  }
3408
3409
  if (k.appendChild(U), o.appendChild(k), t.socialPostRewardsUrl) {
3409
3410
  const c = document.createElement("div");
@@ -3421,7 +3422,7 @@ function jr(e, t) {
3421
3422
  o.preventDefault(), o.stopPropagation(), await t() && (n.textContent = "Copied ✓");
3422
3423
  }), n;
3423
3424
  }
3424
- function Vr(e) {
3425
+ function Kr(e) {
3425
3426
  const t = e.linkedinPost.trim(), n = e.xPost.trim();
3426
3427
  return [
3427
3428
  {
@@ -3441,36 +3442,36 @@ function Vr(e) {
3441
3442
  }
3442
3443
  ];
3443
3444
  }
3444
- function Kr(e) {
3445
+ function Vr(e) {
3445
3446
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3446
- return t.setAttribute("class", "pluno-pa-widget__share-dialog-platform-logo"), t.setAttribute("viewBox", "0 0 32 32"), t.setAttribute("aria-hidden", "true"), e === "linkedin" ? (V(t, "M6.7 13.2c.4 4.1.2 8.1.1 12.3"), V(
3447
+ return t.setAttribute("class", "pluno-pa-widget__share-dialog-platform-logo"), t.setAttribute("viewBox", "0 0 32 32"), t.setAttribute("aria-hidden", "true"), e === "linkedin" ? (K(t, "M6.7 13.2c.4 4.1.2 8.1.1 12.3"), K(
3447
3448
  t,
3448
3449
  "M6.4 6.9c.6-.5 1.6-.5 2.1.1.7.7.5 1.8-.2 2.3-.8.5-1.9.2-2.3-.6-.2-.6 0-1.3.4-1.8Z"
3449
- ), V(t, "M14.4 13.3c.1 3.8.1 7.8 0 11.9"), V(
3450
+ ), K(t, "M14.4 13.3c.1 3.8.1 7.8 0 11.9"), K(
3450
3451
  t,
3451
3452
  "M14.8 16.2c1.2-2 3-3.1 5.1-2.9 3.4.3 4.8 2.7 4.8 6.2 0 1.9-.1 3.8-.1 5.8"
3452
- ), V(t, "M20 18c.1 2.2.1 4.7 0 7.2"), t) : e === "x" ? (V(t, "M7.2 7.4c5.6 6.4 10.9 12.2 17.7 17.2"), V(t, "M24.4 7.2c-5.1 6.3-10.6 11.8-17 17.8"), V(t, "M9.1 8.2c5.1 5.6 9.7 10.8 15 15.5", "0.55"), t) : (V(
3453
+ ), K(t, "M20 18c.1 2.2.1 4.7 0 7.2"), t) : e === "x" ? (K(t, "M7.2 7.4c5.6 6.4 10.9 12.2 17.7 17.2"), K(t, "M24.4 7.2c-5.1 6.3-10.6 11.8-17 17.8"), K(t, "M9.1 8.2c5.1 5.6 9.7 10.8 15 15.5", "0.55"), t) : (K(
3453
3454
  t,
3454
3455
  "M10.2 6.4c3.8-.3 8-.3 11.6.1 2.5.3 3.8 1.8 4 4 .4 3.3.4 7.4 0 10.9-.3 2.4-1.7 3.8-4 4.1-3.8.4-8.2.4-11.8 0-2.3-.3-3.7-1.8-4-4.1-.4-3.5-.3-7.8.1-11.1.2-2.2 1.8-3.6 4.1-3.9Z"
3455
- ), V(
3456
+ ), K(
3456
3457
  t,
3457
3458
  "M11 7.3c3.4-.4 7.1-.4 10.2.1 2 .3 3.1 1.4 3.4 3.2.4 3 .4 6.6.1 9.9-.3 2.2-1.3 3.3-3.3 3.7-3.2.5-7.2.5-10.5.1",
3458
3459
  "0.48"
3459
- ), V(
3460
+ ), K(
3460
3461
  t,
3461
3462
  "M12.1 16.1c.1-2.4 1.8-4.1 4-4.2 2.4-.1 4.2 1.6 4.3 4 .1 2.3-1.6 4.1-3.9 4.2-2.6.2-4.3-1.5-4.4-4Z"
3462
- ), V(
3463
+ ), K(
3463
3464
  t,
3464
3465
  "M22 10.7c.3-.1.7 0 .9.3.2.4.1.8-.2 1-.4.2-.8.1-1-.2-.2-.4-.1-.8.3-1.1Z"
3465
3466
  ), t);
3466
3467
  }
3467
- function V(e, t, n) {
3468
+ function K(e, t, n) {
3468
3469
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
3469
3470
  o.setAttribute("d", t), n && o.setAttribute("opacity", n), e.appendChild(o);
3470
3471
  }
3471
3472
  function Yr() {
3472
3473
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3473
- return e.setAttribute("class", "pluno-pa-widget__share-dialog-external-icon"), e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("aria-hidden", "true"), V(e, "M14 5h5v5"), V(e, "M19 5l-8 8"), V(
3474
+ return e.setAttribute("class", "pluno-pa-widget__share-dialog-external-icon"), e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("aria-hidden", "true"), K(e, "M14 5h5v5"), K(e, "M19 5l-8 8"), K(
3474
3475
  e,
3475
3476
  "M18 13v5a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h5"
3476
3477
  ), e;
package/dist/widget.d.ts CHANGED
@@ -91,7 +91,7 @@ export type ProductAgentWidgetHandle = {
91
91
  updateAppearance: (appearance: Pick<ProductAgentWidgetOptions, "accentColor" | "colorScheme" | "fontFamily" | "scribbleStyle">) => void;
92
92
  updateBillingStatus: (billingStatus: ProductAgentWidgetBillingStatus | null | undefined) => void;
93
93
  updateAuthGate: (options: Pick<ProductAgentWidgetOptions, "loginRequired" | "loginButtonLabel" | "loginUrl" | "signupRequired" | "signupButtonLabel" | "signupUrl">) => void;
94
- openPanel: (options?: {
94
+ openPanel: (initialValueOrOptions?: string | {
95
95
  focusComposer?: boolean;
96
96
  }) => void;
97
97
  closePanel: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluno/product-agent-web",
3
- "version": "0.1.109",
3
+ "version": "0.1.110",
4
4
  "description": "Browser SDK and default widget for embedding Pluno Product Agent into customer web apps.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",