@40rty/ams-ui 0.1.0
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/agent.js +148 -0
- package/dist/catalog-data.js +93 -0
- package/dist/catalog-entries.js +8 -0
- package/dist/chunk-432XYPDT.js +1012 -0
- package/dist/chunk-54QPRWEG.js +2800 -0
- package/dist/chunk-CKGGECAQ.js +239 -0
- package/dist/chunk-E3IJDSKY.js +173 -0
- package/dist/chunk-JQNZ5UUK.js +226 -0
- package/dist/chunk-LQLOG2V3.js +649 -0
- package/dist/chunk-MHUEIBJ3.js +117 -0
- package/dist/chunk-ORIOBWTD.js +112 -0
- package/dist/css/preset/motion.css +78 -0
- package/dist/css/preset/tailwind-theme.css +163 -0
- package/dist/css/shell/mobile/island.css +478 -0
- package/dist/hooks.js +25 -0
- package/dist/index.js +7165 -0
- package/dist/motion.js +113 -0
- package/dist/shell.js +5621 -0
- package/dist/types/agent/AgentStreamingState.d.ts +58 -0
- package/dist/types/agent/ProseSurface.d.ts +31 -0
- package/dist/types/agent/index.d.ts +8 -0
- package/dist/types/agent/phase-label.d.ts +13 -0
- package/dist/types/agent/presence/AgentPresenceWidget.d.ts +85 -0
- package/dist/types/agent/presence/BriefIdentity.d.ts +9 -0
- package/dist/types/agent/presence/CompactRead.d.ts +44 -0
- package/dist/types/agent/presence/CriteriaRail.d.ts +68 -0
- package/dist/types/agent/presence/DefaultNotch.d.ts +2 -0
- package/dist/types/agent/presence/FactChip.d.ts +10 -0
- package/dist/types/agent/presence/InlinePresenceRead.d.ts +25 -0
- package/dist/types/agent/presence/KnowledgePeek.d.ts +23 -0
- package/dist/types/agent/presence/LayoutMorphSkeleton.d.ts +59 -0
- package/dist/types/agent/presence/PresenceBrief.d.ts +29 -0
- package/dist/types/agent/presence/PresenceFiller.d.ts +24 -0
- package/dist/types/agent/presence/SourceSift.d.ts +48 -0
- package/dist/types/agent/presence/StreamRead.d.ts +50 -0
- package/dist/types/agent/presence/VoiceLine.d.ts +19 -0
- package/dist/types/agent/presence/band-beat.d.ts +40 -0
- package/dist/types/agent/presence/band-row.d.ts +188 -0
- package/dist/types/agent/presence/cite-image.d.ts +9 -0
- package/dist/types/agent/presence/class-names.d.ts +134 -0
- package/dist/types/agent/presence/element-view.d.ts +83 -0
- package/dist/types/agent/presence/fact-forms/baseline-forms.d.ts +20 -0
- package/dist/types/agent/presence/fact-forms/class-names.d.ts +14 -0
- package/dist/types/agent/presence/fact-forms/index.d.ts +3 -0
- package/dist/types/agent/presence/fact-forms/register.d.ts +9 -0
- package/dist/types/agent/presence/fact-rail.d.ts +76 -0
- package/dist/types/agent/presence/fact-slots.d.ts +97 -0
- package/dist/types/agent/presence/folded.d.ts +26 -0
- package/dist/types/agent/presence/forms.d.ts +5 -0
- package/dist/types/agent/presence/index.d.ts +39 -0
- package/dist/types/agent/presence/notch/PresenceNotch.d.ts +20 -0
- package/dist/types/agent/presence/parts.d.ts +29 -0
- package/dist/types/agent/presence/read-data.d.ts +48 -0
- package/dist/types/agent/presence/reads.d.ts +37 -0
- package/dist/types/agent/presence/sift-deck.d.ts +58 -0
- package/dist/types/agent/presence/source-cards/ArticleSourceCard.d.ts +4 -0
- package/dist/types/agent/presence/source-cards/CollectionSourceCard.d.ts +4 -0
- package/dist/types/agent/presence/source-cards/PolicySourceCard.d.ts +4 -0
- package/dist/types/agent/presence/source-cards/ProductSourceCard.d.ts +4 -0
- package/dist/types/agent/presence/source-cards/ReviewSourceCard.d.ts +4 -0
- package/dist/types/agent/presence/source-cards/SourceCard.d.ts +4 -0
- package/dist/types/agent/presence/source-cards/card-frame.d.ts +38 -0
- package/dist/types/agent/presence/source-cards/card-marks.d.ts +69 -0
- package/dist/types/agent/presence/source-cards/card-plate.d.ts +20 -0
- package/dist/types/agent/presence/source-cards/card-shell.d.ts +91 -0
- package/dist/types/agent/presence/source-cards/register.d.ts +6 -0
- package/dist/types/agent/presence/source-cards/review-passage.d.ts +53 -0
- package/dist/types/agent/presence/swatch.d.ts +4 -0
- package/dist/types/agent/presence/use-band-facts.d.ts +9 -0
- package/dist/types/agent/presence/use-forget-fact.d.ts +56 -0
- package/dist/types/agent/presence/use-measured-height.d.ts +11 -0
- package/dist/types/catalog-data/base.d.ts +2 -0
- package/dist/types/catalog-data/chat.d.ts +55 -0
- package/dist/types/catalog-data/content.d.ts +1129 -0
- package/dist/types/catalog-data/ecommerce.d.ts +4842 -0
- package/dist/types/catalog-data/index.d.ts +7 -0
- package/dist/types/catalog-data/social.d.ts +1552 -0
- package/dist/types/catalog-data/tokens.d.ts +20 -0
- package/dist/types/catalog-data/ugc.d.ts +50 -0
- package/dist/types/catalog-entries.d.ts +35 -0
- package/dist/types/catalog.d.ts +18 -0
- package/dist/types/components/SkeletonSwap.d.ts +27 -0
- package/dist/types/components/agentic/AgentText.d.ts +44 -0
- package/dist/types/components/agentic/Turn.d.ts +21 -0
- package/dist/types/components/browse/CanvasBootLoader.d.ts +16 -0
- package/dist/types/components/browse/ContinuationLoading.d.ts +22 -0
- package/dist/types/components/browse/canvas-booting.d.ts +37 -0
- package/dist/types/components/browse/constants.d.ts +2 -0
- package/dist/types/components/browse/index.d.ts +4 -0
- package/dist/types/components/chat/SuggestionCards.d.ts +2 -0
- package/dist/types/components/chat/index.d.ts +1 -0
- package/dist/types/components/content/FAQ.d.ts +12 -0
- package/dist/types/components/content/FeatureGrid.d.ts +11 -0
- package/dist/types/components/content/InfoCards.d.ts +16 -0
- package/dist/types/components/content/Reviews.d.ts +9 -0
- package/dist/types/components/content/RichText.d.ts +10 -0
- package/dist/types/components/content/article/ArticleDetail.d.ts +15 -0
- package/dist/types/components/content/article/BlogCard.d.ts +11 -0
- package/dist/types/components/content/article/BlogPosts.d.ts +19 -0
- package/dist/types/components/content/page/PageDetail.d.ts +13 -0
- package/dist/types/components/content/page/PolicyDetail.d.ts +23 -0
- package/dist/types/components/ecommerce/cart/AddToCartButton.d.ts +9 -0
- package/dist/types/components/ecommerce/cart/CartContent.d.ts +40 -0
- package/dist/types/components/ecommerce/cart/CartDrawer.d.ts +41 -0
- package/dist/types/components/ecommerce/cart/CartFoot.d.ts +30 -0
- package/dist/types/components/ecommerce/cart/CartLineItem.d.ts +13 -0
- package/dist/types/components/ecommerce/cart/CartLineRow.d.ts +17 -0
- package/dist/types/components/ecommerce/cart/CartPromoCode.d.ts +29 -0
- package/dist/types/components/ecommerce/cart/CartSummary.d.ts +7 -0
- package/dist/types/components/ecommerce/cart/CartWidget.d.ts +10 -0
- package/dist/types/components/ecommerce/cart/VariantPickerModal.d.ts +12 -0
- package/dist/types/components/ecommerce/cart/cart-format.d.ts +8 -0
- package/dist/types/components/ecommerce/cart/use-cart-view.d.ts +50 -0
- package/dist/types/components/ecommerce/collection/CollectionCard.d.ts +10 -0
- package/dist/types/components/ecommerce/collection/CollectionGrid.d.ts +8 -0
- package/dist/types/components/ecommerce/collection/CollectionList.d.ts +13 -0
- package/dist/types/components/ecommerce/collection/internal/CollectionListItem.d.ts +13 -0
- package/dist/types/components/ecommerce/product/AddToRegistry.d.ts +36 -0
- package/dist/types/components/ecommerce/product/ComparisonTable.d.ts +25 -0
- package/dist/types/components/ecommerce/product/ComparisonTableSkeleton.d.ts +11 -0
- package/dist/types/components/ecommerce/product/PresenceProductRail.d.ts +35 -0
- package/dist/types/components/ecommerce/product/ProductBadge.d.ts +9 -0
- package/dist/types/components/ecommerce/product/ProductCard.d.ts +27 -0
- package/dist/types/components/ecommerce/product/ProductDetail.d.ts +25 -0
- package/dist/types/components/ecommerce/product/ProductGallery.d.ts +19 -0
- package/dist/types/components/ecommerce/product/ProductGrid.d.ts +26 -0
- package/dist/types/components/ecommerce/product/ProductImage.d.ts +54 -0
- package/dist/types/components/ecommerce/product/ProductOption.d.ts +9 -0
- package/dist/types/components/ecommerce/product/ProductPrice.d.ts +8 -0
- package/dist/types/components/ecommerce/product/ProductVideoPlayer.d.ts +17 -0
- package/dist/types/components/ecommerce/product/comparison-table-parts.d.ts +41 -0
- package/dist/types/components/ecommerce/product/comparison-table-rows.d.ts +24 -0
- package/dist/types/components/ecommerce/product/image-trim.d.ts +35 -0
- package/dist/types/components/ecommerce/product/product-card-glyphs.d.ts +2 -0
- package/dist/types/components/ecommerce/product/registry-logos.d.ts +2 -0
- package/dist/types/components/ecommerce/product/trim-geometry.d.ts +45 -0
- package/dist/types/components/ecommerce/wishlist/WishlistDrawer.d.ts +16 -0
- package/dist/types/components/feedback/Skeleton.d.ts +13 -0
- package/dist/types/components/feedback/Thinking.d.ts +15 -0
- package/dist/types/components/layout/AspectRatio.d.ts +5 -0
- package/dist/types/components/layout/Backdrop.d.ts +32 -0
- package/dist/types/components/layout/Container.d.ts +6 -0
- package/dist/types/components/layout/Divider.d.ts +5 -0
- package/dist/types/components/layout/Drawer.d.ts +9 -0
- package/dist/types/components/layout/DrawerDockSlot.d.ts +40 -0
- package/dist/types/components/layout/Grid.d.ts +8 -0
- package/dist/types/components/layout/Modal.d.ts +25 -0
- package/dist/types/components/layout/Page.d.ts +11 -0
- package/dist/types/components/layout/Section.d.ts +6 -0
- package/dist/types/components/layout/Stack.d.ts +7 -0
- package/dist/types/components/marketing/AnnouncementBar.d.ts +15 -0
- package/dist/types/components/marketing/BrandStory.d.ts +19 -0
- package/dist/types/components/marketing/HeroBanner.d.ts +69 -0
- package/dist/types/components/marketing/HeroBannerFeatures.d.ts +10 -0
- package/dist/types/components/marketing/HeroBannerInline.d.ts +20 -0
- package/dist/types/components/marketing/PromoBanner.d.ts +11 -0
- package/dist/types/components/marketing/internal/AnnouncementLink.d.ts +5 -0
- package/dist/types/components/marketing/internal/AnnouncementMessage.d.ts +10 -0
- package/dist/types/components/navigation/Breadcrumbs.d.ts +10 -0
- package/dist/types/components/navigation/Footer.d.ts +15 -0
- package/dist/types/components/navigation/Header.d.ts +14 -0
- package/dist/types/components/navigation/internal/BreadcrumbLink.d.ts +5 -0
- package/dist/types/components/navigation/internal/FooterLink.d.ts +5 -0
- package/dist/types/components/navigation/internal/HeaderLink.d.ts +5 -0
- package/dist/types/components/shell/BaseMark.d.ts +11 -0
- package/dist/types/components/shell/CartPill.d.ts +13 -0
- package/dist/types/components/shell/ComposerDock.d.ts +9 -0
- package/dist/types/components/shell/ErrorBanner.d.ts +14 -0
- package/dist/types/components/shell/HistoryMenu.d.ts +15 -0
- package/dist/types/components/shell/MenuButton.d.ts +31 -0
- package/dist/types/components/shell/MountainRidges.d.ts +11 -0
- package/dist/types/components/shell/PendingTurn.d.ts +1 -0
- package/dist/types/components/shell/ShellTop.d.ts +35 -0
- package/dist/types/components/shell/brand-shell.d.ts +441 -0
- package/dist/types/components/shell/index.d.ts +9 -0
- package/dist/types/components/shell/marks/index.d.ts +5 -0
- package/dist/types/components/social/ReviewCard.d.ts +9 -0
- package/dist/types/components/social/ReviewSummary.d.ts +7 -0
- package/dist/types/components/social/TestimonialCard.d.ts +9 -0
- package/dist/types/components/social/TestimonialCarousel.d.ts +16 -0
- package/dist/types/components/social/UgcCard.d.ts +9 -0
- package/dist/types/components/social/UgcGallery.d.ts +8 -0
- package/dist/types/hooks/index.d.ts +8 -0
- package/dist/types/hooks/keyboard.d.ts +18 -0
- package/dist/types/hooks/use-container-width.d.ts +11 -0
- package/dist/types/hooks/use-dismiss-on-outside.d.ts +23 -0
- package/dist/types/hooks/use-focus-on-change.d.ts +8 -0
- package/dist/types/hooks/use-focus-trap.d.ts +12 -0
- package/dist/types/hooks/use-media-query.d.ts +12 -0
- package/dist/types/hooks/use-projection.d.ts +24 -0
- package/dist/types/hooks/use-reduced-motion.d.ts +1 -0
- package/dist/types/hooks/use-scroll-lock.d.ts +19 -0
- package/dist/types/hooks/use-scroll-threshold.d.ts +14 -0
- package/dist/types/hooks/use-textarea-autosize.d.ts +16 -0
- package/dist/types/index.d.ts +74 -0
- package/dist/types/labels-context.d.ts +18 -0
- package/dist/types/labels.d.ts +240 -0
- package/dist/types/motion/ease.d.ts +10 -0
- package/dist/types/motion/generation/ActiveBlockIndicator.d.ts +27 -0
- package/dist/types/motion/generation/BlurUpImage.d.ts +23 -0
- package/dist/types/motion/generation/ResolveEntrance.d.ts +22 -0
- package/dist/types/motion/generation/ShimmerSkeleton.d.ts +20 -0
- package/dist/types/motion/generation/WordReveal.d.ts +26 -0
- package/dist/types/motion/generation/index.d.ts +6 -0
- package/dist/types/motion/hooks/useInViewOnce.d.ts +14 -0
- package/dist/types/motion/hooks/useScrollDirection.d.ts +38 -0
- package/dist/types/motion/hooks/useScrollProgress.d.ts +23 -0
- package/dist/types/motion/hooks/useStableValue.d.ts +36 -0
- package/dist/types/motion/hooks/useSuccessFlash.d.ts +1 -0
- package/dist/types/motion/index.d.ts +18 -0
- package/dist/types/motion/presets.d.ts +335 -0
- package/dist/types/motion/primitives/Agent.d.ts +118 -0
- package/dist/types/motion/primitives/MorphRegion.d.ts +16 -0
- package/dist/types/motion/primitives/Parallax.d.ts +19 -0
- package/dist/types/motion/primitives/Pin.d.ts +26 -0
- package/dist/types/motion/primitives/Reveal.d.ts +29 -0
- package/dist/types/motion/primitives/RevealStagger.d.ts +16 -0
- package/dist/types/motion/primitives/StickyShelf.d.ts +18 -0
- package/dist/types/primitives/Badge/index.d.ts +12 -0
- package/dist/types/primitives/Button/index.d.ts +25 -0
- package/dist/types/primitives/Input/index.d.ts +5 -0
- package/dist/types/primitives/Money/index.d.ts +13 -0
- package/dist/types/primitives/Select/index.d.ts +5 -0
- package/dist/types/primitives/Skeleton/index.d.ts +4 -0
- package/dist/types/shell/AnimatedPlaceholder.d.ts +13 -0
- package/dist/types/shell/BottomSheet.d.ts +54 -0
- package/dist/types/shell/Button.d.ts +19 -0
- package/dist/types/shell/ChromeSurface.d.ts +33 -0
- package/dist/types/shell/Composer.d.ts +56 -0
- package/dist/types/shell/ComposerChipStrip.d.ts +9 -0
- package/dist/types/shell/ConversationTransition.d.ts +27 -0
- package/dist/types/shell/DictationButton.d.ts +24 -0
- package/dist/types/shell/DragSheet.d.ts +34 -0
- package/dist/types/shell/InlineCompletion.d.ts +38 -0
- package/dist/types/shell/LauncherDock.d.ts +40 -0
- package/dist/types/shell/ListeningWaveform.d.ts +18 -0
- package/dist/types/shell/MenuAccordionPanel.d.ts +26 -0
- package/dist/types/shell/MenuDrawer.d.ts +72 -0
- package/dist/types/shell/MenuFlyout.d.ts +22 -0
- package/dist/types/shell/MenuNav.d.ts +30 -0
- package/dist/types/shell/MenuNavBar.d.ts +22 -0
- package/dist/types/shell/ShellMenuChrome.d.ts +66 -0
- package/dist/types/shell/ShellScaffold.d.ts +92 -0
- package/dist/types/shell/SideDock.d.ts +75 -0
- package/dist/types/shell/Skeleton.d.ts +22 -0
- package/dist/types/shell/Spinner.d.ts +10 -0
- package/dist/types/shell/TypedPlaceholder.d.ts +11 -0
- package/dist/types/shell/VoiceControl.d.ts +23 -0
- package/dist/types/shell/VoiceIsland.d.ts +24 -0
- package/dist/types/shell/canvas-gutter-style.d.ts +15 -0
- package/dist/types/shell/composer/AttachButton.d.ts +14 -0
- package/dist/types/shell/composer/AttachmentStrip.d.ts +12 -0
- package/dist/types/shell/composer/ClearSessionButton.d.ts +16 -0
- package/dist/types/shell/composer/ConversationHistoryButton.d.ts +25 -0
- package/dist/types/shell/composer/ShareCanvasButton.d.ts +19 -0
- package/dist/types/shell/composer/ThreadJumpRail.d.ts +43 -0
- package/dist/types/shell/composer/composer-metrics.d.ts +6 -0
- package/dist/types/shell/composer/field-metrics.d.ts +97 -0
- package/dist/types/shell/composer/heic-convert.d.ts +6 -0
- package/dist/types/shell/composer/use-field-autosize.d.ts +26 -0
- package/dist/types/shell/composer/useComposerAttachments.d.ts +37 -0
- package/dist/types/shell/composer/usePromptComposer.d.ts +51 -0
- package/dist/types/shell/dock-context.d.ts +10 -0
- package/dist/types/shell/index.d.ts +36 -0
- package/dist/types/shell/menu-columns.d.ts +19 -0
- package/dist/types/shell/mobile/DefaultMobileShell.d.ts +88 -0
- package/dist/types/shell/mobile/IslandComposeGroup.d.ts +41 -0
- package/dist/types/shell/mobile/IslandInputBar.d.ts +61 -0
- package/dist/types/shell/mobile/IslandNavButtons.d.ts +20 -0
- package/dist/types/shell/mobile/IslandTrailingAction.d.ts +34 -0
- package/dist/types/shell/mobile/MobileChrome.d.ts +34 -0
- package/dist/types/shell/mobile/MobileVoiceConsole.d.ts +42 -0
- package/dist/types/shell/mobile/MorphIsland.d.ts +105 -0
- package/dist/types/shell/mobile/RestIsland.d.ts +41 -0
- package/dist/types/shell/mobile/constants.d.ts +26 -0
- package/dist/types/shell/mobile/document-scroll-ref.d.ts +22 -0
- package/dist/types/shell/mobile/hero-entry-point.d.ts +110 -0
- package/dist/types/shell/mobile/island-metrics.d.ts +131 -0
- package/dist/types/shell/mobile/sheet-detents.d.ts +49 -0
- package/dist/types/shell/mobile/turn-end-action.d.ts +44 -0
- package/dist/types/shell/mobile/use-blur-on-canvas-gesture.d.ts +31 -0
- package/dist/types/shell/mobile/use-island-fold-scroll.d.ts +28 -0
- package/dist/types/shell/mobile/use-keyboard-inset.d.ts +18 -0
- package/dist/types/shell/mobile/use-sheet-fold-gesture.d.ts +57 -0
- package/dist/types/shell/slots.d.ts +16 -0
- package/dist/types/shell/thread-reland.d.ts +22 -0
- package/dist/types/shell/use-dock-state.d.ts +54 -0
- package/dist/types/types/commerce.d.ts +1 -0
- package/dist/types/utils/cn.d.ts +2 -0
- package/dist/types/utils/format-money.d.ts +2 -0
- package/dist/types/utils/html-to-text.d.ts +8 -0
- package/dist/types/utils/sanitize-html.d.ts +12 -0
- package/dist/types/utils/use-backdrop-presence.d.ts +24 -0
- package/dist/types/utils/use-composer-mode.d.ts +26 -0
- package/dist/types/utils/use-is-seed-home.d.ts +13 -0
- package/dist/types/utils/use-safe-cart.d.ts +17 -0
- package/dist/types/utils/use-safe-facts.d.ts +9 -0
- package/dist/types/utils/use-safe-fourty-session.d.ts +15 -0
- package/package.json +80 -0
|
@@ -0,0 +1,2800 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
AnimatePresence,
|
|
4
|
+
motion,
|
|
5
|
+
useAnimationControls,
|
|
6
|
+
useReducedMotion
|
|
7
|
+
} from "./chunk-432XYPDT.js";
|
|
8
|
+
|
|
9
|
+
// src/labels.ts
|
|
10
|
+
var DEFAULT_LABELS = {
|
|
11
|
+
product: {
|
|
12
|
+
addToBag: "add to bag",
|
|
13
|
+
added: "added \xB7 \u2713",
|
|
14
|
+
save: "save",
|
|
15
|
+
saved: "saved",
|
|
16
|
+
inStock: "in stock",
|
|
17
|
+
outOfStock: "out of stock",
|
|
18
|
+
reviewsTitle: "Reviews",
|
|
19
|
+
reviewsEmpty: "No reviews yet for this one.",
|
|
20
|
+
specs: {
|
|
21
|
+
vendor: "vendor",
|
|
22
|
+
type: "type",
|
|
23
|
+
available: "available",
|
|
24
|
+
rating: "rating",
|
|
25
|
+
tags: "tags",
|
|
26
|
+
variant: "variant"
|
|
27
|
+
},
|
|
28
|
+
a11y: {
|
|
29
|
+
ratingLabel: (value, count) => `Rated ${value.toFixed(1)} of 5 from ${count} reviews`
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
rating: {
|
|
33
|
+
reviewsCount: (count) => `${count} reviews`
|
|
34
|
+
},
|
|
35
|
+
variantPicker: {
|
|
36
|
+
title: "choose your options",
|
|
37
|
+
dismiss: "not now"
|
|
38
|
+
},
|
|
39
|
+
canvas: {
|
|
40
|
+
share: "Share",
|
|
41
|
+
shareCopied: "Link copied",
|
|
42
|
+
shareUnavailable: "Can't share yet",
|
|
43
|
+
shareA11y: "Share this page",
|
|
44
|
+
shareTitle: "Send this page",
|
|
45
|
+
shareExplain: "They get this page and the conversation behind it, frozen as it is right now. It becomes their own copy to carry on from \u2014 your page, your cart and anything you do next stay yours.",
|
|
46
|
+
shareCopy: "Copy link",
|
|
47
|
+
shareExpiry: (days) => `Expires in ${days} days`,
|
|
48
|
+
shareClose: "Close",
|
|
49
|
+
shareNative: "Share\u2026",
|
|
50
|
+
shareSubject: "A page made for me"
|
|
51
|
+
},
|
|
52
|
+
chat: {
|
|
53
|
+
placeholder: "Ask the agent",
|
|
54
|
+
placeholderFollowUp: "Follow up"
|
|
55
|
+
},
|
|
56
|
+
voice: {
|
|
57
|
+
speak: "Speak"
|
|
58
|
+
},
|
|
59
|
+
presence: {
|
|
60
|
+
newFacts: (count) => `${count} new ${count === 1 ? "detail" : "details"}`,
|
|
61
|
+
brief: {
|
|
62
|
+
open: "Show what I know about you",
|
|
63
|
+
close: "Hide what I know about you",
|
|
64
|
+
identity: {
|
|
65
|
+
greeting: (name) => `Hey ${name}`,
|
|
66
|
+
invite: "Tell me what to call you",
|
|
67
|
+
placeholder: "Your name",
|
|
68
|
+
change: (name) => `Change the name I call you (${name})`
|
|
69
|
+
},
|
|
70
|
+
more: (count) => `Show ${count} more`,
|
|
71
|
+
forget: (label) => `Forget ${label}`,
|
|
72
|
+
recalled: {
|
|
73
|
+
title: "From before",
|
|
74
|
+
badge: "You told me this on an earlier visit"
|
|
75
|
+
},
|
|
76
|
+
inferred: {
|
|
77
|
+
title: "From this visit"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
composing: [
|
|
81
|
+
"Putting this together",
|
|
82
|
+
"Lining these up",
|
|
83
|
+
"Laying it all out",
|
|
84
|
+
"Finding the balance",
|
|
85
|
+
"Starting from the top",
|
|
86
|
+
"Making room on the side"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
menu: {
|
|
90
|
+
shopAll: (label) => `Shop all ${label}`
|
|
91
|
+
},
|
|
92
|
+
cart: {
|
|
93
|
+
title: "bag",
|
|
94
|
+
empty: "your bag is empty",
|
|
95
|
+
emptyHint: "add a product to get started",
|
|
96
|
+
removeLine: "Remove from bag",
|
|
97
|
+
viewOnStore: "view bag on official store",
|
|
98
|
+
freeShippingThreshold: null,
|
|
99
|
+
shippingFree: "complimentary",
|
|
100
|
+
shippingDeferred: "shipping & taxes calculated at checkout",
|
|
101
|
+
promoPlaceholder: "promo code",
|
|
102
|
+
promoApply: "apply",
|
|
103
|
+
promoNotApplicable: "doesn't apply",
|
|
104
|
+
promoInvalid: "code not recognized",
|
|
105
|
+
discount: "discount",
|
|
106
|
+
itemSingular: "item",
|
|
107
|
+
itemPlural: "items",
|
|
108
|
+
subtotal: "subtotal",
|
|
109
|
+
shipping: "shipping",
|
|
110
|
+
total: "total",
|
|
111
|
+
linePending: "adding\u2026",
|
|
112
|
+
linePendingPrice: "\u2014",
|
|
113
|
+
totalsPending: "updating totals\u2026"
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/labels-context.tsx
|
|
118
|
+
import * as React from "react";
|
|
119
|
+
import { jsx } from "react/jsx-runtime";
|
|
120
|
+
var LabelsContext = React.createContext(DEFAULT_LABELS);
|
|
121
|
+
function mergeLabels(base, override) {
|
|
122
|
+
if (!override) return base;
|
|
123
|
+
return deepMerge(base, override);
|
|
124
|
+
}
|
|
125
|
+
function deepMerge(target, source) {
|
|
126
|
+
if (!isPlainObject(target) || !isPlainObject(source)) return source === void 0 ? target : source;
|
|
127
|
+
const result = { ...target };
|
|
128
|
+
for (const key of Object.keys(source)) {
|
|
129
|
+
const sv = source[key];
|
|
130
|
+
const tv = target[key];
|
|
131
|
+
result[key] = isPlainObject(sv) && isPlainObject(tv) ? deepMerge(tv, sv) : sv;
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
function isPlainObject(v) {
|
|
136
|
+
if (v === null || typeof v !== "object") return false;
|
|
137
|
+
const proto = Object.getPrototypeOf(v);
|
|
138
|
+
return proto === Object.prototype || proto === null;
|
|
139
|
+
}
|
|
140
|
+
function LabelsProvider({ overrides, children }) {
|
|
141
|
+
const value = React.useMemo(() => mergeLabels(DEFAULT_LABELS, overrides), [overrides]);
|
|
142
|
+
return /* @__PURE__ */ jsx(LabelsContext.Provider, { value, children });
|
|
143
|
+
}
|
|
144
|
+
function useLabels() {
|
|
145
|
+
return React.useContext(LabelsContext);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/agent/presence/notch/PresenceNotch.tsx
|
|
149
|
+
import * as React2 from "react";
|
|
150
|
+
import {
|
|
151
|
+
usePresenceNotch,
|
|
152
|
+
useFormFactor
|
|
153
|
+
} from "@40rty/ams-sdk";
|
|
154
|
+
import { AgentAsk } from "@40rty/ams-sdk";
|
|
155
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
156
|
+
function PresenceNotch({ widgets }) {
|
|
157
|
+
const { expanded, askStanding, lead, trail, drawerWidgets, openDrawerId, toggleDrawer, rootHandlers, rootRef } = usePresenceNotch(widgets);
|
|
158
|
+
const { isMobile } = useFormFactor();
|
|
159
|
+
const handles = React2.useMemo(() => {
|
|
160
|
+
const map = /* @__PURE__ */ new Map();
|
|
161
|
+
for (const w of widgets) {
|
|
162
|
+
if (w.Drawer === void 0) continue;
|
|
163
|
+
map.set(w.id, { open: openDrawerId === w.id, toggle: () => toggleDrawer(w.id) });
|
|
164
|
+
}
|
|
165
|
+
return map;
|
|
166
|
+
}, [widgets, openDrawerId, toggleDrawer]);
|
|
167
|
+
const renderWidget = (w) => {
|
|
168
|
+
const drawer = handles.get(w.id);
|
|
169
|
+
const node = drawer === void 0 ? /* @__PURE__ */ jsx2(w.Component, { expanded }) : /* @__PURE__ */ jsx2(w.Component, { expanded, drawer });
|
|
170
|
+
if (w.Drawer === void 0) return /* @__PURE__ */ jsx2(React2.Fragment, { children: node }, w.id);
|
|
171
|
+
return /* @__PURE__ */ jsx2("div", { className: "fourty-notch__widget", children: node }, w.id);
|
|
172
|
+
};
|
|
173
|
+
return (
|
|
174
|
+
// `rootRef` marks where the notch ENDS: a press outside it closes an open
|
|
175
|
+
// drawer, so reaching back for the page is enough to put the brief away.
|
|
176
|
+
/* @__PURE__ */ jsxs("div", { className: "fourty-notch-root", ref: rootRef, ...rootHandlers, children: [
|
|
177
|
+
/* @__PURE__ */ jsxs(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
className: "fourty-notch",
|
|
181
|
+
"data-fourty-shell-part": "presenceNotch",
|
|
182
|
+
"data-expanded": expanded ? "true" : "false",
|
|
183
|
+
role: "region",
|
|
184
|
+
"aria-live": "polite",
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ jsx2("div", { className: "fourty-notch__lead", children: askStanding ? /* @__PURE__ */ jsx2(AgentAsk, {}) : lead.map(renderWidget) }),
|
|
187
|
+
/* @__PURE__ */ jsx2("div", { className: "fourty-notch__trail", children: trail.map(renderWidget) })
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
),
|
|
191
|
+
!isMobile && drawerWidgets.length > 0 && /* @__PURE__ */ jsx2("div", { className: "fourty-notch__drawer-region", children: drawerWidgets.map((w) => {
|
|
192
|
+
const Drawer = w.Drawer;
|
|
193
|
+
if (Drawer === void 0) return null;
|
|
194
|
+
const open = openDrawerId === w.id;
|
|
195
|
+
const drawer = handles.get(w.id);
|
|
196
|
+
return /* @__PURE__ */ jsx2("div", { className: "fourty-notch__drawer", "data-open": open ? "true" : "false", "aria-hidden": !open, children: drawer === void 0 ? /* @__PURE__ */ jsx2(Drawer, { expanded: true }) : /* @__PURE__ */ jsx2(Drawer, { expanded: true, drawer }) }, w.id);
|
|
197
|
+
}) })
|
|
198
|
+
] })
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/agent/presence/class-names.ts
|
|
203
|
+
var presenceClass = {
|
|
204
|
+
/** The height-animating wrapper (the notch lead fills to it). */
|
|
205
|
+
root: "fourty-presence-read",
|
|
206
|
+
/** Inner static box the ResizeObserver measures (so the band auto-fits). */
|
|
207
|
+
measure: "fourty-presence-read__measure",
|
|
208
|
+
/** The single presence FRAME — the motion wrapper AnimatePresence swaps as the
|
|
209
|
+
* agent's state changes. `popLayout` floats an exiting frame out of flow so
|
|
210
|
+
* the band measures only the entering one. */
|
|
211
|
+
frame: "fourty-presence-read__frame",
|
|
212
|
+
/** `InlinePresenceRead`'s own outer wrapper (prose line + composing skeleton,
|
|
213
|
+
* stacked). Distinct from `frame` above — that one is AgentPresenceWidget's
|
|
214
|
+
* AnimatePresence motion wrapper around whichever form is active; reusing it
|
|
215
|
+
* here previously bled `display:flex` onto the main notch's layout too. */
|
|
216
|
+
inlineFrame: "fourty-presence-read__inline-frame",
|
|
217
|
+
/** The ONE element-stream face — the row, plus the editable dossier beneath it
|
|
218
|
+
* when the band is open at rest. One node with one key: the row and the
|
|
219
|
+
* dossier used to be two trees swapped by AnimatePresence, and both stayed
|
|
220
|
+
* mounted, drawing every glyph twice. `data-stacked` carries the difference. */
|
|
221
|
+
stream: "fourty-presence-read__stream",
|
|
222
|
+
/** The flex row a form lays out on — eyebrow · rule · content. */
|
|
223
|
+
row: "fourty-presence-read__row",
|
|
224
|
+
/** The right-hand DECK REGION — a fixed-width box (JS-set, see
|
|
225
|
+
* `siftRegionWidth`) holding the gate and the candidate deck, standing at the
|
|
226
|
+
* band's right edge WHETHER OR NOT there is a deck in it. Reserved rather
|
|
227
|
+
* than conditional so nothing on the row moves when a turn opens or settles.
|
|
228
|
+
* (Was `evidence`, a block that also held the criteria and swapped ends of
|
|
229
|
+
* the band on `data-working` — a ~1100px traversal twice per turn.) */
|
|
230
|
+
deck: "fourty-presence-read__deck",
|
|
231
|
+
/** Small tracked-caps label naming the moment. */
|
|
232
|
+
eyebrow: "fourty-presence-read__eyebrow",
|
|
233
|
+
/** Hairline divider between eyebrow and content. */
|
|
234
|
+
rule: "fourty-presence-read__rule",
|
|
235
|
+
/** A shimmering placeholder line — shown while a flow is live but before (or
|
|
236
|
+
* between) its reads land, so the lane reads as actively working, not blank. */
|
|
237
|
+
shimmer: "fourty-presence-read__shimmer",
|
|
238
|
+
/** The FILLER sweep — a travelling hairline shown when the band is working
|
|
239
|
+
* and its stream is still empty, so the strip is never blank mid-turn. */
|
|
240
|
+
filler: "fourty-presence-read__filler",
|
|
241
|
+
/** The inline lane's PROSE row — the agent's evolving voice (read or shimmer),
|
|
242
|
+
* kept never-empty above the working skeleton (scanning state). */
|
|
243
|
+
proseLine: "fourty-presence-read__prose-line",
|
|
244
|
+
/** The grow box inside the prose row (the read/shimmer fills it, min-width:0). */
|
|
245
|
+
proseBody: "fourty-presence-read__prose-body",
|
|
246
|
+
/** The continuation loader's centred column — the morphing layout preview stacked
|
|
247
|
+
* over its status line. */
|
|
248
|
+
loaderColumn: "fourty-presence-read__loader",
|
|
249
|
+
/** The status line under the morph — the agent's live read, or the archetype label
|
|
250
|
+
* naming the shape forming, with a steady caret. */
|
|
251
|
+
status: "fourty-presence-read__status",
|
|
252
|
+
/** The morph box — six frosted tiles cycling through layout archetypes. */
|
|
253
|
+
layoutMorph: "fourty-layout-morph",
|
|
254
|
+
/** One frosted tile in the morph (geometry set inline, skin + transition in CSS). */
|
|
255
|
+
layoutMorphTile: "fourty-layout-morph__tile",
|
|
256
|
+
/** The agent's read — the readable lead sentence. */
|
|
257
|
+
prose: "fourty-presence-read__prose",
|
|
258
|
+
/** THE VOICE LINE — the band's sentence, in the row's middle track, typed.
|
|
259
|
+
* Distinct from `prose` (which the island and the inline read lay out): this
|
|
260
|
+
* one is clipped to a single line by a mask, because the band's height is
|
|
261
|
+
* fixed and a second line would be sheared by it. */
|
|
262
|
+
voiceLine: "fourty-presence-read__voice-line",
|
|
263
|
+
/** The rail's last lane — the brief handle's reserved cell, beside the chips it
|
|
264
|
+
* opens rather than floating at the band's right edge. */
|
|
265
|
+
railHandle: "fourty-presence-read__rail-handle",
|
|
266
|
+
/** The dossier's vertical editorial stack — kicker / read / facts. */
|
|
267
|
+
dossier: "fourty-presence-read__dossier",
|
|
268
|
+
/** The dossier's top line — the live dot beside the eyebrow kicker. */
|
|
269
|
+
kicker: "fourty-presence-read__kicker",
|
|
270
|
+
/** Per-form presence HOST — the motion wrapper AnimatePresence swaps. Owns the
|
|
271
|
+
* crossfade so `popLayout` can pull an exiting form out of flow (the band then
|
|
272
|
+
* measures only the entering form → one eased move, no sum, no 2-step fold). */
|
|
273
|
+
formHost: "fourty-presence-read__form-host",
|
|
274
|
+
/** The fact row (the dossier chips). */
|
|
275
|
+
facts: "fourty-presence-read__facts",
|
|
276
|
+
/** One labeled fact. */
|
|
277
|
+
fact: "fourty-presence-read__fact",
|
|
278
|
+
/** A fact's quiet micro-label ("SHOE SIZE"). */
|
|
279
|
+
factLabel: "fourty-presence-read__fact-label",
|
|
280
|
+
/** A fact's hard value ("SIZE 9"). */
|
|
281
|
+
factValue: "fourty-presence-read__fact-value",
|
|
282
|
+
/** The value's TEXT box, inside the value (which may also hold a colour
|
|
283
|
+
* swatch). Exists so the brief can normalise the model's casing with
|
|
284
|
+
* `::first-letter`, which needs a box whose first content is a letter. */
|
|
285
|
+
factValueText: "fourty-presence-read__fact-value-text",
|
|
286
|
+
/** Vertical hairline between facts. */
|
|
287
|
+
factSep: "fourty-presence-read__fact-sep",
|
|
288
|
+
/** The hover × that forgets a fact. */
|
|
289
|
+
factForget: "fourty-presence-read__fact-forget",
|
|
290
|
+
/** "+N" tail on a folded fact list. A BUTTON on the band (it opens the brief),
|
|
291
|
+
* plain text anywhere the brief is already on screen. */
|
|
292
|
+
factMore: "fourty-presence-read__fact-more",
|
|
293
|
+
/** The BRIEF — everything the agent knows, drawn in the notch drawer (desktop)
|
|
294
|
+
* or inline on the expanded island (mobile). The band shows what is in play;
|
|
295
|
+
* this shows what is known. */
|
|
296
|
+
brief: "fourty-presence-read__brief",
|
|
297
|
+
/** The drawer's own panel chrome around the brief. */
|
|
298
|
+
briefPanel: "fourty-presence-read__brief-panel",
|
|
299
|
+
/** THE BRIEF'S IDENTITY LINE — who the agent is talking to. One row, always in
|
|
300
|
+
* the same place: the greeting when a name is known, the invitation to give
|
|
301
|
+
* one when it is not. See `BriefIdentity`. */
|
|
302
|
+
identity: "fourty-presence-read__identity",
|
|
303
|
+
/** The greeting itself — a button, because the name is the visitor's to correct. */
|
|
304
|
+
identityName: "fourty-presence-read__identity-name",
|
|
305
|
+
/** The invitation shown to a visitor who has not given a name. */
|
|
306
|
+
identityInvite: "fourty-presence-read__identity-invite",
|
|
307
|
+
/** The name field. Bare — no commit control beside it (see `NameField`). */
|
|
308
|
+
identityInput: "fourty-presence-read__identity-input",
|
|
309
|
+
/** One register of the brief — carried memory, or this session's derivations. */
|
|
310
|
+
briefGroup: "fourty-presence-read__brief-group",
|
|
311
|
+
/** A register's heading row (its eyebrow + the one-line note under it). */
|
|
312
|
+
briefGroupHead: "fourty-presence-read__brief-head",
|
|
313
|
+
/** A color dot beside a color-valued fact. */
|
|
314
|
+
swatch: "fourty-presence-read__swatch",
|
|
315
|
+
/** The SIFT — the deck of candidates the agent is choosing between, plus the
|
|
316
|
+
* tail count of what it read beyond them. */
|
|
317
|
+
sift: "fourty-presence-read__sift",
|
|
318
|
+
/** The TRACK the candidates sit on. Reserved at full width on the band before
|
|
319
|
+
* anything lands, so records fill a space instead of pushing one open. */
|
|
320
|
+
siftTrack: "fourty-presence-read__sift-track",
|
|
321
|
+
/** The hairline that passes across the deck when a criterion crystallizes. */
|
|
322
|
+
siftPass: "fourty-presence-read__sift-pass",
|
|
323
|
+
/** "+N" naming the records read beyond the ones the deck has room to draw. */
|
|
324
|
+
siftMore: "fourty-presence-read__sift-more",
|
|
325
|
+
/** The CRITERIA rail — the crystallized facts, standing beside the deck they
|
|
326
|
+
* are being applied to rather than adrift at the other end of the band. */
|
|
327
|
+
criteria: "fourty-presence-read__criteria",
|
|
328
|
+
/** The rule a criterion draws under itself as it locks in. */
|
|
329
|
+
criterionRule: "fourty-presence-read__criterion-rule",
|
|
330
|
+
/** The hairline gate between the criteria and the deck. */
|
|
331
|
+
gate: "fourty-presence-read__gate",
|
|
332
|
+
/** The resting promo line when there's nothing to read. */
|
|
333
|
+
fallback: "fourty-presence-read__fallback",
|
|
334
|
+
/** The chevron hinting the read expands on hover. */
|
|
335
|
+
hint: "fourty-presence-read__hint"
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// src/agent/presence/parts.tsx
|
|
339
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
340
|
+
var FALLBACK = "";
|
|
341
|
+
var SETTLE_EASE = [0.22, 1, 0.36, 1];
|
|
342
|
+
var enter = {
|
|
343
|
+
initial: { opacity: 0 },
|
|
344
|
+
animate: { opacity: 1 },
|
|
345
|
+
exit: { opacity: 0 },
|
|
346
|
+
transition: { duration: 0.5, ease: SETTLE_EASE }
|
|
347
|
+
};
|
|
348
|
+
function Eyebrow({ children }) {
|
|
349
|
+
return /* @__PURE__ */ jsx3("span", { className: presenceClass.eyebrow, children });
|
|
350
|
+
}
|
|
351
|
+
function Rule() {
|
|
352
|
+
return /* @__PURE__ */ jsx3("span", { "aria-hidden": true, className: presenceClass.rule });
|
|
353
|
+
}
|
|
354
|
+
function Fallback() {
|
|
355
|
+
if (FALLBACK.length === 0) return null;
|
|
356
|
+
return /* @__PURE__ */ jsx3("span", { className: presenceClass.fallback, children: FALLBACK });
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// src/agent/presence/read-data.ts
|
|
360
|
+
function factRegister(fact) {
|
|
361
|
+
if (fact.provenance === "recalled") return "recalled";
|
|
362
|
+
if (fact.provenance !== void 0) return "inferred";
|
|
363
|
+
return fact.tier === "profile" ? "recalled" : "inferred";
|
|
364
|
+
}
|
|
365
|
+
function readFacts(frame) {
|
|
366
|
+
const raw = frame.data === void 0 ? void 0 : Reflect.get(frame.data, "facts");
|
|
367
|
+
if (!Array.isArray(raw)) return [];
|
|
368
|
+
const out = [];
|
|
369
|
+
for (const f of raw) {
|
|
370
|
+
if (typeof f !== "object" || f === null) continue;
|
|
371
|
+
const label = Reflect.get(f, "label");
|
|
372
|
+
const value = Reflect.get(f, "value");
|
|
373
|
+
if (typeof label !== "string" || typeof value !== "string") continue;
|
|
374
|
+
const tier = Reflect.get(f, "tier");
|
|
375
|
+
const scope = Reflect.get(f, "scope");
|
|
376
|
+
out.push({
|
|
377
|
+
label,
|
|
378
|
+
value,
|
|
379
|
+
...tier === "session" || tier === "profile" ? { tier } : {},
|
|
380
|
+
...typeof scope === "string" && scope.length > 0 ? { scope } : {}
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
return out;
|
|
384
|
+
}
|
|
385
|
+
function factIdentity(fact) {
|
|
386
|
+
return `${fact.label}=${fact.value}`;
|
|
387
|
+
}
|
|
388
|
+
function readLabel(frame) {
|
|
389
|
+
if (frame.data === void 0) return "";
|
|
390
|
+
const l = Reflect.get(frame.data, "label");
|
|
391
|
+
return typeof l === "string" ? l : "";
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
// src/agent/presence/use-forget-fact.ts
|
|
395
|
+
import * as React3 from "react";
|
|
396
|
+
import { useFourtySession, useOptimisticFlowSet, useReconcileFlowSet, PRESENCE_FACT_DISMISS_SIGNAL } from "@40rty/ams-sdk";
|
|
397
|
+
var DISMISSED_FLOW = "presence.dismissed";
|
|
398
|
+
function useVisibleFacts(frame) {
|
|
399
|
+
return useVisibleFactList(frame !== null ? readFacts(frame) : []);
|
|
400
|
+
}
|
|
401
|
+
function useVisibleFactList(facts) {
|
|
402
|
+
const dismissed = useOptimisticFlowSet(DISMISSED_FLOW);
|
|
403
|
+
return facts.filter((f) => !dismissed.has(f.label));
|
|
404
|
+
}
|
|
405
|
+
var useUndismissedFacts = useVisibleFactList;
|
|
406
|
+
function useForgetFact() {
|
|
407
|
+
const { sendImmediateSignal } = useFourtySession();
|
|
408
|
+
const dismissed = useOptimisticFlowSet(DISMISSED_FLOW);
|
|
409
|
+
const forget = React3.useCallback(
|
|
410
|
+
(f) => {
|
|
411
|
+
dismissed.add(f.label);
|
|
412
|
+
sendImmediateSignal({ type: PRESENCE_FACT_DISMISS_SIGNAL, payload: { label: f.label, value: f.value } });
|
|
413
|
+
},
|
|
414
|
+
[dismissed, sendImmediateSignal]
|
|
415
|
+
);
|
|
416
|
+
return { forget };
|
|
417
|
+
}
|
|
418
|
+
function useReconcileDismissed(presentLabels) {
|
|
419
|
+
useReconcileFlowSet(DISMISSED_FLOW, presentLabels);
|
|
420
|
+
}
|
|
421
|
+
function useDismissedLabels() {
|
|
422
|
+
return useOptimisticFlowSet(DISMISSED_FLOW);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// src/agent/presence/swatch.tsx
|
|
426
|
+
import { colorHexOf } from "@40rty/ams-sdk";
|
|
427
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
428
|
+
function colorSwatch(value) {
|
|
429
|
+
const hex = colorHexOf(value);
|
|
430
|
+
if (hex === null) return null;
|
|
431
|
+
return /* @__PURE__ */ jsx4("span", { className: presenceClass.swatch, style: { background: hex } });
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// src/agent/presence/source-cards/card-shell.tsx
|
|
435
|
+
var sourceCardClass = {
|
|
436
|
+
card: "fourty-presence-source",
|
|
437
|
+
plate: "fourty-presence-source__plate",
|
|
438
|
+
rules: "fourty-presence-source__rules",
|
|
439
|
+
rule: "fourty-presence-source__rule",
|
|
440
|
+
pips: "fourty-presence-source__pips",
|
|
441
|
+
pip: "fourty-presence-source__pip",
|
|
442
|
+
/** The hairline struck under a card the canvas chose. */
|
|
443
|
+
chosenRule: "fourty-presence-source__chosen-rule",
|
|
444
|
+
fold: "fourty-presence-source__fold",
|
|
445
|
+
ghost: "fourty-presence-source__ghost",
|
|
446
|
+
image: "fourty-presence-source__image"
|
|
447
|
+
};
|
|
448
|
+
function sourceCardState(found, pending, chosen) {
|
|
449
|
+
if (pending) return "pending";
|
|
450
|
+
if (!found) return "missed";
|
|
451
|
+
return chosen ? "chosen" : "loaded";
|
|
452
|
+
}
|
|
453
|
+
function ink(pct) {
|
|
454
|
+
return `color-mix(in oklab, var(--fourty-notch-fg, currentColor) ${pct}%, transparent)`;
|
|
455
|
+
}
|
|
456
|
+
var SOURCE_CARD_BOX = {
|
|
457
|
+
// The band card sets the band's whole height, so every px here is a px the
|
|
458
|
+
// notch grows by for the entire turn — but the band now draws a DECK of real
|
|
459
|
+
// candidates rather than one representative per kind, and a 40px thumbnail is
|
|
460
|
+
// too small to recognise a shoe in. 42 × 54 is the smallest box in which a
|
|
461
|
+
// product photograph still reads as that product; below it the row degrades
|
|
462
|
+
// into texture, which is the thing the deck exists to stop being.
|
|
463
|
+
band: { width: 42, height: 54 },
|
|
464
|
+
compact: { width: 32, height: 40 },
|
|
465
|
+
foot: { width: 96, height: 126 }
|
|
466
|
+
};
|
|
467
|
+
var SOURCE_CARD_GAP = {
|
|
468
|
+
band: 8,
|
|
469
|
+
compact: 6,
|
|
470
|
+
foot: 12
|
|
471
|
+
};
|
|
472
|
+
function sourceCardBox(size) {
|
|
473
|
+
return SOURCE_CARD_BOX[size];
|
|
474
|
+
}
|
|
475
|
+
function sourceCardSpan(size, slots) {
|
|
476
|
+
const box = SOURCE_CARD_BOX[size];
|
|
477
|
+
const span = Math.max(1, Math.round(slots));
|
|
478
|
+
return { width: box.width * span + SOURCE_CARD_GAP[size] * (span - 1), height: box.height };
|
|
479
|
+
}
|
|
480
|
+
function platePad(width) {
|
|
481
|
+
return Math.max(3, Math.round(width * 0.14));
|
|
482
|
+
}
|
|
483
|
+
function ruleWeight(size) {
|
|
484
|
+
return size === "foot" ? 2 : 1;
|
|
485
|
+
}
|
|
486
|
+
var CARD_EASE = [0.22, 1, 0.36, 1];
|
|
487
|
+
var CARD_SETTLE_MS = 260;
|
|
488
|
+
|
|
489
|
+
// src/agent/presence/source-cards/card-frame.tsx
|
|
490
|
+
import * as React4 from "react";
|
|
491
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
492
|
+
var EXIT_TRANSITION = { duration: 0.62, ease: CARD_EASE };
|
|
493
|
+
var CARD_EXIT = {
|
|
494
|
+
chosen: { opacity: 0, scale: 1.1, y: -8, transition: EXIT_TRANSITION },
|
|
495
|
+
loaded: { opacity: 0, scale: 0.86, y: 6, transition: EXIT_TRANSITION },
|
|
496
|
+
pending: { opacity: 0, scale: 0.9, y: 4, transition: EXIT_TRANSITION },
|
|
497
|
+
missed: { opacity: 0, scale: 0.9, y: 4, transition: EXIT_TRANSITION }
|
|
498
|
+
};
|
|
499
|
+
var CARD_POSE = {
|
|
500
|
+
// Held back: present, legible, visibly NOT yet the answer.
|
|
501
|
+
loaded: { opacity: 0.58, scale: 0.94, y: 0 },
|
|
502
|
+
// Chosen: forward, full weight, lifted off the row.
|
|
503
|
+
chosen: { opacity: 1, scale: 1, y: -2 },
|
|
504
|
+
// Running: the faintest thing on the row — there is nothing to look at yet.
|
|
505
|
+
pending: { opacity: 0.44, scale: 0.94, y: 0 },
|
|
506
|
+
// A miss is a statement, so it is not dimmed into near-invisibility.
|
|
507
|
+
missed: { opacity: 0.7, scale: 0.94, y: 0 }
|
|
508
|
+
};
|
|
509
|
+
var SourceCardFrame = React4.forwardRef(function SourceCardFrame2({ kind, state, size, slots, children }, ref) {
|
|
510
|
+
const box = slots === void 0 ? sourceCardBox(size) : sourceCardSpan(size, slots);
|
|
511
|
+
const pose = CARD_POSE[state];
|
|
512
|
+
return /* @__PURE__ */ jsxs2(
|
|
513
|
+
motion.div,
|
|
514
|
+
{
|
|
515
|
+
ref,
|
|
516
|
+
layout: "position",
|
|
517
|
+
className: sourceCardClass.card,
|
|
518
|
+
"data-kind": kind,
|
|
519
|
+
"data-state": state,
|
|
520
|
+
"data-found": state === "missed" || state === "pending" ? "false" : "true",
|
|
521
|
+
initial: { opacity: 0, scale: 0.88, y: 7, x: -7, rotate: -1.6 },
|
|
522
|
+
animate: { ...pose, x: 0, rotate: 0 },
|
|
523
|
+
exit: CARD_EXIT[state],
|
|
524
|
+
transition: { duration: 0.42, ease: CARD_EASE, layout: { duration: 0.34, ease: CARD_EASE } },
|
|
525
|
+
style: {
|
|
526
|
+
position: "relative",
|
|
527
|
+
width: box.width,
|
|
528
|
+
height: box.height,
|
|
529
|
+
flexShrink: 0
|
|
530
|
+
},
|
|
531
|
+
children: [
|
|
532
|
+
children,
|
|
533
|
+
state === "chosen" && /* @__PURE__ */ jsx5(
|
|
534
|
+
motion.span,
|
|
535
|
+
{
|
|
536
|
+
"aria-hidden": true,
|
|
537
|
+
className: sourceCardClass.chosenRule,
|
|
538
|
+
initial: { scaleX: 0 },
|
|
539
|
+
animate: { scaleX: 1 },
|
|
540
|
+
transition: { duration: 0.34, ease: CARD_EASE },
|
|
541
|
+
style: {
|
|
542
|
+
position: "absolute",
|
|
543
|
+
left: 0,
|
|
544
|
+
right: 0,
|
|
545
|
+
bottom: -4,
|
|
546
|
+
height: 1,
|
|
547
|
+
transformOrigin: "left center",
|
|
548
|
+
background: ink(88)
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
);
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
// src/agent/presence/source-cards/card-plate.tsx
|
|
558
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
559
|
+
var PLATE_STYLE = {
|
|
560
|
+
loaded: {
|
|
561
|
+
background: ink(9),
|
|
562
|
+
boxShadow: `inset 0 0 0 1px ${ink(20)}`
|
|
563
|
+
},
|
|
564
|
+
// The chosen plate is the only one with a real edge on it. Everything else on
|
|
565
|
+
// the row is a candidate; this one is in the answer.
|
|
566
|
+
chosen: {
|
|
567
|
+
background: ink(12),
|
|
568
|
+
boxShadow: `inset 0 0 0 1px ${ink(46)}`
|
|
569
|
+
},
|
|
570
|
+
// Same solid outline as a loaded plate, at roughly half the weight. NOT the
|
|
571
|
+
// miss's dashed rule: a dash says "there is nothing here", and a running
|
|
572
|
+
// lookup has made no such claim.
|
|
573
|
+
pending: {
|
|
574
|
+
background: ink(4),
|
|
575
|
+
boxShadow: `inset 0 0 0 1px ${ink(11)}`
|
|
576
|
+
},
|
|
577
|
+
missed: {
|
|
578
|
+
background: "transparent",
|
|
579
|
+
border: `1px dashed ${ink(26)}`,
|
|
580
|
+
opacity: 0.85
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
var PENDING_MARK_OPACITY = 0.42;
|
|
584
|
+
var MARK_FILTER = {
|
|
585
|
+
loaded: "grayscale(1)",
|
|
586
|
+
chosen: "none",
|
|
587
|
+
pending: "grayscale(1)",
|
|
588
|
+
missed: "grayscale(1)"
|
|
589
|
+
};
|
|
590
|
+
function SourcePlate({
|
|
591
|
+
width,
|
|
592
|
+
height,
|
|
593
|
+
state,
|
|
594
|
+
mark,
|
|
595
|
+
style,
|
|
596
|
+
children
|
|
597
|
+
}) {
|
|
598
|
+
return /* @__PURE__ */ jsxs3(
|
|
599
|
+
"div",
|
|
600
|
+
{
|
|
601
|
+
className: sourceCardClass.plate,
|
|
602
|
+
"data-state": state,
|
|
603
|
+
"data-hollow": state === "missed" ? "true" : "false",
|
|
604
|
+
style: {
|
|
605
|
+
position: "absolute",
|
|
606
|
+
left: 0,
|
|
607
|
+
top: 0,
|
|
608
|
+
width,
|
|
609
|
+
height,
|
|
610
|
+
boxSizing: "border-box",
|
|
611
|
+
overflow: "hidden",
|
|
612
|
+
// The ONE transition on a card: pending → loaded, when the lookup
|
|
613
|
+
// returned. A decision, so it moves; a fill settling, so it is calm.
|
|
614
|
+
transition: `background ${CARD_SETTLE_MS}ms ease, box-shadow ${CARD_SETTLE_MS}ms ease`,
|
|
615
|
+
...PLATE_STYLE[state],
|
|
616
|
+
...style
|
|
617
|
+
},
|
|
618
|
+
children: [
|
|
619
|
+
state === "missed" && mark ? /* @__PURE__ */ jsx6(
|
|
620
|
+
"span",
|
|
621
|
+
{
|
|
622
|
+
"aria-hidden": true,
|
|
623
|
+
style: {
|
|
624
|
+
position: "absolute",
|
|
625
|
+
left: "50%",
|
|
626
|
+
top: "50%",
|
|
627
|
+
width: Math.round(width * 0.42),
|
|
628
|
+
height: 1,
|
|
629
|
+
transform: "translate(-50%, -50%)",
|
|
630
|
+
background: ink(30)
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
) : null,
|
|
634
|
+
state === "missed" ? null : /* @__PURE__ */ jsx6(
|
|
635
|
+
"div",
|
|
636
|
+
{
|
|
637
|
+
style: {
|
|
638
|
+
position: "absolute",
|
|
639
|
+
inset: 0,
|
|
640
|
+
opacity: state === "pending" ? PENDING_MARK_OPACITY : 1,
|
|
641
|
+
filter: MARK_FILTER[state],
|
|
642
|
+
transition: `opacity ${CARD_SETTLE_MS}ms ease, filter ${CARD_SETTLE_MS}ms ease`
|
|
643
|
+
},
|
|
644
|
+
children
|
|
645
|
+
}
|
|
646
|
+
)
|
|
647
|
+
]
|
|
648
|
+
}
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
// src/agent/presence/source-cards/card-marks.tsx
|
|
653
|
+
import * as React5 from "react";
|
|
654
|
+
import { useGenerationStyle } from "@40rty/ams-sdk";
|
|
655
|
+
import { Fragment as Fragment2, jsx as jsx7 } from "react/jsx-runtime";
|
|
656
|
+
function SourceImage({
|
|
657
|
+
imageUrl,
|
|
658
|
+
caption
|
|
659
|
+
}) {
|
|
660
|
+
const generation = useGenerationStyle();
|
|
661
|
+
const [broken, setBroken] = React5.useState(false);
|
|
662
|
+
const [loaded, setLoaded] = React5.useState(false);
|
|
663
|
+
const usable = imageUrl !== void 0 && imageUrl.length > 0 && !broken;
|
|
664
|
+
const ref = React5.useCallback((node) => {
|
|
665
|
+
if (node !== null && node.complete && node.naturalWidth > 0) setLoaded(true);
|
|
666
|
+
}, []);
|
|
667
|
+
if (!usable) return /* @__PURE__ */ jsx7(Fragment2, { children: caption });
|
|
668
|
+
const blurUp = generation.image === "blur-up";
|
|
669
|
+
const seconds = generation.timings.imageResolveS;
|
|
670
|
+
return /* @__PURE__ */ jsx7(
|
|
671
|
+
"img",
|
|
672
|
+
{
|
|
673
|
+
ref,
|
|
674
|
+
className: sourceCardClass.image,
|
|
675
|
+
src: imageUrl,
|
|
676
|
+
alt: "",
|
|
677
|
+
decoding: "async",
|
|
678
|
+
onLoad: () => setLoaded(true),
|
|
679
|
+
onError: () => setBroken(true),
|
|
680
|
+
style: {
|
|
681
|
+
width: "100%",
|
|
682
|
+
height: "100%",
|
|
683
|
+
objectFit: "cover",
|
|
684
|
+
display: "block",
|
|
685
|
+
opacity: loaded ? 1 : 0,
|
|
686
|
+
filter: blurUp && !loaded ? "blur(4px)" : "blur(0px)",
|
|
687
|
+
transition: `opacity ${seconds}s ease-out, filter ${seconds}s ease-out`
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
function CaptionRule({ width, height }) {
|
|
693
|
+
return /* @__PURE__ */ jsx7(
|
|
694
|
+
"span",
|
|
695
|
+
{
|
|
696
|
+
"aria-hidden": true,
|
|
697
|
+
style: {
|
|
698
|
+
position: "absolute",
|
|
699
|
+
left: "50%",
|
|
700
|
+
bottom: Math.max(4, Math.round(height * 0.16)),
|
|
701
|
+
width: Math.round(width * 0.46),
|
|
702
|
+
height: 1,
|
|
703
|
+
transform: "translateX(-50%)",
|
|
704
|
+
background: ink(26)
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
function RuledLines({
|
|
710
|
+
lines,
|
|
711
|
+
headline
|
|
712
|
+
}) {
|
|
713
|
+
return /* @__PURE__ */ jsx7(
|
|
714
|
+
"div",
|
|
715
|
+
{
|
|
716
|
+
className: sourceCardClass.rules,
|
|
717
|
+
style: {
|
|
718
|
+
display: "flex",
|
|
719
|
+
flexDirection: "column",
|
|
720
|
+
justifyContent: "space-between",
|
|
721
|
+
height: "100%",
|
|
722
|
+
width: "100%"
|
|
723
|
+
},
|
|
724
|
+
children: lines.map((line, i) => /* @__PURE__ */ jsx7(
|
|
725
|
+
"span",
|
|
726
|
+
{
|
|
727
|
+
className: sourceCardClass.rule,
|
|
728
|
+
style: {
|
|
729
|
+
width: `${Math.round(line.width * 100)}%`,
|
|
730
|
+
height: line.weight,
|
|
731
|
+
background: ink(i === 0 && headline ? 46 : 30),
|
|
732
|
+
marginBottom: i === 0 && headline ? 2 : 0
|
|
733
|
+
}
|
|
734
|
+
},
|
|
735
|
+
`${i}-${line.width}-${line.weight}`
|
|
736
|
+
))
|
|
737
|
+
}
|
|
738
|
+
);
|
|
739
|
+
}
|
|
740
|
+
function CornerFold({ width, fold }) {
|
|
741
|
+
const length = Math.round(fold * Math.SQRT2);
|
|
742
|
+
return /* @__PURE__ */ jsx7(
|
|
743
|
+
"span",
|
|
744
|
+
{
|
|
745
|
+
"aria-hidden": true,
|
|
746
|
+
className: sourceCardClass.fold,
|
|
747
|
+
style: {
|
|
748
|
+
position: "absolute",
|
|
749
|
+
left: Math.round(width - fold / 2 - length / 2),
|
|
750
|
+
top: Math.round(fold / 2),
|
|
751
|
+
width: length,
|
|
752
|
+
height: 1,
|
|
753
|
+
background: ink(34),
|
|
754
|
+
transform: "rotate(45deg)"
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
);
|
|
758
|
+
}
|
|
759
|
+
var STAR_PATH = "M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z";
|
|
760
|
+
function RatingStars({
|
|
761
|
+
width,
|
|
762
|
+
score,
|
|
763
|
+
count = 5
|
|
764
|
+
}) {
|
|
765
|
+
const gap = Math.max(1, Math.round(width * 0.05));
|
|
766
|
+
const star = Math.max(4, Math.floor((width - gap * (count - 1)) / count));
|
|
767
|
+
const filled = score === void 0 ? 0 : Math.min(count, Math.max(0, Math.round(score)));
|
|
768
|
+
return /* @__PURE__ */ jsx7("div", { className: sourceCardClass.pips, style: { display: "flex", gap, flexShrink: 0 }, children: Array.from({ length: count }, (_, i) => /* @__PURE__ */ jsx7(
|
|
769
|
+
"svg",
|
|
770
|
+
{
|
|
771
|
+
className: sourceCardClass.pip,
|
|
772
|
+
"data-filled": i < filled ? "true" : "false",
|
|
773
|
+
width: star,
|
|
774
|
+
height: star,
|
|
775
|
+
viewBox: "0 0 24 24",
|
|
776
|
+
"aria-hidden": true,
|
|
777
|
+
style: { display: "block", flexShrink: 0 },
|
|
778
|
+
children: /* @__PURE__ */ jsx7(
|
|
779
|
+
"path",
|
|
780
|
+
{
|
|
781
|
+
d: STAR_PATH,
|
|
782
|
+
fill: i < filled ? ink(82) : "none",
|
|
783
|
+
stroke: i < filled ? "none" : ink(46),
|
|
784
|
+
strokeWidth: 2.4,
|
|
785
|
+
strokeLinejoin: "round"
|
|
786
|
+
}
|
|
787
|
+
)
|
|
788
|
+
},
|
|
789
|
+
i
|
|
790
|
+
)) });
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
// src/agent/presence/source-cards/ProductSourceCard.tsx
|
|
794
|
+
import * as React6 from "react";
|
|
795
|
+
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
796
|
+
var ProductSourceCard = React6.forwardRef(
|
|
797
|
+
function ProductSourceCard2({
|
|
798
|
+
source,
|
|
799
|
+
sourceKind,
|
|
800
|
+
size,
|
|
801
|
+
found,
|
|
802
|
+
pending,
|
|
803
|
+
chosen
|
|
804
|
+
}, ref) {
|
|
805
|
+
const box = sourceCardBox(size);
|
|
806
|
+
const state = sourceCardState(found, pending, chosen);
|
|
807
|
+
const imageUrl = source === void 0 ? void 0 : source.imageUrl;
|
|
808
|
+
return /* @__PURE__ */ jsx8(SourceCardFrame, { ref, kind: sourceKind, state, size, children: /* @__PURE__ */ jsx8(SourcePlate, { width: box.width, height: box.height, state, mark: true, children: /* @__PURE__ */ jsx8(
|
|
809
|
+
SourceImage,
|
|
810
|
+
{
|
|
811
|
+
imageUrl,
|
|
812
|
+
caption: /* @__PURE__ */ jsx8(CaptionRule, { width: box.width, height: box.height })
|
|
813
|
+
}
|
|
814
|
+
) }) });
|
|
815
|
+
}
|
|
816
|
+
);
|
|
817
|
+
var productSourceForm = {
|
|
818
|
+
Component: ProductSourceCard
|
|
819
|
+
};
|
|
820
|
+
|
|
821
|
+
// src/agent/presence/source-cards/CollectionSourceCard.tsx
|
|
822
|
+
import * as React7 from "react";
|
|
823
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
824
|
+
var STEP_RATIO = 0.1;
|
|
825
|
+
var CollectionSourceCard = React7.forwardRef(
|
|
826
|
+
function CollectionSourceCard2({
|
|
827
|
+
source,
|
|
828
|
+
sourceKind,
|
|
829
|
+
size,
|
|
830
|
+
found,
|
|
831
|
+
pending,
|
|
832
|
+
chosen
|
|
833
|
+
}, ref) {
|
|
834
|
+
const box = sourceCardBox(size);
|
|
835
|
+
const state = sourceCardState(found, pending, chosen);
|
|
836
|
+
const stepX = Math.max(2, Math.round(box.width * STEP_RATIO));
|
|
837
|
+
const stepY = Math.max(2, Math.round(box.height * STEP_RATIO));
|
|
838
|
+
const face = { width: box.width - stepX * 2, height: box.height - stepY * 2 };
|
|
839
|
+
const missed = state === "missed";
|
|
840
|
+
const imageUrl = source === void 0 ? void 0 : source.imageUrl;
|
|
841
|
+
const hairline = ink(30);
|
|
842
|
+
return /* @__PURE__ */ jsxs4(SourceCardFrame, { ref, kind: sourceKind, state, size, children: [
|
|
843
|
+
(missed ? [1] : [2, 1]).map((depth) => /* @__PURE__ */ jsx9(
|
|
844
|
+
SourcePlate,
|
|
845
|
+
{
|
|
846
|
+
width: face.width,
|
|
847
|
+
height: face.height,
|
|
848
|
+
state,
|
|
849
|
+
mark: false,
|
|
850
|
+
style: {
|
|
851
|
+
left: stepX * depth,
|
|
852
|
+
top: stepY * depth,
|
|
853
|
+
opacity: 1 - depth * 0.28,
|
|
854
|
+
zIndex: 0
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
depth
|
|
858
|
+
)),
|
|
859
|
+
/* @__PURE__ */ jsxs4(SourcePlate, { width: face.width, height: face.height, state, mark: true, style: { zIndex: 1 }, children: [
|
|
860
|
+
/* @__PURE__ */ jsx9(SourceImage, { imageUrl, caption: null }),
|
|
861
|
+
/* @__PURE__ */ jsx9(
|
|
862
|
+
"span",
|
|
863
|
+
{
|
|
864
|
+
"aria-hidden": true,
|
|
865
|
+
style: { position: "absolute", left: 0, top: "50%", width: "100%", height: 1, background: hairline }
|
|
866
|
+
}
|
|
867
|
+
),
|
|
868
|
+
/* @__PURE__ */ jsx9(
|
|
869
|
+
"span",
|
|
870
|
+
{
|
|
871
|
+
"aria-hidden": true,
|
|
872
|
+
style: { position: "absolute", top: 0, left: "50%", height: "100%", width: 1, background: hairline }
|
|
873
|
+
}
|
|
874
|
+
)
|
|
875
|
+
] })
|
|
876
|
+
] });
|
|
877
|
+
}
|
|
878
|
+
);
|
|
879
|
+
var collectionSourceForm = {
|
|
880
|
+
Component: CollectionSourceCard
|
|
881
|
+
};
|
|
882
|
+
|
|
883
|
+
// src/agent/presence/source-cards/ArticleSourceCard.tsx
|
|
884
|
+
import * as React8 from "react";
|
|
885
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
886
|
+
function articleLines(size, weight) {
|
|
887
|
+
const headline = { width: 0.68, weight: weight + 1 };
|
|
888
|
+
const closer = { width: 0.44, weight };
|
|
889
|
+
if (size === "compact") {
|
|
890
|
+
return [headline, { width: 1, weight }, { width: 0.92, weight }, closer];
|
|
891
|
+
}
|
|
892
|
+
return [
|
|
893
|
+
headline,
|
|
894
|
+
{ width: 1, weight },
|
|
895
|
+
{ width: 1, weight },
|
|
896
|
+
{ width: 0.92, weight },
|
|
897
|
+
{ width: 1, weight },
|
|
898
|
+
closer
|
|
899
|
+
];
|
|
900
|
+
}
|
|
901
|
+
var ArticleSourceCard = React8.forwardRef(
|
|
902
|
+
function ArticleSourceCard2({
|
|
903
|
+
sourceKind,
|
|
904
|
+
size,
|
|
905
|
+
found,
|
|
906
|
+
pending,
|
|
907
|
+
chosen
|
|
908
|
+
}, ref) {
|
|
909
|
+
const box = sourceCardBox(size);
|
|
910
|
+
const state = sourceCardState(found, pending, chosen);
|
|
911
|
+
const pad = platePad(box.width);
|
|
912
|
+
return /* @__PURE__ */ jsx10(SourceCardFrame, { ref, kind: sourceKind, state, size, children: /* @__PURE__ */ jsx10(SourcePlate, { width: box.width, height: box.height, state, mark: true, children: /* @__PURE__ */ jsx10("div", { style: { position: "absolute", inset: pad }, children: /* @__PURE__ */ jsx10(RuledLines, { lines: articleLines(size, ruleWeight(size)), headline: true }) }) }) });
|
|
913
|
+
}
|
|
914
|
+
);
|
|
915
|
+
var articleSourceForm = {
|
|
916
|
+
Component: ArticleSourceCard
|
|
917
|
+
};
|
|
918
|
+
|
|
919
|
+
// src/agent/presence/source-cards/PolicySourceCard.tsx
|
|
920
|
+
import * as React9 from "react";
|
|
921
|
+
import { jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
922
|
+
var FOLD_RATIO = 0.32;
|
|
923
|
+
function policyLines(weight) {
|
|
924
|
+
return [
|
|
925
|
+
{ width: 0.72, weight },
|
|
926
|
+
{ width: 0.94, weight },
|
|
927
|
+
{ width: 0.5, weight }
|
|
928
|
+
];
|
|
929
|
+
}
|
|
930
|
+
var PolicySourceCard = React9.forwardRef(
|
|
931
|
+
function PolicySourceCard2({
|
|
932
|
+
sourceKind,
|
|
933
|
+
size,
|
|
934
|
+
found,
|
|
935
|
+
pending,
|
|
936
|
+
chosen
|
|
937
|
+
}, ref) {
|
|
938
|
+
const box = sourceCardBox(size);
|
|
939
|
+
const state = sourceCardState(found, pending, chosen);
|
|
940
|
+
const pad = platePad(box.width);
|
|
941
|
+
const fold = Math.max(5, Math.round(box.width * FOLD_RATIO));
|
|
942
|
+
return /* @__PURE__ */ jsxs5(SourceCardFrame, { ref, kind: sourceKind, state, size, children: [
|
|
943
|
+
/* @__PURE__ */ jsx11(
|
|
944
|
+
SourcePlate,
|
|
945
|
+
{
|
|
946
|
+
width: box.width,
|
|
947
|
+
height: box.height,
|
|
948
|
+
state,
|
|
949
|
+
mark: true,
|
|
950
|
+
style: {
|
|
951
|
+
clipPath: `polygon(0 0, ${box.width - fold}px 0, ${box.width}px ${fold}px, ${box.width}px ${box.height}px, 0 ${box.height}px)`
|
|
952
|
+
},
|
|
953
|
+
children: /* @__PURE__ */ jsx11("div", { style: { position: "absolute", left: pad, right: pad, top: fold + pad, bottom: pad }, children: /* @__PURE__ */ jsx11(RuledLines, { lines: policyLines(ruleWeight(size)), headline: false }) })
|
|
954
|
+
}
|
|
955
|
+
),
|
|
956
|
+
/* @__PURE__ */ jsx11(CornerFold, { width: box.width, fold })
|
|
957
|
+
] });
|
|
958
|
+
}
|
|
959
|
+
);
|
|
960
|
+
var policySourceForm = {
|
|
961
|
+
Component: PolicySourceCard
|
|
962
|
+
};
|
|
963
|
+
|
|
964
|
+
// src/agent/presence/source-cards/ReviewSourceCard.tsx
|
|
965
|
+
import * as React10 from "react";
|
|
966
|
+
|
|
967
|
+
// src/agent/presence/source-cards/review-passage.ts
|
|
968
|
+
function str(value) {
|
|
969
|
+
return typeof value === "string" ? value : "";
|
|
970
|
+
}
|
|
971
|
+
function splitPassage(excerpt, passage) {
|
|
972
|
+
if (excerpt.length === 0) return [];
|
|
973
|
+
if (passage.length === 0) return [{ text: excerpt, marked: false }];
|
|
974
|
+
const hay = excerpt.toLowerCase();
|
|
975
|
+
const needle = passage.toLowerCase();
|
|
976
|
+
if (hay.length !== excerpt.length || needle.length !== passage.length) {
|
|
977
|
+
return [{ text: excerpt, marked: false }];
|
|
978
|
+
}
|
|
979
|
+
const runs = [];
|
|
980
|
+
let from = 0;
|
|
981
|
+
for (; ; ) {
|
|
982
|
+
const at = hay.indexOf(needle, from);
|
|
983
|
+
if (at < 0) break;
|
|
984
|
+
if (at > from) runs.push({ text: excerpt.slice(from, at), marked: false });
|
|
985
|
+
runs.push({ text: excerpt.slice(at, at + needle.length), marked: true });
|
|
986
|
+
from = at + needle.length;
|
|
987
|
+
}
|
|
988
|
+
if (runs.length === 0) return [{ text: excerpt, marked: false }];
|
|
989
|
+
if (from < excerpt.length) runs.push({ text: excerpt.slice(from), marked: false });
|
|
990
|
+
return runs;
|
|
991
|
+
}
|
|
992
|
+
function dwellFor(step, base) {
|
|
993
|
+
const SWING = [0, -0.28, 0.22, -0.16, 0.3, -0.1];
|
|
994
|
+
const swing = SWING[step % SWING.length];
|
|
995
|
+
return Math.round(base * (1 + (swing === void 0 ? 0 : swing)));
|
|
996
|
+
}
|
|
997
|
+
function reviewPassages(refs) {
|
|
998
|
+
const passages = [];
|
|
999
|
+
for (const ref of refs) {
|
|
1000
|
+
if (ref.meta === void 0) continue;
|
|
1001
|
+
const located = str(ref.meta.excerpt);
|
|
1002
|
+
const excerpt = located.length > 0 ? located : str(ref.meta.content);
|
|
1003
|
+
if (excerpt.length === 0) continue;
|
|
1004
|
+
const passage = {
|
|
1005
|
+
key: ref.id,
|
|
1006
|
+
runs: splitPassage(excerpt, str(ref.meta.mark))
|
|
1007
|
+
};
|
|
1008
|
+
const rating = ref.meta.rating;
|
|
1009
|
+
if (typeof rating === "number" && Number.isFinite(rating)) passage.rating = rating;
|
|
1010
|
+
if (ref.imageUrl !== void 0 && ref.imageUrl.length > 0) passage.imageUrl = ref.imageUrl;
|
|
1011
|
+
passages.push(passage);
|
|
1012
|
+
}
|
|
1013
|
+
return passages;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
// src/agent/presence/source-cards/ReviewSourceCard.tsx
|
|
1017
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1018
|
+
var REVIEW_SLOTS = 5;
|
|
1019
|
+
var COLUMN_MAX = 5;
|
|
1020
|
+
var COLUMN_DWELL_MS = 900;
|
|
1021
|
+
var LINE_H = 12;
|
|
1022
|
+
var COLUMN_LINES = 2;
|
|
1023
|
+
var ROW_GAP = 3;
|
|
1024
|
+
var STAR_ROW_W = 64;
|
|
1025
|
+
var THUMB_W = 30;
|
|
1026
|
+
var THUMB_GAP = 8;
|
|
1027
|
+
function reviewLines(weight) {
|
|
1028
|
+
return [
|
|
1029
|
+
{ width: 1, weight },
|
|
1030
|
+
{ width: 0.88, weight },
|
|
1031
|
+
{ width: 0.52, weight }
|
|
1032
|
+
];
|
|
1033
|
+
}
|
|
1034
|
+
function Passage({ passage }) {
|
|
1035
|
+
return /* @__PURE__ */ jsx12(
|
|
1036
|
+
"p",
|
|
1037
|
+
{
|
|
1038
|
+
style: {
|
|
1039
|
+
margin: 0,
|
|
1040
|
+
height: LINE_H * COLUMN_LINES,
|
|
1041
|
+
overflow: "hidden",
|
|
1042
|
+
fontSize: 10,
|
|
1043
|
+
lineHeight: `${LINE_H}px`,
|
|
1044
|
+
color: ink(76),
|
|
1045
|
+
wordBreak: "break-word"
|
|
1046
|
+
},
|
|
1047
|
+
children: passage.runs.map((run, i) => /* @__PURE__ */ jsx12(
|
|
1048
|
+
"span",
|
|
1049
|
+
{
|
|
1050
|
+
"data-marked": run.marked ? "true" : "false",
|
|
1051
|
+
style: run.marked ? {
|
|
1052
|
+
background: ink(26),
|
|
1053
|
+
boxShadow: `0 1px 0 0 ${ink(62)}`,
|
|
1054
|
+
color: ink(100),
|
|
1055
|
+
borderRadius: 1
|
|
1056
|
+
} : void 0,
|
|
1057
|
+
children: run.text
|
|
1058
|
+
},
|
|
1059
|
+
i
|
|
1060
|
+
))
|
|
1061
|
+
}
|
|
1062
|
+
);
|
|
1063
|
+
}
|
|
1064
|
+
function useRead(count, still) {
|
|
1065
|
+
const [at, setAt] = React10.useState(0);
|
|
1066
|
+
React10.useEffect(() => {
|
|
1067
|
+
if (still || count <= 1) return;
|
|
1068
|
+
const last = Math.min(count, COLUMN_MAX) - 1;
|
|
1069
|
+
if (at >= last) return;
|
|
1070
|
+
const timer = setTimeout(() => setAt((n) => Math.min(n + 1, last)), dwellFor(at, COLUMN_DWELL_MS));
|
|
1071
|
+
return () => clearTimeout(timer);
|
|
1072
|
+
}, [count, still, at]);
|
|
1073
|
+
return Math.min(at, Math.max(0, Math.min(count, COLUMN_MAX) - 1));
|
|
1074
|
+
}
|
|
1075
|
+
var ReviewSourceCard = React10.forwardRef(
|
|
1076
|
+
function ReviewSourceCard2({ source, records, sourceKind, size, found, pending, chosen }, ref) {
|
|
1077
|
+
const box = sourceCardSpan(size, REVIEW_SLOTS);
|
|
1078
|
+
const state = sourceCardState(found, pending, chosen);
|
|
1079
|
+
const pad = platePad(box.height);
|
|
1080
|
+
const interior = box.height - pad * 2;
|
|
1081
|
+
const still = useReducedMotion() === true;
|
|
1082
|
+
const set = records !== void 0 ? records : source === void 0 ? [] : [source];
|
|
1083
|
+
const passages = reviewPassages(set);
|
|
1084
|
+
const at = useRead(passages.length, still);
|
|
1085
|
+
const current = passages.length > 0 ? passages[at] : void 0;
|
|
1086
|
+
const viewport = LINE_H * COLUMN_LINES;
|
|
1087
|
+
const framed = passages.some((passage) => passage.imageUrl !== void 0);
|
|
1088
|
+
const thumb = current === void 0 ? void 0 : current.imageUrl;
|
|
1089
|
+
return /* @__PURE__ */ jsx12(SourceCardFrame, { ref, kind: sourceKind, state, size, slots: REVIEW_SLOTS, children: /* @__PURE__ */ jsx12(SourcePlate, { width: box.width, height: box.height, state, mark: true, children: /* @__PURE__ */ jsxs6("div", { style: { position: "absolute", inset: pad, display: "flex", gap: THUMB_GAP }, children: [
|
|
1090
|
+
framed && /* @__PURE__ */ jsx12("div", { style: { width: THUMB_W, height: interior, flexShrink: 0 }, children: thumb !== void 0 && /* @__PURE__ */ jsx12(
|
|
1091
|
+
"img",
|
|
1092
|
+
{
|
|
1093
|
+
src: thumb,
|
|
1094
|
+
alt: "",
|
|
1095
|
+
decoding: "async",
|
|
1096
|
+
style: {
|
|
1097
|
+
width: THUMB_W,
|
|
1098
|
+
height: interior,
|
|
1099
|
+
objectFit: "cover",
|
|
1100
|
+
display: "block",
|
|
1101
|
+
// Drained like every other undecided candidate on the row
|
|
1102
|
+
// — colour on this surface means "this became the
|
|
1103
|
+
// answer", and a review is not the answer, it is what the
|
|
1104
|
+
// answer was read out of.
|
|
1105
|
+
filter: state === "chosen" ? "none" : "grayscale(1)",
|
|
1106
|
+
boxShadow: `inset 0 0 0 1px ${ink(20)}`
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
) }),
|
|
1110
|
+
/* @__PURE__ */ jsxs6("div", { style: { flex: 1, minWidth: 0, display: "flex", flexDirection: "column", gap: ROW_GAP }, children: [
|
|
1111
|
+
/* @__PURE__ */ jsx12(
|
|
1112
|
+
RatingStars,
|
|
1113
|
+
{
|
|
1114
|
+
width: STAR_ROW_W,
|
|
1115
|
+
score: current === void 0 ? void 0 : current.rating
|
|
1116
|
+
}
|
|
1117
|
+
),
|
|
1118
|
+
passages.length === 0 ? (
|
|
1119
|
+
// Nothing to read: a lookup still running, a miss, or records
|
|
1120
|
+
// the tool returned without prose. The ruled lines are the same
|
|
1121
|
+
// statement the card has always made — "somebody's few
|
|
1122
|
+
// sentences about a thing" — with nothing invented to fill them.
|
|
1123
|
+
/* @__PURE__ */ jsx12("div", { style: { flex: 1, minHeight: 0 }, children: /* @__PURE__ */ jsx12(RuledLines, { lines: reviewLines(ruleWeight(size)), headline: false }) })
|
|
1124
|
+
) : /* @__PURE__ */ jsx12("div", { style: { height: viewport, overflow: "hidden", position: "relative" }, children: /* @__PURE__ */ jsx12(
|
|
1125
|
+
motion.div,
|
|
1126
|
+
{
|
|
1127
|
+
animate: { y: -at * viewport },
|
|
1128
|
+
initial: false,
|
|
1129
|
+
transition: still ? { duration: 0 } : { duration: 0.42, ease: CARD_EASE },
|
|
1130
|
+
children: passages.slice(0, COLUMN_MAX).map((passage) => /* @__PURE__ */ jsx12(Passage, { passage }, passage.key))
|
|
1131
|
+
}
|
|
1132
|
+
) })
|
|
1133
|
+
] })
|
|
1134
|
+
] }) }) });
|
|
1135
|
+
}
|
|
1136
|
+
);
|
|
1137
|
+
var reviewSourceForm = {
|
|
1138
|
+
Component: ReviewSourceCard,
|
|
1139
|
+
// One column per lookup, never one card per review: the discovery in a body
|
|
1140
|
+
// of text is what was found INSIDE it, and eight 42px cards of prose is
|
|
1141
|
+
// texture. `spreads: false` is the deck's own rule stated explicitly rather
|
|
1142
|
+
// than fallen into by having no imagery.
|
|
1143
|
+
spreads: () => false,
|
|
1144
|
+
slots: REVIEW_SLOTS
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
// src/agent/presence/source-cards/register.tsx
|
|
1148
|
+
import { registerPresenceSourceForm } from "@40rty/ams-sdk";
|
|
1149
|
+
var BASELINE_SOURCE_KINDS = ["product", "collection", "article", "policy", "review"];
|
|
1150
|
+
var registered = false;
|
|
1151
|
+
function registerDefaultPresenceSourceForms() {
|
|
1152
|
+
if (registered) return;
|
|
1153
|
+
registered = true;
|
|
1154
|
+
registerPresenceSourceForm("product", productSourceForm);
|
|
1155
|
+
registerPresenceSourceForm("collection", collectionSourceForm);
|
|
1156
|
+
registerPresenceSourceForm("article", articleSourceForm);
|
|
1157
|
+
registerPresenceSourceForm("policy", policySourceForm);
|
|
1158
|
+
registerPresenceSourceForm("review", reviewSourceForm);
|
|
1159
|
+
}
|
|
1160
|
+
registerDefaultPresenceSourceForms();
|
|
1161
|
+
|
|
1162
|
+
// src/agent/presence/source-cards/SourceCard.tsx
|
|
1163
|
+
import * as React11 from "react";
|
|
1164
|
+
import { resolvePresenceSourceForm } from "@40rty/ams-sdk";
|
|
1165
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1166
|
+
var PresenceSourceCard = React11.forwardRef(function PresenceSourceCard2({ source, records, sourceKind, size, found, pending, chosen }, ref) {
|
|
1167
|
+
const def = resolvePresenceSourceForm(sourceKind);
|
|
1168
|
+
if (def === void 0) return null;
|
|
1169
|
+
const { Component } = def;
|
|
1170
|
+
return /* @__PURE__ */ jsx13(
|
|
1171
|
+
Component,
|
|
1172
|
+
{
|
|
1173
|
+
ref,
|
|
1174
|
+
source,
|
|
1175
|
+
records,
|
|
1176
|
+
sourceKind,
|
|
1177
|
+
size,
|
|
1178
|
+
found,
|
|
1179
|
+
pending,
|
|
1180
|
+
chosen
|
|
1181
|
+
}
|
|
1182
|
+
);
|
|
1183
|
+
});
|
|
1184
|
+
|
|
1185
|
+
// src/agent/presence/SourceSift.tsx
|
|
1186
|
+
import * as React12 from "react";
|
|
1187
|
+
|
|
1188
|
+
// src/agent/presence/sift-deck.ts
|
|
1189
|
+
import { resolvePresenceSourceForm as resolvePresenceSourceForm2 } from "@40rty/ams-sdk";
|
|
1190
|
+
|
|
1191
|
+
// src/agent/presence/cite-image.ts
|
|
1192
|
+
function picturesOf(sources) {
|
|
1193
|
+
const pictures = /* @__PURE__ */ new Map();
|
|
1194
|
+
for (const element of sources) {
|
|
1195
|
+
for (const ref of element.refs) {
|
|
1196
|
+
if (ref.imageUrl !== void 0 && ref.imageUrl.length > 0) pictures.set(ref.id, ref.imageUrl);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return pictures;
|
|
1200
|
+
}
|
|
1201
|
+
function withCitedImages(refs, sources) {
|
|
1202
|
+
const pictures = picturesOf(sources);
|
|
1203
|
+
if (pictures.size === 0) return [...refs];
|
|
1204
|
+
return refs.map((ref) => {
|
|
1205
|
+
if (ref.imageUrl !== void 0 && ref.imageUrl.length > 0) return ref;
|
|
1206
|
+
if (ref.meta === void 0) return ref;
|
|
1207
|
+
for (const value of Object.values(ref.meta)) {
|
|
1208
|
+
if (typeof value !== "string") continue;
|
|
1209
|
+
const cited = pictures.get(value);
|
|
1210
|
+
if (cited !== void 0) return { ...ref, imageUrl: cited };
|
|
1211
|
+
}
|
|
1212
|
+
return ref;
|
|
1213
|
+
});
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
// src/agent/presence/sift-deck.ts
|
|
1217
|
+
function drawableRefs(element) {
|
|
1218
|
+
const form = resolvePresenceSourceForm2(element.sourceKind);
|
|
1219
|
+
const spreads = form !== void 0 && form.spreads !== void 0 ? form.spreads : (ref) => ref.imageUrl !== void 0 && ref.imageUrl.length > 0;
|
|
1220
|
+
return element.refs.filter((ref) => spreads(ref));
|
|
1221
|
+
}
|
|
1222
|
+
var RANK = {
|
|
1223
|
+
chosen: 0,
|
|
1224
|
+
sifting: 0,
|
|
1225
|
+
pending: 1,
|
|
1226
|
+
missed: 2
|
|
1227
|
+
};
|
|
1228
|
+
function slotsOf(sourceKind) {
|
|
1229
|
+
const form = resolvePresenceSourceForm2(sourceKind);
|
|
1230
|
+
if (form === void 0 || form.slots === void 0) return 1;
|
|
1231
|
+
return Math.max(1, Math.round(form.slots));
|
|
1232
|
+
}
|
|
1233
|
+
function cardsOf(element, materialized, sources) {
|
|
1234
|
+
const slots = slotsOf(element.sourceKind);
|
|
1235
|
+
if (element.pending === true) {
|
|
1236
|
+
return [{ key: element.id, sourceKind: element.sourceKind, state: "pending", slots, lookupId: element.id }];
|
|
1237
|
+
}
|
|
1238
|
+
if (!element.found) {
|
|
1239
|
+
return [{ key: element.id, sourceKind: element.sourceKind, state: "missed", slots, lookupId: element.id }];
|
|
1240
|
+
}
|
|
1241
|
+
const drawable = drawableRefs(element);
|
|
1242
|
+
if (drawable.length > 0) {
|
|
1243
|
+
return drawable.map((ref) => ({
|
|
1244
|
+
key: ref.id,
|
|
1245
|
+
sourceKind: element.sourceKind,
|
|
1246
|
+
ref,
|
|
1247
|
+
state: materialized.has(ref.id) ? "chosen" : "sifting",
|
|
1248
|
+
slots,
|
|
1249
|
+
lookupId: element.id
|
|
1250
|
+
}));
|
|
1251
|
+
}
|
|
1252
|
+
const card = {
|
|
1253
|
+
key: element.id,
|
|
1254
|
+
sourceKind: element.sourceKind,
|
|
1255
|
+
state: element.face !== void 0 && materialized.has(element.face.id) ? "chosen" : "sifting",
|
|
1256
|
+
slots,
|
|
1257
|
+
lookupId: element.id,
|
|
1258
|
+
// The whole set, because this card is the whole lookup. A form that only
|
|
1259
|
+
// draws a silhouette ignores it; a form that READS needs it — with the
|
|
1260
|
+
// pictures its records cite filled in, so a review can show WHAT is being
|
|
1261
|
+
// reviewed when the turn already looked it up.
|
|
1262
|
+
records: withCitedImages(element.refs, sources)
|
|
1263
|
+
};
|
|
1264
|
+
if (element.face !== void 0) card.ref = element.face;
|
|
1265
|
+
return [card];
|
|
1266
|
+
}
|
|
1267
|
+
function siftDeck(sources, materialized, limit, admitted) {
|
|
1268
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
1269
|
+
const arrival = [];
|
|
1270
|
+
let read = 0;
|
|
1271
|
+
for (const element of sources) {
|
|
1272
|
+
if (element.pending !== true && element.found) {
|
|
1273
|
+
read += element.total !== void 0 ? element.total : element.refs.length;
|
|
1274
|
+
}
|
|
1275
|
+
for (const card of cardsOf(element, materialized, sources)) {
|
|
1276
|
+
if (!byKey.has(card.key)) arrival.push(card.key);
|
|
1277
|
+
byKey.set(card.key, card);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
const ordered = arrival.map((key, index) => ({ key, index, admitted: admitted !== void 0 && admitted.has(key) })).sort((a, b) => {
|
|
1281
|
+
if (a.admitted && b.admitted) return a.index - b.index;
|
|
1282
|
+
if (a.admitted !== b.admitted) return a.admitted ? -1 : 1;
|
|
1283
|
+
const ca = byKey.get(a.key);
|
|
1284
|
+
const cb = byKey.get(b.key);
|
|
1285
|
+
if (ca === void 0 || cb === void 0) return a.index - b.index;
|
|
1286
|
+
const rank2 = RANK[ca.state] - RANK[cb.state];
|
|
1287
|
+
return rank2 !== 0 ? rank2 : a.index - b.index;
|
|
1288
|
+
});
|
|
1289
|
+
const queues = /* @__PURE__ */ new Map();
|
|
1290
|
+
for (const entry of ordered) {
|
|
1291
|
+
const card = byKey.get(entry.key);
|
|
1292
|
+
if (card === void 0) continue;
|
|
1293
|
+
const queue = queues.get(card.lookupId);
|
|
1294
|
+
if (queue === void 0) queues.set(card.lookupId, [entry.key]);
|
|
1295
|
+
else queue.push(entry.key);
|
|
1296
|
+
}
|
|
1297
|
+
const cards = [];
|
|
1298
|
+
let drawn = 0;
|
|
1299
|
+
let spent = 0;
|
|
1300
|
+
if (admitted !== void 0) for (const slots of admitted.values()) spent += slots;
|
|
1301
|
+
const lanes = [...queues.values()];
|
|
1302
|
+
for (let round = 0; ; round += 1) {
|
|
1303
|
+
let dealt = false;
|
|
1304
|
+
for (const lane of lanes) {
|
|
1305
|
+
const key = lane[round];
|
|
1306
|
+
if (key === void 0) continue;
|
|
1307
|
+
dealt = true;
|
|
1308
|
+
const card = byKey.get(key);
|
|
1309
|
+
if (card === void 0) continue;
|
|
1310
|
+
const seen = admitted !== void 0 && admitted.has(card.key);
|
|
1311
|
+
if (!seen && (admitted === void 0 ? drawn : spent) + card.slots > limit) continue;
|
|
1312
|
+
if (drawn + card.slots > limit) continue;
|
|
1313
|
+
cards.push(card);
|
|
1314
|
+
drawn += card.slots;
|
|
1315
|
+
}
|
|
1316
|
+
if (!dealt) break;
|
|
1317
|
+
}
|
|
1318
|
+
const rank = new Map(ordered.map((entry, index) => [entry.key, index]));
|
|
1319
|
+
cards.sort((a, b) => {
|
|
1320
|
+
const ra = rank.get(a.key);
|
|
1321
|
+
const rb = rank.get(b.key);
|
|
1322
|
+
return (ra === void 0 ? 0 : ra) - (rb === void 0 ? 0 : rb);
|
|
1323
|
+
});
|
|
1324
|
+
return { cards, read, overflow: Math.max(0, ordered.length - cards.length) };
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
// src/agent/presence/SourceSift.tsx
|
|
1328
|
+
import { jsx as jsx14, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1329
|
+
var SIFT_MAX_CARDS = {
|
|
1330
|
+
band: 8,
|
|
1331
|
+
compact: 5,
|
|
1332
|
+
foot: 8
|
|
1333
|
+
};
|
|
1334
|
+
var SIFT_TAIL_GAP = {
|
|
1335
|
+
band: 12,
|
|
1336
|
+
compact: 8,
|
|
1337
|
+
foot: 12
|
|
1338
|
+
};
|
|
1339
|
+
var SIFT_TAIL_WIDTH = 34;
|
|
1340
|
+
var SIFT_GATE_LANE = 21;
|
|
1341
|
+
var SIFT_PAD_Y = 9;
|
|
1342
|
+
var SIFT_BAND_HEIGHT = SOURCE_CARD_BOX.band.height + SIFT_PAD_Y * 2;
|
|
1343
|
+
function trackWidth(size) {
|
|
1344
|
+
const count = SIFT_MAX_CARDS[size];
|
|
1345
|
+
return SOURCE_CARD_BOX[size].width * count + SOURCE_CARD_GAP[size] * (count - 1);
|
|
1346
|
+
}
|
|
1347
|
+
function siftRegionWidth(size) {
|
|
1348
|
+
return SIFT_GATE_LANE + trackWidth(size) + SIFT_TAIL_GAP[size] + SIFT_TAIL_WIDTH;
|
|
1349
|
+
}
|
|
1350
|
+
function CriterionPass({ seq }) {
|
|
1351
|
+
if (seq === 0) return null;
|
|
1352
|
+
return /* @__PURE__ */ jsx14(
|
|
1353
|
+
motion.span,
|
|
1354
|
+
{
|
|
1355
|
+
"aria-hidden": true,
|
|
1356
|
+
className: presenceClass.siftPass,
|
|
1357
|
+
initial: { left: "-2%", opacity: 0 },
|
|
1358
|
+
animate: { left: "102%", opacity: [0, 1, 1, 0] },
|
|
1359
|
+
transition: { duration: 0.62, ease: "easeInOut", times: [0, 0.12, 0.8, 1] },
|
|
1360
|
+
style: {
|
|
1361
|
+
position: "absolute",
|
|
1362
|
+
top: -SIFT_PAD_Y + 3,
|
|
1363
|
+
bottom: -SIFT_PAD_Y + 3,
|
|
1364
|
+
width: 1,
|
|
1365
|
+
background: ink(70),
|
|
1366
|
+
pointerEvents: "none"
|
|
1367
|
+
}
|
|
1368
|
+
},
|
|
1369
|
+
seq
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
function SourceSift({
|
|
1373
|
+
sources,
|
|
1374
|
+
materialized,
|
|
1375
|
+
criteria = 0,
|
|
1376
|
+
size = "band",
|
|
1377
|
+
reserveTrack = false
|
|
1378
|
+
}) {
|
|
1379
|
+
const admitted = React12.useRef(/* @__PURE__ */ new Map());
|
|
1380
|
+
const deck = siftDeck(sources, materialized, SIFT_MAX_CARDS[size], admitted.current);
|
|
1381
|
+
for (const card of deck.cards) admitted.current.set(card.key, card.slots);
|
|
1382
|
+
const controls = useAnimationControls();
|
|
1383
|
+
const seen = React12.useRef(criteria);
|
|
1384
|
+
const [pass, setPass] = React12.useState(0);
|
|
1385
|
+
React12.useEffect(() => {
|
|
1386
|
+
if (criteria > seen.current) setPass((n) => n + 1);
|
|
1387
|
+
seen.current = criteria;
|
|
1388
|
+
}, [criteria]);
|
|
1389
|
+
React12.useEffect(() => {
|
|
1390
|
+
if (pass === 0) return;
|
|
1391
|
+
void controls.start({
|
|
1392
|
+
opacity: [1, 0.62, 1],
|
|
1393
|
+
transition: { duration: 0.62, ease: "easeInOut", times: [0, 0.34, 1] }
|
|
1394
|
+
});
|
|
1395
|
+
}, [pass, controls]);
|
|
1396
|
+
const lastRest = React12.useRef(0);
|
|
1397
|
+
const live = deck.cards.length > 0;
|
|
1398
|
+
const [resolving, setResolving] = React12.useState(false);
|
|
1399
|
+
React12.useEffect(() => {
|
|
1400
|
+
if (live) setResolving(true);
|
|
1401
|
+
}, [live]);
|
|
1402
|
+
if (!live && !resolving) return null;
|
|
1403
|
+
const rest = Math.max(0, deck.read - deck.cards.length);
|
|
1404
|
+
if (rest > 0) lastRest.current = rest;
|
|
1405
|
+
const shownRest = rest > 0 ? rest : lastRest.current;
|
|
1406
|
+
const tail = /* @__PURE__ */ jsx14(
|
|
1407
|
+
motion.span,
|
|
1408
|
+
{
|
|
1409
|
+
className: presenceClass.siftMore,
|
|
1410
|
+
style: { width: SIFT_TAIL_WIDTH },
|
|
1411
|
+
animate: { opacity: rest > 0 ? 1 : 0 },
|
|
1412
|
+
initial: false,
|
|
1413
|
+
transition: { duration: 0.28, ease: "easeOut" },
|
|
1414
|
+
children: shownRest > 0 ? `+${shownRest}` : ""
|
|
1415
|
+
}
|
|
1416
|
+
);
|
|
1417
|
+
return /* @__PURE__ */ jsxs7(
|
|
1418
|
+
"div",
|
|
1419
|
+
{
|
|
1420
|
+
className: presenceClass.sift,
|
|
1421
|
+
"data-size": size,
|
|
1422
|
+
"data-resolving": live ? "false" : "true",
|
|
1423
|
+
style: { gap: SIFT_TAIL_GAP[size] },
|
|
1424
|
+
children: [
|
|
1425
|
+
/* @__PURE__ */ jsxs7(
|
|
1426
|
+
motion.div,
|
|
1427
|
+
{
|
|
1428
|
+
className: presenceClass.siftTrack,
|
|
1429
|
+
animate: controls,
|
|
1430
|
+
style: reserveTrack ? { gap: SOURCE_CARD_GAP[size], width: trackWidth(size) } : { gap: SOURCE_CARD_GAP[size] },
|
|
1431
|
+
children: [
|
|
1432
|
+
/* @__PURE__ */ jsx14(
|
|
1433
|
+
AnimatePresence,
|
|
1434
|
+
{
|
|
1435
|
+
mode: "popLayout",
|
|
1436
|
+
onExitComplete: () => {
|
|
1437
|
+
if (live) return;
|
|
1438
|
+
admitted.current = /* @__PURE__ */ new Map();
|
|
1439
|
+
setResolving(false);
|
|
1440
|
+
},
|
|
1441
|
+
children: deck.cards.map((card) => /* @__PURE__ */ jsx14(
|
|
1442
|
+
PresenceSourceCard,
|
|
1443
|
+
{
|
|
1444
|
+
source: card.ref,
|
|
1445
|
+
records: card.records,
|
|
1446
|
+
sourceKind: card.sourceKind,
|
|
1447
|
+
size,
|
|
1448
|
+
found: card.state !== "missed",
|
|
1449
|
+
pending: card.state === "pending",
|
|
1450
|
+
chosen: card.state === "chosen"
|
|
1451
|
+
},
|
|
1452
|
+
card.key
|
|
1453
|
+
))
|
|
1454
|
+
}
|
|
1455
|
+
),
|
|
1456
|
+
/* @__PURE__ */ jsx14(CriterionPass, { seq: pass })
|
|
1457
|
+
]
|
|
1458
|
+
}
|
|
1459
|
+
),
|
|
1460
|
+
tail
|
|
1461
|
+
]
|
|
1462
|
+
}
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
// src/agent/presence/FactChip.tsx
|
|
1467
|
+
import {
|
|
1468
|
+
presenceFactShape,
|
|
1469
|
+
resolvePresenceFactForm
|
|
1470
|
+
} from "@40rty/ams-sdk";
|
|
1471
|
+
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1472
|
+
function resolveValueForm(fact) {
|
|
1473
|
+
if (fact.scope !== void 0) {
|
|
1474
|
+
const declared = resolvePresenceFactForm(fact.scope);
|
|
1475
|
+
if (declared !== void 0) return { kind: fact.scope, form: declared };
|
|
1476
|
+
}
|
|
1477
|
+
const shape = presenceFactShape(fact);
|
|
1478
|
+
return { kind: shape, form: resolvePresenceFactForm(shape) };
|
|
1479
|
+
}
|
|
1480
|
+
function FactChip({ fact, onForget }) {
|
|
1481
|
+
const { brief } = useLabels().presence;
|
|
1482
|
+
const { kind, form } = resolveValueForm(fact);
|
|
1483
|
+
return /* @__PURE__ */ jsxs8(
|
|
1484
|
+
motion.span,
|
|
1485
|
+
{
|
|
1486
|
+
className: presenceClass.fact,
|
|
1487
|
+
"data-tier": fact.tier === "profile" ? "profile" : "session",
|
|
1488
|
+
"data-fact-kind": kind,
|
|
1489
|
+
title: fact.tier === "profile" ? brief.recalled.badge : void 0,
|
|
1490
|
+
initial: { opacity: 0 },
|
|
1491
|
+
animate: { opacity: 1 },
|
|
1492
|
+
exit: { opacity: 0, scale: 0.92 },
|
|
1493
|
+
transition: { duration: 0.3, ease: [0.22, 1, 0.36, 1] },
|
|
1494
|
+
children: [
|
|
1495
|
+
/* @__PURE__ */ jsx15("span", { className: presenceClass.factLabel, children: fact.label }),
|
|
1496
|
+
form === void 0 ? /* @__PURE__ */ jsxs8("span", { className: presenceClass.factValue, children: [
|
|
1497
|
+
colorSwatch(fact.value),
|
|
1498
|
+
/* @__PURE__ */ jsx15("span", { className: presenceClass.factValueText, children: fact.value })
|
|
1499
|
+
] }) : /* @__PURE__ */ jsx15("span", { className: presenceClass.factValue, "data-form": "true", children: /* @__PURE__ */ jsx15(form.Component, { fact, kind }) }),
|
|
1500
|
+
/* @__PURE__ */ jsx15(
|
|
1501
|
+
"button",
|
|
1502
|
+
{
|
|
1503
|
+
type: "button",
|
|
1504
|
+
className: presenceClass.factForget,
|
|
1505
|
+
onClick: (e) => {
|
|
1506
|
+
e.stopPropagation();
|
|
1507
|
+
onForget(fact);
|
|
1508
|
+
},
|
|
1509
|
+
"aria-label": brief.forget(fact.label),
|
|
1510
|
+
children: "\xD7"
|
|
1511
|
+
}
|
|
1512
|
+
)
|
|
1513
|
+
]
|
|
1514
|
+
},
|
|
1515
|
+
fact.label
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
function sortFactsByTier(facts) {
|
|
1519
|
+
const profile = facts.filter((f) => f.tier === "profile");
|
|
1520
|
+
const session = facts.filter((f) => f.tier !== "profile");
|
|
1521
|
+
return [...profile, ...session];
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
// src/agent/presence/CompactRead.tsx
|
|
1525
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1526
|
+
function CompactLead({ text }) {
|
|
1527
|
+
if (text.trim().length === 0) return null;
|
|
1528
|
+
return /* @__PURE__ */ jsx16("div", { className: "fourty-presence-read__compact-lead", children: /* @__PURE__ */ jsx16("span", { className: presenceClass.prose, "data-clamp": "1", children: text }) });
|
|
1529
|
+
}
|
|
1530
|
+
function CompactStream({
|
|
1531
|
+
lead,
|
|
1532
|
+
sources,
|
|
1533
|
+
materialized,
|
|
1534
|
+
facts,
|
|
1535
|
+
hiddenFacts = 0,
|
|
1536
|
+
chipsOnly = false
|
|
1537
|
+
}) {
|
|
1538
|
+
return /* @__PURE__ */ jsxs9("div", { className: presenceClass.row, "data-compact": "true", children: [
|
|
1539
|
+
!chipsOnly && /* @__PURE__ */ jsx16(CompactLead, { text: lead }),
|
|
1540
|
+
/* @__PURE__ */ jsx16(
|
|
1541
|
+
SourceSift,
|
|
1542
|
+
{
|
|
1543
|
+
sources,
|
|
1544
|
+
materialized,
|
|
1545
|
+
criteria: facts.length,
|
|
1546
|
+
size: "compact"
|
|
1547
|
+
}
|
|
1548
|
+
),
|
|
1549
|
+
/* @__PURE__ */ jsx16(
|
|
1550
|
+
FactChips,
|
|
1551
|
+
{
|
|
1552
|
+
facts: [...facts].sort((a, b) => a.slot - b.slot).map((f) => f.fact),
|
|
1553
|
+
more: hiddenFacts
|
|
1554
|
+
}
|
|
1555
|
+
)
|
|
1556
|
+
] });
|
|
1557
|
+
}
|
|
1558
|
+
function FactChips({
|
|
1559
|
+
facts,
|
|
1560
|
+
more = 0
|
|
1561
|
+
}) {
|
|
1562
|
+
const { forget } = useForgetFact();
|
|
1563
|
+
if (facts.length === 0) return null;
|
|
1564
|
+
return /* @__PURE__ */ jsxs9("div", { className: presenceClass.facts, "data-compact": "true", children: [
|
|
1565
|
+
/* @__PURE__ */ jsx16(AnimatePresence, { initial: false, children: facts.map((fact) => /* @__PURE__ */ jsx16(FactChip, { fact, onForget: forget }, factIdentity(fact))) }),
|
|
1566
|
+
more > 0 && /* @__PURE__ */ jsxs9("span", { className: presenceClass.factMore, children: [
|
|
1567
|
+
"+",
|
|
1568
|
+
more
|
|
1569
|
+
] })
|
|
1570
|
+
] });
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
// src/agent/presence/band-row.ts
|
|
1574
|
+
var BAND_PAD_Y = 2;
|
|
1575
|
+
var BAND_HEIGHT = SOURCE_CARD_BOX.compact.height + BAND_PAD_Y * 2;
|
|
1576
|
+
var CRITERION_SLOT = 152;
|
|
1577
|
+
var CRITERION_GAP = 22;
|
|
1578
|
+
var CRITERION_LABEL_LINE = 12;
|
|
1579
|
+
var CRITERION_VALUE_LINE = 15;
|
|
1580
|
+
var CRITERION_LINE_GAP = 2;
|
|
1581
|
+
var CRITERION_RULE_GAP = 5;
|
|
1582
|
+
var CRITERION_BOX_HEIGHT = CRITERION_LABEL_LINE + CRITERION_LINE_GAP + CRITERION_VALUE_LINE + CRITERION_RULE_GAP;
|
|
1583
|
+
var CRITERION_HANDLE_LANE = 22;
|
|
1584
|
+
var CRITERION_TAIL_LANE = 30;
|
|
1585
|
+
var VOICE_LINE_HEIGHT = 24;
|
|
1586
|
+
var VOICE_MIN_WIDTH = 280;
|
|
1587
|
+
function criteriaRegionWidth(slots, lanes) {
|
|
1588
|
+
const laneWidth = (lanes.tail ? CRITERION_TAIL_LANE + CRITERION_GAP : 0) + (lanes.handle ? CRITERION_HANDLE_LANE + CRITERION_GAP : 0);
|
|
1589
|
+
if (slots <= 0) return laneWidth;
|
|
1590
|
+
return slots * CRITERION_SLOT + (slots - 1) * CRITERION_GAP + laneWidth;
|
|
1591
|
+
}
|
|
1592
|
+
function criteriaRailTemplate(slots, lanes) {
|
|
1593
|
+
const tracks = [];
|
|
1594
|
+
if (slots > 0) tracks.push(`repeat(${slots}, minmax(0, 1fr))`);
|
|
1595
|
+
if (lanes.tail) tracks.push(`${CRITERION_TAIL_LANE}px`);
|
|
1596
|
+
if (lanes.handle) tracks.push(`${CRITERION_HANDLE_LANE}px`);
|
|
1597
|
+
return tracks.join(" ");
|
|
1598
|
+
}
|
|
1599
|
+
function railTailLane(slots) {
|
|
1600
|
+
return slots + 1;
|
|
1601
|
+
}
|
|
1602
|
+
function railHandleLane(slots, lanes) {
|
|
1603
|
+
return slots + (lanes.tail ? 1 : 0) + 1;
|
|
1604
|
+
}
|
|
1605
|
+
function bandRowTemplate(railWidth, deckWidth) {
|
|
1606
|
+
return `minmax(0, ${railWidth}px) minmax(${VOICE_MIN_WIDTH}px, 1fr) minmax(0, ${deckWidth}px)`;
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
// src/agent/presence/fact-rail.ts
|
|
1610
|
+
var PRESENCE_FACT_LIMIT = 3;
|
|
1611
|
+
var PRESENCE_DURABLE_SLOTS = 1;
|
|
1612
|
+
function rankFactElements(facts, liveTurnId) {
|
|
1613
|
+
const thisTurn = [];
|
|
1614
|
+
const profile = [];
|
|
1615
|
+
const older = [];
|
|
1616
|
+
for (const el of facts) {
|
|
1617
|
+
if (liveTurnId !== void 0 && el.turnId === liveTurnId) thisTurn.push(el);
|
|
1618
|
+
else if (el.tier === "profile") profile.push(el);
|
|
1619
|
+
else older.push(el);
|
|
1620
|
+
}
|
|
1621
|
+
return [...thisTurn, ...profile, ...newestReadFirst(older)];
|
|
1622
|
+
}
|
|
1623
|
+
function newestReadFirst(facts) {
|
|
1624
|
+
const reads = /* @__PURE__ */ new Map();
|
|
1625
|
+
for (const el of facts) {
|
|
1626
|
+
const held = reads.get(el.turnId);
|
|
1627
|
+
if (held === void 0) reads.set(el.turnId, [el]);
|
|
1628
|
+
else held.push(el);
|
|
1629
|
+
}
|
|
1630
|
+
const out = [];
|
|
1631
|
+
for (const read of [...reads.values()].reverse()) out.push(...read);
|
|
1632
|
+
return out;
|
|
1633
|
+
}
|
|
1634
|
+
function selectPresenceFacts(facts, liveTurnId) {
|
|
1635
|
+
return rankFactElements(facts, liveTurnId);
|
|
1636
|
+
}
|
|
1637
|
+
function isDurable(fact) {
|
|
1638
|
+
return fact.tier === "profile";
|
|
1639
|
+
}
|
|
1640
|
+
function capWithDurableFloor(facts, limit) {
|
|
1641
|
+
const head = facts.slice(0, limit);
|
|
1642
|
+
if (limit < PRESENCE_DURABLE_SLOTS) return head;
|
|
1643
|
+
if (head.some(isDurable)) return head;
|
|
1644
|
+
const durable = facts.slice(limit).find(isDurable);
|
|
1645
|
+
if (durable === void 0) return head;
|
|
1646
|
+
return [...head.slice(0, limit - PRESENCE_DURABLE_SLOTS), durable];
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
// src/agent/presence/folded.tsx
|
|
1650
|
+
import * as React13 from "react";
|
|
1651
|
+
import { jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1652
|
+
function Sep() {
|
|
1653
|
+
return /* @__PURE__ */ jsx17("span", { "aria-hidden": true, className: presenceClass.factSep, "data-dot": "true", children: "\xB7" });
|
|
1654
|
+
}
|
|
1655
|
+
function FactChip2({ fact }) {
|
|
1656
|
+
const swatch = colorSwatch(fact.value);
|
|
1657
|
+
return /* @__PURE__ */ jsxs10("span", { className: presenceClass.fact, "data-tier": fact.tier === "profile" ? "profile" : "session", children: [
|
|
1658
|
+
/* @__PURE__ */ jsx17("span", { className: presenceClass.factLabel, children: fact.label }),
|
|
1659
|
+
/* @__PURE__ */ jsxs10("span", { className: presenceClass.factValue, children: [
|
|
1660
|
+
swatch,
|
|
1661
|
+
fact.value
|
|
1662
|
+
] })
|
|
1663
|
+
] });
|
|
1664
|
+
}
|
|
1665
|
+
function FoldedRead({ label, facts, text }) {
|
|
1666
|
+
const shown = sortFactsByTier(facts).slice(0, 3);
|
|
1667
|
+
const moreFacts = facts.length - shown.length;
|
|
1668
|
+
return /* @__PURE__ */ jsxs10("div", { className: presenceClass.row, "data-folded": "true", children: [
|
|
1669
|
+
label.length > 0 && /* @__PURE__ */ jsx17(Eyebrow, { children: label }),
|
|
1670
|
+
label.length > 0 && /* @__PURE__ */ jsx17(Rule, {}),
|
|
1671
|
+
shown.length > 0 ? /* @__PURE__ */ jsxs10("div", { className: presenceClass.facts, "data-folded": "true", children: [
|
|
1672
|
+
shown.map((f, i) => /* @__PURE__ */ jsxs10(React13.Fragment, { children: [
|
|
1673
|
+
i > 0 && /* @__PURE__ */ jsx17(Sep, {}),
|
|
1674
|
+
/* @__PURE__ */ jsx17(FactChip2, { fact: f })
|
|
1675
|
+
] }, f.label)),
|
|
1676
|
+
moreFacts > 0 && /* @__PURE__ */ jsxs10("span", { className: presenceClass.factMore, children: [
|
|
1677
|
+
"+",
|
|
1678
|
+
moreFacts
|
|
1679
|
+
] })
|
|
1680
|
+
] }) : /* @__PURE__ */ jsx17("span", { className: presenceClass.prose, "data-clamp": "1", children: text })
|
|
1681
|
+
] });
|
|
1682
|
+
}
|
|
1683
|
+
function BriefHandle({
|
|
1684
|
+
open,
|
|
1685
|
+
onToggle
|
|
1686
|
+
}) {
|
|
1687
|
+
const { brief } = useLabels().presence;
|
|
1688
|
+
return /* @__PURE__ */ jsx17(
|
|
1689
|
+
motion.button,
|
|
1690
|
+
{
|
|
1691
|
+
type: "button",
|
|
1692
|
+
className: presenceClass.hint,
|
|
1693
|
+
"data-open": open ? "true" : "false",
|
|
1694
|
+
onClick: onToggle,
|
|
1695
|
+
"aria-expanded": open,
|
|
1696
|
+
"aria-label": open ? brief.close : brief.open,
|
|
1697
|
+
initial: false,
|
|
1698
|
+
animate: { rotate: open ? 0 : -90 },
|
|
1699
|
+
transition: { duration: 0.25 },
|
|
1700
|
+
children: "\u2304"
|
|
1701
|
+
}
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
// src/agent/presence/PresenceBrief.tsx
|
|
1706
|
+
import * as React15 from "react";
|
|
1707
|
+
import { usePresenceElements, usePresenceLiveTurn } from "@40rty/ams-sdk";
|
|
1708
|
+
|
|
1709
|
+
// src/agent/presence/BriefIdentity.tsx
|
|
1710
|
+
import * as React14 from "react";
|
|
1711
|
+
import { useVisitorName } from "@40rty/ams-sdk";
|
|
1712
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1713
|
+
var SETTLE = [0.22, 1, 0.36, 1];
|
|
1714
|
+
function NameField({
|
|
1715
|
+
onCommit,
|
|
1716
|
+
onCancel,
|
|
1717
|
+
initial
|
|
1718
|
+
}) {
|
|
1719
|
+
const { identity } = useLabels().presence.brief;
|
|
1720
|
+
const [draft, setDraft] = React14.useState(initial);
|
|
1721
|
+
const ref = React14.useRef(null);
|
|
1722
|
+
React14.useEffect(() => {
|
|
1723
|
+
ref.current?.focus();
|
|
1724
|
+
}, []);
|
|
1725
|
+
const commit = () => {
|
|
1726
|
+
const next = draft.trim();
|
|
1727
|
+
if (next.length === 0 || next === initial) {
|
|
1728
|
+
onCancel();
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
onCommit(next);
|
|
1732
|
+
};
|
|
1733
|
+
return /* @__PURE__ */ jsx18(
|
|
1734
|
+
"input",
|
|
1735
|
+
{
|
|
1736
|
+
ref,
|
|
1737
|
+
className: presenceClass.identityInput,
|
|
1738
|
+
value: draft,
|
|
1739
|
+
onChange: (e) => setDraft(e.target.value),
|
|
1740
|
+
onKeyDown: (e) => {
|
|
1741
|
+
if (e.key === "Enter") {
|
|
1742
|
+
e.preventDefault();
|
|
1743
|
+
commit();
|
|
1744
|
+
}
|
|
1745
|
+
if (e.key === "Escape") onCancel();
|
|
1746
|
+
},
|
|
1747
|
+
onBlur: commit,
|
|
1748
|
+
placeholder: identity.placeholder,
|
|
1749
|
+
"aria-label": identity.placeholder,
|
|
1750
|
+
maxLength: 100,
|
|
1751
|
+
autoComplete: "given-name"
|
|
1752
|
+
}
|
|
1753
|
+
);
|
|
1754
|
+
}
|
|
1755
|
+
function BriefIdentity() {
|
|
1756
|
+
const { name, setName } = useVisitorName();
|
|
1757
|
+
const { identity } = useLabels().presence.brief;
|
|
1758
|
+
const [editing, setEditing] = React14.useState(false);
|
|
1759
|
+
if (editing) {
|
|
1760
|
+
return /* @__PURE__ */ jsx18("div", { className: presenceClass.identity, children: /* @__PURE__ */ jsx18(
|
|
1761
|
+
NameField,
|
|
1762
|
+
{
|
|
1763
|
+
initial: name === null ? "" : name,
|
|
1764
|
+
onCommit: (next) => {
|
|
1765
|
+
setName(next);
|
|
1766
|
+
setEditing(false);
|
|
1767
|
+
},
|
|
1768
|
+
onCancel: () => setEditing(false)
|
|
1769
|
+
}
|
|
1770
|
+
) });
|
|
1771
|
+
}
|
|
1772
|
+
return /* @__PURE__ */ jsx18("div", { className: presenceClass.identity, children: name === null ? /* @__PURE__ */ jsx18(
|
|
1773
|
+
"button",
|
|
1774
|
+
{
|
|
1775
|
+
type: "button",
|
|
1776
|
+
className: presenceClass.identityInvite,
|
|
1777
|
+
onClick: () => setEditing(true),
|
|
1778
|
+
children: identity.invite
|
|
1779
|
+
}
|
|
1780
|
+
) : /* @__PURE__ */ jsx18(
|
|
1781
|
+
motion.button,
|
|
1782
|
+
{
|
|
1783
|
+
type: "button",
|
|
1784
|
+
className: presenceClass.identityName,
|
|
1785
|
+
"aria-label": identity.change(name),
|
|
1786
|
+
onClick: () => setEditing(true),
|
|
1787
|
+
initial: { opacity: 0, y: 2 },
|
|
1788
|
+
animate: { opacity: 1, y: 0 },
|
|
1789
|
+
transition: { duration: 0.3, ease: SETTLE },
|
|
1790
|
+
children: identity.greeting(name)
|
|
1791
|
+
}
|
|
1792
|
+
) });
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
// src/agent/presence/element-view.ts
|
|
1796
|
+
function toFact(el) {
|
|
1797
|
+
if (el.scope === void 0) {
|
|
1798
|
+
return { label: el.label, value: el.value, tier: el.tier, provenance: el.provenance };
|
|
1799
|
+
}
|
|
1800
|
+
return {
|
|
1801
|
+
label: el.label,
|
|
1802
|
+
value: el.value,
|
|
1803
|
+
tier: el.tier,
|
|
1804
|
+
provenance: el.provenance,
|
|
1805
|
+
scope: el.scope
|
|
1806
|
+
};
|
|
1807
|
+
}
|
|
1808
|
+
function isWorthShowing(el) {
|
|
1809
|
+
return el.provenance !== "stated";
|
|
1810
|
+
}
|
|
1811
|
+
function derivePresenceView(elements, liveTurnId) {
|
|
1812
|
+
const sources = [];
|
|
1813
|
+
const showable = [];
|
|
1814
|
+
const heldLabels = [];
|
|
1815
|
+
let voice = "";
|
|
1816
|
+
let ask;
|
|
1817
|
+
let concession;
|
|
1818
|
+
for (const el of elements) {
|
|
1819
|
+
switch (el.kind) {
|
|
1820
|
+
case "source":
|
|
1821
|
+
sources.push(el);
|
|
1822
|
+
break;
|
|
1823
|
+
case "fact":
|
|
1824
|
+
heldLabels.push(el.label);
|
|
1825
|
+
if (isWorthShowing(el)) showable.push(el);
|
|
1826
|
+
break;
|
|
1827
|
+
case "voice":
|
|
1828
|
+
if (el.register === "lead") voice = el.text;
|
|
1829
|
+
break;
|
|
1830
|
+
case "ask":
|
|
1831
|
+
ask = el;
|
|
1832
|
+
break;
|
|
1833
|
+
case "concession":
|
|
1834
|
+
concession = el;
|
|
1835
|
+
break;
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
const facts = selectPresenceFacts(showable, liveTurnId).map(toFact);
|
|
1839
|
+
return { sources, facts, hiddenFacts: 0, heldLabels, voice, ask, concession };
|
|
1840
|
+
}
|
|
1841
|
+
function withCappedFacts(view, facts, reachable, limit) {
|
|
1842
|
+
const drawn = capWithDurableFloor(facts, limit);
|
|
1843
|
+
const shown = new Set(drawn.map(factIdentity));
|
|
1844
|
+
return {
|
|
1845
|
+
sources: view.sources,
|
|
1846
|
+
facts: drawn,
|
|
1847
|
+
// `+N` COUNTS WHAT THE BRIEF HOLDS AND THE BAND IS NOT SHOWING — the two are
|
|
1848
|
+
// different lists, and counting the wrong one is a door onto an empty room.
|
|
1849
|
+
// It was `facts.length - limit`: `facts` is the BAND's set, which includes
|
|
1850
|
+
// the optimistic bridge (a pick shown before the agent's read lands), while
|
|
1851
|
+
// the brief shows only what the agent knows. A visitor who picked a size got
|
|
1852
|
+
// a "+4" whose destination held two entries. Counting the REACHABLE set that
|
|
1853
|
+
// the band did not draw is exact by construction, whatever fills the slots.
|
|
1854
|
+
hiddenFacts: reachable.filter((f) => !shown.has(factIdentity(f))).length,
|
|
1855
|
+
heldLabels: view.heldLabels,
|
|
1856
|
+
voice: view.voice,
|
|
1857
|
+
ask: view.ask,
|
|
1858
|
+
concession: view.concession
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
function viewIsEmpty(view) {
|
|
1862
|
+
return view.sources.length === 0 && view.facts.length === 0 && view.voice.length === 0 && view.ask === void 0 && view.concession === void 0;
|
|
1863
|
+
}
|
|
1864
|
+
function viewHasHeld(view) {
|
|
1865
|
+
return view.facts.length > 0 || view.voice.length > 0 || view.ask !== void 0;
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
// src/agent/presence/PresenceBrief.tsx
|
|
1869
|
+
import { jsx as jsx19, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1870
|
+
var SETTLE2 = [0.22, 1, 0.36, 1];
|
|
1871
|
+
function partition(facts) {
|
|
1872
|
+
const recalled = [];
|
|
1873
|
+
const inferred = [];
|
|
1874
|
+
for (const f of facts) {
|
|
1875
|
+
if (factRegister(f) === "recalled") recalled.push(f);
|
|
1876
|
+
else inferred.push(f);
|
|
1877
|
+
}
|
|
1878
|
+
return { recalled, inferred };
|
|
1879
|
+
}
|
|
1880
|
+
function Group({
|
|
1881
|
+
title,
|
|
1882
|
+
facts,
|
|
1883
|
+
onForget
|
|
1884
|
+
}) {
|
|
1885
|
+
if (facts.length === 0) return null;
|
|
1886
|
+
return /* @__PURE__ */ jsxs11("section", { className: presenceClass.briefGroup, children: [
|
|
1887
|
+
/* @__PURE__ */ jsx19("header", { className: presenceClass.briefGroupHead, children: /* @__PURE__ */ jsx19("span", { className: presenceClass.eyebrow, children: title }) }),
|
|
1888
|
+
/* @__PURE__ */ jsx19("div", { className: presenceClass.facts, "data-editable": "true", "data-brief": "true", children: /* @__PURE__ */ jsx19(AnimatePresence, { initial: false, children: facts.map((f) => /* @__PURE__ */ jsx19(FactChip, { fact: f, onForget }, f.label)) }) })
|
|
1889
|
+
] });
|
|
1890
|
+
}
|
|
1891
|
+
function PresenceBriefBody({ facts }) {
|
|
1892
|
+
const { forget } = useForgetFact();
|
|
1893
|
+
const { brief } = useLabels().presence;
|
|
1894
|
+
const { recalled, inferred } = React15.useMemo(() => partition(facts), [facts]);
|
|
1895
|
+
if (facts.length === 0) return null;
|
|
1896
|
+
return /* @__PURE__ */ jsxs11("div", { className: presenceClass.brief, children: [
|
|
1897
|
+
/* @__PURE__ */ jsx19(BriefIdentity, {}),
|
|
1898
|
+
/* @__PURE__ */ jsx19(Group, { title: brief.recalled.title, facts: recalled, onForget: forget }),
|
|
1899
|
+
/* @__PURE__ */ jsx19(Group, { title: brief.inferred.title, facts: inferred, onForget: forget })
|
|
1900
|
+
] });
|
|
1901
|
+
}
|
|
1902
|
+
function PresenceBriefDrawer() {
|
|
1903
|
+
const elements = usePresenceElements();
|
|
1904
|
+
const liveTurnId = usePresenceLiveTurn();
|
|
1905
|
+
const view = React15.useMemo(
|
|
1906
|
+
() => derivePresenceView(elements, liveTurnId),
|
|
1907
|
+
[elements, liveTurnId]
|
|
1908
|
+
);
|
|
1909
|
+
const visible = useUndismissedFacts(view.facts);
|
|
1910
|
+
if (visible.length === 0) return null;
|
|
1911
|
+
return /* @__PURE__ */ jsx19(
|
|
1912
|
+
motion.div,
|
|
1913
|
+
{
|
|
1914
|
+
className: presenceClass.briefPanel,
|
|
1915
|
+
initial: { opacity: 0 },
|
|
1916
|
+
animate: { opacity: 1 },
|
|
1917
|
+
transition: { duration: 0.24, ease: SETTLE2 },
|
|
1918
|
+
children: /* @__PURE__ */ jsx19(PresenceBriefBody, { facts: visible })
|
|
1919
|
+
}
|
|
1920
|
+
);
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
// src/agent/presence/use-measured-height.ts
|
|
1924
|
+
import * as React16 from "react";
|
|
1925
|
+
function useMeasuredHeight() {
|
|
1926
|
+
const ref = React16.useRef(null);
|
|
1927
|
+
const [height, setHeight] = React16.useState(0);
|
|
1928
|
+
React16.useLayoutEffect(() => {
|
|
1929
|
+
const el = ref.current;
|
|
1930
|
+
if (el === null) return;
|
|
1931
|
+
if (typeof ResizeObserver === "undefined") {
|
|
1932
|
+
setHeight(el.getBoundingClientRect().height);
|
|
1933
|
+
return;
|
|
1934
|
+
}
|
|
1935
|
+
const ro = new ResizeObserver((entries) => {
|
|
1936
|
+
const entry = entries[0];
|
|
1937
|
+
if (entry === void 0) return;
|
|
1938
|
+
setHeight(entry.contentRect.height);
|
|
1939
|
+
});
|
|
1940
|
+
ro.observe(el);
|
|
1941
|
+
return () => ro.disconnect();
|
|
1942
|
+
}, []);
|
|
1943
|
+
return [ref, height];
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
// src/agent/presence/reads.tsx
|
|
1947
|
+
import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1948
|
+
function Thought({
|
|
1949
|
+
text,
|
|
1950
|
+
eyebrow,
|
|
1951
|
+
compact = false
|
|
1952
|
+
}) {
|
|
1953
|
+
const hasEyebrow = eyebrow.length > 0;
|
|
1954
|
+
return /* @__PURE__ */ jsxs12("div", { className: presenceClass.row, "data-compact": compact ? "true" : void 0, children: [
|
|
1955
|
+
hasEyebrow && /* @__PURE__ */ jsx20(Eyebrow, { children: eyebrow }),
|
|
1956
|
+
hasEyebrow && !compact && /* @__PURE__ */ jsx20(Rule, {}),
|
|
1957
|
+
/* @__PURE__ */ jsx20("span", { className: presenceClass.prose, children: text })
|
|
1958
|
+
] });
|
|
1959
|
+
}
|
|
1960
|
+
function Dossier({ text, facts, eyebrow }) {
|
|
1961
|
+
const hasEyebrow = eyebrow.length > 0;
|
|
1962
|
+
const { forget } = useForgetFact();
|
|
1963
|
+
const shown = facts;
|
|
1964
|
+
return /* @__PURE__ */ jsxs12("div", { className: presenceClass.dossier, children: [
|
|
1965
|
+
hasEyebrow && /* @__PURE__ */ jsx20("div", { className: presenceClass.kicker, children: /* @__PURE__ */ jsx20(Eyebrow, { children: eyebrow }) }),
|
|
1966
|
+
/* @__PURE__ */ jsx20("span", { className: presenceClass.prose, children: text }),
|
|
1967
|
+
shown.length > 0 && // ONE flat list — no group headers, no taxonomy. The long/short-term
|
|
1968
|
+
// distinction is carried by the entries' MATERIAL (a durable fact's
|
|
1969
|
+
// value is set: full weight, anchored hairline; a this-visit note is
|
|
1970
|
+
// provisional: same shape, lighter register) and by ORDER (durable
|
|
1971
|
+
// first). The surface never explains itself with labels.
|
|
1972
|
+
/* @__PURE__ */ jsx20("div", { className: presenceClass.facts, children: /* @__PURE__ */ jsx20(AnimatePresence, { initial: false, children: sortFactsByTier(shown).map((f) => /* @__PURE__ */ jsx20(FactChip, { fact: f, onForget: forget }, f.label)) }) })
|
|
1973
|
+
] });
|
|
1974
|
+
}
|
|
1975
|
+
|
|
1976
|
+
// src/agent/presence/forms.tsx
|
|
1977
|
+
import { registerPresenceForm } from "@40rty/ams-sdk";
|
|
1978
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
1979
|
+
function DossierForm({ frame, expanded }) {
|
|
1980
|
+
const text = typeof frame.text === "string" ? frame.text : "";
|
|
1981
|
+
const facts = useVisibleFacts(frame);
|
|
1982
|
+
const label = readLabel(frame);
|
|
1983
|
+
return expanded ? /* @__PURE__ */ jsx21(Dossier, { text, facts, eyebrow: label }) : /* @__PURE__ */ jsx21(FoldedRead, { label, facts, text });
|
|
1984
|
+
}
|
|
1985
|
+
function ThoughtForm({ frame, expanded }) {
|
|
1986
|
+
const text = typeof frame.text === "string" ? frame.text : "";
|
|
1987
|
+
const label = readLabel(frame);
|
|
1988
|
+
return expanded ? /* @__PURE__ */ jsx21(Thought, { text, eyebrow: label }) : /* @__PURE__ */ jsx21(FoldedRead, { label, facts: [], text });
|
|
1989
|
+
}
|
|
1990
|
+
var registered2 = false;
|
|
1991
|
+
function registerDefaultPresenceForms() {
|
|
1992
|
+
if (registered2) return;
|
|
1993
|
+
registered2 = true;
|
|
1994
|
+
registerPresenceForm("dossier", { Component: DossierForm, foldable: true });
|
|
1995
|
+
registerPresenceForm("thought", { Component: ThoughtForm, foldable: true });
|
|
1996
|
+
}
|
|
1997
|
+
registerDefaultPresenceForms();
|
|
1998
|
+
|
|
1999
|
+
// src/agent/presence/AgentPresenceWidget.tsx
|
|
2000
|
+
import * as React22 from "react";
|
|
2001
|
+
import {
|
|
2002
|
+
usePresenceMaterialized,
|
|
2003
|
+
useFourtySession as useFourtySession2
|
|
2004
|
+
} from "@40rty/ams-sdk";
|
|
2005
|
+
import { useFormFactor as useFormFactor2 } from "@40rty/ams-sdk";
|
|
2006
|
+
|
|
2007
|
+
// src/agent/presence/band-beat.ts
|
|
2008
|
+
import * as React17 from "react";
|
|
2009
|
+
var BAND_BEAT_MS = 260;
|
|
2010
|
+
var BAND_REGION_STAGGER_S = 0.06;
|
|
2011
|
+
var BAND_REGION_ORDER = {
|
|
2012
|
+
criteria: 0,
|
|
2013
|
+
voice: 1,
|
|
2014
|
+
deck: 2
|
|
2015
|
+
};
|
|
2016
|
+
function bandRegionDelay(region) {
|
|
2017
|
+
return BAND_REGION_ORDER[region] * BAND_REGION_STAGGER_S;
|
|
2018
|
+
}
|
|
2019
|
+
var BAND_SETTLE = [0.22, 1, 0.36, 1];
|
|
2020
|
+
function useBandBeat(value, signature) {
|
|
2021
|
+
const [drawn, setDrawn] = React17.useState(value);
|
|
2022
|
+
const latest = React17.useRef(value);
|
|
2023
|
+
latest.current = value;
|
|
2024
|
+
const composedAt = React17.useRef(Number.NEGATIVE_INFINITY);
|
|
2025
|
+
React17.useEffect(() => {
|
|
2026
|
+
const since = performance.now() - composedAt.current;
|
|
2027
|
+
if (since >= BAND_BEAT_MS) {
|
|
2028
|
+
composedAt.current = performance.now();
|
|
2029
|
+
setDrawn(latest.current);
|
|
2030
|
+
return;
|
|
2031
|
+
}
|
|
2032
|
+
const timer = setTimeout(() => {
|
|
2033
|
+
composedAt.current = performance.now();
|
|
2034
|
+
setDrawn(latest.current);
|
|
2035
|
+
}, BAND_BEAT_MS - since);
|
|
2036
|
+
return () => clearTimeout(timer);
|
|
2037
|
+
}, [signature]);
|
|
2038
|
+
return drawn;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
// src/agent/presence/fact-slots.ts
|
|
2042
|
+
import * as React18 from "react";
|
|
2043
|
+
function emptySlotRegistry(limit) {
|
|
2044
|
+
return { slots: new Array(limit).fill(void 0), clock: 0 };
|
|
2045
|
+
}
|
|
2046
|
+
function isDurable2(fact) {
|
|
2047
|
+
return fact.tier === "profile";
|
|
2048
|
+
}
|
|
2049
|
+
function evictionCandidate(slots, incoming) {
|
|
2050
|
+
const durableCount = slots.filter((t) => t !== void 0 && isDurable2(t.fact)).length;
|
|
2051
|
+
let choice;
|
|
2052
|
+
let stalest = Number.POSITIVE_INFINITY;
|
|
2053
|
+
for (let i = 0; i < slots.length; i += 1) {
|
|
2054
|
+
const tenant = slots[i];
|
|
2055
|
+
if (tenant === void 0) return i;
|
|
2056
|
+
const protectedDurable = isDurable2(tenant.fact) && durableCount <= 1 && !isDurable2(incoming);
|
|
2057
|
+
if (protectedDurable) continue;
|
|
2058
|
+
if (tenant.seen < stalest) {
|
|
2059
|
+
stalest = tenant.seen;
|
|
2060
|
+
choice = i;
|
|
2061
|
+
}
|
|
2062
|
+
}
|
|
2063
|
+
return choice;
|
|
2064
|
+
}
|
|
2065
|
+
function assignSlots(registry, facts, dismissed) {
|
|
2066
|
+
const slots = [...registry.slots];
|
|
2067
|
+
let clock = registry.clock;
|
|
2068
|
+
const present = new Map(facts.map((f) => [f.label, f]));
|
|
2069
|
+
const held = /* @__PURE__ */ new Map();
|
|
2070
|
+
for (let i = 0; i < slots.length; i += 1) {
|
|
2071
|
+
const tenant = slots[i];
|
|
2072
|
+
if (tenant !== void 0) held.set(tenant.label, i);
|
|
2073
|
+
}
|
|
2074
|
+
const asserts = facts.some((f) => !held.has(f.label));
|
|
2075
|
+
let forgotten = false;
|
|
2076
|
+
for (let i = 0; i < slots.length; i += 1) {
|
|
2077
|
+
const tenant = slots[i];
|
|
2078
|
+
if (tenant === void 0) continue;
|
|
2079
|
+
const byVisitor = dismissed.has(tenant.label);
|
|
2080
|
+
const gone = byVisitor || asserts && !present.has(tenant.label);
|
|
2081
|
+
if (!gone) continue;
|
|
2082
|
+
if (byVisitor) forgotten = true;
|
|
2083
|
+
slots[i] = void 0;
|
|
2084
|
+
held.delete(tenant.label);
|
|
2085
|
+
}
|
|
2086
|
+
if (forgotten) {
|
|
2087
|
+
const survivors = [];
|
|
2088
|
+
for (const tenant of slots) {
|
|
2089
|
+
if (tenant !== void 0) survivors.push(tenant);
|
|
2090
|
+
}
|
|
2091
|
+
held.clear();
|
|
2092
|
+
for (let i = 0; i < slots.length; i += 1) {
|
|
2093
|
+
const tenant = i < survivors.length ? survivors[i] : void 0;
|
|
2094
|
+
slots[i] = tenant;
|
|
2095
|
+
if (tenant !== void 0) held.set(tenant.label, i);
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
for (const fact of facts) {
|
|
2099
|
+
const slot = held.get(fact.label);
|
|
2100
|
+
if (slot === void 0) continue;
|
|
2101
|
+
clock += 1;
|
|
2102
|
+
slots[slot] = { label: fact.label, fact, seen: clock };
|
|
2103
|
+
}
|
|
2104
|
+
for (const fact of facts) {
|
|
2105
|
+
if (held.has(fact.label) || dismissed.has(fact.label)) continue;
|
|
2106
|
+
const slot = evictionCandidate(slots, fact);
|
|
2107
|
+
if (slot === void 0) continue;
|
|
2108
|
+
const outgoing = slots[slot];
|
|
2109
|
+
if (outgoing !== void 0) held.delete(outgoing.label);
|
|
2110
|
+
clock += 1;
|
|
2111
|
+
slots[slot] = { label: fact.label, fact, seen: clock };
|
|
2112
|
+
held.set(fact.label, slot);
|
|
2113
|
+
}
|
|
2114
|
+
const slotted = [];
|
|
2115
|
+
for (let i = 0; i < slots.length; i += 1) {
|
|
2116
|
+
const tenant = slots[i];
|
|
2117
|
+
if (tenant !== void 0) slotted.push({ slot: i, fact: tenant.fact });
|
|
2118
|
+
}
|
|
2119
|
+
return { registry: { slots, clock }, slotted };
|
|
2120
|
+
}
|
|
2121
|
+
function useFactSlots(facts) {
|
|
2122
|
+
const dismissed = useDismissedLabels();
|
|
2123
|
+
const registry = React18.useRef(emptySlotRegistry(PRESENCE_FACT_LIMIT));
|
|
2124
|
+
return React18.useMemo(() => {
|
|
2125
|
+
const next = assignSlots(registry.current, facts, dismissed);
|
|
2126
|
+
registry.current = next.registry;
|
|
2127
|
+
return next.slotted;
|
|
2128
|
+
}, [facts]);
|
|
2129
|
+
}
|
|
2130
|
+
function useRetainedFacts(facts) {
|
|
2131
|
+
const dismissed = useDismissedLabels();
|
|
2132
|
+
const held = React18.useRef([]);
|
|
2133
|
+
return React18.useMemo(() => {
|
|
2134
|
+
const present = new Map(facts.map((f) => [f.label, f]));
|
|
2135
|
+
const known = new Set(held.current.map((f) => f.label));
|
|
2136
|
+
const asserts = facts.some((f) => !known.has(f.label));
|
|
2137
|
+
const next = [];
|
|
2138
|
+
for (const entry of held.current) {
|
|
2139
|
+
if (dismissed.has(entry.label)) continue;
|
|
2140
|
+
const live = present.get(entry.label);
|
|
2141
|
+
if (live !== void 0) next.push(live);
|
|
2142
|
+
else if (!asserts) next.push(entry);
|
|
2143
|
+
}
|
|
2144
|
+
const kept = new Set(next.map((f) => f.label));
|
|
2145
|
+
for (const [label, fact] of present) {
|
|
2146
|
+
if (!kept.has(label) && !dismissed.has(label)) next.push(fact);
|
|
2147
|
+
}
|
|
2148
|
+
held.current = next;
|
|
2149
|
+
return next;
|
|
2150
|
+
}, [facts]);
|
|
2151
|
+
}
|
|
2152
|
+
function useHeldSlotCount(slots, holdMs) {
|
|
2153
|
+
const [held, setHeld] = React18.useState(slots);
|
|
2154
|
+
React18.useEffect(() => {
|
|
2155
|
+
if (slots >= held) {
|
|
2156
|
+
setHeld(slots);
|
|
2157
|
+
return;
|
|
2158
|
+
}
|
|
2159
|
+
const timer = setTimeout(() => setHeld(slots), holdMs);
|
|
2160
|
+
return () => clearTimeout(timer);
|
|
2161
|
+
}, [slots, held, holdMs]);
|
|
2162
|
+
return Math.max(held, slots);
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
// src/agent/presence/CriteriaRail.tsx
|
|
2166
|
+
import * as React19 from "react";
|
|
2167
|
+
import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
2168
|
+
var CRITERION_EXIT_S = 0.16;
|
|
2169
|
+
var CRITERION_ENTER_DELAY_S = 0.08;
|
|
2170
|
+
var Criterion = React19.forwardRef(function Criterion2({ fact, slot, onOpenBrief }, ref) {
|
|
2171
|
+
const attach = React19.useCallback((el) => {
|
|
2172
|
+
if (typeof ref === "function") {
|
|
2173
|
+
ref(el);
|
|
2174
|
+
return;
|
|
2175
|
+
}
|
|
2176
|
+
if (ref !== null) ref.current = el;
|
|
2177
|
+
}, [ref]);
|
|
2178
|
+
const content = /* @__PURE__ */ jsxs13(Fragment4, { children: [
|
|
2179
|
+
/* @__PURE__ */ jsx22("span", { className: presenceClass.factLabel, style: { lineHeight: `${CRITERION_LABEL_LINE}px` }, children: fact.label }),
|
|
2180
|
+
/* @__PURE__ */ jsxs13("span", { className: presenceClass.factValue, style: { lineHeight: `${CRITERION_VALUE_LINE}px` }, children: [
|
|
2181
|
+
colorSwatch(fact.value),
|
|
2182
|
+
fact.value
|
|
2183
|
+
] }),
|
|
2184
|
+
/* @__PURE__ */ jsx22(
|
|
2185
|
+
motion.span,
|
|
2186
|
+
{
|
|
2187
|
+
"aria-hidden": true,
|
|
2188
|
+
className: presenceClass.criterionRule,
|
|
2189
|
+
initial: { scaleX: 0 },
|
|
2190
|
+
animate: { scaleX: 1 },
|
|
2191
|
+
transition: { duration: 0.34, ease: BAND_SETTLE, delay: bandRegionDelay("criteria") + 0.06 }
|
|
2192
|
+
}
|
|
2193
|
+
)
|
|
2194
|
+
] });
|
|
2195
|
+
const common = {
|
|
2196
|
+
className: presenceClass.fact,
|
|
2197
|
+
"data-tier": fact.tier === "profile" ? "profile" : "session",
|
|
2198
|
+
// FIXED BOX. A chip is the same height whatever the agent wrote in it —
|
|
2199
|
+
// otherwise the rail (centred) and the row (centred) lift every other chip
|
|
2200
|
+
// when one value happens to run long. See `CRITERION_BOX_HEIGHT`.
|
|
2201
|
+
style: {
|
|
2202
|
+
gridColumn: slot,
|
|
2203
|
+
// ROW 1, EXPLICITLY. A substitution puts the outgoing chip and its
|
|
2204
|
+
// replacement in the SAME column, and CSS Grid does not overlap two
|
|
2205
|
+
// auto-placed items — it flows the second onto a new ROW. Measured live:
|
|
2206
|
+
// the rail became 68px (two 34px rows) for the length of every swap, and
|
|
2207
|
+
// because the row centres its regions, every chip and the sentence beside
|
|
2208
|
+
// them slid vertically by half of that and back. Two explicitly placed
|
|
2209
|
+
// items may share a cell, which is what makes the crossfade a crossfade.
|
|
2210
|
+
gridRow: 1,
|
|
2211
|
+
height: CRITERION_BOX_HEIGHT,
|
|
2212
|
+
// The two terms the box height is summed from, set where they are spent —
|
|
2213
|
+
// a second copy in the stylesheet is a second number for the reservation
|
|
2214
|
+
// to drift from.
|
|
2215
|
+
rowGap: CRITERION_LINE_GAP,
|
|
2216
|
+
paddingBottom: CRITERION_RULE_GAP
|
|
2217
|
+
},
|
|
2218
|
+
initial: { opacity: 0, y: 3 },
|
|
2219
|
+
animate: { opacity: 1, y: 0 },
|
|
2220
|
+
// The outgoing chip clears its cell BEFORE the incoming one draws in it —
|
|
2221
|
+
// they share a grid cell now, so without the offset a substitution is two
|
|
2222
|
+
// sets of words printed over each other for a third of a second.
|
|
2223
|
+
exit: { opacity: 0, transition: { duration: CRITERION_EXIT_S, ease: BAND_SETTLE } },
|
|
2224
|
+
// A criterion does not arrive on its own clock. It arrives as the band's
|
|
2225
|
+
// LEFT-HAND REGION composing, offset by that region's place in the band's
|
|
2226
|
+
// one gesture (see `band-beat.ts`) — which is the difference between a
|
|
2227
|
+
// surface composing itself and three widgets twitching in a strip.
|
|
2228
|
+
transition: {
|
|
2229
|
+
duration: 0.34,
|
|
2230
|
+
ease: BAND_SETTLE,
|
|
2231
|
+
delay: bandRegionDelay("criteria") + CRITERION_ENTER_DELAY_S
|
|
2232
|
+
}
|
|
2233
|
+
};
|
|
2234
|
+
if (onOpenBrief === void 0) {
|
|
2235
|
+
return /* @__PURE__ */ jsx22(motion.span, { ref: attach, ...common, children: content });
|
|
2236
|
+
}
|
|
2237
|
+
return /* @__PURE__ */ jsx22(
|
|
2238
|
+
motion.button,
|
|
2239
|
+
{
|
|
2240
|
+
type: "button",
|
|
2241
|
+
ref: attach,
|
|
2242
|
+
...common,
|
|
2243
|
+
"data-handle": "true",
|
|
2244
|
+
onClick: onOpenBrief,
|
|
2245
|
+
children: content
|
|
2246
|
+
}
|
|
2247
|
+
);
|
|
2248
|
+
});
|
|
2249
|
+
function MoreTail({
|
|
2250
|
+
count,
|
|
2251
|
+
onOpenBrief,
|
|
2252
|
+
lane
|
|
2253
|
+
}) {
|
|
2254
|
+
const { brief } = useLabels().presence;
|
|
2255
|
+
const style = { gridColumn: lane, gridRow: 1 };
|
|
2256
|
+
if (onOpenBrief === void 0) {
|
|
2257
|
+
return /* @__PURE__ */ jsxs13("span", { className: presenceClass.factMore, style, children: [
|
|
2258
|
+
"+",
|
|
2259
|
+
count
|
|
2260
|
+
] });
|
|
2261
|
+
}
|
|
2262
|
+
return /* @__PURE__ */ jsxs13(
|
|
2263
|
+
"button",
|
|
2264
|
+
{
|
|
2265
|
+
type: "button",
|
|
2266
|
+
className: presenceClass.factMore,
|
|
2267
|
+
style,
|
|
2268
|
+
"data-handle": "true",
|
|
2269
|
+
onClick: onOpenBrief,
|
|
2270
|
+
"aria-label": brief.more(count),
|
|
2271
|
+
children: [
|
|
2272
|
+
"+",
|
|
2273
|
+
count
|
|
2274
|
+
]
|
|
2275
|
+
}
|
|
2276
|
+
);
|
|
2277
|
+
}
|
|
2278
|
+
function CriteriaRail({
|
|
2279
|
+
facts,
|
|
2280
|
+
slots,
|
|
2281
|
+
hidden,
|
|
2282
|
+
brief,
|
|
2283
|
+
onOpenBrief
|
|
2284
|
+
}) {
|
|
2285
|
+
const lanes = { tail: hidden > 0, handle: brief !== void 0 };
|
|
2286
|
+
return /* @__PURE__ */ jsxs13(
|
|
2287
|
+
"div",
|
|
2288
|
+
{
|
|
2289
|
+
className: presenceClass.criteria,
|
|
2290
|
+
style: {
|
|
2291
|
+
gridTemplateColumns: criteriaRailTemplate(slots, lanes),
|
|
2292
|
+
columnGap: CRITERION_GAP
|
|
2293
|
+
},
|
|
2294
|
+
children: [
|
|
2295
|
+
/* @__PURE__ */ jsx22(AnimatePresence, { initial: false, children: facts.map(({ fact, slot }) => /* @__PURE__ */ jsx22(
|
|
2296
|
+
Criterion,
|
|
2297
|
+
{
|
|
2298
|
+
fact,
|
|
2299
|
+
slot: slot + 1,
|
|
2300
|
+
onOpenBrief
|
|
2301
|
+
},
|
|
2302
|
+
factIdentity(fact)
|
|
2303
|
+
)) }),
|
|
2304
|
+
lanes.tail && /* @__PURE__ */ jsx22(MoreTail, { count: hidden, onOpenBrief, lane: railTailLane(slots) }),
|
|
2305
|
+
brief !== void 0 && /* @__PURE__ */ jsx22(
|
|
2306
|
+
"span",
|
|
2307
|
+
{
|
|
2308
|
+
className: presenceClass.railHandle,
|
|
2309
|
+
style: { gridColumn: railHandleLane(slots, lanes), gridRow: 1 },
|
|
2310
|
+
children: /* @__PURE__ */ jsx22(BriefHandle, { open: brief.open, onToggle: brief.toggle })
|
|
2311
|
+
}
|
|
2312
|
+
)
|
|
2313
|
+
]
|
|
2314
|
+
}
|
|
2315
|
+
);
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
// src/agent/presence/VoiceLine.tsx
|
|
2319
|
+
import * as React20 from "react";
|
|
2320
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
2321
|
+
var WORD_FADE_S = 0.14;
|
|
2322
|
+
var WORD_STAGGER_S = 0.014;
|
|
2323
|
+
var SWEEP_MAX_S = 0.26;
|
|
2324
|
+
function partsWithWordIndex(text) {
|
|
2325
|
+
const out = [];
|
|
2326
|
+
let word = 0;
|
|
2327
|
+
for (const part of text.split(/(\s+)/)) {
|
|
2328
|
+
if (part.length === 0) continue;
|
|
2329
|
+
const isSpace = part.trim().length === 0;
|
|
2330
|
+
out.push({ part, word });
|
|
2331
|
+
if (!isSpace) word += 1;
|
|
2332
|
+
}
|
|
2333
|
+
return out;
|
|
2334
|
+
}
|
|
2335
|
+
function VoiceLine({ text, className, style, delay = 0 }) {
|
|
2336
|
+
const reduce = useReducedMotion();
|
|
2337
|
+
const parts = React20.useMemo(() => partsWithWordIndex(text), [text]);
|
|
2338
|
+
const words = parts.length === 0 ? 0 : parts[parts.length - 1].word + 1;
|
|
2339
|
+
const step = words <= 1 ? 0 : Math.min(WORD_STAGGER_S, SWEEP_MAX_S / words);
|
|
2340
|
+
if (reduce === true) return /* @__PURE__ */ jsx23("span", { className, style, children: text });
|
|
2341
|
+
return (
|
|
2342
|
+
// Keyed by the sentence: a NEW read is a new arrival, so the stagger runs
|
|
2343
|
+
// again from the left rather than the changed words popping in place.
|
|
2344
|
+
/* @__PURE__ */ jsx23("span", { className, style, children: parts.map(({ part, word }, i) => /* @__PURE__ */ jsx23(
|
|
2345
|
+
motion.span,
|
|
2346
|
+
{
|
|
2347
|
+
initial: { opacity: 0 },
|
|
2348
|
+
animate: { opacity: 1 },
|
|
2349
|
+
transition: { duration: WORD_FADE_S, delay: delay + word * step, ease: "easeOut" },
|
|
2350
|
+
children: part
|
|
2351
|
+
},
|
|
2352
|
+
i
|
|
2353
|
+
)) }, text)
|
|
2354
|
+
);
|
|
2355
|
+
}
|
|
2356
|
+
|
|
2357
|
+
// src/agent/presence/StreamRead.tsx
|
|
2358
|
+
import { jsx as jsx24, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2359
|
+
var DECK_SIZE = "compact";
|
|
2360
|
+
function compositionSignature(view) {
|
|
2361
|
+
const facts = view.facts.map((f) => `${f.label}=${f.value}`).join("|");
|
|
2362
|
+
const sources = view.sources.map((s) => `${s.id}:${s.sourceKind}:${s.pending === true ? "p" : "r"}:${s.refs.length}`).join("|");
|
|
2363
|
+
const ask = view.ask === void 0 ? "" : view.ask.question;
|
|
2364
|
+
return `${facts}//${view.hiddenFacts}//${view.voice}//${ask}//${sources}`;
|
|
2365
|
+
}
|
|
2366
|
+
function leadTextOf(view) {
|
|
2367
|
+
if (view.voice.length > 0) return view.voice;
|
|
2368
|
+
if (view.ask !== void 0) return view.ask.question;
|
|
2369
|
+
return "";
|
|
2370
|
+
}
|
|
2371
|
+
function PresenceStream({
|
|
2372
|
+
view,
|
|
2373
|
+
slotted,
|
|
2374
|
+
materialized,
|
|
2375
|
+
showHeld,
|
|
2376
|
+
working,
|
|
2377
|
+
brief,
|
|
2378
|
+
onOpenBrief
|
|
2379
|
+
}) {
|
|
2380
|
+
const composed = view;
|
|
2381
|
+
const lead = showHeld ? leadTextOf(composed) : "";
|
|
2382
|
+
const rowFacts = showHeld ? slotted : [];
|
|
2383
|
+
const more = showHeld ? composed.hiddenFacts : 0;
|
|
2384
|
+
const hasDeck = composed.sources.length > 0;
|
|
2385
|
+
const hasVoice = lead.length > 0 || working === true;
|
|
2386
|
+
const hasRow = rowFacts.length > 0 || hasDeck || hasVoice;
|
|
2387
|
+
const deckWidth = siftRegionWidth(DECK_SIZE);
|
|
2388
|
+
const railSlots = useHeldSlotCount(
|
|
2389
|
+
rowFacts.reduce((n, f) => Math.max(n, f.slot + 1), 0),
|
|
2390
|
+
CRITERION_EXIT_S * 1e3
|
|
2391
|
+
);
|
|
2392
|
+
const railWidth = criteriaRegionWidth(railSlots, {
|
|
2393
|
+
tail: more > 0,
|
|
2394
|
+
handle: brief !== void 0
|
|
2395
|
+
});
|
|
2396
|
+
return /* @__PURE__ */ jsx24("div", { className: presenceClass.stream, children: hasRow && /* @__PURE__ */ jsxs14(
|
|
2397
|
+
"div",
|
|
2398
|
+
{
|
|
2399
|
+
className: presenceClass.row,
|
|
2400
|
+
"data-tracks": "band",
|
|
2401
|
+
style: { gridTemplateColumns: bandRowTemplate(railWidth, deckWidth), height: BAND_HEIGHT },
|
|
2402
|
+
children: [
|
|
2403
|
+
/* @__PURE__ */ jsx24(
|
|
2404
|
+
CriteriaRail,
|
|
2405
|
+
{
|
|
2406
|
+
facts: rowFacts,
|
|
2407
|
+
slots: railSlots,
|
|
2408
|
+
hidden: more,
|
|
2409
|
+
brief,
|
|
2410
|
+
onOpenBrief
|
|
2411
|
+
}
|
|
2412
|
+
),
|
|
2413
|
+
/* @__PURE__ */ jsx24(
|
|
2414
|
+
VoiceLine,
|
|
2415
|
+
{
|
|
2416
|
+
className: presenceClass.voiceLine,
|
|
2417
|
+
style: { height: VOICE_LINE_HEIGHT },
|
|
2418
|
+
text: hasVoice ? lead : "",
|
|
2419
|
+
delay: bandRegionDelay("voice")
|
|
2420
|
+
}
|
|
2421
|
+
),
|
|
2422
|
+
/* @__PURE__ */ jsxs14("div", { className: presenceClass.deck, style: { width: deckWidth }, children: [
|
|
2423
|
+
rowFacts.length > 0 && hasDeck && /* @__PURE__ */ jsx24("span", { "aria-hidden": true, className: presenceClass.gate }),
|
|
2424
|
+
/* @__PURE__ */ jsx24(
|
|
2425
|
+
SourceSift,
|
|
2426
|
+
{
|
|
2427
|
+
sources: composed.sources,
|
|
2428
|
+
materialized,
|
|
2429
|
+
criteria: composed.facts.length,
|
|
2430
|
+
size: DECK_SIZE,
|
|
2431
|
+
reserveTrack: true
|
|
2432
|
+
}
|
|
2433
|
+
)
|
|
2434
|
+
] })
|
|
2435
|
+
]
|
|
2436
|
+
}
|
|
2437
|
+
) });
|
|
2438
|
+
}
|
|
2439
|
+
function streamLeadLine(view) {
|
|
2440
|
+
return leadTextOf(view).trim();
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
// src/agent/presence/use-band-facts.ts
|
|
2444
|
+
import * as React21 from "react";
|
|
2445
|
+
import { usePresenceElements as usePresenceElements2, usePresenceLiveTurn as usePresenceLiveTurn2 } from "@40rty/ams-sdk";
|
|
2446
|
+
function useBandFacts() {
|
|
2447
|
+
const elements = usePresenceElements2();
|
|
2448
|
+
const liveTurnId = usePresenceLiveTurn2();
|
|
2449
|
+
const rawView = React21.useMemo(
|
|
2450
|
+
() => derivePresenceView(elements, liveTurnId),
|
|
2451
|
+
[elements, liveTurnId]
|
|
2452
|
+
);
|
|
2453
|
+
useReconcileDismissed(rawView.heldLabels.length > 0 ? rawView.heldLabels : null);
|
|
2454
|
+
const all = useVisibleFactList(rawView.facts);
|
|
2455
|
+
const reachable = all;
|
|
2456
|
+
const view = React21.useMemo(
|
|
2457
|
+
() => withCappedFacts(rawView, all, reachable, PRESENCE_FACT_LIMIT),
|
|
2458
|
+
[rawView, all]
|
|
2459
|
+
);
|
|
2460
|
+
return { view, all: reachable };
|
|
2461
|
+
}
|
|
2462
|
+
|
|
2463
|
+
// src/agent/presence/PresenceFiller.tsx
|
|
2464
|
+
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
2465
|
+
function PresenceFiller() {
|
|
2466
|
+
return /* @__PURE__ */ jsx25("span", { className: presenceClass.filler, "aria-hidden": "true" });
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2469
|
+
// src/agent/presence/AgentPresenceWidget.tsx
|
|
2470
|
+
import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2471
|
+
var SETTLE3 = [0.22, 1, 0.36, 1];
|
|
2472
|
+
function AgentPresenceWidget({
|
|
2473
|
+
expanded,
|
|
2474
|
+
drawer,
|
|
2475
|
+
suppressIdleFallback = false,
|
|
2476
|
+
staticBand = false,
|
|
2477
|
+
chipsOnly = false,
|
|
2478
|
+
hideHeld = false,
|
|
2479
|
+
idleContent
|
|
2480
|
+
}) {
|
|
2481
|
+
const materialized = usePresenceMaterialized();
|
|
2482
|
+
const { isRunning, isSubmitting } = useFourtySession2();
|
|
2483
|
+
const working = isRunning || isSubmitting;
|
|
2484
|
+
const { isMobile } = useFormFactor2();
|
|
2485
|
+
const [measureRef, height] = useMeasuredHeight();
|
|
2486
|
+
const measured = !staticBand && height > 0;
|
|
2487
|
+
const firstMeasure = React22.useRef(true);
|
|
2488
|
+
const snap = firstMeasure.current && measured;
|
|
2489
|
+
React22.useEffect(() => {
|
|
2490
|
+
if (measured) firstMeasure.current = false;
|
|
2491
|
+
}, [measured]);
|
|
2492
|
+
const { view: liveView, all: facts } = useBandFacts();
|
|
2493
|
+
const view = useBandBeat(liveView, compositionSignature(liveView));
|
|
2494
|
+
const slotted = useFactSlots(view.facts);
|
|
2495
|
+
const hasHeld = !hideHeld && viewHasHeld(view);
|
|
2496
|
+
const openBrief = drawer === void 0 ? void 0 : drawer.toggle;
|
|
2497
|
+
const briefOpen = drawer !== void 0 && drawer.open;
|
|
2498
|
+
const hasBriefHandle = drawer !== void 0 && facts.length > 0;
|
|
2499
|
+
if (isMobile) {
|
|
2500
|
+
let node2 = null;
|
|
2501
|
+
if (!viewIsEmpty(view)) {
|
|
2502
|
+
node2 = expanded && hasHeld ? /* @__PURE__ */ jsx26(PresenceBriefBody, { facts }) : /* @__PURE__ */ jsx26(
|
|
2503
|
+
CompactStream,
|
|
2504
|
+
{
|
|
2505
|
+
lead: hasHeld ? streamLeadLine(view) : "",
|
|
2506
|
+
sources: view.sources,
|
|
2507
|
+
materialized,
|
|
2508
|
+
facts: hasHeld ? slotted : [],
|
|
2509
|
+
hiddenFacts: hasHeld ? view.hiddenFacts : 0,
|
|
2510
|
+
chipsOnly
|
|
2511
|
+
}
|
|
2512
|
+
);
|
|
2513
|
+
} else if (!working) {
|
|
2514
|
+
if (idleContent !== void 0) node2 = idleContent;
|
|
2515
|
+
else if (!suppressIdleFallback) node2 = /* @__PURE__ */ jsx26(Fallback, {});
|
|
2516
|
+
}
|
|
2517
|
+
return /* @__PURE__ */ jsxs15("div", { className: presenceClass.root, "data-compact": "true", "data-working": working ? "true" : "false", children: [
|
|
2518
|
+
working && /* @__PURE__ */ jsx26(PresenceFiller, {}),
|
|
2519
|
+
/* @__PURE__ */ jsx26("div", { className: presenceClass.measure, children: /* @__PURE__ */ jsx26(AnimatePresence, { mode: "popLayout", initial: false, children: node2 !== null && /* @__PURE__ */ jsx26(motion.div, { className: presenceClass.frame, ...enter, children: node2 }, viewIsEmpty(view) ? "idle" : "stream") }) })
|
|
2520
|
+
] });
|
|
2521
|
+
}
|
|
2522
|
+
let node = null;
|
|
2523
|
+
let key = "idle";
|
|
2524
|
+
if (!viewIsEmpty(view)) {
|
|
2525
|
+
node = /* @__PURE__ */ jsx26(
|
|
2526
|
+
PresenceStream,
|
|
2527
|
+
{
|
|
2528
|
+
view,
|
|
2529
|
+
slotted,
|
|
2530
|
+
materialized,
|
|
2531
|
+
showHeld: !hideHeld,
|
|
2532
|
+
working,
|
|
2533
|
+
brief: hasBriefHandle && openBrief !== void 0 ? { open: briefOpen, toggle: openBrief } : void 0,
|
|
2534
|
+
onOpenBrief: openBrief
|
|
2535
|
+
}
|
|
2536
|
+
);
|
|
2537
|
+
key = "stream";
|
|
2538
|
+
} else if (working) {
|
|
2539
|
+
key = "silent";
|
|
2540
|
+
} else if (idleContent !== void 0) {
|
|
2541
|
+
node = idleContent;
|
|
2542
|
+
} else if (!suppressIdleFallback) {
|
|
2543
|
+
node = /* @__PURE__ */ jsx26(Fallback, {});
|
|
2544
|
+
}
|
|
2545
|
+
const bandHeight = BAND_HEIGHT;
|
|
2546
|
+
return /* @__PURE__ */ jsxs15(
|
|
2547
|
+
motion.div,
|
|
2548
|
+
{
|
|
2549
|
+
className: presenceClass.root,
|
|
2550
|
+
"data-working": working ? "true" : "false",
|
|
2551
|
+
"data-brief": hasBriefHandle ? "true" : "false",
|
|
2552
|
+
initial: false,
|
|
2553
|
+
animate: staticBand ? void 0 : { height: bandHeight },
|
|
2554
|
+
transition: snap ? { duration: 0 } : { duration: 0.7, ease: SETTLE3 },
|
|
2555
|
+
children: [
|
|
2556
|
+
working && /* @__PURE__ */ jsx26(PresenceFiller, {}),
|
|
2557
|
+
/* @__PURE__ */ jsx26("div", { ref: staticBand ? void 0 : measureRef, className: presenceClass.measure, children: /* @__PURE__ */ jsx26(AnimatePresence, { mode: "popLayout", initial: false, children: node !== null && /* @__PURE__ */ jsx26(motion.div, { className: presenceClass.frame, ...enter, children: node }, key) }) })
|
|
2558
|
+
]
|
|
2559
|
+
}
|
|
2560
|
+
);
|
|
2561
|
+
}
|
|
2562
|
+
|
|
2563
|
+
// src/agent/presence/DefaultNotch.tsx
|
|
2564
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
2565
|
+
var DEFAULT_NOTCH_WIDGETS = [
|
|
2566
|
+
{ id: "read", zone: "lead", Component: AgentPresenceWidget }
|
|
2567
|
+
];
|
|
2568
|
+
function DefaultNotch() {
|
|
2569
|
+
return /* @__PURE__ */ jsx27(PresenceNotch, { widgets: DEFAULT_NOTCH_WIDGETS });
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
// src/agent/presence/fact-forms/class-names.ts
|
|
2573
|
+
var factFormClass = {
|
|
2574
|
+
/** A colour value — the swatch and its name. */
|
|
2575
|
+
color: "fourty-presence-fact-color",
|
|
2576
|
+
/** The colour itself, at a size that actually shows the colour. */
|
|
2577
|
+
colorChip: "fourty-presence-fact-color__chip",
|
|
2578
|
+
/** The colour's name beside it. */
|
|
2579
|
+
colorName: "fourty-presence-fact-color__name",
|
|
2580
|
+
/** A numeric value — the figure plus any qualifying words. */
|
|
2581
|
+
figure: "fourty-presence-fact-figure",
|
|
2582
|
+
/** The number itself, carrying any currency mark or comparator. */
|
|
2583
|
+
figureAmount: "fourty-presence-fact-figure__amount",
|
|
2584
|
+
/** "under", "inches" — the quiet words around the number. */
|
|
2585
|
+
figureQualifier: "fourty-presence-fact-figure__qualifier"
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2588
|
+
// src/agent/presence/fact-forms/baseline-forms.tsx
|
|
2589
|
+
import { colorHexOf as colorHexOf2, factFigureParts } from "@40rty/ams-sdk";
|
|
2590
|
+
import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2591
|
+
function BaselineColorFactForm({ fact }) {
|
|
2592
|
+
const hex = colorHexOf2(fact.value);
|
|
2593
|
+
return /* @__PURE__ */ jsxs16("span", { className: factFormClass.color, children: [
|
|
2594
|
+
hex !== null && /* @__PURE__ */ jsx28("span", { "aria-hidden": true, className: factFormClass.colorChip, style: { background: hex } }),
|
|
2595
|
+
/* @__PURE__ */ jsx28("span", { className: factFormClass.colorName, children: fact.value })
|
|
2596
|
+
] });
|
|
2597
|
+
}
|
|
2598
|
+
function BaselineFigureFactForm({ fact }) {
|
|
2599
|
+
const parts = factFigureParts(fact);
|
|
2600
|
+
if (parts === null) return /* @__PURE__ */ jsx28("span", { className: factFormClass.figure, children: fact.value.trim() });
|
|
2601
|
+
return /* @__PURE__ */ jsxs16("span", { className: factFormClass.figure, children: [
|
|
2602
|
+
parts.before.length > 0 && /* @__PURE__ */ jsx28("span", { className: factFormClass.figureQualifier, children: parts.before }),
|
|
2603
|
+
/* @__PURE__ */ jsx28("span", { className: factFormClass.figureAmount, children: parts.figure }),
|
|
2604
|
+
parts.after.length > 0 && /* @__PURE__ */ jsx28("span", { className: factFormClass.figureQualifier, children: parts.after })
|
|
2605
|
+
] });
|
|
2606
|
+
}
|
|
2607
|
+
|
|
2608
|
+
// src/agent/presence/fact-forms/register.ts
|
|
2609
|
+
import { FACT_SHAPE, registerPresenceFactForm } from "@40rty/ams-sdk";
|
|
2610
|
+
function registerBaselineFactForms() {
|
|
2611
|
+
registerPresenceFactForm(FACT_SHAPE.color, { Component: BaselineColorFactForm });
|
|
2612
|
+
registerPresenceFactForm(FACT_SHAPE.figure, { Component: BaselineFigureFactForm });
|
|
2613
|
+
registerPresenceFactForm(FACT_SHAPE.measure, { Component: BaselineFigureFactForm });
|
|
2614
|
+
}
|
|
2615
|
+
|
|
2616
|
+
// src/agent/presence/LayoutMorphSkeleton.tsx
|
|
2617
|
+
import * as React23 from "react";
|
|
2618
|
+
import { useDocumentVisible, useInterval } from "@40rty/ams-sdk";
|
|
2619
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
2620
|
+
var LAYOUT_ARCHETYPES = [
|
|
2621
|
+
{ rects: [{ l: 0, t: 0, w: 100, h: 100 }] },
|
|
2622
|
+
{
|
|
2623
|
+
rects: [
|
|
2624
|
+
{ l: 0, t: 0, w: 32, h: 100 },
|
|
2625
|
+
{ l: 34, t: 0, w: 32, h: 100 },
|
|
2626
|
+
{ l: 68, t: 0, w: 32, h: 100 }
|
|
2627
|
+
]
|
|
2628
|
+
},
|
|
2629
|
+
{
|
|
2630
|
+
rects: [
|
|
2631
|
+
{ l: 0, t: 0, w: 32, h: 49 },
|
|
2632
|
+
{ l: 34, t: 0, w: 32, h: 49 },
|
|
2633
|
+
{ l: 68, t: 0, w: 32, h: 49 },
|
|
2634
|
+
{ l: 0, t: 51, w: 32, h: 49 },
|
|
2635
|
+
{ l: 34, t: 51, w: 32, h: 49 },
|
|
2636
|
+
{ l: 68, t: 51, w: 32, h: 49 }
|
|
2637
|
+
]
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
rects: [
|
|
2641
|
+
{ l: 0, t: 0, w: 64, h: 100 },
|
|
2642
|
+
{ l: 66, t: 0, w: 34, h: 100 }
|
|
2643
|
+
]
|
|
2644
|
+
},
|
|
2645
|
+
{
|
|
2646
|
+
rects: [
|
|
2647
|
+
{ l: 0, t: 0, w: 100, h: 30 },
|
|
2648
|
+
{ l: 0, t: 32, w: 49, h: 68 },
|
|
2649
|
+
{ l: 51, t: 32, w: 49, h: 68 }
|
|
2650
|
+
]
|
|
2651
|
+
},
|
|
2652
|
+
{
|
|
2653
|
+
rects: [
|
|
2654
|
+
{ l: 0, t: 0, w: 30, h: 100 },
|
|
2655
|
+
{ l: 32, t: 0, w: 68, h: 48 },
|
|
2656
|
+
{ l: 32, t: 50, w: 68, h: 50 }
|
|
2657
|
+
]
|
|
2658
|
+
}
|
|
2659
|
+
];
|
|
2660
|
+
var TILE_SLOTS = 6;
|
|
2661
|
+
var COLLAPSED = { l: 50, t: 50, w: 0, h: 0 };
|
|
2662
|
+
var MORPH_MS = 3200;
|
|
2663
|
+
function useLayoutMorph(active) {
|
|
2664
|
+
const reduce = useReducedMotion();
|
|
2665
|
+
const visible = useDocumentVisible();
|
|
2666
|
+
const phrases = useLabels().presence.composing;
|
|
2667
|
+
const [index, setIndex] = React23.useState(0);
|
|
2668
|
+
const advancing = active && visible && reduce !== true;
|
|
2669
|
+
useInterval(() => setIndex((x) => (x + 1) % LAYOUT_ARCHETYPES.length), MORPH_MS, advancing);
|
|
2670
|
+
const archetype = LAYOUT_ARCHETYPES[index];
|
|
2671
|
+
const label = phrases.length > 0 ? phrases[index % phrases.length] : "";
|
|
2672
|
+
return { index, label, rects: archetype.rects };
|
|
2673
|
+
}
|
|
2674
|
+
function LayoutMorphSkeleton({ rects }) {
|
|
2675
|
+
return /* @__PURE__ */ jsx29("div", { className: presenceClass.layoutMorph, "aria-hidden": true, children: Array.from({ length: TILE_SLOTS }, (_, i) => {
|
|
2676
|
+
const on = i < rects.length;
|
|
2677
|
+
const rect = on ? rects[i] : COLLAPSED;
|
|
2678
|
+
return /* @__PURE__ */ jsx29(
|
|
2679
|
+
"div",
|
|
2680
|
+
{
|
|
2681
|
+
className: presenceClass.layoutMorphTile,
|
|
2682
|
+
style: {
|
|
2683
|
+
left: `${rect.l}%`,
|
|
2684
|
+
top: `${rect.t}%`,
|
|
2685
|
+
width: `${rect.w}%`,
|
|
2686
|
+
height: `${rect.h}%`,
|
|
2687
|
+
opacity: on ? 1 : 0
|
|
2688
|
+
}
|
|
2689
|
+
},
|
|
2690
|
+
i
|
|
2691
|
+
);
|
|
2692
|
+
}) });
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
// src/agent/presence/InlinePresenceRead.tsx
|
|
2696
|
+
import { useAgentPresence, useAgentPresenceFresh } from "@40rty/ams-sdk";
|
|
2697
|
+
import { jsx as jsx30, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2698
|
+
function InlinePresenceRead({
|
|
2699
|
+
flowId,
|
|
2700
|
+
compact = false
|
|
2701
|
+
}) {
|
|
2702
|
+
const { kind, frame } = useAgentPresence(flowId);
|
|
2703
|
+
const fresh = useAgentPresenceFresh(flowId);
|
|
2704
|
+
const hasRead = kind === "held" && frame !== null && fresh;
|
|
2705
|
+
const readText = hasRead && frame !== null && typeof frame.text === "string" ? frame.text : "";
|
|
2706
|
+
const morph = useLayoutMorph(true);
|
|
2707
|
+
const statusText = readText.length > 0 ? readText : morph.label;
|
|
2708
|
+
return /* @__PURE__ */ jsxs17("div", { className: presenceClass.loaderColumn, children: [
|
|
2709
|
+
/* @__PURE__ */ jsx30(LayoutMorphSkeleton, { rects: morph.rects }),
|
|
2710
|
+
/* @__PURE__ */ jsx30("div", { className: presenceClass.status, "aria-live": "polite", children: /* @__PURE__ */ jsx30(AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ jsx30(motion.span, { className: presenceClass.prose, ...enter, children: statusText }, statusText) }) })
|
|
2711
|
+
] });
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
// src/agent/presence/KnowledgePeek.tsx
|
|
2715
|
+
import * as React24 from "react";
|
|
2716
|
+
import { usePresenceElements as usePresenceElements3, usePresenceLiveTurn as usePresenceLiveTurn3 } from "@40rty/ams-sdk";
|
|
2717
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
2718
|
+
function PresenceBriefRail() {
|
|
2719
|
+
const elements = usePresenceElements3();
|
|
2720
|
+
const liveTurnId = usePresenceLiveTurn3();
|
|
2721
|
+
const view = React24.useMemo(
|
|
2722
|
+
() => derivePresenceView(elements, liveTurnId),
|
|
2723
|
+
[elements, liveTurnId]
|
|
2724
|
+
);
|
|
2725
|
+
const facts = useRetainedFacts(useUndismissedFacts(view.facts));
|
|
2726
|
+
if (facts.length === 0) return null;
|
|
2727
|
+
return /* @__PURE__ */ jsx31(FactChips, { facts });
|
|
2728
|
+
}
|
|
2729
|
+
|
|
2730
|
+
export {
|
|
2731
|
+
DEFAULT_LABELS,
|
|
2732
|
+
LabelsProvider,
|
|
2733
|
+
useLabels,
|
|
2734
|
+
PresenceNotch,
|
|
2735
|
+
presenceClass,
|
|
2736
|
+
Eyebrow,
|
|
2737
|
+
Rule,
|
|
2738
|
+
Fallback,
|
|
2739
|
+
readFacts,
|
|
2740
|
+
readLabel,
|
|
2741
|
+
useVisibleFacts,
|
|
2742
|
+
useVisibleFactList,
|
|
2743
|
+
useForgetFact,
|
|
2744
|
+
colorSwatch,
|
|
2745
|
+
sourceCardClass,
|
|
2746
|
+
sourceCardState,
|
|
2747
|
+
ink,
|
|
2748
|
+
SOURCE_CARD_BOX,
|
|
2749
|
+
sourceCardBox,
|
|
2750
|
+
platePad,
|
|
2751
|
+
ruleWeight,
|
|
2752
|
+
SourceCardFrame,
|
|
2753
|
+
SourcePlate,
|
|
2754
|
+
SourceImage,
|
|
2755
|
+
CaptionRule,
|
|
2756
|
+
RuledLines,
|
|
2757
|
+
CornerFold,
|
|
2758
|
+
ProductSourceCard,
|
|
2759
|
+
productSourceForm,
|
|
2760
|
+
CollectionSourceCard,
|
|
2761
|
+
collectionSourceForm,
|
|
2762
|
+
ArticleSourceCard,
|
|
2763
|
+
articleSourceForm,
|
|
2764
|
+
PolicySourceCard,
|
|
2765
|
+
policySourceForm,
|
|
2766
|
+
ReviewSourceCard,
|
|
2767
|
+
reviewSourceForm,
|
|
2768
|
+
BASELINE_SOURCE_KINDS,
|
|
2769
|
+
registerDefaultPresenceSourceForms,
|
|
2770
|
+
PresenceSourceCard,
|
|
2771
|
+
SIFT_BAND_HEIGHT,
|
|
2772
|
+
siftRegionWidth,
|
|
2773
|
+
FactChips,
|
|
2774
|
+
CRITERION_SLOT,
|
|
2775
|
+
CRITERION_GAP,
|
|
2776
|
+
CRITERION_TAIL_LANE,
|
|
2777
|
+
VOICE_MIN_WIDTH,
|
|
2778
|
+
criteriaRegionWidth,
|
|
2779
|
+
criteriaRailTemplate,
|
|
2780
|
+
bandRowTemplate,
|
|
2781
|
+
PRESENCE_FACT_LIMIT,
|
|
2782
|
+
PRESENCE_DURABLE_SLOTS,
|
|
2783
|
+
FoldedRead,
|
|
2784
|
+
BriefHandle,
|
|
2785
|
+
PresenceBriefBody,
|
|
2786
|
+
PresenceBriefDrawer,
|
|
2787
|
+
useMeasuredHeight,
|
|
2788
|
+
Thought,
|
|
2789
|
+
Dossier,
|
|
2790
|
+
registerDefaultPresenceForms,
|
|
2791
|
+
AgentPresenceWidget,
|
|
2792
|
+
DefaultNotch,
|
|
2793
|
+
factFormClass,
|
|
2794
|
+
BaselineColorFactForm,
|
|
2795
|
+
BaselineFigureFactForm,
|
|
2796
|
+
registerBaselineFactForms,
|
|
2797
|
+
LayoutMorphSkeleton,
|
|
2798
|
+
InlinePresenceRead,
|
|
2799
|
+
PresenceBriefRail
|
|
2800
|
+
};
|