@40rty/ams-sdk 0.5.12 → 0.5.13
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.js +583 -396
- package/dist/types/ecommerce/src/index.d.ts +1 -0
- package/dist/types/ecommerce/src/installment-offer.d.ts +42 -0
- package/dist/types/sdk/src/canvas/canvas-lead.d.ts +23 -0
- package/dist/types/sdk/src/canvas/index.d.ts +1 -0
- package/dist/types/sdk/src/host/host-modules.d.ts +12 -0
- package/dist/types/sdk/src/shell/conversation/answer-text.d.ts +7 -0
- package/dist/types/sdk/src/shell/conversation/index.d.ts +1 -1
- package/dist/types/sdk/src/shell/index.d.ts +1 -0
- package/dist/types/sdk/src/shell/submit-origin.d.ts +40 -0
- package/dist/types/sdk/src/shell/use-prompt-composer.d.ts +6 -0
- package/dist/types/sdk/src/verticals/commerce/commerce-context.d.ts +9 -1
- package/dist/types/sdk/src/verticals/commerce/commerce-shapes.d.ts +3 -2
- package/dist/types/sdk/src/verticals/commerce/index.d.ts +1 -1
- package/dist/types/spacestation/src/index.d.ts +1 -0
- package/dist/types/spacestation/src/signal/chip-show.d.ts +10 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -71,6 +71,7 @@ __export(src_exports3, {
|
|
|
71
71
|
CHECKOUT_OUTCOMES: () => CHECKOUT_OUTCOMES,
|
|
72
72
|
CHECKOUT_REACHED_OUTCOMES: () => CHECKOUT_REACHED_OUTCOMES,
|
|
73
73
|
CHECKOUT_REFUSALS: () => CHECKOUT_REFUSALS,
|
|
74
|
+
CHIP_SHOW_SIGNAL: () => CHIP_SHOW_SIGNAL,
|
|
74
75
|
CLICK_ID_KINDS: () => CLICK_ID_KINDS,
|
|
75
76
|
CLIENT_STATE_HELLO_SIGNAL: () => CLIENT_STATE_HELLO_SIGNAL,
|
|
76
77
|
COMPONENT_SOURCE: () => COMPONENT_SOURCE,
|
|
@@ -80,6 +81,8 @@ __export(src_exports3, {
|
|
|
80
81
|
CONTINUATION_ENABLED: () => CONTINUATION_ENABLED,
|
|
81
82
|
CUSTOMER_ACCOUNT_SESSION_HEADER: () => CUSTOMER_ACCOUNT_SESSION_HEADER,
|
|
82
83
|
CanvasArrangementProvider: () => CanvasArrangementProvider,
|
|
84
|
+
CanvasLeadProvider: () => CanvasLeadProvider,
|
|
85
|
+
CanvasLeadSlot: () => CanvasLeadSlot,
|
|
83
86
|
CanvasMotionStyleProvider: () => CanvasMotionStyleProvider,
|
|
84
87
|
CanvasOutletProvider: () => CanvasOutletProvider,
|
|
85
88
|
CanvasTailMount: () => CanvasTailMount,
|
|
@@ -338,6 +341,7 @@ __export(src_exports3, {
|
|
|
338
341
|
catalogToWire: () => catalogToWire,
|
|
339
342
|
changeAnchorWithin: () => changeAnchorWithin,
|
|
340
343
|
checkoutHandoffReasonFor: () => checkoutHandoffReasonFor,
|
|
344
|
+
chipsFromShowSignal: () => chipsFromShowSignal,
|
|
341
345
|
claimExclusiveOverlay: () => claimExclusiveOverlay,
|
|
342
346
|
classifyComparisonValue: () => classifyComparisonValue,
|
|
343
347
|
classifyItemChange: () => classifyItemChange,
|
|
@@ -413,6 +417,8 @@ __export(src_exports3, {
|
|
|
413
417
|
hostPlace: () => hostPlace,
|
|
414
418
|
hostingAllows: () => hostingAllows,
|
|
415
419
|
injectGoogleFonts: () => injectGoogleFonts,
|
|
420
|
+
installmentOffer: () => installmentOffer,
|
|
421
|
+
installmentPayment: () => installmentPayment,
|
|
416
422
|
isActiveDirective: () => isActiveDirective,
|
|
417
423
|
isAllowedAttachmentType: () => isAllowedAttachmentType,
|
|
418
424
|
isDegenerateLayout: () => isDegenerateLayout,
|
|
@@ -563,6 +569,7 @@ __export(src_exports3, {
|
|
|
563
569
|
surfaceEmits: () => surfaceEmits,
|
|
564
570
|
surfaceSuppressionReason: () => surfaceSuppressionReason,
|
|
565
571
|
takeQueuedDiscountCodes: () => takeQueuedDiscountCodes,
|
|
572
|
+
takeSubmitOrigin: () => takeSubmitOrigin,
|
|
566
573
|
text: () => text,
|
|
567
574
|
textDirectionOf: () => textDirectionOf,
|
|
568
575
|
threadRowAttrs: () => threadRowAttrs,
|
|
@@ -589,6 +596,8 @@ __export(src_exports3, {
|
|
|
589
596
|
useCanvasArrangement: () => useCanvasArrangement,
|
|
590
597
|
useCanvasBack: () => useCanvasBack,
|
|
591
598
|
useCanvasForward: () => useCanvasForward,
|
|
599
|
+
useCanvasLead: () => useCanvasLead,
|
|
600
|
+
useCanvasLeadTarget: () => useCanvasLeadTarget,
|
|
592
601
|
useCanvasMotionStyle: () => useCanvasMotionStyle,
|
|
593
602
|
useCanvasTail: () => useCanvasTail,
|
|
594
603
|
useCanvasViewBack: () => useCanvasViewBack,
|
|
@@ -650,6 +659,7 @@ __export(src_exports3, {
|
|
|
650
659
|
useHydrationState: () => useHydrationState,
|
|
651
660
|
useHydrators: () => useHydrators,
|
|
652
661
|
useInlineCompletion: () => useInlineCompletion,
|
|
662
|
+
useInstallmentOffer: () => useInstallmentOffer,
|
|
653
663
|
useInteraction: () => useInteraction,
|
|
654
664
|
useInteractionTracking: () => useInteraction2,
|
|
655
665
|
useInterval: () => useInterval,
|
|
@@ -724,6 +734,7 @@ __export(src_exports3, {
|
|
|
724
734
|
useVisibleFactList: () => useVisibleFactList,
|
|
725
735
|
useVisitorName: () => useVisitorName,
|
|
726
736
|
useVoiceCapture: () => useVoiceCapture,
|
|
737
|
+
useWaitingSubmitOrigin: () => useWaitingSubmitOrigin,
|
|
727
738
|
useWakeLock: () => useWakeLock,
|
|
728
739
|
useWishlist: () => useWishlist,
|
|
729
740
|
useWishlistDrawer: () => useWishlistDrawer,
|
|
@@ -736,7 +747,8 @@ __export(src_exports3, {
|
|
|
736
747
|
withCartActorOrigin: () => withCartActorOrigin,
|
|
737
748
|
withInteractionTracking: () => withInteractionTracking,
|
|
738
749
|
withQueuedDiscountCodes: () => withQueuedDiscountCodes,
|
|
739
|
-
withSignalTurn: () => withSignalTurn
|
|
750
|
+
withSignalTurn: () => withSignalTurn,
|
|
751
|
+
withoutClosingQuestion: () => withoutClosingQuestion
|
|
740
752
|
});
|
|
741
753
|
|
|
742
754
|
// src/analytics/index.ts
|
|
@@ -1540,6 +1552,7 @@ __export(src_exports, {
|
|
|
1540
1552
|
CART_REMOVE_SIGNAL: () => CART_REMOVE_SIGNAL,
|
|
1541
1553
|
CART_SET_QUANTITY_SIGNAL: () => CART_SET_QUANTITY_SIGNAL,
|
|
1542
1554
|
CHECKOUT_BEGIN_SIGNAL: () => CHECKOUT_BEGIN_SIGNAL,
|
|
1555
|
+
CHIP_SHOW_SIGNAL: () => CHIP_SHOW_SIGNAL,
|
|
1543
1556
|
CLICK_ID_KINDS: () => CLICK_ID_KINDS,
|
|
1544
1557
|
CLIENT_STATE_HELLO_SIGNAL: () => CLIENT_STATE_HELLO_SIGNAL,
|
|
1545
1558
|
COMPONENT_SOURCE: () => COMPONENT_SOURCE,
|
|
@@ -1703,6 +1716,7 @@ __export(src_exports, {
|
|
|
1703
1716
|
carriesShapeToken: () => carriesShapeToken,
|
|
1704
1717
|
catalogFromWire: () => catalogFromWire,
|
|
1705
1718
|
catalogToWire: () => catalogToWire,
|
|
1719
|
+
chipsFromShowSignal: () => chipsFromShowSignal,
|
|
1706
1720
|
collectElementEntityRefs: () => collectElementEntityRefs,
|
|
1707
1721
|
collectPlacedEntityRefs: () => collectPlacedEntityRefs,
|
|
1708
1722
|
compareSdkVersions: () => compareSdkVersions,
|
|
@@ -2347,6 +2361,24 @@ function withCartActorOrigin(signalType, payload, origin) {
|
|
|
2347
2361
|
return { ...payload, origin };
|
|
2348
2362
|
}
|
|
2349
2363
|
|
|
2364
|
+
// ../spacestation/src/signal/chip-show.ts
|
|
2365
|
+
var CHIP_SHOW_SIGNAL = "chip.show";
|
|
2366
|
+
function chipsFromShowSignal(signal) {
|
|
2367
|
+
if (signal.type !== CHIP_SHOW_SIGNAL) return null;
|
|
2368
|
+
const actions = Array.isArray(signal.payload.chips) ? signal.payload.chips.map(
|
|
2369
|
+
(chip, index) => typeof chip === "object" && chip !== null && !Array.isArray(chip) && !("id" in chip) ? { ...chip, id: `chip-${String(index)}` } : chip
|
|
2370
|
+
) : signal.payload.chips;
|
|
2371
|
+
const parsed = SuggestionActionsSchema.safeParse({
|
|
2372
|
+
type: "suggestion_cards",
|
|
2373
|
+
actions
|
|
2374
|
+
});
|
|
2375
|
+
if (!parsed.success) {
|
|
2376
|
+
console.warn("[chip-show] payload failed validation:", parsed.error);
|
|
2377
|
+
return null;
|
|
2378
|
+
}
|
|
2379
|
+
return parsed.data.actions;
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2350
2382
|
// ../spacestation/src/signal/turn-ask.ts
|
|
2351
2383
|
import { z as z14 } from "zod";
|
|
2352
2384
|
var TURN_ASK_SIGNAL = "turn.ask";
|
|
@@ -5062,6 +5094,8 @@ __export(src_exports2, {
|
|
|
5062
5094
|
createUnavailableProduct: () => createUnavailableProduct,
|
|
5063
5095
|
entityProjections: () => entityProjections,
|
|
5064
5096
|
formatVariantValue: () => formatVariantValue,
|
|
5097
|
+
installmentOffer: () => installmentOffer,
|
|
5098
|
+
installmentPayment: () => installmentPayment,
|
|
5065
5099
|
isGhostEntity: () => isGhostEntity,
|
|
5066
5100
|
isPendingCartLine: () => isPendingCartLine,
|
|
5067
5101
|
lookupBucketedFact: () => lookupBucketedFact,
|
|
@@ -5857,6 +5891,36 @@ function clearStoreThemeSources() {
|
|
|
5857
5891
|
factories3.length = 0;
|
|
5858
5892
|
}
|
|
5859
5893
|
|
|
5894
|
+
// ../ecommerce/src/installment-offer.ts
|
|
5895
|
+
function installmentPayment(amount, term) {
|
|
5896
|
+
const r = term.apr / 100 / (term.frequency === "weekly" ? 52 : 12);
|
|
5897
|
+
const raw = r === 0 ? amount / term.count : amount * r / (1 - Math.pow(1 + r, -term.count));
|
|
5898
|
+
return Math.round(raw * 100) / 100;
|
|
5899
|
+
}
|
|
5900
|
+
function installmentOffer(plans, price) {
|
|
5901
|
+
if (price.currencyCode !== plans.minPrice.currencyCode) return void 0;
|
|
5902
|
+
const amount = price.amount;
|
|
5903
|
+
const band = plans.plans.find((p) => amount >= p.minPrice.amount && amount <= p.maxPrice.amount);
|
|
5904
|
+
if (band === void 0) return void 0;
|
|
5905
|
+
const quotes = band.terms.map((t) => ({
|
|
5906
|
+
kind: t.kind,
|
|
5907
|
+
apr: t.apr,
|
|
5908
|
+
frequency: t.frequency,
|
|
5909
|
+
count: t.count,
|
|
5910
|
+
payment: installmentPayment(amount, t)
|
|
5911
|
+
}));
|
|
5912
|
+
let split;
|
|
5913
|
+
let lowestMonthly;
|
|
5914
|
+
for (const q of quotes) {
|
|
5915
|
+
if (q.kind === "split") {
|
|
5916
|
+
if (split === void 0 || q.count > split.count) split = q;
|
|
5917
|
+
} else if (q.frequency === "monthly" && (lowestMonthly === void 0 || q.payment < lowestMonthly.payment)) {
|
|
5918
|
+
lowestMonthly = q;
|
|
5919
|
+
}
|
|
5920
|
+
}
|
|
5921
|
+
return { plans: quotes, split, lowestMonthly };
|
|
5922
|
+
}
|
|
5923
|
+
|
|
5860
5924
|
// src/session/visitor-locale.ts
|
|
5861
5925
|
var cached = null;
|
|
5862
5926
|
function getVisitorLocale() {
|
|
@@ -5924,6 +5988,7 @@ __export(shell_exports, {
|
|
|
5924
5988
|
claimExclusiveOverlay: () => claimExclusiveOverlay,
|
|
5925
5989
|
registerExclusiveOverlay: () => registerExclusiveOverlay,
|
|
5926
5990
|
splitAnswer: () => splitAnswer,
|
|
5991
|
+
takeSubmitOrigin: () => takeSubmitOrigin,
|
|
5927
5992
|
threadRowAttrs: () => threadRowAttrs,
|
|
5928
5993
|
useBotCheckNotice: () => useBotCheckNotice,
|
|
5929
5994
|
useComposerAttachments: () => useComposerAttachments,
|
|
@@ -5947,7 +6012,9 @@ __export(shell_exports, {
|
|
|
5947
6012
|
useThreadLanding: () => useThreadLanding,
|
|
5948
6013
|
useThreadRows: () => useThreadRows,
|
|
5949
6014
|
useTurnAskPlacement: () => useTurnAskPlacement,
|
|
5950
|
-
useTurnAskReply: () => useTurnAskReply
|
|
6015
|
+
useTurnAskReply: () => useTurnAskReply,
|
|
6016
|
+
useWaitingSubmitOrigin: () => useWaitingSubmitOrigin,
|
|
6017
|
+
withoutClosingQuestion: () => withoutClosingQuestion
|
|
5951
6018
|
});
|
|
5952
6019
|
|
|
5953
6020
|
// src/shell/ScrollContainerContext.tsx
|
|
@@ -6364,7 +6431,7 @@ function useComposerAttachments() {
|
|
|
6364
6431
|
}
|
|
6365
6432
|
|
|
6366
6433
|
// src/shell/use-prompt-composer.ts
|
|
6367
|
-
import * as
|
|
6434
|
+
import * as React11 from "react";
|
|
6368
6435
|
|
|
6369
6436
|
// src/voice/use-voice-capture.ts
|
|
6370
6437
|
import { useCallback as useCallback4, useEffect as useEffect4, useRef as useRef4, useState as useState3 } from "react";
|
|
@@ -6629,33 +6696,88 @@ function useVoiceCapture(options) {
|
|
|
6629
6696
|
};
|
|
6630
6697
|
}
|
|
6631
6698
|
|
|
6699
|
+
// src/shell/submit-origin.ts
|
|
6700
|
+
import * as React10 from "react";
|
|
6701
|
+
var ORIGIN_TTL_MS = 3e3;
|
|
6702
|
+
var noted = null;
|
|
6703
|
+
var notedAt = 0;
|
|
6704
|
+
var expiry = null;
|
|
6705
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
6706
|
+
var notify = () => listeners.forEach((l) => l());
|
|
6707
|
+
var sameWords = (a, b) => a.replace(/\s+/g, " ").trim() === b.replace(/\s+/g, " ").trim();
|
|
6708
|
+
var px = (value, fallback) => {
|
|
6709
|
+
const n = Number.parseFloat(value);
|
|
6710
|
+
return Number.isFinite(n) ? n : fallback;
|
|
6711
|
+
};
|
|
6712
|
+
function noteSubmitOrigin(text2, el) {
|
|
6713
|
+
const r = el.getBoundingClientRect();
|
|
6714
|
+
const style = getComputedStyle(el);
|
|
6715
|
+
const fontSizePx = px(style.fontSize, 16);
|
|
6716
|
+
const padLeft = px(style.paddingLeft, 0);
|
|
6717
|
+
const padTop = px(style.paddingTop, 0);
|
|
6718
|
+
const padRight = px(style.paddingRight, 0);
|
|
6719
|
+
const padBottom = px(style.paddingBottom, 0);
|
|
6720
|
+
noted = {
|
|
6721
|
+
text: text2,
|
|
6722
|
+
rect: { left: r.left + padLeft, top: r.top + padTop, width: Math.max(0, r.width - padLeft - padRight), height: Math.max(0, r.height - padTop - padBottom) },
|
|
6723
|
+
fontSizePx,
|
|
6724
|
+
lineHeightPx: px(style.lineHeight, fontSizePx * 1.4),
|
|
6725
|
+
fontFamily: style.fontFamily,
|
|
6726
|
+
color: style.color
|
|
6727
|
+
};
|
|
6728
|
+
notedAt = performance.now();
|
|
6729
|
+
if (expiry !== null) clearTimeout(expiry);
|
|
6730
|
+
expiry = setTimeout(() => {
|
|
6731
|
+
noted = null;
|
|
6732
|
+
expiry = null;
|
|
6733
|
+
notify();
|
|
6734
|
+
}, ORIGIN_TTL_MS);
|
|
6735
|
+
notify();
|
|
6736
|
+
}
|
|
6737
|
+
function takeSubmitOrigin(text2) {
|
|
6738
|
+
const origin = noted;
|
|
6739
|
+
if (origin === null || performance.now() - notedAt > ORIGIN_TTL_MS || !sameWords(origin.text, text2)) return null;
|
|
6740
|
+
noted = null;
|
|
6741
|
+
if (expiry !== null) clearTimeout(expiry);
|
|
6742
|
+
expiry = null;
|
|
6743
|
+
notify();
|
|
6744
|
+
return origin;
|
|
6745
|
+
}
|
|
6746
|
+
function subscribe(listener) {
|
|
6747
|
+
listeners.add(listener);
|
|
6748
|
+
return () => listeners.delete(listener);
|
|
6749
|
+
}
|
|
6750
|
+
function useWaitingSubmitOrigin() {
|
|
6751
|
+
return React10.useSyncExternalStore(subscribe, () => noted, () => null);
|
|
6752
|
+
}
|
|
6753
|
+
|
|
6632
6754
|
// src/shell/use-prompt-composer.ts
|
|
6633
6755
|
function usePromptComposer(options = {}) {
|
|
6634
|
-
const { attachments: attachmentsController } = options;
|
|
6756
|
+
const { attachments: attachmentsController, origin } = options;
|
|
6635
6757
|
const session = useFourtySession();
|
|
6636
6758
|
const internalAttach = useComposerAttachments();
|
|
6637
6759
|
const attach = attachmentsController !== void 0 ? attachmentsController : internalAttach;
|
|
6638
6760
|
const [value, setValue] = useComposerDraft();
|
|
6639
|
-
const dictationBaseRef =
|
|
6640
|
-
const handleDictationResult =
|
|
6761
|
+
const dictationBaseRef = React11.useRef("");
|
|
6762
|
+
const handleDictationResult = React11.useCallback((transcript) => {
|
|
6641
6763
|
const base = dictationBaseRef.current;
|
|
6642
6764
|
setValue(base.length > 0 ? `${base} ${transcript}` : transcript);
|
|
6643
6765
|
}, [setValue]);
|
|
6644
|
-
const submitRef =
|
|
6766
|
+
const submitRef = React11.useRef(() => {
|
|
6645
6767
|
});
|
|
6646
6768
|
const voiceCapture = useVoiceCapture({
|
|
6647
6769
|
onResult: handleDictationResult,
|
|
6648
6770
|
onCommit: () => submitRef.current()
|
|
6649
6771
|
});
|
|
6650
|
-
const valueRef =
|
|
6772
|
+
const valueRef = React11.useRef(value);
|
|
6651
6773
|
valueRef.current = value;
|
|
6652
|
-
const toggleDictation =
|
|
6774
|
+
const toggleDictation = React11.useCallback(() => {
|
|
6653
6775
|
if (voiceCapture.state !== "listening") {
|
|
6654
6776
|
dictationBaseRef.current = valueRef.current;
|
|
6655
6777
|
}
|
|
6656
6778
|
voiceCapture.toggle();
|
|
6657
6779
|
}, [voiceCapture]);
|
|
6658
|
-
const onPaste =
|
|
6780
|
+
const onPaste = React11.useCallback(
|
|
6659
6781
|
(e) => {
|
|
6660
6782
|
const files = e.clipboardData.files;
|
|
6661
6783
|
if (files.length > 0) {
|
|
@@ -6666,16 +6788,19 @@ function usePromptComposer(options = {}) {
|
|
|
6666
6788
|
[attach]
|
|
6667
6789
|
);
|
|
6668
6790
|
const canSend = (value.trim().length > 0 || attach.readyRefs.length > 0) && !attach.hasPending;
|
|
6669
|
-
const submit =
|
|
6791
|
+
const submit = React11.useCallback(() => {
|
|
6670
6792
|
if (!((value.trim().length > 0 || attach.readyRefs.length > 0) && !attach.hasPending)) return;
|
|
6671
6793
|
voiceCapture.cancel();
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6794
|
+
const originEl = origin === void 0 ? null : origin.current;
|
|
6795
|
+
if (originEl !== null && value.trim().length > 0) noteSubmitOrigin(value, originEl);
|
|
6796
|
+
const text2 = value;
|
|
6797
|
+
const options2 = attach.readyRefs.length > 0 ? { attachments: attach.readyRefs } : void 0;
|
|
6676
6798
|
setValue("");
|
|
6677
6799
|
attach.clear();
|
|
6678
|
-
|
|
6800
|
+
requestAnimationFrame(() => {
|
|
6801
|
+
setTimeout(() => session.sendMessage(text2, options2), 0);
|
|
6802
|
+
});
|
|
6803
|
+
}, [session, value, attach, setValue, voiceCapture, origin]);
|
|
6679
6804
|
submitRef.current = submit;
|
|
6680
6805
|
return {
|
|
6681
6806
|
value,
|
|
@@ -6693,10 +6818,10 @@ function usePromptComposer(options = {}) {
|
|
|
6693
6818
|
}
|
|
6694
6819
|
|
|
6695
6820
|
// src/shell/use-composer-chip-select.ts
|
|
6696
|
-
import * as
|
|
6821
|
+
import * as React12 from "react";
|
|
6697
6822
|
function useComposerChipSelect() {
|
|
6698
6823
|
const session = useFourtySession();
|
|
6699
|
-
return
|
|
6824
|
+
return React12.useCallback(
|
|
6700
6825
|
(action) => {
|
|
6701
6826
|
session.dispatchSuggestionAction({
|
|
6702
6827
|
id: action.id,
|
|
@@ -6710,10 +6835,10 @@ function useComposerChipSelect() {
|
|
|
6710
6835
|
}
|
|
6711
6836
|
|
|
6712
6837
|
// src/shell/use-turn-ask-reply.ts
|
|
6713
|
-
import * as
|
|
6838
|
+
import * as React13 from "react";
|
|
6714
6839
|
function useTurnAskReply() {
|
|
6715
6840
|
const session = useFourtySession();
|
|
6716
|
-
return
|
|
6841
|
+
return React13.useCallback(
|
|
6717
6842
|
(answer) => {
|
|
6718
6843
|
session.dispatchSuggestionAction({ id: `ask-${answer}`, label: answer, type: "message", payload: { text: answer, followUp: true } });
|
|
6719
6844
|
},
|
|
@@ -6722,14 +6847,14 @@ function useTurnAskReply() {
|
|
|
6722
6847
|
}
|
|
6723
6848
|
|
|
6724
6849
|
// src/shell/turn-ask-placement.tsx
|
|
6725
|
-
import * as
|
|
6850
|
+
import * as React14 from "react";
|
|
6726
6851
|
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
6727
|
-
var TurnAskPlacementContext =
|
|
6852
|
+
var TurnAskPlacementContext = React14.createContext("prose");
|
|
6728
6853
|
function TurnAskPlacementProvider({ placement, children }) {
|
|
6729
6854
|
return /* @__PURE__ */ jsx6(TurnAskPlacementContext.Provider, { value: placement, children });
|
|
6730
6855
|
}
|
|
6731
6856
|
function useTurnAskPlacement() {
|
|
6732
|
-
return
|
|
6857
|
+
return React14.useContext(TurnAskPlacementContext);
|
|
6733
6858
|
}
|
|
6734
6859
|
|
|
6735
6860
|
// src/shell/use-go-home.ts
|
|
@@ -6746,10 +6871,10 @@ function useGoHome() {
|
|
|
6746
6871
|
}
|
|
6747
6872
|
|
|
6748
6873
|
// src/shell/use-menu-item-select.ts
|
|
6749
|
-
import * as
|
|
6874
|
+
import * as React15 from "react";
|
|
6750
6875
|
function useMenuItemSelect() {
|
|
6751
6876
|
const session = useFourtySession();
|
|
6752
|
-
return
|
|
6877
|
+
return React15.useCallback(
|
|
6753
6878
|
(item) => {
|
|
6754
6879
|
const payload = item.action.payload === void 0 ? {} : item.action.payload;
|
|
6755
6880
|
session.dispatchSuggestionAction({
|
|
@@ -6802,15 +6927,15 @@ function useThreadRows() {
|
|
|
6802
6927
|
}
|
|
6803
6928
|
|
|
6804
6929
|
// src/shell/conversation/use-conversation-page.ts
|
|
6805
|
-
import * as
|
|
6930
|
+
import * as React19 from "react";
|
|
6806
6931
|
|
|
6807
6932
|
// src/canvas/use-is-seed-home.ts
|
|
6808
|
-
import * as
|
|
6933
|
+
import * as React16 from "react";
|
|
6809
6934
|
function useIsSeedHome() {
|
|
6810
6935
|
const layout = useDisplayedLayout();
|
|
6811
6936
|
const turn = useTurn();
|
|
6812
6937
|
const sessionState = useSessionState();
|
|
6813
|
-
return
|
|
6938
|
+
return React16.useMemo(() => {
|
|
6814
6939
|
if (sessionState.seedLayout === null) return false;
|
|
6815
6940
|
if (turn.index !== 0) return false;
|
|
6816
6941
|
if (turn.userMessage !== "") return false;
|
|
@@ -6839,6 +6964,13 @@ function splitAnswer(prose2) {
|
|
|
6839
6964
|
body: text2.slice(end).trim().replace(/\s*\n+\s*/g, " ").replace(/([.!?])(?=\*{0,2}[A-Z])/g, "$1 ")
|
|
6840
6965
|
};
|
|
6841
6966
|
}
|
|
6967
|
+
function withoutClosingQuestion(body) {
|
|
6968
|
+
const text2 = body.trimEnd();
|
|
6969
|
+
if (!/\?\**$/.test(text2)) return body;
|
|
6970
|
+
const stops = [...text2.slice(0, -1).matchAll(/[.!?]\**\s/g)];
|
|
6971
|
+
const last = stops[stops.length - 1];
|
|
6972
|
+
return last === void 0 ? "" : text2.slice(0, last.index + last[0].length).trimEnd();
|
|
6973
|
+
}
|
|
6842
6974
|
|
|
6843
6975
|
// src/canvas/turn-edit.ts
|
|
6844
6976
|
function isRecord2(value) {
|
|
@@ -7109,7 +7241,7 @@ function usePresenceLiveTurn() {
|
|
|
7109
7241
|
}
|
|
7110
7242
|
|
|
7111
7243
|
// src/widgets/presence/flows/flow-store.ts
|
|
7112
|
-
import { useSyncExternalStore as
|
|
7244
|
+
import { useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
7113
7245
|
|
|
7114
7246
|
// src/utils/storage.ts
|
|
7115
7247
|
var opened = /* @__PURE__ */ new Map();
|
|
@@ -7199,14 +7331,14 @@ function load() {
|
|
|
7199
7331
|
}
|
|
7200
7332
|
var outputs = load();
|
|
7201
7333
|
var freshIds = /* @__PURE__ */ new Set();
|
|
7202
|
-
var
|
|
7203
|
-
function
|
|
7204
|
-
for (const listener of
|
|
7334
|
+
var listeners2 = /* @__PURE__ */ new Set();
|
|
7335
|
+
function notify2() {
|
|
7336
|
+
for (const listener of listeners2) listener();
|
|
7205
7337
|
}
|
|
7206
|
-
function
|
|
7207
|
-
|
|
7338
|
+
function subscribe2(listener) {
|
|
7339
|
+
listeners2.add(listener);
|
|
7208
7340
|
return () => {
|
|
7209
|
-
|
|
7341
|
+
listeners2.delete(listener);
|
|
7210
7342
|
};
|
|
7211
7343
|
}
|
|
7212
7344
|
function persist() {
|
|
@@ -7217,24 +7349,24 @@ function setFlowOutput(flowId, data) {
|
|
|
7217
7349
|
outputs = { ...outputs, [flowId]: data };
|
|
7218
7350
|
freshIds.add(flowId);
|
|
7219
7351
|
persist();
|
|
7220
|
-
|
|
7352
|
+
notify2();
|
|
7221
7353
|
}
|
|
7222
7354
|
function getFlowOutput(flowId) {
|
|
7223
7355
|
return Object.prototype.hasOwnProperty.call(outputs, flowId) ? outputs[flowId] : null;
|
|
7224
7356
|
}
|
|
7225
7357
|
function subscribeFlowOutputs(listener) {
|
|
7226
|
-
return
|
|
7358
|
+
return subscribe2(listener);
|
|
7227
7359
|
}
|
|
7228
7360
|
function useAgentFlow(flowId) {
|
|
7229
|
-
return
|
|
7230
|
-
|
|
7361
|
+
return useSyncExternalStore3(
|
|
7362
|
+
subscribe2,
|
|
7231
7363
|
() => Object.prototype.hasOwnProperty.call(outputs, flowId) ? outputs[flowId] : null,
|
|
7232
7364
|
() => null
|
|
7233
7365
|
);
|
|
7234
7366
|
}
|
|
7235
7367
|
function useAgentFlowFresh(flowId) {
|
|
7236
|
-
return
|
|
7237
|
-
|
|
7368
|
+
return useSyncExternalStore3(
|
|
7369
|
+
subscribe2,
|
|
7238
7370
|
() => freshIds.has(flowId),
|
|
7239
7371
|
() => false
|
|
7240
7372
|
);
|
|
@@ -7244,7 +7376,7 @@ if (typeof window !== "undefined") {
|
|
|
7244
7376
|
outputs = {};
|
|
7245
7377
|
freshIds.clear();
|
|
7246
7378
|
persist();
|
|
7247
|
-
|
|
7379
|
+
notify2();
|
|
7248
7380
|
});
|
|
7249
7381
|
}
|
|
7250
7382
|
|
|
@@ -7340,10 +7472,10 @@ function useAgentPresence(flowId = PRESENCE_FLOW) {
|
|
|
7340
7472
|
}
|
|
7341
7473
|
|
|
7342
7474
|
// src/widgets/presence/use-forget-fact.ts
|
|
7343
|
-
import * as
|
|
7475
|
+
import * as React18 from "react";
|
|
7344
7476
|
|
|
7345
7477
|
// src/widgets/presence/use-optimistic-flow-set.ts
|
|
7346
|
-
import * as
|
|
7478
|
+
import * as React17 from "react";
|
|
7347
7479
|
function readKeys(data) {
|
|
7348
7480
|
if (typeof data !== "object" || data === null || !("keys" in data)) return [];
|
|
7349
7481
|
const raw = data.keys;
|
|
@@ -7352,8 +7484,8 @@ function readKeys(data) {
|
|
|
7352
7484
|
function useOptimisticFlowSet(flowId) {
|
|
7353
7485
|
const keys = readKeys(useAgentFlow(flowId));
|
|
7354
7486
|
const joined = keys.join("\0");
|
|
7355
|
-
const set =
|
|
7356
|
-
return
|
|
7487
|
+
const set = React17.useMemo(() => new Set(keys), [joined]);
|
|
7488
|
+
return React17.useMemo(
|
|
7357
7489
|
() => ({
|
|
7358
7490
|
has: (key) => set.has(key),
|
|
7359
7491
|
add: (key) => {
|
|
@@ -7369,7 +7501,7 @@ function useOptimisticFlowSet(flowId) {
|
|
|
7369
7501
|
function useReconcileFlowSet(flowId, presentKeys) {
|
|
7370
7502
|
const data = useAgentFlow(flowId);
|
|
7371
7503
|
const presentJoined = presentKeys === null ? null : [...presentKeys].join("\0");
|
|
7372
|
-
|
|
7504
|
+
React17.useEffect(() => {
|
|
7373
7505
|
if (presentKeys === null) return;
|
|
7374
7506
|
const keys = readKeys(data);
|
|
7375
7507
|
if (keys.length === 0) return;
|
|
@@ -7391,7 +7523,7 @@ var useUndismissedFacts = useVisibleFactList;
|
|
|
7391
7523
|
function useForgetFact() {
|
|
7392
7524
|
const { sendImmediateSignal } = useFourtySession();
|
|
7393
7525
|
const dismissed = useOptimisticFlowSet(DISMISSED_FLOW);
|
|
7394
|
-
const forget =
|
|
7526
|
+
const forget = React18.useCallback(
|
|
7395
7527
|
(f) => {
|
|
7396
7528
|
dismissed.add(f.label);
|
|
7397
7529
|
sendImmediateSignal({ type: PRESENCE_FACT_DISMISS_SIGNAL, payload: { label: f.label, value: f.value } });
|
|
@@ -7442,7 +7574,7 @@ function useConversationPage() {
|
|
|
7442
7574
|
const presence = useConversationPresence();
|
|
7443
7575
|
const suggestions = useSuggestionsWithDefaults();
|
|
7444
7576
|
const followUp = useComposerChipSelect();
|
|
7445
|
-
const onWelcomePage =
|
|
7577
|
+
const onWelcomePage = React19.useMemo(
|
|
7446
7578
|
() => seedLayout !== null && JSON.stringify(layout) === JSON.stringify(seedLayout),
|
|
7447
7579
|
[layout, seedLayout]
|
|
7448
7580
|
);
|
|
@@ -7469,7 +7601,8 @@ function useConversationPage() {
|
|
|
7469
7601
|
index: shown.index,
|
|
7470
7602
|
question: shown.visitorText,
|
|
7471
7603
|
headline: answer.headline,
|
|
7472
|
-
body
|
|
7604
|
+
// Its closing question is `ask`'s line, so the body never repeats it.
|
|
7605
|
+
body: shown.streams.ask === void 0 ? answer.body : withoutClosingQuestion(answer.body),
|
|
7473
7606
|
ask: shown.streams.ask,
|
|
7474
7607
|
answerable: settledNewest,
|
|
7475
7608
|
live: live !== null,
|
|
@@ -7517,7 +7650,7 @@ function ThreadHeadroom() {
|
|
|
7517
7650
|
}
|
|
7518
7651
|
|
|
7519
7652
|
// src/shell/thread-scroll/use-pin-turn-to-top.ts
|
|
7520
|
-
import * as
|
|
7653
|
+
import * as React20 from "react";
|
|
7521
7654
|
|
|
7522
7655
|
// src/canvas/dom-targets.ts
|
|
7523
7656
|
var ACTIVE_PANEL_ATTR = "data-fourty-panel-active";
|
|
@@ -7694,7 +7827,7 @@ function pinTurnHead(scroller, row, options) {
|
|
|
7694
7827
|
|
|
7695
7828
|
// src/shell/thread-scroll/use-pin-turn-to-top.ts
|
|
7696
7829
|
function usePinTurnToTop({ scrollerRef, turnRef, turnId }) {
|
|
7697
|
-
|
|
7830
|
+
React20.useEffect(() => {
|
|
7698
7831
|
if (turnId === null) return;
|
|
7699
7832
|
const scroller = scrollerRef.current;
|
|
7700
7833
|
const row = turnRef.current;
|
|
@@ -7715,10 +7848,10 @@ function usePinTurnToTop({ scrollerRef, turnRef, turnId }) {
|
|
|
7715
7848
|
}
|
|
7716
7849
|
|
|
7717
7850
|
// src/shell/thread-scroll/use-scroll-has-more-below.ts
|
|
7718
|
-
import * as
|
|
7851
|
+
import * as React21 from "react";
|
|
7719
7852
|
function useScrollHasMoreBelow(scroller, thresholdPx = 16) {
|
|
7720
|
-
const [hasMore, setHasMore] =
|
|
7721
|
-
|
|
7853
|
+
const [hasMore, setHasMore] = React21.useState(false);
|
|
7854
|
+
React21.useEffect(() => {
|
|
7722
7855
|
if (scroller === null) return;
|
|
7723
7856
|
const view = scroller.ownerDocument.defaultView;
|
|
7724
7857
|
if (view === null) return;
|
|
@@ -7758,9 +7891,9 @@ function threadRowAttrs(key) {
|
|
|
7758
7891
|
}
|
|
7759
7892
|
|
|
7760
7893
|
// src/shell/thread-scroll/use-thread-jump-marks.ts
|
|
7761
|
-
import * as
|
|
7894
|
+
import * as React22 from "react";
|
|
7762
7895
|
function useThreadJumpMarks(rows) {
|
|
7763
|
-
return
|
|
7896
|
+
return React22.useMemo(
|
|
7764
7897
|
() => rows.filter((row) => row.visitorText.length > 0).map((row) => ({
|
|
7765
7898
|
key: row.key,
|
|
7766
7899
|
label: row.visitorText,
|
|
@@ -7774,7 +7907,7 @@ function useThreadJumpMarks(rows) {
|
|
|
7774
7907
|
}
|
|
7775
7908
|
|
|
7776
7909
|
// src/shell/thread-scroll/use-thread-landing.ts
|
|
7777
|
-
import * as
|
|
7910
|
+
import * as React23 from "react";
|
|
7778
7911
|
|
|
7779
7912
|
// src/shell/thread-scroll/settle-thread-row.ts
|
|
7780
7913
|
var SETTLE_MS = 1200;
|
|
@@ -7838,11 +7971,11 @@ function settleThreadRow(scroller, rowKey, behavior = "smooth") {
|
|
|
7838
7971
|
}
|
|
7839
7972
|
|
|
7840
7973
|
// src/shell/thread-scroll/use-thread-landing.ts
|
|
7841
|
-
var useIsomorphicLayoutEffect = typeof window === "undefined" ?
|
|
7974
|
+
var useIsomorphicLayoutEffect = typeof window === "undefined" ? React23.useEffect : React23.useLayoutEffect;
|
|
7842
7975
|
function useThreadLanding(scroller, relandKey = 0) {
|
|
7843
7976
|
const { turnId, seq } = useExplicitTurnSelection();
|
|
7844
|
-
const openedWith =
|
|
7845
|
-
const landedRef =
|
|
7977
|
+
const openedWith = React23.useRef({ turnId, seq });
|
|
7978
|
+
const landedRef = React23.useRef(null);
|
|
7846
7979
|
useIsomorphicLayoutEffect(() => {
|
|
7847
7980
|
if (scroller === null) return;
|
|
7848
7981
|
if (turnId !== null) {
|
|
@@ -7897,7 +8030,7 @@ function useRegisterSignalHandlers(handlers) {
|
|
|
7897
8030
|
var AGENT_ASK_SIGNAL = "agent_ask";
|
|
7898
8031
|
|
|
7899
8032
|
// src/provider/use-clamp-toggle.ts
|
|
7900
|
-
import
|
|
8033
|
+
import React24 from "react";
|
|
7901
8034
|
|
|
7902
8035
|
// src/shared/use-expandable.ts
|
|
7903
8036
|
import { useCallback as useCallback10, useState as useState5 } from "react";
|
|
@@ -7910,9 +8043,9 @@ function useExpandable(initial = false) {
|
|
|
7910
8043
|
// src/provider/use-clamp-toggle.ts
|
|
7911
8044
|
function useClampToggle(contentKey) {
|
|
7912
8045
|
const { expanded, toggle } = useExpandable(false);
|
|
7913
|
-
const [overflowing, setOverflowing] =
|
|
7914
|
-
const ref =
|
|
7915
|
-
|
|
8046
|
+
const [overflowing, setOverflowing] = React24.useState(false);
|
|
8047
|
+
const ref = React24.useRef(null);
|
|
8048
|
+
React24.useEffect(() => {
|
|
7916
8049
|
const el = ref.current;
|
|
7917
8050
|
if (el === null) return;
|
|
7918
8051
|
if (expanded) return;
|
|
@@ -7928,16 +8061,16 @@ function useClampToggle(contentKey) {
|
|
|
7928
8061
|
}
|
|
7929
8062
|
|
|
7930
8063
|
// src/provider/use-timed-flag.ts
|
|
7931
|
-
import
|
|
8064
|
+
import React25 from "react";
|
|
7932
8065
|
function useTimedFlag(durationMs) {
|
|
7933
|
-
const [flag, setFlag] =
|
|
7934
|
-
const timerRef =
|
|
7935
|
-
|
|
8066
|
+
const [flag, setFlag] = React25.useState(false);
|
|
8067
|
+
const timerRef = React25.useRef(null);
|
|
8068
|
+
React25.useEffect(() => {
|
|
7936
8069
|
return () => {
|
|
7937
8070
|
if (timerRef.current !== null) window.clearTimeout(timerRef.current);
|
|
7938
8071
|
};
|
|
7939
8072
|
}, []);
|
|
7940
|
-
const trigger =
|
|
8073
|
+
const trigger = React25.useCallback(() => {
|
|
7941
8074
|
if (timerRef.current !== null) window.clearTimeout(timerRef.current);
|
|
7942
8075
|
setFlag(true);
|
|
7943
8076
|
timerRef.current = window.setTimeout(() => {
|
|
@@ -7954,6 +8087,8 @@ __export(canvas_exports, {
|
|
|
7954
8087
|
ACTIVE_PANEL_ATTR: () => ACTIVE_PANEL_ATTR,
|
|
7955
8088
|
ACTIVE_PANEL_SELECTOR: () => ACTIVE_PANEL_SELECTOR,
|
|
7956
8089
|
CanvasArrangementProvider: () => CanvasArrangementProvider,
|
|
8090
|
+
CanvasLeadProvider: () => CanvasLeadProvider,
|
|
8091
|
+
CanvasLeadSlot: () => CanvasLeadSlot,
|
|
7957
8092
|
CanvasMotionStyleProvider: () => CanvasMotionStyleProvider,
|
|
7958
8093
|
CanvasOutletProvider: () => CanvasOutletProvider,
|
|
7959
8094
|
CanvasTailMount: () => CanvasTailMount,
|
|
@@ -8005,6 +8140,8 @@ __export(canvas_exports, {
|
|
|
8005
8140
|
useCanvasArrangement: () => useCanvasArrangement,
|
|
8006
8141
|
useCanvasBack: () => useCanvasBack,
|
|
8007
8142
|
useCanvasForward: () => useCanvasForward,
|
|
8143
|
+
useCanvasLead: () => useCanvasLead,
|
|
8144
|
+
useCanvasLeadTarget: () => useCanvasLeadTarget,
|
|
8008
8145
|
useCanvasMotionStyle: () => useCanvasMotionStyle,
|
|
8009
8146
|
useCanvasTail: () => useCanvasTail,
|
|
8010
8147
|
useCanvasViewBack: () => useCanvasViewBack,
|
|
@@ -8050,9 +8187,9 @@ __export(canvas_exports, {
|
|
|
8050
8187
|
});
|
|
8051
8188
|
|
|
8052
8189
|
// src/canvas/canvas-tail.tsx
|
|
8053
|
-
import * as
|
|
8190
|
+
import * as React26 from "react";
|
|
8054
8191
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
8055
|
-
var CanvasTailContext =
|
|
8192
|
+
var CanvasTailContext = React26.createContext(null);
|
|
8056
8193
|
function CanvasTailProvider({
|
|
8057
8194
|
tail,
|
|
8058
8195
|
children
|
|
@@ -8060,7 +8197,7 @@ function CanvasTailProvider({
|
|
|
8060
8197
|
return /* @__PURE__ */ jsx9(CanvasTailContext.Provider, { value: tail, children });
|
|
8061
8198
|
}
|
|
8062
8199
|
function useCanvasTail() {
|
|
8063
|
-
return
|
|
8200
|
+
return React26.useContext(CanvasTailContext);
|
|
8064
8201
|
}
|
|
8065
8202
|
function CanvasTailMount({
|
|
8066
8203
|
isActive
|
|
@@ -8071,14 +8208,14 @@ function CanvasTailMount({
|
|
|
8071
8208
|
}
|
|
8072
8209
|
|
|
8073
8210
|
// src/canvas/hydration-notice.tsx
|
|
8074
|
-
import * as
|
|
8211
|
+
import * as React27 from "react";
|
|
8075
8212
|
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
8076
|
-
var HydrationNoticeContext =
|
|
8213
|
+
var HydrationNoticeContext = React27.createContext(null);
|
|
8077
8214
|
function HydrationNoticeProvider({ notice, children }) {
|
|
8078
8215
|
return /* @__PURE__ */ jsx10(HydrationNoticeContext.Provider, { value: notice, children });
|
|
8079
8216
|
}
|
|
8080
8217
|
function useHydrationNotice() {
|
|
8081
|
-
return
|
|
8218
|
+
return React27.useContext(HydrationNoticeContext);
|
|
8082
8219
|
}
|
|
8083
8220
|
|
|
8084
8221
|
// src/canvas/GenerationStyleContext.tsx
|
|
@@ -8138,13 +8275,13 @@ function ShimmerSweep({ durationS }) {
|
|
|
8138
8275
|
}
|
|
8139
8276
|
|
|
8140
8277
|
// src/canvas/TransitionContext.tsx
|
|
8141
|
-
import
|
|
8278
|
+
import React28, { createContext as createContext14, useContext as useContext14 } from "react";
|
|
8142
8279
|
import { AnimatePresence, motion as motion2 } from "framer-motion";
|
|
8143
8280
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
8144
8281
|
function FadeGroup({ children }) {
|
|
8145
8282
|
return /* @__PURE__ */ jsx12(AnimatePresence, { mode: "popLayout", initial: false, children });
|
|
8146
8283
|
}
|
|
8147
|
-
var FadeItem =
|
|
8284
|
+
var FadeItem = React28.forwardRef(function FadeItem2({ id, children, style, className }, ref) {
|
|
8148
8285
|
return /* @__PURE__ */ jsx12(
|
|
8149
8286
|
motion2.div,
|
|
8150
8287
|
{
|
|
@@ -8172,7 +8309,7 @@ function useLayoutTransition() {
|
|
|
8172
8309
|
}
|
|
8173
8310
|
|
|
8174
8311
|
// src/canvas/canvas-arrangement.tsx
|
|
8175
|
-
import
|
|
8312
|
+
import React29, { createContext as createContext15, useContext as useContext15 } from "react";
|
|
8176
8313
|
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
8177
8314
|
var CanvasArrangementContext = createContext15({ arrangement: "stack", turnPages: false });
|
|
8178
8315
|
function CanvasArrangementProvider({
|
|
@@ -8180,29 +8317,61 @@ function CanvasArrangementProvider({
|
|
|
8180
8317
|
turnPages = false,
|
|
8181
8318
|
children
|
|
8182
8319
|
}) {
|
|
8183
|
-
const value =
|
|
8320
|
+
const value = React29.useMemo(() => ({ arrangement, turnPages }), [arrangement, turnPages]);
|
|
8184
8321
|
return /* @__PURE__ */ jsx13(CanvasArrangementContext.Provider, { value, children });
|
|
8185
8322
|
}
|
|
8186
8323
|
function useCanvasArrangement() {
|
|
8187
8324
|
return useContext15(CanvasArrangementContext);
|
|
8188
8325
|
}
|
|
8189
8326
|
|
|
8190
|
-
// src/canvas/canvas-
|
|
8191
|
-
import
|
|
8327
|
+
// src/canvas/canvas-lead.tsx
|
|
8328
|
+
import * as React30 from "react";
|
|
8192
8329
|
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
8193
|
-
var
|
|
8330
|
+
var NO_TYPES = [];
|
|
8331
|
+
var CanvasLeadContext = React30.createContext(null);
|
|
8332
|
+
function CanvasLeadProvider({ types, children }) {
|
|
8333
|
+
const [target, setTarget] = React30.useState(null);
|
|
8334
|
+
const [leadId, setLeadId] = React30.useState(null);
|
|
8335
|
+
const value = React30.useMemo(() => ({ types, target, setTarget, leadId, setLeadId }), [types, target, leadId]);
|
|
8336
|
+
return /* @__PURE__ */ jsx14(CanvasLeadContext.Provider, { value, children });
|
|
8337
|
+
}
|
|
8338
|
+
function CanvasLeadSlot({ className }) {
|
|
8339
|
+
const lead = React30.useContext(CanvasLeadContext);
|
|
8340
|
+
if (lead === null) throw new Error("<CanvasLeadSlot> must be rendered inside <CanvasLeadProvider>.");
|
|
8341
|
+
const { setTarget } = lead;
|
|
8342
|
+
const ref = React30.useCallback((el) => setTarget(el), [setTarget]);
|
|
8343
|
+
return /* @__PURE__ */ jsx14("div", { ref, className, "data-fourty-canvas-lead": "" });
|
|
8344
|
+
}
|
|
8345
|
+
function useCanvasLead() {
|
|
8346
|
+
const lead = React30.useContext(CanvasLeadContext);
|
|
8347
|
+
return { present: lead !== null && lead.target !== null && lead.leadId !== null };
|
|
8348
|
+
}
|
|
8349
|
+
function useCanvasLeadTarget() {
|
|
8350
|
+
const lead = React30.useContext(CanvasLeadContext);
|
|
8351
|
+
const setLeadId = lead === null ? null : lead.setLeadId;
|
|
8352
|
+
const report = React30.useCallback((id) => {
|
|
8353
|
+
if (setLeadId !== null) setLeadId(id);
|
|
8354
|
+
}, [setLeadId]);
|
|
8355
|
+
if (lead === null) return { types: NO_TYPES, target: null, report };
|
|
8356
|
+
return { types: lead.types, target: lead.target, report };
|
|
8357
|
+
}
|
|
8358
|
+
|
|
8359
|
+
// src/canvas/canvas-motion-style.tsx
|
|
8360
|
+
import { createContext as createContext17, useContext as useContext17 } from "react";
|
|
8361
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
8362
|
+
var CanvasMotionStyleContext = createContext17(null);
|
|
8194
8363
|
function CanvasMotionStyleProvider({ style, children }) {
|
|
8195
|
-
return /* @__PURE__ */
|
|
8364
|
+
return /* @__PURE__ */ jsx15(CanvasMotionStyleContext.Provider, { value: style, children });
|
|
8196
8365
|
}
|
|
8197
8366
|
function useCanvasMotionStyle() {
|
|
8198
|
-
return
|
|
8367
|
+
return useContext17(CanvasMotionStyleContext);
|
|
8199
8368
|
}
|
|
8200
8369
|
|
|
8201
8370
|
// src/canvas/ElementIdContext.ts
|
|
8202
|
-
import { createContext as
|
|
8203
|
-
var ElementIdContext =
|
|
8371
|
+
import { createContext as createContext18, useContext as useContext18 } from "react";
|
|
8372
|
+
var ElementIdContext = createContext18(null);
|
|
8204
8373
|
function useElementId() {
|
|
8205
|
-
return
|
|
8374
|
+
return useContext18(ElementIdContext);
|
|
8206
8375
|
}
|
|
8207
8376
|
|
|
8208
8377
|
// src/canvas/generation-entrance.ts
|
|
@@ -8276,27 +8445,27 @@ var INITIAL_NAV_PRESENTATION = {
|
|
|
8276
8445
|
};
|
|
8277
8446
|
|
|
8278
8447
|
// src/canvas/use-canvas-actions.ts
|
|
8279
|
-
import { useCallback as
|
|
8448
|
+
import { useCallback as useCallback12 } from "react";
|
|
8280
8449
|
function navigateActionId(page) {
|
|
8281
8450
|
const id = Reflect.get(page, "id");
|
|
8282
8451
|
return typeof id === "string" ? `navigate-${page.kind}-${id}` : `navigate-${page.kind}`;
|
|
8283
8452
|
}
|
|
8284
8453
|
function useCanvasActions() {
|
|
8285
8454
|
const session = useOptionalFourtySession();
|
|
8286
|
-
const dispatchAction =
|
|
8455
|
+
const dispatchAction = useCallback12(
|
|
8287
8456
|
(action) => {
|
|
8288
8457
|
if (!session) return;
|
|
8289
8458
|
session.dispatchSuggestionAction(action);
|
|
8290
8459
|
},
|
|
8291
8460
|
[session]
|
|
8292
8461
|
);
|
|
8293
|
-
const navigate =
|
|
8462
|
+
const navigate = useCallback12(
|
|
8294
8463
|
(page, label) => {
|
|
8295
8464
|
dispatchAction({ id: navigateActionId(page), label, type: NAVIGATE_SIGNAL, payload: { page } });
|
|
8296
8465
|
},
|
|
8297
8466
|
[dispatchAction]
|
|
8298
8467
|
);
|
|
8299
|
-
const ask =
|
|
8468
|
+
const ask = useCallback12(
|
|
8300
8469
|
(text2, label) => {
|
|
8301
8470
|
dispatchAction({ id: `ask-${label}`, label, type: "message", payload: { text: text2 } });
|
|
8302
8471
|
},
|
|
@@ -8462,22 +8631,22 @@ function deriveTurnChangeAnchor(prev, next) {
|
|
|
8462
8631
|
}
|
|
8463
8632
|
|
|
8464
8633
|
// src/canvas/canvas-outlet.tsx
|
|
8465
|
-
import { createContext as
|
|
8466
|
-
import { jsx as
|
|
8467
|
-
var CanvasOutletContext =
|
|
8634
|
+
import { createContext as createContext19, useContext as useContext19 } from "react";
|
|
8635
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
8636
|
+
var CanvasOutletContext = createContext19(null);
|
|
8468
8637
|
function CanvasOutletProvider({ canvas, children }) {
|
|
8469
|
-
return /* @__PURE__ */
|
|
8638
|
+
return /* @__PURE__ */ jsx16(CanvasOutletContext.Provider, { value: canvas, children });
|
|
8470
8639
|
}
|
|
8471
8640
|
function SpacefrontCanvas() {
|
|
8472
|
-
const Canvas =
|
|
8641
|
+
const Canvas = useContext19(CanvasOutletContext);
|
|
8473
8642
|
if (Canvas === null) {
|
|
8474
8643
|
throw new Error("<SpacefrontCanvas> must be rendered inside <Spacefront> \u2014 no engine has provided a canvas.");
|
|
8475
8644
|
}
|
|
8476
|
-
return /* @__PURE__ */
|
|
8645
|
+
return /* @__PURE__ */ jsx16(Canvas, {});
|
|
8477
8646
|
}
|
|
8478
8647
|
|
|
8479
8648
|
// src/canvas/item-motion/ItemTransitionGroup.tsx
|
|
8480
|
-
import
|
|
8649
|
+
import React32 from "react";
|
|
8481
8650
|
import { AnimatePresence as AnimatePresence2, motion as motion3, useReducedMotion as useReducedMotion2 } from "framer-motion";
|
|
8482
8651
|
|
|
8483
8652
|
// src/canvas/item-motion/classify-items.ts
|
|
@@ -8696,7 +8865,7 @@ function getActiveProfile() {
|
|
|
8696
8865
|
}
|
|
8697
8866
|
|
|
8698
8867
|
// src/canvas/item-motion/ItemTransitionGroup.tsx
|
|
8699
|
-
import { jsx as
|
|
8868
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
8700
8869
|
var ITEM_IDENTITY_ATTR = "data-flip-id";
|
|
8701
8870
|
function ItemTransitionGroup({
|
|
8702
8871
|
items,
|
|
@@ -8711,14 +8880,14 @@ function ItemTransitionGroup({
|
|
|
8711
8880
|
const profile = getActiveProfile();
|
|
8712
8881
|
const animated = reduce !== true;
|
|
8713
8882
|
const ids = items.map(getId);
|
|
8714
|
-
const prevIdsRef =
|
|
8715
|
-
const lastChangeRef =
|
|
8883
|
+
const prevIdsRef = React32.useRef(null);
|
|
8884
|
+
const lastChangeRef = React32.useRef(null);
|
|
8716
8885
|
const prevIds = prevIdsRef.current;
|
|
8717
8886
|
const freshChange = prevIds === null ? null : classifyItemChange(prevIds, ids);
|
|
8718
8887
|
if (freshChange !== null) {
|
|
8719
8888
|
lastChangeRef.current = freshChange;
|
|
8720
8889
|
}
|
|
8721
|
-
|
|
8890
|
+
React32.useEffect(() => {
|
|
8722
8891
|
prevIdsRef.current = ids;
|
|
8723
8892
|
});
|
|
8724
8893
|
const activeChange = lastChangeRef.current;
|
|
@@ -8731,7 +8900,7 @@ function ItemTransitionGroup({
|
|
|
8731
8900
|
const isGrid = itemClassName === void 0;
|
|
8732
8901
|
const outerClassName = isGrid ? "h-full" : itemClassName;
|
|
8733
8902
|
const innerClassName = isGrid ? "h-full" : void 0;
|
|
8734
|
-
return /* @__PURE__ */
|
|
8903
|
+
return /* @__PURE__ */ jsx17("div", { className, style, children: /* @__PURE__ */ jsx17(AnimatePresence2, { mode: "popLayout", initial: false, children: items.map((item) => {
|
|
8735
8904
|
const id = getId(item);
|
|
8736
8905
|
const identityAttr = { [ITEM_IDENTITY_ATTR]: id };
|
|
8737
8906
|
const isEntering = activeChange !== null && activeChange.entered.includes(id);
|
|
@@ -8741,7 +8910,7 @@ function ItemTransitionGroup({
|
|
|
8741
8910
|
// `itemClassName`/`itemStyle` size the wrapper for flex/snap
|
|
8742
8911
|
// layouts (carousel); grid layouts leave them unset and get
|
|
8743
8912
|
// `h-full` so the cell height reaches the card.
|
|
8744
|
-
/* @__PURE__ */
|
|
8913
|
+
/* @__PURE__ */ jsx17(
|
|
8745
8914
|
motion3.div,
|
|
8746
8915
|
{
|
|
8747
8916
|
...identityAttr,
|
|
@@ -8750,7 +8919,7 @@ function ItemTransitionGroup({
|
|
|
8750
8919
|
layout: animated ? "position" : void 0,
|
|
8751
8920
|
layoutDependency,
|
|
8752
8921
|
transition: animated ? layoutTransition : void 0,
|
|
8753
|
-
children: /* @__PURE__ */
|
|
8922
|
+
children: /* @__PURE__ */ jsx17(
|
|
8754
8923
|
motion3.div,
|
|
8755
8924
|
{
|
|
8756
8925
|
className: innerClassName,
|
|
@@ -8830,21 +8999,21 @@ __export(catalog_exports, {
|
|
|
8830
8999
|
});
|
|
8831
9000
|
|
|
8832
9001
|
// src/catalog/DebugContext.tsx
|
|
8833
|
-
import { createContext as
|
|
8834
|
-
import { jsx as
|
|
8835
|
-
var DebugContext =
|
|
9002
|
+
import { createContext as createContext20, useContext as useContext20 } from "react";
|
|
9003
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
9004
|
+
var DebugContext = createContext20(false);
|
|
8836
9005
|
function DebugProvider({
|
|
8837
9006
|
debug,
|
|
8838
9007
|
children
|
|
8839
9008
|
}) {
|
|
8840
|
-
return /* @__PURE__ */
|
|
9009
|
+
return /* @__PURE__ */ jsx18(DebugContext.Provider, { value: debug, children });
|
|
8841
9010
|
}
|
|
8842
9011
|
function useDebug() {
|
|
8843
|
-
return
|
|
9012
|
+
return useContext20(DebugContext);
|
|
8844
9013
|
}
|
|
8845
9014
|
|
|
8846
9015
|
// src/catalog/HydrationStateContext.tsx
|
|
8847
|
-
import { createContext as
|
|
9016
|
+
import { createContext as createContext21, useContext as useContext21 } from "react";
|
|
8848
9017
|
var DEFAULT_STATE = {
|
|
8849
9018
|
hasResolvedFields: false,
|
|
8850
9019
|
hydrating: false,
|
|
@@ -8854,47 +9023,47 @@ var DEFAULT_STATE = {
|
|
|
8854
9023
|
pendingCount: 0,
|
|
8855
9024
|
errors: []
|
|
8856
9025
|
};
|
|
8857
|
-
var HydrationStateContext =
|
|
9026
|
+
var HydrationStateContext = createContext21(DEFAULT_STATE);
|
|
8858
9027
|
function useHydrationState() {
|
|
8859
|
-
return
|
|
9028
|
+
return useContext21(HydrationStateContext);
|
|
8860
9029
|
}
|
|
8861
9030
|
|
|
8862
9031
|
// src/catalog/HydratorContext.tsx
|
|
8863
|
-
import { createContext as
|
|
8864
|
-
import { jsx as
|
|
8865
|
-
var HydratorContext =
|
|
9032
|
+
import { createContext as createContext22, useContext as useContext22 } from "react";
|
|
9033
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
9034
|
+
var HydratorContext = createContext22({});
|
|
8866
9035
|
function HydratorProvider({
|
|
8867
9036
|
hydrators,
|
|
8868
9037
|
children
|
|
8869
9038
|
}) {
|
|
8870
|
-
return /* @__PURE__ */
|
|
9039
|
+
return /* @__PURE__ */ jsx19(HydratorContext.Provider, { value: hydrators, children });
|
|
8871
9040
|
}
|
|
8872
9041
|
function useHydrators() {
|
|
8873
|
-
return
|
|
9042
|
+
return useContext22(HydratorContext);
|
|
8874
9043
|
}
|
|
8875
9044
|
|
|
8876
9045
|
// src/catalog/registry.tsx
|
|
8877
|
-
import { createContext as
|
|
8878
|
-
import { jsx as
|
|
8879
|
-
var RegistryContext =
|
|
9046
|
+
import { createContext as createContext23, useContext as useContext23 } from "react";
|
|
9047
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
9048
|
+
var RegistryContext = createContext23({});
|
|
8880
9049
|
function RegistryProvider({
|
|
8881
9050
|
registry: registry2,
|
|
8882
9051
|
children
|
|
8883
9052
|
}) {
|
|
8884
|
-
return /* @__PURE__ */
|
|
9053
|
+
return /* @__PURE__ */ jsx20(RegistryContext.Provider, { value: registry2, children });
|
|
8885
9054
|
}
|
|
8886
9055
|
function useRegistry() {
|
|
8887
|
-
return
|
|
9056
|
+
return useContext23(RegistryContext);
|
|
8888
9057
|
}
|
|
8889
|
-
var PackageLookupContext =
|
|
9058
|
+
var PackageLookupContext = createContext23(null);
|
|
8890
9059
|
function PackageLookupProvider({
|
|
8891
9060
|
lookup,
|
|
8892
9061
|
children
|
|
8893
9062
|
}) {
|
|
8894
|
-
return /* @__PURE__ */
|
|
9063
|
+
return /* @__PURE__ */ jsx20(PackageLookupContext.Provider, { value: lookup, children });
|
|
8895
9064
|
}
|
|
8896
9065
|
function usePackageLookup() {
|
|
8897
|
-
return
|
|
9066
|
+
return useContext23(PackageLookupContext);
|
|
8898
9067
|
}
|
|
8899
9068
|
function createAliasedRegistry(baseRegistry, aliases, getPackageComponent) {
|
|
8900
9069
|
return new Proxy(baseRegistry, {
|
|
@@ -8925,9 +9094,9 @@ function createAliasedRegistry(baseRegistry, aliases, getPackageComponent) {
|
|
|
8925
9094
|
}
|
|
8926
9095
|
|
|
8927
9096
|
// src/catalog/render-inline.tsx
|
|
8928
|
-
import
|
|
8929
|
-
import { jsx as
|
|
8930
|
-
var linkRenderer = (href, key) => /* @__PURE__ */
|
|
9097
|
+
import React35 from "react";
|
|
9098
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
9099
|
+
var linkRenderer = (href, key) => /* @__PURE__ */ jsx21(
|
|
8931
9100
|
"a",
|
|
8932
9101
|
{
|
|
8933
9102
|
className: "fourty-inline-link",
|
|
@@ -8947,14 +9116,14 @@ function linkifyText(text2, keyPrefix) {
|
|
|
8947
9116
|
URL_RE.lastIndex = 0;
|
|
8948
9117
|
while ((match = URL_RE.exec(text2)) !== null) {
|
|
8949
9118
|
if (match.index > last) {
|
|
8950
|
-
out.push(/* @__PURE__ */
|
|
9119
|
+
out.push(/* @__PURE__ */ jsx21(React35.Fragment, { children: text2.slice(last, match.index) }, `${keyPrefix}-lt-${i++}`));
|
|
8951
9120
|
}
|
|
8952
9121
|
const href = match[0];
|
|
8953
9122
|
out.push(linkRenderer(href, `${keyPrefix}-lk-${i++}`));
|
|
8954
9123
|
last = match.index + href.length;
|
|
8955
9124
|
}
|
|
8956
9125
|
if (last < text2.length) {
|
|
8957
|
-
out.push(/* @__PURE__ */
|
|
9126
|
+
out.push(/* @__PURE__ */ jsx21(React35.Fragment, { children: text2.slice(last) }, `${keyPrefix}-lt-${i++}`));
|
|
8958
9127
|
}
|
|
8959
9128
|
return out;
|
|
8960
9129
|
}
|
|
@@ -8967,8 +9136,8 @@ function renderInline(text2, keyPrefix) {
|
|
|
8967
9136
|
while ((match = re.exec(text2)) !== null) {
|
|
8968
9137
|
if (match.index > last) out.push(...linkifyText(text2.slice(last, match.index), `${keyPrefix}-t-${i++}`));
|
|
8969
9138
|
const bold = match[1];
|
|
8970
|
-
if (bold !== void 0) out.push(/* @__PURE__ */
|
|
8971
|
-
else out.push(/* @__PURE__ */
|
|
9139
|
+
if (bold !== void 0) out.push(/* @__PURE__ */ jsx21("strong", { children: bold }, `${keyPrefix}-b-${i++}`));
|
|
9140
|
+
else out.push(/* @__PURE__ */ jsx21("em", { children: match[2] }, `${keyPrefix}-i-${i++}`));
|
|
8972
9141
|
last = match.index + match[0].length;
|
|
8973
9142
|
}
|
|
8974
9143
|
if (last < text2.length) out.push(...linkifyText(text2.slice(last), `${keyPrefix}-t-${i++}`));
|
|
@@ -8976,7 +9145,7 @@ function renderInline(text2, keyPrefix) {
|
|
|
8976
9145
|
}
|
|
8977
9146
|
|
|
8978
9147
|
// src/catalog/component-library.ts
|
|
8979
|
-
import * as
|
|
9148
|
+
import * as React36 from "react";
|
|
8980
9149
|
function displayNameOf(Inner) {
|
|
8981
9150
|
if (typeof Inner === "string") return Inner;
|
|
8982
9151
|
if (typeof Inner.displayName === "string" && Inner.displayName.length > 0) return Inner.displayName;
|
|
@@ -8985,7 +9154,7 @@ function displayNameOf(Inner) {
|
|
|
8985
9154
|
}
|
|
8986
9155
|
function adaptComponent(Inner) {
|
|
8987
9156
|
function Adapted(props) {
|
|
8988
|
-
return
|
|
9157
|
+
return React36.createElement(Inner, props);
|
|
8989
9158
|
}
|
|
8990
9159
|
Adapted.displayName = displayNameOf(Inner);
|
|
8991
9160
|
return Adapted;
|
|
@@ -9268,12 +9437,12 @@ __export(presence_exports2, {
|
|
|
9268
9437
|
});
|
|
9269
9438
|
|
|
9270
9439
|
// src/widgets/presence/use-standing-signal.ts
|
|
9271
|
-
import { useMemo as
|
|
9440
|
+
import { useMemo as useMemo10 } from "react";
|
|
9272
9441
|
|
|
9273
9442
|
// src/widgets/presence/core-presence/standing-signal-store.ts
|
|
9274
|
-
import { useSyncExternalStore as
|
|
9443
|
+
import { useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
9275
9444
|
var current = null;
|
|
9276
|
-
var
|
|
9445
|
+
var listeners3 = /* @__PURE__ */ new Set();
|
|
9277
9446
|
var scope = null;
|
|
9278
9447
|
var seen = /* @__PURE__ */ new Set();
|
|
9279
9448
|
function seenKey(forScope) {
|
|
@@ -9304,13 +9473,13 @@ function bindScope(next) {
|
|
|
9304
9473
|
scope = next;
|
|
9305
9474
|
seen = readSeen(next);
|
|
9306
9475
|
}
|
|
9307
|
-
function
|
|
9308
|
-
for (const listener of
|
|
9476
|
+
function notify3() {
|
|
9477
|
+
for (const listener of listeners3) listener();
|
|
9309
9478
|
}
|
|
9310
|
-
function
|
|
9311
|
-
|
|
9479
|
+
function subscribe3(listener) {
|
|
9480
|
+
listeners3.add(listener);
|
|
9312
9481
|
return () => {
|
|
9313
|
-
|
|
9482
|
+
listeners3.delete(listener);
|
|
9314
9483
|
};
|
|
9315
9484
|
}
|
|
9316
9485
|
function raiseStanding(type, id, payload, signalScope) {
|
|
@@ -9319,7 +9488,7 @@ function raiseStanding(type, id, payload, signalScope) {
|
|
|
9319
9488
|
if (seen.has(id)) return;
|
|
9320
9489
|
if (current !== null) return;
|
|
9321
9490
|
current = { type, id, payload };
|
|
9322
|
-
|
|
9491
|
+
notify3();
|
|
9323
9492
|
}
|
|
9324
9493
|
function resolveStanding(id, signalScope) {
|
|
9325
9494
|
bindScope(signalScope);
|
|
@@ -9327,12 +9496,12 @@ function resolveStanding(id, signalScope) {
|
|
|
9327
9496
|
persistSeen();
|
|
9328
9497
|
if (current !== null && current.id === id) {
|
|
9329
9498
|
current = null;
|
|
9330
|
-
|
|
9499
|
+
notify3();
|
|
9331
9500
|
}
|
|
9332
9501
|
}
|
|
9333
9502
|
function useStandingOfType(type) {
|
|
9334
|
-
return
|
|
9335
|
-
|
|
9503
|
+
return useSyncExternalStore4(
|
|
9504
|
+
subscribe3,
|
|
9336
9505
|
() => current !== null && current.type === type ? current : null,
|
|
9337
9506
|
() => null
|
|
9338
9507
|
);
|
|
@@ -9343,7 +9512,7 @@ if (typeof window !== "undefined") {
|
|
|
9343
9512
|
seen.clear();
|
|
9344
9513
|
persistSeen();
|
|
9345
9514
|
scope = null;
|
|
9346
|
-
|
|
9515
|
+
notify3();
|
|
9347
9516
|
});
|
|
9348
9517
|
}
|
|
9349
9518
|
|
|
@@ -9352,7 +9521,7 @@ function useConsumeStandingSignal(type) {
|
|
|
9352
9521
|
const session = useFourtySession();
|
|
9353
9522
|
const scope2 = session.sessionId === null ? void 0 : session.sessionId;
|
|
9354
9523
|
useRegisterSignalHandlers(
|
|
9355
|
-
|
|
9524
|
+
useMemo10(
|
|
9356
9525
|
() => ({
|
|
9357
9526
|
[type]: (payload) => {
|
|
9358
9527
|
const id = typeof payload.id === "string" && payload.id.length > 0 ? payload.id : type;
|
|
@@ -9363,7 +9532,7 @@ function useConsumeStandingSignal(type) {
|
|
|
9363
9532
|
)
|
|
9364
9533
|
);
|
|
9365
9534
|
const standing = useStandingOfType(type);
|
|
9366
|
-
return
|
|
9535
|
+
return useMemo10(() => {
|
|
9367
9536
|
if (standing === null) return null;
|
|
9368
9537
|
const id = standing.id;
|
|
9369
9538
|
return {
|
|
@@ -9382,7 +9551,7 @@ function useConsumeStandingSignal(type) {
|
|
|
9382
9551
|
}
|
|
9383
9552
|
|
|
9384
9553
|
// src/widgets/presence/use-presence-notch.ts
|
|
9385
|
-
import * as
|
|
9554
|
+
import * as React37 from "react";
|
|
9386
9555
|
var SETTLE_DWELL_MS = 4e3;
|
|
9387
9556
|
var HOVER_CLOSE_MS = 240;
|
|
9388
9557
|
var HOVER_BOUNCE_WINDOW_MS = 800;
|
|
@@ -9390,21 +9559,21 @@ var BOUNCE_PX = 2;
|
|
|
9390
9559
|
function usePresenceNotch(widgets) {
|
|
9391
9560
|
const askStanding = useStandingOfType(AGENT_ASK_SIGNAL) !== null;
|
|
9392
9561
|
const { isRunning } = useAgentPresence();
|
|
9393
|
-
const [hovered, setHovered] =
|
|
9394
|
-
const [openDrawerId, setOpenDrawerId] =
|
|
9395
|
-
const rootRef =
|
|
9396
|
-
const toggleDrawer =
|
|
9562
|
+
const [hovered, setHovered] = React37.useState(false);
|
|
9563
|
+
const [openDrawerId, setOpenDrawerId] = React37.useState(null);
|
|
9564
|
+
const rootRef = React37.useRef(null);
|
|
9565
|
+
const toggleDrawer = React37.useCallback((id) => {
|
|
9397
9566
|
setOpenDrawerId((current2) => current2 === id ? null : id);
|
|
9398
9567
|
}, []);
|
|
9399
|
-
const closeTimer =
|
|
9400
|
-
const cancelClose =
|
|
9568
|
+
const closeTimer = React37.useRef(null);
|
|
9569
|
+
const cancelClose = React37.useCallback(() => {
|
|
9401
9570
|
if (closeTimer.current !== null) {
|
|
9402
9571
|
clearTimeout(closeTimer.current);
|
|
9403
9572
|
closeTimer.current = null;
|
|
9404
9573
|
}
|
|
9405
9574
|
}, []);
|
|
9406
|
-
const lastLeaveRef =
|
|
9407
|
-
const openHover =
|
|
9575
|
+
const lastLeaveRef = React37.useRef(null);
|
|
9576
|
+
const openHover = React37.useCallback((e) => {
|
|
9408
9577
|
const last = lastLeaveRef.current;
|
|
9409
9578
|
if (last !== null && Date.now() - last.t < HOVER_BOUNCE_WINDOW_MS && Math.abs(e.clientX - last.x) <= BOUNCE_PX && Math.abs(e.clientY - last.y) <= BOUNCE_PX) {
|
|
9410
9579
|
return;
|
|
@@ -9412,7 +9581,7 @@ function usePresenceNotch(widgets) {
|
|
|
9412
9581
|
cancelClose();
|
|
9413
9582
|
setHovered(true);
|
|
9414
9583
|
}, [cancelClose]);
|
|
9415
|
-
const scheduleClose =
|
|
9584
|
+
const scheduleClose = React37.useCallback((e) => {
|
|
9416
9585
|
lastLeaveRef.current = { x: e.clientX, y: e.clientY, t: Date.now() };
|
|
9417
9586
|
cancelClose();
|
|
9418
9587
|
closeTimer.current = setTimeout(() => {
|
|
@@ -9420,8 +9589,8 @@ function usePresenceNotch(widgets) {
|
|
|
9420
9589
|
setHovered(false);
|
|
9421
9590
|
}, HOVER_CLOSE_MS);
|
|
9422
9591
|
}, [cancelClose]);
|
|
9423
|
-
|
|
9424
|
-
|
|
9592
|
+
React37.useEffect(() => cancelClose, [cancelClose]);
|
|
9593
|
+
React37.useEffect(() => {
|
|
9425
9594
|
if (openDrawerId === null) return;
|
|
9426
9595
|
const onKey = (e) => {
|
|
9427
9596
|
if (e.key === "Escape") setOpenDrawerId(null);
|
|
@@ -9429,7 +9598,7 @@ function usePresenceNotch(widgets) {
|
|
|
9429
9598
|
window.addEventListener("keydown", onKey);
|
|
9430
9599
|
return () => window.removeEventListener("keydown", onKey);
|
|
9431
9600
|
}, [openDrawerId]);
|
|
9432
|
-
|
|
9601
|
+
React37.useEffect(() => {
|
|
9433
9602
|
if (openDrawerId === null) return;
|
|
9434
9603
|
const onDown = (e) => {
|
|
9435
9604
|
const root = rootRef.current;
|
|
@@ -9441,8 +9610,8 @@ function usePresenceNotch(widgets) {
|
|
|
9441
9610
|
document.addEventListener("pointerdown", onDown);
|
|
9442
9611
|
return () => document.removeEventListener("pointerdown", onDown);
|
|
9443
9612
|
}, [openDrawerId]);
|
|
9444
|
-
const [active, setActive] =
|
|
9445
|
-
|
|
9613
|
+
const [active, setActive] = React37.useState(false);
|
|
9614
|
+
React37.useEffect(() => {
|
|
9446
9615
|
if (isRunning) {
|
|
9447
9616
|
setActive(true);
|
|
9448
9617
|
return;
|
|
@@ -9602,7 +9771,7 @@ function presenceFactShape(fact) {
|
|
|
9602
9771
|
}
|
|
9603
9772
|
|
|
9604
9773
|
// src/widgets/presence/use-optimistic-facts.ts
|
|
9605
|
-
import * as
|
|
9774
|
+
import * as React38 from "react";
|
|
9606
9775
|
function readEntries(data) {
|
|
9607
9776
|
if (typeof data !== "object" || data === null || !("entries" in data)) return [];
|
|
9608
9777
|
const raw = data.entries;
|
|
@@ -9621,7 +9790,7 @@ function writeOptimisticFact(entries3, fact) {
|
|
|
9621
9790
|
}
|
|
9622
9791
|
function useOptimisticFactOverlay(flowId) {
|
|
9623
9792
|
const entries3 = readEntries(useAgentFlow(flowId));
|
|
9624
|
-
return
|
|
9793
|
+
return React38.useMemo(
|
|
9625
9794
|
() => ({
|
|
9626
9795
|
entries: entries3,
|
|
9627
9796
|
add: (fact) => setFlowOutput(flowId, { entries: writeOptimisticFact(entries3, fact) })
|
|
@@ -9630,8 +9799,8 @@ function useOptimisticFactOverlay(flowId) {
|
|
|
9630
9799
|
);
|
|
9631
9800
|
}
|
|
9632
9801
|
function useReconcileOptimisticFacts(flowId, readIdentity) {
|
|
9633
|
-
const seenRef =
|
|
9634
|
-
|
|
9802
|
+
const seenRef = React38.useRef(null);
|
|
9803
|
+
React38.useEffect(() => {
|
|
9635
9804
|
if (readIdentity === null) return;
|
|
9636
9805
|
if (seenRef.current === null) {
|
|
9637
9806
|
seenRef.current = readIdentity;
|
|
@@ -9803,16 +9972,16 @@ __export(chat_exports, {
|
|
|
9803
9972
|
});
|
|
9804
9973
|
|
|
9805
9974
|
// src/chat/chat-context.ts
|
|
9806
|
-
import { createContext as
|
|
9807
|
-
var FourtyChatContext =
|
|
9975
|
+
import { createContext as createContext24, useContext as useContext24 } from "react";
|
|
9976
|
+
var FourtyChatContext = createContext24(null);
|
|
9808
9977
|
function useFourtyChat() {
|
|
9809
|
-
const ctx =
|
|
9978
|
+
const ctx = useContext24(FourtyChatContext);
|
|
9810
9979
|
if (!ctx) throw new Error("useFourtyChat must be used inside <FourtyChatProvider>");
|
|
9811
9980
|
return ctx;
|
|
9812
9981
|
}
|
|
9813
9982
|
|
|
9814
9983
|
// src/rendering/post-hydration.ts
|
|
9815
|
-
import { useCallback as
|
|
9984
|
+
import { useCallback as useCallback14 } from "react";
|
|
9816
9985
|
var registry = [];
|
|
9817
9986
|
function registerPostHydrationTransform(transform) {
|
|
9818
9987
|
const existing = registry.findIndex((t) => t.id === transform.id);
|
|
@@ -9821,7 +9990,7 @@ function registerPostHydrationTransform(transform) {
|
|
|
9821
9990
|
}
|
|
9822
9991
|
function usePostHydrationTransforms() {
|
|
9823
9992
|
const fns = registry.map((t) => t.use());
|
|
9824
|
-
return
|
|
9993
|
+
return useCallback14(
|
|
9825
9994
|
(props, ctx) => {
|
|
9826
9995
|
let out = props;
|
|
9827
9996
|
for (const fn of fns) {
|
|
@@ -9837,10 +10006,10 @@ function usePostHydrationTransforms() {
|
|
|
9837
10006
|
}
|
|
9838
10007
|
|
|
9839
10008
|
// src/projection/transform.ts
|
|
9840
|
-
import { useMemo as
|
|
10009
|
+
import { useMemo as useMemo12 } from "react";
|
|
9841
10010
|
|
|
9842
10011
|
// src/projection/preferences.ts
|
|
9843
|
-
import { useSyncExternalStore as
|
|
10012
|
+
import { useSyncExternalStore as useSyncExternalStore5 } from "react";
|
|
9844
10013
|
var STORAGE_KEY2 = "fourty.projection.preferences";
|
|
9845
10014
|
var storage2 = createSessionStorageAdapter();
|
|
9846
10015
|
function load2() {
|
|
@@ -9855,22 +10024,22 @@ function load2() {
|
|
|
9855
10024
|
}
|
|
9856
10025
|
}
|
|
9857
10026
|
var preferences = load2();
|
|
9858
|
-
var
|
|
10027
|
+
var listeners4 = /* @__PURE__ */ new Set();
|
|
9859
10028
|
registerSessionScopedClear(() => {
|
|
9860
10029
|
preferences = {};
|
|
9861
10030
|
storage2.remove(STORAGE_KEY2);
|
|
9862
|
-
|
|
10031
|
+
notify4();
|
|
9863
10032
|
});
|
|
9864
|
-
function
|
|
9865
|
-
for (const listener of
|
|
10033
|
+
function notify4() {
|
|
10034
|
+
for (const listener of listeners4) listener();
|
|
9866
10035
|
}
|
|
9867
10036
|
function getProjectionPreferences() {
|
|
9868
10037
|
return preferences;
|
|
9869
10038
|
}
|
|
9870
10039
|
function subscribeProjectionPreferences(listener) {
|
|
9871
|
-
|
|
10040
|
+
listeners4.add(listener);
|
|
9872
10041
|
return () => {
|
|
9873
|
-
|
|
10042
|
+
listeners4.delete(listener);
|
|
9874
10043
|
};
|
|
9875
10044
|
}
|
|
9876
10045
|
function allProjectableScopes() {
|
|
@@ -9911,11 +10080,11 @@ function applyProjectionSet(payload) {
|
|
|
9911
10080
|
if (!changed) return;
|
|
9912
10081
|
preferences = next;
|
|
9913
10082
|
storage2.set(STORAGE_KEY2, JSON.stringify(preferences));
|
|
9914
|
-
|
|
10083
|
+
notify4();
|
|
9915
10084
|
}
|
|
9916
10085
|
var EMPTY = {};
|
|
9917
10086
|
function useProjectionPreferences() {
|
|
9918
|
-
return
|
|
10087
|
+
return useSyncExternalStore5(
|
|
9919
10088
|
subscribeProjectionPreferences,
|
|
9920
10089
|
getProjectionPreferences,
|
|
9921
10090
|
() => EMPTY
|
|
@@ -9965,7 +10134,7 @@ var projectionTransform = {
|
|
|
9965
10134
|
use: () => {
|
|
9966
10135
|
const preferences2 = useProjectionPreferences();
|
|
9967
10136
|
const facts = useFacts();
|
|
9968
|
-
return
|
|
10137
|
+
return useMemo12(() => {
|
|
9969
10138
|
if (Object.keys(preferences2).length === 0) return null;
|
|
9970
10139
|
return buildTransform(preferences2, facts);
|
|
9971
10140
|
}, [preferences2, facts]);
|
|
@@ -9981,7 +10150,7 @@ function ProjectionSignalBridge() {
|
|
|
9981
10150
|
}
|
|
9982
10151
|
|
|
9983
10152
|
// src/projection/use-projection.ts
|
|
9984
|
-
import { useCallback as
|
|
10153
|
+
import { useCallback as useCallback15, useEffect as useEffect12, useState as useState8 } from "react";
|
|
9985
10154
|
function readResult(raw) {
|
|
9986
10155
|
if (raw === null || typeof raw !== "object") return void 0;
|
|
9987
10156
|
if (!("hiddenCount" in raw) || typeof raw.hiddenCount !== "number") return void 0;
|
|
@@ -9994,8 +10163,8 @@ function entityIdOf(value) {
|
|
|
9994
10163
|
}
|
|
9995
10164
|
var NO_AXES = [];
|
|
9996
10165
|
function useProjection(projectionProp, entity2) {
|
|
9997
|
-
const [expanded, setExpanded] =
|
|
9998
|
-
const toggle =
|
|
10166
|
+
const [expanded, setExpanded] = useState8(false);
|
|
10167
|
+
const toggle = useCallback15(() => setExpanded((e) => !e), []);
|
|
9999
10168
|
const entityId = entityIdOf(entity2);
|
|
10000
10169
|
useEffect12(() => {
|
|
10001
10170
|
setExpanded(false);
|
|
@@ -10043,34 +10212,34 @@ __export(interaction_exports, {
|
|
|
10043
10212
|
});
|
|
10044
10213
|
|
|
10045
10214
|
// src/interaction/withInteractionTracking.tsx
|
|
10046
|
-
import
|
|
10047
|
-
import { jsx as
|
|
10048
|
-
var InteractionContext =
|
|
10215
|
+
import React39, { createContext as createContext25, useContext as useContext25 } from "react";
|
|
10216
|
+
import { jsx as jsx22, jsxs } from "react/jsx-runtime";
|
|
10217
|
+
var InteractionContext = createContext25(null);
|
|
10049
10218
|
function InteractionProvider({
|
|
10050
10219
|
onInteraction,
|
|
10051
10220
|
children
|
|
10052
10221
|
}) {
|
|
10053
|
-
return /* @__PURE__ */
|
|
10222
|
+
return /* @__PURE__ */ jsx22(InteractionContext.Provider, { value: onInteraction, children });
|
|
10054
10223
|
}
|
|
10055
10224
|
function useInteraction2() {
|
|
10056
|
-
return
|
|
10225
|
+
return useContext25(InteractionContext);
|
|
10057
10226
|
}
|
|
10058
10227
|
function withInteractionTracking(WrappedComponent, meta) {
|
|
10059
10228
|
function TrackedComponent(props) {
|
|
10060
|
-
return /* @__PURE__ */
|
|
10229
|
+
return /* @__PURE__ */ jsx22(
|
|
10061
10230
|
"div",
|
|
10062
10231
|
{
|
|
10063
10232
|
"data-tracked-component": meta.componentId,
|
|
10064
10233
|
"data-tracked-component-type": meta.componentType,
|
|
10065
10234
|
style: { display: "contents" },
|
|
10066
|
-
children: /* @__PURE__ */
|
|
10235
|
+
children: /* @__PURE__ */ jsx22(ComponentErrorBoundary, { componentId: meta.componentId, children: /* @__PURE__ */ jsx22(WrappedComponent, { ...props }) })
|
|
10067
10236
|
}
|
|
10068
10237
|
);
|
|
10069
10238
|
}
|
|
10070
10239
|
TrackedComponent.displayName = `Tracked(${WrappedComponent.displayName || WrappedComponent.name || "Component"})`;
|
|
10071
10240
|
return TrackedComponent;
|
|
10072
10241
|
}
|
|
10073
|
-
var ComponentErrorBoundary = class extends
|
|
10242
|
+
var ComponentErrorBoundary = class extends React39.Component {
|
|
10074
10243
|
constructor() {
|
|
10075
10244
|
super(...arguments);
|
|
10076
10245
|
__publicField(this, "state", { error: null });
|
|
@@ -10084,7 +10253,7 @@ var ComponentErrorBoundary = class extends React37.Component {
|
|
|
10084
10253
|
render() {
|
|
10085
10254
|
if (this.state.error) {
|
|
10086
10255
|
return /* @__PURE__ */ jsxs("div", { className: "fourty-component-error", role: "alert", "data-component-id": this.props.componentId, children: [
|
|
10087
|
-
/* @__PURE__ */
|
|
10256
|
+
/* @__PURE__ */ jsx22("strong", { children: this.props.componentId }),
|
|
10088
10257
|
": ",
|
|
10089
10258
|
this.state.error.message
|
|
10090
10259
|
] });
|
|
@@ -10141,17 +10310,17 @@ __export(utils_exports, {
|
|
|
10141
10310
|
});
|
|
10142
10311
|
|
|
10143
10312
|
// src/utils/use-form-factor.ts
|
|
10144
|
-
import { useSyncExternalStore as
|
|
10313
|
+
import { useSyncExternalStore as useSyncExternalStore6 } from "react";
|
|
10145
10314
|
|
|
10146
10315
|
// src/utils/viewport-window.tsx
|
|
10147
|
-
import { createContext as
|
|
10148
|
-
import { jsx as
|
|
10149
|
-
var ViewportWindowContext =
|
|
10316
|
+
import { createContext as createContext26, useContext as useContext26 } from "react";
|
|
10317
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
10318
|
+
var ViewportWindowContext = createContext26(null);
|
|
10150
10319
|
function canAnswer(win) {
|
|
10151
10320
|
return win !== null && typeof win.matchMedia === "function";
|
|
10152
10321
|
}
|
|
10153
10322
|
function useViewportWindow() {
|
|
10154
|
-
const provided =
|
|
10323
|
+
const provided = useContext26(ViewportWindowContext);
|
|
10155
10324
|
if (provided !== null) return canAnswer(provided) ? provided : null;
|
|
10156
10325
|
const global = globalThis;
|
|
10157
10326
|
return canAnswer(global) ? global : null;
|
|
@@ -10160,7 +10329,7 @@ function ViewportWindowProvider({
|
|
|
10160
10329
|
value,
|
|
10161
10330
|
children
|
|
10162
10331
|
}) {
|
|
10163
|
-
return /* @__PURE__ */
|
|
10332
|
+
return /* @__PURE__ */ jsx23(ViewportWindowContext.Provider, { value, children });
|
|
10164
10333
|
}
|
|
10165
10334
|
|
|
10166
10335
|
// src/utils/use-form-factor.ts
|
|
@@ -10219,7 +10388,7 @@ var noWindowRead = () => SERVER_SNAPSHOT;
|
|
|
10219
10388
|
function useFormFactor() {
|
|
10220
10389
|
const win = useViewportWindow();
|
|
10221
10390
|
const store = win === null ? null : storeFor(win);
|
|
10222
|
-
return
|
|
10391
|
+
return useSyncExternalStore6(
|
|
10223
10392
|
store === null ? noWindowSubscribe : store.subscribe,
|
|
10224
10393
|
store === null ? noWindowRead : store.read,
|
|
10225
10394
|
noWindowRead
|
|
@@ -10227,14 +10396,14 @@ function useFormFactor() {
|
|
|
10227
10396
|
}
|
|
10228
10397
|
|
|
10229
10398
|
// src/utils/use-inline-completion.ts
|
|
10230
|
-
import { useCallback as
|
|
10399
|
+
import { useCallback as useCallback16, useMemo as useMemo13, useState as useState9 } from "react";
|
|
10231
10400
|
function useInlineCompletion(opts) {
|
|
10232
10401
|
const { value, candidates } = opts;
|
|
10233
10402
|
const minChars = opts.minChars !== void 0 ? opts.minChars : 2;
|
|
10234
10403
|
const enabled = opts.enabled !== void 0 ? opts.enabled : true;
|
|
10235
|
-
const [dismissedValue, setDismissedValue] =
|
|
10236
|
-
const dismiss =
|
|
10237
|
-
return
|
|
10404
|
+
const [dismissedValue, setDismissedValue] = useState9(null);
|
|
10405
|
+
const dismiss = useCallback16(() => setDismissedValue(value), [value]);
|
|
10406
|
+
return useMemo13(() => {
|
|
10238
10407
|
if (!enabled || value.length < minChars || dismissedValue === value) {
|
|
10239
10408
|
return { completion: "", ghost: "", active: false, dismiss };
|
|
10240
10409
|
}
|
|
@@ -10251,8 +10420,8 @@ function useInlineCompletion(opts) {
|
|
|
10251
10420
|
}
|
|
10252
10421
|
|
|
10253
10422
|
// src/utils/use-document-visible.ts
|
|
10254
|
-
import
|
|
10255
|
-
function
|
|
10423
|
+
import React40 from "react";
|
|
10424
|
+
function subscribe4(onChange) {
|
|
10256
10425
|
document.addEventListener("visibilitychange", onChange);
|
|
10257
10426
|
return () => document.removeEventListener("visibilitychange", onChange);
|
|
10258
10427
|
}
|
|
@@ -10263,15 +10432,15 @@ function getServerSnapshot() {
|
|
|
10263
10432
|
return true;
|
|
10264
10433
|
}
|
|
10265
10434
|
function useDocumentVisible() {
|
|
10266
|
-
return
|
|
10435
|
+
return React40.useSyncExternalStore(subscribe4, getSnapshot, getServerSnapshot);
|
|
10267
10436
|
}
|
|
10268
10437
|
|
|
10269
10438
|
// src/utils/use-interval.ts
|
|
10270
|
-
import
|
|
10439
|
+
import React41 from "react";
|
|
10271
10440
|
function useInterval(callback, ms, active = true) {
|
|
10272
|
-
const cbRef =
|
|
10441
|
+
const cbRef = React41.useRef(callback);
|
|
10273
10442
|
cbRef.current = callback;
|
|
10274
|
-
|
|
10443
|
+
React41.useEffect(() => {
|
|
10275
10444
|
if (!active) return;
|
|
10276
10445
|
const id = window.setInterval(() => cbRef.current(), ms);
|
|
10277
10446
|
return () => window.clearInterval(id);
|
|
@@ -10279,7 +10448,7 @@ function useInterval(callback, ms, active = true) {
|
|
|
10279
10448
|
}
|
|
10280
10449
|
|
|
10281
10450
|
// src/utils/use-success-flash.ts
|
|
10282
|
-
import { useCallback as
|
|
10451
|
+
import { useCallback as useCallback17, useEffect as useEffect13, useRef as useRef9, useState as useState10 } from "react";
|
|
10283
10452
|
import { useAnimationControls } from "framer-motion";
|
|
10284
10453
|
function useSuccessFlash(options) {
|
|
10285
10454
|
const duration = options !== void 0 && options.duration !== void 0 ? options.duration : 900;
|
|
@@ -10288,14 +10457,14 @@ function useSuccessFlash(options) {
|
|
|
10288
10457
|
options !== void 0 && options.scale !== void 0 ? options.scale : [1, 1.06, 0.98, 1]
|
|
10289
10458
|
);
|
|
10290
10459
|
const controls = useAnimationControls();
|
|
10291
|
-
const [flashing, setFlashing] =
|
|
10460
|
+
const [flashing, setFlashing] = useState10(false);
|
|
10292
10461
|
const timerRef = useRef9(null);
|
|
10293
10462
|
useEffect13(() => {
|
|
10294
10463
|
return () => {
|
|
10295
10464
|
if (timerRef.current !== null) window.clearTimeout(timerRef.current);
|
|
10296
10465
|
};
|
|
10297
10466
|
}, []);
|
|
10298
|
-
const trigger =
|
|
10467
|
+
const trigger = useCallback17(() => {
|
|
10299
10468
|
setFlashing(true);
|
|
10300
10469
|
controls.start({
|
|
10301
10470
|
scale: scaleRef.current,
|
|
@@ -10397,14 +10566,14 @@ function validateAll(items, schema, context) {
|
|
|
10397
10566
|
|
|
10398
10567
|
// src/client-state/store.ts
|
|
10399
10568
|
var entries = /* @__PURE__ */ new Map();
|
|
10400
|
-
var
|
|
10569
|
+
var listeners5 = /* @__PURE__ */ new Set();
|
|
10401
10570
|
var vectorCache = {};
|
|
10402
10571
|
var entriesCache = /* @__PURE__ */ new Map();
|
|
10403
|
-
function
|
|
10572
|
+
function notify5() {
|
|
10404
10573
|
vectorCache = {};
|
|
10405
10574
|
for (const [ns, e] of entries) vectorCache[ns] = e.rev;
|
|
10406
10575
|
entriesCache = new Map(entries);
|
|
10407
|
-
for (const l of
|
|
10576
|
+
for (const l of listeners5) l();
|
|
10408
10577
|
}
|
|
10409
10578
|
function publishClientState(namespace, payload) {
|
|
10410
10579
|
if (namespace.length === 0) return;
|
|
@@ -10413,7 +10582,7 @@ function publishClientState(namespace, payload) {
|
|
|
10413
10582
|
if (prev !== void 0 && prev.key === key) return;
|
|
10414
10583
|
const rev = prev !== void 0 ? prev.rev + 1 : 1;
|
|
10415
10584
|
entries.set(namespace, { payload, rev, key });
|
|
10416
|
-
|
|
10585
|
+
notify5();
|
|
10417
10586
|
}
|
|
10418
10587
|
function clientStateVector() {
|
|
10419
10588
|
return vectorCache;
|
|
@@ -10422,26 +10591,26 @@ function clientStateEntries() {
|
|
|
10422
10591
|
return entriesCache;
|
|
10423
10592
|
}
|
|
10424
10593
|
function subscribeClientState(listener) {
|
|
10425
|
-
|
|
10594
|
+
listeners5.add(listener);
|
|
10426
10595
|
return () => {
|
|
10427
|
-
|
|
10596
|
+
listeners5.delete(listener);
|
|
10428
10597
|
};
|
|
10429
10598
|
}
|
|
10430
10599
|
|
|
10431
10600
|
// src/client-state/server-store.ts
|
|
10432
10601
|
var entries2 = /* @__PURE__ */ new Map();
|
|
10433
|
-
var
|
|
10602
|
+
var listeners6 = /* @__PURE__ */ new Set();
|
|
10434
10603
|
var entriesCache2 = /* @__PURE__ */ new Map();
|
|
10435
|
-
function
|
|
10604
|
+
function notify6() {
|
|
10436
10605
|
entriesCache2 = new Map(entries2);
|
|
10437
|
-
for (const l of
|
|
10606
|
+
for (const l of listeners6) l();
|
|
10438
10607
|
}
|
|
10439
10608
|
function applyServerState(namespace, rev, payload) {
|
|
10440
10609
|
if (namespace.length === 0) return false;
|
|
10441
10610
|
const prev = entries2.get(namespace);
|
|
10442
10611
|
if (prev !== void 0 && rev <= prev.rev) return false;
|
|
10443
10612
|
entries2.set(namespace, { payload, rev });
|
|
10444
|
-
|
|
10613
|
+
notify6();
|
|
10445
10614
|
return true;
|
|
10446
10615
|
}
|
|
10447
10616
|
function serverState(namespace) {
|
|
@@ -10457,15 +10626,15 @@ function serverStateEntries() {
|
|
|
10457
10626
|
return entriesCache2;
|
|
10458
10627
|
}
|
|
10459
10628
|
function subscribeServerState(listener) {
|
|
10460
|
-
|
|
10629
|
+
listeners6.add(listener);
|
|
10461
10630
|
return () => {
|
|
10462
|
-
|
|
10631
|
+
listeners6.delete(listener);
|
|
10463
10632
|
};
|
|
10464
10633
|
}
|
|
10465
10634
|
function resetServerState() {
|
|
10466
10635
|
if (entries2.size === 0) return;
|
|
10467
10636
|
entries2.clear();
|
|
10468
|
-
|
|
10637
|
+
notify6();
|
|
10469
10638
|
}
|
|
10470
10639
|
function primedEntities() {
|
|
10471
10640
|
const payload = serverState(ENTITY_PRIME_NAMESPACE);
|
|
@@ -10483,15 +10652,15 @@ function primedEntitiesFor(resolverKey) {
|
|
|
10483
10652
|
}
|
|
10484
10653
|
|
|
10485
10654
|
// src/preview/SpacefrontPreviewProvider.tsx
|
|
10486
|
-
import * as
|
|
10487
|
-
import { jsx as
|
|
10655
|
+
import * as React42 from "react";
|
|
10656
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
10488
10657
|
var NOOP = () => {
|
|
10489
10658
|
};
|
|
10490
10659
|
var ASYNC_NOOP = () => Promise.resolve();
|
|
10491
10660
|
var VIEW = { page: { kind: "home" }, layout: EMPTY_SPEC, shell: EMPTY_SHELL };
|
|
10492
|
-
var PreviewContext =
|
|
10661
|
+
var PreviewContext = React42.createContext(null);
|
|
10493
10662
|
function usePreview() {
|
|
10494
|
-
const value =
|
|
10663
|
+
const value = React42.useContext(PreviewContext);
|
|
10495
10664
|
if (value === null) throw new Error("preview runtime used outside <SpacefrontPreviewProvider>");
|
|
10496
10665
|
return value;
|
|
10497
10666
|
}
|
|
@@ -10645,27 +10814,27 @@ var PRESENCE = {
|
|
|
10645
10814
|
usePresenceLiveTurn: () => usePreview().pending?.messageId
|
|
10646
10815
|
};
|
|
10647
10816
|
function SpacefrontPreviewProvider({ scene, onSend, children }) {
|
|
10648
|
-
const [sessionId] =
|
|
10649
|
-
const derived =
|
|
10650
|
-
const onSendRef =
|
|
10817
|
+
const [sessionId] = React42.useState(() => `preview-${Math.random().toString(36).slice(2)}`);
|
|
10818
|
+
const derived = React42.useMemo(() => derive(scene, sessionId), [scene, sessionId]);
|
|
10819
|
+
const onSendRef = React42.useRef(onSend);
|
|
10651
10820
|
onSendRef.current = onSend;
|
|
10652
|
-
const draft =
|
|
10821
|
+
const draft = React42.useMemo(() => {
|
|
10653
10822
|
let text2 = "";
|
|
10654
|
-
const
|
|
10823
|
+
const listeners14 = /* @__PURE__ */ new Set();
|
|
10655
10824
|
return {
|
|
10656
10825
|
store: { subscribe: (fn) => {
|
|
10657
|
-
|
|
10826
|
+
listeners14.add(fn);
|
|
10658
10827
|
return () => {
|
|
10659
|
-
|
|
10828
|
+
listeners14.delete(fn);
|
|
10660
10829
|
};
|
|
10661
10830
|
}, get: () => text2 },
|
|
10662
10831
|
set: (next) => {
|
|
10663
10832
|
text2 = next;
|
|
10664
|
-
|
|
10833
|
+
listeners14.forEach((fn) => fn());
|
|
10665
10834
|
}
|
|
10666
10835
|
};
|
|
10667
10836
|
}, []);
|
|
10668
|
-
const session =
|
|
10837
|
+
const session = React42.useMemo(() => {
|
|
10669
10838
|
const send = (text2) => {
|
|
10670
10839
|
draft.set("");
|
|
10671
10840
|
onSendRef.current?.(text2);
|
|
@@ -10717,15 +10886,15 @@ function SpacefrontPreviewProvider({ scene, onSend, children }) {
|
|
|
10717
10886
|
const qId = question === null ? null : question.id;
|
|
10718
10887
|
const qText = question === null ? "" : question.text;
|
|
10719
10888
|
const qReplies = question === null ? "" : list(question.replies).join("\0");
|
|
10720
|
-
const raised =
|
|
10721
|
-
|
|
10889
|
+
const raised = React42.useRef(0);
|
|
10890
|
+
React42.useEffect(() => {
|
|
10722
10891
|
if (qId === null) return;
|
|
10723
10892
|
raised.current += 1;
|
|
10724
10893
|
const id = `${qId}-${raised.current}`;
|
|
10725
10894
|
raiseStanding(AGENT_ASK_SIGNAL, id, { ask: qText, suggestions: qReplies === "" ? [] : qReplies.split("\0") }, sessionId);
|
|
10726
10895
|
return () => resolveStanding(id, sessionId);
|
|
10727
10896
|
}, [qId, qText, qReplies, sessionId]);
|
|
10728
|
-
return /* @__PURE__ */
|
|
10897
|
+
return /* @__PURE__ */ jsx24(PreviewContext.Provider, { value: derived, children: /* @__PURE__ */ jsx24(FourtySessionContext.Provider, { value: session, children: /* @__PURE__ */ jsx24(FourtyRuntimeProvider, { value: RUNTIME, children: /* @__PURE__ */ jsx24(PresenceRuntimeProvider, { value: PRESENCE, children }) }) }) });
|
|
10729
10898
|
}
|
|
10730
10899
|
|
|
10731
10900
|
// src/verticals/commerce/index.ts
|
|
@@ -10812,6 +10981,7 @@ __export(commerce_exports, {
|
|
|
10812
10981
|
useCommerceRuntime: () => useCommerceRuntime,
|
|
10813
10982
|
useComparisonHighlight: () => useComparisonHighlight,
|
|
10814
10983
|
useCustomerAccount: () => useCustomerAccount,
|
|
10984
|
+
useInstallmentOffer: () => useInstallmentOffer,
|
|
10815
10985
|
useLookCard: () => useLookCard,
|
|
10816
10986
|
useOptionSelections: () => useOptionSelections,
|
|
10817
10987
|
usePendingVariantChoice: () => usePendingVariantChoice,
|
|
@@ -10868,7 +11038,7 @@ registerEntityPageKind("search", {
|
|
|
10868
11038
|
});
|
|
10869
11039
|
|
|
10870
11040
|
// src/verticals/commerce/commerce-context.tsx
|
|
10871
|
-
import { createContext as
|
|
11041
|
+
import { createContext as createContext28, useContext as useContext28 } from "react";
|
|
10872
11042
|
var INERT_COMMERCE_RUNTIME = {
|
|
10873
11043
|
useCart: () => {
|
|
10874
11044
|
throw new Error("useCart must be used within a <CommerceProvider>");
|
|
@@ -10905,14 +11075,16 @@ var INERT_COMMERCE_RUNTIME = {
|
|
|
10905
11075
|
}),
|
|
10906
11076
|
useCustomerAccount: () => ({ signedIn: false, email: null, signIn: () => {
|
|
10907
11077
|
}, signOut: async () => {
|
|
10908
|
-
}, available: false })
|
|
11078
|
+
}, available: false }),
|
|
11079
|
+
// No store, no plans: a price line simply shows no installment offer.
|
|
11080
|
+
useInstallmentOffer: () => void 0
|
|
10909
11081
|
};
|
|
10910
|
-
var FourtyCommerceRuntimeContext =
|
|
11082
|
+
var FourtyCommerceRuntimeContext = createContext28(
|
|
10911
11083
|
INERT_COMMERCE_RUNTIME
|
|
10912
11084
|
);
|
|
10913
11085
|
var FourtyCommerceRuntimeProvider = FourtyCommerceRuntimeContext.Provider;
|
|
10914
11086
|
function useCommerceRuntime() {
|
|
10915
|
-
return
|
|
11087
|
+
return useContext28(FourtyCommerceRuntimeContext);
|
|
10916
11088
|
}
|
|
10917
11089
|
function useCart() {
|
|
10918
11090
|
return useCommerceRuntime().useCart();
|
|
@@ -10938,6 +11110,9 @@ function useProductReviews(product, intent) {
|
|
|
10938
11110
|
function useCustomerAccount() {
|
|
10939
11111
|
return useCommerceRuntime().useCustomerAccount();
|
|
10940
11112
|
}
|
|
11113
|
+
function useInstallmentOffer(price) {
|
|
11114
|
+
return useCommerceRuntime().useInstallmentOffer(price);
|
|
11115
|
+
}
|
|
10941
11116
|
|
|
10942
11117
|
// src/verticals/commerce/checkout/external-navigation.ts
|
|
10943
11118
|
function navigateToExternalCommerceUrl(url) {
|
|
@@ -10963,17 +11138,17 @@ function navigateToExternalCommerceUrl(url) {
|
|
|
10963
11138
|
}
|
|
10964
11139
|
|
|
10965
11140
|
// src/verticals/commerce/variant/variant-selection-store.ts
|
|
10966
|
-
import { useSyncExternalStore as
|
|
11141
|
+
import { useSyncExternalStore as useSyncExternalStore7 } from "react";
|
|
10967
11142
|
var EMPTY2 = /* @__PURE__ */ new Map();
|
|
10968
11143
|
var selections = /* @__PURE__ */ new Map();
|
|
10969
|
-
var
|
|
10970
|
-
function
|
|
10971
|
-
for (const listener of
|
|
11144
|
+
var listeners7 = /* @__PURE__ */ new Set();
|
|
11145
|
+
function notify7() {
|
|
11146
|
+
for (const listener of listeners7) listener();
|
|
10972
11147
|
}
|
|
10973
|
-
function
|
|
10974
|
-
|
|
11148
|
+
function subscribe5(listener) {
|
|
11149
|
+
listeners7.add(listener);
|
|
10975
11150
|
return () => {
|
|
10976
|
-
|
|
11151
|
+
listeners7.delete(listener);
|
|
10977
11152
|
};
|
|
10978
11153
|
}
|
|
10979
11154
|
function recordVariantSelection(productId, variantId) {
|
|
@@ -10983,58 +11158,58 @@ function recordVariantSelection(productId, variantId) {
|
|
|
10983
11158
|
const next = new Map(selections);
|
|
10984
11159
|
next.set(productId, variantId);
|
|
10985
11160
|
selections = next;
|
|
10986
|
-
|
|
11161
|
+
notify7();
|
|
10987
11162
|
}
|
|
10988
11163
|
function getVariantSelection(productId) {
|
|
10989
11164
|
return selections.get(productId);
|
|
10990
11165
|
}
|
|
10991
11166
|
function useVariantSelections() {
|
|
10992
|
-
return
|
|
11167
|
+
return useSyncExternalStore7(subscribe5, () => selections, () => EMPTY2);
|
|
10993
11168
|
}
|
|
10994
11169
|
registerSessionScopedClear(() => {
|
|
10995
11170
|
if (selections.size === 0) return;
|
|
10996
11171
|
selections = /* @__PURE__ */ new Map();
|
|
10997
|
-
|
|
11172
|
+
notify7();
|
|
10998
11173
|
});
|
|
10999
11174
|
|
|
11000
11175
|
// src/verticals/commerce/variant/pending-variant-choice-store.ts
|
|
11001
|
-
import { useSyncExternalStore as
|
|
11176
|
+
import { useSyncExternalStore as useSyncExternalStore8 } from "react";
|
|
11002
11177
|
var pending = null;
|
|
11003
|
-
var
|
|
11004
|
-
function
|
|
11005
|
-
for (const listener of
|
|
11178
|
+
var listeners8 = /* @__PURE__ */ new Set();
|
|
11179
|
+
function notify8() {
|
|
11180
|
+
for (const listener of listeners8) listener();
|
|
11006
11181
|
}
|
|
11007
|
-
function
|
|
11008
|
-
|
|
11182
|
+
function subscribe6(listener) {
|
|
11183
|
+
listeners8.add(listener);
|
|
11009
11184
|
return () => {
|
|
11010
|
-
|
|
11185
|
+
listeners8.delete(listener);
|
|
11011
11186
|
};
|
|
11012
11187
|
}
|
|
11013
11188
|
function requestVariantChoice(choice) {
|
|
11014
11189
|
pending = choice;
|
|
11015
|
-
|
|
11190
|
+
notify8();
|
|
11016
11191
|
}
|
|
11017
11192
|
function clearVariantChoice() {
|
|
11018
11193
|
if (pending === null) return;
|
|
11019
11194
|
pending = null;
|
|
11020
|
-
|
|
11195
|
+
notify8();
|
|
11021
11196
|
}
|
|
11022
11197
|
function usePendingVariantChoice() {
|
|
11023
|
-
return
|
|
11198
|
+
return useSyncExternalStore8(subscribe6, () => pending, () => null);
|
|
11024
11199
|
}
|
|
11025
11200
|
|
|
11026
11201
|
// src/verticals/commerce/variant/option-selection-store.ts
|
|
11027
|
-
import { useSyncExternalStore as
|
|
11202
|
+
import { useSyncExternalStore as useSyncExternalStore9 } from "react";
|
|
11028
11203
|
var EMPTY3 = /* @__PURE__ */ new Map();
|
|
11029
11204
|
var selections2 = /* @__PURE__ */ new Map();
|
|
11030
|
-
var
|
|
11031
|
-
function
|
|
11032
|
-
for (const listener of
|
|
11205
|
+
var listeners9 = /* @__PURE__ */ new Set();
|
|
11206
|
+
function notify9() {
|
|
11207
|
+
for (const listener of listeners9) listener();
|
|
11033
11208
|
}
|
|
11034
|
-
function
|
|
11035
|
-
|
|
11209
|
+
function subscribe7(listener) {
|
|
11210
|
+
listeners9.add(listener);
|
|
11036
11211
|
return () => {
|
|
11037
|
-
|
|
11212
|
+
listeners9.delete(listener);
|
|
11038
11213
|
};
|
|
11039
11214
|
}
|
|
11040
11215
|
function recordOptionSelections(productId, picks) {
|
|
@@ -11056,18 +11231,18 @@ function recordOptionSelections(productId, picks) {
|
|
|
11056
11231
|
const next = new Map(selections2);
|
|
11057
11232
|
next.set(productId, merged);
|
|
11058
11233
|
selections2 = next;
|
|
11059
|
-
|
|
11234
|
+
notify9();
|
|
11060
11235
|
}
|
|
11061
11236
|
function getOptionSelections(productId) {
|
|
11062
11237
|
return selections2.get(productId);
|
|
11063
11238
|
}
|
|
11064
11239
|
function useOptionSelections() {
|
|
11065
|
-
return
|
|
11240
|
+
return useSyncExternalStore9(subscribe7, () => selections2, () => EMPTY3);
|
|
11066
11241
|
}
|
|
11067
11242
|
registerSessionScopedClear(() => {
|
|
11068
11243
|
if (selections2.size === 0) return;
|
|
11069
11244
|
selections2 = /* @__PURE__ */ new Map();
|
|
11070
|
-
|
|
11245
|
+
notify9();
|
|
11071
11246
|
});
|
|
11072
11247
|
|
|
11073
11248
|
// ../spacestation/src/analytics/ecommerce/index.ts
|
|
@@ -11125,33 +11300,33 @@ function isFunnelStep(value) {
|
|
|
11125
11300
|
}
|
|
11126
11301
|
|
|
11127
11302
|
// src/verticals/commerce/product/use-product-grid-filter.ts
|
|
11128
|
-
import { useCallback as
|
|
11303
|
+
import { useCallback as useCallback18, useMemo as useMemo15, useState as useState12 } from "react";
|
|
11129
11304
|
function useProductGridFilter(chips) {
|
|
11130
|
-
const labelKey =
|
|
11305
|
+
const labelKey = useMemo15(() => chips.map((c) => c.label).join("|"), [chips]);
|
|
11131
11306
|
const first = chips[0];
|
|
11132
|
-
const [activeLabel, setActiveLabel] =
|
|
11307
|
+
const [activeLabel, setActiveLabel] = useState12(
|
|
11133
11308
|
first !== void 0 ? first.label : null
|
|
11134
11309
|
);
|
|
11135
|
-
const activeFromKey =
|
|
11310
|
+
const activeFromKey = useMemo15(() => {
|
|
11136
11311
|
void labelKey;
|
|
11137
11312
|
if (first === void 0) return null;
|
|
11138
11313
|
const found = chips.find((c) => c.label === activeLabel);
|
|
11139
11314
|
return found !== void 0 ? found : first;
|
|
11140
11315
|
}, [chips, first, activeLabel, labelKey]);
|
|
11141
|
-
const setActive =
|
|
11316
|
+
const setActive = useCallback18((next) => {
|
|
11142
11317
|
setActiveLabel(next.label);
|
|
11143
11318
|
}, []);
|
|
11144
11319
|
return { chips, active: activeFromKey, setActive };
|
|
11145
11320
|
}
|
|
11146
11321
|
|
|
11147
11322
|
// src/verticals/commerce/product/use-product-detail.ts
|
|
11148
|
-
import { useCallback as
|
|
11323
|
+
import { useCallback as useCallback20, useMemo as useMemo16, useRef as useRef13, useState as useState15 } from "react";
|
|
11149
11324
|
|
|
11150
11325
|
// src/verticals/commerce/checkout/use-buy-now.ts
|
|
11151
|
-
import { useCallback as
|
|
11326
|
+
import { useCallback as useCallback19, useEffect as useEffect16, useState as useState13 } from "react";
|
|
11152
11327
|
|
|
11153
11328
|
// src/verticals/commerce/checkout/checkout-handoff-store.ts
|
|
11154
|
-
import { useSyncExternalStore as
|
|
11329
|
+
import { useSyncExternalStore as useSyncExternalStore10 } from "react";
|
|
11155
11330
|
|
|
11156
11331
|
// src/verticals/commerce/checkout/checkout-handoff-reasons.ts
|
|
11157
11332
|
var CHECKOUT_BLOCKED_REASON = "the browser blocked the checkout tab, so the visitor has NOT reached checkout and is still on the page. Tell them plainly and point them at their bag to check out from there; never imply they arrived.";
|
|
@@ -11180,13 +11355,13 @@ var IDLE = {
|
|
|
11180
11355
|
attempt: 0
|
|
11181
11356
|
};
|
|
11182
11357
|
var state = IDLE;
|
|
11183
|
-
var
|
|
11184
|
-
function
|
|
11185
|
-
for (const listener of
|
|
11358
|
+
var listeners10 = /* @__PURE__ */ new Set();
|
|
11359
|
+
function notify10() {
|
|
11360
|
+
for (const listener of listeners10) listener();
|
|
11186
11361
|
}
|
|
11187
11362
|
function record(analytics, next) {
|
|
11188
11363
|
state = next;
|
|
11189
|
-
|
|
11364
|
+
notify10();
|
|
11190
11365
|
if (analytics === null) return;
|
|
11191
11366
|
analytics.emit(CHECKOUT_CLICKED, {
|
|
11192
11367
|
origin: next.origin,
|
|
@@ -11252,22 +11427,22 @@ function recordVisitorCheckoutExit(analytics, outcome) {
|
|
|
11252
11427
|
attempt: state.attempt + 1
|
|
11253
11428
|
});
|
|
11254
11429
|
}
|
|
11255
|
-
function
|
|
11256
|
-
|
|
11430
|
+
function subscribe8(listener) {
|
|
11431
|
+
listeners10.add(listener);
|
|
11257
11432
|
return () => {
|
|
11258
|
-
|
|
11433
|
+
listeners10.delete(listener);
|
|
11259
11434
|
};
|
|
11260
11435
|
}
|
|
11261
11436
|
function readCheckoutHandoff() {
|
|
11262
11437
|
return state;
|
|
11263
11438
|
}
|
|
11264
11439
|
function useCheckoutHandoff() {
|
|
11265
|
-
return
|
|
11440
|
+
return useSyncExternalStore10(subscribe8, readCheckoutHandoff, () => IDLE);
|
|
11266
11441
|
}
|
|
11267
11442
|
registerSessionScopedClear(() => {
|
|
11268
11443
|
if (state === IDLE) return;
|
|
11269
11444
|
state = IDLE;
|
|
11270
|
-
|
|
11445
|
+
notify10();
|
|
11271
11446
|
});
|
|
11272
11447
|
|
|
11273
11448
|
// src/verticals/commerce/checkout/buy-now-exit.ts
|
|
@@ -11288,8 +11463,8 @@ var BUY_NOW_SETTLE_TIMEOUT_MS = 12e3;
|
|
|
11288
11463
|
function useBuyNow(addToCart) {
|
|
11289
11464
|
const cartApi = useCart();
|
|
11290
11465
|
const analytics = useOptionalAnalyticsSink();
|
|
11291
|
-
const [pending2, setPending] =
|
|
11292
|
-
const start =
|
|
11466
|
+
const [pending2, setPending] = useState13(null);
|
|
11467
|
+
const start = useCallback19((variantId) => {
|
|
11293
11468
|
if (pending2 !== null) return;
|
|
11294
11469
|
addToCart();
|
|
11295
11470
|
setPending(variantId);
|
|
@@ -11377,9 +11552,9 @@ function isOptionUnavailable(product, selectedVariants, group, opt) {
|
|
|
11377
11552
|
}
|
|
11378
11553
|
|
|
11379
11554
|
// src/verticals/commerce/variant/use-selected-variants-state.ts
|
|
11380
|
-
import { useEffect as useEffect17, useRef as useRef12, useState as
|
|
11555
|
+
import { useEffect as useEffect17, useRef as useRef12, useState as useState14 } from "react";
|
|
11381
11556
|
function useSelectedVariantsState(product, facts) {
|
|
11382
|
-
const [selectedVariants, setSelectedVariants] =
|
|
11557
|
+
const [selectedVariants, setSelectedVariants] = useState14(() => {
|
|
11383
11558
|
const recorded = getOptionSelections(product.id);
|
|
11384
11559
|
return { ...preselectFromFacts(product, facts), ...recorded !== void 0 ? recorded : {} };
|
|
11385
11560
|
});
|
|
@@ -11430,8 +11605,8 @@ function useProductDetail(product) {
|
|
|
11430
11605
|
const session = useFourtySession();
|
|
11431
11606
|
const facts = useFacts();
|
|
11432
11607
|
const optimisticFacts = useOptimisticFactOverlay(PRESENCE_OPTIMISTIC_FACTS_FLOW);
|
|
11433
|
-
const [selectedImage, setSelectedImage] =
|
|
11434
|
-
const [zoomed, setZoomed] =
|
|
11608
|
+
const [selectedImage, setSelectedImage] = useState15(0);
|
|
11609
|
+
const [zoomed, setZoomed] = useState15(false);
|
|
11435
11610
|
const lastProductIdRef = useRef13(product.id);
|
|
11436
11611
|
if (lastProductIdRef.current !== product.id) {
|
|
11437
11612
|
lastProductIdRef.current = product.id;
|
|
@@ -11440,19 +11615,19 @@ function useProductDetail(product) {
|
|
|
11440
11615
|
}
|
|
11441
11616
|
const { selectedVariants, setSelectedVariants, markTouched } = useSelectedVariantsState(product, facts);
|
|
11442
11617
|
const desc = useExpandable(false);
|
|
11443
|
-
const variantGroups =
|
|
11618
|
+
const variantGroups = useMemo16(
|
|
11444
11619
|
() => deriveVariantGroups(product),
|
|
11445
11620
|
[product]
|
|
11446
11621
|
);
|
|
11447
|
-
const allSelected =
|
|
11622
|
+
const allSelected = useMemo16(
|
|
11448
11623
|
() => variantGroups.every((g) => selectedVariants[g.name] !== void 0),
|
|
11449
11624
|
[variantGroups, selectedVariants]
|
|
11450
11625
|
);
|
|
11451
|
-
const missingGroup =
|
|
11626
|
+
const missingGroup = useMemo16(
|
|
11452
11627
|
() => variantGroups.find((g) => selectedVariants[g.name] === void 0),
|
|
11453
11628
|
[variantGroups, selectedVariants]
|
|
11454
11629
|
);
|
|
11455
|
-
const findVariant =
|
|
11630
|
+
const findVariant = useCallback20(
|
|
11456
11631
|
(opts) => matchVariant(product, opts),
|
|
11457
11632
|
[product]
|
|
11458
11633
|
);
|
|
@@ -11463,11 +11638,11 @@ function useProductDetail(product) {
|
|
|
11463
11638
|
const matchIndex = product.images.findIndex((img) => img.url === activeVariantImageUrl);
|
|
11464
11639
|
if (matchIndex >= 0) setSelectedImage(matchIndex);
|
|
11465
11640
|
}
|
|
11466
|
-
const isVariantUnavailable =
|
|
11641
|
+
const isVariantUnavailable = useCallback20(
|
|
11467
11642
|
(group, opt) => isOptionUnavailable(product, selectedVariants, group, opt),
|
|
11468
11643
|
[product, selectedVariants]
|
|
11469
11644
|
);
|
|
11470
|
-
const selectVariant =
|
|
11645
|
+
const selectVariant = useCallback20((group, opt) => {
|
|
11471
11646
|
markTouched();
|
|
11472
11647
|
setSelectedVariants((prev) => ({ ...prev, [group]: opt }));
|
|
11473
11648
|
session.dispatchSignal({
|
|
@@ -11476,7 +11651,7 @@ function useProductDetail(product) {
|
|
|
11476
11651
|
});
|
|
11477
11652
|
optimisticFacts.add({ label: group, value: opt });
|
|
11478
11653
|
}, [session, product.id, markTouched, setSelectedVariants, optimisticFacts]);
|
|
11479
|
-
const addPicked =
|
|
11654
|
+
const addPicked = useCallback20((acknowledgeInDrawer) => {
|
|
11480
11655
|
if (!allSelected) return;
|
|
11481
11656
|
const variant = findVariant(selectedVariants);
|
|
11482
11657
|
if (variant === void 0) {
|
|
@@ -11500,10 +11675,10 @@ function useProductDetail(product) {
|
|
|
11500
11675
|
}
|
|
11501
11676
|
});
|
|
11502
11677
|
}, [allSelected, findVariant, product.id, product.title, product.images, selectedVariants, session]);
|
|
11503
|
-
const onAddToBag =
|
|
11504
|
-
const addForBuyNow =
|
|
11678
|
+
const onAddToBag = useCallback20(() => addPicked(true), [addPicked]);
|
|
11679
|
+
const addForBuyNow = useCallback20(() => addPicked(false), [addPicked]);
|
|
11505
11680
|
const buyNow = useBuyNow(addForBuyNow);
|
|
11506
|
-
const onBuyNow =
|
|
11681
|
+
const onBuyNow = useCallback20(() => {
|
|
11507
11682
|
if (!allSelected) return;
|
|
11508
11683
|
const variant = findVariant(selectedVariants);
|
|
11509
11684
|
if (variant === void 0) {
|
|
@@ -11512,10 +11687,10 @@ function useProductDetail(product) {
|
|
|
11512
11687
|
}
|
|
11513
11688
|
buyNow.start(variant.id);
|
|
11514
11689
|
}, [allSelected, findVariant, selectedVariants, buyNow]);
|
|
11515
|
-
const onAskAgent =
|
|
11690
|
+
const onAskAgent = useCallback20(() => {
|
|
11516
11691
|
session.sendMessage(`Tell me more about the ${product.title}`);
|
|
11517
11692
|
}, [session, product.title]);
|
|
11518
|
-
const onPickSibling =
|
|
11693
|
+
const onPickSibling = useCallback20((sibling) => {
|
|
11519
11694
|
if (sibling.current === true) return;
|
|
11520
11695
|
session.dispatchSuggestionAction({
|
|
11521
11696
|
id: `navigate-product-${sibling.id}`,
|
|
@@ -11530,7 +11705,7 @@ function useProductDetail(product) {
|
|
|
11530
11705
|
payload: { page: { kind: "product", id: sibling.id, morph: true } }
|
|
11531
11706
|
});
|
|
11532
11707
|
}, [session]);
|
|
11533
|
-
const toggleZoom =
|
|
11708
|
+
const toggleZoom = useCallback20(() => setZoomed((p) => !p), []);
|
|
11534
11709
|
return {
|
|
11535
11710
|
selectedImage,
|
|
11536
11711
|
selectImage: setSelectedImage,
|
|
@@ -11557,7 +11732,7 @@ function useProductDetail(product) {
|
|
|
11557
11732
|
}
|
|
11558
11733
|
|
|
11559
11734
|
// src/verticals/commerce/comparison/use-comparison-table.ts
|
|
11560
|
-
import { useCallback as
|
|
11735
|
+
import { useCallback as useCallback21 } from "react";
|
|
11561
11736
|
function classifyComparisonValue(v) {
|
|
11562
11737
|
if (v === void 0) return { kind: "value", value: "" };
|
|
11563
11738
|
if (v === true || v === "true" || v === "Yes") return { kind: "true" };
|
|
@@ -11565,7 +11740,7 @@ function classifyComparisonValue(v) {
|
|
|
11565
11740
|
return { kind: "value", value: v };
|
|
11566
11741
|
}
|
|
11567
11742
|
function useComparisonHighlight(highlightedId) {
|
|
11568
|
-
const isHighlighted =
|
|
11743
|
+
const isHighlighted = useCallback21(
|
|
11569
11744
|
(id) => id === highlightedId,
|
|
11570
11745
|
[highlightedId]
|
|
11571
11746
|
);
|
|
@@ -11573,7 +11748,7 @@ function useComparisonHighlight(highlightedId) {
|
|
|
11573
11748
|
}
|
|
11574
11749
|
|
|
11575
11750
|
// src/verticals/commerce/cart/use-cart-drawer.ts
|
|
11576
|
-
import { useCallback as
|
|
11751
|
+
import { useCallback as useCallback22 } from "react";
|
|
11577
11752
|
|
|
11578
11753
|
// src/verticals/commerce/cart/use-safe-cart.ts
|
|
11579
11754
|
var warnedCart = false;
|
|
@@ -11607,24 +11782,24 @@ function useSafeCart() {
|
|
|
11607
11782
|
}
|
|
11608
11783
|
|
|
11609
11784
|
// src/verticals/commerce/cart/cart-drawer-store.ts
|
|
11610
|
-
import { useSyncExternalStore as
|
|
11785
|
+
import { useSyncExternalStore as useSyncExternalStore11 } from "react";
|
|
11611
11786
|
var isOpen = false;
|
|
11612
11787
|
var focus = null;
|
|
11613
|
-
var
|
|
11614
|
-
function
|
|
11615
|
-
for (const listener of
|
|
11788
|
+
var listeners11 = /* @__PURE__ */ new Set();
|
|
11789
|
+
function notify11() {
|
|
11790
|
+
for (const listener of listeners11) listener();
|
|
11616
11791
|
}
|
|
11617
|
-
function
|
|
11618
|
-
|
|
11792
|
+
function subscribe9(listener) {
|
|
11793
|
+
listeners11.add(listener);
|
|
11619
11794
|
return () => {
|
|
11620
|
-
|
|
11795
|
+
listeners11.delete(listener);
|
|
11621
11796
|
};
|
|
11622
11797
|
}
|
|
11623
11798
|
function openCartDrawer() {
|
|
11624
11799
|
if (isOpen) return;
|
|
11625
11800
|
claimExclusiveOverlay("cart");
|
|
11626
11801
|
isOpen = true;
|
|
11627
|
-
|
|
11802
|
+
notify11();
|
|
11628
11803
|
}
|
|
11629
11804
|
function openCartDrawerFocusedOn(productId) {
|
|
11630
11805
|
if (typeof productId !== "string" || productId.length === 0) {
|
|
@@ -11634,39 +11809,39 @@ function openCartDrawerFocusedOn(productId) {
|
|
|
11634
11809
|
claimExclusiveOverlay("cart");
|
|
11635
11810
|
isOpen = true;
|
|
11636
11811
|
focus = { productId, at: Date.now() };
|
|
11637
|
-
|
|
11812
|
+
notify11();
|
|
11638
11813
|
}
|
|
11639
11814
|
function useCartDrawerFocus() {
|
|
11640
|
-
return
|
|
11815
|
+
return useSyncExternalStore11(subscribe9, () => focus, () => null);
|
|
11641
11816
|
}
|
|
11642
11817
|
function closeCartDrawer() {
|
|
11643
11818
|
if (!isOpen) return;
|
|
11644
11819
|
isOpen = false;
|
|
11645
|
-
|
|
11820
|
+
notify11();
|
|
11646
11821
|
}
|
|
11647
11822
|
function toggleCartDrawer() {
|
|
11648
11823
|
if (!isOpen) claimExclusiveOverlay("cart");
|
|
11649
11824
|
isOpen = !isOpen;
|
|
11650
|
-
|
|
11825
|
+
notify11();
|
|
11651
11826
|
}
|
|
11652
11827
|
function useCartDrawerOpen() {
|
|
11653
|
-
return
|
|
11828
|
+
return useSyncExternalStore11(subscribe9, () => isOpen, () => false);
|
|
11654
11829
|
}
|
|
11655
11830
|
registerExclusiveOverlay("cart", closeCartDrawer);
|
|
11656
11831
|
registerSessionScopedClear(() => {
|
|
11657
11832
|
if (!isOpen && focus === null) return;
|
|
11658
11833
|
isOpen = false;
|
|
11659
11834
|
focus = null;
|
|
11660
|
-
|
|
11835
|
+
notify11();
|
|
11661
11836
|
});
|
|
11662
11837
|
|
|
11663
11838
|
// src/verticals/commerce/cart/use-cart-drawer.ts
|
|
11664
11839
|
function useCartDrawer() {
|
|
11665
11840
|
const cart = useSafeCart();
|
|
11666
11841
|
const isOpen2 = useCartDrawerOpen();
|
|
11667
|
-
const open =
|
|
11668
|
-
const close =
|
|
11669
|
-
const toggle =
|
|
11842
|
+
const open = useCallback22(() => openCartDrawer(), []);
|
|
11843
|
+
const close = useCallback22(() => closeCartDrawer(), []);
|
|
11844
|
+
const toggle = useCallback22(() => toggleCartDrawer(), []);
|
|
11670
11845
|
return {
|
|
11671
11846
|
isOpen: isOpen2,
|
|
11672
11847
|
open,
|
|
@@ -11683,14 +11858,14 @@ function useCartDrawer() {
|
|
|
11683
11858
|
}
|
|
11684
11859
|
|
|
11685
11860
|
// src/verticals/commerce/cart/use-cart-view.ts
|
|
11686
|
-
import
|
|
11861
|
+
import React43 from "react";
|
|
11687
11862
|
|
|
11688
11863
|
// src/verticals/commerce/cart/queued-discount-codes.ts
|
|
11689
|
-
import { useSyncExternalStore as
|
|
11864
|
+
import { useSyncExternalStore as useSyncExternalStore12 } from "react";
|
|
11690
11865
|
var queued = [];
|
|
11691
|
-
var
|
|
11692
|
-
function
|
|
11693
|
-
for (const listener of
|
|
11866
|
+
var listeners12 = /* @__PURE__ */ new Set();
|
|
11867
|
+
function notify12() {
|
|
11868
|
+
for (const listener of listeners12) listener();
|
|
11694
11869
|
}
|
|
11695
11870
|
function withQueuedDiscountCodes(cartCodes, held) {
|
|
11696
11871
|
const extra = held.filter((h) => !cartCodes.some((c) => sameCode(c.code, h)));
|
|
@@ -11703,7 +11878,7 @@ function dequeueDiscountCode(code) {
|
|
|
11703
11878
|
const kept = queued.filter((c) => !sameCode(c, code));
|
|
11704
11879
|
if (kept.length === queued.length) return;
|
|
11705
11880
|
queued = kept;
|
|
11706
|
-
|
|
11881
|
+
notify12();
|
|
11707
11882
|
}
|
|
11708
11883
|
function sameCode(a, b) {
|
|
11709
11884
|
return a.toUpperCase() === b.toUpperCase();
|
|
@@ -11711,38 +11886,38 @@ function sameCode(a, b) {
|
|
|
11711
11886
|
function queueDiscountCode(code) {
|
|
11712
11887
|
if (queued.some((c) => sameCode(c, code))) return;
|
|
11713
11888
|
queued = [...queued, code];
|
|
11714
|
-
|
|
11889
|
+
notify12();
|
|
11715
11890
|
}
|
|
11716
11891
|
function takeQueuedDiscountCodes() {
|
|
11717
11892
|
const taken = queued;
|
|
11718
11893
|
if (taken.length === 0) return taken;
|
|
11719
11894
|
queued = [];
|
|
11720
|
-
|
|
11895
|
+
notify12();
|
|
11721
11896
|
return taken;
|
|
11722
11897
|
}
|
|
11723
11898
|
function readQueuedDiscountCodes() {
|
|
11724
11899
|
return queued;
|
|
11725
11900
|
}
|
|
11726
|
-
function
|
|
11727
|
-
|
|
11901
|
+
function subscribe10(listener) {
|
|
11902
|
+
listeners12.add(listener);
|
|
11728
11903
|
return () => {
|
|
11729
|
-
|
|
11904
|
+
listeners12.delete(listener);
|
|
11730
11905
|
};
|
|
11731
11906
|
}
|
|
11732
11907
|
var NONE = [];
|
|
11733
11908
|
function useQueuedDiscountCodes() {
|
|
11734
|
-
return
|
|
11909
|
+
return useSyncExternalStore12(subscribe10, readQueuedDiscountCodes, () => NONE);
|
|
11735
11910
|
}
|
|
11736
11911
|
registerSessionScopedClear(() => {
|
|
11737
11912
|
if (queued.length === 0) return;
|
|
11738
11913
|
queued = [];
|
|
11739
|
-
|
|
11914
|
+
notify12();
|
|
11740
11915
|
});
|
|
11741
11916
|
|
|
11742
11917
|
// src/verticals/commerce/cart/use-cart-view.ts
|
|
11743
11918
|
function useCartView(cart, onCheckout) {
|
|
11744
11919
|
const analytics = useOptionalAnalyticsSink();
|
|
11745
|
-
const [exitPending, setExitPending] =
|
|
11920
|
+
const [exitPending, setExitPending] = React43.useState(null);
|
|
11746
11921
|
const lines = cart === null ? [] : cart.lines;
|
|
11747
11922
|
const count = lines.reduce((sum, l) => sum + l.quantity, 0);
|
|
11748
11923
|
const totalsPending = lines.some((l) => isPendingCartLine(l));
|
|
@@ -11753,7 +11928,7 @@ function useCartView(cart, onCheckout) {
|
|
|
11753
11928
|
const backendTotal = cart !== null && cart.total !== void 0 ? cart.total.amount : void 0;
|
|
11754
11929
|
const discountAmount = backendTotal !== void 0 && backendTotal < subtotal ? subtotal - backendTotal : 0;
|
|
11755
11930
|
const effectiveTotal = backendTotal !== void 0 ? backendTotal : subtotal;
|
|
11756
|
-
const navigateToExit =
|
|
11931
|
+
const navigateToExit = React43.useCallback((url, kind) => {
|
|
11757
11932
|
const result = navigateToExternalCommerceUrl(url);
|
|
11758
11933
|
if (kind === "checkout") recordVisitorCheckoutExit(analytics, result);
|
|
11759
11934
|
if (result === "new-tab") {
|
|
@@ -11770,7 +11945,7 @@ function useCartView(cart, onCheckout) {
|
|
|
11770
11945
|
setExitPending(null);
|
|
11771
11946
|
}
|
|
11772
11947
|
}, [analytics]);
|
|
11773
|
-
const handleCheckout =
|
|
11948
|
+
const handleCheckout = React43.useCallback(() => {
|
|
11774
11949
|
if (lines.length === 0 || exitPending !== null) return;
|
|
11775
11950
|
setExitPending("checkout");
|
|
11776
11951
|
if (onCheckout) {
|
|
@@ -11790,7 +11965,7 @@ function useCartView(cart, onCheckout) {
|
|
|
11790
11965
|
}
|
|
11791
11966
|
navigateToExit(cart?.checkoutUrl, "checkout");
|
|
11792
11967
|
}, [lines.length, exitPending, onCheckout, cart, navigateToExit]);
|
|
11793
|
-
const handleGoToStore =
|
|
11968
|
+
const handleGoToStore = React43.useCallback(() => {
|
|
11794
11969
|
if (lines.length === 0 || exitPending !== null) return;
|
|
11795
11970
|
setExitPending("store");
|
|
11796
11971
|
navigateToExit(cart?.storeCartUrl, "store");
|
|
@@ -11814,13 +11989,13 @@ function useCartView(cart, onCheckout) {
|
|
|
11814
11989
|
}
|
|
11815
11990
|
|
|
11816
11991
|
// src/verticals/commerce/cart/cart-action-failures.ts
|
|
11817
|
-
import { useMemo as
|
|
11992
|
+
import { useMemo as useMemo17, useSyncExternalStore as useSyncExternalStore13 } from "react";
|
|
11818
11993
|
var FAILURE_TTL_MS = 2 * 6e4;
|
|
11819
11994
|
var FAILURE_CAP = 5;
|
|
11820
11995
|
var failures = [];
|
|
11821
|
-
var
|
|
11822
|
-
function
|
|
11823
|
-
for (const listener of
|
|
11996
|
+
var listeners13 = /* @__PURE__ */ new Set();
|
|
11997
|
+
function notify13() {
|
|
11998
|
+
for (const listener of listeners13) listener();
|
|
11824
11999
|
}
|
|
11825
12000
|
function pruneExpired(now) {
|
|
11826
12001
|
const kept = failures.filter((f) => now - f.at <= FAILURE_TTL_MS);
|
|
@@ -11838,13 +12013,13 @@ function recordCartActionFailure(action, subject, reason) {
|
|
|
11838
12013
|
pruneExpired(now);
|
|
11839
12014
|
const rest = failures.filter((f) => !(f.action === action && sameSubject(f, subject)));
|
|
11840
12015
|
failures = [...rest, { action, productId: subject.productId, code: subject.code, reason, at: now }].slice(-FAILURE_CAP);
|
|
11841
|
-
|
|
12016
|
+
notify13();
|
|
11842
12017
|
}
|
|
11843
12018
|
function clearCartActionFailures(subject) {
|
|
11844
12019
|
const kept = failures.filter((f) => !sameSubject(f, subject));
|
|
11845
12020
|
if (kept.length === failures.length) return;
|
|
11846
12021
|
failures = kept;
|
|
11847
|
-
|
|
12022
|
+
notify13();
|
|
11848
12023
|
}
|
|
11849
12024
|
function snapshot() {
|
|
11850
12025
|
return failures;
|
|
@@ -11853,20 +12028,20 @@ function readCartActionFailures() {
|
|
|
11853
12028
|
pruneExpired(Date.now());
|
|
11854
12029
|
return failures;
|
|
11855
12030
|
}
|
|
11856
|
-
function
|
|
11857
|
-
|
|
12031
|
+
function subscribe11(listener) {
|
|
12032
|
+
listeners13.add(listener);
|
|
11858
12033
|
return () => {
|
|
11859
|
-
|
|
12034
|
+
listeners13.delete(listener);
|
|
11860
12035
|
};
|
|
11861
12036
|
}
|
|
11862
12037
|
var NO_FAILURES = [];
|
|
11863
12038
|
function useCartActionFailures() {
|
|
11864
|
-
return
|
|
12039
|
+
return useSyncExternalStore13(subscribe11, snapshot, () => NO_FAILURES);
|
|
11865
12040
|
}
|
|
11866
12041
|
function useCartActionFailuresFor(productIdsInCart) {
|
|
11867
12042
|
const all = useCartActionFailures();
|
|
11868
12043
|
const key = productIdsInCart.join("\0");
|
|
11869
|
-
return
|
|
12044
|
+
return useMemo17(() => {
|
|
11870
12045
|
const present = new Set(key.length === 0 ? [] : key.split("\0"));
|
|
11871
12046
|
return all.filter((f) => f.productId !== void 0 && !present.has(f.productId));
|
|
11872
12047
|
}, [all, key]);
|
|
@@ -11874,24 +12049,24 @@ function useCartActionFailuresFor(productIdsInCart) {
|
|
|
11874
12049
|
registerSessionScopedClear(() => {
|
|
11875
12050
|
if (failures.length === 0) return;
|
|
11876
12051
|
failures = [];
|
|
11877
|
-
|
|
12052
|
+
notify13();
|
|
11878
12053
|
});
|
|
11879
12054
|
|
|
11880
12055
|
// src/verticals/commerce/cart/use-cart-line-row.ts
|
|
11881
|
-
import * as
|
|
12056
|
+
import * as React44 from "react";
|
|
11882
12057
|
|
|
11883
12058
|
// src/verticals/commerce/use-commerce-actions.ts
|
|
11884
|
-
import { useCallback as
|
|
12059
|
+
import { useCallback as useCallback23 } from "react";
|
|
11885
12060
|
function useCommerceActions() {
|
|
11886
12061
|
const canvas = useCanvasActions();
|
|
11887
|
-
const navigateToProduct =
|
|
12062
|
+
const navigateToProduct = useCallback23(
|
|
11888
12063
|
(productId, title) => {
|
|
11889
12064
|
if (!canvas) return;
|
|
11890
12065
|
canvas.navigate({ kind: "product", id: productId }, title);
|
|
11891
12066
|
},
|
|
11892
12067
|
[canvas]
|
|
11893
12068
|
);
|
|
11894
|
-
const showCollection =
|
|
12069
|
+
const showCollection = useCallback23(
|
|
11895
12070
|
(collectionTitle) => {
|
|
11896
12071
|
if (!canvas) return;
|
|
11897
12072
|
canvas.dispatchAction({
|
|
@@ -11903,7 +12078,7 @@ function useCommerceActions() {
|
|
|
11903
12078
|
},
|
|
11904
12079
|
[canvas]
|
|
11905
12080
|
);
|
|
11906
|
-
const navigateToProductSet =
|
|
12081
|
+
const navigateToProductSet = useCallback23(
|
|
11907
12082
|
(handle, title, productIds) => {
|
|
11908
12083
|
if (!canvas) return;
|
|
11909
12084
|
canvas.dispatchAction({
|
|
@@ -11924,19 +12099,19 @@ var SPOTLIGHT_MAX_AGE_MS = 3e4;
|
|
|
11924
12099
|
function useCartLineRow(line, opts) {
|
|
11925
12100
|
const actions = useCommerceActions();
|
|
11926
12101
|
const drawerFocus = useCartDrawerFocus();
|
|
11927
|
-
const rowRef =
|
|
12102
|
+
const rowRef = React44.useRef(null);
|
|
11928
12103
|
const pending2 = isPendingCartLine(line);
|
|
11929
12104
|
const navigable = actions !== null && !pending2 && line.productId.length > 0;
|
|
11930
12105
|
const onNavigated = opts === void 0 ? void 0 : opts.onNavigated;
|
|
11931
|
-
const navigatedRef =
|
|
12106
|
+
const navigatedRef = React44.useRef(onNavigated);
|
|
11932
12107
|
navigatedRef.current = onNavigated;
|
|
11933
|
-
const navigate =
|
|
12108
|
+
const navigate = React44.useCallback(() => {
|
|
11934
12109
|
if (actions === null) return;
|
|
11935
12110
|
actions.navigateToProduct(line.productId, line.title);
|
|
11936
12111
|
const done = navigatedRef.current;
|
|
11937
12112
|
if (done !== void 0) done();
|
|
11938
12113
|
}, [actions, line.productId, line.title]);
|
|
11939
|
-
const interaction =
|
|
12114
|
+
const interaction = React44.useMemo(() => {
|
|
11940
12115
|
if (!navigable) return void 0;
|
|
11941
12116
|
return {
|
|
11942
12117
|
onClick: navigate,
|
|
@@ -11951,7 +12126,7 @@ function useCartLineRow(line, opts) {
|
|
|
11951
12126
|
};
|
|
11952
12127
|
}, [navigable, navigate]);
|
|
11953
12128
|
const spotlightKey = drawerFocus !== null && !pending2 && line.productId.length > 0 && drawerFocus.productId === line.productId && Date.now() - drawerFocus.at < SPOTLIGHT_MAX_AGE_MS ? drawerFocus.at : null;
|
|
11954
|
-
|
|
12129
|
+
React44.useEffect(() => {
|
|
11955
12130
|
if (spotlightKey === null) return;
|
|
11956
12131
|
const node = rowRef.current;
|
|
11957
12132
|
if (node === null) return;
|
|
@@ -11961,7 +12136,7 @@ function useCartLineRow(line, opts) {
|
|
|
11961
12136
|
}
|
|
11962
12137
|
|
|
11963
12138
|
// src/verticals/commerce/wishlist/use-wishlist-drawer.ts
|
|
11964
|
-
import { useCallback as
|
|
12139
|
+
import { useCallback as useCallback25, useState as useState16 } from "react";
|
|
11965
12140
|
var warnedDegraded = false;
|
|
11966
12141
|
function useSafeWishlist() {
|
|
11967
12142
|
try {
|
|
@@ -11984,12 +12159,12 @@ function useSafeWishlist() {
|
|
|
11984
12159
|
}
|
|
11985
12160
|
function useWishlistDrawer() {
|
|
11986
12161
|
const wishlist = useSafeWishlist();
|
|
11987
|
-
const [isOpen2, setIsOpen] =
|
|
11988
|
-
const open =
|
|
11989
|
-
const close =
|
|
11990
|
-
const toggle =
|
|
12162
|
+
const [isOpen2, setIsOpen] = useState16(false);
|
|
12163
|
+
const open = useCallback25(() => setIsOpen(true), []);
|
|
12164
|
+
const close = useCallback25(() => setIsOpen(false), []);
|
|
12165
|
+
const toggle = useCallback25(() => setIsOpen((p) => !p), []);
|
|
11991
12166
|
useExclusiveOverlay("wishlist", isOpen2, close);
|
|
11992
|
-
const removeLine =
|
|
12167
|
+
const removeLine = useCallback25(
|
|
11993
12168
|
(productId) => {
|
|
11994
12169
|
if (wishlist === null) {
|
|
11995
12170
|
console.warn("[useWishlistDrawer] removeLine called with no commerce provider");
|
|
@@ -12013,9 +12188,9 @@ function useWishlistDrawer() {
|
|
|
12013
12188
|
}
|
|
12014
12189
|
|
|
12015
12190
|
// src/shared/use-image-hover.ts
|
|
12016
|
-
import { useState as
|
|
12191
|
+
import { useState as useState17 } from "react";
|
|
12017
12192
|
function useImageHover() {
|
|
12018
|
-
const [hover, setHover] =
|
|
12193
|
+
const [hover, setHover] = useState17(false);
|
|
12019
12194
|
return {
|
|
12020
12195
|
hover,
|
|
12021
12196
|
hoverProps: {
|
|
@@ -12096,7 +12271,7 @@ function pickColorCount(product) {
|
|
|
12096
12271
|
}
|
|
12097
12272
|
|
|
12098
12273
|
// src/verticals/commerce/product/use-look-card.ts
|
|
12099
|
-
import * as
|
|
12274
|
+
import * as React45 from "react";
|
|
12100
12275
|
|
|
12101
12276
|
// src/verticals/commerce/variant/variant-option-axes.ts
|
|
12102
12277
|
function carriesValue(variant, name, value) {
|
|
@@ -12306,8 +12481,8 @@ function useLookCard({
|
|
|
12306
12481
|
const session = useFourtySession();
|
|
12307
12482
|
const addFlash = useSuccessFlash({ duration: 1200 });
|
|
12308
12483
|
const locale = useSpaceLocale();
|
|
12309
|
-
const [pending2, setPending] =
|
|
12310
|
-
const clean =
|
|
12484
|
+
const [pending2, setPending] = React45.useState(null);
|
|
12485
|
+
const clean = React45.useMemo(
|
|
12311
12486
|
() => (Array.isArray(products) ? products : []).filter(
|
|
12312
12487
|
(p) => p !== null && p !== void 0 && typeof p === "object"
|
|
12313
12488
|
),
|
|
@@ -12632,17 +12807,17 @@ function resolveSwatchColor(name) {
|
|
|
12632
12807
|
}
|
|
12633
12808
|
|
|
12634
12809
|
// src/verticals/content/use-content-actions.ts
|
|
12635
|
-
import { useCallback as
|
|
12810
|
+
import { useCallback as useCallback26 } from "react";
|
|
12636
12811
|
function useContentActions() {
|
|
12637
12812
|
const canvas = useCanvasActions();
|
|
12638
|
-
const navigateToArticle =
|
|
12813
|
+
const navigateToArticle = useCallback26(
|
|
12639
12814
|
(articleId, title) => {
|
|
12640
12815
|
if (!canvas) return;
|
|
12641
12816
|
canvas.navigate({ kind: "article", id: articleId }, title);
|
|
12642
12817
|
},
|
|
12643
12818
|
[canvas]
|
|
12644
12819
|
);
|
|
12645
|
-
const subscribeNewsletter =
|
|
12820
|
+
const subscribeNewsletter = useCallback26(
|
|
12646
12821
|
(email, buttonLabel) => {
|
|
12647
12822
|
if (!canvas) return;
|
|
12648
12823
|
canvas.dispatchAction({
|
|
@@ -12659,10 +12834,10 @@ function useContentActions() {
|
|
|
12659
12834
|
}
|
|
12660
12835
|
|
|
12661
12836
|
// src/host/Spacefront.tsx
|
|
12662
|
-
import { useEffect as useEffect19, useState as
|
|
12837
|
+
import { useEffect as useEffect19, useState as useState19 } from "react";
|
|
12663
12838
|
|
|
12664
12839
|
// package.json
|
|
12665
|
-
var version = "0.5.
|
|
12840
|
+
var version = "0.5.13";
|
|
12666
12841
|
|
|
12667
12842
|
// src/host/host-modules.ts
|
|
12668
12843
|
import * as react from "react";
|
|
@@ -12723,10 +12898,10 @@ function loadEngine(apiUrl) {
|
|
|
12723
12898
|
}
|
|
12724
12899
|
|
|
12725
12900
|
// src/host/Spacefront.tsx
|
|
12726
|
-
import { jsx as
|
|
12901
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
12727
12902
|
function Spacefront(props) {
|
|
12728
|
-
const [engine, setEngine] =
|
|
12729
|
-
const [failure, setFailure] =
|
|
12903
|
+
const [engine, setEngine] = useState19(null);
|
|
12904
|
+
const [failure, setFailure] = useState19(null);
|
|
12730
12905
|
useEffect19(() => {
|
|
12731
12906
|
let live = true;
|
|
12732
12907
|
loadEngine(props.apiUrl).then(
|
|
@@ -12745,7 +12920,7 @@ function Spacefront(props) {
|
|
|
12745
12920
|
if (failure !== null) throw failure;
|
|
12746
12921
|
if (engine === null) return null;
|
|
12747
12922
|
const EngineRoot = engine.EngineRoot;
|
|
12748
|
-
return /* @__PURE__ */
|
|
12923
|
+
return /* @__PURE__ */ jsx25(EngineRoot, { ...props });
|
|
12749
12924
|
}
|
|
12750
12925
|
|
|
12751
12926
|
// src/npm.ts
|
|
@@ -12812,6 +12987,7 @@ export {
|
|
|
12812
12987
|
CHECKOUT_OUTCOMES,
|
|
12813
12988
|
CHECKOUT_REACHED_OUTCOMES,
|
|
12814
12989
|
CHECKOUT_REFUSALS,
|
|
12990
|
+
CHIP_SHOW_SIGNAL,
|
|
12815
12991
|
CLICK_ID_KINDS,
|
|
12816
12992
|
CLIENT_STATE_HELLO_SIGNAL,
|
|
12817
12993
|
COMPONENT_SOURCE,
|
|
@@ -12821,6 +12997,8 @@ export {
|
|
|
12821
12997
|
CONTINUATION_ENABLED,
|
|
12822
12998
|
CUSTOMER_ACCOUNT_SESSION_HEADER,
|
|
12823
12999
|
CanvasArrangementProvider,
|
|
13000
|
+
CanvasLeadProvider,
|
|
13001
|
+
CanvasLeadSlot,
|
|
12824
13002
|
CanvasMotionStyleProvider,
|
|
12825
13003
|
CanvasOutletProvider,
|
|
12826
13004
|
CanvasTailMount,
|
|
@@ -13082,6 +13260,7 @@ export {
|
|
|
13082
13260
|
catalogToWire,
|
|
13083
13261
|
changeAnchorWithin,
|
|
13084
13262
|
checkoutHandoffReasonFor,
|
|
13263
|
+
chipsFromShowSignal,
|
|
13085
13264
|
claimExclusiveOverlay,
|
|
13086
13265
|
classifyComparisonValue,
|
|
13087
13266
|
classifyItemChange,
|
|
@@ -13157,6 +13336,8 @@ export {
|
|
|
13157
13336
|
hostPlace,
|
|
13158
13337
|
hostingAllows,
|
|
13159
13338
|
injectGoogleFonts,
|
|
13339
|
+
installmentOffer,
|
|
13340
|
+
installmentPayment,
|
|
13160
13341
|
isActiveDirective,
|
|
13161
13342
|
isAllowedAttachmentType,
|
|
13162
13343
|
isDegenerateLayout,
|
|
@@ -13308,6 +13489,7 @@ export {
|
|
|
13308
13489
|
surfaceEmits,
|
|
13309
13490
|
surfaceSuppressionReason,
|
|
13310
13491
|
takeQueuedDiscountCodes,
|
|
13492
|
+
takeSubmitOrigin,
|
|
13311
13493
|
text,
|
|
13312
13494
|
textDirectionOf,
|
|
13313
13495
|
threadRowAttrs,
|
|
@@ -13334,6 +13516,8 @@ export {
|
|
|
13334
13516
|
useCanvasArrangement,
|
|
13335
13517
|
useCanvasBack,
|
|
13336
13518
|
useCanvasForward,
|
|
13519
|
+
useCanvasLead,
|
|
13520
|
+
useCanvasLeadTarget,
|
|
13337
13521
|
useCanvasMotionStyle,
|
|
13338
13522
|
useCanvasTail,
|
|
13339
13523
|
useCanvasViewBack,
|
|
@@ -13395,6 +13579,7 @@ export {
|
|
|
13395
13579
|
useHydrationState,
|
|
13396
13580
|
useHydrators,
|
|
13397
13581
|
useInlineCompletion,
|
|
13582
|
+
useInstallmentOffer,
|
|
13398
13583
|
useInteraction,
|
|
13399
13584
|
useInteraction2 as useInteractionTracking,
|
|
13400
13585
|
useInterval,
|
|
@@ -13469,6 +13654,7 @@ export {
|
|
|
13469
13654
|
useVisibleFactList,
|
|
13470
13655
|
useVisitorName,
|
|
13471
13656
|
useVoiceCapture,
|
|
13657
|
+
useWaitingSubmitOrigin,
|
|
13472
13658
|
useWakeLock,
|
|
13473
13659
|
useWishlist,
|
|
13474
13660
|
useWishlistDrawer,
|
|
@@ -13482,5 +13668,6 @@ export {
|
|
|
13482
13668
|
withInteractionTracking,
|
|
13483
13669
|
withQueuedDiscountCodes,
|
|
13484
13670
|
withSignalTurn,
|
|
13671
|
+
withoutClosingQuestion,
|
|
13485
13672
|
z52 as z
|
|
13486
13673
|
};
|