pxengine 0.1.134 → 0.1.136

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.
package/dist/index.cjs CHANGED
@@ -212,6 +212,7 @@ __export(index_exports, {
212
212
  InputWidget: () => InputWidget,
213
213
  InsightDigestCard: () => InsightDigestCard,
214
214
  InsightSummaryCard: () => InsightSummaryCard,
215
+ JOB_SIGNAL_EVENT: () => JOB_SIGNAL_EVENT,
215
216
  KPIStatsCard: () => KPIStatsCard,
216
217
  KbdAtom: () => KbdAtom,
217
218
  KeywordBundlesDisplay: () => KeywordBundlesDisplay,
@@ -272,6 +273,7 @@ __export(index_exports, {
272
273
  ResizablePanel: () => ResizablePanel,
273
274
  ResizablePanelGroup: () => ResizablePanelGroup,
274
275
  RiskSignalCard: () => RiskSignalCard,
276
+ SSE_FALLBACK_POLL_MS: () => SSE_FALLBACK_POLL_MS,
275
277
  ScoreBreakdownCard: () => ScoreBreakdownCard,
276
278
  ScrollArea: () => ScrollArea,
277
279
  ScrollAreaAtom: () => ScrollAreaAtom,
@@ -342,24 +344,28 @@ __export(index_exports, {
342
344
  defaultFetchSelections: () => defaultFetchSelections,
343
345
  defaultPersistSelection: () => defaultPersistSelection,
344
346
  elementToQAField: () => elementToQAField,
347
+ emitJobSignal: () => emitJobSignal,
345
348
  formatQAMessage: () => formatQAMessage,
346
349
  generateFieldsFromData: () => generateFieldsFromData,
347
350
  generateFieldsFromPropDefinitions: () => generateFieldsFromPropDefinitions,
348
351
  getPxAuthToken: () => getPxAuthToken,
349
352
  isInputAtom: () => isInputAtom,
350
353
  notifyPxUnauthorized: () => notifyPxUnauthorized,
354
+ refreshSharedPoll: () => refreshSharedPoll,
351
355
  setPxAuthTokenProvider: () => setPxAuthTokenProvider,
352
356
  setPxUnauthorizedHandler: () => setPxUnauthorizedHandler,
353
357
  submitWidgetToAgent: () => submitWidgetToAgent,
358
+ subscribeJobSignal: () => subscribeJobSignal,
354
359
  th: () => th,
355
360
  useCreatorWidgetPolling: () => useCreatorWidgetPolling,
361
+ useJobSignal: () => useJobSignal,
356
362
  useWidgetTheme: () => useWidgetTheme,
357
363
  withAlpha: () => withAlpha
358
364
  });
359
365
  module.exports = __toCommonJS(index_exports);
360
366
 
361
367
  // src/render/PXEngineRenderer.tsx
362
- var import_react99 = __toESM(require("react"), 1);
368
+ var import_react100 = __toESM(require("react"), 1);
363
369
 
364
370
  // src/atoms/index.ts
365
371
  var atoms_exports = {};
@@ -16119,10 +16125,11 @@ var NextStepCard = ({
16119
16125
  };
16120
16126
 
16121
16127
  // src/molecules/generic/PresentationJobCard/PresentationJobCard.tsx
16122
- var import_react80 = require("react");
16128
+ var import_react81 = require("react");
16123
16129
 
16124
16130
  // src/lib/shared-poll.ts
16125
16131
  var import_react79 = require("react");
16132
+ var SSE_FALLBACK_POLL_MS = 2e4;
16126
16133
  var MAX_RETAINED = 50;
16127
16134
  var RETAIN_TTL_MS = 30 * 60 * 1e3;
16128
16135
  var entries = /* @__PURE__ */ new Map();
@@ -16249,6 +16256,12 @@ function stopSharedPoll(key) {
16249
16256
  entry.stopped = true;
16250
16257
  clearTimer(entry);
16251
16258
  }
16259
+ function refreshSharedPoll(key) {
16260
+ if (!key) return;
16261
+ const entry = entries.get(key);
16262
+ if (!entry || entry.stopped) return;
16263
+ void runPoll(key);
16264
+ }
16252
16265
  function getSharedPollLastData(key) {
16253
16266
  if (!key) return void 0;
16254
16267
  const entry = entries.get(key);
@@ -16285,6 +16298,45 @@ function useSharedPoll(config, onData, onError) {
16285
16298
  }, [key, intervalMs]);
16286
16299
  }
16287
16300
 
16301
+ // src/lib/job-signal.ts
16302
+ var import_react80 = require("react");
16303
+ var JOB_SIGNAL_EVENT = "pxengine:job-signal";
16304
+ var listeners = /* @__PURE__ */ new Set();
16305
+ var windowBridgeInstalled = false;
16306
+ function fanout(jobId) {
16307
+ if (!jobId) return;
16308
+ for (const listener of Array.from(listeners)) {
16309
+ try {
16310
+ listener(jobId);
16311
+ } catch {
16312
+ }
16313
+ }
16314
+ }
16315
+ function ensureWindowBridge() {
16316
+ if (windowBridgeInstalled || typeof window === "undefined") return;
16317
+ windowBridgeInstalled = true;
16318
+ window.addEventListener(JOB_SIGNAL_EVENT, (event) => {
16319
+ const detail = event.detail;
16320
+ const jobId = detail?.jobId;
16321
+ if (typeof jobId === "string" && jobId) fanout(jobId);
16322
+ });
16323
+ }
16324
+ function emitJobSignal(jobId) {
16325
+ fanout(jobId);
16326
+ }
16327
+ function subscribeJobSignal(listener) {
16328
+ ensureWindowBridge();
16329
+ listeners.add(listener);
16330
+ return () => {
16331
+ listeners.delete(listener);
16332
+ };
16333
+ }
16334
+ function useJobSignal(onSignal) {
16335
+ const ref = (0, import_react80.useRef)(onSignal);
16336
+ ref.current = onSignal;
16337
+ (0, import_react80.useEffect)(() => subscribeJobSignal((jobId) => ref.current(jobId)), []);
16338
+ }
16339
+
16288
16340
  // src/molecules/generic/job-card-shared/Chip.tsx
16289
16341
  var import_jsx_runtime148 = require("react/jsx-runtime");
16290
16342
  var Chip = ({
@@ -16376,6 +16428,40 @@ function formatTemplateLabel(templateId) {
16376
16428
  if (!templateId) return null;
16377
16429
  return templateId.split("-").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ");
16378
16430
  }
16431
+ var DECK_CANVAS = { w: 1280, h: 720 };
16432
+ function useDeckFitScale(canvasW = DECK_CANVAS.w, canvasH = DECK_CANVAS.h) {
16433
+ const containerRef = (0, import_react81.useRef)(null);
16434
+ const [scale, setScale] = (0, import_react81.useState)(1);
16435
+ (0, import_react81.useLayoutEffect)(() => {
16436
+ const el = containerRef.current;
16437
+ if (!el) return;
16438
+ const update = () => {
16439
+ const w = el.clientWidth;
16440
+ const h = el.clientHeight;
16441
+ if (w <= 0 || h <= 0) return;
16442
+ setScale(Math.min(w / canvasW, h / canvasH));
16443
+ };
16444
+ update();
16445
+ const ro = new ResizeObserver(update);
16446
+ ro.observe(el);
16447
+ return () => ro.disconnect();
16448
+ }, [canvasW, canvasH]);
16449
+ return { containerRef, scale, canvasW, canvasH };
16450
+ }
16451
+ function hideDeckChrome(iframe) {
16452
+ try {
16453
+ const doc = iframe?.contentDocument;
16454
+ if (!doc) return;
16455
+ let style = doc.getElementById("pxe-embed-chrome");
16456
+ if (!style) {
16457
+ style = doc.createElement("style");
16458
+ style.id = "pxe-embed-chrome";
16459
+ (doc.head || doc.documentElement).appendChild(style);
16460
+ }
16461
+ style.textContent = ".nav,.progress-bar,.dots{display:none!important}";
16462
+ } catch {
16463
+ }
16464
+ }
16379
16465
  function deriveJobStatusUrl(newJobId, pollUrl, regenerateUrl) {
16380
16466
  const base = pollUrl?.replace(/\/api\/jobs\/[^/]+\/status.*$/, "") ?? regenerateUrl?.replace(/\/api\/presentations\/[^/]+\/regenerate.*$/, "") ?? "";
16381
16467
  return `${base}/api/jobs/${newJobId}/status`;
@@ -16409,7 +16495,7 @@ var FORMATS = [
16409
16495
  var ExportModal = ({ formats, title, onClose }) => {
16410
16496
  const available = FORMATS.filter((f) => (formats ?? {})[f.key]);
16411
16497
  const filename = (title ?? "").replace(/[^a-z0-9]/gi, "-").toLowerCase();
16412
- const [downloadingKey, setDownloadingKey] = (0, import_react80.useState)(null);
16498
+ const [downloadingKey, setDownloadingKey] = (0, import_react81.useState)(null);
16413
16499
  const handleDownload = async (fmtKey, url, ext) => {
16414
16500
  if (downloadingKey) return;
16415
16501
  const downloadName = `${filename}${ext}`;
@@ -16477,10 +16563,11 @@ var ExportModal = ({ formats, title, onClose }) => {
16477
16563
  ] });
16478
16564
  };
16479
16565
  var FullscreenModal = ({ url, title, slideCount, initialSlide = 1, onClose }) => {
16480
- const [currentSlide, setCurrentSlide] = (0, import_react80.useState)(initialSlide);
16481
- const [iframeReady, setIframeReady] = (0, import_react80.useState)(false);
16482
- const iframeRef = (0, import_react80.useRef)(null);
16483
- (0, import_react80.useEffect)(() => {
16566
+ const [currentSlide, setCurrentSlide] = (0, import_react81.useState)(initialSlide);
16567
+ const [iframeReady, setIframeReady] = (0, import_react81.useState)(false);
16568
+ const iframeRef = (0, import_react81.useRef)(null);
16569
+ const { containerRef, scale, canvasW, canvasH } = useDeckFitScale();
16570
+ (0, import_react81.useEffect)(() => {
16484
16571
  const onKey = (e) => {
16485
16572
  if (e.key === "Escape") onClose();
16486
16573
  };
@@ -16498,7 +16585,7 @@ var FullscreenModal = ({ url, title, slideCount, initialSlide = 1, onClose }) =>
16498
16585
  window.removeEventListener("message", onMsg);
16499
16586
  };
16500
16587
  }, [onClose, iframeReady]);
16501
- (0, import_react80.useEffect)(() => {
16588
+ (0, import_react81.useEffect)(() => {
16502
16589
  document.body.style.overflow = "hidden";
16503
16590
  return () => {
16504
16591
  document.body.style.overflow = "";
@@ -16562,19 +16649,33 @@ var FullscreenModal = ({ url, title, slideCount, initialSlide = 1, onClose }) =>
16562
16649
  )
16563
16650
  ] })
16564
16651
  ] }),
16565
- /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { className: "flex-1 relative", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
16566
- "iframe",
16652
+ /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { ref: containerRef, className: "flex-1 relative flex items-center justify-center overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
16653
+ "div",
16567
16654
  {
16568
- ref: iframeRef,
16569
- src: url,
16570
- title,
16571
- onLoad: () => {
16572
- setIframeReady(true);
16573
- iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: initialSlide }, "*");
16574
- },
16575
- sandbox: "allow-same-origin allow-scripts",
16576
- allow: "fullscreen",
16577
- className: "absolute inset-0 w-full h-full border-0"
16655
+ className: "relative",
16656
+ style: { width: canvasW * scale, height: canvasH * scale },
16657
+ children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
16658
+ "iframe",
16659
+ {
16660
+ ref: iframeRef,
16661
+ src: url,
16662
+ title,
16663
+ onLoad: () => {
16664
+ setIframeReady(true);
16665
+ hideDeckChrome(iframeRef.current);
16666
+ iframeRef.current?.contentWindow?.postMessage({ type: "goToSlide", slide: initialSlide }, "*");
16667
+ },
16668
+ sandbox: "allow-same-origin allow-scripts",
16669
+ allow: "fullscreen",
16670
+ className: "absolute top-0 left-0 border-0",
16671
+ style: {
16672
+ width: canvasW,
16673
+ height: canvasH,
16674
+ transform: `scale(${scale})`,
16675
+ transformOrigin: "top left"
16676
+ }
16677
+ }
16678
+ )
16578
16679
  }
16579
16680
  ) })
16580
16681
  ] });
@@ -16610,73 +16711,74 @@ var PresentationJobCard = ({
16610
16711
  }) => {
16611
16712
  const t = th(theme);
16612
16713
  const accentGradient = theme?.gradient;
16613
- const [status, setStatus] = (0, import_react80.useState)(initialStatus);
16614
- const [title, setTitle] = (0, import_react80.useState)(initialTitle);
16615
- const [slideCount, setSlideCount] = (0, import_react80.useState)(initialSlideCount ?? 0);
16616
- const [formats, setFormats] = (0, import_react80.useState)(initialFormats);
16617
- const [error, setError] = (0, import_react80.useState)(initialError);
16618
- const [progress, setProgress] = (0, import_react80.useState)(initialProgress);
16619
- const [generationMode, setGenerationMode] = (0, import_react80.useState)(
16714
+ const [status, setStatus] = (0, import_react81.useState)(initialStatus);
16715
+ const [title, setTitle] = (0, import_react81.useState)(initialTitle);
16716
+ const [slideCount, setSlideCount] = (0, import_react81.useState)(initialSlideCount ?? 0);
16717
+ const [formats, setFormats] = (0, import_react81.useState)(initialFormats);
16718
+ const [error, setError] = (0, import_react81.useState)(initialError);
16719
+ const [progress, setProgress] = (0, import_react81.useState)(initialProgress);
16720
+ const [generationMode, setGenerationMode] = (0, import_react81.useState)(
16620
16721
  initialGenerationMode || (initialFormats?.html_url ? "template" : "")
16621
16722
  );
16622
- const [templateId, setTemplateId] = (0, import_react80.useState)(initialTemplateId || "");
16623
- const [, setTemplateVersionId] = (0, import_react80.useState)(initialTemplateVersionId || "");
16624
- const [reviewStatus, setReviewStatus] = (0, import_react80.useState)(initialReviewStatus || "");
16625
- const [outline, setOutline] = (0, import_react80.useState)(initialOutline);
16626
- const [slideTemplateOptions, setSlideTemplateOptions] = (0, import_react80.useState)(null);
16627
- const [showExport, setShowExport] = (0, import_react80.useState)(false);
16628
- const [showFullscreen, setShowFullscreen] = (0, import_react80.useState)(false);
16629
- const [copied, setCopied] = (0, import_react80.useState)(false);
16630
- const [approving, setApproving] = (0, import_react80.useState)(false);
16631
- const [regenerating, setRegenerating] = (0, import_react80.useState)(false);
16632
- const [approveError, setApproveError] = (0, import_react80.useState)(null);
16633
- const [messageEdits, setMessageEdits] = (0, import_react80.useState)({});
16634
- const [approvingOutline, setApprovingOutline] = (0, import_react80.useState)(false);
16635
- const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react80.useState)(null);
16636
- const [rowBusyIndex, setRowBusyIndex] = (0, import_react80.useState)(null);
16637
- const [rowError, setRowError] = (0, import_react80.useState)(null);
16638
- const [regenPollUrl, setRegenPollUrl] = (0, import_react80.useState)(null);
16639
- const [currentSlide, setCurrentSlide] = (0, import_react80.useState)(1);
16640
- const [iframeReady, setIframeReady] = (0, import_react80.useState)(false);
16641
- const iframeRef = (0, import_react80.useRef)(null);
16642
- (0, import_react80.useEffect)(() => {
16723
+ const [templateId, setTemplateId] = (0, import_react81.useState)(initialTemplateId || "");
16724
+ const [, setTemplateVersionId] = (0, import_react81.useState)(initialTemplateVersionId || "");
16725
+ const [reviewStatus, setReviewStatus] = (0, import_react81.useState)(initialReviewStatus || "");
16726
+ const [outline, setOutline] = (0, import_react81.useState)(initialOutline);
16727
+ const [slideTemplateOptions, setSlideTemplateOptions] = (0, import_react81.useState)(null);
16728
+ const [showExport, setShowExport] = (0, import_react81.useState)(false);
16729
+ const [showFullscreen, setShowFullscreen] = (0, import_react81.useState)(false);
16730
+ const [copied, setCopied] = (0, import_react81.useState)(false);
16731
+ const [approving, setApproving] = (0, import_react81.useState)(false);
16732
+ const [regenerating, setRegenerating] = (0, import_react81.useState)(false);
16733
+ const [approveError, setApproveError] = (0, import_react81.useState)(null);
16734
+ const [messageEdits, setMessageEdits] = (0, import_react81.useState)({});
16735
+ const [approvingOutline, setApprovingOutline] = (0, import_react81.useState)(false);
16736
+ const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react81.useState)(null);
16737
+ const [rowBusyIndex, setRowBusyIndex] = (0, import_react81.useState)(null);
16738
+ const [rowError, setRowError] = (0, import_react81.useState)(null);
16739
+ const [regenPollUrl, setRegenPollUrl] = (0, import_react81.useState)(null);
16740
+ const [currentSlide, setCurrentSlide] = (0, import_react81.useState)(1);
16741
+ const [iframeReady, setIframeReady] = (0, import_react81.useState)(false);
16742
+ const iframeRef = (0, import_react81.useRef)(null);
16743
+ const { containerRef: previewFitRef, scale: previewScale, canvasW, canvasH } = useDeckFitScale();
16744
+ (0, import_react81.useEffect)(() => {
16643
16745
  setStatus(initialStatus);
16644
16746
  }, [initialStatus]);
16645
16747
  const progressPct = initialProgress?.percentage;
16646
16748
  const progressStep = initialProgress?.current_step;
16647
- (0, import_react80.useEffect)(() => {
16749
+ (0, import_react81.useEffect)(() => {
16648
16750
  if (initialProgress) setProgress(initialProgress);
16649
16751
  }, [progressPct, progressStep]);
16650
- (0, import_react80.useEffect)(() => {
16752
+ (0, import_react81.useEffect)(() => {
16651
16753
  if (initialError) setError(initialError);
16652
16754
  }, [initialError]);
16653
- (0, import_react80.useEffect)(() => {
16755
+ (0, import_react81.useEffect)(() => {
16654
16756
  if (initialSlideCount !== void 0) setSlideCount(initialSlideCount);
16655
16757
  }, [initialSlideCount]);
16656
16758
  const htmlUrl = initialFormats?.html_url;
16657
- (0, import_react80.useEffect)(() => {
16759
+ (0, import_react81.useEffect)(() => {
16658
16760
  if (initialFormats) setFormats(initialFormats);
16659
16761
  }, [htmlUrl]);
16660
- (0, import_react80.useEffect)(() => {
16762
+ (0, import_react81.useEffect)(() => {
16661
16763
  if (initialTitle) setTitle(initialTitle);
16662
16764
  }, [initialTitle]);
16663
- (0, import_react80.useEffect)(() => {
16765
+ (0, import_react81.useEffect)(() => {
16664
16766
  if (initialGenerationMode) setGenerationMode(initialGenerationMode);
16665
16767
  }, [initialGenerationMode]);
16666
- (0, import_react80.useEffect)(() => {
16768
+ (0, import_react81.useEffect)(() => {
16667
16769
  if (initialTemplateId) setTemplateId(initialTemplateId);
16668
16770
  }, [initialTemplateId]);
16669
- (0, import_react80.useEffect)(() => {
16771
+ (0, import_react81.useEffect)(() => {
16670
16772
  if (initialTemplateVersionId) setTemplateVersionId(initialTemplateVersionId);
16671
16773
  }, [initialTemplateVersionId]);
16672
- (0, import_react80.useEffect)(() => {
16774
+ (0, import_react81.useEffect)(() => {
16673
16775
  if (initialReviewStatus) setReviewStatus(initialReviewStatus);
16674
16776
  }, [initialReviewStatus]);
16675
16777
  const initialOutlineSlideCount = initialOutline?.slides?.length;
16676
- (0, import_react80.useEffect)(() => {
16778
+ (0, import_react81.useEffect)(() => {
16677
16779
  if (initialOutline) setOutline(initialOutline);
16678
16780
  }, [initialOutlineSlideCount]);
16679
- (0, import_react80.useEffect)(() => {
16781
+ (0, import_react81.useEffect)(() => {
16680
16782
  if (reviewStatus !== "pending_outline_approval" || slideTemplateOptions !== null) return;
16681
16783
  let cancelled = false;
16682
16784
  (async () => {
@@ -16703,10 +16805,10 @@ var PresentationJobCard = ({
16703
16805
  cancelled = true;
16704
16806
  };
16705
16807
  }, [reviewStatus, slideTemplateOptions, templatesUrl, authToken]);
16706
- (0, import_react80.useEffect)(() => {
16808
+ (0, import_react81.useEffect)(() => {
16707
16809
  setIframeReady(false);
16708
16810
  }, [formats.html_url]);
16709
- (0, import_react80.useEffect)(() => {
16811
+ (0, import_react81.useEffect)(() => {
16710
16812
  const handler = (e) => {
16711
16813
  if (e.data?.type === "slideChanged") {
16712
16814
  setCurrentSlide(e.data.slide);
@@ -16732,15 +16834,15 @@ var PresentationJobCard = ({
16732
16834
  };
16733
16835
  const isTerminal = status === "complete" || status === "failed";
16734
16836
  const building = Boolean(outlineWritePollUrl) || approvingOutline;
16735
- const onCompleteRef = (0, import_react80.useRef)(onComplete);
16736
- const onFailedRef = (0, import_react80.useRef)(onFailed);
16737
- const hasNotifiedRef = (0, import_react80.useRef)(false);
16837
+ const onCompleteRef = (0, import_react81.useRef)(onComplete);
16838
+ const onFailedRef = (0, import_react81.useRef)(onFailed);
16839
+ const hasNotifiedRef = (0, import_react81.useRef)(false);
16738
16840
  onCompleteRef.current = onComplete;
16739
16841
  onFailedRef.current = onFailed;
16740
16842
  useSharedPoll(
16741
16843
  {
16742
16844
  key: !isTerminal && pollUrl ? pollUrl : null,
16743
- intervalMs: 3e3,
16845
+ intervalMs: SSE_FALLBACK_POLL_MS,
16744
16846
  fetcher: async () => {
16745
16847
  const headers = {};
16746
16848
  if (authToken) {
@@ -16800,7 +16902,7 @@ var PresentationJobCard = ({
16800
16902
  useSharedPoll(
16801
16903
  {
16802
16904
  key: building && pollUrl ? pollUrl : null,
16803
- intervalMs: 2e3,
16905
+ intervalMs: SSE_FALLBACK_POLL_MS,
16804
16906
  fetcher: async () => {
16805
16907
  const headers = {};
16806
16908
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -16814,7 +16916,7 @@ var PresentationJobCard = ({
16814
16916
  if (data.progress) setProgress(data.progress);
16815
16917
  }
16816
16918
  );
16817
- const applyDeckOutput = (0, import_react80.useCallback)((out, opts) => {
16919
+ const applyDeckOutput = (0, import_react81.useCallback)((out, opts) => {
16818
16920
  if (out.title) setTitle(out.title);
16819
16921
  if (out.slide_count !== void 0) setSlideCount(out.slide_count);
16820
16922
  if (out.formats) setFormats(out.formats);
@@ -16835,7 +16937,7 @@ var PresentationJobCard = ({
16835
16937
  });
16836
16938
  }
16837
16939
  }, [title, slideCount, formats, generationMode, templateId]);
16838
- const refetchSourceAndApply = (0, import_react80.useCallback)(async () => {
16940
+ const refetchSourceAndApply = (0, import_react81.useCallback)(async () => {
16839
16941
  if (!pollUrl) return;
16840
16942
  try {
16841
16943
  const headers = {};
@@ -16850,7 +16952,7 @@ var PresentationJobCard = ({
16850
16952
  useSharedPoll(
16851
16953
  {
16852
16954
  key: outlineWritePollUrl,
16853
- intervalMs: 3e3,
16955
+ intervalMs: SSE_FALLBACK_POLL_MS,
16854
16956
  fetcher: async () => {
16855
16957
  const headers = {};
16856
16958
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -16875,7 +16977,7 @@ var PresentationJobCard = ({
16875
16977
  useSharedPoll(
16876
16978
  {
16877
16979
  key: regenPollUrl,
16878
- intervalMs: 3e3,
16980
+ intervalMs: SSE_FALLBACK_POLL_MS,
16879
16981
  fetcher: async () => {
16880
16982
  const headers = {};
16881
16983
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -16897,6 +16999,16 @@ var PresentationJobCard = ({
16897
16999
  }
16898
17000
  }
16899
17001
  );
17002
+ useJobSignal(
17003
+ (0, import_react81.useCallback)(
17004
+ (completedJobId) => {
17005
+ for (const url of [pollUrl, outlineWritePollUrl, regenPollUrl]) {
17006
+ if (url && url.includes(completedJobId)) refreshSharedPoll(url);
17007
+ }
17008
+ },
17009
+ [pollUrl, outlineWritePollUrl, regenPollUrl]
17010
+ )
17011
+ );
16900
17012
  const buildEditedOutline = () => {
16901
17013
  if (!outline || !Array.isArray(outline.slides)) return void 0;
16902
17014
  let changed = false;
@@ -17499,19 +17611,36 @@ var PresentationJobCard = ({
17499
17611
  /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)(
17500
17612
  "div",
17501
17613
  {
17614
+ ref: previewFitRef,
17502
17615
  onClick: () => setShowFullscreen(true),
17503
- className: "group relative aspect-video w-full overflow-hidden rounded-xl bg-zinc-950 border border-zinc-800/50 cursor-pointer",
17616
+ className: "group relative aspect-video w-full overflow-hidden rounded-xl bg-zinc-950 border border-zinc-800/50 cursor-pointer flex items-center justify-center",
17504
17617
  title: "Click to open fullscreen",
17505
17618
  children: [
17506
17619
  /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
17507
- "iframe",
17620
+ "div",
17508
17621
  {
17509
- ref: iframeRef,
17510
- src: formats.html_url,
17511
- title,
17512
- sandbox: "allow-same-origin allow-scripts",
17513
- onLoad: () => setIframeReady(true),
17514
- className: "absolute inset-0 block h-full w-full border-0 pointer-events-none"
17622
+ className: "relative",
17623
+ style: { width: canvasW * previewScale, height: canvasH * previewScale },
17624
+ children: /* @__PURE__ */ (0, import_jsx_runtime151.jsx)(
17625
+ "iframe",
17626
+ {
17627
+ ref: iframeRef,
17628
+ src: formats.html_url,
17629
+ title,
17630
+ sandbox: "allow-same-origin allow-scripts",
17631
+ onLoad: () => {
17632
+ setIframeReady(true);
17633
+ hideDeckChrome(iframeRef.current);
17634
+ },
17635
+ className: "absolute top-0 left-0 border-0 pointer-events-none",
17636
+ style: {
17637
+ width: canvasW,
17638
+ height: canvasH,
17639
+ transform: `scale(${previewScale})`,
17640
+ transformOrigin: "top left"
17641
+ }
17642
+ }
17643
+ )
17515
17644
  }
17516
17645
  ),
17517
17646
  /* @__PURE__ */ (0, import_jsx_runtime151.jsx)("div", { className: "absolute inset-0 flex items-center justify-center bg-black/0 group-hover:bg-black/30 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime151.jsxs)("span", { className: "opacity-0 group-hover:opacity-100 transition-opacity flex items-center gap-2 bg-zinc-900/80 backdrop-blur-sm border border-zinc-700 rounded-lg px-3 py-1.5 text-xs text-zinc-200 font-medium", children: [
@@ -17572,7 +17701,7 @@ var PresentationJobCard = ({
17572
17701
  };
17573
17702
 
17574
17703
  // src/molecules/generic/ResearchReportJobCard/ResearchReportJobCard.tsx
17575
- var import_react81 = require("react");
17704
+ var import_react82 = require("react");
17576
17705
  var import_jsx_runtime152 = require("react/jsx-runtime");
17577
17706
  var DEFAULT_THEME = {
17578
17707
  primary: "#C0AE82",
@@ -17608,14 +17737,14 @@ function withPdfViewerParams(url) {
17608
17737
  return `${url}#toolbar=0&navpanes=0&scrollbar=0`;
17609
17738
  }
17610
17739
  var FullscreenPreviewModal = ({ url, title, onClose, isPdf }) => {
17611
- (0, import_react81.useEffect)(() => {
17740
+ (0, import_react82.useEffect)(() => {
17612
17741
  const onKey = (e) => {
17613
17742
  if (e.key === "Escape") onClose();
17614
17743
  };
17615
17744
  document.addEventListener("keydown", onKey);
17616
17745
  return () => document.removeEventListener("keydown", onKey);
17617
17746
  }, [onClose]);
17618
- (0, import_react81.useEffect)(() => {
17747
+ (0, import_react82.useEffect)(() => {
17619
17748
  document.body.style.overflow = "hidden";
17620
17749
  return () => {
17621
17750
  document.body.style.overflow = "";
@@ -17672,8 +17801,8 @@ var ReportExportModal = ({ htmlUrl, pdfUrl, title, onClose }) => {
17672
17801
  const urls = { pdf: pdfUrl, html: htmlUrl };
17673
17802
  const available = REPORT_FORMATS.filter((f) => urls[f.key]);
17674
17803
  const filename = (title ?? "").replace(/[^a-z0-9]/gi, "-").toLowerCase();
17675
- const [downloadingKey, setDownloadingKey] = (0, import_react81.useState)(null);
17676
- (0, import_react81.useEffect)(() => {
17804
+ const [downloadingKey, setDownloadingKey] = (0, import_react82.useState)(null);
17805
+ (0, import_react82.useEffect)(() => {
17677
17806
  const onKey = (e) => {
17678
17807
  if (e.key === "Escape") onClose();
17679
17808
  };
@@ -17786,95 +17915,95 @@ var ResearchReportJobCard = (props) => {
17786
17915
  compact = false
17787
17916
  } = props;
17788
17917
  const inferredStatus = initialStatus ?? (initialHtmlUrl ? "complete" : void 0);
17789
- const [status, setStatus] = (0, import_react81.useState)(inferredStatus);
17790
- const [title, setTitle] = (0, import_react81.useState)(initialTitle);
17791
- const [depth, setDepth] = (0, import_react81.useState)(initialDepth || "");
17792
- const [sectionCount, setSectionCount] = (0, import_react81.useState)(initialSectionCount ?? 0);
17793
- const [sourceCount, setSourceCount] = (0, import_react81.useState)(initialSourceCount ?? 0);
17794
- const [wordCount, setWordCount] = (0, import_react81.useState)(initialWordCount ?? 0);
17795
- const [summary, setSummary] = (0, import_react81.useState)(initialSummary || "");
17796
- const [htmlUrl, setHtmlUrl] = (0, import_react81.useState)(initialHtmlUrl || "");
17797
- const [pdfUrl, setPdfUrl] = (0, import_react81.useState)(initialPdfUrl || "");
17798
- const [generationMode, setGenerationMode] = (0, import_react81.useState)(
17918
+ const [status, setStatus] = (0, import_react82.useState)(inferredStatus);
17919
+ const [title, setTitle] = (0, import_react82.useState)(initialTitle);
17920
+ const [depth, setDepth] = (0, import_react82.useState)(initialDepth || "");
17921
+ const [sectionCount, setSectionCount] = (0, import_react82.useState)(initialSectionCount ?? 0);
17922
+ const [sourceCount, setSourceCount] = (0, import_react82.useState)(initialSourceCount ?? 0);
17923
+ const [wordCount, setWordCount] = (0, import_react82.useState)(initialWordCount ?? 0);
17924
+ const [summary, setSummary] = (0, import_react82.useState)(initialSummary || "");
17925
+ const [htmlUrl, setHtmlUrl] = (0, import_react82.useState)(initialHtmlUrl || "");
17926
+ const [pdfUrl, setPdfUrl] = (0, import_react82.useState)(initialPdfUrl || "");
17927
+ const [generationMode, setGenerationMode] = (0, import_react82.useState)(
17799
17928
  initialGenerationMode || (initialHtmlUrl ? "template" : "")
17800
17929
  );
17801
- const [templateId, setTemplateId] = (0, import_react81.useState)(initialTemplateId || "");
17802
- const [templateVersionId, setTemplateVersionId] = (0, import_react81.useState)(initialTemplateVersionId || "");
17803
- const [reviewStatus, setReviewStatus] = (0, import_react81.useState)(
17930
+ const [templateId, setTemplateId] = (0, import_react82.useState)(initialTemplateId || "");
17931
+ const [templateVersionId, setTemplateVersionId] = (0, import_react82.useState)(initialTemplateVersionId || "");
17932
+ const [reviewStatus, setReviewStatus] = (0, import_react82.useState)(
17804
17933
  initialReviewStatus || (initialHtmlUrl ? "pending_review" : "")
17805
17934
  );
17806
- const [outline, setOutline] = (0, import_react81.useState)(initialOutline);
17807
- const [theme, setTheme] = (0, import_react81.useState)(initialTheme || DEFAULT_THEME);
17808
- const [error, setError] = (0, import_react81.useState)(initialError);
17809
- const [progress, setProgress] = (0, import_react81.useState)(initialProgress);
17810
- const [showPreview, setShowPreview] = (0, import_react81.useState)(false);
17811
- const [showExport, setShowExport] = (0, import_react81.useState)(false);
17812
- const [copied, setCopied] = (0, import_react81.useState)(false);
17813
- const [approving, setApproving] = (0, import_react81.useState)(false);
17814
- const [regenerating, setRegenerating] = (0, import_react81.useState)(false);
17815
- const [approveError, setApproveError] = (0, import_react81.useState)(null);
17816
- const [headingEdits, setHeadingEdits] = (0, import_react81.useState)({});
17817
- const [approvingOutline, setApprovingOutline] = (0, import_react81.useState)(false);
17818
- const [rowBusyIndex, setRowBusyIndex] = (0, import_react81.useState)(null);
17819
- const [rowError, setRowError] = (0, import_react81.useState)(null);
17820
- const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react81.useState)(null);
17821
- const [regenPollUrl, setRegenPollUrl] = (0, import_react81.useState)(null);
17822
- const onCompleteRef = (0, import_react81.useRef)(onComplete);
17823
- const onFailedRef = (0, import_react81.useRef)(onFailed);
17824
- const hasNotifiedRef = (0, import_react81.useRef)(false);
17935
+ const [outline, setOutline] = (0, import_react82.useState)(initialOutline);
17936
+ const [theme, setTheme] = (0, import_react82.useState)(initialTheme || DEFAULT_THEME);
17937
+ const [error, setError] = (0, import_react82.useState)(initialError);
17938
+ const [progress, setProgress] = (0, import_react82.useState)(initialProgress);
17939
+ const [showPreview, setShowPreview] = (0, import_react82.useState)(false);
17940
+ const [showExport, setShowExport] = (0, import_react82.useState)(false);
17941
+ const [copied, setCopied] = (0, import_react82.useState)(false);
17942
+ const [approving, setApproving] = (0, import_react82.useState)(false);
17943
+ const [regenerating, setRegenerating] = (0, import_react82.useState)(false);
17944
+ const [approveError, setApproveError] = (0, import_react82.useState)(null);
17945
+ const [headingEdits, setHeadingEdits] = (0, import_react82.useState)({});
17946
+ const [approvingOutline, setApprovingOutline] = (0, import_react82.useState)(false);
17947
+ const [rowBusyIndex, setRowBusyIndex] = (0, import_react82.useState)(null);
17948
+ const [rowError, setRowError] = (0, import_react82.useState)(null);
17949
+ const [outlineWritePollUrl, setOutlineWritePollUrl] = (0, import_react82.useState)(null);
17950
+ const [regenPollUrl, setRegenPollUrl] = (0, import_react82.useState)(null);
17951
+ const onCompleteRef = (0, import_react82.useRef)(onComplete);
17952
+ const onFailedRef = (0, import_react82.useRef)(onFailed);
17953
+ const hasNotifiedRef = (0, import_react82.useRef)(false);
17825
17954
  onCompleteRef.current = onComplete;
17826
17955
  onFailedRef.current = onFailed;
17827
- (0, import_react81.useEffect)(() => {
17956
+ (0, import_react82.useEffect)(() => {
17828
17957
  const newStatus = initialStatus ?? (initialHtmlUrl ? "complete" : void 0);
17829
17958
  setStatus(newStatus);
17830
17959
  }, [initialStatus, initialHtmlUrl]);
17831
- (0, import_react81.useEffect)(() => {
17960
+ (0, import_react82.useEffect)(() => {
17832
17961
  if (initialTitle) setTitle(initialTitle);
17833
17962
  }, [initialTitle]);
17834
- (0, import_react81.useEffect)(() => {
17963
+ (0, import_react82.useEffect)(() => {
17835
17964
  if (initialHtmlUrl) setHtmlUrl(initialHtmlUrl);
17836
17965
  }, [initialHtmlUrl]);
17837
- (0, import_react81.useEffect)(() => {
17966
+ (0, import_react82.useEffect)(() => {
17838
17967
  if (initialGenerationMode) setGenerationMode(initialGenerationMode);
17839
17968
  }, [initialGenerationMode]);
17840
- (0, import_react81.useEffect)(() => {
17969
+ (0, import_react82.useEffect)(() => {
17841
17970
  if (initialTemplateId) setTemplateId(initialTemplateId);
17842
17971
  }, [initialTemplateId]);
17843
- (0, import_react81.useEffect)(() => {
17972
+ (0, import_react82.useEffect)(() => {
17844
17973
  if (initialTemplateVersionId) setTemplateVersionId(initialTemplateVersionId);
17845
17974
  }, [initialTemplateVersionId]);
17846
- (0, import_react81.useEffect)(() => {
17975
+ (0, import_react82.useEffect)(() => {
17847
17976
  if (initialReviewStatus) setReviewStatus(initialReviewStatus);
17848
17977
  }, [initialReviewStatus]);
17849
17978
  const initialOutlineSectionCount = initialOutline?.sections?.length;
17850
- (0, import_react81.useEffect)(() => {
17979
+ (0, import_react82.useEffect)(() => {
17851
17980
  if (initialOutline) setOutline(initialOutline);
17852
17981
  }, [initialOutlineSectionCount]);
17853
- (0, import_react81.useEffect)(() => {
17982
+ (0, import_react82.useEffect)(() => {
17854
17983
  if (initialDepth) setDepth(initialDepth);
17855
17984
  }, [initialDepth]);
17856
- (0, import_react81.useEffect)(() => {
17985
+ (0, import_react82.useEffect)(() => {
17857
17986
  if (initialSectionCount !== void 0) setSectionCount(initialSectionCount);
17858
17987
  }, [initialSectionCount]);
17859
- (0, import_react81.useEffect)(() => {
17988
+ (0, import_react82.useEffect)(() => {
17860
17989
  if (initialSourceCount !== void 0) setSourceCount(initialSourceCount);
17861
17990
  }, [initialSourceCount]);
17862
- (0, import_react81.useEffect)(() => {
17991
+ (0, import_react82.useEffect)(() => {
17863
17992
  if (initialWordCount !== void 0) setWordCount(initialWordCount);
17864
17993
  }, [initialWordCount]);
17865
- (0, import_react81.useEffect)(() => {
17994
+ (0, import_react82.useEffect)(() => {
17866
17995
  if (initialSummary) setSummary(initialSummary);
17867
17996
  }, [initialSummary]);
17868
17997
  const themePrimary = initialTheme?.primary;
17869
- (0, import_react81.useEffect)(() => {
17998
+ (0, import_react82.useEffect)(() => {
17870
17999
  if (initialTheme) setTheme(initialTheme);
17871
18000
  }, [themePrimary]);
17872
- (0, import_react81.useEffect)(() => {
18001
+ (0, import_react82.useEffect)(() => {
17873
18002
  if (initialError) setError(initialError);
17874
18003
  }, [initialError]);
17875
18004
  const progressPct = initialProgress?.percentage;
17876
18005
  const progressStep = initialProgress?.current_step;
17877
- (0, import_react81.useEffect)(() => {
18006
+ (0, import_react82.useEffect)(() => {
17878
18007
  if (initialProgress) setProgress(initialProgress);
17879
18008
  }, [progressPct, progressStep]);
17880
18009
  const isTerminal = status === "complete" || status === "failed";
@@ -17884,7 +18013,7 @@ var ResearchReportJobCard = (props) => {
17884
18013
  useSharedPoll(
17885
18014
  {
17886
18015
  key: !isTerminal && pollUrl ? pollUrl : null,
17887
- intervalMs: 3e3,
18016
+ intervalMs: SSE_FALLBACK_POLL_MS,
17888
18017
  fetcher: async () => {
17889
18018
  const headers = {};
17890
18019
  if (authToken) {
@@ -17940,7 +18069,7 @@ var ResearchReportJobCard = (props) => {
17940
18069
  useSharedPoll(
17941
18070
  {
17942
18071
  key: building && pollUrl ? pollUrl : null,
17943
- intervalMs: 2e3,
18072
+ intervalMs: SSE_FALLBACK_POLL_MS,
17944
18073
  fetcher: async () => {
17945
18074
  const headers = {};
17946
18075
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -17954,7 +18083,7 @@ var ResearchReportJobCard = (props) => {
17954
18083
  if (data.progress) setProgress(data.progress);
17955
18084
  }
17956
18085
  );
17957
- const applyRegeneratedOutput = (0, import_react81.useCallback)(
18086
+ const applyRegeneratedOutput = (0, import_react82.useCallback)(
17958
18087
  (out) => {
17959
18088
  if (out.html_url) setHtmlUrl(out.html_url);
17960
18089
  setPdfUrl(out.pdf_url || "");
@@ -17987,7 +18116,7 @@ var ResearchReportJobCard = (props) => {
17987
18116
  useSharedPoll(
17988
18117
  {
17989
18118
  key: regenPollUrl,
17990
- intervalMs: 3e3,
18119
+ intervalMs: SSE_FALLBACK_POLL_MS,
17991
18120
  fetcher: async () => {
17992
18121
  const headers = {};
17993
18122
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -18009,7 +18138,7 @@ var ResearchReportJobCard = (props) => {
18009
18138
  }
18010
18139
  }
18011
18140
  );
18012
- const refetchSourceAndApply = (0, import_react81.useCallback)(async () => {
18141
+ const refetchSourceAndApply = (0, import_react82.useCallback)(async () => {
18013
18142
  if (!pollUrl) return;
18014
18143
  try {
18015
18144
  const headers = {};
@@ -18042,7 +18171,7 @@ var ResearchReportJobCard = (props) => {
18042
18171
  useSharedPoll(
18043
18172
  {
18044
18173
  key: outlineWritePollUrl,
18045
- intervalMs: 3e3,
18174
+ intervalMs: SSE_FALLBACK_POLL_MS,
18046
18175
  fetcher: async () => {
18047
18176
  const headers = {};
18048
18177
  if (authToken) headers["Authorization"] = `Bearer ${authToken}`;
@@ -18064,6 +18193,16 @@ var ResearchReportJobCard = (props) => {
18064
18193
  }
18065
18194
  }
18066
18195
  );
18196
+ useJobSignal(
18197
+ (0, import_react82.useCallback)(
18198
+ (completedJobId) => {
18199
+ for (const url of [pollUrl, outlineWritePollUrl, regenPollUrl]) {
18200
+ if (url && url.includes(completedJobId)) refreshSharedPoll(url);
18201
+ }
18202
+ },
18203
+ [pollUrl, outlineWritePollUrl, regenPollUrl]
18204
+ )
18205
+ );
18067
18206
  const buildEditedOutline = () => {
18068
18207
  if (!outline || !Array.isArray(outline.sections)) return void 0;
18069
18208
  let changed = false;
@@ -18737,7 +18876,7 @@ var ResearchReportJobCard = (props) => {
18737
18876
  };
18738
18877
 
18739
18878
  // src/molecules/generic/WebSearchJobCard/WebSearchJobCard.tsx
18740
- var import_react82 = require("react");
18879
+ var import_react83 = require("react");
18741
18880
  var import_jsx_runtime153 = require("react/jsx-runtime");
18742
18881
  var SearchIcon = () => /* @__PURE__ */ (0, import_jsx_runtime153.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
18743
18882
  /* @__PURE__ */ (0, import_jsx_runtime153.jsx)("circle", { cx: "11", cy: "11", r: "8" }),
@@ -18766,46 +18905,46 @@ var WebSearchJobCard = ({
18766
18905
  onFailed,
18767
18906
  compact = false
18768
18907
  }) => {
18769
- const [status, setStatus] = (0, import_react82.useState)(initialStatus);
18770
- const [query, setQuery] = (0, import_react82.useState)(initialQuery || initialTitle || "");
18771
- const [resultCount, setResultCount] = (0, import_react82.useState)(initialResultCount ?? 0);
18772
- const [searchCount, setSearchCount] = (0, import_react82.useState)(initialSearchCount ?? 0);
18773
- const [summary, setSummary] = (0, import_react82.useState)(initialSummary || "");
18774
- const [results, setResults] = (0, import_react82.useState)(initialResults || []);
18775
- const [error, setError] = (0, import_react82.useState)(initialError);
18776
- const [progress, setProgress] = (0, import_react82.useState)(initialProgress);
18777
- const onCompleteRef = (0, import_react82.useRef)(onComplete);
18778
- const onFailedRef = (0, import_react82.useRef)(onFailed);
18779
- const hasNotifiedRef = (0, import_react82.useRef)(false);
18908
+ const [status, setStatus] = (0, import_react83.useState)(initialStatus);
18909
+ const [query, setQuery] = (0, import_react83.useState)(initialQuery || initialTitle || "");
18910
+ const [resultCount, setResultCount] = (0, import_react83.useState)(initialResultCount ?? 0);
18911
+ const [searchCount, setSearchCount] = (0, import_react83.useState)(initialSearchCount ?? 0);
18912
+ const [summary, setSummary] = (0, import_react83.useState)(initialSummary || "");
18913
+ const [results, setResults] = (0, import_react83.useState)(initialResults || []);
18914
+ const [error, setError] = (0, import_react83.useState)(initialError);
18915
+ const [progress, setProgress] = (0, import_react83.useState)(initialProgress);
18916
+ const onCompleteRef = (0, import_react83.useRef)(onComplete);
18917
+ const onFailedRef = (0, import_react83.useRef)(onFailed);
18918
+ const hasNotifiedRef = (0, import_react83.useRef)(false);
18780
18919
  onCompleteRef.current = onComplete;
18781
18920
  onFailedRef.current = onFailed;
18782
- (0, import_react82.useEffect)(() => {
18921
+ (0, import_react83.useEffect)(() => {
18783
18922
  setStatus(initialStatus);
18784
18923
  }, [initialStatus]);
18785
- (0, import_react82.useEffect)(() => {
18924
+ (0, import_react83.useEffect)(() => {
18786
18925
  if (initialQuery) setQuery(initialQuery);
18787
18926
  }, [initialQuery]);
18788
- (0, import_react82.useEffect)(() => {
18927
+ (0, import_react83.useEffect)(() => {
18789
18928
  if (initialTitle && !initialQuery) setQuery(initialTitle);
18790
18929
  }, [initialTitle, initialQuery]);
18791
- (0, import_react82.useEffect)(() => {
18930
+ (0, import_react83.useEffect)(() => {
18792
18931
  if (initialResultCount !== void 0) setResultCount(initialResultCount);
18793
18932
  }, [initialResultCount]);
18794
- (0, import_react82.useEffect)(() => {
18933
+ (0, import_react83.useEffect)(() => {
18795
18934
  if (initialSearchCount !== void 0) setSearchCount(initialSearchCount);
18796
18935
  }, [initialSearchCount]);
18797
- (0, import_react82.useEffect)(() => {
18936
+ (0, import_react83.useEffect)(() => {
18798
18937
  if (initialSummary) setSummary(initialSummary);
18799
18938
  }, [initialSummary]);
18800
- (0, import_react82.useEffect)(() => {
18939
+ (0, import_react83.useEffect)(() => {
18801
18940
  if (initialResults) setResults(initialResults);
18802
18941
  }, [initialResults]);
18803
- (0, import_react82.useEffect)(() => {
18942
+ (0, import_react83.useEffect)(() => {
18804
18943
  if (initialError) setError(initialError);
18805
18944
  }, [initialError]);
18806
18945
  const progressPct = initialProgress?.percentage;
18807
18946
  const progressStep = initialProgress?.current_step;
18808
- (0, import_react82.useEffect)(() => {
18947
+ (0, import_react83.useEffect)(() => {
18809
18948
  if (initialProgress) setProgress(initialProgress);
18810
18949
  }, [progressPct, progressStep]);
18811
18950
  const isTerminal = status === "complete" || status === "failed";
@@ -18990,10 +19129,10 @@ var WebSearchJobCard = ({
18990
19129
  };
18991
19130
 
18992
19131
  // src/molecules/creator-discovery/CampaignSeedCard/CampaignSeedCard.tsx
18993
- var import_react84 = __toESM(require("react"), 1);
19132
+ var import_react85 = __toESM(require("react"), 1);
18994
19133
 
18995
19134
  // src/molecules/creator-discovery/SearchSpecCard/CustomFieldRenderers.tsx
18996
- var import_react83 = require("react");
19135
+ var import_react84 = require("react");
18997
19136
 
18998
19137
  // src/lib/countries.ts
18999
19138
  var countries = [
@@ -19205,10 +19344,10 @@ var CountrySelectEdit = ({
19205
19344
  value,
19206
19345
  onChange
19207
19346
  }) => {
19208
- const [isDropdownOpen, setIsDropdownOpen] = (0, import_react83.useState)(false);
19209
- const [searchTerm, setSearchTerm] = (0, import_react83.useState)("");
19210
- const dropdownRef = (0, import_react83.useRef)(null);
19211
- (0, import_react83.useEffect)(() => {
19347
+ const [isDropdownOpen, setIsDropdownOpen] = (0, import_react84.useState)(false);
19348
+ const [searchTerm, setSearchTerm] = (0, import_react84.useState)("");
19349
+ const dropdownRef = (0, import_react84.useRef)(null);
19350
+ (0, import_react84.useEffect)(() => {
19212
19351
  const handleClickOutside = (event) => {
19213
19352
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
19214
19353
  setIsDropdownOpen(false);
@@ -19217,7 +19356,7 @@ var CountrySelectEdit = ({
19217
19356
  document.addEventListener("mousedown", handleClickOutside);
19218
19357
  return () => document.removeEventListener("mousedown", handleClickOutside);
19219
19358
  }, []);
19220
- const inputValue = (0, import_react83.useMemo)(() => {
19359
+ const inputValue = (0, import_react84.useMemo)(() => {
19221
19360
  if (Array.isArray(value)) return value;
19222
19361
  if (typeof value === "string" && value.trim() !== "") {
19223
19362
  const foundCountry = countries.find(
@@ -19318,7 +19457,7 @@ var CountrySelectEdit = ({
19318
19457
  ] });
19319
19458
  };
19320
19459
  var CountrySelectDisplay = ({ value }) => {
19321
- const displayValues = (0, import_react83.useMemo)(() => {
19460
+ const displayValues = (0, import_react84.useMemo)(() => {
19322
19461
  if (Array.isArray(value)) return value;
19323
19462
  if (typeof value === "string" && value.trim() !== "") return [value];
19324
19463
  return [];
@@ -19494,7 +19633,7 @@ var PlatformSelectEdit = ({
19494
19633
  value,
19495
19634
  onChange
19496
19635
  }) => {
19497
- const selectedPlatforms = (0, import_react83.useMemo)(() => {
19636
+ const selectedPlatforms = (0, import_react84.useMemo)(() => {
19498
19637
  if (Array.isArray(value)) return value;
19499
19638
  if (typeof value === "string" && value.trim() !== "") {
19500
19639
  return value.split(",").map((s) => s.trim()).filter(Boolean);
@@ -19513,7 +19652,7 @@ var PlatformSelectEdit = ({
19513
19652
  onChange([...selectedPlatforms, platform]);
19514
19653
  }
19515
19654
  };
19516
- const options = (0, import_react83.useMemo)(() => {
19655
+ const options = (0, import_react84.useMemo)(() => {
19517
19656
  return DEFAULT_PLATFORMS;
19518
19657
  }, []);
19519
19658
  return /* @__PURE__ */ (0, import_jsx_runtime154.jsx)("div", { className: "flex flex-wrap gap-4 py-2", children: options.map((platform) => /* @__PURE__ */ (0, import_jsx_runtime154.jsxs)(
@@ -19539,7 +19678,7 @@ var PlatformSelectEdit = ({
19539
19678
  )) });
19540
19679
  };
19541
19680
  var PlatformSelectDisplay = ({ value }) => {
19542
- const displayValues = (0, import_react83.useMemo)(() => {
19681
+ const displayValues = (0, import_react84.useMemo)(() => {
19543
19682
  if (Array.isArray(value)) return value;
19544
19683
  if (typeof value === "string" && value.trim() !== "") {
19545
19684
  return value.split(",").map((s) => s.trim()).filter(Boolean);
@@ -19699,7 +19838,7 @@ function buildCampaignSeedFields(data) {
19699
19838
  return generated;
19700
19839
  });
19701
19840
  }
19702
- var CampaignSeedCard = import_react84.default.memo(
19841
+ var CampaignSeedCard = import_react85.default.memo(
19703
19842
  ({
19704
19843
  selectionStatus,
19705
19844
  isLatestMessage = true,
@@ -19711,7 +19850,7 @@ var CampaignSeedCard = import_react84.default.memo(
19711
19850
  sendMessage,
19712
19851
  ...formCardProps
19713
19852
  }) => {
19714
- const fields = (0, import_react84.useMemo)(() => {
19853
+ const fields = (0, import_react85.useMemo)(() => {
19715
19854
  return providedFields || buildCampaignSeedFields(data);
19716
19855
  }, [providedFields, data]);
19717
19856
  const handleProceed = () => {
@@ -19745,7 +19884,7 @@ var CampaignSeedCard = import_react84.default.memo(
19745
19884
  CampaignSeedCard.displayName = "CampaignSeedCard";
19746
19885
 
19747
19886
  // src/molecules/creator-discovery/SearchSpecCard/SearchSpecCard.tsx
19748
- var import_react85 = __toESM(require("react"), 1);
19887
+ var import_react86 = __toESM(require("react"), 1);
19749
19888
  var import_jsx_runtime156 = require("react/jsx-runtime");
19750
19889
  var ObjectDisplay2 = ({ value }) => {
19751
19890
  if (!value || typeof value !== "object") return null;
@@ -19861,7 +20000,7 @@ function buildSearchSpecFields(data) {
19861
20000
  return generated;
19862
20001
  });
19863
20002
  }
19864
- var SearchSpecCard = import_react85.default.memo(
20003
+ var SearchSpecCard = import_react86.default.memo(
19865
20004
  ({
19866
20005
  selectionStatus,
19867
20006
  isLatestMessage = true,
@@ -19875,7 +20014,7 @@ var SearchSpecCard = import_react85.default.memo(
19875
20014
  ...formCardProps
19876
20015
  }) => {
19877
20016
  const resolvedData = data || specData;
19878
- const fields = (0, import_react85.useMemo)(() => {
20017
+ const fields = (0, import_react86.useMemo)(() => {
19879
20018
  return providedFields || buildSearchSpecFields(resolvedData ?? {});
19880
20019
  }, [providedFields, resolvedData]);
19881
20020
  const handleProceed = () => {
@@ -19911,7 +20050,7 @@ var SearchSpecCard = import_react85.default.memo(
19911
20050
  SearchSpecCard.displayName = "SearchSpecCard";
19912
20051
 
19913
20052
  // src/molecules/creator-discovery/MCQCard/MCQCard.tsx
19914
- var import_react86 = __toESM(require("react"), 1);
20053
+ var import_react87 = __toESM(require("react"), 1);
19915
20054
 
19916
20055
  // src/lib/auth-provider.ts
19917
20056
  var _provider = null;
@@ -20081,7 +20220,7 @@ function inferSelectionLimits(text, optionCount) {
20081
20220
  }
20082
20221
  return null;
20083
20222
  }
20084
- var MCQCard = import_react86.default.memo(
20223
+ var MCQCard = import_react87.default.memo(
20085
20224
  ({
20086
20225
  question,
20087
20226
  options,
@@ -20139,12 +20278,12 @@ var MCQCard = import_react86.default.memo(
20139
20278
  if (propsSelectedOption) return [propsSelectedOption];
20140
20279
  return [];
20141
20280
  };
20142
- const [selectedKeys, setSelectedKeys] = import_react86.default.useState(seedSelection);
20143
- const [isProceeded, setIsProceeded] = import_react86.default.useState(
20281
+ const [selectedKeys, setSelectedKeys] = import_react87.default.useState(seedSelection);
20282
+ const [isProceeded, setIsProceeded] = import_react87.default.useState(
20144
20283
  Boolean(propsSelectedOption || propsSelectedOptions && propsSelectedOptions.length)
20145
20284
  );
20146
- const fetchedSessionRef = import_react86.default.useRef("");
20147
- import_react86.default.useEffect(() => {
20285
+ const fetchedSessionRef = import_react87.default.useRef("");
20286
+ import_react87.default.useEffect(() => {
20148
20287
  if (propsSelectedOption) {
20149
20288
  setSelectedKeys([propsSelectedOption]);
20150
20289
  setIsProceeded(true);
@@ -20153,7 +20292,7 @@ var MCQCard = import_react86.default.memo(
20153
20292
  setIsProceeded(true);
20154
20293
  }
20155
20294
  }, [propsSelectedOption, propsSelectedOptions]);
20156
- const buildQuestionKey = import_react86.default.useCallback((sid, q) => {
20295
+ const buildQuestionKey = import_react87.default.useCallback((sid, q) => {
20157
20296
  let hash = 2166136261;
20158
20297
  for (let i = 0; i < q.length; i++) {
20159
20298
  hash ^= q.charCodeAt(i);
@@ -20161,7 +20300,7 @@ var MCQCard = import_react86.default.memo(
20161
20300
  }
20162
20301
  return `mcq_${sid}_${hash.toString(36)}`;
20163
20302
  }, []);
20164
- import_react86.default.useEffect(() => {
20303
+ import_react87.default.useEffect(() => {
20165
20304
  if (!sessionId || !resolvedQuestion) return;
20166
20305
  const fetchKey = `${sessionId}::${resolvedQuestion}`;
20167
20306
  if (fetchedSessionRef.current === fetchKey) return;
@@ -20833,9 +20972,9 @@ var CreatorActionHeader = ({
20833
20972
  };
20834
20973
 
20835
20974
  // src/molecules/creator-discovery/CreatorSearchBox/CreatorSearch.tsx
20836
- var import_react87 = __toESM(require("react"), 1);
20975
+ var import_react88 = __toESM(require("react"), 1);
20837
20976
  var import_jsx_runtime168 = require("react/jsx-runtime");
20838
- var CreatorSearch = import_react87.default.memo(
20977
+ var CreatorSearch = import_react88.default.memo(
20839
20978
  ({
20840
20979
  selectionStatus,
20841
20980
  isLatestMessage = true,
@@ -20844,7 +20983,7 @@ var CreatorSearch = import_react87.default.memo(
20844
20983
  data,
20845
20984
  ...formCardProps
20846
20985
  }) => {
20847
- const fields = (0, import_react87.useMemo)(() => {
20986
+ const fields = (0, import_react88.useMemo)(() => {
20848
20987
  const baseFields = providedFields || generateFieldsFromData(data);
20849
20988
  return baseFields.map((field) => {
20850
20989
  if (field.key === "platforms") {
@@ -20924,10 +21063,10 @@ var CreatorSearch = import_react87.default.memo(
20924
21063
  CreatorSearch.displayName = "CreatorSearch";
20925
21064
 
20926
21065
  // src/molecules/creator-discovery/CampaignConceptCard/CampaignConceptCard.tsx
20927
- var import_react88 = __toESM(require("react"), 1);
21066
+ var import_react89 = __toESM(require("react"), 1);
20928
21067
  var import_framer_motion = require("framer-motion");
20929
21068
  var import_jsx_runtime169 = require("react/jsx-runtime");
20930
- var CampaignConceptCard = import_react88.default.memo(
21069
+ var CampaignConceptCard = import_react89.default.memo(
20931
21070
  ({
20932
21071
  index,
20933
21072
  isRecommended,
@@ -20943,7 +21082,7 @@ var CampaignConceptCard = import_react88.default.memo(
20943
21082
  onAction,
20944
21083
  ...formCardProps
20945
21084
  }) => {
20946
- const [internalIsOpen, setInternalIsOpen] = (0, import_react88.useState)(false);
21085
+ const [internalIsOpen, setInternalIsOpen] = (0, import_react89.useState)(false);
20947
21086
  const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
20948
21087
  const handleToggle = () => {
20949
21088
  if (onToggle) {
@@ -20962,7 +21101,7 @@ var CampaignConceptCard = import_react88.default.memo(
20962
21101
  });
20963
21102
  };
20964
21103
  const effectiveIsLatest = isLatestMessage && !hasUserResponded;
20965
- const fields = (0, import_react88.useMemo)(() => {
21104
+ const fields = (0, import_react89.useMemo)(() => {
20966
21105
  const baseFields = providedFields || generateFieldsFromData(data);
20967
21106
  const FIELD_ORDER = [
20968
21107
  "description",
@@ -21274,14 +21413,14 @@ var CampaignConceptCard = import_react88.default.memo(
21274
21413
  CampaignConceptCard.displayName = "CampaignConceptCard";
21275
21414
 
21276
21415
  // src/molecules/creator-discovery/CreatorWidget/CreatorWidget.tsx
21277
- var import_react96 = require("react");
21416
+ var import_react97 = require("react");
21278
21417
 
21279
21418
  // src/molecules/creator-discovery/CreatorWidget/CreatorImageList.tsx
21280
- var import_react89 = require("react");
21419
+ var import_react90 = require("react");
21281
21420
  var import_jsx_runtime170 = require("react/jsx-runtime");
21282
21421
  function useMediaQuery(query) {
21283
- const [matches, setMatches] = (0, import_react89.useState)(false);
21284
- (0, import_react89.useEffect)(() => {
21422
+ const [matches, setMatches] = (0, import_react90.useState)(false);
21423
+ (0, import_react90.useEffect)(() => {
21285
21424
  const media = window.matchMedia(query);
21286
21425
  const listener = () => setMatches(media.matches);
21287
21426
  listener();
@@ -21364,7 +21503,7 @@ function CreatorImageList({
21364
21503
  }
21365
21504
 
21366
21505
  // src/molecules/creator-discovery/CreatorWidget/CreatorProgressBar.tsx
21367
- var import_react90 = require("react");
21506
+ var import_react91 = require("react");
21368
21507
  var import_framer_motion2 = require("framer-motion");
21369
21508
  var import_jsx_runtime171 = require("react/jsx-runtime");
21370
21509
  function truncateName(name, maxLength) {
@@ -21372,8 +21511,8 @@ function truncateName(name, maxLength) {
21372
21511
  return name.substring(0, maxLength) + "...";
21373
21512
  }
21374
21513
  function ProgressBar({ overallPercentage }) {
21375
- const [showTooltip, setShowTooltip] = (0, import_react90.useState)(true);
21376
- (0, import_react90.useEffect)(() => {
21514
+ const [showTooltip, setShowTooltip] = (0, import_react91.useState)(true);
21515
+ (0, import_react91.useEffect)(() => {
21377
21516
  if (overallPercentage && overallPercentage >= 100) {
21378
21517
  setShowTooltip(false);
21379
21518
  }
@@ -21534,7 +21673,7 @@ function CreatorCompactView({
21534
21673
  }
21535
21674
 
21536
21675
  // src/molecules/creator-discovery/CreatorWidget/CreatorExpandedPanel.tsx
21537
- var import_react94 = require("react");
21676
+ var import_react95 = require("react");
21538
21677
  var import_react_dom2 = __toESM(require("react-dom"), 1);
21539
21678
  var import_framer_motion5 = require("framer-motion");
21540
21679
 
@@ -22008,7 +22147,7 @@ function getPlatformIconColor(platform) {
22008
22147
  }
22009
22148
 
22010
22149
  // src/molecules/creator-discovery/CreatorWidget/PostCard.tsx
22011
- var import_react91 = require("react");
22150
+ var import_react92 = require("react");
22012
22151
  var import_jsx_runtime176 = require("react/jsx-runtime");
22013
22152
  var formatFollowerCount = (count) => {
22014
22153
  if (count >= 1e6) {
@@ -22022,8 +22161,8 @@ var formatFollowerCount = (count) => {
22022
22161
  return Math.floor(count).toString();
22023
22162
  };
22024
22163
  function PostCard({ post, platformUsername }) {
22025
- const [expanded, setExpanded] = (0, import_react91.useState)(false);
22026
- const [errored, setErrored] = (0, import_react91.useState)(false);
22164
+ const [expanded, setExpanded] = (0, import_react92.useState)(false);
22165
+ const [errored, setErrored] = (0, import_react92.useState)(false);
22027
22166
  const thumbnail = post.thumbnail_url || post.thumbnail || post.image || "";
22028
22167
  const likes = post.engagement?.likes ?? post.likes ?? null;
22029
22168
  const comments = post.engagement?.comments ?? post.comments ?? null;
@@ -22233,7 +22372,7 @@ function PlatformPostsSection({
22233
22372
  }
22234
22373
 
22235
22374
  // src/molecules/creator-discovery/CreatorWidget/BrandCollaborationsList.tsx
22236
- var import_react92 = require("react");
22375
+ var import_react93 = require("react");
22237
22376
  var import_react_dom = __toESM(require("react-dom"), 1);
22238
22377
  var import_framer_motion3 = require("framer-motion");
22239
22378
  var import_jsx_runtime178 = require("react/jsx-runtime");
@@ -22435,8 +22574,8 @@ function BrandMentionDetails({
22435
22574
  function BrandCollaborationsList({
22436
22575
  brandBreakdown
22437
22576
  }) {
22438
- const [openDetails, setOpenDetails] = (0, import_react92.useState)(false);
22439
- const [selectedBrand, setSelectedBrand] = (0, import_react92.useState)("");
22577
+ const [openDetails, setOpenDetails] = (0, import_react93.useState)(false);
22578
+ const [selectedBrand, setSelectedBrand] = (0, import_react93.useState)("");
22440
22579
  if (!brandBreakdown?.insights?.brandBreakdown || brandBreakdown.insights.brandBreakdown.length === 0) {
22441
22580
  return null;
22442
22581
  }
@@ -22495,7 +22634,7 @@ function BrandCollaborationsList({
22495
22634
  }
22496
22635
 
22497
22636
  // src/molecules/creator-discovery/CreatorWidget/CreatorGridView.tsx
22498
- var import_react93 = require("react");
22637
+ var import_react94 = require("react");
22499
22638
  var import_framer_motion4 = require("framer-motion");
22500
22639
  var import_jsx_runtime179 = require("react/jsx-runtime");
22501
22640
  var formatFollowerCount3 = (count) => {
@@ -22544,25 +22683,25 @@ var itemsExplanation = [
22544
22683
  { key: "brandSafety", label: "Brand Safety" }
22545
22684
  ];
22546
22685
  function CreatorGridViewCard({ creator }) {
22547
- const [isExpanded, setIsExpanded] = (0, import_react93.useState)(false);
22548
- const [showFullDescription, setShowFullDescription] = (0, import_react93.useState)(false);
22549
- const [isDescriptionOverflowing, setIsDescriptionOverflowing] = (0, import_react93.useState)(false);
22550
- const descriptionRef = (0, import_react93.useRef)(null);
22551
- const cardRef = (0, import_react93.useRef)(null);
22552
- const checkDescriptionOverflow = (0, import_react93.useCallback)(() => {
22686
+ const [isExpanded, setIsExpanded] = (0, import_react94.useState)(false);
22687
+ const [showFullDescription, setShowFullDescription] = (0, import_react94.useState)(false);
22688
+ const [isDescriptionOverflowing, setIsDescriptionOverflowing] = (0, import_react94.useState)(false);
22689
+ const descriptionRef = (0, import_react94.useRef)(null);
22690
+ const cardRef = (0, import_react94.useRef)(null);
22691
+ const checkDescriptionOverflow = (0, import_react94.useCallback)(() => {
22553
22692
  const el = descriptionRef.current;
22554
22693
  if (!el) return;
22555
22694
  setIsDescriptionOverflowing(el.scrollHeight > el.clientHeight + 1);
22556
22695
  }, []);
22557
- (0, import_react93.useEffect)(() => {
22696
+ (0, import_react94.useEffect)(() => {
22558
22697
  checkDescriptionOverflow();
22559
22698
  }, [checkDescriptionOverflow, isExpanded, showFullDescription]);
22560
- (0, import_react93.useEffect)(() => {
22699
+ (0, import_react94.useEffect)(() => {
22561
22700
  const onResize = () => checkDescriptionOverflow();
22562
22701
  window.addEventListener("resize", onResize);
22563
22702
  return () => window.removeEventListener("resize", onResize);
22564
22703
  }, [checkDescriptionOverflow]);
22565
- const platformStats = (0, import_react93.useMemo)(() => {
22704
+ const platformStats = (0, import_react94.useMemo)(() => {
22566
22705
  return [
22567
22706
  {
22568
22707
  platform: "instagram",
@@ -22991,7 +23130,7 @@ function BrandMentionPerformance({ creator }) {
22991
23130
  ] });
22992
23131
  }
22993
23132
  function CreatorFitSummary({ creator, showBrandPerformance }) {
22994
- const [contentExpanded, setContentExpanded] = (0, import_react94.useState)(false);
23133
+ const [contentExpanded, setContentExpanded] = (0, import_react95.useState)(false);
22995
23134
  const hasDeepAnalysis = creator?.sentiment?.deepAnalysis?.deepAnalysis;
22996
23135
  const title = hasDeepAnalysis ? "CREATOR DEEP ANALYSIS" : "CREATOR FIT SUMMARY";
22997
23136
  const content = hasDeepAnalysis ? creator.sentiment.deepAnalysis.deepAnalysis : creator?.sentiment?.aiReasoning || "No data available.";
@@ -23011,7 +23150,7 @@ function CreatorFitSummary({ creator, showBrandPerformance }) {
23011
23150
  ] });
23012
23151
  }
23013
23152
  function ProfileSection({ creator, isValidationComplete }) {
23014
- const [descriptionExpanded, setDescriptionExpanded] = (0, import_react94.useState)(false);
23153
+ const [descriptionExpanded, setDescriptionExpanded] = (0, import_react95.useState)(false);
23015
23154
  const username = creator.platformMetrics?.instagramMetrics?.username ? `@${creator.platformMetrics.instagramMetrics.username}` : creator.platformMetrics?.youtubeMetrics?.channelName ? `@${creator.platformMetrics.youtubeMetrics.channelName}` : creator.platformMetrics?.tiktokMetrics?.username ? `@${creator.platformMetrics.tiktokMetrics.username}` : "";
23016
23155
  const iso2 = normalizeToIso2(creator.country);
23017
23156
  const meta = codeToMeta[iso2];
@@ -23101,7 +23240,7 @@ function CreatorCard({
23101
23240
  creator,
23102
23241
  isValidationComplete
23103
23242
  }) {
23104
- const [detailsExpanded, setDetailsExpanded] = (0, import_react94.useState)(false);
23243
+ const [detailsExpanded, setDetailsExpanded] = (0, import_react95.useState)(false);
23105
23244
  const hasValidBrandMention = (() => {
23106
23245
  const insights = creator?.brandCollaborations?.insights;
23107
23246
  if (!insights) return false;
@@ -23143,7 +23282,7 @@ function CreatorDisplay({
23143
23282
  creators,
23144
23283
  isValidationComplete
23145
23284
  }) {
23146
- const [viewMode, setViewMode] = (0, import_react94.useState)("list");
23285
+ const [viewMode, setViewMode] = (0, import_react95.useState)("list");
23147
23286
  return /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("div", { className: "px-4", children: [
23148
23287
  /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("div", { className: "flex justify-end items-center my-3 gap-1", children: [
23149
23288
  /* @__PURE__ */ (0, import_jsx_runtime180.jsxs)("span", { className: "text-xs text-gray600 mr-2", children: [
@@ -23234,10 +23373,10 @@ function CreatorExpandedPanel({
23234
23373
  searchSpec,
23235
23374
  fetchCreatorDetails
23236
23375
  }) {
23237
- const [creators, setCreators] = (0, import_react94.useState)([]);
23238
- const [loading, setLoading] = (0, import_react94.useState)(false);
23376
+ const [creators, setCreators] = (0, import_react95.useState)([]);
23377
+ const [loading, setLoading] = (0, import_react95.useState)(false);
23239
23378
  const fetcher = fetchCreatorDetails ?? defaultFetchCreatorDetails;
23240
- const loadCreators = (0, import_react94.useCallback)(async () => {
23379
+ const loadCreators = (0, import_react95.useCallback)(async () => {
23241
23380
  if (!creatorIds.length) return;
23242
23381
  setLoading(true);
23243
23382
  try {
@@ -23249,7 +23388,7 @@ function CreatorExpandedPanel({
23249
23388
  setLoading(false);
23250
23389
  }
23251
23390
  }, [creatorIds, sessionId, version, fetcher]);
23252
- (0, import_react94.useEffect)(() => {
23391
+ (0, import_react95.useEffect)(() => {
23253
23392
  if (isOpen && creatorIds.length > 0) {
23254
23393
  loadCreators();
23255
23394
  }
@@ -23303,7 +23442,7 @@ function CreatorExpandedPanel({
23303
23442
  }
23304
23443
 
23305
23444
  // src/molecules/creator-discovery/CreatorWidget/useCreatorWidgetPolling.ts
23306
- var import_react95 = require("react");
23445
+ var import_react96 = require("react");
23307
23446
  var DEFAULT_POLLING_CONFIG = {
23308
23447
  pollInterval: 5e3,
23309
23448
  maxDuration: 15 * 60 * 1e3,
@@ -23334,11 +23473,11 @@ function useCreatorWidgetPolling({
23334
23473
  }) {
23335
23474
  const fetchVersions = fetchVersionsProp ?? defaultFetchVersions;
23336
23475
  const fetchStatus = fetchStatusProp ?? defaultFetchStatus;
23337
- const config = (0, import_react95.useMemo)(
23476
+ const config = (0, import_react96.useMemo)(
23338
23477
  () => ({ ...DEFAULT_POLLING_CONFIG, ...pollingConfig }),
23339
23478
  [pollingConfig]
23340
23479
  );
23341
- const hydrated = (0, import_react95.useMemo)(() => {
23480
+ const hydrated = (0, import_react96.useMemo)(() => {
23342
23481
  if (!sessionId) {
23343
23482
  return {
23344
23483
  versionData: null,
@@ -23360,33 +23499,33 @@ function useCreatorWidgetPolling({
23360
23499
  }, [sessionId, currentVersion]);
23361
23500
  const hydratedStatus = hydrated.statusPayload?.status?.status;
23362
23501
  const hydratedTerminal = isTerminalStatus(hydratedStatus);
23363
- const [versionData, setVersionData] = (0, import_react95.useState)(
23502
+ const [versionData, setVersionData] = (0, import_react96.useState)(
23364
23503
  hydrated.versionData
23365
23504
  );
23366
- const [totalVersions, setTotalVersions] = (0, import_react95.useState)(
23505
+ const [totalVersions, setTotalVersions] = (0, import_react96.useState)(
23367
23506
  hydrated.versionData?.totalVersions || 0
23368
23507
  );
23369
- const [selectedVersion, setSelectedVersion] = (0, import_react95.useState)();
23370
- const [isLoadingVersion, setIsLoadingVersion] = (0, import_react95.useState)(!hydrated.versionData);
23371
- const [isValidationComplete, setIsValidationComplete] = (0, import_react95.useState)(
23508
+ const [selectedVersion, setSelectedVersion] = (0, import_react96.useState)();
23509
+ const [isLoadingVersion, setIsLoadingVersion] = (0, import_react96.useState)(!hydrated.versionData);
23510
+ const [isValidationComplete, setIsValidationComplete] = (0, import_react96.useState)(
23372
23511
  hydratedTerminal && hydratedStatus !== "failed"
23373
23512
  );
23374
- const [versionStatus, setVersionStatus] = (0, import_react95.useState)(
23513
+ const [versionStatus, setVersionStatus] = (0, import_react96.useState)(
23375
23514
  hydratedStatus || (hydrated.versionData ? "in-progress" : "checking")
23376
23515
  );
23377
- const [statusDetails, setStatusDetails] = (0, import_react95.useState)(
23516
+ const [statusDetails, setStatusDetails] = (0, import_react96.useState)(
23378
23517
  hydrated.statusPayload?.status
23379
23518
  );
23380
- const [timeDisplay, setTimeDisplay] = (0, import_react95.useState)("");
23381
- const [loadingStatus, setLoadingStatus] = (0, import_react95.useState)(
23519
+ const [timeDisplay, setTimeDisplay] = (0, import_react96.useState)("");
23520
+ const [loadingStatus, setLoadingStatus] = (0, import_react96.useState)(
23382
23521
  !(hydrated.versionData && hydratedTerminal)
23383
23522
  );
23384
- const remainingTimeRef = (0, import_react95.useRef)(0);
23385
- const countdownRef = (0, import_react95.useRef)(null);
23386
- const versionDataRef = (0, import_react95.useRef)(versionData);
23523
+ const remainingTimeRef = (0, import_react96.useRef)(0);
23524
+ const countdownRef = (0, import_react96.useRef)(null);
23525
+ const versionDataRef = (0, import_react96.useRef)(versionData);
23387
23526
  versionDataRef.current = versionData;
23388
23527
  const requestedVersion = selectedVersion ?? currentVersion ?? versionData?.currentVersion;
23389
- const updateStatus = (0, import_react95.useCallback)(
23528
+ const updateStatus = (0, import_react96.useCallback)(
23390
23529
  (status) => {
23391
23530
  setVersionStatus(status);
23392
23531
  onStatusChange?.(status);
@@ -23424,17 +23563,17 @@ function useCreatorWidgetPolling({
23424
23563
  );
23425
23564
  const activeVersion = selectedVersion ?? requestedVersion;
23426
23565
  const statusKey = sessionId && activeVersion != null ? statusPollKey(sessionId, activeVersion) : null;
23427
- const errorCountRef = (0, import_react95.useRef)(0);
23428
- const deadlineRef = (0, import_react95.useRef)(0);
23429
- const doneRef = (0, import_react95.useRef)(hydratedTerminal);
23430
- const stopCountdown = (0, import_react95.useCallback)(() => {
23566
+ const errorCountRef = (0, import_react96.useRef)(0);
23567
+ const deadlineRef = (0, import_react96.useRef)(0);
23568
+ const doneRef = (0, import_react96.useRef)(hydratedTerminal);
23569
+ const stopCountdown = (0, import_react96.useCallback)(() => {
23431
23570
  if (countdownRef.current) {
23432
23571
  clearInterval(countdownRef.current);
23433
23572
  countdownRef.current = null;
23434
23573
  }
23435
23574
  setTimeDisplay("");
23436
23575
  }, []);
23437
- (0, import_react95.useEffect)(() => {
23576
+ (0, import_react96.useEffect)(() => {
23438
23577
  if (statusKey == null) return;
23439
23578
  const cached = getSharedPollLastData(statusKey);
23440
23579
  const cachedStatus = cached?.status?.status;
@@ -23515,7 +23654,7 @@ function useCreatorWidgetPolling({
23515
23654
  setLoadingStatus(false);
23516
23655
  }
23517
23656
  );
23518
- const versionNumbers = (0, import_react95.useMemo)(() => {
23657
+ const versionNumbers = (0, import_react96.useMemo)(() => {
23519
23658
  if (!totalVersions) return [];
23520
23659
  return Array.from({ length: totalVersions }, (_, i) => i + 1);
23521
23660
  }, [totalVersions]);
@@ -23555,7 +23694,7 @@ function CreatorWidgetInner({
23555
23694
  onAction,
23556
23695
  className
23557
23696
  }) {
23558
- const [isExpanded, setIsExpanded] = (0, import_react96.useState)(false);
23697
+ const [isExpanded, setIsExpanded] = (0, import_react97.useState)(false);
23559
23698
  const {
23560
23699
  versionNumbers,
23561
23700
  selectedVersion,
@@ -23576,11 +23715,11 @@ function CreatorWidgetInner({
23576
23715
  pollingConfig,
23577
23716
  onStatusChange
23578
23717
  });
23579
- const handleVersionSelect = (0, import_react96.useCallback)(
23718
+ const handleVersionSelect = (0, import_react97.useCallback)(
23580
23719
  (version) => setSelectedVersion(version),
23581
23720
  [setSelectedVersion]
23582
23721
  );
23583
- const handleViewCreators = (0, import_react96.useCallback)(() => {
23722
+ const handleViewCreators = (0, import_react97.useCallback)(() => {
23584
23723
  setIsExpanded(true);
23585
23724
  onAction?.({
23586
23725
  type: "view-creators",
@@ -23621,10 +23760,10 @@ function CreatorWidgetInner({
23621
23760
  )
23622
23761
  ] });
23623
23762
  }
23624
- var CreatorWidget = (0, import_react96.memo)(CreatorWidgetInner);
23763
+ var CreatorWidget = (0, import_react97.memo)(CreatorWidgetInner);
23625
23764
 
23626
23765
  // src/molecules/analytics/AnalyticsChart.tsx
23627
- var import_react97 = require("react");
23766
+ var import_react98 = require("react");
23628
23767
 
23629
23768
  // src/molecules/analytics/buildOptions.ts
23630
23769
  function deepMerge(base, override) {
@@ -23956,13 +24095,13 @@ function AnalyticsChart({
23956
24095
  loading: loadingProp,
23957
24096
  error: errorProp
23958
24097
  }) {
23959
- const [mounted, setMounted] = (0, import_react97.useState)(false);
23960
- const [fetchedConfig, setFetchedConfig] = (0, import_react97.useState)(null);
23961
- const [fetching, setFetching] = (0, import_react97.useState)(false);
23962
- const [fetchError, setFetchError] = (0, import_react97.useState)(null);
23963
- const containerRef = (0, import_react97.useRef)(null);
23964
- const chartRef = (0, import_react97.useRef)(null);
23965
- const declarative = (0, import_react97.useMemo)(
24098
+ const [mounted, setMounted] = (0, import_react98.useState)(false);
24099
+ const [fetchedConfig, setFetchedConfig] = (0, import_react98.useState)(null);
24100
+ const [fetching, setFetching] = (0, import_react98.useState)(false);
24101
+ const [fetchError, setFetchError] = (0, import_react98.useState)(null);
24102
+ const containerRef = (0, import_react98.useRef)(null);
24103
+ const chartRef = (0, import_react98.useRef)(null);
24104
+ const declarative = (0, import_react98.useMemo)(
23966
24105
  () => resolveDeclarativeConfig({
23967
24106
  chartConfig,
23968
24107
  chartType,
@@ -23996,16 +24135,16 @@ function AnalyticsChart({
23996
24135
  height
23997
24136
  ]
23998
24137
  );
23999
- const builtConfig = (0, import_react97.useMemo)(() => {
24138
+ const builtConfig = (0, import_react98.useMemo)(() => {
24000
24139
  if (!declarative) return null;
24001
24140
  const palette = buildChartPalette(theme, mode);
24002
24141
  const options = buildChartOptions(declarative, palette);
24003
24142
  return extraOptions ? deepMerge(options, extraOptions) : options;
24004
24143
  }, [declarative, theme, mode, extraOptions]);
24005
- (0, import_react97.useEffect)(() => {
24144
+ (0, import_react98.useEffect)(() => {
24006
24145
  setMounted(true);
24007
24146
  }, []);
24008
- (0, import_react97.useEffect)(() => {
24147
+ (0, import_react98.useEffect)(() => {
24009
24148
  if (!chartId || configProp || builtConfig) return;
24010
24149
  let cancelled = false;
24011
24150
  setFetching(true);
@@ -24027,7 +24166,7 @@ function AnalyticsChart({
24027
24166
  };
24028
24167
  }, [chartId, apiBase, authToken, configProp, builtConfig]);
24029
24168
  const activeConfig = configProp ?? builtConfig ?? fetchedConfig;
24030
- (0, import_react97.useEffect)(() => {
24169
+ (0, import_react98.useEffect)(() => {
24031
24170
  if (!mounted || !activeConfig || !containerRef.current) return;
24032
24171
  const container = containerRef.current;
24033
24172
  let cancelled = false;
@@ -24047,7 +24186,7 @@ function AnalyticsChart({
24047
24186
  cancelled = true;
24048
24187
  };
24049
24188
  }, [mounted, activeConfig]);
24050
- (0, import_react97.useEffect)(() => {
24189
+ (0, import_react98.useEffect)(() => {
24051
24190
  return () => {
24052
24191
  if (chartRef.current) {
24053
24192
  try {
@@ -24058,7 +24197,7 @@ function AnalyticsChart({
24058
24197
  }
24059
24198
  };
24060
24199
  }, []);
24061
- (0, import_react97.useEffect)(() => {
24200
+ (0, import_react98.useEffect)(() => {
24062
24201
  if (!mounted || !containerRef.current) return;
24063
24202
  const obs = new ResizeObserver(() => {
24064
24203
  try {
@@ -24540,7 +24679,7 @@ function EmptyContent({ className, ...props }) {
24540
24679
  }
24541
24680
 
24542
24681
  // src/components/ui/field.tsx
24543
- var import_react98 = require("react");
24682
+ var import_react99 = require("react");
24544
24683
  var import_class_variance_authority10 = require("class-variance-authority");
24545
24684
  var import_jsx_runtime185 = require("react/jsx-runtime");
24546
24685
  function FieldSet({ className, ...props }) {
@@ -24723,7 +24862,7 @@ function FieldError({
24723
24862
  errors,
24724
24863
  ...props
24725
24864
  }) {
24726
- const content = (0, import_react98.useMemo)(() => {
24865
+ const content = (0, import_react99.useMemo)(() => {
24727
24866
  if (children) {
24728
24867
  return children;
24729
24868
  }
@@ -26004,18 +26143,18 @@ var FORM_INPUT_ATOM_NAMES = /* @__PURE__ */ new Set([
26004
26143
  "InputOTPAtom",
26005
26144
  "ToggleAtom"
26006
26145
  ]);
26007
- var PXEngineRenderer = import_react99.default.memo(function PXEngineRenderer2({
26146
+ var PXEngineRenderer = import_react100.default.memo(function PXEngineRenderer2({
26008
26147
  schema,
26009
26148
  onAction,
26010
26149
  disabled,
26011
26150
  theme,
26012
26151
  onFormSubmit
26013
26152
  }) {
26014
- const contextTheme = import_react99.default.useContext(WidgetThemeContext);
26153
+ const contextTheme = import_react100.default.useContext(WidgetThemeContext);
26015
26154
  const effectiveTheme = theme ?? contextTheme;
26016
- const formValuesRef = import_react99.default.useRef({});
26017
- const [, forceUpdate] = import_react99.default.useReducer((x) => x + 1, 0);
26018
- const handleInputValueChange = import_react99.default.useCallback((key, value) => {
26155
+ const formValuesRef = import_react100.default.useRef({});
26156
+ const [, forceUpdate] = import_react100.default.useReducer((x) => x + 1, 0);
26157
+ const handleInputValueChange = import_react100.default.useCallback((key, value) => {
26019
26158
  formValuesRef.current[key] = value;
26020
26159
  forceUpdate();
26021
26160
  }, []);
@@ -26023,12 +26162,12 @@ var PXEngineRenderer = import_react99.default.memo(function PXEngineRenderer2({
26023
26162
  const root = schema.root || schema;
26024
26163
  const renderRecursive = (component, index) => {
26025
26164
  if (Array.isArray(component)) {
26026
- return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_react99.default.Fragment, { children: component.map((child, idx) => renderRecursive(child, idx)) }, index !== void 0 ? `array-${index}` : "array-root");
26165
+ return /* @__PURE__ */ (0, import_jsx_runtime192.jsx)(import_react100.default.Fragment, { children: component.map((child, idx) => renderRecursive(child, idx)) }, index !== void 0 ? `array-${index}` : "array-root");
26027
26166
  }
26028
26167
  if (typeof component === "string" || typeof component === "number") {
26029
26168
  return component;
26030
26169
  }
26031
- if (import_react99.default.isValidElement(component)) {
26170
+ if (import_react100.default.isValidElement(component)) {
26032
26171
  return component;
26033
26172
  }
26034
26173
  if (!component || typeof component !== "object") return null;
@@ -26335,6 +26474,7 @@ PXEngineRenderer.displayName = "PXEngineRenderer";
26335
26474
  InputWidget,
26336
26475
  InsightDigestCard,
26337
26476
  InsightSummaryCard,
26477
+ JOB_SIGNAL_EVENT,
26338
26478
  KPIStatsCard,
26339
26479
  KbdAtom,
26340
26480
  KeywordBundlesDisplay,
@@ -26395,6 +26535,7 @@ PXEngineRenderer.displayName = "PXEngineRenderer";
26395
26535
  ResizablePanel,
26396
26536
  ResizablePanelGroup,
26397
26537
  RiskSignalCard,
26538
+ SSE_FALLBACK_POLL_MS,
26398
26539
  ScoreBreakdownCard,
26399
26540
  ScrollArea,
26400
26541
  ScrollAreaAtom,
@@ -26465,17 +26606,21 @@ PXEngineRenderer.displayName = "PXEngineRenderer";
26465
26606
  defaultFetchSelections,
26466
26607
  defaultPersistSelection,
26467
26608
  elementToQAField,
26609
+ emitJobSignal,
26468
26610
  formatQAMessage,
26469
26611
  generateFieldsFromData,
26470
26612
  generateFieldsFromPropDefinitions,
26471
26613
  getPxAuthToken,
26472
26614
  isInputAtom,
26473
26615
  notifyPxUnauthorized,
26616
+ refreshSharedPoll,
26474
26617
  setPxAuthTokenProvider,
26475
26618
  setPxUnauthorizedHandler,
26476
26619
  submitWidgetToAgent,
26620
+ subscribeJobSignal,
26477
26621
  th,
26478
26622
  useCreatorWidgetPolling,
26623
+ useJobSignal,
26479
26624
  useWidgetTheme,
26480
26625
  withAlpha
26481
26626
  });