@lockerverse/react 0.2.155 → 0.2.157

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -7,6 +7,17 @@ project, use its local README, `package.json` exports, and public `.d.ts` files.
7
7
  Online examples can describe a newer release. Do not import private `dist`
8
8
  modules or copy API details from a different SDK version.
9
9
 
10
+ ## Version-matched integration guides
11
+
12
+ Read [shared integration rules](guides/integration.md) first, then the guide for
13
+ [auctions](guides/auctions.md), [payment widgets](guides/payment-widgets.md),
14
+ [Events](guides/events.md), or [signup](guides/signup.md). These are stable files
15
+ inside the installed package: `node_modules/@lockerverse/react/guides/`.
16
+ They ship with this release and are generated from the maintained documentation.
17
+ Admin prompts supply public resource identity and a minimum SDK version; they
18
+ do not duplicate these rules. Keep a newer matching stable SDK pair instead of
19
+ downgrading it. Read the installed guides and public types before implementation.
20
+
10
21
  ## Usage guide
11
22
 
12
23
  - [Install](#install) and [payment quick start](#use)
@@ -693,63 +704,9 @@ plural options type is also exported from `auctions`.
693
704
 
694
705
  ## Public event listings
695
706
 
696
- Use the public Events entry to show publicly listed Events that are happening
697
- now, start in the future, or have ended. It does not load ticket or payment UI.
698
-
699
- ```tsx
700
- import {
701
- LockerversePublicEvents,
702
- useLockerversePublicEvents,
703
- } from "@lockerverse/react/public-events";
704
- import "@lockerverse/react/public-events.css";
705
-
706
- function CommunityEvents() {
707
- const events = useLockerversePublicEvents({ communitySlug: "auburn" });
708
- return <LockerversePublicEvents events={events} title="Events" theme="light" />;
709
- }
710
- ```
711
-
712
- The hook returns `client`, `events`, `loading`, `error`, and `refresh`. The
713
- component takes the full hook result so it can show loading, empty, and retry
714
- states. `title` sets the visible heading, `showHeading` can hide it, and
715
- `timeZone` controls date display. The default time zone is
716
- `America/New_York`. Use `style` with `LockerverseStyle` tokens or `className`
717
- to match the host site. Links open in a new tab when they use HTTP or HTTPS.
718
- Events can include an optional `imageUrl`. The list uses image cards when an
719
- image is present and a date tile when it is absent. The default view groups
720
- events into "Happening now" and "Upcoming". The "Past Events" view loads on
721
- demand and offers "Load more" for older events. Each card has a share action.
722
- Sharing uses the event link when one exists; otherwise it uses a link to the
723
- event card on the host page. For a one-list view, a card link can load up to
724
- five more pages to find its Event. The visitor can still use Load more.
725
-
726
- Pass one configuration object to the hook for a different list. The component
727
- reads that configuration from the hook result. With `showTabs: false`, it shows
728
- one full-width list; `includePast` selects whether that list includes ended
729
- Events. `from`, `to`, and `sort` set the server-side date range and order.
730
- Without `from` or `to`, a one-list view reads all publicly listed Event
731
- history. It includes past Events by default and sorts by descending start
732
- time, so newer Events appear first. With `includePast: false`, the default is
733
- ascending start time for current and future Events. Each page has 20 Events.
734
-
735
- ```tsx
736
- const config = {
737
- showTabs: false,
738
- includePast: true,
739
- from: "2026-09-01T00:00:00.000Z",
740
- to: "2026-10-01T00:00:00.000Z",
741
- sort: "startAtAsc",
742
- } as const;
743
- const events = useLockerversePublicEvents(
744
- { communitySlug: "auburn" },
745
- { config, initialPage }
746
- );
747
- return <LockerversePublicEvents events={events} />;
748
- ```
749
-
750
- For server rendering, obtain `initialPage` with the SDK client's `search()`
751
- and the same date, scope, sort, and page size. Without this configuration,
752
- `initialEvents` from `list()` keeps the original Upcoming and Past views.
707
+ Read the version-matched [Events integration guide](guides/events.md) for
708
+ `useLockerversePublicEvents`, list configuration, server seeds, and public
709
+ attendee lists. It is generated from the maintained Events documentation.
753
710
 
754
711
  ## Prefill checkout custom fields
755
712
 
@@ -19,7 +19,7 @@
19
19
  line-height: 24px;
20
20
  color: var(--lockerverse-muted, #b5b1bc);
21
21
  }
22
- .lockerverse-auctions button.lockerverse-auctions__catalog-back {
22
+ .lockerverse-auctions .lockerverse-auctions__catalog-back {
23
23
  display: inline-flex;
24
24
  gap: 8px;
25
25
  align-items: center;
@@ -28,6 +28,8 @@
28
28
  margin-bottom: 28px;
29
29
  font-size: 14px;
30
30
  font-weight: 500;
31
+ color: var(--lockerverse-text);
32
+ text-decoration: none;
31
33
  background: rgb(255 255 255 / 4%);
32
34
  border-radius: 999px;
33
35
  }
@@ -206,6 +206,7 @@
206
206
  color: #fff;
207
207
  text-transform: uppercase;
208
208
  letter-spacing: 0.14em;
209
+ text-decoration: none;
209
210
  background: var(--lockerverse-accent);
210
211
  border: 0;
211
212
  border-radius: 999px;
@@ -224,6 +225,7 @@
224
225
  font-size: 14px;
225
226
  font-weight: 500;
226
227
  color: var(--lockerverse-text);
228
+ text-decoration: none;
227
229
  background: rgb(128 128 128 / 6%);
228
230
  border: 1px solid var(--lockerverse-border);
229
231
  border-radius: 999px;
@@ -238,6 +240,7 @@
238
240
  font-size: 14px;
239
241
  font-weight: 500;
240
242
  color: var(--lockerverse-muted);
243
+ text-decoration: none;
241
244
  background: transparent;
242
245
  border: 0;
243
246
  }
@@ -17,6 +17,8 @@ type LockerverseAuctionItemProps = {
17
17
  itemId: string;
18
18
  /** Host navigation; the SDK does not depend on a router. */
19
19
  onBack?: (() => void) | undefined;
20
+ /** Native URL for returning to the auction, including direct item visits. */
21
+ backHref?: string | undefined;
20
22
  /** Item URL for a fresh page visit from the completed result. */
21
23
  returnToItemHref?: string | undefined;
22
24
  /** Disable host navigation/reset while submitting or resolving an uncertain operation.
@@ -1 +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;;EAEA;;;EAGA,2BAA2B;EAC3B;EACA;EACA,QAAQ;EACR,QAAQ;EACR,eAAe;;EAEf,kBAAkB,QAAQ;;EAE1B,sBAAsB,QAAQ;EAC9B,4BACE,UAAU;EAEZ,eAAe;;EAEf,iBAAiB;;;;iBC4XH,uBAAuB,OAAO,8CAA2B,IAAA"}
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;;EAEA;;EAEA;;;EAGA,2BAA2B;EAC3B;EACA;EACA,QAAQ;EACR,QAAQ;EACR,eAAe;;EAEf,kBAAkB,QAAQ;;EAE1B,sBAAsB,QAAQ;EAC9B,4BACE,UAAU;EAEZ,eAAe;;EAEf,iBAAiB;;;;iBC8XH,uBAAuB,OAAO,8CAA2B,IAAA"}
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,i as n,n as r,r as i,s as a,t as o}from"./use-auction-boundary.js";import{t as s}from"./auction-image.js";import{d as c,n as l,p as u,r as d,t as f,u as p}from"./phone-field.js";import{t as m}from"./host-callback.js";import{i as h,n as g,t as _}from"./stripe-loader.js";import{t as v}from"./auction-result2.js";import{ArrowRight as y,ChevronDown as b,ChevronLeft as x,ChevronRight as S,Clock3 as C,Gavel as w,Pause as T,Play as ee,ShieldCheck as E,TimerReset as D,X as O}from"lucide-react";import{useCallback as k,useEffect as A,useId as j,useMemo as M,useRef as N,useState as P}from"react";import{Fragment as F,jsx as I,jsxs as L}from"react/jsx-runtime";import{LockerverseSdkError as R,calculateLockerverseAuctionPricing as z,getLockerverseAuctionMinimumBid as B}from"@lockerverse/sdk/auctions";import{AddressElement as V,Elements as H,PaymentElement as U,useElements as te,useStripe as W}from"@stripe/react-stripe-js";import{Dialog as G}from"@base-ui/react/dialog";import K from"embla-carousel-autoplay";import q from"embla-carousel-react";function J(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 ne(e){let{isPurchase:t,item:r,pricing:i,id:a}=e;return L(`form`,{className:`lockerverse-auctions__checkout`,noValidate:!0,onSubmit:e.onSubmit,children:[L(`div`,{className:`lockerverse-auctions__checkout-header`,children:[L(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[I(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!e.onBack,onClick:e.onBack,type:`button`,children:I(x,{"aria-hidden":`true`,size:20})}),L(`div`,{children:[I(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),I(`p`,{children:t?`Secure checkout`:`Secure payment method`})]})]}),I(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:e.communityName}),I(`h2`,{children:t?`Finalize your purchase.`:`Finalize your bid authorization.`}),I(`p`,{className:`lockerverse-auctions__checkout-summary`,children:t?L(F,{children:[`Pay `,I(`strong`,{children:n(i.totalCents)}),` for`,` `,e.quantity,` `,e.quantity===1?`item`:`items`,` of`,` `,I(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):L(F,{children:[`Authorize a payment method for your bid of`,` `,I(`strong`,{children:n(i.subtotalCents)}),` on`,` `,I(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),r.collectShippingAddress&&L(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[I(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),I(`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.`})]})]}),L(`div`,{className:`lockerverse-auctions__checkout-body`,children:[e.showFields&&L(`fieldset`,{disabled:e.locked,children:[L(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[I(c,{error:e.contactErrors.email,id:`${a}-email`,label:`Email`,name:`email`,onChange:t=>e.onEmailChange(t.target.value),required:!0,value:e.email}),I(u,{error:e.contactErrors.phone,id:`${a}-phone`,label:`Phone`,children:I(f,{country:e.phoneCountry,error:e.contactErrors.phone,errorId:`${a}-phone-error`,id:`${a}-phone`,name:`phone`,onChange:e.onPhoneChange,required:!0,value:e.phone})})]}),L(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[L(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[I(`h3`,{children:`Payment Information`}),I(`p`,{children:t?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),I(U,{onLoadError:e.onPaymentLoadError,options:J(t)})]}),L(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[I(`h3`,{children:`Billing Details`}),I(V,{onChange:e.onBillingChange,options:{mode:`billing`}}),I(`p`,{children:t?`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&&L(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[L(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,htmlFor:`${a}-delivery-same-as-billing`,children:[I(p,{checked:e.sameAsBilling,id:`${a}-delivery-same-as-billing`,onChange:t=>e.onSameAsBillingChange(t.target.checked)}),L(`span`,{children:[I(`strong`,{children:`Delivery address is the same as billing`}),I(`span`,{children:`Leave this on for the fastest flow. Turn it off only if the delivery address should differ from the billing details above.`})]})]}),!e.sameAsBilling&&L(F,{children:[I(`h3`,{children:`Delivery Address`}),I(V,{onChange:e.onShippingChange,options:{mode:`shipping`}})]})]}),e.serviceFeeEnabled&&I(Y,{...e})]}),e.message&&I(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:e.message}),!e.isTerminal&&L(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[L(`p`,{children:[t?`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 ${t?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),L(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:e.submitDisabled,type:`submit`,children:[e.buttonText,I(y,{"aria-hidden":`true`,size:16})]})]})]})]})}function Y(e){let{isPurchase:t,pricing:r}=e;return I(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:e.onIncludeServiceFeeChange?L(`label`,{className:`lockerverse-auctions__checkout-checkbox`,htmlFor:`${e.id}-service-fee`,children:[I(p,{checked:e.includeServiceFee,id:`${e.id}-service-fee`,onChange:t=>e.onIncludeServiceFeeChange?.(t.target.checked)}),L(`span`,{children:[L(`strong`,{children:[t?`Add`:`If I win, add`,` `,n(e.serviceFeeCents),` to help cover processing fees`]}),L(`span`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})]})]}):L(`p`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})})}function X(e,t,n){return z(e,t.saleMode===`buy_now`?(t.buyNowPriceAmount??0)*n.quantity:n.amount,n.includeServiceFee)}function re(t,n,r){if(e(t,n)!==`active`)return`This item is not accepting bids or purchases.`;if(n.saleMode===`hybrid`)return`This item type is not supported for checkout.`;if(n.saleMode===`buy_now`){if(n.isSoldOut||n.availableQuantity===0)return`This item is sold out.`;if(!(n.buyNowPriceAmount&&Number.isSafeInteger(r.quantity))||r.quantity<1||n.availableQuantity!==null&&r.quantity>n.availableQuantity)return`Select an available quantity.`}else if(!Number.isSafeInteger(r.amount)||r.amount%100!=0||r.amount<B(n))return`Enter a whole-dollar bid at or above the minimum bid.`;return null}function ie(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(X(e,n,i))!==JSON.stringify(X(t,r,i))}function ae(e){return{expectedServiceFeeCents:e.serviceFeeCents,expectedSubtotalCents:e.subtotalCents,expectedTotalCents:e.totalCents}}async function oe({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 se(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 ce(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function Z(e){let{auction:t,item:n,selection:r,client:i,onReview:a,onBack:o}=e,s=W(),c=te(),u=j(),[f,p]=P(e.contact?.email??``),[g,_]=P(e.contact?.phone??``),[v,y]=P(()=>d(e.contact?.phone??``)),[b,x]=P({}),[S,C]=P(!0),[w,T]=P(null),[ee,E]=P(null),[D,O]=P(e.resumePurchase??null),[k,M]=P(e.resumePurchase?`pending`:`ready`),[F,L]=P(null),z=N(e.resumePurchase?.submission.clientRequestId??null),B=k===`complete`||k===`uncertain`,V=N(!1),H=N(!0),U=N(e);U.current=e;let G=N(!1);function K(e){H.current&&M(e),m(U.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function q(e){H.current&&L(e)}function J(e){K(e===`bid`?`uncertain`:`pending`),q(e===`bid`?`We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.`:`We could not confirm the purchase result. Check its status using the same purchase request.`),G.current||(G.current=!0,m(U.current.onUncertain,e))}A(()=>(H.current=!0,()=>{H.current=!1}),[]);let Y=!!(D??e.resumePurchase)||n.saleMode===`buy_now`,Z=D?.pricing??e.resumePurchase?.pricing??X(t,n,r),Q=D?.payment??e.resumePurchase?.payment??t.payment;function $(e){H.current&&O(e),m(U.current.onPurchaseRecoveryChange,e)}function le(e){e.status===`paid`?(z.current=null,$(null),K(`complete`),m(U.current.onResult,{kind:`purchase`,purchaseId:e.purchaseId,quantity:e.quantity,serviceFeeCents:e.serviceFeeCents,status:`paid`,subtotalCents:e.subtotalCents,totalCents:e.totalCents,unitAmountCents:e.subtotalCents/e.quantity}),G.current||(G.current=!0,m(U.current.onPurchaseComplete,e))):e.status===`pending_payment`?(K(`pending`),q(`Your purchase is pending. Check its status before making another payment.`)):(z.current=null,$(null),K(`ready`),q(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`))}function ue(){let e=l(g,v),t=h({email:f,phone:e},!0);return x(t.errors),t.value?{email:t.value.email,phone:e}:(document.getElementById(`${u}-${t.errors.email?`email`:`phone`}`)?.focus(),null)}async function de(e){if(!e)throw Error(`Check the contact fields below.`);if(!(s&&c&&t.payment))throw Error(`Payment details are still loading.`);let o=await i.load(t.slug);if(!H.current)return null;let l=o.items.find(e=>e.id===n.id);if(!l)return a(o,`This item is no longer available.`),null;let u=re(o,l,r);if(u||ie(t,o,n,l,r))return a(o,u??`The checkout details changed. Review them before continuing.`),null;let d=await oe({billing:w,collectShippingAddress:n.collectShippingAddress,elements:c,email:e.email,phone:e.phone,shipping:S?w:ee,stripe:s});return H.current?{confirmationToken:d,email:e.email,includeServiceFee:r.includeServiceFee,phone:e.phone,...ae(Z)}:null}async function fe(e){let a=await i.createBid(t.slug,n.id,{...e,amount:r.amount});if(a.requiresAction){if(!(H.current&&s)){J(`bid`);return}await se(s,a)}K(`complete`),m(U.current.onResult,{amountCents:a.subtotalCents,kind:`bid`}),G.current||(G.current=!0,m(U.current.onBidSubmitted,a))}async function pe(e,r){if(e.requiresAction){if(!(H.current&&s)){J(`purchase`);return}await se(s,e);let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);a?le(a):(K(`pending`),q(`Payment status is not available yet. Check again shortly.`));return}le(e),!H.current&&e.status===`pending_payment`&&J(`purchase`)}async function me(e){let r=await i.getPurchaseStatus(t.slug,n.id,e.submission.clientRequestId);if(r)await pe(r,e);else{if(!H.current){J(`purchase`);return}K(`retry`),q(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)}}async function he(e,r){let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);if(a){await pe(a,r);return}$(null),K(`ready`),q(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}async function ge(e,t,n,r){let i=t&&(!(e instanceof R)||e.recoveryRecommended);if(q(e instanceof Error?e.message:`Unable to complete this request.`),Y&&n){if(!r&&e instanceof R&&!e.recoveryRecommended)try{await he(e,n);return}catch{}J(`purchase`)}else i?J(`bid`):K(`ready`)}function _e(){return z.current??=globalThis.crypto.randomUUID(),z.current}function ve(){return H.current?!0:(D||($(null),K(`ready`)),!1)}async function ye(e,r){if(r){await me(e);return}ve()&&await pe(await i.createPurchase(t.slug,n.id,e.submission),e)}let be=s&&c&&Q;function xe(){if(V.current||B)return null;if(!be)return q(`Payment details are still loading.`),null;let e=D?null:ue();return D||e?{checkoutPayment:be,contact:e,retryOriginal:k===`retry`}:null}async function Se(e){e.preventDefault();let i=xe();if(!i)return;let{contact:a,checkoutPayment:o,retryOriginal:s}=i;V.current=!0,G.current=!1,K(`busy`),q(null);let c=!1,l=D;try{if(!l){let e=await de(a);if(!(e&&H.current)){K(`ready`);return}if(!Y){c=!0,await fe(e);return}l=Object.freeze({auctionId:t.id,item:n,itemId:n.id,payment:Object.freeze({...o}),pricing:Z,submission:Object.freeze({...e,clientRequestId:_e(),paymentMethodTypes:Object.freeze([`card`]),quantity:r.quantity})}),$(l)}c=!0,await ye(l,!!D&&!s)}catch(e){await ge(e,c,l,D!==null&&!s)}finally{V.current=!1}}let Ce=ce(k,D!==null,Y),we=k!==`ready`;return I(ne,{buttonText:Ce,communityName:e.communityName??t.name,contactErrors:b,email:f,id:u,includeServiceFee:r.includeServiceFee,isPurchase:Y,isTerminal:B,item:n,locked:we,message:F,onBack:k===`ready`?o:void 0,onBillingChange:T,onEmailChange:t=>{p(t),e.onContactChange?.({email:t,phone:l(g,v)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>q(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{_(t),y(n),e.onContactChange?.({email:f,phone:l(t,n)})},onSameAsBillingChange:C,onShippingChange:E,onSubmit:Se,phone:g,phoneCountry:v,pricing:Z,quantity:r.quantity,sameAsBilling:S,serviceFeeCents:D?Z.serviceFeeCents:X(t,n,{...r,includeServiceFee:t.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:t.serviceFeeEnabled,showFields:!(D||B),submitDisabled:k===`busy`||!s||!c})}const Q=6e3;function $(e,t){let n=N(Q),r=N(null),[i,a]=P(Q),o=M(()=>K({delay:i,playOnInit:!1,stopOnFocusIn:!1,stopOnInteraction:!0,stopOnMouseEnter:!1}),[i]),[s,c]=q({duration:t?0:25,loop:!0},[o]),l=k(()=>{r.current&&(r.current.style.transform=`scaleX(${1-n.current/Q})`)},[]),u=k(()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(1,Math.min(Q,e))),o.stop(),l()},[o,l]),d=k(()=>{n.current=Q,a(Q),o.reset(),l()},[o,l]);return A(()=>{c&&(e?i===n.current?o.play():a(n.current):u())},[c,e,o,i,a,n,u]),A(()=>{if(!c)return;let t=0,r=()=>{let i=o.timeUntilNext();!e||i===null||(n.current=Math.max(0,Math.min(Q,i)),l(),t=requestAnimationFrame(r))},i=()=>{cancelAnimationFrame(t),e&&(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 le({photos:e,name:t,selected:n,paused:i=!1,photoButtonRef:a,onSelect:o,onExpand:c}){let l=N(null),u=N(null),d=N([]),[f,p]=P(!0),[m,h]=P(!1),[g,_]=P(!1),[v,y]=P(!1),[b,C]=P(!1),{ref:w,visible:E}=r(),[D,O]=P(!1),[k,j]=P(!0),M=N(null),R=`lockerverse-auction-gallery__control ${k||D||g?`is-visible`:``}`,z=()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>O(!1),2e3)},B=e=>{if(e.pointerType!==`mouse`){j(!0);return}O(!0),M.current&&clearTimeout(M.current),e.target instanceof Element&&e.target.closest(`[data-gallery-control]`)||z()};A(()=>{let e=window.matchMedia(`(hover: none), (pointer: coarse)`),t=()=>j(e.matches);return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),clearTimeout(M.current??void 0)}},[]);let V=!(i||f||m||g||v||b)&&E,H=e.length,U=H?(n%H+H)%H:0,{viewportRef:te,embla:W,progressRef:G,freeze:K,reset:q}=$(V&&H>1,f);A(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>p(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),A(()=>{if(!W)return;let e=()=>o(W.selectedScrollSnap());return W.on(`select`,e).on(`reInit`,e),()=>{W.off(`select`,e).off(`reInit`,e)}},[W,o]),A(()=>{W&&W.selectedScrollSnap()!==U&&W.scrollTo(U,!0)},[W,U]),A(()=>{let e=()=>{document.hidden&&K()},t=()=>C(!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)}},[K]);let J=e=>{W?.scrollTo((e+H)%H,f),q()};return A(()=>{let e=u.current;u.current=null,e&&document.activeElement===e&&w.current?.querySelector(`.lockerverse-auction-gallery__photo[tabindex="0"]`)?.focus({preventScroll:!0})},[U,w]),A(()=>{let e=l.current,t=d.current[U];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)},[U,H]),L(`section`,{"aria-label":`${t} photos`,className:`lockerverse-auction-gallery`,onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||_(!1)},onFocusCapture:e=>_(e.target.matches(`:focus-visible`)),onKeyDown:e=>{H<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),e.target instanceof HTMLButtonElement&&e.target.classList.contains(`lockerverse-auction-gallery__photo`)&&(u.current=e.target),J(U+(e.key===`ArrowRight`?1:-1)))},onPointerEnter:e=>{e.pointerType===`mouse`&&h(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&h(!1)},ref:w,children:[H?L(`div`,{className:`lockerverse-auction-gallery__stage`,onPointerEnter:B,onPointerLeave:z,onPointerMove:B,children:[I(`div`,{className:`lockerverse-auction-gallery__viewport`,onPointerDownCapture:()=>{K(),C(!0)},ref:te,children:I(`div`,{className:`lockerverse-auction-gallery__track`,children:e.map((e,n)=>I(`div`,{"aria-hidden":n!==U,className:`lockerverse-auction-gallery__slide`,children:I(`button`,{"aria-label":`View photo ${n+1} of ${t} at full size`,className:`lockerverse-auction-gallery__photo`,onClick:()=>{c(n)},ref:n===U?a:void 0,tabIndex:n===U?0:-1,type:`button`,children:I(s,{alt:`${t}, ${n+1} of ${H}`,className:`lockerverse-auction-gallery__image`,draggable:!1,height:900,loading:n===0||n===U||n===(U+1)%H?`eager`:`lazy`,maxWidth:1280,sizes:`(max-width: 1280px) 100vw, 45vw`,src:e,width:1200})})},`${e}-${n}`))})}),H>1&&!f&&L(`div`,{className:`lockerverse-auction-gallery__rotation`,children:[I(`div`,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__progress-track`,children:I(`div`,{className:`lockerverse-auction-gallery__progress`,ref:G,style:{transform:`scaleX(0)`}})}),I(`button`,{"aria-label":v?`Play photo rotation`:`Pause photo rotation`,className:`lockerverse-auction-gallery__play ${R}`,"data-gallery-control":!0,onClick:()=>y(e=>!e),title:v?`Play photo rotation`:`Pause photo rotation`,type:`button`,children:I(v?ee:T,{"aria-hidden":`true`,size:13})})]}),H>1&&L(F,{children:[I(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__previous ${R}`,"data-gallery-control":!0,onClick:()=>J(U-1),type:`button`,children:I(x,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})}),I(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__next ${R}`,"data-gallery-control":!0,onClick:()=>J(U+1),type:`button`,children:I(S,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})})]})]}):I(`div`,{className:`lockerverse-auction-gallery__empty`,children:`No photo available`}),H>1&&I(`section`,{"aria-label":`Choose a photo`,className:`lockerverse-auction-gallery__strip`,ref:l,children:I(`div`,{className:`lockerverse-auction-gallery__thumbnails`,children:e.map((e,t)=>I(`button`,{"aria-label":`Show photo ${t+1} of ${H}`,"aria-pressed":U===t,className:`lockerverse-auction-gallery__thumbnail ${U===t?`is-selected`:``}`,onClick:()=>J(t),ref:e=>{d.current[t]=e},type:`button`,children:I(s,{alt:``,className:`lockerverse-auction-gallery__thumbnail-image`,height:66,loading:`lazy`,maxWidth:192,sizes:`88px`,src:e,width:88})},`${e}-${t}`))})})]})}function ue({images:e,fallbackImage:t,name:n}){let r=[...new Set(e.filter(Boolean))];!r.length&&t&&r.push(t);let[i,a]=P(0),[o,c]=P(!1),l=N(null),u=N(null),d=r.length,f=d?(i%d+d)%d:0;return L(F,{children:[I(le,{name:n,onExpand:e=>{a(e),c(!0)},onSelect:a,paused:o,photoButtonRef:l,photos:r,selected:f}),d>0&&I(G.Root,{onOpenChange:c,open:o,children:L(G.Portal,{children:[I(G.Backdrop,{className:`lockerverse-auction-gallery__backdrop`}),L(G.Popup,{"aria-describedby":void 0,className:`lockerverse-auction-gallery__viewer`,finalFocus:l,onKeyDown:e=>{d<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),a((f+(e.key===`ArrowRight`?1:-1)+d)%d))},children:[L(G.Title,{className:`lockerverse-auction-gallery__sr-only`,children:[n,` · Photo `,f+1,` of `,d]}),L(`div`,{className:`lockerverse-auction-gallery__full-image`,onTouchCancel:()=>{u.current=null},onTouchEnd:e=>{let t=u.current;u.current=null;let n=e.changedTouches.item(0);if(!(t&&n)||d<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((f+(r<0?1:-1)+d)%d)},onTouchMove:e=>{e.touches.length!==1&&(u.current=null)},onTouchStart:e=>{let t=e.touches.item(0);u.current=e.touches.length===1&&t?{x:t.clientX,y:t.clientY}:null},children:[I(s,{alt:`${n}, ${f+1} of ${d}`,height:900,maxWidth:1920,sizes:`100vw`,src:r[f],width:1200}),o&&d>1&&I(s,{alt:``,"aria-hidden":`true`,className:`lockerverse-auction-gallery__preload`,height:900,loading:`eager`,maxWidth:1920,sizes:`100vw`,src:r[(f+1)%d],width:1200})]}),I(G.Close,{"aria-label":`Close photo viewer`,className:`lockerverse-auction-gallery__viewer-close`,children:I(O,{"aria-hidden":`true`,size:22})}),d>1&&L(F,{children:[I(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__viewer-previous`,onClick:()=>a((f-1+d)%d),type:`button`,children:I(x,{"aria-hidden":`true`,size:28})}),I(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__viewer-next`,onClick:()=>a((f+1)%d),type:`button`,children:I(S,{"aria-hidden":`true`,size:28})})]})]})]})})]})}function de(e){return I(e===`Buy Now`?E:e===`Available`||e===`Increment`?D:w,{"aria-hidden":`true`,size:16})}function fe(e,t){return e.saleMode===`buy_now`?[[`Buy Now`,n(e.buyNowPriceAmount??0)],[`Available`,e.availableQuantity===null?`Available`:String(e.availableQuantity)]]:t===`finished`?[[`Final bid`,e.maxBidAmount?n(e.maxBidAmount):`No bids`]]:[[`Current bid`,n(e.maxBidAmount??0)],[`Floor`,n(e.minBidAmount??0)],[`Increment`,n(e.bidIncrementAmount??100)]]}function pe({auction:r,item:a}){o(a.startAt??r.startAt,a.endAt??r.endAt);let[s,c]=P(!1),l=j(),u=e(r,a),d={active:`Closes`,draft:`Opens`,finished:`Closed`}[u],f=i(r,u,a),p=a.saleMode===`buy_now`,m=(a.description??``).trim().length>240,h=fe(a,u);return L(`section`,{className:`lockerverse-auctions__item-summary`,children:[I(ue,{fallbackImage:a.image??r.configuration.image??r.community?.banner??r.community?.thumbnail??null,images:a.images,name:a.name}),L(`div`,{className:`lockerverse-auctions__item-copy`,children:[I(`h2`,{children:a.name}),a.description?L(`div`,{className:`lockerverse-auctions__item-description`,children:[I(t,{className:!s&&m?`lockerverse-auctions__description-clamped`:void 0,description:a.description,id:l}),m?L(`button`,{"aria-controls":l,"aria-expanded":s,className:`lockerverse-auctions__description-toggle`,onClick:()=>c(!s),type:`button`,children:[s?`Hide description`:`Read full description`,` `,I(b,{"aria-hidden":`true`,size:16,style:{transform:s?`rotate(180deg)`:void 0}})]}):null]}):null,L(`dl`,{className:`lockerverse-auctions__stat-panel`,children:[h.map(([e,t])=>L(`div`,{className:`lockerverse-auctions__stat-row`,children:[L(`dt`,{children:[de(e),e]}),I(`dd`,{children:t})]},e)),L(`div`,{className:`lockerverse-auctions__stat-row`,children:[L(`dt`,{children:[I(C,{"aria-hidden":`true`,size:16}),d]}),I(`dd`,{className:`lockerverse-auctions__stat-date`,children:f})]}),!p&&u===`finished`?L(`div`,{className:`lockerverse-auctions__stat-footer`,children:[L(`div`,{children:[I(`dt`,{children:`Floor`}),I(`dd`,{children:n(a.minBidAmount??0)})]}),L(`div`,{children:[I(`dt`,{children:`Bid increment`}),I(`dd`,{children:n(a.bidIncrementAmount??100)})]})]}):null]})]})]})}const me=/^\d+$/;function he(e,t){return me.test(e)&&Number.isSafeInteger(Number(e)*t)?`Total: ${n(Number(e)*t)}`:`Enter a whole-number quantity.`}function ge(e,t,n){return String(e?t?t.quantity:1:t?t.amount/100:n)}function _e(e,t){return a(e)?`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 ve(e,t,n){return a(t)?`All available quantities have been purchased.`:n===`draft`?`This item opens ${i(e,`draft`,t)}.`:t.saleMode===`buy_now`?`This item is no longer available to purchase.`:`Bidding has closed for this item.`}function ye(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 be({auction:t,item:r,initialSelection:i,onContinue:s,onError:c,onBack:l}){let u=r.saleMode===`buy_now`,d=Math.ceil(B(r)/100),[f,p]=P(ge(u,i,d)),[m,h]=P(null),g=j();o(r.startAt??t.startAt,r.endAt??t.endAt);let _=e(t,r),v=_===`active`&&!a(r)&&r.saleMode!==`hybrid`;function b(e){if(e.preventDefault(),!me.test(f)){h(u?`Enter a whole-number quantity.`:`Enter a whole-dollar bid amount.`);return}let n=ye(t,u,i,f),a=re(t,r,n);if(a){h(a),c(a);return}try{X(t,r,n)}catch{h(`Enter a valid amount or quantity.`);return}s(n)}return v?L(`form`,{className:`lockerverse-auctions__selection`,onSubmit:b,children:[I(xe,{buyNow:u,item:r,minimum:d}),L(`div`,{className:`lockerverse-auctions__selection-body`,children:[L(`label`,{className:`lockerverse-auctions__field`,htmlFor:g,children:[u?`Quantity`:`Your bid amount`,L(`span`,{className:`lockerverse-auctions__amount-control`,children:[u?null:I(`span`,{"aria-hidden":`true`,children:`$`}),I(`input`,{"aria-describedby":`${g}-help`,"aria-invalid":!!m,autoComplete:`off`,id:g,inputMode:`numeric`,onChange:e=>{p(e.target.value),h(null)},placeholder:u?`1`:String(d),required:!0,value:f})]})]}),m?I(`p`,{role:`alert`,children:m}):null,I(`p`,{id:`${g}-help`,children:u?he(f,r.buyNowPriceAmount??0):`Enter a whole-dollar bid of at least ${n(d*100)}. Bid increment: ${n(r.bidIncrementAmount??100)}.`}),L(`div`,{className:`lockerverse-auctions__selection-footer`,children:[I(`p`,{children:u?`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.`}),L(`button`,{className:`lockerverse-auctions__button`,disabled:!t.payment,type:`submit`,children:[u?`Continue to Checkout`:`Continue to Payment`,` `,I(y,{"aria-hidden":`true`,size:16})]})]}),t.payment?null:I(`p`,{role:`alert`,children:`Payments are not configured for this auction.`})]})]}):L(`div`,{className:`lockerverse-auctions__selection lockerverse-auctions__read-only`,children:[I(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Item status`}),I(`h3`,{children:_e(r,_)}),I(`p`,{children:ve(t,r,_)}),l?L(`button`,{className:`lockerverse-auctions__button`,onClick:l,type:`button`,children:[`Browse auction items `,I(y,{"aria-hidden":`true`,size:16})]}):null]})}function xe({item:e,buyNow:t,minimum:r}){return L(`div`,{className:`lockerverse-auctions__selection-header`,children:[I(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Step 1 of 2`}),I(`h3`,{children:t?`Buy this item now.`:`Place your bid.`}),I(`p`,{children:t?`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.`}),L(`p`,{children:[t?`Price: `:`Minimum qualifying bid: `,I(`strong`,{children:n(t?e.buyNowPriceAmount??0:r*100)})]}),t&&e.availableQuantity!==null?L(`p`,{children:[e.availableQuantity,` available`]}):null,e.collectShippingAddress?I(`p`,{children:`The next step will also collect a delivery address for seller fulfillment.`}):null]})}function Se(e){let{auction:t,item:n,selection:r,theme:i=`dark`,stripeLoader:a=_,style:o,onBack:s,resumePurchase:c}=e,[l,u]=P(null),[d,f]=P(!1),[p,m]=P(0),h=g(e.appearanceRoot,i,o,e.interactionLocked),v=c?.payment??t.payment;if(A(()=>{let e=!0;if(!v){f(!0);return}return Promise.resolve().then(()=>a(v.publishableKey,v.connectedAccountId?{stripeAccount:v.connectedAccountId}:void 0)).then(t=>{e&&(u(t),f(!t))},()=>{e&&f(!0)}),()=>{e=!1}},[v,a,p]),d)return L(`div`,{children:[I(`p`,{role:`alert`,children:`Payment details could not load.`}),c?null:I(`button`,{onClick:s,type:`button`,children:`Back to item`}),I(`button`,{onClick:()=>{f(!1),u(null),m(e=>e+1)},type:`button`,children:`Try again`})]});if(!(l&&h))return L(`div`,{children:[I(`p`,{role:`status`,children:`Loading secure payment details…`}),c?null:I(`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:X(t,n,r).totalCents,currency:`usd`,mode:`payment`});let b={...y,appearance:h,currency:`usd`,paymentMethodTypes:[`card`],syncAddressCheckbox:`none`};return I(H,{options:b,stripe:l,children:I(Z,{...e})})}function Ce({buyNow:e}){return L(`div`,{className:`lockerverse-auctions__progress`,children:[L(`span`,{children:[I(e?E:w,{"aria-hidden":`true`,size:16}),e?`Choose quantity`:`Place bid`]}),L(`span`,{children:[I(E,{"aria-hidden":`true`,size:16}),e?`Pay securely`:`Secure card`]}),L(`span`,{children:[I(D,{"aria-hidden":`true`,size:16}),e?`Get confirmation`:`Wait for close`]})]})}function we(e){let{auction:t,item:n,outcome:r}=e,a=e.onBack?{label:`View auction items`,onClick:e.onBack}:void 0;return I(v,{auctionName:t.name,className:e.className,closesAtLabel:i(t,`active`,n),communityName:e.communityName??t.community?.name,focusHeading:!0,imageUrl:n.image??n.images[0]??t.configuration.image??void 0,itemName:n.name,outcome:r,primaryAction:e.returnToItemHref?{href:e.returnToItemHref,label:`Return to item`}:a,secondaryAction:e.returnToItemHref?a:void 0,style:{"--lockerverse-accent":t.community?.color??`#6f8f6d`,...e.style},theme:e.theme})}function Te(t){let{auction:n,itemId:r,resumePurchase:i,className:a,theme:s=`dark`,style:c}=t,l=N(null),[u,d]=P(n),f=N(n),p=u.items.find(e=>e.id===r)??i?.item;o(p?.startAt??u.startAt,p?.endAt??u.endAt);let[h,g]=P(()=>i?{amount:0,includeServiceFee:i.submission.includeServiceFee??!1,quantity:i.submission.quantity}:null),[_,v]=P(!!i),b=N(!0),S=N(t);S.current=t;let C=N(null),w=k(e=>{b.current&&v(e),C.current!==e&&(C.current=e,m(S.current.onInteractionLockChange,e))},[]),T=!!i;A(()=>(b.current=!0,w(T),()=>{b.current=!1}),[T,w]);let[ee,E]=P({email:``,phone:``}),[D,O]=P(!!i),[j,M]=P(null),[F,R]=P(null);A(()=>{!(D||_||i)&&f.current!==n&&(f.current=n,d(n))},[n,D,_,i]);function z(e,t){w(!1),f.current=S.current.auction,d(e),g(null),O(!1),M(t)}function B(e){M(null),g(e),O(!0)}return p?F?I(we,{...t,auction:u,item:p,outcome:F}):L(`section`,{className:[`lockerverse-auctions`,a].filter(Boolean).join(` `),"data-lockerverse-theme":s,ref:l,style:{"--lockerverse-accent":u.community?.color??`#6f8f6d`,...c},children:[t.onBack&&!_?L(`button`,{className:`lockerverse-auctions__back`,onClick:t.onBack,type:`button`,children:[I(x,{"aria-hidden":`true`,size:16}),` All items`]}):null,L(`div`,{className:`lockerverse-auctions__detail`,children:[I(pe,{auction:u,item:p}),L(`div`,{className:`lockerverse-auctions__transaction`,children:[e(u,p)===`active`?I(Ce,{buyNow:p.saleMode===`buy_now`}):null,j?I(`p`,{className:`lockerverse-auctions__notice`,role:`alert`,children:j}):null,D&&h?I(Se,{...t,appearanceRoot:l,auction:u,communityName:t.communityName??u.community?.name,contact:ee,interactionLocked:_,item:p,onBack:()=>O(!1),onContactChange:E,onIncludeServiceFeeChange:e=>g(t=>t&&{...t,includeServiceFee:u.serviceFeeEnabled&&e}),onInteractionLockChange:w,onResult:R,onReview:z,selection:h}):I(be,{auction:u,initialSelection:h,item:p,onBack:t.onBack,onContinue:B,onError:M}),t.onBack&&!_?L(`button`,{className:`lockerverse-auctions__footer-back`,onClick:t.onBack,type:`button`,children:[`Back to auction items `,I(y,{"aria-hidden":`true`,size:16})]}):null]})]})]}):L(`div`,{children:[I(`p`,{role:`alert`,children:`This auction item is no longer available.`}),t.onBack?I(`button`,{onClick:t.onBack,type:`button`,children:`Back to auction items`}):null]})}function Ee(e){let t=N({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.`);return I(Te,{...e})}export{Ee as LockerverseAuctionItem};
1
+ import{a as e,c as t,i as n,l as r,n as i,r as a,s as o,t as s}from"./use-auction-boundary.js";import{t as c}from"./auction-image.js";import{d as l,n as u,p as d,r as f,t as p,u as m}from"./phone-field.js";import{t as h}from"./host-callback.js";import{i as g,n as _,t as v}from"./stripe-loader.js";import{t as y}from"./auction-result2.js";import{ArrowRight as b,ChevronDown as x,ChevronLeft as S,ChevronRight as C,Clock3 as w,Gavel as T,Pause as E,Play as ee,ShieldCheck as D,TimerReset as O,X as k}from"lucide-react";import{useCallback as A,useEffect as j,useId as M,useMemo as N,useRef as P,useState as F}from"react";import{Fragment as I,jsx as L,jsxs as R}from"react/jsx-runtime";import{LockerverseSdkError as z,calculateLockerverseAuctionPricing as B,getLockerverseAuctionMinimumBid as V}from"@lockerverse/sdk/auctions";import{AddressElement as H,Elements as U,PaymentElement as W,useElements as G,useStripe as te}from"@stripe/react-stripe-js";import{Dialog as K}from"@base-ui/react/dialog";import q from"embla-carousel-autoplay";import J from"embla-carousel-react";function Y(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 ne(e){let{isPurchase:t,item:r,pricing:i,id:a}=e;return R(`form`,{className:`lockerverse-auctions__checkout`,noValidate:!0,onSubmit:e.onSubmit,children:[R(`div`,{className:`lockerverse-auctions__checkout-header`,children:[R(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[L(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!e.onBack,onClick:e.onBack,type:`button`,children:L(S,{"aria-hidden":`true`,size:20})}),R(`div`,{children:[L(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),L(`p`,{children:t?`Secure checkout`:`Secure payment method`})]})]}),L(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:e.communityName}),L(`h2`,{children:t?`Finalize your purchase.`:`Finalize your bid authorization.`}),L(`p`,{className:`lockerverse-auctions__checkout-summary`,children:t?R(I,{children:[`Pay `,L(`strong`,{children:n(i.totalCents)}),` for`,` `,e.quantity,` `,e.quantity===1?`item`:`items`,` of`,` `,L(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):R(I,{children:[`Authorize a payment method for your bid of`,` `,L(`strong`,{children:n(i.subtotalCents)}),` on`,` `,L(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),r.collectShippingAddress&&R(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[L(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),L(`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.`})]})]}),R(`div`,{className:`lockerverse-auctions__checkout-body`,children:[e.showFields&&R(`fieldset`,{disabled:e.locked,children:[R(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[L(l,{error:e.contactErrors.email,id:`${a}-email`,label:`Email`,name:`email`,onChange:t=>e.onEmailChange(t.target.value),required:!0,value:e.email}),L(d,{error:e.contactErrors.phone,id:`${a}-phone`,label:`Phone`,children:L(p,{country:e.phoneCountry,error:e.contactErrors.phone,errorId:`${a}-phone-error`,id:`${a}-phone`,name:`phone`,onChange:e.onPhoneChange,required:!0,value:e.phone})})]}),R(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[R(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[L(`h3`,{children:`Payment Information`}),L(`p`,{children:t?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),L(W,{onLoadError:e.onPaymentLoadError,options:Y(t)})]}),R(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[L(`h3`,{children:`Billing Details`}),L(H,{onChange:e.onBillingChange,options:{mode:`billing`}}),L(`p`,{children:t?`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&&R(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[R(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,htmlFor:`${a}-delivery-same-as-billing`,children:[L(m,{checked:e.sameAsBilling,id:`${a}-delivery-same-as-billing`,onChange:t=>e.onSameAsBillingChange(t.target.checked)}),R(`span`,{children:[L(`strong`,{children:`Delivery address is the same as billing`}),L(`span`,{children:`Leave this on for the fastest flow. Turn it off only if the delivery address should differ from the billing details above.`})]})]}),!e.sameAsBilling&&R(I,{children:[L(`h3`,{children:`Delivery Address`}),L(H,{onChange:e.onShippingChange,options:{mode:`shipping`}})]})]}),e.serviceFeeEnabled&&L(X,{...e})]}),e.message&&L(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:e.message}),!e.isTerminal&&R(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[R(`p`,{children:[t?`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 ${t?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),R(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:e.submitDisabled,type:`submit`,children:[e.buttonText,L(b,{"aria-hidden":`true`,size:16})]})]})]})]})}function X(e){let{isPurchase:t,pricing:r}=e;return L(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:e.onIncludeServiceFeeChange?R(`label`,{className:`lockerverse-auctions__checkout-checkbox`,htmlFor:`${e.id}-service-fee`,children:[L(m,{checked:e.includeServiceFee,id:`${e.id}-service-fee`,onChange:t=>e.onIncludeServiceFeeChange?.(t.target.checked)}),R(`span`,{children:[R(`strong`,{children:[t?`Add`:`If I win, add`,` `,n(e.serviceFeeCents),` to help cover processing fees`]}),R(`span`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})]})]}):R(`p`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})})}function Z(e,t,n){return B(e,t.saleMode===`buy_now`?(t.buyNowPriceAmount??0)*n.quantity:n.amount,n.includeServiceFee)}function re(t,n,r){if(e(t,n)!==`active`)return`This item is not accepting bids or purchases.`;if(n.saleMode===`hybrid`)return`This item type is not supported for checkout.`;if(n.saleMode===`buy_now`){if(n.isSoldOut||n.availableQuantity===0)return`This item is sold out.`;if(!(n.buyNowPriceAmount&&Number.isSafeInteger(r.quantity))||r.quantity<1||n.availableQuantity!==null&&r.quantity>n.availableQuantity)return`Select an available quantity.`}else if(!Number.isSafeInteger(r.amount)||r.amount%100!=0||r.amount<V(n))return`Enter a whole-dollar bid at or above the minimum bid.`;return null}function ie(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(Z(e,n,i))!==JSON.stringify(Z(t,r,i))}function ae(e){return{expectedServiceFeeCents:e.serviceFeeCents,expectedSubtotalCents:e.subtotalCents,expectedTotalCents:e.totalCents}}async function oe({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 se(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 ce(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function le(e){let{auction:t,item:n,selection:r,client:i,onReview:a,onBack:o}=e,s=te(),c=G(),l=M(),[d,p]=F(e.contact?.email??``),[m,_]=F(e.contact?.phone??``),[v,y]=F(()=>f(e.contact?.phone??``)),[b,x]=F({}),[S,C]=F(!0),[w,T]=F(null),[E,ee]=F(null),[D,O]=F(e.resumePurchase??null),[k,A]=F(e.resumePurchase?`pending`:`ready`),[N,I]=F(null),R=P(e.resumePurchase?.submission.clientRequestId??null),B=k===`complete`||k===`uncertain`,V=P(!1),H=P(!0),U=P(e);U.current=e;let W=P(!1);function K(e){H.current&&A(e),h(U.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function q(e){H.current&&I(e)}function J(e){K(e===`bid`?`uncertain`:`pending`),q(e===`bid`?`We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.`:`We could not confirm the purchase result. Check its status using the same purchase request.`),W.current||(W.current=!0,h(U.current.onUncertain,e))}j(()=>(H.current=!0,()=>{H.current=!1}),[]);let Y=!!(D??e.resumePurchase)||n.saleMode===`buy_now`,X=D?.pricing??e.resumePurchase?.pricing??Z(t,n,r),le=D?.payment??e.resumePurchase?.payment??t.payment;function Q(e){H.current&&O(e),h(U.current.onPurchaseRecoveryChange,e)}function ue(e){e.status===`paid`?(R.current=null,Q(null),K(`complete`),h(U.current.onResult,{kind:`purchase`,purchaseId:e.purchaseId,quantity:e.quantity,serviceFeeCents:e.serviceFeeCents,status:`paid`,subtotalCents:e.subtotalCents,totalCents:e.totalCents,unitAmountCents:e.subtotalCents/e.quantity}),W.current||(W.current=!0,h(U.current.onPurchaseComplete,e))):e.status===`pending_payment`?(K(`pending`),q(`Your purchase is pending. Check its status before making another payment.`)):(R.current=null,Q(null),K(`ready`),q(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`))}function de(){let e=u(m,v),t=g({email:d,phone:e},!0);return x(t.errors),t.value?{email:t.value.email,phone:e}:(document.getElementById(`${l}-${t.errors.email?`email`:`phone`}`)?.focus(),null)}async function fe(e){if(!e)throw Error(`Check the contact fields below.`);if(!(s&&c&&t.payment))throw Error(`Payment details are still loading.`);let o=await i.load(t.slug);if(!H.current)return null;let l=o.items.find(e=>e.id===n.id);if(!l)return a(o,`This item is no longer available.`),null;let u=re(o,l,r);if(u||ie(t,o,n,l,r))return a(o,u??`The checkout details changed. Review them before continuing.`),null;let d=await oe({billing:w,collectShippingAddress:n.collectShippingAddress,elements:c,email:e.email,phone:e.phone,shipping:S?w:E,stripe:s});return H.current?{confirmationToken:d,email:e.email,includeServiceFee:r.includeServiceFee,phone:e.phone,...ae(X)}:null}async function pe(e){let a=await i.createBid(t.slug,n.id,{...e,amount:r.amount});if(a.requiresAction){if(!(H.current&&s)){J(`bid`);return}await se(s,a)}K(`complete`),h(U.current.onResult,{amountCents:a.subtotalCents,kind:`bid`}),W.current||(W.current=!0,h(U.current.onBidSubmitted,a))}async function $(e,r){if(e.requiresAction){if(!(H.current&&s)){J(`purchase`);return}await se(s,e);let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);a?ue(a):(K(`pending`),q(`Payment status is not available yet. Check again shortly.`));return}ue(e),!H.current&&e.status===`pending_payment`&&J(`purchase`)}async function me(e){let r=await i.getPurchaseStatus(t.slug,n.id,e.submission.clientRequestId);if(r)await $(r,e);else{if(!H.current){J(`purchase`);return}K(`retry`),q(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)}}async function he(e,r){let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);if(a){await $(a,r);return}Q(null),K(`ready`),q(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}async function ge(e,t,n,r){let i=t&&(!(e instanceof z)||e.recoveryRecommended);if(q(e instanceof Error?e.message:`Unable to complete this request.`),Y&&n){if(!r&&e instanceof z&&!e.recoveryRecommended)try{await he(e,n);return}catch{}J(`purchase`)}else i?J(`bid`):K(`ready`)}function _e(){return R.current??=globalThis.crypto.randomUUID(),R.current}function ve(){return H.current?!0:(D||(Q(null),K(`ready`)),!1)}async function ye(e,r){if(r){await me(e);return}ve()&&await $(await i.createPurchase(t.slug,n.id,e.submission),e)}let be=s&&c&&le;function xe(){if(V.current||B)return null;if(!be)return q(`Payment details are still loading.`),null;let e=D?null:de();return D||e?{checkoutPayment:be,contact:e,retryOriginal:k===`retry`}:null}async function Se(e){e.preventDefault();let i=xe();if(!i)return;let{contact:a,checkoutPayment:o,retryOriginal:s}=i;V.current=!0,W.current=!1,K(`busy`),q(null);let c=!1,l=D;try{if(!l){let e=await fe(a);if(!(e&&H.current)){K(`ready`);return}if(!Y){c=!0,await pe(e);return}l=Object.freeze({auctionId:t.id,item:n,itemId:n.id,payment:Object.freeze({...o}),pricing:X,submission:Object.freeze({...e,clientRequestId:_e(),paymentMethodTypes:Object.freeze([`card`]),quantity:r.quantity})}),Q(l)}c=!0,await ye(l,!!D&&!s)}catch(e){await ge(e,c,l,D!==null&&!s)}finally{V.current=!1}}let Ce=ce(k,D!==null,Y),we=k!==`ready`;return L(ne,{buttonText:Ce,communityName:e.communityName??t.name,contactErrors:b,email:d,id:l,includeServiceFee:r.includeServiceFee,isPurchase:Y,isTerminal:B,item:n,locked:we,message:N,onBack:k===`ready`?o:void 0,onBillingChange:T,onEmailChange:t=>{p(t),e.onContactChange?.({email:t,phone:u(m,v)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>q(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{_(t),y(n),e.onContactChange?.({email:d,phone:u(t,n)})},onSameAsBillingChange:C,onShippingChange:ee,onSubmit:Se,phone:m,phoneCountry:v,pricing:X,quantity:r.quantity,sameAsBilling:S,serviceFeeCents:D?X.serviceFeeCents:Z(t,n,{...r,includeServiceFee:t.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:t.serviceFeeEnabled,showFields:!(D||B),submitDisabled:k===`busy`||!s||!c})}const Q=6e3;function ue(e,t){let n=P(Q),r=P(null),[i,a]=F(Q),o=N(()=>q({delay:i,playOnInit:!1,stopOnFocusIn:!1,stopOnInteraction:!0,stopOnMouseEnter:!1}),[i]),[s,c]=J({duration:t?0:25,loop:!0},[o]),l=A(()=>{r.current&&(r.current.style.transform=`scaleX(${1-n.current/Q})`)},[]),u=A(()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(1,Math.min(Q,e))),o.stop(),l()},[o,l]),d=A(()=>{n.current=Q,a(Q),o.reset(),l()},[o,l]);return j(()=>{c&&(e?i===n.current?o.play():a(n.current):u())},[c,e,o,i,a,n,u]),j(()=>{if(!c)return;let t=0,r=()=>{let i=o.timeUntilNext();!e||i===null||(n.current=Math.max(0,Math.min(Q,i)),l(),t=requestAnimationFrame(r))},i=()=>{cancelAnimationFrame(t),e&&(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 de({photos:e,name:t,selected:n,paused:r=!1,photoButtonRef:a,onSelect:o,onExpand:s}){let l=P(null),u=P(null),d=P([]),[f,p]=F(!0),[m,h]=F(!1),[g,_]=F(!1),[v,y]=F(!1),[b,x]=F(!1),{ref:w,visible:T}=i(),[D,O]=F(!1),[k,A]=F(!0),M=P(null),N=`lockerverse-auction-gallery__control ${k||D||g?`is-visible`:``}`,z=()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>O(!1),2e3)},B=e=>{if(e.pointerType!==`mouse`){A(!0);return}O(!0),M.current&&clearTimeout(M.current),e.target instanceof Element&&e.target.closest(`[data-gallery-control]`)||z()};j(()=>{let e=window.matchMedia(`(hover: none), (pointer: coarse)`),t=()=>A(e.matches);return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),clearTimeout(M.current??void 0)}},[]);let V=!(r||f||m||g||v||b)&&T,H=e.length,U=H?(n%H+H)%H:0,{viewportRef:W,embla:G,progressRef:te,freeze:K,reset:q}=ue(V&&H>1,f);j(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>p(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),j(()=>{if(!G)return;let e=()=>o(G.selectedScrollSnap());return G.on(`select`,e).on(`reInit`,e),()=>{G.off(`select`,e).off(`reInit`,e)}},[G,o]),j(()=>{G&&G.selectedScrollSnap()!==U&&G.scrollTo(U,!0)},[G,U]),j(()=>{let e=()=>{document.hidden&&K()},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)}},[K]);let J=e=>{G?.scrollTo((e+H)%H,f),q()};return j(()=>{let e=u.current;u.current=null,e&&document.activeElement===e&&w.current?.querySelector(`.lockerverse-auction-gallery__photo[tabindex="0"]`)?.focus({preventScroll:!0})},[U,w]),j(()=>{let e=l.current,t=d.current[U];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)},[U,H]),R(`section`,{"aria-label":`${t} photos`,className:`lockerverse-auction-gallery`,onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||_(!1)},onFocusCapture:e=>_(e.target.matches(`:focus-visible`)),onKeyDown:e=>{H<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),e.target instanceof HTMLButtonElement&&e.target.classList.contains(`lockerverse-auction-gallery__photo`)&&(u.current=e.target),J(U+(e.key===`ArrowRight`?1:-1)))},onPointerEnter:e=>{e.pointerType===`mouse`&&h(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&h(!1)},ref:w,children:[H?R(`div`,{className:`lockerverse-auction-gallery__stage`,onPointerEnter:B,onPointerLeave:z,onPointerMove:B,children:[L(`div`,{className:`lockerverse-auction-gallery__viewport`,onPointerDownCapture:()=>{K(),x(!0)},ref:W,children:L(`div`,{className:`lockerverse-auction-gallery__track`,children:e.map((e,n)=>L(`div`,{"aria-hidden":n!==U,className:`lockerverse-auction-gallery__slide`,children:L(`button`,{"aria-label":`View photo ${n+1} of ${t} at full size`,className:`lockerverse-auction-gallery__photo`,onClick:()=>{s(n)},ref:n===U?a:void 0,tabIndex:n===U?0:-1,type:`button`,children:L(c,{alt:`${t}, ${n+1} of ${H}`,className:`lockerverse-auction-gallery__image`,draggable:!1,height:900,loading:n===0||n===U||n===(U+1)%H?`eager`:`lazy`,maxWidth:1280,sizes:`(max-width: 1280px) 100vw, 45vw`,src:e,width:1200})})},`${e}-${n}`))})}),H>1&&!f&&R(`div`,{className:`lockerverse-auction-gallery__rotation`,children:[L(`div`,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__progress-track`,children:L(`div`,{className:`lockerverse-auction-gallery__progress`,ref:te,style:{transform:`scaleX(0)`}})}),L(`button`,{"aria-label":v?`Play photo rotation`:`Pause photo rotation`,className:`lockerverse-auction-gallery__play ${N}`,"data-gallery-control":!0,onClick:()=>y(e=>!e),title:v?`Play photo rotation`:`Pause photo rotation`,type:`button`,children:L(v?ee:E,{"aria-hidden":`true`,size:13})})]}),H>1&&R(I,{children:[L(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__previous ${N}`,"data-gallery-control":!0,onClick:()=>J(U-1),type:`button`,children:L(S,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})}),L(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__next ${N}`,"data-gallery-control":!0,onClick:()=>J(U+1),type:`button`,children:L(C,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})})]})]}):L(`div`,{className:`lockerverse-auction-gallery__empty`,children:`No photo available`}),H>1&&L(`section`,{"aria-label":`Choose a photo`,className:`lockerverse-auction-gallery__strip`,ref:l,children:L(`div`,{className:`lockerverse-auction-gallery__thumbnails`,children:e.map((e,t)=>L(`button`,{"aria-label":`Show photo ${t+1} of ${H}`,"aria-pressed":U===t,className:`lockerverse-auction-gallery__thumbnail ${U===t?`is-selected`:``}`,onClick:()=>J(t),ref:e=>{d.current[t]=e},type:`button`,children:L(c,{alt:``,className:`lockerverse-auction-gallery__thumbnail-image`,height:66,loading:`lazy`,maxWidth:192,sizes:`88px`,src:e,width:88})},`${e}-${t}`))})})]})}function fe({images:e,fallbackImage:t,name:n}){let r=[...new Set(e.filter(Boolean))];!r.length&&t&&r.push(t);let[i,a]=F(0),[o,s]=F(!1),l=P(null),u=P(null),d=r.length,f=d?(i%d+d)%d:0;return R(I,{children:[L(de,{name:n,onExpand:e=>{a(e),s(!0)},onSelect:a,paused:o,photoButtonRef:l,photos:r,selected:f}),d>0&&L(K.Root,{onOpenChange:s,open:o,children:R(K.Portal,{children:[L(K.Backdrop,{className:`lockerverse-auction-gallery__backdrop`}),R(K.Popup,{"aria-describedby":void 0,className:`lockerverse-auction-gallery__viewer`,finalFocus:l,onKeyDown:e=>{d<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),a((f+(e.key===`ArrowRight`?1:-1)+d)%d))},children:[R(K.Title,{className:`lockerverse-auction-gallery__sr-only`,children:[n,` · Photo `,f+1,` of `,d]}),R(`div`,{className:`lockerverse-auction-gallery__full-image`,onTouchCancel:()=>{u.current=null},onTouchEnd:e=>{let t=u.current;u.current=null;let n=e.changedTouches.item(0);if(!(t&&n)||d<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((f+(r<0?1:-1)+d)%d)},onTouchMove:e=>{e.touches.length!==1&&(u.current=null)},onTouchStart:e=>{let t=e.touches.item(0);u.current=e.touches.length===1&&t?{x:t.clientX,y:t.clientY}:null},children:[L(c,{alt:`${n}, ${f+1} of ${d}`,height:900,maxWidth:1920,sizes:`100vw`,src:r[f],width:1200}),o&&d>1&&L(c,{alt:``,"aria-hidden":`true`,className:`lockerverse-auction-gallery__preload`,height:900,loading:`eager`,maxWidth:1920,sizes:`100vw`,src:r[(f+1)%d],width:1200})]}),L(K.Close,{"aria-label":`Close photo viewer`,className:`lockerverse-auction-gallery__viewer-close`,children:L(k,{"aria-hidden":`true`,size:22})}),d>1&&R(I,{children:[L(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__viewer-previous`,onClick:()=>a((f-1+d)%d),type:`button`,children:L(S,{"aria-hidden":`true`,size:28})}),L(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__viewer-next`,onClick:()=>a((f+1)%d),type:`button`,children:L(C,{"aria-hidden":`true`,size:28})})]})]})]})})]})}function pe(e){return L(e===`Buy Now`?D:e===`Available`||e===`Increment`?O:T,{"aria-hidden":`true`,size:16})}function $(e,t){return e.saleMode===`buy_now`?[[`Buy Now`,n(e.buyNowPriceAmount??0)],[`Available`,e.availableQuantity===null?`Available`:String(e.availableQuantity)]]:t===`finished`?[[`Final bid`,e.maxBidAmount?n(e.maxBidAmount):`No bids`]]:[[`Current bid`,n(e.maxBidAmount??0)],[`Floor`,n(e.minBidAmount??0)],[`Increment`,n(e.bidIncrementAmount??100)]]}function me({auction:r,item:i}){s(i.startAt??r.startAt,i.endAt??r.endAt);let[o,c]=F(!1),l=M(),u=e(r,i),d={active:`Closes`,draft:`Opens`,finished:`Closed`}[u],f=a(r,u,i),p=i.saleMode===`buy_now`,m=(i.description??``).trim().length>240,h=$(i,u);return R(`section`,{className:`lockerverse-auctions__item-summary`,children:[L(fe,{fallbackImage:i.image??r.configuration.image??r.community?.banner??r.community?.thumbnail??null,images:i.images,name:i.name}),R(`div`,{className:`lockerverse-auctions__item-copy`,children:[L(`h2`,{children:i.name}),i.description?R(`div`,{className:`lockerverse-auctions__item-description`,children:[L(t,{className:!o&&m?`lockerverse-auctions__description-clamped`:void 0,description:i.description,id:l}),m?R(`button`,{"aria-controls":l,"aria-expanded":o,className:`lockerverse-auctions__description-toggle`,onClick:()=>c(!o),type:`button`,children:[o?`Hide description`:`Read full description`,` `,L(x,{"aria-hidden":`true`,size:16,style:{transform:o?`rotate(180deg)`:void 0}})]}):null]}):null,R(`dl`,{className:`lockerverse-auctions__stat-panel`,children:[h.map(([e,t])=>R(`div`,{className:`lockerverse-auctions__stat-row`,children:[R(`dt`,{children:[pe(e),e]}),L(`dd`,{children:t})]},e)),R(`div`,{className:`lockerverse-auctions__stat-row`,children:[R(`dt`,{children:[L(w,{"aria-hidden":`true`,size:16}),d]}),L(`dd`,{className:`lockerverse-auctions__stat-date`,children:f})]}),!p&&u===`finished`?R(`div`,{className:`lockerverse-auctions__stat-footer`,children:[R(`div`,{children:[L(`dt`,{children:`Floor`}),L(`dd`,{children:n(i.minBidAmount??0)})]}),R(`div`,{children:[L(`dt`,{children:`Bid increment`}),L(`dd`,{children:n(i.bidIncrementAmount??100)})]})]}):null]})]})]})}const he=/^\d+$/;function ge(e,t){return he.test(e)&&Number.isSafeInteger(Number(e)*t)?`Total: ${n(Number(e)*t)}`:`Enter a whole-number quantity.`}function _e(e,t,n){return String(e?t?t.quantity:1:t?t.amount/100:n)}function ve(e,t){return o(e)?`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 ye(e,t,n){return o(t)?`All available quantities have been purchased.`:n===`draft`?`This item opens ${a(e,`draft`,t)}.`:t.saleMode===`buy_now`?`This item is no longer available to purchase.`:`Bidding has closed for this item.`}function be(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 xe({auction:t,item:i,initialSelection:a,onContinue:c,onError:l,onBack:u,backHref:d}){let f=i.saleMode===`buy_now`,p=Math.ceil(V(i)/100),[m,h]=F(_e(f,a,p)),[g,_]=F(null),v=M();s(i.startAt??t.startAt,i.endAt??t.endAt);let y=e(t,i),x=y===`active`&&!o(i)&&i.saleMode!==`hybrid`;function S(e){if(e.preventDefault(),!he.test(m)){_(f?`Enter a whole-number quantity.`:`Enter a whole-dollar bid amount.`);return}let n=be(t,f,a,m),r=re(t,i,n);if(r){_(r),l(r);return}try{Z(t,i,n)}catch{_(`Enter a valid amount or quantity.`);return}c(n)}return x?R(`form`,{className:`lockerverse-auctions__selection`,onSubmit:S,children:[L(Se,{buyNow:f,item:i,minimum:p}),R(`div`,{className:`lockerverse-auctions__selection-body`,children:[R(`label`,{className:`lockerverse-auctions__field`,htmlFor:v,children:[f?`Quantity`:`Your bid amount`,R(`span`,{className:`lockerverse-auctions__amount-control`,children:[f?null:L(`span`,{"aria-hidden":`true`,children:`$`}),L(`input`,{"aria-describedby":`${v}-help`,"aria-invalid":!!g,autoComplete:`off`,id:v,inputMode:`numeric`,onChange:e=>{h(e.target.value),_(null)},placeholder:f?`1`:String(p),required:!0,value:m})]})]}),g?L(`p`,{role:`alert`,children:g}):null,L(`p`,{id:`${v}-help`,children:f?ge(m,i.buyNowPriceAmount??0):`Enter a whole-dollar bid of at least ${n(p*100)}. Bid increment: ${n(i.bidIncrementAmount??100)}.`}),R(`div`,{className:`lockerverse-auctions__selection-footer`,children:[L(`p`,{children:f?`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.`}),R(`button`,{className:`lockerverse-auctions__button`,disabled:!t.payment,type:`submit`,children:[f?`Continue to Checkout`:`Continue to Payment`,` `,L(b,{"aria-hidden":`true`,size:16})]})]}),t.payment?null:L(`p`,{role:`alert`,children:`Payments are not configured for this auction.`})]})]}):R(`div`,{className:`lockerverse-auctions__selection lockerverse-auctions__read-only`,children:[L(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Item status`}),L(`h3`,{children:ve(i,y)}),L(`p`,{children:ye(t,i,y)}),R(r,{className:`lockerverse-auctions__button`,href:d,onBack:u,children:[`Browse auction items `,L(b,{"aria-hidden":`true`,size:16})]})]})}function Se({item:e,buyNow:t,minimum:r}){return R(`div`,{className:`lockerverse-auctions__selection-header`,children:[L(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Step 1 of 2`}),L(`h3`,{children:t?`Buy this item now.`:`Place your bid.`}),L(`p`,{children:t?`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.`}),R(`p`,{children:[t?`Price: `:`Minimum qualifying bid: `,L(`strong`,{children:n(t?e.buyNowPriceAmount??0:r*100)})]}),t&&e.availableQuantity!==null?R(`p`,{children:[e.availableQuantity,` available`]}):null,e.collectShippingAddress?L(`p`,{children:`The next step will also collect a delivery address for seller fulfillment.`}):null]})}function Ce(e){let{auction:t,item:n,selection:r,theme:i=`dark`,stripeLoader:a=v,style:o,onBack:s,resumePurchase:c}=e,[l,u]=F(null),[d,f]=F(!1),[p,m]=F(0),h=_(e.appearanceRoot,i,o,e.interactionLocked),g=c?.payment??t.payment;if(j(()=>{let e=!0;if(!g){f(!0);return}return Promise.resolve().then(()=>a(g.publishableKey,g.connectedAccountId?{stripeAccount:g.connectedAccountId}:void 0)).then(t=>{e&&(u(t),f(!t))},()=>{e&&f(!0)}),()=>{e=!1}},[g,a,p]),d)return R(`div`,{children:[L(`p`,{role:`alert`,children:`Payment details could not load.`}),c?null:L(`button`,{onClick:s,type:`button`,children:`Back to item`}),L(`button`,{onClick:()=>{f(!1),u(null),m(e=>e+1)},type:`button`,children:`Try again`})]});if(!(l&&h))return R(`div`,{children:[L(`p`,{role:`status`,children:`Loading secure payment details…`}),c?null:L(`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:Z(t,n,r).totalCents,currency:`usd`,mode:`payment`});let b={...y,appearance:h,currency:`usd`,paymentMethodTypes:[`card`],syncAddressCheckbox:`none`};return L(U,{options:b,stripe:l,children:L(le,{...e})})}function we({buyNow:e}){return R(`div`,{className:`lockerverse-auctions__progress`,children:[R(`span`,{children:[L(e?D:T,{"aria-hidden":`true`,size:16}),e?`Choose quantity`:`Place bid`]}),R(`span`,{children:[L(D,{"aria-hidden":`true`,size:16}),e?`Pay securely`:`Secure card`]}),R(`span`,{children:[L(O,{"aria-hidden":`true`,size:16}),e?`Get confirmation`:`Wait for close`]})]})}function Te(e){let{auction:t,item:n,outcome:r}=e,i;return e.backHref?i={href:e.backHref,label:`View auction items`}:e.onBack&&(i={label:`View auction items`,onClick:e.onBack}),L(y,{auctionName:t.name,className:e.className,closesAtLabel:a(t,`active`,n),communityName:e.communityName??t.community?.name,focusHeading:!0,imageUrl:n.image??n.images[0]??t.configuration.image??void 0,itemName:n.name,outcome:r,primaryAction:e.returnToItemHref?{href:e.returnToItemHref,label:`Return to item`}:i,secondaryAction:e.returnToItemHref?i:void 0,style:{"--lockerverse-accent":t.community?.color??`#6f8f6d`,...e.style},theme:e.theme})}function Ee(t){let{auction:n,itemId:i,resumePurchase:a,className:o,theme:c=`dark`,style:l}=t,u=P(null),[d,f]=F(n),p=P(n),m=d.items.find(e=>e.id===i)??a?.item;s(m?.startAt??d.startAt,m?.endAt??d.endAt);let[g,_]=F(()=>a?{amount:0,includeServiceFee:a.submission.includeServiceFee??!1,quantity:a.submission.quantity}:null),[v,y]=F(!!a),x=P(!0),C=P(t);C.current=t;let w=P(null),T=A(e=>{x.current&&y(e),w.current!==e&&(w.current=e,h(C.current.onInteractionLockChange,e))},[]),E=!!a;j(()=>(x.current=!0,T(E),()=>{x.current=!1}),[E,T]);let[ee,D]=F({email:``,phone:``}),[O,k]=F(!!a),[M,N]=F(null),[I,z]=F(null);j(()=>{!(O||v||a)&&p.current!==n&&(p.current=n,f(n))},[n,O,v,a]);function B(e,t){T(!1),p.current=C.current.auction,f(e),_(null),k(!1),N(t)}function V(e){N(null),_(e),k(!0)}return m?I?L(Te,{...t,auction:d,item:m,outcome:I}):R(`section`,{className:[`lockerverse-auctions`,o].filter(Boolean).join(` `),"data-lockerverse-theme":c,ref:u,style:{"--lockerverse-accent":d.community?.color??`#6f8f6d`,...l},children:[v?null:R(r,{className:`lockerverse-auctions__back`,href:t.backHref,onBack:t.onBack,children:[L(S,{"aria-hidden":`true`,size:16}),` All items`]}),R(`div`,{className:`lockerverse-auctions__detail`,children:[L(me,{auction:d,item:m}),R(`div`,{className:`lockerverse-auctions__transaction`,children:[e(d,m)===`active`?L(we,{buyNow:m.saleMode===`buy_now`}):null,M?L(`p`,{className:`lockerverse-auctions__notice`,role:`alert`,children:M}):null,O&&g?L(Ce,{...t,appearanceRoot:u,auction:d,communityName:t.communityName??d.community?.name,contact:ee,interactionLocked:v,item:m,onBack:()=>k(!1),onContactChange:D,onIncludeServiceFeeChange:e=>_(t=>t&&{...t,includeServiceFee:d.serviceFeeEnabled&&e}),onInteractionLockChange:T,onResult:z,onReview:B,selection:g}):L(xe,{auction:d,backHref:t.backHref,initialSelection:g,item:m,onBack:t.onBack,onContinue:V,onError:N}),v?null:R(r,{className:`lockerverse-auctions__footer-back`,href:t.backHref,onBack:t.onBack,children:[`Back to auction items `,L(b,{"aria-hidden":`true`,size:16})]})]})]})]}):R(`div`,{children:[L(`p`,{role:`alert`,children:`This auction item is no longer available.`}),L(r,{href:t.backHref,onBack:t.onBack,children:`Back to auction items`})]})}function De(e){let t=P({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.`);return L(Ee,{...e})}export{De as LockerverseAuctionItem};
2
2
  //# sourceMappingURL=auction-item.js.map