@levo-so/studio 0.3.10 → 0.3.12

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.
@@ -8,7 +8,7 @@ var s = {
8
8
  title: "_title_s7k8g_7",
9
9
  subtitle: "_subtitle_s7k8g_14",
10
10
  formWrapper: "_formWrapper_s7k8g_20"
11
- }, c = r(() => import("./PendingApprovalCard-DbYp0nSk.js")), l = ({ logo: r, siteName: l, page: u }) => {
11
+ }, c = r(() => import("./PendingApprovalCard-Cf58Fj0h.js")), l = ({ logo: r, siteName: l, page: u }) => {
12
12
  let [d, f] = i(!1), [p, m] = i(!1), h = u.access?.find((e) => e.kind === "gating" && e.enabled)?.options;
13
13
  return p ? /* @__PURE__ */ a(n, {
14
14
  fallback: /* @__PURE__ */ a("div", {}),
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { r as e } from "./dist-D5mTOitS.js";
2
+ import { r as e } from "./dist-CveI0e3_.js";
3
3
  import { t } from "./card-5ooLmYSr.js";
4
4
  import { t as n } from "./MessageFooter-K4Zd_eFO.js";
5
5
  import { useState as r } from "react";
@@ -75,7 +75,7 @@ var Q = [
75
75
  ...i,
76
76
  children: o
77
77
  }) : null;
78
- }, te = /* @__PURE__ */ d({ PopupBody: () => oe }), ne = b(() => import("./dist-D5mTOitS.js").then((e) => e.t).then((e) => ({ default: e.CollectionFormBuilder }))), re = a({ baseSpacing: ".625rem" }), ie = { style: l({ form: { gap: "1rem" } }) }, ae = {
78
+ }, te = /* @__PURE__ */ d({ PopupBody: () => oe }), ne = b(() => import("./dist-CveI0e3_.js").then((e) => e.t).then((e) => ({ default: e.CollectionFormBuilder }))), re = a({ baseSpacing: ".625rem" }), ie = { style: l({ form: { gap: "1rem" } }) }, ae = {
79
79
  left: u,
80
80
  center: h,
81
81
  right: p
@@ -104,7 +104,7 @@ var oe = (e) => (e ?? "16:9").replace(":", " / "), se = (e) => {
104
104
  ...i,
105
105
  children: n
106
106
  }), t[15] = n, t[16] = i, t[17] = g, t[18] = _) : _ = t[18], _;
107
- }, ue = F(() => import("./PopupBody-BI-MJqmd-BrzdFaaE.js").then((e) => e.n).then((e) => ({ default: e.PopupBody }))), de = (e) => {
107
+ }, ue = F(() => import("./PopupBody-BI-MJqmd-Cj3VgwnW.js").then((e) => e.n).then((e) => ({ default: e.PopupBody }))), de = (e) => {
108
108
  let t = D(7), { size: n } = e, r = n ?? "medium", i;
109
109
  t[0] === r ? i = t[1] : (i = E({ size: r }), t[0] = r, t[1] = i);
110
110
  let a, o, s;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { c as e } from "./dist-D5mTOitS.js";
2
+ import { c as e } from "./dist-CveI0e3_.js";
3
3
  import { n as t } from "./AuthProvider-B5NfFwbG.js";
4
4
  import { t as n } from "./Spinner-D5spB_Mv.js";
5
5
  import { t as r } from "./card-5ooLmYSr.js";
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { t as e } from "./Button-Dza3e6Mv.js";
2
+ import { t as e } from "./Button-CYXSFoBr.js";
3
3
  import { n as t } from "./AuthProvider-B5NfFwbG.js";
4
4
  import { t as n } from "./cn-B6c1DjO_.js";
5
5
  import { n as r, t as i } from "./StripePaymentModal-CiKqmQwK.js";
6
- import { BillingStep as a } from "./BillingStep-CvRmZGdq.js";
6
+ import { BillingStep as a } from "./BillingStep-BG4hhiaE.js";
7
7
  import { errorHandler as o, useLevo as s } from "@levo-so/react";
8
8
  import { useEffect as c, useRef as l, useState as u } from "react";
9
9
  import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
package/collection.d.ts CHANGED
@@ -87,6 +87,12 @@ declare interface ILevoFormContext {
87
87
  uiConfig?: {
88
88
  hideSectionHeadings?: boolean;
89
89
  hideFormHeading?: boolean;
90
+ /**
91
+ * Suppress the built-in success overlay, for hosts that render their own confirmation
92
+ * (or navigate away) from `onSuccess`. The form still submits and still resets itself —
93
+ * it just stays on screen instead of being replaced by the thank-you card.
94
+ */
95
+ hideSuccessScreen?: boolean;
90
96
  };
91
97
  toastConfig?: {
92
98
  showSuccessToast?: boolean;
package/collection.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as e, c as t, i as n, n as r, o as i, r as a, s as o } from "./dist-D5mTOitS.js";
1
+ import { a as e, c as t, i as n, n as r, o as i, r as a, s as o } from "./dist-CveI0e3_.js";
2
2
  export { t as CollectionForm, a as CollectionFormBuilder, r as CollectionFormRenderer, n as FormBuilder, i as LevoFormProvider, e as useLevoForm, o as useLevoFormContext };
@@ -2324,14 +2324,14 @@ var Br = ((e) => (t) => t ? zr(e, t) : e)({
2324
2324
  }, oi = (e) => {
2325
2325
  localStorage.removeItem(`${e}-${ri.FORM_VALUES}`);
2326
2326
  }, si = ({ schema: e, originalSchema: t, onSubmitSuccess: n, onSubmitError: r, onInit: i, setFormErrorAfterSubmit: a = !0 }) => {
2327
- let o = R(() => e, [e]), s = R(() => t || o, [t, o]), c = A(), { toastConfig: l, onSuccess: u, onError: d, isLoggedIn: f, isDisabled: p, externalInitialValues: m = {}, account: h, preview: g } = ti(), [_, v] = B({
2327
+ let o = R(() => e, [e]), s = R(() => t || o, [t, o]), c = A(), { toastConfig: l, onSuccess: u, onError: d, isLoggedIn: f, isDisabled: p, externalInitialValues: m = {}, account: h, preview: g, uiConfig: _ } = ti(), [v, y] = B({
2328
2328
  contentId: null,
2329
2329
  publishedId: null
2330
- }), [y, b] = B(!1), [x, S] = B(!1), [C, w] = B(!1), T = z({}), E = z({}), O = (e) => {
2330
+ }), [b, x] = B(!1), [S, C] = B(!1), [w, T] = B(!1), E = z({}), O = z({}), j = (e) => {
2331
2331
  if (!o?.sections) return null;
2332
2332
  for (let t of o.sections) for (let n of t?.fields ?? []) if (n?.key === e) return n?.kind ?? null;
2333
2333
  return null;
2334
- }, j = () => {
2334
+ }, M = () => {
2335
2335
  let e = {};
2336
2336
  try {
2337
2337
  if (typeof window < "u") {
@@ -2339,7 +2339,7 @@ var Br = ((e) => (t) => t ? zr(e, t) : e)({
2339
2339
  for (let [n, r] of t.entries()) {
2340
2340
  let [t, i] = n.split("-");
2341
2341
  if (t === "lf" && i && r) try {
2342
- let t = JSON.parse(r), n = O(i);
2342
+ let t = JSON.parse(r), n = j(i);
2343
2343
  e[i] = typeof t == "number" && !(n === "number" || n === "currency") ? r : t;
2344
2344
  } catch {
2345
2345
  e[i] = r;
@@ -2354,112 +2354,117 @@ var Br = ((e) => (t) => t ? zr(e, t) : e)({
2354
2354
  ...n,
2355
2355
  ...e
2356
2356
  };
2357
- T.current = {
2357
+ E.current = {
2358
2358
  ...t,
2359
2359
  ...r,
2360
- ...T.current
2360
+ ...E.current
2361
2361
  };
2362
- }, M = ae({
2362
+ }, N = ae({
2363
2363
  mode: "onTouched",
2364
2364
  disabled: p
2365
- }), { formState: N } = M, P = (e) => {
2366
- T.current = {
2367
- ...T.current || {},
2365
+ }), { formState: P } = N, F = (e) => {
2366
+ E.current = {
2367
+ ...E.current || {},
2368
2368
  ...e
2369
2369
  };
2370
2370
  };
2371
2371
  return L(() => {
2372
2372
  if (o && c?.collection) {
2373
- if (j(), !_.contentId && !_.publishedId && !g) {
2373
+ if (M(), !v.contentId && !v.publishedId && !g) {
2374
2374
  let e = o?.allow_multiple === !1;
2375
2375
  if (o?.allow_draft) {
2376
2376
  if (f) {
2377
- b(!0), c?.collection?.getDraftEntry(o?.key).then((t) => {
2377
+ x(!0), c?.collection?.getDraftEntry(o?.key).then((t) => {
2378
2378
  let n = t?.content?.data;
2379
2379
  if (n === null) {
2380
- S(!0);
2380
+ C(!0);
2381
2381
  return;
2382
2382
  }
2383
- S(!1);
2383
+ C(!1);
2384
2384
  let r = e && Array.isArray(n) && n?.find((e) => e?._status === "published") || null;
2385
- if (r?._id) T.current = {
2386
- ...T.current || {},
2385
+ if (r?._id) E.current = {
2386
+ ...E.current || {},
2387
2387
  ...r
2388
- }, v({
2388
+ }, y({
2389
2389
  contentId: null,
2390
2390
  publishedId: r._id
2391
2391
  });
2392
2392
  else {
2393
2393
  let e = Array.isArray(n) ? n?.filter((e) => e?._status === "draft") : [], t = e?.[e.length - 1] || null;
2394
- t?._id && (T.current = {
2395
- ...T.current || {},
2394
+ t?._id && (E.current = {
2395
+ ...E.current || {},
2396
2396
  ...t
2397
- }, v({
2397
+ }, y({
2398
2398
  contentId: t._id,
2399
2399
  publishedId: null
2400
2400
  }));
2401
2401
  }
2402
2402
  }).catch((e) => (c?.logger?.error("Failed to get draft entry", { exception: e }), null)).finally(() => {
2403
- E.current = { ...T.current }, M.reset({ ...T?.current }), i?.(T.current), b(!1);
2403
+ O.current = { ...E.current }, N.reset({ ...E?.current }), i?.(E.current), x(!1);
2404
2404
  });
2405
2405
  return;
2406
2406
  }
2407
2407
  let t = ii(o?.key);
2408
- t && (T.current = {
2409
- ...T.current || {},
2408
+ t && (E.current = {
2409
+ ...E.current || {},
2410
2410
  ...t
2411
2411
  });
2412
2412
  }
2413
2413
  }
2414
- E.current = { ...T.current }, M.reset({ ...T?.current }), i?.(T.current);
2414
+ O.current = { ...E.current }, N.reset({ ...E?.current }), i?.(E.current);
2415
2415
  }
2416
2416
  }, [o, f]), L(() => {
2417
- let { isSubmitSuccessful: e, isValid: t } = N;
2418
- e && t && (E.current = { ...T.current }, M.reset({
2419
- ...T?.current,
2417
+ let { isSubmitSuccessful: e, isValid: t } = P;
2418
+ e && t && (O.current = { ...E.current }, N.reset({
2419
+ ...E?.current,
2420
2420
  __captcha: "verified"
2421
- }), i?.(T.current));
2422
- }, [N]), L(() => {
2423
- o && (_.contentId || _.publishedId) && oi(o?.key);
2424
- }, [_]), {
2425
- methods: M,
2426
- isLoading: y,
2427
- isError: x,
2428
- contentId: _.contentId,
2429
- publishedId: _.publishedId,
2430
- allFormValues: T.current,
2421
+ }), i?.(E.current));
2422
+ }, [P]), L(() => {
2423
+ o && (v.contentId || v.publishedId) && oi(o?.key);
2424
+ }, [v]), {
2425
+ methods: N,
2426
+ isLoading: b,
2427
+ isError: S,
2428
+ contentId: v.contentId,
2429
+ publishedId: v.publishedId,
2430
+ allFormValues: E.current,
2431
2431
  handleContentId: (e) => {
2432
- e && e !== _.contentId && !_.publishedId && v({
2432
+ e && e !== v.contentId && !v.publishedId && y({
2433
2433
  contentId: e,
2434
2434
  publishedId: null
2435
2435
  });
2436
2436
  },
2437
- appendFormValues: P,
2437
+ appendFormValues: F,
2438
2438
  submitToRemote: async (e) => {
2439
- if (P(e), !(g || !c?.collection || !s)) try {
2440
- let e = nt(T?.current, s, E.current), t = null;
2441
- if (t = _.publishedId ? await c?.collection?.editDraftEntry(s?.key, _.publishedId, e) : _.contentId ? await c?.collection?.submitDraftEntry(s?.key, e) : await c?.collection?.saveCollectionData({
2439
+ if (F(e), !(g || !c?.collection || !s)) try {
2440
+ let e = nt(E?.current, s, O.current), t = null;
2441
+ if (t = v.publishedId ? await c?.collection?.editDraftEntry(s?.key, v.publishedId, e) : v.contentId ? await c?.collection?.submitDraftEntry(s?.key, e) : await c?.collection?.saveCollectionData({
2442
2442
  collection_id: s?.id,
2443
2443
  data: e
2444
2444
  }), t?.content?.data) {
2445
2445
  let e = t?.content?.meta?.booking_config?.enabled;
2446
- l?.showSuccessToast && !(l?.suppressOnBooking && e) && k(l.successToastText || "Form submitted successfully."), T.current = {}, j(), oi(s?.key), v({
2446
+ l?.showSuccessToast && !(l?.suppressOnBooking && e) && k(l.successToastText || "Form submitted successfully."), E.current = {}, M(), oi(s?.key), y({
2447
2447
  contentId: null,
2448
2448
  publishedId: null
2449
- }), w(!0), u && u({
2450
- schemaId: s?.id,
2451
- response: t?.content?.data,
2452
- meta: t?.content?.meta
2453
- }), n && n();
2449
+ }), _?.hideSuccessScreen || T(!0);
2450
+ try {
2451
+ u && u({
2452
+ schemaId: s?.id,
2453
+ response: t?.content?.data,
2454
+ meta: t?.content?.meta
2455
+ }), n && n();
2456
+ } catch (e) {
2457
+ c?.logger?.error("Form success callback threw after a saved entry", { exception: J(e) });
2458
+ }
2454
2459
  return;
2455
2460
  }
2456
2461
  throw Error("Failed to save form details, API response invalid");
2457
2462
  } catch (e) {
2458
- D(e), e instanceof G ? (e?.hasFieldErrors && a && ni(e?.fieldErrors, M.setError), r && r(e.fieldErrors || []), d && d(e)) : d && d(e?.response?.data || e);
2463
+ D(e), e instanceof G ? (e?.hasFieldErrors && a && ni(e?.fieldErrors, N.setError), r && r(e.fieldErrors || []), d && d(e)) : d && d(e?.response?.data || e);
2459
2464
  }
2460
2465
  },
2461
- showSuccessOverlay: C,
2462
- dismissSuccessOverlay: () => w(!1)
2466
+ showSuccessOverlay: w,
2467
+ dismissSuccessOverlay: () => T(!1)
2463
2468
  };
2464
2469
  }, ci = "_1jed92w2", li = "_1jed92w3 _1jed92w1", ui = "_1jed92w4 _1jed92w1", di = "_1jed92w5 _1jed92w1", fi = "_1jed92w6 _1jed92w1", pi = () => {
2465
2470
  let e = E(1), t;
package/index.d.ts CHANGED
@@ -1544,6 +1544,12 @@ declare interface ILevoFormContext {
1544
1544
  uiConfig?: {
1545
1545
  hideSectionHeadings?: boolean;
1546
1546
  hideFormHeading?: boolean;
1547
+ /**
1548
+ * Suppress the built-in success overlay, for hosts that render their own confirmation
1549
+ * (or navigate away) from `onSuccess`. The form still submits and still resets itself —
1550
+ * it just stays on screen instead of being replaced by the thank-you card.
1551
+ */
1552
+ hideSuccessScreen?: boolean;
1547
1553
  };
1548
1554
  toastConfig?: {
1549
1555
  showSuccessToast?: boolean;
@@ -2664,7 +2670,7 @@ export declare const PopoverTrigger: WithBlockPropsComponent<BasePopoverTriggerP
2664
2670
  * Plug-and-play popup integration for React apps.
2665
2671
  * Waits for identity context (session hydrated + identity resolved), then
2666
2672
  * fetches active popups and lazy-loads the renderer only when popups exist.
2667
- * Works without insights network — gates on local readiness, not /welcome.
2673
+ * Works without insights network: gates on local readiness only, nothing waits on a request.
2668
2674
  * Must be placed inside a `<LevoProvider>`.
2669
2675
  */
2670
2676
  export declare const PopupLoader: React.FC<IPopupLoaderProps>;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import { l as e, r as t } from "./dist-D5mTOitS.js";
2
+ import { l as e, r as t } from "./dist-CveI0e3_.js";
3
3
  import { r as n } from "./themeMapping-Bi9Rcr5G-C7UXWE6o.js";
4
- import { _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, i as d, l as f, m as p, n as m, o as h, p as g, r as _, s as v, t as y, u as b, v as x, y as S } from "./Button-Dza3e6Mv.js";
4
+ import { _ as r, a as i, b as a, c as o, d as s, f as c, g as l, h as u, i as d, l as f, m as p, n as m, o as h, p as g, r as _, s as v, t as y, u as b, v as x, y as S } from "./Button-CYXSFoBr.js";
5
5
  import { n as C, t as w } from "./AuthProvider-B5NfFwbG.js";
6
6
  import { n as T, t as E } from "./ModalManager-CzH36UIk.js";
7
7
  import { t as D } from "./cn-B6c1DjO_.js";
@@ -3800,7 +3800,7 @@ var Di = (e, t) => {
3800
3800
  getAllBlocks() {
3801
3801
  return this.blocks;
3802
3802
  }
3803
- }, yo = vo.getInstance(), bo = nt(() => import("./kbChat-BLHDnA-T.js"), { ssr: !1 }), xo = () => {
3803
+ }, yo = vo.getInstance(), bo = nt(() => import("./kbChat-DfcTNf0n.js"), { ssr: !1 }), xo = () => {
3804
3804
  let e = rt(), [t, n] = R(void 0), r = e?.events;
3805
3805
  return F(() => {
3806
3806
  if (typeof window > "u" || !r) return;
@@ -4042,7 +4042,7 @@ var Do = ({ site: e }) => {
4042
4042
  siteSlug: e?.slug,
4043
4043
  siteName: e?.name
4044
4044
  })] });
4045
- }, Oo = { loadingContainer: "_loadingContainer_1d4on_1" }, ko = Pe(() => import("./LoginCard-B_anBE4b.js")), Ao = Pe(() => import("./EntryCard-BpcaCqXU.js")), jo = Pe(() => import("./MessageCard-Nsxr98n6.js")), Mo = Pe(() => import("./ProfileCard-DmAnVf5R.js")), No = {
4045
+ }, Oo = { loadingContainer: "_loadingContainer_1d4on_1" }, ko = Pe(() => import("./LoginCard-HUsLBH9Y.js")), Ao = Pe(() => import("./EntryCard-Btvieg4y.js")), jo = Pe(() => import("./MessageCard-Nsxr98n6.js")), Mo = Pe(() => import("./ProfileCard-WC8XhXzF.js")), No = {
4046
4046
  "authentication.NOT_LOGGED_IN": ({ logo: e, siteName: t, page: n }) => /* @__PURE__ */ B(je, {
4047
4047
  fallback: /* @__PURE__ */ B("div", {}),
4048
4048
  children: /* @__PURE__ */ B(ko, {
@@ -6092,7 +6092,7 @@ var el = d(qc), tl = Ne(({ children: e, className: t, elementKey: n, generatedCl
6092
6092
  children: [/* @__PURE__ */ B(Vc, { backgroundVideo: a?.backgroundVideo }), e]
6093
6093
  }));
6094
6094
  tl.displayName = "BaseContainer";
6095
- var nl = d(tl), rl = Pe(() => import("./dist-D5mTOitS.js").then((e) => e.t).then((e) => ({ default: e.CollectionForm }))), il = d(({ elementKey: e, generatedClassName: t, config: n, className: r, initialValues: i, theme: a, onSubmit: o, isLoading: s }) => /* @__PURE__ */ B("div", {
6095
+ var nl = d(tl), rl = Pe(() => import("./dist-CveI0e3_.js").then((e) => e.t).then((e) => ({ default: e.CollectionForm }))), il = d(({ elementKey: e, generatedClassName: t, config: n, className: r, initialValues: i, theme: a, onSubmit: o, isLoading: s }) => /* @__PURE__ */ B("div", {
6096
6096
  "data-levo_element_key": e,
6097
6097
  className: D(r, t),
6098
6098
  children: /* @__PURE__ */ B(je, {
@@ -6114,7 +6114,7 @@ var nl = d(tl), rl = Pe(() => import("./dist-D5mTOitS.js").then((e) => e.t).then
6114
6114
  isLoading: s
6115
6115
  })
6116
6116
  })
6117
- })), al = Pe(() => import("./dist-D5mTOitS.js").then((e) => e.t).then((e) => ({ default: e.CollectionFormRenderer }))), ol = Pe(() => import("./bookingCard-CLhIpOpR.js").then((e) => ({ default: e.BookingCard }))), sl = Pe(() => import("./BillingStep-CvRmZGdq.js").then((e) => ({ default: e.BillingStep }))), cl = d(({ elementKey: e, generatedClassName: t, config: r, className: i, initialValues: a, theme: o }) => {
6117
+ })), al = Pe(() => import("./dist-CveI0e3_.js").then((e) => e.t).then((e) => ({ default: e.CollectionFormRenderer }))), ol = Pe(() => import("./bookingCard-CmsUeDr3.js").then((e) => ({ default: e.BookingCard }))), sl = Pe(() => import("./BillingStep-BG4hhiaE.js").then((e) => ({ default: e.BillingStep }))), cl = d(({ elementKey: e, generatedClassName: t, config: r, className: i, initialValues: a, theme: o }) => {
6118
6118
  let s = M(), { workspace: c, isLoggedIn: l, isAuthLoaded: u } = C(), d = I(() => {
6119
6119
  if (!r?.theme && !o) return;
6120
6120
  let e = r?.theme;
@@ -0,0 +1,173 @@
1
+ "use client";
2
+ import { C as e, a as t, c as n, f as r, g as i, h as a, l as o, m as s, n as c, o as l, p as u, r as d, t as f, u as p } from "./pillChrome-QDjBETmP.js";
3
+ import { useEffect as m, useRef as h, useState as g } from "react";
4
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
5
+ import { ArrowUp as y, Sparkles as b } from "lucide-react";
6
+ //#region ../../libraries/ai-chat/src/useActiveAgent.ts
7
+ var x = (t) => e("active_agent", t), S = (e) => {
8
+ let t = x(e);
9
+ if (!t || typeof window > "u") return null;
10
+ try {
11
+ let e = window.sessionStorage.getItem(t);
12
+ if (!e) return null;
13
+ let n = JSON.parse(e);
14
+ return typeof n?.id != "string" || n.id.length === 0 ? null : n;
15
+ } catch {
16
+ return null;
17
+ }
18
+ }, C = (e, t) => {
19
+ let n = x(e);
20
+ if (!(!n || typeof window > "u")) try {
21
+ t === null ? window.sessionStorage.removeItem(n) : window.sessionStorage.setItem(n, JSON.stringify(t));
22
+ } catch {}
23
+ }, w = ({ url: e, workspaceId: t, headers: n, path: r }) => {
24
+ let [i, a] = g({ status: "loading" });
25
+ m(() => {
26
+ let e = S(t);
27
+ a(e ? {
28
+ status: "ready",
29
+ agent: e
30
+ } : (e) => e.status === "ready" ? { status: "loading" } : e);
31
+ }, [t]);
32
+ let o = h(n);
33
+ return o.current = n, m(() => {
34
+ if (!t || !e) return;
35
+ let n = r ? `${e}${e.includes("?") ? "&" : "?"}path=${encodeURIComponent(r)}` : e, i = new AbortController();
36
+ return (async () => {
37
+ try {
38
+ let e = await fetch(n, {
39
+ method: "GET",
40
+ credentials: "include",
41
+ headers: o.current,
42
+ signal: i.signal
43
+ });
44
+ if (!e.ok) {
45
+ C(t, null), a({ status: "missing" });
46
+ return;
47
+ }
48
+ let r = (await e.json())?.content?.data;
49
+ if (!r || typeof r.id != "string" || r.id.length === 0) {
50
+ C(t, null), a({ status: "missing" });
51
+ return;
52
+ }
53
+ C(t, r), a({
54
+ status: "ready",
55
+ agent: r
56
+ });
57
+ } catch (e) {
58
+ if (e?.name === "AbortError") return;
59
+ console.warn("[levo-kb-chat] active-agent boot failed:", e), a({ status: "error" });
60
+ }
61
+ })(), () => i.abort();
62
+ }, [
63
+ t,
64
+ e,
65
+ r
66
+ ]), i;
67
+ }, T = (...e) => e.filter(Boolean).join(" "), E = () => import("./KBChatWidget-aK7vt64V.js"), D = (e) => {
68
+ let [t, n] = g(null), [r, i] = g(!1), [a, o] = g("");
69
+ return t ? /* @__PURE__ */ _(t, {
70
+ initialOpen: !0,
71
+ initialDraft: a,
72
+ ...e
73
+ }) : /* @__PURE__ */ _(k, {
74
+ siteName: e.siteName,
75
+ draft: a,
76
+ loading: r,
77
+ onDraftChange: o,
78
+ onActivate: () => {
79
+ r || t || (i(!0), E().then((e) => n(() => e.KBChatWidget)).catch((e) => {
80
+ i(!1), console.warn("[levo-kb-chat] widget load failed:", e);
81
+ }));
82
+ },
83
+ onPrefetch: () => {
84
+ E().catch(() => {});
85
+ }
86
+ });
87
+ }, O = () => /* @__PURE__ */ _("span", {
88
+ "aria-hidden": !0,
89
+ className: "h-5 w-5 animate-spin rounded-full border-2 border-current border-t-transparent"
90
+ }), k = ({ siteName: e, draft: i, loading: m, onDraftChange: x, onActivate: S, onPrefetch: C }) => {
91
+ let w = h(null), E = h(null), D = a(e), [k, A] = g(!1);
92
+ return /* @__PURE__ */ _("div", {
93
+ onPointerEnter: C,
94
+ className: T("ai-chat-launcher fixed bottom-8 left-1/2 z-[60] -translate-x-1/2", u),
95
+ children: /* @__PURE__ */ _("div", {
96
+ className: T(c, n, "ai-chat-intro-morph"),
97
+ children: /* @__PURE__ */ v("div", {
98
+ ref: E,
99
+ className: T(p, k && "ai-chat-pill-surface--stacked"),
100
+ children: [
101
+ /* @__PURE__ */ _("button", {
102
+ type: "button",
103
+ onClick: S,
104
+ onFocus: C,
105
+ "aria-label": "Open AI chat",
106
+ className: o,
107
+ children: m ? /* @__PURE__ */ _(O, {}) : /* @__PURE__ */ _(b, { className: "h-5 w-5" })
108
+ }),
109
+ /* @__PURE__ */ v("div", {
110
+ className: d,
111
+ children: [/* @__PURE__ */ _("textarea", {
112
+ ref: w,
113
+ rows: 1,
114
+ autoComplete: "off",
115
+ autoCorrect: "off",
116
+ autoCapitalize: "none",
117
+ inputMode: "text",
118
+ value: i,
119
+ "aria-label": D,
120
+ onFocus: S,
121
+ onChange: (e) => {
122
+ let t = e.currentTarget;
123
+ x(t.value), E.current && A(s(E.current, t));
124
+ },
125
+ className: r
126
+ }), !i && /* @__PURE__ */ _("span", {
127
+ className: T("ai-chat-pill-label pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-[15px] text-transparent", "ai-chat-intro-label"),
128
+ "aria-hidden": !0,
129
+ children: D
130
+ })]
131
+ }),
132
+ /* @__PURE__ */ _("div", {
133
+ className: f,
134
+ children: /* @__PURE__ */ _("button", {
135
+ type: "button",
136
+ onClick: S,
137
+ "aria-label": "Open AI chat",
138
+ className: t,
139
+ style: l,
140
+ children: m ? /* @__PURE__ */ _(O, {}) : /* @__PURE__ */ _(y, { className: "h-5 w-5 stroke-[2.5px]" })
141
+ })
142
+ })
143
+ ]
144
+ })
145
+ })
146
+ });
147
+ }, A = "/.levo/public/api/v1/agents/kb-chat/public", j = (e) => e.replace(/\/v1\/agents\/kb-chat\/public\/?$/, ""), M = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, apiBaseUrl: a = A, authHeaders: o, showBranding: s, siteSlug: c, path: l }) => {
148
+ let u = w({
149
+ url: `${j(a)}/v1/intelligence/site-agent/get-active`,
150
+ workspaceId: e,
151
+ headers: e ? {
152
+ ...i(o),
153
+ "Levo-Workspace": e
154
+ } : i(o),
155
+ path: l
156
+ });
157
+ return u.status === "ready" ? /* @__PURE__ */ _("div", {
158
+ "data-ai-chat-root": !0,
159
+ children: /* @__PURE__ */ _(D, {
160
+ workspaceId: e,
161
+ siteName: t,
162
+ siteLogo: n,
163
+ siteIcon: r,
164
+ agentId: u.agent.id,
165
+ apiBaseUrl: a,
166
+ authHeaders: o,
167
+ showBranding: s,
168
+ siteSlug: c
169
+ })
170
+ }) : null;
171
+ };
172
+ //#endregion
173
+ export { M as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/studio",
3
- "version": "0.3.10",
3
+ "version": "0.3.12",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo Studio components and utilities for building block-based pages",
6
6
  "type": "module",
@@ -123,8 +123,8 @@
123
123
  "react": ">=19",
124
124
  "next": ">=14",
125
125
  "react-dom": ">=19",
126
- "@levo-so/core": "0.3.10",
127
- "@levo-so/react": "0.3.10",
128
- "@levo-so/insights": "0.3.10"
126
+ "@levo-so/insights": "0.3.12",
127
+ "@levo-so/react": "0.3.12",
128
+ "@levo-so/core": "0.3.12"
129
129
  }
130
130
  }
@@ -38,13 +38,13 @@ var e = "disabled:cursor-not-allowed disabled:opacity-40", t = (e) => {
38
38
  let t = e.value.length;
39
39
  e.setSelectionRange(t, t);
40
40
  });
41
- }, l = "w-72", u = "ai-chat-pill-gradient relative rounded-[30px] p-[2px] transition-shadow duration-300", d = "shadow-lg shadow-zinc-950/10", f = "shadow-md", p = "ai-chat-pill-surface min-h-14 w-full rounded-[28px] bg-white p-1.5", m = "ai-chat-pill-surface--stacked", h = "ai-chat-pill-input relative min-w-0", g = "ai-chat-pill-actions flex items-center gap-1.5", _ = "ai-chat-pill-spark flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full text-blue-500 transition-[background-color,transform] duration-150 hover:bg-zinc-50 active:scale-95", v = "flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-[transform,box-shadow] duration-150 hover:scale-105 hover:shadow-md active:scale-95", y = "block h-6 max-h-[120px] w-full resize-none overflow-y-auto bg-transparent text-base text-zinc-900 leading-6 placeholder:text-zinc-400 focus:outline-none", b = 24, x = (e, t) => {
42
- e.classList.remove(m), t.style.height = "auto";
43
- let n = t.scrollHeight > b + 4;
44
- return e.classList.toggle(m, n), s(t, 120), n;
45
- }, S = "ai-chat-pill-label pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-[15px] text-transparent", C = {
41
+ }, l = (e) => typeof e == "function" ? e() : e ?? {}, u = "w-72", d = "ai-chat-pill-gradient relative rounded-[30px] p-[2px] transition-shadow duration-300", f = "shadow-lg shadow-zinc-950/10", p = "shadow-md", m = "ai-chat-pill-surface min-h-14 w-full rounded-[28px] bg-white p-1.5", h = "ai-chat-pill-surface--stacked", g = "ai-chat-pill-input relative min-w-0", _ = "ai-chat-pill-actions flex items-center gap-1.5", v = "ai-chat-pill-spark flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full text-blue-500 transition-[background-color,transform] duration-150 hover:bg-zinc-50 active:scale-95", y = "flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-[transform,box-shadow] duration-150 hover:scale-105 hover:shadow-md active:scale-95", b = "block h-6 max-h-[120px] w-full resize-none overflow-y-auto bg-transparent text-base text-zinc-900 leading-6 placeholder:text-zinc-400 focus:outline-none", x = 24, S = (e, t) => {
42
+ e.classList.remove(h), t.style.height = "auto";
43
+ let n = t.scrollHeight > x + 4;
44
+ return e.classList.toggle(h, n), s(t, 120), n;
45
+ }, C = "ai-chat-pill-label pointer-events-none absolute inset-y-0 left-0 flex max-w-full items-center truncate bg-clip-text font-semibold text-[15px] text-transparent", w = {
46
46
  backgroundColor: "var(--color-brand, #0a0a0a)",
47
47
  color: "var(--color-brand-foreground, #fff)"
48
- }, w = (e) => e ? `Ask ${e}` : "Ask AI";
48
+ }, T = (e) => e ? `Ask ${e}` : "Ask AI";
49
49
  //#endregion
50
- export { o as S, s as _, v as a, r as b, d as c, m as d, y as f, e as g, w as h, S as i, _ as l, x as m, u as n, C as o, l as p, h as r, f as s, g as t, p as u, c as v, a as x, i as y };
50
+ export { o as C, a as S, e as _, y as a, i as b, f as c, h as d, b as f, l as g, T as h, C as i, v as l, S as m, d as n, w as o, u as p, g as r, p as s, _ as t, m as u, s as v, r as x, c as y };