@lockerverse/react 0.2.99 → 0.2.101

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auction-description.js","names":[],"sources":["../src/auction-display.ts","../src/auction-icons.tsx","../src/auction-description-html.ts","../src/auction-description.tsx"],"sourcesContent":["import type {\n LockerverseAuction,\n LockerverseAuctionItem,\n LockerverseAuctionStatus,\n} from \"@lockerverse/sdk/auctions\";\n\n// Match the public web app. Keep display policy here for all SDK auction surfaces.\nexport function formatAuctionBoundary(\n auction: LockerverseAuction,\n status: LockerverseAuctionStatus = auction.status\n) {\n const starts = status === \"draft\";\n const value = starts ? auction.startAt : auction.endAt;\n const date = new Date(value);\n if (!Number.isFinite(date.getTime())) {\n return \"\";\n }\n const showTime =\n (starts\n ? auction.configuration.startTimeEnabled\n : auction.configuration.endTimeEnabled) ?? true;\n const dateLabel = new Intl.DateTimeFormat(\"en-US\", {\n day: \"numeric\",\n month: \"short\",\n timeZone: \"America/New_York\",\n year: \"numeric\",\n }).format(date);\n if (!showTime) {\n return dateLabel;\n }\n const timeLabel = new Intl.DateTimeFormat(\"en-US\", {\n hour: \"numeric\",\n minute: \"2-digit\",\n timeZone: \"America/New_York\",\n timeZoneName: \"short\",\n }).format(date);\n return `${dateLabel} at ${timeLabel}`;\n}\n\nexport function formatAuctionMoney(cents: number) {\n return new Intl.NumberFormat(\"en-US\", {\n currency: \"USD\",\n maximumFractionDigits: 2,\n minimumFractionDigits: 0,\n style: \"currency\",\n }).format(cents / 100);\n}\n\nexport function getAuctionDisplayStatus(\n auction: LockerverseAuction,\n item?: LockerverseAuctionItem\n): LockerverseAuctionStatus {\n if (\n auction.status === \"finished\" ||\n item?.status === \"finished\" ||\n Date.parse(auction.endAt) <= Date.now()\n ) {\n return \"finished\";\n }\n if (\n auction.status === \"draft\" ||\n item?.status === \"draft\" ||\n Date.parse(auction.startAt) > Date.now()\n ) {\n return \"draft\";\n }\n return \"active\";\n}\n","export function AuctionIcon({\n kind,\n}: {\n kind:\n | \"arrow\"\n | \"back\"\n | \"items\"\n | \"gavel\"\n | \"clock\"\n | \"bag\"\n | \"shield\"\n | \"timer\";\n}) {\n const paths = {\n arrow: \"M5 12h14m-6-6 6 6-6 6\",\n back: \"m15 6-6 6 6 6\",\n bag: \"M5 7h14l1 14H4L5 7Zm4 0V5a3 3 0 0 1 6 0v2\",\n clock: \"M12 8v4l3 2\",\n gavel: \"m14 3 7 7m-9-5 7 7M3 21l10-10M3 17l4 4M10 7l7 7\",\n items: \"M9 6h11M9 12h11M9 18h11M3 6h1M3 12h1M3 18h1\",\n shield: \"M12 22s8-4 8-11V5l-8-3-8 3v6c0 7 8 11 8 11Zm-4-11 3 3 5-5\",\n timer: \"M10 2h4M12 8v4l2 2M3 11a9 9 0 1 0 3-6M3 3v5h5\",\n };\n return (\n <svg\n aria-hidden=\"true\"\n fill=\"none\"\n height=\"16\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"1.6\"\n viewBox=\"0 0 24 24\"\n width=\"16\"\n >\n {kind === \"clock\" ? <circle cx=\"12\" cy=\"12\" r=\"9\" /> : null}\n <path d={paths[kind]} />\n </svg>\n );\n}\n","import sanitizeHtml from \"sanitize-html\";\n\nconst richDescriptionPattern =\n /<\\/?(?:p|br|strong|em|u|s|ul|ol|li|blockquote|pre|code|hr|h[1-6]|a)(?:\\s|\\/?>)/i;\n\nexport function auctionDescriptionHtml(\n description: string,\n links = true\n): string {\n if (!richDescriptionPattern.test(description)) {\n return description\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\\r\\n|\\r|\\n/g, \"<br>\");\n }\n\n return sanitizeHtml(description, {\n allowedAttributes: { a: links ? [\"href\"] : [], ol: [\"start\"] },\n allowedSchemes: [\"http\", \"https\", \"mailto\", \"tel\"],\n allowedTags: [\n \"p\",\n \"br\",\n \"strong\",\n \"em\",\n \"u\",\n \"s\",\n \"ul\",\n \"ol\",\n \"li\",\n \"blockquote\",\n \"pre\",\n \"code\",\n \"hr\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n ...(links ? [\"a\"] : []),\n ],\n allowProtocolRelative: false,\n });\n}\n\nexport function auctionDescriptionText(description: string): string {\n if (!richDescriptionPattern.test(description)) {\n return description.trim();\n }\n return sanitizeHtml(\n description.replace(\n /<\\/?(?:p|br|li|ul|ol|blockquote|pre|hr|h[1-6])(?:\\s[^>]*)?\\/?>/gi,\n \" \"\n ),\n {\n allowedAttributes: {},\n allowedTags: [],\n }\n )\n .replace(/&nbsp;/g, \" \")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#39;/g, \"'\")\n .replace(/&amp;/g, \"&\")\n .replace(/\\s+/g, \" \")\n .trim();\n}\n","import { auctionDescriptionHtml } from \"./auction-description-html.ts\";\n\nexport function AuctionDescription({\n description,\n links = true,\n className,\n id,\n}: {\n description: string;\n links?: boolean;\n className?: string | undefined;\n id?: string | undefined;\n}) {\n return (\n <div\n className={[\"lockerverse-auctions__description\", className]\n .filter(Boolean)\n .join(\" \")}\n // biome-ignore lint/security/noDangerouslySetInnerHtml: The shared allowlist strips scripts, event handlers, attributes, and unsafe link protocols before rendering.\n dangerouslySetInnerHTML={{\n __html: auctionDescriptionHtml(description, links),\n }}\n id={id}\n />\n );\n}\n"],"mappings":"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"}
@@ -0,0 +1,298 @@
1
+ .lockerverse-auction-gallery {
2
+ min-width: 0;
3
+ background: var(--lockerverse-control, #101114);
4
+ }
5
+ .lockerverse-auction-gallery button,
6
+ .lockerverse-auction-gallery__viewer button {
7
+ box-sizing: border-box;
8
+ padding: 0;
9
+ font: inherit;
10
+ cursor: pointer;
11
+ border: 0;
12
+ }
13
+ .lockerverse-auction-gallery button:focus-visible,
14
+ .lockerverse-auction-gallery__viewer button:focus-visible {
15
+ outline: 2px solid #fff;
16
+ outline-offset: 2px;
17
+ }
18
+ .lockerverse-auction-gallery__stage {
19
+ position: relative;
20
+ }
21
+ .lockerverse-auction-gallery__viewport {
22
+ aspect-ratio: 4 / 3;
23
+ overflow: hidden;
24
+ background: #000;
25
+ }
26
+ .lockerverse-auction-gallery__track {
27
+ display: flex;
28
+ height: 100%;
29
+ touch-action: pan-y pinch-zoom;
30
+ }
31
+ .lockerverse-auction-gallery__slide {
32
+ position: relative;
33
+ flex: 0 0 100%;
34
+ min-width: 0;
35
+ height: 100%;
36
+ }
37
+ .lockerverse-auction-gallery .lockerverse-auction-gallery__photo {
38
+ position: relative;
39
+ display: flex;
40
+ align-items: center;
41
+ justify-content: center;
42
+ width: 100%;
43
+ height: 100%;
44
+ overflow: hidden;
45
+ cursor: zoom-in;
46
+ background: transparent;
47
+ border-radius: 0;
48
+ }
49
+ .lockerverse-auction-gallery .lockerverse-auction-gallery__photo:focus-visible {
50
+ outline-offset: -2px;
51
+ }
52
+ .lockerverse-auction-gallery__image {
53
+ position: absolute;
54
+ inset: 0;
55
+ display: block;
56
+ width: 100%;
57
+ height: 100%;
58
+ object-fit: cover;
59
+ }
60
+ .lockerverse-auction-gallery__rotation {
61
+ position: absolute;
62
+ inset: auto 12px 8px;
63
+ display: flex;
64
+ gap: 8px;
65
+ align-items: center;
66
+ height: 32px;
67
+ pointer-events: none;
68
+ }
69
+ .lockerverse-auction-gallery__progress-track {
70
+ flex: 1;
71
+ height: 2px;
72
+ overflow: hidden;
73
+ background: #ffffff40;
74
+ border-radius: 999px;
75
+ }
76
+ .lockerverse-auction-gallery__progress {
77
+ width: 100%;
78
+ height: 100%;
79
+ background: #ffffffe6;
80
+ border-radius: 999px;
81
+ transform-origin: left;
82
+ }
83
+ .lockerverse-auction-gallery__control {
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ color: #ffffffd9;
88
+ pointer-events: none;
89
+ border-radius: 999px;
90
+ opacity: 0;
91
+ }
92
+ .lockerverse-auction-gallery__control.is-visible {
93
+ pointer-events: auto;
94
+ opacity: 0.7;
95
+ }
96
+ .lockerverse-auction-gallery__control:focus-visible,
97
+ .lockerverse-auction-gallery__control:hover {
98
+ color: #fff;
99
+ pointer-events: auto;
100
+ opacity: 1;
101
+ }
102
+ .lockerverse-auction-gallery__play {
103
+ position: relative;
104
+ flex-shrink: 0;
105
+ width: 28px;
106
+ height: 28px;
107
+ background: #0006;
108
+ }
109
+ .lockerverse-auction-gallery__play::before {
110
+ position: absolute;
111
+ inset: -8px;
112
+ content: "";
113
+ }
114
+ .lockerverse-auction-gallery__play:hover {
115
+ background: #0009;
116
+ }
117
+ .lockerverse-auction-gallery__previous,
118
+ .lockerverse-auction-gallery__next {
119
+ position: absolute;
120
+ top: 50%;
121
+ width: 44px;
122
+ height: 44px;
123
+ background: #0000004d;
124
+ transform: translateY(-50%);
125
+ }
126
+ .lockerverse-auction-gallery__previous {
127
+ left: 8px;
128
+ }
129
+ .lockerverse-auction-gallery__next {
130
+ right: 8px;
131
+ }
132
+ .lockerverse-auction-gallery__previous:hover,
133
+ .lockerverse-auction-gallery__next:hover {
134
+ background: #0000008c;
135
+ }
136
+ .lockerverse-auction-gallery__chevron {
137
+ width: 20px;
138
+ height: 20px;
139
+ }
140
+ .lockerverse-auction-gallery__empty {
141
+ display: flex;
142
+ align-items: center;
143
+ justify-content: center;
144
+ min-height: 224px;
145
+ font-size: 14px;
146
+ color: var(--lockerverse-muted, #ffffff80);
147
+ }
148
+ .lockerverse-auction-gallery__strip {
149
+ padding: 12px;
150
+ overflow-x: auto;
151
+ scrollbar-width: none;
152
+ }
153
+ .lockerverse-auction-gallery__strip::-webkit-scrollbar {
154
+ display: none;
155
+ }
156
+ .lockerverse-auction-gallery__thumbnails {
157
+ display: flex;
158
+ gap: 10px;
159
+ width: max-content;
160
+ margin-inline: auto;
161
+ }
162
+ .lockerverse-auction-gallery .lockerverse-auction-gallery__thumbnail {
163
+ display: flex;
164
+ flex-shrink: 0;
165
+ align-items: center;
166
+ justify-content: center;
167
+ width: 80px;
168
+ height: 60px;
169
+ padding: 2px;
170
+ background: transparent;
171
+ border: 1px solid transparent;
172
+ border-radius: 8px;
173
+ opacity: 0.55;
174
+ }
175
+ .lockerverse-auction-gallery
176
+ .lockerverse-auction-gallery__thumbnail.is-selected {
177
+ border-color: var(--lockerverse-text, #ffffffe6);
178
+ opacity: 1;
179
+ }
180
+ .lockerverse-auction-gallery__thumbnail:hover,
181
+ .lockerverse-auction-gallery__thumbnail:focus-visible {
182
+ opacity: 1;
183
+ }
184
+ .lockerverse-auction-gallery__thumbnail-image {
185
+ display: block;
186
+ width: 100%;
187
+ height: 100%;
188
+ object-fit: cover;
189
+ border-radius: 5px;
190
+ }
191
+ .lockerverse-auction-gallery__backdrop {
192
+ position: fixed;
193
+ inset: 0;
194
+ z-index: 2147483645;
195
+ background: #000;
196
+ }
197
+ .lockerverse-auction-gallery__viewer {
198
+ position: fixed;
199
+ inset: 0;
200
+ z-index: 2147483646;
201
+ display: block;
202
+ width: 100vw;
203
+ max-width: none;
204
+ height: 100dvh;
205
+ padding: 0;
206
+ margin: 0;
207
+ overflow: hidden;
208
+ color: #fff;
209
+ outline: none;
210
+ background: #000;
211
+ border: 0;
212
+ border-radius: 0;
213
+ }
214
+ .lockerverse-auction-gallery__full-image {
215
+ position: relative;
216
+ width: 100%;
217
+ height: 100%;
218
+ touch-action: pan-y pinch-zoom;
219
+ }
220
+ .lockerverse-auction-gallery__full-image img {
221
+ position: absolute;
222
+ inset: 0;
223
+ width: 100%;
224
+ height: 100%;
225
+ object-fit: contain;
226
+ }
227
+ .lockerverse-auction-gallery__preload {
228
+ visibility: hidden;
229
+ pointer-events: none;
230
+ }
231
+ .lockerverse-auction-gallery__viewer-close,
232
+ .lockerverse-auction-gallery__viewer-previous,
233
+ .lockerverse-auction-gallery__viewer-next {
234
+ position: absolute;
235
+ z-index: 1;
236
+ display: flex;
237
+ align-items: center;
238
+ justify-content: center;
239
+ width: 44px;
240
+ height: 44px;
241
+ color: #fffc;
242
+ background: #0000008c;
243
+ border-radius: 999px;
244
+ }
245
+ .lockerverse-auction-gallery__viewer-close {
246
+ top: 16px;
247
+ right: 16px;
248
+ }
249
+ .lockerverse-auction-gallery__viewer-previous,
250
+ .lockerverse-auction-gallery__viewer-next {
251
+ top: 50%;
252
+ transform: translateY(-50%);
253
+ }
254
+ .lockerverse-auction-gallery__viewer-previous {
255
+ left: 12px;
256
+ }
257
+ .lockerverse-auction-gallery__viewer-next {
258
+ right: 12px;
259
+ }
260
+ .lockerverse-auction-gallery__viewer-close:hover,
261
+ .lockerverse-auction-gallery__viewer-previous:hover,
262
+ .lockerverse-auction-gallery__viewer-next:hover {
263
+ color: #fff;
264
+ background: #000c;
265
+ }
266
+ .lockerverse-auction-gallery__sr-only {
267
+ position: absolute;
268
+ width: 1px;
269
+ height: 1px;
270
+ padding: 0;
271
+ margin: -1px;
272
+ overflow: hidden;
273
+ white-space: nowrap;
274
+ border: 0;
275
+ clip: rect(0, 0, 0, 0);
276
+ }
277
+ @media (min-width: 640px) {
278
+ .lockerverse-auction-gallery .lockerverse-auction-gallery__thumbnail {
279
+ width: 88px;
280
+ height: 66px;
281
+ }
282
+ .lockerverse-auction-gallery__viewer-previous {
283
+ left: 24px;
284
+ }
285
+ .lockerverse-auction-gallery__viewer-next {
286
+ right: 24px;
287
+ }
288
+ }
289
+ @media (prefers-reduced-motion: no-preference) {
290
+ .lockerverse-auction-gallery__control {
291
+ transition: opacity 200ms;
292
+ }
293
+ .lockerverse-auction-gallery .lockerverse-auction-gallery__thumbnail {
294
+ transition:
295
+ opacity 150ms,
296
+ border-color 150ms;
297
+ }
298
+ }
@@ -0,0 +1,39 @@
1
+ import { n as LockerverseTheme, t as LockerverseStyle } from "./theme.js";
2
+ import { u as LockerverseStripeLoader } from "./types.js";
3
+ import { LockerverseAuction, LockerverseAuctionBidResult, LockerverseAuctionClient, LockerverseAuctionItem as LockerverseAuctionItem$1, LockerverseAuctionPricing, LockerverseAuctionPurchaseResult, LockerverseAuctionPurchaseSubmission } from "@lockerverse/sdk/auctions";
4
+ //#region src/auction-item-types.d.ts
5
+ /** Keep this record private. It includes buyer contact data and a Stripe token. */
6
+ type LockerverseAuctionPurchaseRecovery = {
7
+ auctionId: string;
8
+ itemId: string;
9
+ item: LockerverseAuctionItem$1;
10
+ payment: NonNullable<LockerverseAuction["payment"]>;
11
+ pricing: LockerverseAuctionPricing;
12
+ submission: LockerverseAuctionPurchaseSubmission;
13
+ };
14
+ type LockerverseAuctionItemProps = {
15
+ auction: LockerverseAuction;
16
+ client: LockerverseAuctionClient;
17
+ itemId: string;
18
+ /** Host navigation; the SDK does not depend on a router. */
19
+ onBack?: (() => void) | undefined;
20
+ communityName?: string | undefined;
21
+ className?: string;
22
+ theme?: LockerverseTheme;
23
+ style?: LockerverseStyle;
24
+ stripeLoader?: LockerverseStripeLoader;
25
+ /** A submitted bid is not a winning bid or a payment receipt. */
26
+ onBidSubmitted?: (result: LockerverseAuctionBidResult) => void;
27
+ /** Called only after Lockerverse reports a paid purchase. */
28
+ onPurchaseComplete?: (result: LockerverseAuctionPurchaseResult) => void;
29
+ onPurchaseRecoveryChange?: (recovery: LockerverseAuctionPurchaseRecovery | null) => void;
30
+ onUncertain?: (kind: "bid" | "purchase") => void;
31
+ /** Resume with the same auction, item, client, and payment environment. */
32
+ resumePurchase?: LockerverseAuctionPurchaseRecovery;
33
+ };
34
+ //#endregion
35
+ //#region src/lockerverse-auction-item.d.ts
36
+ declare function LockerverseAuctionItem(props: LockerverseAuctionItemProps): import("react").JSX.Element;
37
+ //#endregion
38
+ export { LockerverseAuctionItem, type LockerverseAuctionItemProps, type LockerverseAuctionPurchaseRecovery, type LockerverseStyle, type LockerverseTheme };
39
+ //# sourceMappingURL=auction-item.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auction-item.d.ts","names":[],"sources":["../src/auction-item-types.ts","../src/lockerverse-auction-item.tsx"],"mappings":";;;;;KAaY;EACV;EACA;EACA,MAAM;EACN,SAAS,YAAY;EACrB,SAAS;EACT,YAAY;;KAGF;EACV,SAAS;EACT,QAAQ;EACR;;EAEA;EACA;EACA;EACA,QAAQ;EACR,QAAQ;EACR,eAAe;;EAEf,kBAAkB,QAAQ;;EAE1B,sBAAsB,QAAQ;EAC9B,4BACE,UAAU;EAEZ,eAAe;;EAEf,iBAAiB;;;;iBCgRH,uBAAuB,OAAO,8CAA2B,IAAA"}
@@ -0,0 +1,2 @@
1
+ import{a as e,i as t,n,o as r,r as i,t as a}from"./auction-description.js";import{c as o,s,t as c}from"./host-callback.js";import{AddressElement as l,Elements as u,PaymentElement as d,useElements as f,useStripe as p}from"@stripe/react-stripe-js";import{loadStripe as m}from"@stripe/stripe-js/pure/index.js";import{useCallback as h,useEffect as g,useId as _,useMemo as v,useRef as y,useState as b}from"react";import{LockerverseSdkError as x,calculateLockerverseAuctionPricing as S,getLockerverseAuctionMinimumBid as C}from"@lockerverse/sdk/auctions";import{safeParse as w}from"valibot";import{AsYouType as T,getCountries as E,getCountryCallingCode as D,parsePhoneNumberFromString as O}from"libphonenumber-js/max";import{Fragment as k,jsx as A,jsxs as j}from"react/jsx-runtime";import{Dialog as M}from"@base-ui/react/dialog";import N from"embla-carousel-autoplay";import P from"embla-carousel-react";const F=/^00/,I=new Intl.DisplayNames([`en`],{type:`region`}),L=E().map(e=>({country:e,label:I.of(e)??e})).sort((e,t)=>e.label.localeCompare(t.label,`en`));function R(e,t){let n=e.normalize(`NFKC`).trim().replace(F,`+`),r=n.startsWith(`+`)?void 0:O(n,{defaultCountry:t,extract:!1});if(r?.isValid()&&!r.ext)return r;let i=O(n,{extract:!1})??O(`+${n}`,{extract:!1});return i?.isValid()&&!i.ext?i:null}function z(e){return String.fromCodePoint(...Array.from(e,e=>127397+e.charCodeAt(0)))}function B({id:e,value:t,onChange:n}){let r=O(t),[i,a]=b(r?.country??`US`),[o,s]=b(r?.formatNational()??t),c=y(null),l=y(t);g(()=>{if(t===l.current)return;let e=O(t);l.current=t,a(e?.country??`US`),s((e?e.formatNational():null)??t)},[t]),g(()=>{c.current?.setCustomValidity(o&&!R(o,i)?`Enter a valid phone number.`:``)},[i,o]);function u(e,t,r=!1){let i=e.normalize(`NFKC`).trim().replace(F,`+`),o=R(e,t),c=i.startsWith(`+`)?o?.country??t:t,u=(o?o.formatNational():null)??new T(c).input(i);a(c),s(r?e:u),l.current=o?o.number:``,n(l.current)}return j(`div`,{className:`lockerverse-auctions__phone`,dir:`ltr`,children:[j(`div`,{className:`lockerverse-auctions__phone-country`,children:[j(`span`,{"aria-hidden":`true`,children:[A(`span`,{className:`lockerverse-auctions__phone-flag`,children:z(i)}),` `,`+`,D(i),` `,A(`span`,{children:`⌄`})]}),A(`select`,{"aria-label":`Phone number country`,onChange:e=>{let t=L.find(t=>t.country===e.target.value);t&&u(o,t.country)},value:i,children:L.map(e=>j(`option`,{value:e.country,children:[e.label,` +`,D(e.country)]},e.country))})]}),A(`input`,{autoComplete:`tel-national`,id:e,onChange:e=>u(e.target.value,i,e.target.value.length<o.length),onPaste:e=>{let t=R(e.clipboardData.getData(`text`),i);t&&(e.preventDefault(),u(t.number,t.country??i))},placeholder:`(201) 555-0123`,ref:c,required:!0,type:`tel`,value:o})]})}function V(e){return{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},terms:{applePay:e?`auto`:`never`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:e?`auto`:`never`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:e?`auto`:`never`,googlePay:`never`}}}function ee(t){let{isPurchase:n,item:r,pricing:i,id:a}=t;return j(`form`,{className:`lockerverse-auctions__checkout`,onSubmit:t.onSubmit,children:[j(`div`,{className:`lockerverse-auctions__checkout-header`,children:[j(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[A(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!t.onBack,onClick:t.onBack,type:`button`,children:`‹`}),j(`div`,{children:[A(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),A(`p`,{children:n?`Secure checkout`:`Secure payment method`})]})]}),A(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:t.communityName}),A(`h2`,{children:n?`Finalize your purchase.`:`Finalize your bid authorization.`}),A(`p`,{className:`lockerverse-auctions__checkout-summary`,children:n?j(k,{children:[`Pay `,A(`strong`,{children:e(i.totalCents)}),` for`,` `,t.quantity,` `,t.quantity===1?`item`:`items`,` of`,` `,A(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):j(k,{children:[`Authorize a payment method for your bid of`,` `,A(`strong`,{children:e(i.subtotalCents)}),` on`,` `,A(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),r.collectShippingAddress&&j(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[A(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),A(`p`,{children:`This item requires a delivery address. Billing details are used by default, and you can switch to a separate delivery address below if needed.`})]})]}),j(`div`,{className:`lockerverse-auctions__checkout-body`,children:[t.showFields&&j(`fieldset`,{disabled:t.locked,children:[j(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[j(`label`,{className:`lockerverse-auctions__field`,htmlFor:`${a}-email`,children:[`Email`,A(`input`,{autoComplete:`email`,id:`${a}-email`,onChange:e=>t.onEmailChange(e.target.value),placeholder:`example@domain.com`,required:!0,type:`email`,value:t.email})]}),j(`label`,{className:`lockerverse-auctions__field`,htmlFor:`${a}-phone`,children:[`Phone Number`,A(B,{id:`${a}-phone`,onChange:t.onPhoneChange,value:t.phone})]})]}),j(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[j(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[A(`h3`,{children:`Payment Information`}),A(`p`,{children:n?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),A(d,{onLoadError:t.onPaymentLoadError,options:V(n)})]}),j(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[A(`h3`,{children:`Billing Details`}),A(l,{onChange:t.onBillingChange,options:{mode:`billing`}}),A(`p`,{children:n?`Use your full name here. We use the email and phone above for purchase confirmation and fulfillment updates.`:`Use the bidder's full name here. We use the email and phone above to contact you if this bid is outbid or wins.`})]}),r.collectShippingAddress&&j(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[j(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,children:[A(`input`,{checked:t.sameAsBilling,onChange:e=>t.onSameAsBillingChange(e.target.checked),type:`checkbox`}),j(`span`,{children:[A(`strong`,{children:`Delivery address is the same as billing`}),A(`span`,{children:`Leave this on for the fastest flow. Turn it off only if the delivery address should differ from the billing details above.`})]})]}),!t.sameAsBilling&&j(k,{children:[A(`h3`,{children:`Delivery Address`}),A(l,{onChange:t.onShippingChange,options:{mode:`shipping`}})]})]}),t.serviceFeeEnabled&&A(H,{...t})]}),t.message&&A(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:t.message}),!t.isTerminal&&j(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[j(`p`,{children:[n?`By continuing, you agree to be charged for this purchase.`:`By continuing, you agree to have this payment method stored for item settlement if your bid is the winning offer.`,r.collectShippingAddress?` Your delivery details are stored with the ${n?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),j(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:t.submitDisabled,type:`submit`,children:[t.buttonText,A(`span`,{"aria-hidden":`true`,children:` →`})]})]})]})]})}function H(t){let{isPurchase:n,pricing:r}=t;return A(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:t.onIncludeServiceFeeChange?j(`label`,{className:`lockerverse-auctions__checkout-checkbox`,children:[A(`input`,{checked:t.includeServiceFee,onChange:e=>t.onIncludeServiceFeeChange?.(e.target.checked),type:`checkbox`}),j(`span`,{children:[j(`strong`,{children:[n?`Add`:`If I win, add`,` `,e(t.serviceFeeCents),` to help cover processing fees`]}),j(`span`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})]})]}):j(`p`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})})}function U(e,t,n){return S(e,t.saleMode===`buy_now`?(t.buyNowPriceAmount??0)*n.quantity:n.amount,n.includeServiceFee)}function W(e,t,n){if(e.status!==`active`||t.status!==`active`||Date.parse(e.endAt)<=Date.now())return`This item is not accepting bids or purchases.`;if(t.saleMode===`hybrid`)return`This item type is not supported for checkout.`;if(t.saleMode===`buy_now`){if(t.isSoldOut||t.availableQuantity===0)return`This item is sold out.`;if(!(t.buyNowPriceAmount&&Number.isSafeInteger(n.quantity))||n.quantity<1||t.availableQuantity!==null&&n.quantity>t.availableQuantity)return`Select an available quantity.`}else if(!Number.isSafeInteger(n.amount)||n.amount%100!=0||n.amount<C(t))return`Enter a whole-dollar bid at or above the minimum bid.`;return null}function te(e,t,n,r,i){return e.payment?.publishableKey!==t.payment?.publishableKey||e.payment?.connectedAccountId!==t.payment?.connectedAccountId||e.serviceFeeEnabled!==t.serviceFeeEnabled||n.saleMode!==r.saleMode||n.collectShippingAddress!==r.collectShippingAddress||JSON.stringify(U(e,n,i))!==JSON.stringify(U(t,r,i))}function ne(e){return{expectedServiceFeeCents:e.serviceFeeCents,expectedSubtotalCents:e.subtotalCents,expectedTotalCents:e.totalCents}}async function re({stripe:e,elements:t,email:n,phone:r,billing:i,shipping:a,collectShippingAddress:o}){if(!(i?.complete&&i.value.name.trim()))throw Error(`Complete your billing name and address.`);if(o&&!(a?.complete&&a.value.name.trim()))throw Error(`Complete your shipping name and address.`);let s=await t.submit();if(s.error)throw Error(s.error.message??`Check your payment details.`);let c=await e.createConfirmationToken({elements:t,params:{payment_method_data:{allow_redisplay:`always`,billing_details:{address:i.value.address,email:n,name:i.value.name,phone:r}},return_url:window.location.href,...o&&a?{shipping:{address:a.value.address,name:a.value.name,phone:r}}:void 0}});if(c.error||!c.confirmationToken)throw Error(c.error?.message??`Unable to prepare payment details.`);return c.confirmationToken.id}async function ie(e,t){if(!t.requiresAction)return;if(!t.clientSecret)throw Error(`Payment confirmation is incomplete. Check its status before trying again.`);let n=await e.handleNextAction({clientSecret:t.clientSecret});if(n.error)throw Error(n.error.message??`Payment confirmation is incomplete.`)}function ae(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function G(e){let{auction:t,item:n,selection:r,client:i,onReview:a,onBack:l}=e,u=p(),d=f(),m=_(),[h,v]=b(e.contact?.email??``),[S,C]=b(e.contact?.phone??``),[T,E]=b(!0),[D,O]=b(null),[k,j]=b(null),[M,N]=b(e.resumePurchase??null),[P,F]=b(e.resumePurchase?`pending`:`ready`),[I,L]=b(null),R=y(e.resumePurchase?.submission.clientRequestId??null),z=P===`complete`||P===`uncertain`,B=P!==`ready`&&P!==`complete`,{onInteractionLockChange:V}=e;g(()=>{V?.(B)},[B,V]);let H=y(!1),G=y(!0),K=y(e);K.current=e,g(()=>(G.current=!0,()=>{G.current=!1}),[]);let q=!!(M??e.resumePurchase)||n.saleMode===`buy_now`,J=M?.pricing??e.resumePurchase?.pricing??U(t,n,r),oe=M?.payment??e.resumePurchase?.payment??t.payment;function Y(e){G.current&&N(e),c(K.current.onPurchaseRecoveryChange,e)}function X(e){G.current&&(e.status===`paid`?(R.current=null,Y(null),F(`complete`),L(`Purchase complete. Receipt: ${e.purchaseId}`),c(K.current.onPurchaseComplete,e)):e.status===`pending_payment`?(F(`pending`),L(`Your purchase is pending. Check its status before making another payment.`)):(R.current=null,Y(null),F(`ready`),L(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`)))}async function Z(){if(!(u&&d&&t.payment))throw Error(`Payment details are still loading.`);let e=w(s,h),c=w(o,S);if(!(e.success&&c.success))throw Error(`Enter a valid email and phone number with its country code.`);let l=await i.load(t.slug);if(!G.current)return null;let f=l.items.find(e=>e.id===n.id);if(!f)return a(l,`This item is no longer available.`),null;let p=W(l,f,r);if(p||te(t,l,n,f,r))return a(l,p??`The checkout details changed. Review them before continuing.`),null;let m=await re({billing:D,collectShippingAddress:n.collectShippingAddress,elements:d,email:e.output,phone:c.output,shipping:T?D:k,stripe:u});return G.current?{confirmationToken:m,email:e.output,includeServiceFee:r.includeServiceFee,phone:c.output,...ne(J)}:null}async function se(e){let a=await i.createBid(t.slug,n.id,{...e,amount:r.amount});G.current&&u&&(await ie(u,a),G.current&&(F(`complete`),L(`Bid submitted. Watch your email for bid and auction updates.`),c(K.current.onBidSubmitted,a)))}async function Q(e,r){if(G.current&&u){if(e.requiresAction){if(await ie(u,e),!G.current)return;let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);a?X(a):(F(`pending`),L(`Payment status is not available yet. Check again shortly.`));return}X(e)}}async function ce(e){let r=await i.getPurchaseStatus(t.slug,n.id,e.submission.clientRequestId);G.current&&(r?await Q(r,e):(F(`retry`),L(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)))}async function le(e,r){let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);if(G.current){if(a){await Q(a,r);return}Y(null),F(`ready`),L(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}}async function ue(e,t,n,r){if(!G.current)return;let i=t&&(!(e instanceof x)||e.recoveryRecommended);if(L(e instanceof Error?e.message:`Unable to complete this request.`),q&&n){if(!r&&e instanceof x&&!e.recoveryRecommended)try{await le(e,n);return}catch{}F(`pending`),L(`We could not confirm the purchase result. Check its status using the same purchase request.`),c(K.current.onUncertain,`purchase`)}else i?(F(`uncertain`),L(`We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.`),c(K.current.onUncertain,`bid`)):F(`ready`)}function de(){return R.current??=globalThis.crypto.randomUUID(),R.current}let $=u&&d&&oe;async function fe(e){if(e.preventDefault(),H.current||z)return;if(!$){L(`Payment details are still loading.`);return}let a=P===`retry`;H.current=!0,F(`busy`),L(null);let o=!1,s=M;try{if(!s){let e=await Z();if(!e)return;if(!q){o=!0,await se(e);return}s=Object.freeze({auctionId:t.id,item:n,itemId:n.id,payment:Object.freeze({...$}),pricing:J,submission:Object.freeze({...e,clientRequestId:de(),paymentMethodTypes:Object.freeze([`card`]),quantity:r.quantity})}),Y(s)}if(M&&!a){await ce(s);return}o=!0,await Q(await i.createPurchase(t.slug,n.id,s.submission),s)}catch(e){await ue(e,o,s,M!==null&&!a)}finally{H.current=!1}}let pe=ae(P,M!==null,q),me=P!==`ready`;return A(ee,{buttonText:pe,communityName:e.communityName??t.name,email:h,id:m,includeServiceFee:r.includeServiceFee,isPurchase:q,isTerminal:z,item:n,locked:me,message:I,onBack:P===`ready`?l:void 0,onBillingChange:O,onEmailChange:t=>{v(t),e.onContactChange?.({email:t,phone:S})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>L(`Unable to load payment form.`),onPhoneChange:t=>{C(t),e.onContactChange?.({email:h,phone:t})},onSameAsBillingChange:E,onShippingChange:j,onSubmit:fe,phone:S,pricing:J,quantity:r.quantity,sameAsBilling:T,serviceFeeCents:M?J.serviceFeeCents:U(t,n,{...r,includeServiceFee:t.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:t.serviceFeeEnabled,showFields:!(M||z),submitDisabled:P===`busy`||!u||!d})}function K({size:e=24,children:t,...n}){return A(`svg`,{"aria-hidden":`true`,fill:`none`,height:e,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:e,...n,children:t})}function q(e){return A(K,{...e,children:A(`path`,{d:`m15 18-6-6 6-6`})})}function J(e){return A(K,{...e,children:A(`path`,{d:`m9 18 6-6-6-6`})})}function oe(e){return j(K,{...e,children:[A(`rect`,{height:`16`,rx:`1`,width:`4`,x:`6`,y:`4`}),A(`rect`,{height:`16`,rx:`1`,width:`4`,x:`14`,y:`4`})]})}function Y(e){return A(K,{...e,children:A(`path`,{d:`m6 3 14 9-14 9V3Z`})})}function X(e){return A(K,{...e,children:A(`path`,{d:`m18 6-12 12M6 6l12 12`})})}const Z=6e3;function se(e,t){let n=y(Z),r=y(null),[i,a]=b(Z),o=v(()=>N({delay:i,playOnInit:!1,stopOnFocusIn:!1,stopOnInteraction:!0,stopOnMouseEnter:!1}),[i]),[s,c]=P({duration:t?0:25,loop:!0},[o]),l=h(()=>{r.current&&(r.current.style.transform=`scaleX(${1-n.current/Z})`)},[]),u=h(()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(1,Math.min(Z,e))),o.stop(),l()},[o,l]),d=h(()=>{n.current=Z,a(Z),o.reset(),l()},[o,l]);return g(()=>{c&&(e?i===n.current?o.play():a(n.current):u())},[c,e,o,i,a,n,u]),g(()=>{if(!c)return;let t=0,r=()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(0,Math.min(Z,e)),l(),t=requestAnimationFrame(r))},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)},a=()=>cancelAnimationFrame(t),s=()=>{e&&o.play()};return c.on(`select`,d).on(`reInit`,s).on(`autoplay:timerset`,i).on(`autoplay:timerstopped`,a),l(),i(),()=>{a(),c.off(`select`,d).off(`reInit`,s).off(`autoplay:timerset`,i).off(`autoplay:timerstopped`,a)}},[c,o,e,n,d,l]),{embla:c,freeze:u,progressRef:r,reset:d,viewportRef:s}}function Q({photos:e,name:t,selected:n,paused:r=!1,photoButtonRef:i,onSelect:a,onExpand:o}){let s=y(null),c=y([]),[l,u]=b(!0),[d,f]=b(!1),[p,m]=b(!1),[h,_]=b(!1),[v,x]=b(!1),[S,C]=b(!1),[w,T]=b(!1),[E,D]=b(!0),O=y(null),M=`lockerverse-auction-gallery__control ${E||w||p?`is-visible`:``}`,N=()=>{O.current&&clearTimeout(O.current),O.current=setTimeout(()=>T(!1),2e3)},P=e=>{if(e.pointerType!==`mouse`){D(!0);return}T(!0),O.current&&clearTimeout(O.current),e.target instanceof Element&&e.target.closest(`[data-gallery-control]`)||N()};g(()=>{let e=window.matchMedia(`(hover: none), (pointer: coarse)`),t=()=>D(e.matches);return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),clearTimeout(O.current??void 0)}},[]);let F=!(r||l||d||p||h||v)&&S,I=e.length,L=I?(n%I+I)%I:0,{viewportRef:R,embla:z,progressRef:B,freeze:V,reset:ee}=se(F&&I>1,l);g(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>u(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),g(()=>{if(!z)return;let e=()=>a(z.selectedScrollSnap());return z.on(`select`,e).on(`reInit`,e),()=>{z.off(`select`,e).off(`reInit`,e)}},[z,a]),g(()=>{z&&z.selectedScrollSnap()!==L&&z.scrollTo(L,!0)},[z,L]),g(()=>{let e=()=>{document.hidden&&V(),C(!document.hidden)},t=()=>x(!1);return e(),document.addEventListener(`visibilitychange`,e,!0),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{document.removeEventListener(`visibilitychange`,e,!0),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[V]);let H=e=>{z?.scrollTo((e+I)%I,l),ee()};return g(()=>{let e=s.current,t=c.current[L];if(!(e&&t))return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.left<n.left?e.scrollLeft-=n.left-r.left:r.right>n.right&&(e.scrollLeft+=r.right-n.right)},[L,I]),j(`section`,{"aria-label":`${t} photos`,className:`lockerverse-auction-gallery`,onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||m(!1)},onFocusCapture:e=>m(e.target.matches(`:focus-visible`)),onKeyDown:e=>{I<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),H(L+(e.key===`ArrowRight`?1:-1)))},onPointerEnter:e=>{e.pointerType===`mouse`&&f(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&f(!1)},children:[I?j(`div`,{className:`lockerverse-auction-gallery__stage`,onPointerEnter:P,onPointerLeave:N,onPointerMove:P,children:[A(`div`,{className:`lockerverse-auction-gallery__viewport`,onPointerDownCapture:()=>{V(),x(!0)},ref:R,children:A(`div`,{className:`lockerverse-auction-gallery__track`,children:e.map((e,n)=>A(`div`,{"aria-hidden":n!==L,className:`lockerverse-auction-gallery__slide`,children:A(`button`,{"aria-label":`View photo ${n+1} of ${t} at full size`,className:`lockerverse-auction-gallery__photo`,onClick:()=>{o(n)},ref:n===L?i:void 0,tabIndex:n===L?0:-1,type:`button`,children:A(`img`,{alt:`${t}, ${n+1} of ${I}`,className:`lockerverse-auction-gallery__image`,draggable:!1,height:900,loading:n===0||n===L||n===(L+1)%I?`eager`:`lazy`,sizes:`(max-width: 1280px) 100vw, 45vw`,src:e,width:1200})})},`${e}-${n}`))})}),I>1&&!l&&j(`div`,{className:`lockerverse-auction-gallery__rotation`,children:[A(`div`,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__progress-track`,children:A(`div`,{className:`lockerverse-auction-gallery__progress`,ref:B,style:{transform:`scaleX(0)`}})}),A(`button`,{"aria-label":h?`Play photo rotation`:`Pause photo rotation`,className:`lockerverse-auction-gallery__play ${M}`,"data-gallery-control":!0,onClick:()=>_(e=>!e),title:h?`Play photo rotation`:`Pause photo rotation`,type:`button`,children:A(h?Y:oe,{"aria-hidden":`true`,size:13})})]}),I>1&&j(k,{children:[A(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__previous ${M}`,"data-gallery-control":!0,onClick:()=>H(L-1),type:`button`,children:A(q,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})}),A(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__next ${M}`,"data-gallery-control":!0,onClick:()=>H(L+1),type:`button`,children:A(J,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})})]})]}):A(`div`,{className:`lockerverse-auction-gallery__empty`,children:`No photo available`}),I>1&&A(`section`,{"aria-label":`Choose a photo`,className:`lockerverse-auction-gallery__strip`,ref:s,children:A(`div`,{className:`lockerverse-auction-gallery__thumbnails`,children:e.map((e,t)=>A(`button`,{"aria-label":`Show photo ${t+1} of ${I}`,"aria-pressed":L===t,className:`lockerverse-auction-gallery__thumbnail ${L===t?`is-selected`:``}`,onClick:()=>H(t),ref:e=>{c.current[t]=e},type:`button`,children:A(`img`,{alt:``,className:`lockerverse-auction-gallery__thumbnail-image`,height:66,sizes:`88px`,src:e,width:88})},`${e}-${t}`))})})]})}function ce({images:e,fallbackImage:t,name:n}){let r=[...new Set(e.filter(Boolean))];!r.length&&t&&r.push(t);let[i,a]=b(0),[o,s]=b(!1),c=y(null),l=y(null),u=r.length,d=u?(i%u+u)%u:0;return j(k,{children:[A(Q,{name:n,onExpand:e=>{a(e),s(!0)},onSelect:a,paused:o,photoButtonRef:c,photos:r,selected:d}),u>0&&A(M.Root,{onOpenChange:s,open:o,children:j(M.Portal,{children:[A(M.Backdrop,{className:`lockerverse-auction-gallery__backdrop`}),j(M.Popup,{"aria-describedby":void 0,className:`lockerverse-auction-gallery__viewer`,finalFocus:c,onKeyDown:e=>{u<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),a((d+(e.key===`ArrowRight`?1:-1)+u)%u))},children:[j(M.Title,{className:`lockerverse-auction-gallery__sr-only`,children:[n,` · Photo `,d+1,` of `,u]}),j(`div`,{className:`lockerverse-auction-gallery__full-image`,onTouchCancel:()=>{l.current=null},onTouchEnd:e=>{let t=l.current;l.current=null;let n=e.changedTouches.item(0);if(!(t&&n)||u<2)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>=45&&Math.abs(r)>Math.abs(i)*1.3&&a((d+(r<0?1:-1)+u)%u)},onTouchMove:e=>{e.touches.length!==1&&(l.current=null)},onTouchStart:e=>{let t=e.touches.item(0);l.current=e.touches.length===1&&t?{x:t.clientX,y:t.clientY}:null},children:[A(`img`,{alt:`${n}, ${d+1} of ${u}`,height:900,src:r[d],width:1200}),o&&u>1&&A(`img`,{alt:``,"aria-hidden":`true`,className:`lockerverse-auction-gallery__preload`,height:900,loading:`eager`,src:r[(d+1)%u],width:1200})]}),A(M.Close,{"aria-label":`Close photo viewer`,className:`lockerverse-auction-gallery__viewer-close`,children:A(X,{size:22})}),u>1&&j(k,{children:[A(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__viewer-previous`,onClick:()=>a((d-1+u)%u),type:`button`,children:A(q,{size:28})}),A(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__viewer-next`,onClick:()=>a((d+1)%u),type:`button`,children:A(J,{size:28})})]})]})]})})]})}function le(e){return e===`Buy Now`?`shield`:e===`Available`||e===`Increment`?`timer`:`gavel`}function ue(t,n){return t.saleMode===`buy_now`?[[`Buy Now`,e(t.buyNowPriceAmount??0)],[`Available`,t.availableQuantity===null?`Available`:String(t.availableQuantity)]]:n===`finished`?[[`Final bid`,t.maxBidAmount?e(t.maxBidAmount):`No bids`]]:[[`Current bid`,e(t.maxBidAmount??0)],[`Floor`,e(t.minBidAmount??0)],[`Increment`,e(t.bidIncrementAmount??0)]]}function de({auction:o,item:s}){let[c,l]=b(!1),u=_(),d=r(o,s),f={active:`Closes`,draft:`Opens`,finished:`Closed`}[d],p=t(o,d),m=s.saleMode===`buy_now`,h=n(s.description??``).length>240,g=ue(s,d);return j(`section`,{className:`lockerverse-auctions__item-summary`,children:[A(ce,{fallbackImage:s.image??o.configuration.image??o.community?.banner??o.community?.thumbnail??null,images:s.images,name:s.name}),j(`div`,{className:`lockerverse-auctions__item-copy`,children:[j(`p`,{className:`lockerverse-auctions__eyebrow`,children:[f,` `,p,` `,A(`span`,{"aria-hidden":`true`,children:` · `}),` Public item`]}),A(`h2`,{children:s.name}),s.description?j(`div`,{className:`lockerverse-auctions__item-description`,children:[A(a,{className:!c&&h?`lockerverse-auctions__description-clamped`:void 0,description:s.description,id:u}),h?j(`button`,{"aria-controls":u,"aria-expanded":c,className:`lockerverse-auctions__description-toggle`,onClick:()=>l(!c),type:`button`,children:[c?`Hide description`:`Read full description`,` `,A(`span`,{"aria-hidden":`true`,children:`⌄`})]}):null]}):null,j(`dl`,{className:`lockerverse-auctions__stat-panel`,children:[g.map(([e,t])=>j(`div`,{className:`lockerverse-auctions__stat-row`,children:[j(`dt`,{children:[A(i,{kind:le(e)}),e]}),A(`dd`,{children:t})]},e)),j(`div`,{className:`lockerverse-auctions__stat-row`,children:[j(`dt`,{children:[A(i,{kind:`clock`}),f]}),A(`dd`,{className:`lockerverse-auctions__stat-date`,children:p})]}),!m&&d===`finished`?j(`div`,{className:`lockerverse-auctions__stat-footer`,children:[j(`div`,{children:[A(`dt`,{children:`Floor`}),A(`dd`,{children:e(s.minBidAmount??0)})]}),j(`div`,{children:[A(`dt`,{children:`Bid increment`}),A(`dd`,{children:e(s.bidIncrementAmount??0)})]})]}):null]})]})]})}const $=/^\d+$/;function fe(t,n){return $.test(t)&&Number.isSafeInteger(Number(t)*n)?`Total: ${e(Number(t)*n)}`:`Enter a whole-number quantity.`}function pe(e,t,n){return String(e?t?t.quantity:1:t?t.amount/100:n)}function me(e,t){return e.isSoldOut?`This item is sold out.`:t===`draft`?`This item is not open yet.`:t===`finished`?e.saleMode===`buy_now`?`Purchases are closed for this item.`:`Bidding is closed for this item.`:`This item is not available.`}function he(e,n,r){return r===`draft`?`This item opens ${t(e,`draft`)}.`:n.isSoldOut?`All available quantities have been purchased.`:n.saleMode===`buy_now`?`This item is no longer available to purchase.`:`Bidding has closed for this item.`}function ge(e,t,n,r){return{amount:t?0:Number(r)*100,includeServiceFee:n?n.includeServiceFee:e.serviceFeeEnabled&&e.serviceFeeDefaultChecked,quantity:t?Number(r):1}}function _e({auction:t,item:n,initialSelection:i,onContinue:a,onError:o,onBack:s}){let c=n.saleMode===`buy_now`,l=Math.ceil(C(n)/100),[u,d]=b(pe(c,i,l)),[f,p]=b(null),m=_(),h=r(t,n),g=h===`active`&&!n.isSoldOut&&n.saleMode!==`hybrid`;function v(e){if(e.preventDefault(),!$.test(u)){p(c?`Enter a whole-number quantity.`:`Enter a whole-dollar bid amount.`);return}let r=ge(t,c,i,u),s=W(t,n,r);if(s){p(s),o(s);return}try{U(t,n,r)}catch{p(`Enter a valid amount or quantity.`);return}a(r)}return g?j(`form`,{className:`lockerverse-auctions__selection`,onSubmit:v,children:[A(ve,{buyNow:c,item:n,minimum:l}),j(`div`,{className:`lockerverse-auctions__selection-body`,children:[j(`label`,{className:`lockerverse-auctions__field`,htmlFor:m,children:[c?`Quantity`:`Your bid amount`,j(`span`,{className:`lockerverse-auctions__amount-control`,children:[c?null:A(`span`,{"aria-hidden":`true`,children:`$`}),A(`input`,{"aria-describedby":`${m}-help`,"aria-invalid":!!f,autoComplete:`off`,id:m,inputMode:`numeric`,onChange:e=>{d(e.target.value),p(null)},placeholder:c?`1`:String(l),required:!0,value:u})]})]}),f?A(`p`,{role:`alert`,children:f}):null,A(`p`,{id:`${m}-help`,children:c?fe(u,n.buyNowPriceAmount??0):`Enter a whole-dollar bid of at least ${e(l*100)}. Bid increment: ${e(n.bidIncrementAmount??0)}.`}),j(`div`,{className:`lockerverse-auctions__selection-footer`,children:[A(`p`,{children:c?`Continuing moves you into secure checkout where your payment is processed immediately.`:`Continuing moves you into the secure payment step where your card is stored for settlement only if your bid wins.`}),j(`button`,{className:`lockerverse-auctions__button`,disabled:!t.payment,type:`submit`,children:[c?`Continue to Checkout`:`Continue to Payment`,` `,A(`span`,{"aria-hidden":`true`,children:`→`})]})]}),t.payment?null:A(`p`,{role:`alert`,children:`Payments are not configured for this auction.`})]})]}):j(`div`,{className:`lockerverse-auctions__selection lockerverse-auctions__read-only`,children:[A(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Item status`}),A(`h3`,{children:me(n,h)}),A(`p`,{children:he(t,n,h)}),s?j(`button`,{className:`lockerverse-auctions__button`,onClick:s,type:`button`,children:[`Browse auction items `,A(`span`,{"aria-hidden":`true`,children:`→`})]}):null]})}function ve({item:t,buyNow:n,minimum:r}){return j(`div`,{className:`lockerverse-auctions__selection-header`,children:[A(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Step 1 of 2`}),A(`h3`,{children:n?`Buy this item now.`:`Place your bid.`}),A(`p`,{children:n?`Choose how many you want, then complete the secure checkout.`:`Enter the bid amount you want to place for this item. You are only charged if this bid wins after bidding closes.`}),j(`p`,{children:[n?`Price: `:`Minimum qualifying bid: `,A(`strong`,{children:e(n?t.buyNowPriceAmount??0:r*100)})]}),n&&t.availableQuantity!==null?j(`p`,{children:[t.availableQuantity,` available`]}):null,t.collectShippingAddress?A(`p`,{children:`The next step will also collect a delivery address for seller fulfillment.`}):null]})}function ye(e){let{auction:t,item:n,selection:r,theme:i=`dark`,stripeLoader:a=m,style:o,onBack:s,resumePurchase:c}=e,[l,d]=b(null),[f,p]=b(!1),[h,_]=b(0),v=c?.payment??t.payment;if(g(()=>{let e=!0;if(!v){p(!0);return}return Promise.resolve().then(()=>a(v.publishableKey,v.connectedAccountId?{stripeAccount:v.connectedAccountId}:void 0)).then(t=>{e&&(d(t),p(!t))},()=>{e&&p(!0)}),()=>{e=!1}},[v,a,h]),f)return j(`div`,{children:[A(`p`,{role:`alert`,children:`Payment details could not load.`}),c?null:A(`button`,{onClick:s,type:`button`,children:`Back to item`}),A(`button`,{onClick:()=>{p(!1),d(null),_(e=>e+1)},type:`button`,children:`Try again`})]});if(!l)return j(`div`,{children:[A(`p`,{role:`status`,children:`Loading secure payment details…`}),c?null:A(`button`,{onClick:s,type:`button`,children:`Back to item`})]});let y={mode:`setup`,setupFutureUsage:`off_session`};c?y={amount:c.pricing.totalCents,currency:`usd`,mode:`payment`}:n.saleMode===`buy_now`&&(y={amount:U(t,n,r).totalCents,currency:`usd`,mode:`payment`});let x={...y,appearance:{theme:i===`dark`?`night`:`stripe`,variables:{borderRadius:`18px`,colorBackground:i===`dark`?`#0F1014`:`#FFFFFF`,colorDanger:`#EF4444`,colorText:i===`dark`?`#FFFFFF`:`#121416`,colorTextSecondary:i===`dark`?`#C0BBC8`:`#55515E`,...o?.[`--lockerverse-accent`]?{colorPrimary:o[`--lockerverse-accent`]}:void 0,...o?.[`--lockerverse-font-family`]?{fontFamily:o[`--lockerverse-font-family`]}:void 0}},currency:`usd`,paymentMethodTypes:[`card`],syncAddressCheckbox:`none`};return A(u,{options:x,stripe:l,children:A(G,{...e})})}function be({buyNow:e}){return j(`div`,{className:`lockerverse-auctions__progress`,children:[j(`span`,{children:[A(i,{kind:e?`shield`:`gavel`}),e?`Choose quantity`:`Place bid`]}),j(`span`,{children:[A(i,{kind:`shield`}),e?`Pay securely`:`Secure card`]}),j(`span`,{children:[A(i,{kind:`timer`}),e?`Get confirmation`:`Wait for close`]})]})}function xe(e){let{auction:t,item:n,resumePurchase:i,className:a,theme:o=`dark`,style:s}=e,[c,l]=b(t),u=c.items.find(e=>e.id===n.id)??i?.item,[d,f]=b(()=>i?{amount:0,includeServiceFee:i.submission.includeServiceFee??!1,quantity:i.submission.quantity}:null),[p,m]=b(!!i),[h,g]=b({email:``,phone:``}),[_,v]=b(!!i),[y,x]=b(null);function S(e,t){m(!1),l(e),f(null),v(!1),x(t)}function C(e){x(null),f(e),v(!0)}return u?j(`section`,{className:[`lockerverse-auctions`,a].filter(Boolean).join(` `),"data-lockerverse-theme":o,style:{"--lockerverse-accent":c.community?.color??`#6f8f6d`,...s},children:[e.onBack&&!p?A(`button`,{className:`lockerverse-auctions__back`,onClick:e.onBack,type:`button`,children:`‹ All items`}):null,j(`div`,{className:`lockerverse-auctions__detail`,children:[A(de,{auction:c,item:u}),j(`div`,{className:`lockerverse-auctions__transaction`,children:[r(c,u)===`active`?A(be,{buyNow:u.saleMode===`buy_now`}):null,y?A(`p`,{className:`lockerverse-auctions__notice`,role:`alert`,children:y}):null,_&&d?A(ye,{...e,auction:c,communityName:e.communityName??c.community?.name,contact:h,item:u,onBack:()=>v(!1),onContactChange:g,onIncludeServiceFeeChange:e=>f(t=>t&&{...t,includeServiceFee:c.serviceFeeEnabled&&e}),onInteractionLockChange:m,onReview:S,selection:d}):A(_e,{auction:c,initialSelection:d,item:u,onBack:e.onBack,onContinue:C,onError:x}),e.onBack&&!p?A(`button`,{className:`lockerverse-auctions__footer-back`,onClick:e.onBack,type:`button`,children:`Back to auction items →`}):null]})]})]}):j(`div`,{children:[A(`p`,{role:`alert`,children:`This auction item is no longer available.`}),e.onBack?A(`button`,{onClick:e.onBack,type:`button`,children:`Back to auction items`}):null]})}function Se(e){let t=y({auctionId:e.auction.id,client:e.client,itemId:e.itemId});if(t.current.client!==e.client||t.current.auctionId!==e.auction.id||t.current.itemId!==e.itemId)throw TypeError(`Auction item identity cannot change. Remount with a new React key.`);if(e.resumePurchase&&(e.resumePurchase.auctionId!==e.auction.id||e.resumePurchase.itemId!==e.itemId||e.resumePurchase.item.id!==e.itemId||e.resumePurchase.item.auctionId!==e.auction.id))throw TypeError(`The purchase recovery record belongs to a different auction item.`);let n=e.auction.items.find(t=>t.id===e.itemId)??e.resumePurchase?.item;return n?A(xe,{...e,item:n}):A(`p`,{role:`alert`,children:`This auction item is not available.`})}export{Se as LockerverseAuctionItem};
2
+ //# sourceMappingURL=auction-item.js.map