@tiledev/sdk-apptile-live-selling 0.13.0 → 0.14.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.
Files changed (111) hide show
  1. package/README.md +94 -12
  2. package/dist/giveawayPrizeLines.d.ts +10 -0
  3. package/dist/giveawayPrizeLines.d.ts.map +1 -1
  4. package/dist/giveawayPrizeLines.js +11 -1
  5. package/dist/giveawayPrizeLines.js.map +1 -1
  6. package/dist/hiddenShows.d.ts +10 -0
  7. package/dist/hiddenShows.d.ts.map +1 -1
  8. package/dist/hiddenShows.js +11 -0
  9. package/dist/hiddenShows.js.map +1 -1
  10. package/dist/index.d.ts +7 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +32 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/livePages.d.ts +79 -0
  15. package/dist/livePages.d.ts.map +1 -0
  16. package/dist/livePages.js +90 -0
  17. package/dist/livePages.js.map +1 -0
  18. package/dist/liveRoom.d.ts +21 -0
  19. package/dist/liveRoom.d.ts.map +1 -0
  20. package/dist/liveRoom.js +28 -0
  21. package/dist/liveRoom.js.map +1 -0
  22. package/dist/pageOptions.d.ts +100 -0
  23. package/dist/pageOptions.d.ts.map +1 -0
  24. package/dist/pageOptions.js +82 -0
  25. package/dist/pageOptions.js.map +1 -0
  26. package/dist/pageTypes.d.ts +127 -0
  27. package/dist/pageTypes.d.ts.map +1 -0
  28. package/dist/pageTypes.js +3 -0
  29. package/dist/pageTypes.js.map +1 -0
  30. package/dist/react/LiveSellingProvider.d.ts +23 -1
  31. package/dist/react/LiveSellingProvider.d.ts.map +1 -1
  32. package/dist/react/LiveSellingProvider.js +26 -2
  33. package/dist/react/LiveSellingProvider.js.map +1 -1
  34. package/dist/react/index.d.ts +10 -0
  35. package/dist/react/index.d.ts.map +1 -1
  36. package/dist/react/index.js +29 -1
  37. package/dist/react/index.js.map +1 -1
  38. package/dist/react/index.web.d.ts +11 -32
  39. package/dist/react/index.web.d.ts.map +1 -1
  40. package/dist/react/index.web.js +46 -139
  41. package/dist/react/index.web.js.map +1 -1
  42. package/dist/react/navigation.d.ts +13 -0
  43. package/dist/react/navigation.d.ts.map +1 -0
  44. package/dist/react/navigation.js +7 -0
  45. package/dist/react/navigation.js.map +1 -0
  46. package/dist/react/platformSession.d.ts +16 -0
  47. package/dist/react/platformSession.d.ts.map +1 -0
  48. package/dist/react/platformSession.js +28 -0
  49. package/dist/react/platformSession.js.map +1 -0
  50. package/dist/react/platformSession.web.d.ts +35 -0
  51. package/dist/react/platformSession.web.d.ts.map +1 -0
  52. package/dist/react/platformSession.web.js +148 -0
  53. package/dist/react/platformSession.web.js.map +1 -0
  54. package/dist/react/replayPlayer.d.ts +74 -0
  55. package/dist/react/replayPlayer.d.ts.map +1 -0
  56. package/dist/react/replayPlayer.js +279 -0
  57. package/dist/react/replayPlayer.js.map +1 -0
  58. package/dist/react/shopifyProviders.d.ts +68 -0
  59. package/dist/react/shopifyProviders.d.ts.map +1 -0
  60. package/dist/react/shopifyProviders.js +98 -0
  61. package/dist/react/shopifyProviders.js.map +1 -0
  62. package/dist/react/useKeepScreenAwake.d.ts +2 -0
  63. package/dist/react/useKeepScreenAwake.d.ts.map +1 -0
  64. package/dist/react/useKeepScreenAwake.js +34 -0
  65. package/dist/react/useKeepScreenAwake.js.map +1 -0
  66. package/dist/react/useLiveAuction.d.ts +104 -0
  67. package/dist/react/useLiveAuction.d.ts.map +1 -0
  68. package/dist/react/useLiveAuction.js +244 -0
  69. package/dist/react/useLiveAuction.js.map +1 -0
  70. package/dist/react/useLiveChat.d.ts +75 -0
  71. package/dist/react/useLiveChat.d.ts.map +1 -0
  72. package/dist/react/useLiveChat.js +131 -0
  73. package/dist/react/useLiveChat.js.map +1 -0
  74. package/dist/react/useLiveGiveawaysAndPolls.d.ts +84 -0
  75. package/dist/react/useLiveGiveawaysAndPolls.d.ts.map +1 -0
  76. package/dist/react/useLiveGiveawaysAndPolls.js +180 -0
  77. package/dist/react/useLiveGiveawaysAndPolls.js.map +1 -0
  78. package/dist/react/useLivePage.d.ts +113 -0
  79. package/dist/react/useLivePage.d.ts.map +1 -0
  80. package/dist/react/useLivePage.js +264 -0
  81. package/dist/react/useLivePage.js.map +1 -0
  82. package/dist/react/useLiveShop.d.ts +83 -0
  83. package/dist/react/useLiveShop.d.ts.map +1 -0
  84. package/dist/react/useLiveShop.js +165 -0
  85. package/dist/react/useLiveShop.js.map +1 -0
  86. package/dist/react/useReplayPage.d.ts +117 -0
  87. package/dist/react/useReplayPage.d.ts.map +1 -0
  88. package/dist/react/useReplayPage.js +504 -0
  89. package/dist/react/useReplayPage.js.map +1 -0
  90. package/dist/showCredit.d.ts +87 -0
  91. package/dist/showCredit.d.ts.map +1 -0
  92. package/dist/showCredit.js +120 -0
  93. package/dist/showCredit.js.map +1 -0
  94. package/dist/ui/BubbleFrame.d.ts +38 -0
  95. package/dist/ui/BubbleFrame.d.ts.map +1 -0
  96. package/dist/ui/BubbleFrame.js +181 -0
  97. package/dist/ui/BubbleFrame.js.map +1 -0
  98. package/dist/ui/LiveBubble.d.ts +37 -0
  99. package/dist/ui/LiveBubble.d.ts.map +1 -0
  100. package/dist/ui/LiveBubble.js +101 -0
  101. package/dist/ui/LiveBubble.js.map +1 -0
  102. package/dist/ui/ReplayBubble.d.ts +23 -0
  103. package/dist/ui/ReplayBubble.d.ts.map +1 -0
  104. package/dist/ui/ReplayBubble.js +65 -0
  105. package/dist/ui/ReplayBubble.js.map +1 -0
  106. package/dist/ui.d.ts +27 -0
  107. package/dist/ui.d.ts.map +1 -0
  108. package/dist/ui.js +34 -0
  109. package/dist/ui.js.map +1 -0
  110. package/package.json +36 -5
  111. package/ui/package.json +6 -0
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ShopifyLiveSellingProvider = ShopifyLiveSellingProvider;
7
+ exports.ShopifyLiveSessionProvider = ShopifyLiveSessionProvider;
8
+ /**
9
+ * The live-selling providers for an app on `@tiledev/sdk-shopify` (0.14.0, moved from amore-v2's
10
+ * `AppLiveSellingProvider` and `AppLiveSessionProvider`, `src/core/providers/liveSelling.tsx` and
11
+ * `liveSession.tsx`): `LiveSellingProvider` and `LiveSessionProvider` filled in from the app's own
12
+ * sdk-shopify client (`shopify`) and customer (`useCustomer`), so the app passes only its config.
13
+ *
14
+ * `createElement` rather than JSX, like the rest of the package, so this stays a plain `.ts`.
15
+ */
16
+ const async_storage_1 = __importDefault(require("@react-native-async-storage/async-storage"));
17
+ const sdk_shopify_1 = require("@tiledev/sdk-shopify");
18
+ const react_1 = require("react");
19
+ const shopifyCommerce_1 = require("../shopifyCommerce");
20
+ const shopifyIdentity_1 = require("../shopifyIdentity");
21
+ const showNames_1 = require("../showNames");
22
+ const LiveSellingProvider_1 = require("./LiveSellingProvider");
23
+ const platformSession_1 = require("./platformSession");
24
+ /**
25
+ * `LiveSellingProvider` on the app's sdk-shopify client and customer (the README's §4 "On Shopify"):
26
+ * products from Shopify at the card photo size; the wins checkout, a cart of its own (a won lot stamped
27
+ * `_winningBid`, a prize `prizeWriteKey`) with `source_name`, `source_type: "auction"` and `auction_id`
28
+ * for the order webhook; and the bidder, the customer's numeric id, only for a Shopify sign-in (the
29
+ * winner's record is on the Customer Account API). The phone's storage keeps the poll votes, a
30
+ * signed-out shopper's name and the accepted terms across relaunches. Hidden shows (`hiddenShows`) are
31
+ * hidden from every shopper whose email isn't the team's: the signed-in customer's email is the
32
+ * provider's `viewerEmail`, so a sign-in reaches every screen at once.
33
+ *
34
+ * Mount it inside sdk-shopify's `ShopifyProvider`, above the navigator. `routes`, `track`, `onWarning`
35
+ * and `shopName` pass through to `LiveSellingProvider`.
36
+ */
37
+ function ShopifyLiveSellingProvider({ children, config, cartSourceName, prizeWriteKey, imageTransform = sdk_shopify_1.CARD_IMAGE, ...pageProps }) {
38
+ var _a, _b;
39
+ const customer = (0, sdk_shopify_1.useCustomer)();
40
+ const latestCustomer = (0, react_1.useRef)(customer);
41
+ latestCustomer.current = customer;
42
+ const liveConfig = (0, react_1.useMemo)(() => {
43
+ var _a;
44
+ const signedIn = (0, shopifyIdentity_1.createShopifyLiveIdentity)(() => latestCustomer.current);
45
+ return {
46
+ ...config,
47
+ storage: (_a = config.storage) !== null && _a !== void 0 ? _a : async_storage_1.default,
48
+ identity: signedIn.identity,
49
+ customerAccountRequest: signedIn.customerAccountRequest,
50
+ commerce: (0, shopifyCommerce_1.createShopifyLiveCommerce)({
51
+ shopify: sdk_shopify_1.shopify,
52
+ cartSourceName,
53
+ prizeWriteKey,
54
+ buyer: signedIn.buyer,
55
+ imageTransform,
56
+ }),
57
+ };
58
+ }, [config, cartSourceName, prizeWriteKey, imageTransform]);
59
+ return (0, react_1.createElement)(LiveSellingProvider_1.LiveSellingProvider, {
60
+ ...pageProps,
61
+ config: liveConfig,
62
+ viewerEmail: (_b = (_a = customer.customer) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : null,
63
+ children,
64
+ });
65
+ }
66
+ /**
67
+ * The app's one live session (`LiveSessionProvider`; decided 2026-10-05 by amore-v2's Head of
68
+ * Engineering: joined app-wide, as Freckled Poppy). Mount it above the navigator, inside
69
+ * `ShopifyLiveSellingProvider`, because Zego's engine holds exactly one room and several places show
70
+ * the same show: the Live tab's card, the Live screen and the bubble. Each binds to the picture with
71
+ * `LiveVideoTarget`; none owns the room.
72
+ *
73
+ * - **`viewerName`** is the signed-in shopper's (`viewerNameFor`: first and last name, else whichever
74
+ * the account has; never an email nor its part before the @), so a name edited on Account reaches the
75
+ * room without a restart. Null with no name on the account, or signed out, so a name the shopper typed
76
+ * on this phone stays in charge (the comment box asks for one: `useLivePage`'s chat).
77
+ * - **`blockedNames`** passes through: the names nobody watching may go by (Host and Moderator unless
78
+ * the app says otherwise).
79
+ * - **`onPipRestore`**: the phone's picture-in-picture window, opened from the Live screen and then
80
+ * expanded (or, on iOS, left up when the shopper came back by the app's icon), comes back to the Live
81
+ * screen (`routes.openLive`). A window opened from the bubble goes back to the bubble instead, which
82
+ * the session does itself without calling this. An `onPipRestore` of the app's own replaces it.
83
+ */
84
+ function ShopifyLiveSessionProvider({ children, onPipRestore, ...props }) {
85
+ const { customer } = (0, sdk_shopify_1.useCustomer)();
86
+ const { routes } = (0, LiveSellingProvider_1.useLivePageOptions)();
87
+ const backToTheLiveShow = (0, react_1.useMemo)(() => onPipRestore !== null && onPipRestore !== void 0 ? onPipRestore : ((streamId) => {
88
+ if (streamId)
89
+ routes.openLive(streamId);
90
+ }), [onPipRestore, routes]);
91
+ return (0, react_1.createElement)(platformSession_1.LiveSessionProvider, {
92
+ ...props,
93
+ viewerName: (0, showNames_1.viewerNameFor)(customer),
94
+ onPipRestore: backToTheLiveShow,
95
+ children,
96
+ });
97
+ }
98
+ //# sourceMappingURL=shopifyProviders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shopifyProviders.js","sourceRoot":"","sources":["../../src/react/shopifyProviders.ts"],"names":[],"mappings":";;;;;AA8DA,gEAmCC;AAwBD,gEAiBC;AA1ID;;;;;;;GAOG;AACH,8FAAqE;AACrE,sDAAwE;AACxE,iCAAuD;AAGvD,wDAA2F;AAC3F,wDAA+D;AAC/D,4CAA6C;AAE7C,+DAA+G;AAC/G,uDAAwD;AA+BxD;;;;;;;;;;;;GAYG;AACH,SAAgB,0BAA0B,CAAC,EACzC,QAAQ,EACR,MAAM,EACN,cAAc,EACd,aAAa,EACb,cAAc,GAAG,wBAAU,EAC3B,GAAG,SAAS,EACoB;;IAChC,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;IAC/B,MAAM,cAAc,GAAG,IAAA,cAAM,EAAC,QAAQ,CAAC,CAAC;IACxC,cAAc,CAAC,OAAO,GAAG,QAAQ,CAAC;IAElC,MAAM,UAAU,GAAG,IAAA,eAAO,EAAoB,GAAG,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,OAAO,IAAA,qBAAa,EAAC,qCAAmB,EAAE;QACxC,GAAG,KAAK;QACR,UAAU,EAAE,IAAA,yBAAa,EAAC,QAAQ,CAAC;QACnC,YAAY,EAAE,iBAAiB;QAC/B,QAAQ;KACT,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function useKeepScreenAwake(active: boolean, tag: string): void;
2
+ //# sourceMappingURL=useKeepScreenAwake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeepScreenAwake.d.ts","sourceRoot":"","sources":["../../src/react/useKeepScreenAwake.ts"],"names":[],"mappings":"AAmBA,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAWrE"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useKeepScreenAwake = useKeepScreenAwake;
4
+ /**
5
+ * `useKeepScreenAwake(active, tag)` (0.14.0, moved from amore-v2's `src/core/hooks/useKeepScreenAwake.ts`,
6
+ * Freckled Poppy's before it): keeps the phone's screen on while `active` is true. A live show runs for
7
+ * an hour and is watched without a touch, so the phone's idle timer would put it to sleep mid-show.
8
+ *
9
+ * - **Driven by a condition, not by the screen being mounted** (expo-keep-awake's own `useKeepAwake`):
10
+ * the Live screen stays mounted under the Cart and the variant page, where it has no claim on the
11
+ * screen.
12
+ * - **One `tag` per caller.** expo-keep-awake releases by tag, so the Live screen and the live bubble
13
+ * holding the same tag would release each other's hold as the show moves between them.
14
+ * - The release waits for the hold to have been taken: both cross to native, and a condition that turns
15
+ * off as soon as it turned on would otherwise release a hold not yet made, leaving it on for good.
16
+ * - A hold or release that fails goes to `LiveSellingProvider`'s `onWarning`.
17
+ */
18
+ const expo_keep_awake_1 = require("expo-keep-awake");
19
+ const react_1 = require("react");
20
+ const pageOptions_1 = require("../pageOptions");
21
+ function useKeepScreenAwake(active, tag) {
22
+ (0, react_1.useEffect)(() => {
23
+ if (!active)
24
+ return;
25
+ const holding = (0, expo_keep_awake_1.activateKeepAwakeAsync)(tag);
26
+ holding.catch((error) => (0, pageOptions_1.reportLiveWarning)(error, { at: 'useKeepScreenAwake.activate', tag }));
27
+ return () => {
28
+ holding
29
+ .then(() => (0, expo_keep_awake_1.deactivateKeepAwake)(tag))
30
+ .catch((error) => (0, pageOptions_1.reportLiveWarning)(error, { at: 'useKeepScreenAwake.deactivate', tag }));
31
+ };
32
+ }, [active, tag]);
33
+ }
34
+ //# sourceMappingURL=useKeepScreenAwake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeepScreenAwake.js","sourceRoot":"","sources":["../../src/react/useKeepScreenAwake.ts"],"names":[],"mappings":";;AAmBA,gDAWC;AA9BD;;;;;;;;;;;;;GAaG;AACH,qDAA8E;AAC9E,iCAAkC;AAElC,gDAAmD;AAEnD,SAAgB,kBAAkB,CAAC,MAAe,EAAE,GAAW;IAC7D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,MAAM,OAAO,GAAG,IAAA,wCAAsB,EAAC,GAAG,CAAC,CAAC;QAC5C,OAAO,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,IAAA,+BAAiB,EAAC,KAAK,EAAE,EAAE,EAAE,EAAE,6BAA6B,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QACxG,OAAO,GAAG,EAAE;YACV,OAAO;iBACJ,IAAI,CAAC,GAAG,EAAE,CAAC,IAAA,qCAAmB,EAAC,GAAG,CAAC,CAAC;iBACpC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,IAAA,+BAAiB,EAAC,KAAK,EAAE,EAAE,EAAE,EAAE,+BAA+B,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QACvG,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The Live screen's auction (0.14.0, moved from amore-v2's `src/core/hooks/useLiveAuction.ts`: phase 4
3
+ * of its "Live player plan", bidding). The routes and the store's name are the app's
4
+ * (`LiveSellingProvider`'s `routes` and `shopName`); the route's `streamId` param is read here.
5
+ */
6
+ import { type Product } from '@tiledev/sdk-shopify';
7
+ import type { LiveAuctionLot, LiveAuctionRound, LiveAuctionWinner, LiveBidRefusal, LiveBidStep } from '../pageTypes';
8
+ /** What the Live screen hands the auction. */
9
+ export interface LiveAuctionScreen {
10
+ /**
11
+ * Opens Items You Won over the show, as the header's cart does on an auction show (`useLivePage`'s
12
+ * `header.onCart`, which shrinks a show on air into the bubble first): the unpaid-wins sheet's
13
+ * "Checkout now".
14
+ */
15
+ openItemsYouWon: () => void;
16
+ }
17
+ /**
18
+ * The Live screen's auction, so the screen stays plain tiles. The session never ticks: it gives when
19
+ * the round closes (`auction.closesAt`, on the phone's clock), and the bid bar and the final countdown
20
+ * count down to it themselves (`useAuctionCountdown`), so the screen is never drawn on the round's
21
+ * clock.
22
+ *
23
+ * - **The session does the auction:** the round, the leader, the clock, the hammer and whether it is the
24
+ * shopper's (`session.auction`, `lastWin.isYou`), the bid itself (`actions.placeBid`), and everything
25
+ * in front of a bid (`useAuctionBidGate`: signed in, nothing unpaid from another show, the rules
26
+ * accepted once per phone, a variant chosen once a round). Nothing here repeats them.
27
+ * - **The bid gate's sheets are the bid bar's** (decided, amore-v2's Head of Engineering): `step` tells
28
+ * the bid bar which one to show. Signing in is sdk-shopify's `useSignIn` (Shopify's sheet, or the
29
+ * app's Sign In page: `routes.openSignIn`), as bidding needs a Shopify sign-in (the win is written to
30
+ * the customer).
31
+ * - **Back to the bid after signing in** (the gate's `startSignIn`): the bid waits; once the shopper is
32
+ * a bidder, and if bidding on that lot is still open, it goes through the gate again (unpaid wins,
33
+ * read fresh first, then the rules, the variant). Dropped when bidding on the lot closes, when the
34
+ * shopper asks for another bid, or when this screen is back on show still signed out (the Sign In
35
+ * page closed). Shopify's own sign-in sheet doesn't leave the screen: closed without signing in, the
36
+ * bid waits until bidding on its lot closes. Signed in with the customer still loading, no sign-in
37
+ * opens: the bid waits for them (`signInLoading`).
38
+ * - **A bid goes out at the amount the shopper saw** (the gate's `atAmountShown`): the slide's "Bid
39
+ * $25.00", or the amount typed. The last look before it goes: the round still open with time on the
40
+ * clock, at most the host's ceiling, at least the next bid. If the room moved past it (a sheet was
41
+ * open meanwhile), it isn't sent and the bar says so (`refusal`), rather than going out at a price
42
+ * nobody showed. After a bid goes the bar takes no other for 1.2 s (`bidOnItsWay`). The session sends
43
+ * nothing when it knows no moderator for the round (L3), and a send can fail: `placeBid` says so
44
+ * (`{ sent: false }`), and the bar says the bid didn't go through in the place of the outbid line,
45
+ * and takes a bid again at once (decided 2026-10-06: "Bid didn't go through"). The bar's line goes
46
+ * with the next bid or the round.
47
+ * - **The winner is told** (`win`): everyone sees who won; the shopper sees "You" when they held the
48
+ * highest bid as the round closed and the winning bid is theirs (`lastWin.isYou`). The room sends only
49
+ * the winner's name, not who they are. No name is handed out as an email. The win itself reaches the
50
+ * cart's Items You Won from the server; that page reads it each time it opens.
51
+ * - **The lots** for the Shop button's sheet and the card (`lotStateFor`): open (the round is on it),
52
+ * closed (won: on the show's record, or seen here), else upcoming.
53
+ * - **The store's name** in the bidding rules is `shopName` (old Amore's took the host's, which can be
54
+ * a person's).
55
+ * - **Nothing shows** until the session holds this show's record (`useLiveShow`; never a hidden show the
56
+ * shopper can't see), or on a show that isn't an auction. The web's session is always "ended":
57
+ * nothing draws there.
58
+ */
59
+ export declare function useLiveAuction({ openItemsYouWon }: LiveAuctionScreen): {
60
+ bidBar: {
61
+ visible: boolean;
62
+ currencyCode: string;
63
+ highestBid: number;
64
+ nextBid: number;
65
+ closesAt: number | null;
66
+ extended: boolean;
67
+ extendedSeconds: number;
68
+ isLeading: boolean;
69
+ bidCap: number | null;
70
+ busy: boolean;
71
+ step: LiveBidStep | null;
72
+ shopName: string | undefined;
73
+ lotProduct: Product | null;
74
+ refusal: LiveBidRefusal | null;
75
+ onBid: (amount: number) => void;
76
+ onAcceptTerms: () => void;
77
+ onChooseVariant: (variantId: string) => void;
78
+ onCloseStep: () => void;
79
+ onSeeWins: () => void;
80
+ };
81
+ finalCountdown: {
82
+ visible: boolean;
83
+ closesAt: number | null;
84
+ };
85
+ biddingWar: {
86
+ active: boolean;
87
+ onDone: () => void;
88
+ };
89
+ win: {
90
+ winner: LiveAuctionWinner | null;
91
+ onDone: () => void;
92
+ };
93
+ /** The auction part of the featured card; `useLiveShop` gives the rest. */
94
+ productCard: {
95
+ auctionRound: LiveAuctionRound | null;
96
+ };
97
+ /** The auction part of the Shop button: its sheet lists the lots. */
98
+ shopButton: {
99
+ lots: LiveAuctionLot[] | null;
100
+ };
101
+ };
102
+ /** What `useLiveAuction` hands the Live screen's auction tiles. */
103
+ export type LiveAuction = ReturnType<typeof useLiveAuction>;
104
+ //# sourceMappingURL=useLiveAuction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveAuction.d.ts","sourceRoot":"","sources":["../../src/react/useLiveAuction.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAuC,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAIzF,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAiBrH,8CAA8C;AAC9C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,eAAe,EAAE,MAAM,IAAI,CAAC;CAC7B;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,cAAc,CAAC,EAAE,eAAe,EAAE,EAAE,iBAAiB;;;;;;;;;;;;;;;;wBAqFxD,MAAM;;;;;;;;;;;;;;;;;;IAoGf,2EAA2E;;;;IAE3E,qEAAqE;;;;EAGxE;AAED,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useLiveAuction = useLiveAuction;
4
+ /**
5
+ * The Live screen's auction (0.14.0, moved from amore-v2's `src/core/hooks/useLiveAuction.ts`: phase 4
6
+ * of its "Live player plan", bidding). The routes and the store's name are the app's
7
+ * (`LiveSellingProvider`'s `routes` and `shopName`); the route's `streamId` param is read here.
8
+ */
9
+ const sdk_shopify_1 = require("@tiledev/sdk-shopify");
10
+ const react_1 = require("react");
11
+ const auctionRules_1 = require("../auctionRules");
12
+ const LiveSellingProvider_1 = require("./LiveSellingProvider");
13
+ const platformSession_1 = require("./platformSession");
14
+ const navigation_1 = require("./navigation");
15
+ /**
16
+ * Why a sent bid "didn't go through", in the bar's words (decided 2026-10-06, amore-v2's Head of
17
+ * Engineering): no moderator was known for the round (L3), or the room's send failed. The session's
18
+ * other reasons never reach a shopper here: the gate sends only for a signed-in bidder (`signedOut`)
19
+ * and only while this show's round is open (`noShow`). `noAmount` (a bid of 0, on a lot the host gave
20
+ * no starting bid, before the first bid) has no words yet.
21
+ */
22
+ const DIDNT_GO_THROUGH = new Set(['noModerator', 'sendFailed']);
23
+ /** Money in the lot's currency, for a tile that shows it as words. */
24
+ const moneyIn = (currencyCode) => (amount) => (0, sdk_shopify_1.formatMoney)({ amount: String(amount), currencyCode });
25
+ /**
26
+ * The Live screen's auction, so the screen stays plain tiles. The session never ticks: it gives when
27
+ * the round closes (`auction.closesAt`, on the phone's clock), and the bid bar and the final countdown
28
+ * count down to it themselves (`useAuctionCountdown`), so the screen is never drawn on the round's
29
+ * clock.
30
+ *
31
+ * - **The session does the auction:** the round, the leader, the clock, the hammer and whether it is the
32
+ * shopper's (`session.auction`, `lastWin.isYou`), the bid itself (`actions.placeBid`), and everything
33
+ * in front of a bid (`useAuctionBidGate`: signed in, nothing unpaid from another show, the rules
34
+ * accepted once per phone, a variant chosen once a round). Nothing here repeats them.
35
+ * - **The bid gate's sheets are the bid bar's** (decided, amore-v2's Head of Engineering): `step` tells
36
+ * the bid bar which one to show. Signing in is sdk-shopify's `useSignIn` (Shopify's sheet, or the
37
+ * app's Sign In page: `routes.openSignIn`), as bidding needs a Shopify sign-in (the win is written to
38
+ * the customer).
39
+ * - **Back to the bid after signing in** (the gate's `startSignIn`): the bid waits; once the shopper is
40
+ * a bidder, and if bidding on that lot is still open, it goes through the gate again (unpaid wins,
41
+ * read fresh first, then the rules, the variant). Dropped when bidding on the lot closes, when the
42
+ * shopper asks for another bid, or when this screen is back on show still signed out (the Sign In
43
+ * page closed). Shopify's own sign-in sheet doesn't leave the screen: closed without signing in, the
44
+ * bid waits until bidding on its lot closes. Signed in with the customer still loading, no sign-in
45
+ * opens: the bid waits for them (`signInLoading`).
46
+ * - **A bid goes out at the amount the shopper saw** (the gate's `atAmountShown`): the slide's "Bid
47
+ * $25.00", or the amount typed. The last look before it goes: the round still open with time on the
48
+ * clock, at most the host's ceiling, at least the next bid. If the room moved past it (a sheet was
49
+ * open meanwhile), it isn't sent and the bar says so (`refusal`), rather than going out at a price
50
+ * nobody showed. After a bid goes the bar takes no other for 1.2 s (`bidOnItsWay`). The session sends
51
+ * nothing when it knows no moderator for the round (L3), and a send can fail: `placeBid` says so
52
+ * (`{ sent: false }`), and the bar says the bid didn't go through in the place of the outbid line,
53
+ * and takes a bid again at once (decided 2026-10-06: "Bid didn't go through"). The bar's line goes
54
+ * with the next bid or the round.
55
+ * - **The winner is told** (`win`): everyone sees who won; the shopper sees "You" when they held the
56
+ * highest bid as the round closed and the winning bid is theirs (`lastWin.isYou`). The room sends only
57
+ * the winner's name, not who they are. No name is handed out as an email. The win itself reaches the
58
+ * cart's Items You Won from the server; that page reads it each time it opens.
59
+ * - **The lots** for the Shop button's sheet and the card (`lotStateFor`): open (the round is on it),
60
+ * closed (won: on the show's record, or seen here), else upcoming.
61
+ * - **The store's name** in the bidding rules is `shopName` (old Amore's took the host's, which can be
62
+ * a person's).
63
+ * - **Nothing shows** until the session holds this show's record (`useLiveShow`; never a hidden show the
64
+ * shopper can't see), or on a show that isn't an auction. The web's session is always "ended":
65
+ * nothing draws there.
66
+ */
67
+ function useLiveAuction({ openItemsYouWon }) {
68
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
69
+ const streamId = (_b = (_a = (0, navigation_1.useRoute)().params) === null || _a === void 0 ? void 0 : _a.streamId) !== null && _b !== void 0 ? _b : '';
70
+ const isFocused = (0, navigation_1.useIsFocused)();
71
+ const session = (0, platformSession_1.useLiveSession)();
72
+ const { placeBid, dismissAuctionWin } = session.actions;
73
+ const customer = (0, sdk_shopify_1.useCustomer)();
74
+ const nav = (0, navigation_1.useNavigation)();
75
+ const { routes, shopName } = (0, LiveSellingProvider_1.useLivePageOptions)();
76
+ const signIn = (0, sdk_shopify_1.useSignIn)({ onOpenSignInPage: (method) => routes.openSignIn(method, nav) });
77
+ const { auction } = session;
78
+ // ─── Which show ────────────────────────────────────────────────────────────────────────────────
79
+ // The session's record once it is this show's: right after the pin it can still hold the last show's.
80
+ const { show, onAir, capabilities } = (0, platformSession_1.useLiveShow)(streamId);
81
+ const isAuction = !!show && capabilities.canBid;
82
+ const roundOpen = isAuction && onAir && auction.biddingOpen;
83
+ // ─── Who is bidding ────────────────────────────────────────────────────────────────────────────
84
+ // The app's bidder (the identity's `bidderId`): a Shopify sign-in with the customer loaded.
85
+ const isBidder = !!customer.loggedIn && customer.sessionKind === 'shopify' && !!((_c = customer.customer) === null || _c === void 0 ? void 0 : _c.id);
86
+ // Signed in, the customer still loading (or the stored sign-in still being read): not someone to send to sign-in.
87
+ const bidderLoading = !isBidder && (!!customer.restoring || (!!customer.loggedIn && customer.sessionKind === 'shopify'));
88
+ // ─── The lot under the hammer ──────────────────────────────────────────────────────────────────
89
+ // The lot the host opened the round on, which may lead the featured product (old Amore's).
90
+ const lot = (0, react_1.useMemo)(() => {
91
+ var _a;
92
+ if (!auction.storeProductId)
93
+ return session.activeProduct;
94
+ return (_a = session.products.find((product) => product.storeProductId === auction.storeProductId)) !== null && _a !== void 0 ? _a : session.activeProduct;
95
+ }, [auction.storeProductId, session.products, session.activeProduct]);
96
+ const lotProduct = (_d = lot === null || lot === void 0 ? void 0 : lot.raw) !== null && _d !== void 0 ? _d : null;
97
+ const currencyCode = (_g = (_e = lot === null || lot === void 0 ? void 0 : lot.currencyCode) !== null && _e !== void 0 ? _e : (_f = session.products[0]) === null || _f === void 0 ? void 0 : _f.currencyCode) !== null && _g !== void 0 ? _g : 'USD';
98
+ const money = (0, react_1.useMemo)(() => moneyIn(currencyCode), [currencyCode]);
99
+ // ─── A bid that didn't go through ──────────────────────────────────────────────────────────────
100
+ /** The bar's one line about the last bid: the gate's refusal (outbid, over the ceiling), or a bid that didn't go through. */
101
+ const [barMessage, setBarMessage] = (0, react_1.useState)(null);
102
+ /** The last bid sent didn't go through: the bar takes another at once, rather than after its 1.2 s. */
103
+ const [lastBidFailed, setLastBidFailed] = (0, react_1.useState)(false);
104
+ const messagesSoFar = (0, react_1.useRef)(0);
105
+ const mounted = (0, react_1.useRef)(true);
106
+ (0, react_1.useEffect)(() => () => {
107
+ mounted.current = false;
108
+ }, []);
109
+ /** The session's bid, and what it answered: a bid that didn't go through is said on the bar. */
110
+ const placeBidAndSay = (0, react_1.useCallback)(async (options) => {
111
+ var _a;
112
+ setLastBidFailed(false);
113
+ const result = await placeBid(options);
114
+ if (mounted.current && !result.sent && DIDNT_GO_THROUGH.has(result.reason)) {
115
+ messagesSoFar.current += 1;
116
+ setBarMessage({ id: messagesSoFar.current, reason: 'notSent', amount: (_a = options === null || options === void 0 ? void 0 : options.amount) !== null && _a !== void 0 ? _a : 0 });
117
+ setLastBidFailed(true);
118
+ }
119
+ return result;
120
+ }, [placeBid]);
121
+ // ─── The bid gate ──────────────────────────────────────────────────────────────────────────────
122
+ const gate = (0, platformSession_1.useAuctionBidGate)({
123
+ streamingId: (_h = show === null || show === void 0 ? void 0 : show.streamingId) !== null && _h !== void 0 ? _h : null,
124
+ isLoggedIn: isBidder,
125
+ biddingOpen: roundOpen,
126
+ variantCount: (_j = lot === null || lot === void 0 ? void 0 : lot.variants.length) !== null && _j !== void 0 ? _j : 0,
127
+ placeBid: placeBidAndSay,
128
+ atAmountShown: true,
129
+ round: auction,
130
+ startSignIn: signIn.start,
131
+ signInLoading: bidderLoading,
132
+ screenOnShow: isFocused,
133
+ });
134
+ const { dismiss, refreshUnpaidWins, requestBid } = gate;
135
+ // The gate's refusals take the bar's line as they come.
136
+ const gateRefusal = gate.refusal;
137
+ (0, react_1.useEffect)(() => {
138
+ if (!gateRefusal)
139
+ return;
140
+ messagesSoFar.current += 1;
141
+ setBarMessage({ ...gateRefusal, id: messagesSoFar.current });
142
+ }, [gateRefusal]);
143
+ // The line goes with the next bid, and with the round (closed, or another lot's).
144
+ const bid = (0, react_1.useCallback)((amount) => {
145
+ setBarMessage(null);
146
+ requestBid(amount);
147
+ }, [requestBid]);
148
+ (0, react_1.useEffect)(() => {
149
+ setBarMessage(null);
150
+ setLastBidFailed(false);
151
+ }, [roundOpen, auction.storeProductId]);
152
+ // Unpaid wins are read again each time the screen comes back (the shopper may have just paid them).
153
+ (0, navigation_1.useFocusEffect)((0, react_1.useCallback)(() => {
154
+ refreshUnpaidWins();
155
+ }, [refreshUnpaidWins]));
156
+ // The gate signs the shopper in itself (`startSignIn`), so it never stops at "signIn".
157
+ const step = gate.blocker === 'signIn' ? null : gate.blocker;
158
+ const seeWins = (0, react_1.useCallback)(() => {
159
+ dismiss();
160
+ openItemsYouWon();
161
+ }, [dismiss, openItemsYouWon]);
162
+ // ─── The bidding war, once a round ─────────────────────────────────────────────────────────────
163
+ const [warAnnounced, setWarAnnounced] = (0, react_1.useState)(false);
164
+ (0, react_1.useEffect)(() => {
165
+ if (!auction.biddingOpen)
166
+ setWarAnnounced(false);
167
+ }, [auction.biddingOpen]);
168
+ // ─── The hammer ────────────────────────────────────────────────────────────────────────────────
169
+ const lastWin = auction.lastWin;
170
+ const winner = (0, react_1.useMemo)(() => {
171
+ var _a;
172
+ if (!lastWin || !isAuction)
173
+ return null;
174
+ return {
175
+ key: `${(_a = lastWin.storeProductId) !== null && _a !== void 0 ? _a : ''}|${lastWin.userName}|${lastWin.winningBid}`,
176
+ name: lastWin.userName,
177
+ amount: money(lastWin.winningBid),
178
+ isYou: lastWin.isYou,
179
+ };
180
+ }, [lastWin, isAuction, money]);
181
+ // ─── The lots and the featured lot's round ─────────────────────────────────────────────────────
182
+ const { biddingOpen, storeProductId: roundLotId, wonLotIds } = auction;
183
+ const stateOf = (0, react_1.useCallback)((storeProductId) => (0, auctionRules_1.lotStateFor)(storeProductId, { biddingOpen, storeProductId: roundLotId, wonLotIds }, show), [biddingOpen, roundLotId, wonLotIds, show]);
184
+ const lots = (0, react_1.useMemo)(() => {
185
+ if (!isAuction)
186
+ return null;
187
+ return session.products.flatMap((item) => {
188
+ var _a;
189
+ if (!item.raw)
190
+ return [];
191
+ // The lot's opening bid, joined onto the product from the record by the session.
192
+ const startingBid = (_a = item.baseBidPrice) !== null && _a !== void 0 ? _a : null;
193
+ return [{ product: item.raw, startingBid: startingBid !== null ? money(startingBid) : null, state: stateOf(item.storeProductId) }];
194
+ });
195
+ }, [isAuction, session.products, money, stateOf]);
196
+ const featured = session.activeProduct;
197
+ const auctionRound = (0, react_1.useMemo)(() => {
198
+ if (!isAuction || !featured)
199
+ return null;
200
+ const state = stateOf(featured.storeProductId);
201
+ const onThisLot = state === 'open';
202
+ return {
203
+ state,
204
+ highestBid: onThisLot && auction.highestBid > 0 ? money(auction.highestBid) : null,
205
+ leaderName: onThisLot ? auction.leaderName || null : null,
206
+ leaderIsYou: onThisLot && auction.isLeading,
207
+ };
208
+ }, [isAuction, featured, stateOf, auction.highestBid, auction.leaderName, auction.isLeading, money]);
209
+ return {
210
+ bidBar: {
211
+ visible: roundOpen,
212
+ currencyCode,
213
+ highestBid: auction.highestBid,
214
+ nextBid: auction.nextBid,
215
+ closesAt: auction.closesAt,
216
+ extended: auction.extended,
217
+ extendedSeconds: Math.round(auction.extendedBiddingMs / 1000),
218
+ isLeading: auction.isLeading,
219
+ bidCap: auction.bidCap,
220
+ busy: gate.bidOnItsWay && !lastBidFailed,
221
+ step: roundOpen ? step : null,
222
+ // The store's name in the bidding rules (old Amore's took the host's, which can be a person's).
223
+ shopName,
224
+ lotProduct,
225
+ refusal: barMessage,
226
+ onBid: bid,
227
+ onAcceptTerms: gate.acceptTerms,
228
+ onChooseVariant: gate.chooseVariant,
229
+ onCloseStep: dismiss,
230
+ onSeeWins: seeWins,
231
+ },
232
+ finalCountdown: { visible: roundOpen, closesAt: auction.closesAt },
233
+ biddingWar: {
234
+ active: roundOpen && auction.extended && !warAnnounced,
235
+ onDone: () => setWarAnnounced(true),
236
+ },
237
+ win: { winner, onDone: dismissAuctionWin },
238
+ /** The auction part of the featured card; `useLiveShop` gives the rest. */
239
+ productCard: { auctionRound },
240
+ /** The auction part of the Shop button: its sheet lists the lots. */
241
+ shopButton: { lots },
242
+ };
243
+ }
244
+ //# sourceMappingURL=useLiveAuction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveAuction.js","sourceRoot":"","sources":["../../src/react/useLiveAuction.ts"],"names":[],"mappings":";;AA0FA,wCA8LC;AAxRD;;;;GAIG;AACH,sDAAyF;AACzF,iCAA0E;AAE1E,kDAA8C;AAG9C,+DAA2D;AAC3D,uDAAmF;AACnF,6CAQsB;AAetB;;;;;;GAMG;AACH,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;AAErF,sEAAsE;AACtE,MAAM,OAAO,GAAG,CAAC,YAAoB,EAAE,EAAE,CAAC,CAAC,MAAc,EAAE,EAAE,CAAC,IAAA,yBAAW,EAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;AAEp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AAE,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE;QAC1C,2EAA2E;QAC3E,WAAW,EAAE,EAAE,YAAY,EAAE;QAC7B,qEAAqE;QACrE,UAAU,EAAE,EAAE,IAAI,EAAE;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,75 @@
1
+ import type { LiveCommentMention } from '../pageTypes';
2
+ /** What the Live screen knows about the show, which decides what the chat shows. */
3
+ export interface LiveChatShow {
4
+ /** This show is playing or waiting for its host: not joining, ended or failed. */
5
+ onAir: boolean;
6
+ /** The show takes comments (`capabilitiesFor(show).canComment`). */
7
+ canComment: boolean;
8
+ /** The show takes reactions (`capabilitiesFor(show).canReact`). */
9
+ canReact: boolean;
10
+ }
11
+ /**
12
+ * The Live screen's chat and reactions. `useLivePage` calls it with what it knows about the show and
13
+ * hands the result to the screen (`page.chat`), one set of props per tile.
14
+ *
15
+ * - **Only while the show is on air** (playing, or waiting for its host): the chat, the comment box,
16
+ * the reaction button, the floating reactions and the pinned comment all go once it has ended, as
17
+ * Freckled Poppy's, and while it is still joining (nothing can be said into a room not yet joined).
18
+ * - **The session does the work:** the room's history in front of what arrives since
19
+ * (`session.comments`), the name a comment goes out under, holding a comment while the shopper's
20
+ * account loads, the pin (`session.pinnedComment`), the host's reaction setting
21
+ * (`session.reactionStyle`), and the shopper's own comment and reaction shown at once. Nothing here
22
+ * repeats it.
23
+ * - **Anyone can comment** (Freckled Poppy's rule, decided): a shopper the room has no name for is asked
24
+ * for one on their first comment, inside the comment box, and the session saves it on this phone
25
+ * (`chooseViewerName`) before the comment goes out. A signed-in shopper comments under their
26
+ * account's name (`ShopifyLiveSessionProvider`'s `viewerName`); while their account loads (on app
27
+ * open, or a moment after signing in), Send waits. An account with no name, or with a name the show's
28
+ * team goes by, gives the room none since 0.13.0, so that shopper is asked too, once it has loaded
29
+ * (`chatNameAsk`; amore-v2's chat waited for ever for them).
30
+ * - **Reactions** need no sign-in. Which ones is the button tile's; the Live screen hands the same list
31
+ * to the floating reactions.
32
+ * - **A tap on a name** in the chat puts "@name" in the comment box.
33
+ * - **Hide Comments** is the shopper's, for this visit to the screen.
34
+ * - **`keyboardUp`**: the comment box's keyboard is up, so the screen lets a tap on the video put it
35
+ * away (iOS has no key for that).
36
+ */
37
+ export declare function useLiveChat({ onAir, canComment, canReact }: LiveChatShow): {
38
+ keyboardUp: boolean;
39
+ /** The comment box has the keyboard: the screen lifts its bottom group for it, and for nothing else. */
40
+ typing: boolean;
41
+ comments: {
42
+ visible: boolean;
43
+ comments: import("..").LiveComment[];
44
+ hidden: boolean;
45
+ onToggleHidden: () => void;
46
+ onPressName: ((name: string) => void) | undefined;
47
+ };
48
+ commentBox: {
49
+ visible: boolean;
50
+ askForName: boolean;
51
+ waitingForName: boolean;
52
+ sending: boolean;
53
+ mention: LiveCommentMention | null;
54
+ nameMaxLength: number;
55
+ onSend: (text: string) => Promise<void>;
56
+ onSaveName: (name: string) => Promise<boolean>;
57
+ onTypingChange: import("react").Dispatch<import("react").SetStateAction<boolean>>;
58
+ };
59
+ reactionButton: {
60
+ visible: boolean;
61
+ onReact: (reactionUrl: string) => undefined;
62
+ };
63
+ reactions: {
64
+ visible: boolean;
65
+ reactions: import("..").FloatingReaction[];
66
+ reactionStyle: import("..").ReactionStyle;
67
+ };
68
+ pinnedComment: {
69
+ visible: boolean;
70
+ pinnedComment: import("..").LivePinnedComment | null;
71
+ };
72
+ };
73
+ /** What `useLiveChat` hands the Live screen: one set of props per tile. */
74
+ export type LiveChat = ReturnType<typeof useLiveChat>;
75
+ //# sourceMappingURL=useLiveChat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiveChat.d.ts","sourceRoot":"","sources":["../../src/react/useLiveChat.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIvD,oFAAoF;AACpF,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,KAAK,EAAE,OAAO,CAAC;IACf,oEAAoE;IACpE,UAAU,EAAE,OAAO,CAAC;IACpB,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE,YAAY;;IA+DrE,wGAAwG;;;;;;;6BA/BvE,MAAM;;;;;;;;;uBAf1B,MAAM;2BAWqB,MAAM;;;;;+BAaR,MAAM;;;;;;;;;;;EAyD/C;AAED,2EAA2E;AAC3E,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}