@lockerverse/react 0.2.153 → 0.2.155
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 +74 -0
- package/dist/auction-item.js +1 -1
- package/dist/auction-item.js.map +1 -1
- package/dist/custom-fields.d.ts +31 -0
- package/dist/custom-fields.d.ts.map +1 -0
- package/dist/custom-fields.js +2 -0
- package/dist/custom-fields.js.map +1 -0
- package/dist/form-skeleton.js +1 -1
- package/dist/form-skeleton.js.map +1 -1
- package/dist/host-callback.js +1 -1
- package/dist/host-callback.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/lockerverse-payment.js +1 -1
- package/dist/lockerverse-payment.js.map +1 -1
- package/dist/payment-form.d.ts +2 -2
- package/dist/payment-form.d.ts.map +1 -1
- package/dist/payment-primitives.d.ts +113 -0
- package/dist/payment-primitives.d.ts.map +1 -0
- package/dist/payment-primitives.js +1 -0
- package/dist/payment-summary.js +2 -0
- package/dist/payment-summary.js.map +1 -0
- package/dist/payment.d.ts +2 -1
- package/dist/phone-field.js +2 -0
- package/dist/phone-field.js.map +1 -0
- package/dist/signup.js +1 -1
- package/dist/signup.js.map +1 -1
- package/dist/stripe-loader.js +1 -1
- package/dist/stripe-loader.js.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -2
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ modules or copy API details from a different SDK version.
|
|
|
13
13
|
- [Configuration and environment](#configuration-and-environment)
|
|
14
14
|
- [Server rendering](#server-rendering) and [resource identity](#resource-identity)
|
|
15
15
|
- [Custom product UI](#custom-product-ui) and [live availability](#live-product-availability)
|
|
16
|
+
- [Payment primitives](#payment-primitives) for custom Core SDK checkout
|
|
16
17
|
- [Donate launcher](#donate-launcher)
|
|
17
18
|
- [Signup](#signup)
|
|
18
19
|
- [Styling](#styling)
|
|
@@ -749,3 +750,76 @@ return <LockerversePublicEvents events={events} />;
|
|
|
749
750
|
For server rendering, obtain `initialPage` with the SDK client's `search()`
|
|
750
751
|
and the same date, scope, sort, and page size. Without this configuration,
|
|
751
752
|
`initialEvents` from `list()` keeps the original Upcoming and Past views.
|
|
753
|
+
|
|
754
|
+
## Prefill checkout custom fields
|
|
755
|
+
|
|
756
|
+
`LockerversePayment` and `LockerverseDonateLauncher` accept
|
|
757
|
+
`initialCustomFieldValues`, keyed by configured field ID:
|
|
758
|
+
|
|
759
|
+
```tsx
|
|
760
|
+
<LockerversePayment
|
|
761
|
+
widget={widget}
|
|
762
|
+
selection={selection}
|
|
763
|
+
initialCustomFieldValues={{ field_muw2q7vx_sf7r94: "Autographed basketball" }}
|
|
764
|
+
/>
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
Values are read once when the checkout form starts. Buyers can edit them;
|
|
768
|
+
price updates and parent renders do not overwrite edits. A new component `key`
|
|
769
|
+
starts a new form and resets all its inputs. Text uses strings, checkboxes use
|
|
770
|
+
booleans, and choice fields use option IDs (arrays for multiple choices).
|
|
771
|
+
Unknown fields, invalid types, and unknown options are ignored. Only custom
|
|
772
|
+
fields for the selected products are included. Required-field and server
|
|
773
|
+
validation still apply. For controlled updates, use the primitives below.
|
|
774
|
+
|
|
775
|
+
## Payment primitives
|
|
776
|
+
|
|
777
|
+
For a custom Core SDK checkout, import the same controlled fields and summary
|
|
778
|
+
used by `LockerversePayment`:
|
|
779
|
+
|
|
780
|
+
```tsx
|
|
781
|
+
import {
|
|
782
|
+
CustomField, CustomFields, EmailField, TextField, FormField, FieldError,
|
|
783
|
+
Checkbox, PhoneInput, PaymentSummary,
|
|
784
|
+
createCustomFieldValues, reconcileCustomFieldValues,
|
|
785
|
+
getCheckoutCustomFields, validateCustomFields, buildCustomFieldAnswers,
|
|
786
|
+
getInternationalPhone,
|
|
787
|
+
type CustomFieldValues,
|
|
788
|
+
} from "@lockerverse/react/payment-primitives";
|
|
789
|
+
import "@lockerverse/react/payment.css";
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
Each component also exports a named `...Props` type. The entry has no Stripe
|
|
793
|
+
or ready-made payment-controller dependency. Components are controlled: your
|
|
794
|
+
website owns the values and can mix its own inputs with the shared components.
|
|
795
|
+
|
|
796
|
+
```tsx
|
|
797
|
+
const fields = getCheckoutCustomFields(catalog, checkout.items);
|
|
798
|
+
const [values, setValues] = useState<CustomFieldValues>(() =>
|
|
799
|
+
createCustomFieldValues(fields, { [itemNameFieldId]: "Autographed basketball" })
|
|
800
|
+
);
|
|
801
|
+
|
|
802
|
+
<CustomFields fields={fields} values={values} onChange={setValues} />
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
Use real catalog field IDs. Text values are strings, checkbox values are
|
|
806
|
+
booleans, and choice values are option IDs (arrays for multiple choices).
|
|
807
|
+
Use `CustomField` with `field`, `value`, `onChange`, and optional `error` to
|
|
808
|
+
place individual fields in your own layout. Reconcile values with
|
|
809
|
+
`reconcileCustomFieldValues` when selected products or definitions change.
|
|
810
|
+
Before submission, pass the output of `validateCustomFields` to `errors` and
|
|
811
|
+
focus the first invalid field. Build the payload with
|
|
812
|
+
`buildCustomFieldAnswers(fields, values)` and supply it as
|
|
813
|
+
`submission.customFieldAnswers` to Core SDK `client.submitPayment()`.
|
|
814
|
+
|
|
815
|
+
The host still owns authoritative quotes, final-total display, Stripe Elements
|
|
816
|
+
validation and confirmation, required contact/shipping details, authentication,
|
|
817
|
+
and payment recovery. Do not show success until payment completion is confirmed.
|
|
818
|
+
See the Core SDK README for that contract.
|
|
819
|
+
|
|
820
|
+
Use `lockerverse-payment` with `data-lockerverse-theme="light"` or `"dark"`
|
|
821
|
+
on a wrapper for the existing appearance. Omit the stylesheet to supply your
|
|
822
|
+
own design. Use `<PaymentSummary quote={checkout} />` for a current quote.
|
|
823
|
+
Optional `displayedBaseCents`, `displayedTipCents`, and `displayedTotalCents`
|
|
824
|
+
overrides support pending price changes. They default to the quoted total minus
|
|
825
|
+
tip, tip, and total. These display properties never change the payable amount.
|
package/dist/auction-item.js
CHANGED
|
@@ -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,f as l,i as u,m as d,n as f,r as p,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(l,{error:e.contactErrors.email,id:`${a}-email`,label:`Email`,name:`email`,onChange:t=>e.onEmailChange(t.target.value),required:!0,value:e.email}),I(d,{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(c,{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(c,{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(),l=j(),[d,f]=P(e.contact?.email??``),[g,_]=P(e.contact?.phone??``),[v,y]=P(()=>u(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=p(g,v),t=h({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 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:d,id:l,includeServiceFee:r.includeServiceFee,isPurchase:Y,isTerminal:B,item:n,locked:we,message:F,onBack:k===`ready`?o:void 0,onBillingChange:T,onEmailChange:t=>{f(t),e.onContactChange?.({email:t,phone:p(g,v)})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>q(`Unable to load payment form.`),onPhoneChange:({value:t,country:n})=>{_(t),y(n),e.onContactChange?.({email:d,phone:p(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,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};
|
|
2
2
|
//# sourceMappingURL=auction-item.js.map
|