@lockerverse/react 0.2.101 → 0.2.102
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 +55 -18
- package/dist/auction-base.css +116 -0
- package/dist/auction-catalog.css +7 -0
- package/dist/auction-data.d.ts +16 -0
- package/dist/auction-data.d.ts.map +1 -0
- package/dist/auction-data.js +2 -0
- package/dist/auction-data.js.map +1 -0
- package/dist/auction-item-layout.css +298 -0
- package/dist/auction-item.css +4 -0
- package/dist/auction-item.d.ts +3 -0
- package/dist/auction-item.d.ts.map +1 -1
- package/dist/auction-item.js +1 -1
- package/dist/auction-item.js.map +1 -1
- package/dist/auction.css +2 -0
- package/dist/auction.d.ts +3 -0
- package/dist/auction.js +1 -0
- package/dist/auctions.css +2 -406
- package/dist/auctions.d.ts +6 -19
- package/dist/auctions.d.ts.map +1 -1
- package/dist/auctions.js +1 -1
- package/dist/auctions.js.map +1 -1
- package/dist/immutable-resource-identity.js.map +1 -1
- package/dist/lockerverse-auction-item-card.d.ts +47 -0
- package/dist/lockerverse-auction-item-card.d.ts.map +1 -0
- package/dist/lockerverse-auction.js +2 -0
- package/dist/lockerverse-auction.js.map +1 -0
- package/dist/lockerverse-payment.js +1 -1
- package/dist/lockerverse-payment.js.map +1 -1
- package/dist/phone.js +1 -1
- package/dist/signup.js +1 -1
- package/dist/signup.js.map +1 -1
- package/dist/use-auction-boundary.js +2 -0
- package/dist/use-auction-boundary.js.map +1 -0
- package/dist/use-lockerverse-auctions.d.ts +13 -0
- package/dist/use-lockerverse-auctions.d.ts.map +1 -0
- package/dist/use-lockerverse-auctions.js +2 -0
- package/dist/use-lockerverse-auctions.js.map +1 -0
- package/package.json +26 -3
- package/dist/auction-description.js +0 -2
- package/dist/auction-description.js.map +0 -1
package/dist/auction-item.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i,t as a}from"./auction-description.js";import{c as o,s,t as c}from"./host-callback.js";import{AddressElement as l,Elements as u,PaymentElement as d,useElements as f,useStripe as p}from"@stripe/react-stripe-js";import{loadStripe as m}from"@stripe/stripe-js/pure/index.js";import{useCallback as h,useEffect as g,useId as _,useMemo as v,useRef as y,useState as b}from"react";import{LockerverseSdkError as x,calculateLockerverseAuctionPricing as S,getLockerverseAuctionMinimumBid as C}from"@lockerverse/sdk/auctions";import{safeParse as w}from"valibot";import{AsYouType as T,getCountries as E,getCountryCallingCode as D,parsePhoneNumberFromString as O}from"libphonenumber-js/max";import{Fragment as k,jsx as A,jsxs as j}from"react/jsx-runtime";import{Dialog as M}from"@base-ui/react/dialog";import N from"embla-carousel-autoplay";import P from"embla-carousel-react";const F=/^00/,I=new Intl.DisplayNames([`en`],{type:`region`}),L=E().map(e=>({country:e,label:I.of(e)??e})).sort((e,t)=>e.label.localeCompare(t.label,`en`));function R(e,t){let n=e.normalize(`NFKC`).trim().replace(F,`+`),r=n.startsWith(`+`)?void 0:O(n,{defaultCountry:t,extract:!1});if(r?.isValid()&&!r.ext)return r;let i=O(n,{extract:!1})??O(`+${n}`,{extract:!1});return i?.isValid()&&!i.ext?i:null}function z(e){return String.fromCodePoint(...Array.from(e,e=>127397+e.charCodeAt(0)))}function B({id:e,value:t,onChange:n}){let r=O(t),[i,a]=b(r?.country??`US`),[o,s]=b(r?.formatNational()??t),c=y(null),l=y(t);g(()=>{if(t===l.current)return;let e=O(t);l.current=t,a(e?.country??`US`),s((e?e.formatNational():null)??t)},[t]),g(()=>{c.current?.setCustomValidity(o&&!R(o,i)?`Enter a valid phone number.`:``)},[i,o]);function u(e,t,r=!1){let i=e.normalize(`NFKC`).trim().replace(F,`+`),o=R(e,t),c=i.startsWith(`+`)?o?.country??t:t,u=(o?o.formatNational():null)??new T(c).input(i);a(c),s(r?e:u),l.current=o?o.number:``,n(l.current)}return j(`div`,{className:`lockerverse-auctions__phone`,dir:`ltr`,children:[j(`div`,{className:`lockerverse-auctions__phone-country`,children:[j(`span`,{"aria-hidden":`true`,children:[A(`span`,{className:`lockerverse-auctions__phone-flag`,children:z(i)}),` `,`+`,D(i),` `,A(`span`,{children:`⌄`})]}),A(`select`,{"aria-label":`Phone number country`,onChange:e=>{let t=L.find(t=>t.country===e.target.value);t&&u(o,t.country)},value:i,children:L.map(e=>j(`option`,{value:e.country,children:[e.label,` +`,D(e.country)]},e.country))})]}),A(`input`,{autoComplete:`tel-national`,id:e,onChange:e=>u(e.target.value,i,e.target.value.length<o.length),onPaste:e=>{let t=R(e.clipboardData.getData(`text`),i);t&&(e.preventDefault(),u(t.number,t.country??i))},placeholder:`(201) 555-0123`,ref:c,required:!0,type:`tel`,value:o})]})}function V(e){return{business:{name:`Lockerverse`},fields:{billingDetails:{address:`never`,email:`never`,name:`never`,phone:`never`}},terms:{applePay:e?`auto`:`never`,auBecsDebit:`never`,bancontact:`never`,card:`always`,cashapp:`never`,googlePay:`never`,ideal:`never`,paypal:e?`auto`:`never`,sepaDebit:`never`,sofort:`never`,usBankAccount:`never`},wallets:{applePay:e?`auto`:`never`,googlePay:`never`}}}function ee(t){let{isPurchase:n,item:r,pricing:i,id:a}=t;return j(`form`,{className:`lockerverse-auctions__checkout`,onSubmit:t.onSubmit,children:[j(`div`,{className:`lockerverse-auctions__checkout-header`,children:[j(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[A(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!t.onBack,onClick:t.onBack,type:`button`,children:`‹`}),j(`div`,{children:[A(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),A(`p`,{children:n?`Secure checkout`:`Secure payment method`})]})]}),A(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:t.communityName}),A(`h2`,{children:n?`Finalize your purchase.`:`Finalize your bid authorization.`}),A(`p`,{className:`lockerverse-auctions__checkout-summary`,children:n?j(k,{children:[`Pay `,A(`strong`,{children:e(i.totalCents)}),` for`,` `,t.quantity,` `,t.quantity===1?`item`:`items`,` of`,` `,A(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):j(k,{children:[`Authorize a payment method for your bid of`,` `,A(`strong`,{children:e(i.subtotalCents)}),` on`,` `,A(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),r.collectShippingAddress&&j(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[A(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),A(`p`,{children:`This item requires a delivery address. Billing details are used by default, and you can switch to a separate delivery address below if needed.`})]})]}),j(`div`,{className:`lockerverse-auctions__checkout-body`,children:[t.showFields&&j(`fieldset`,{disabled:t.locked,children:[j(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[j(`label`,{className:`lockerverse-auctions__field`,htmlFor:`${a}-email`,children:[`Email`,A(`input`,{autoComplete:`email`,id:`${a}-email`,onChange:e=>t.onEmailChange(e.target.value),placeholder:`example@domain.com`,required:!0,type:`email`,value:t.email})]}),j(`label`,{className:`lockerverse-auctions__field`,htmlFor:`${a}-phone`,children:[`Phone Number`,A(B,{id:`${a}-phone`,onChange:t.onPhoneChange,value:t.phone})]})]}),j(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[j(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[A(`h3`,{children:`Payment Information`}),A(`p`,{children:n?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),A(d,{onLoadError:t.onPaymentLoadError,options:V(n)})]}),j(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[A(`h3`,{children:`Billing Details`}),A(l,{onChange:t.onBillingChange,options:{mode:`billing`}}),A(`p`,{children:n?`Use your full name here. We use the email and phone above for purchase confirmation and fulfillment updates.`:`Use the bidder's full name here. We use the email and phone above to contact you if this bid is outbid or wins.`})]}),r.collectShippingAddress&&j(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[j(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,children:[A(`input`,{checked:t.sameAsBilling,onChange:e=>t.onSameAsBillingChange(e.target.checked),type:`checkbox`}),j(`span`,{children:[A(`strong`,{children:`Delivery address is the same as billing`}),A(`span`,{children:`Leave this on for the fastest flow. Turn it off only if the delivery address should differ from the billing details above.`})]})]}),!t.sameAsBilling&&j(k,{children:[A(`h3`,{children:`Delivery Address`}),A(l,{onChange:t.onShippingChange,options:{mode:`shipping`}})]})]}),t.serviceFeeEnabled&&A(H,{...t})]}),t.message&&A(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:t.message}),!t.isTerminal&&j(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[j(`p`,{children:[n?`By continuing, you agree to be charged for this purchase.`:`By continuing, you agree to have this payment method stored for item settlement if your bid is the winning offer.`,r.collectShippingAddress?` Your delivery details are stored with the ${n?`order`:`bid`} so the seller can fulfill the item after payment.`:``]}),j(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:t.submitDisabled,type:`submit`,children:[t.buttonText,A(`span`,{"aria-hidden":`true`,children:` →`})]})]})]})]})}function H(t){let{isPurchase:n,pricing:r}=t;return A(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:t.onIncludeServiceFeeChange?j(`label`,{className:`lockerverse-auctions__checkout-checkbox`,children:[A(`input`,{checked:t.includeServiceFee,onChange:e=>t.onIncludeServiceFeeChange?.(e.target.checked),type:`checkbox`}),j(`span`,{children:[j(`strong`,{children:[n?`Add`:`If I win, add`,` `,e(t.serviceFeeCents),` to help cover processing fees`]}),j(`span`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})]})]}):j(`p`,{children:[n?`Total`:`Total if I win`,`:`,` `,e(r.totalCents)]})})}function U(e,t,n){return S(e,t.saleMode===`buy_now`?(t.buyNowPriceAmount??0)*n.quantity:n.amount,n.includeServiceFee)}function W(e,t,n){if(e.status!==`active`||t.status!==`active`||Date.parse(e.endAt)<=Date.now())return`This item is not accepting bids or purchases.`;if(t.saleMode===`hybrid`)return`This item type is not supported for checkout.`;if(t.saleMode===`buy_now`){if(t.isSoldOut||t.availableQuantity===0)return`This item is sold out.`;if(!(t.buyNowPriceAmount&&Number.isSafeInteger(n.quantity))||n.quantity<1||t.availableQuantity!==null&&n.quantity>t.availableQuantity)return`Select an available quantity.`}else if(!Number.isSafeInteger(n.amount)||n.amount%100!=0||n.amount<C(t))return`Enter a whole-dollar bid at or above the minimum bid.`;return null}function te(e,t,n,r,i){return e.payment?.publishableKey!==t.payment?.publishableKey||e.payment?.connectedAccountId!==t.payment?.connectedAccountId||e.serviceFeeEnabled!==t.serviceFeeEnabled||n.saleMode!==r.saleMode||n.collectShippingAddress!==r.collectShippingAddress||JSON.stringify(U(e,n,i))!==JSON.stringify(U(t,r,i))}function ne(e){return{expectedServiceFeeCents:e.serviceFeeCents,expectedSubtotalCents:e.subtotalCents,expectedTotalCents:e.totalCents}}async function re({stripe:e,elements:t,email:n,phone:r,billing:i,shipping:a,collectShippingAddress:o}){if(!(i?.complete&&i.value.name.trim()))throw Error(`Complete your billing name and address.`);if(o&&!(a?.complete&&a.value.name.trim()))throw Error(`Complete your shipping name and address.`);let s=await t.submit();if(s.error)throw Error(s.error.message??`Check your payment details.`);let c=await e.createConfirmationToken({elements:t,params:{payment_method_data:{allow_redisplay:`always`,billing_details:{address:i.value.address,email:n,name:i.value.name,phone:r}},return_url:window.location.href,...o&&a?{shipping:{address:a.value.address,name:a.value.name,phone:r}}:void 0}});if(c.error||!c.confirmationToken)throw Error(c.error?.message??`Unable to prepare payment details.`);return c.confirmationToken.id}async function ie(e,t){if(!t.requiresAction)return;if(!t.clientSecret)throw Error(`Payment confirmation is incomplete. Check its status before trying again.`);let n=await e.handleNextAction({clientSecret:t.clientSecret});if(n.error)throw Error(n.error.message??`Payment confirmation is incomplete.`)}function ae(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function G(e){let{auction:t,item:n,selection:r,client:i,onReview:a,onBack:l}=e,u=p(),d=f(),m=_(),[h,v]=b(e.contact?.email??``),[S,C]=b(e.contact?.phone??``),[T,E]=b(!0),[D,O]=b(null),[k,j]=b(null),[M,N]=b(e.resumePurchase??null),[P,F]=b(e.resumePurchase?`pending`:`ready`),[I,L]=b(null),R=y(e.resumePurchase?.submission.clientRequestId??null),z=P===`complete`||P===`uncertain`,B=P!==`ready`&&P!==`complete`,{onInteractionLockChange:V}=e;g(()=>{V?.(B)},[B,V]);let H=y(!1),G=y(!0),K=y(e);K.current=e,g(()=>(G.current=!0,()=>{G.current=!1}),[]);let q=!!(M??e.resumePurchase)||n.saleMode===`buy_now`,J=M?.pricing??e.resumePurchase?.pricing??U(t,n,r),oe=M?.payment??e.resumePurchase?.payment??t.payment;function Y(e){G.current&&N(e),c(K.current.onPurchaseRecoveryChange,e)}function X(e){G.current&&(e.status===`paid`?(R.current=null,Y(null),F(`complete`),L(`Purchase complete. Receipt: ${e.purchaseId}`),c(K.current.onPurchaseComplete,e)):e.status===`pending_payment`?(F(`pending`),L(`Your purchase is pending. Check its status before making another payment.`)):(R.current=null,Y(null),F(`ready`),L(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`)))}async function Z(){if(!(u&&d&&t.payment))throw Error(`Payment details are still loading.`);let e=w(s,h),c=w(o,S);if(!(e.success&&c.success))throw Error(`Enter a valid email and phone number with its country code.`);let l=await i.load(t.slug);if(!G.current)return null;let f=l.items.find(e=>e.id===n.id);if(!f)return a(l,`This item is no longer available.`),null;let p=W(l,f,r);if(p||te(t,l,n,f,r))return a(l,p??`The checkout details changed. Review them before continuing.`),null;let m=await re({billing:D,collectShippingAddress:n.collectShippingAddress,elements:d,email:e.output,phone:c.output,shipping:T?D:k,stripe:u});return G.current?{confirmationToken:m,email:e.output,includeServiceFee:r.includeServiceFee,phone:c.output,...ne(J)}:null}async function se(e){let a=await i.createBid(t.slug,n.id,{...e,amount:r.amount});G.current&&u&&(await ie(u,a),G.current&&(F(`complete`),L(`Bid submitted. Watch your email for bid and auction updates.`),c(K.current.onBidSubmitted,a)))}async function Q(e,r){if(G.current&&u){if(e.requiresAction){if(await ie(u,e),!G.current)return;let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);a?X(a):(F(`pending`),L(`Payment status is not available yet. Check again shortly.`));return}X(e)}}async function ce(e){let r=await i.getPurchaseStatus(t.slug,n.id,e.submission.clientRequestId);G.current&&(r?await Q(r,e):(F(`retry`),L(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)))}async function le(e,r){let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);if(G.current){if(a){await Q(a,r);return}Y(null),F(`ready`),L(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}}async function ue(e,t,n,r){if(!G.current)return;let i=t&&(!(e instanceof x)||e.recoveryRecommended);if(L(e instanceof Error?e.message:`Unable to complete this request.`),q&&n){if(!r&&e instanceof x&&!e.recoveryRecommended)try{await le(e,n);return}catch{}F(`pending`),L(`We could not confirm the purchase result. Check its status using the same purchase request.`),c(K.current.onUncertain,`purchase`)}else i?(F(`uncertain`),L(`We could not confirm your bid. Do not submit another bid until you check your email or contact the auction organizer.`),c(K.current.onUncertain,`bid`)):F(`ready`)}function de(){return R.current??=globalThis.crypto.randomUUID(),R.current}let $=u&&d&&oe;async function fe(e){if(e.preventDefault(),H.current||z)return;if(!$){L(`Payment details are still loading.`);return}let a=P===`retry`;H.current=!0,F(`busy`),L(null);let o=!1,s=M;try{if(!s){let e=await Z();if(!e)return;if(!q){o=!0,await se(e);return}s=Object.freeze({auctionId:t.id,item:n,itemId:n.id,payment:Object.freeze({...$}),pricing:J,submission:Object.freeze({...e,clientRequestId:de(),paymentMethodTypes:Object.freeze([`card`]),quantity:r.quantity})}),Y(s)}if(M&&!a){await ce(s);return}o=!0,await Q(await i.createPurchase(t.slug,n.id,s.submission),s)}catch(e){await ue(e,o,s,M!==null&&!a)}finally{H.current=!1}}let pe=ae(P,M!==null,q),me=P!==`ready`;return A(ee,{buttonText:pe,communityName:e.communityName??t.name,email:h,id:m,includeServiceFee:r.includeServiceFee,isPurchase:q,isTerminal:z,item:n,locked:me,message:I,onBack:P===`ready`?l:void 0,onBillingChange:O,onEmailChange:t=>{v(t),e.onContactChange?.({email:t,phone:S})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>L(`Unable to load payment form.`),onPhoneChange:t=>{C(t),e.onContactChange?.({email:h,phone:t})},onSameAsBillingChange:E,onShippingChange:j,onSubmit:fe,phone:S,pricing:J,quantity:r.quantity,sameAsBilling:T,serviceFeeCents:M?J.serviceFeeCents:U(t,n,{...r,includeServiceFee:t.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:t.serviceFeeEnabled,showFields:!(M||z),submitDisabled:P===`busy`||!u||!d})}function K({size:e=24,children:t,...n}){return A(`svg`,{"aria-hidden":`true`,fill:`none`,height:e,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 24 24`,width:e,...n,children:t})}function q(e){return A(K,{...e,children:A(`path`,{d:`m15 18-6-6 6-6`})})}function J(e){return A(K,{...e,children:A(`path`,{d:`m9 18 6-6-6-6`})})}function oe(e){return j(K,{...e,children:[A(`rect`,{height:`16`,rx:`1`,width:`4`,x:`6`,y:`4`}),A(`rect`,{height:`16`,rx:`1`,width:`4`,x:`14`,y:`4`})]})}function Y(e){return A(K,{...e,children:A(`path`,{d:`m6 3 14 9-14 9V3Z`})})}function X(e){return A(K,{...e,children:A(`path`,{d:`m18 6-12 12M6 6l12 12`})})}const Z=6e3;function se(e,t){let n=y(Z),r=y(null),[i,a]=b(Z),o=v(()=>N({delay:i,playOnInit:!1,stopOnFocusIn:!1,stopOnInteraction:!0,stopOnMouseEnter:!1}),[i]),[s,c]=P({duration:t?0:25,loop:!0},[o]),l=h(()=>{r.current&&(r.current.style.transform=`scaleX(${1-n.current/Z})`)},[]),u=h(()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(1,Math.min(Z,e))),o.stop(),l()},[o,l]),d=h(()=>{n.current=Z,a(Z),o.reset(),l()},[o,l]);return g(()=>{c&&(e?i===n.current?o.play():a(n.current):u())},[c,e,o,i,a,n,u]),g(()=>{if(!c)return;let t=0,r=()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(0,Math.min(Z,e)),l(),t=requestAnimationFrame(r))},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)},a=()=>cancelAnimationFrame(t),s=()=>{e&&o.play()};return c.on(`select`,d).on(`reInit`,s).on(`autoplay:timerset`,i).on(`autoplay:timerstopped`,a),l(),i(),()=>{a(),c.off(`select`,d).off(`reInit`,s).off(`autoplay:timerset`,i).off(`autoplay:timerstopped`,a)}},[c,o,e,n,d,l]),{embla:c,freeze:u,progressRef:r,reset:d,viewportRef:s}}function Q({photos:e,name:t,selected:n,paused:r=!1,photoButtonRef:i,onSelect:a,onExpand:o}){let s=y(null),c=y([]),[l,u]=b(!0),[d,f]=b(!1),[p,m]=b(!1),[h,_]=b(!1),[v,x]=b(!1),[S,C]=b(!1),[w,T]=b(!1),[E,D]=b(!0),O=y(null),M=`lockerverse-auction-gallery__control ${E||w||p?`is-visible`:``}`,N=()=>{O.current&&clearTimeout(O.current),O.current=setTimeout(()=>T(!1),2e3)},P=e=>{if(e.pointerType!==`mouse`){D(!0);return}T(!0),O.current&&clearTimeout(O.current),e.target instanceof Element&&e.target.closest(`[data-gallery-control]`)||N()};g(()=>{let e=window.matchMedia(`(hover: none), (pointer: coarse)`),t=()=>D(e.matches);return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),clearTimeout(O.current??void 0)}},[]);let F=!(r||l||d||p||h||v)&&S,I=e.length,L=I?(n%I+I)%I:0,{viewportRef:R,embla:z,progressRef:B,freeze:V,reset:ee}=se(F&&I>1,l);g(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>u(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),g(()=>{if(!z)return;let e=()=>a(z.selectedScrollSnap());return z.on(`select`,e).on(`reInit`,e),()=>{z.off(`select`,e).off(`reInit`,e)}},[z,a]),g(()=>{z&&z.selectedScrollSnap()!==L&&z.scrollTo(L,!0)},[z,L]),g(()=>{let e=()=>{document.hidden&&V(),C(!document.hidden)},t=()=>x(!1);return e(),document.addEventListener(`visibilitychange`,e,!0),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{document.removeEventListener(`visibilitychange`,e,!0),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[V]);let H=e=>{z?.scrollTo((e+I)%I,l),ee()};return g(()=>{let e=s.current,t=c.current[L];if(!(e&&t))return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();r.left<n.left?e.scrollLeft-=n.left-r.left:r.right>n.right&&(e.scrollLeft+=r.right-n.right)},[L,I]),j(`section`,{"aria-label":`${t} photos`,className:`lockerverse-auction-gallery`,onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||m(!1)},onFocusCapture:e=>m(e.target.matches(`:focus-visible`)),onKeyDown:e=>{I<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),H(L+(e.key===`ArrowRight`?1:-1)))},onPointerEnter:e=>{e.pointerType===`mouse`&&f(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&f(!1)},children:[I?j(`div`,{className:`lockerverse-auction-gallery__stage`,onPointerEnter:P,onPointerLeave:N,onPointerMove:P,children:[A(`div`,{className:`lockerverse-auction-gallery__viewport`,onPointerDownCapture:()=>{V(),x(!0)},ref:R,children:A(`div`,{className:`lockerverse-auction-gallery__track`,children:e.map((e,n)=>A(`div`,{"aria-hidden":n!==L,className:`lockerverse-auction-gallery__slide`,children:A(`button`,{"aria-label":`View photo ${n+1} of ${t} at full size`,className:`lockerverse-auction-gallery__photo`,onClick:()=>{o(n)},ref:n===L?i:void 0,tabIndex:n===L?0:-1,type:`button`,children:A(`img`,{alt:`${t}, ${n+1} of ${I}`,className:`lockerverse-auction-gallery__image`,draggable:!1,height:900,loading:n===0||n===L||n===(L+1)%I?`eager`:`lazy`,sizes:`(max-width: 1280px) 100vw, 45vw`,src:e,width:1200})})},`${e}-${n}`))})}),I>1&&!l&&j(`div`,{className:`lockerverse-auction-gallery__rotation`,children:[A(`div`,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__progress-track`,children:A(`div`,{className:`lockerverse-auction-gallery__progress`,ref:B,style:{transform:`scaleX(0)`}})}),A(`button`,{"aria-label":h?`Play photo rotation`:`Pause photo rotation`,className:`lockerverse-auction-gallery__play ${M}`,"data-gallery-control":!0,onClick:()=>_(e=>!e),title:h?`Play photo rotation`:`Pause photo rotation`,type:`button`,children:A(h?Y:oe,{"aria-hidden":`true`,size:13})})]}),I>1&&j(k,{children:[A(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__previous ${M}`,"data-gallery-control":!0,onClick:()=>H(L-1),type:`button`,children:A(q,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})}),A(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__next ${M}`,"data-gallery-control":!0,onClick:()=>H(L+1),type:`button`,children:A(J,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})})]})]}):A(`div`,{className:`lockerverse-auction-gallery__empty`,children:`No photo available`}),I>1&&A(`section`,{"aria-label":`Choose a photo`,className:`lockerverse-auction-gallery__strip`,ref:s,children:A(`div`,{className:`lockerverse-auction-gallery__thumbnails`,children:e.map((e,t)=>A(`button`,{"aria-label":`Show photo ${t+1} of ${I}`,"aria-pressed":L===t,className:`lockerverse-auction-gallery__thumbnail ${L===t?`is-selected`:``}`,onClick:()=>H(t),ref:e=>{c.current[t]=e},type:`button`,children:A(`img`,{alt:``,className:`lockerverse-auction-gallery__thumbnail-image`,height:66,sizes:`88px`,src:e,width:88})},`${e}-${t}`))})})]})}function ce({images:e,fallbackImage:t,name:n}){let r=[...new Set(e.filter(Boolean))];!r.length&&t&&r.push(t);let[i,a]=b(0),[o,s]=b(!1),c=y(null),l=y(null),u=r.length,d=u?(i%u+u)%u:0;return j(k,{children:[A(Q,{name:n,onExpand:e=>{a(e),s(!0)},onSelect:a,paused:o,photoButtonRef:c,photos:r,selected:d}),u>0&&A(M.Root,{onOpenChange:s,open:o,children:j(M.Portal,{children:[A(M.Backdrop,{className:`lockerverse-auction-gallery__backdrop`}),j(M.Popup,{"aria-describedby":void 0,className:`lockerverse-auction-gallery__viewer`,finalFocus:c,onKeyDown:e=>{u<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),a((d+(e.key===`ArrowRight`?1:-1)+u)%u))},children:[j(M.Title,{className:`lockerverse-auction-gallery__sr-only`,children:[n,` · Photo `,d+1,` of `,u]}),j(`div`,{className:`lockerverse-auction-gallery__full-image`,onTouchCancel:()=>{l.current=null},onTouchEnd:e=>{let t=l.current;l.current=null;let n=e.changedTouches.item(0);if(!(t&&n)||u<2)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>=45&&Math.abs(r)>Math.abs(i)*1.3&&a((d+(r<0?1:-1)+u)%u)},onTouchMove:e=>{e.touches.length!==1&&(l.current=null)},onTouchStart:e=>{let t=e.touches.item(0);l.current=e.touches.length===1&&t?{x:t.clientX,y:t.clientY}:null},children:[A(`img`,{alt:`${n}, ${d+1} of ${u}`,height:900,src:r[d],width:1200}),o&&u>1&&A(`img`,{alt:``,"aria-hidden":`true`,className:`lockerverse-auction-gallery__preload`,height:900,loading:`eager`,src:r[(d+1)%u],width:1200})]}),A(M.Close,{"aria-label":`Close photo viewer`,className:`lockerverse-auction-gallery__viewer-close`,children:A(X,{size:22})}),u>1&&j(k,{children:[A(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__viewer-previous`,onClick:()=>a((d-1+u)%u),type:`button`,children:A(q,{size:28})}),A(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__viewer-next`,onClick:()=>a((d+1)%u),type:`button`,children:A(J,{size:28})})]})]})]})})]})}function le(e){return e===`Buy Now`?`shield`:e===`Available`||e===`Increment`?`timer`:`gavel`}function ue(t,n){return t.saleMode===`buy_now`?[[`Buy Now`,e(t.buyNowPriceAmount??0)],[`Available`,t.availableQuantity===null?`Available`:String(t.availableQuantity)]]:n===`finished`?[[`Final bid`,t.maxBidAmount?e(t.maxBidAmount):`No bids`]]:[[`Current bid`,e(t.maxBidAmount??0)],[`Floor`,e(t.minBidAmount??0)],[`Increment`,e(t.bidIncrementAmount??0)]]}function de({auction:o,item:s}){let[c,l]=b(!1),u=_(),d=r(o,s),f={active:`Closes`,draft:`Opens`,finished:`Closed`}[d],p=t(o,d),m=s.saleMode===`buy_now`,h=n(s.description??``).length>240,g=ue(s,d);return j(`section`,{className:`lockerverse-auctions__item-summary`,children:[A(ce,{fallbackImage:s.image??o.configuration.image??o.community?.banner??o.community?.thumbnail??null,images:s.images,name:s.name}),j(`div`,{className:`lockerverse-auctions__item-copy`,children:[j(`p`,{className:`lockerverse-auctions__eyebrow`,children:[f,` `,p,` `,A(`span`,{"aria-hidden":`true`,children:` · `}),` Public item`]}),A(`h2`,{children:s.name}),s.description?j(`div`,{className:`lockerverse-auctions__item-description`,children:[A(a,{className:!c&&h?`lockerverse-auctions__description-clamped`:void 0,description:s.description,id:u}),h?j(`button`,{"aria-controls":u,"aria-expanded":c,className:`lockerverse-auctions__description-toggle`,onClick:()=>l(!c),type:`button`,children:[c?`Hide description`:`Read full description`,` `,A(`span`,{"aria-hidden":`true`,children:`⌄`})]}):null]}):null,j(`dl`,{className:`lockerverse-auctions__stat-panel`,children:[g.map(([e,t])=>j(`div`,{className:`lockerverse-auctions__stat-row`,children:[j(`dt`,{children:[A(i,{kind:le(e)}),e]}),A(`dd`,{children:t})]},e)),j(`div`,{className:`lockerverse-auctions__stat-row`,children:[j(`dt`,{children:[A(i,{kind:`clock`}),f]}),A(`dd`,{className:`lockerverse-auctions__stat-date`,children:p})]}),!m&&d===`finished`?j(`div`,{className:`lockerverse-auctions__stat-footer`,children:[j(`div`,{children:[A(`dt`,{children:`Floor`}),A(`dd`,{children:e(s.minBidAmount??0)})]}),j(`div`,{children:[A(`dt`,{children:`Bid increment`}),A(`dd`,{children:e(s.bidIncrementAmount??0)})]})]}):null]})]})]})}const $=/^\d+$/;function fe(t,n){return $.test(t)&&Number.isSafeInteger(Number(t)*n)?`Total: ${e(Number(t)*n)}`:`Enter a whole-number quantity.`}function pe(e,t,n){return String(e?t?t.quantity:1:t?t.amount/100:n)}function me(e,t){return e.isSoldOut?`This item is sold out.`:t===`draft`?`This item is not open yet.`:t===`finished`?e.saleMode===`buy_now`?`Purchases are closed for this item.`:`Bidding is closed for this item.`:`This item is not available.`}function he(e,n,r){return r===`draft`?`This item opens ${t(e,`draft`)}.`:n.isSoldOut?`All available quantities have been purchased.`:n.saleMode===`buy_now`?`This item is no longer available to purchase.`:`Bidding has closed for this item.`}function ge(e,t,n,r){return{amount:t?0:Number(r)*100,includeServiceFee:n?n.includeServiceFee:e.serviceFeeEnabled&&e.serviceFeeDefaultChecked,quantity:t?Number(r):1}}function _e({auction:t,item:n,initialSelection:i,onContinue:a,onError:o,onBack:s}){let c=n.saleMode===`buy_now`,l=Math.ceil(C(n)/100),[u,d]=b(pe(c,i,l)),[f,p]=b(null),m=_(),h=r(t,n),g=h===`active`&&!n.isSoldOut&&n.saleMode!==`hybrid`;function v(e){if(e.preventDefault(),!$.test(u)){p(c?`Enter a whole-number quantity.`:`Enter a whole-dollar bid amount.`);return}let r=ge(t,c,i,u),s=W(t,n,r);if(s){p(s),o(s);return}try{U(t,n,r)}catch{p(`Enter a valid amount or quantity.`);return}a(r)}return g?j(`form`,{className:`lockerverse-auctions__selection`,onSubmit:v,children:[A(ve,{buyNow:c,item:n,minimum:l}),j(`div`,{className:`lockerverse-auctions__selection-body`,children:[j(`label`,{className:`lockerverse-auctions__field`,htmlFor:m,children:[c?`Quantity`:`Your bid amount`,j(`span`,{className:`lockerverse-auctions__amount-control`,children:[c?null:A(`span`,{"aria-hidden":`true`,children:`$`}),A(`input`,{"aria-describedby":`${m}-help`,"aria-invalid":!!f,autoComplete:`off`,id:m,inputMode:`numeric`,onChange:e=>{d(e.target.value),p(null)},placeholder:c?`1`:String(l),required:!0,value:u})]})]}),f?A(`p`,{role:`alert`,children:f}):null,A(`p`,{id:`${m}-help`,children:c?fe(u,n.buyNowPriceAmount??0):`Enter a whole-dollar bid of at least ${e(l*100)}. Bid increment: ${e(n.bidIncrementAmount??0)}.`}),j(`div`,{className:`lockerverse-auctions__selection-footer`,children:[A(`p`,{children:c?`Continuing moves you into secure checkout where your payment is processed immediately.`:`Continuing moves you into the secure payment step where your card is stored for settlement only if your bid wins.`}),j(`button`,{className:`lockerverse-auctions__button`,disabled:!t.payment,type:`submit`,children:[c?`Continue to Checkout`:`Continue to Payment`,` `,A(`span`,{"aria-hidden":`true`,children:`→`})]})]}),t.payment?null:A(`p`,{role:`alert`,children:`Payments are not configured for this auction.`})]})]}):j(`div`,{className:`lockerverse-auctions__selection lockerverse-auctions__read-only`,children:[A(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Item status`}),A(`h3`,{children:me(n,h)}),A(`p`,{children:he(t,n,h)}),s?j(`button`,{className:`lockerverse-auctions__button`,onClick:s,type:`button`,children:[`Browse auction items `,A(`span`,{"aria-hidden":`true`,children:`→`})]}):null]})}function ve({item:t,buyNow:n,minimum:r}){return j(`div`,{className:`lockerverse-auctions__selection-header`,children:[A(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Step 1 of 2`}),A(`h3`,{children:n?`Buy this item now.`:`Place your bid.`}),A(`p`,{children:n?`Choose how many you want, then complete the secure checkout.`:`Enter the bid amount you want to place for this item. You are only charged if this bid wins after bidding closes.`}),j(`p`,{children:[n?`Price: `:`Minimum qualifying bid: `,A(`strong`,{children:e(n?t.buyNowPriceAmount??0:r*100)})]}),n&&t.availableQuantity!==null?j(`p`,{children:[t.availableQuantity,` available`]}):null,t.collectShippingAddress?A(`p`,{children:`The next step will also collect a delivery address for seller fulfillment.`}):null]})}function ye(e){let{auction:t,item:n,selection:r,theme:i=`dark`,stripeLoader:a=m,style:o,onBack:s,resumePurchase:c}=e,[l,d]=b(null),[f,p]=b(!1),[h,_]=b(0),v=c?.payment??t.payment;if(g(()=>{let e=!0;if(!v){p(!0);return}return Promise.resolve().then(()=>a(v.publishableKey,v.connectedAccountId?{stripeAccount:v.connectedAccountId}:void 0)).then(t=>{e&&(d(t),p(!t))},()=>{e&&p(!0)}),()=>{e=!1}},[v,a,h]),f)return j(`div`,{children:[A(`p`,{role:`alert`,children:`Payment details could not load.`}),c?null:A(`button`,{onClick:s,type:`button`,children:`Back to item`}),A(`button`,{onClick:()=>{p(!1),d(null),_(e=>e+1)},type:`button`,children:`Try again`})]});if(!l)return j(`div`,{children:[A(`p`,{role:`status`,children:`Loading secure payment details…`}),c?null:A(`button`,{onClick:s,type:`button`,children:`Back to item`})]});let y={mode:`setup`,setupFutureUsage:`off_session`};c?y={amount:c.pricing.totalCents,currency:`usd`,mode:`payment`}:n.saleMode===`buy_now`&&(y={amount:U(t,n,r).totalCents,currency:`usd`,mode:`payment`});let x={...y,appearance:{theme:i===`dark`?`night`:`stripe`,variables:{borderRadius:`18px`,colorBackground:i===`dark`?`#0F1014`:`#FFFFFF`,colorDanger:`#EF4444`,colorText:i===`dark`?`#FFFFFF`:`#121416`,colorTextSecondary:i===`dark`?`#C0BBC8`:`#55515E`,...o?.[`--lockerverse-accent`]?{colorPrimary:o[`--lockerverse-accent`]}:void 0,...o?.[`--lockerverse-font-family`]?{fontFamily:o[`--lockerverse-font-family`]}:void 0}},currency:`usd`,paymentMethodTypes:[`card`],syncAddressCheckbox:`none`};return A(u,{options:x,stripe:l,children:A(G,{...e})})}function be({buyNow:e}){return j(`div`,{className:`lockerverse-auctions__progress`,children:[j(`span`,{children:[A(i,{kind:e?`shield`:`gavel`}),e?`Choose quantity`:`Place bid`]}),j(`span`,{children:[A(i,{kind:`shield`}),e?`Pay securely`:`Secure card`]}),j(`span`,{children:[A(i,{kind:`timer`}),e?`Get confirmation`:`Wait for close`]})]})}function xe(e){let{auction:t,item:n,resumePurchase:i,className:a,theme:o=`dark`,style:s}=e,[c,l]=b(t),u=c.items.find(e=>e.id===n.id)??i?.item,[d,f]=b(()=>i?{amount:0,includeServiceFee:i.submission.includeServiceFee??!1,quantity:i.submission.quantity}:null),[p,m]=b(!!i),[h,g]=b({email:``,phone:``}),[_,v]=b(!!i),[y,x]=b(null);function S(e,t){m(!1),l(e),f(null),v(!1),x(t)}function C(e){x(null),f(e),v(!0)}return u?j(`section`,{className:[`lockerverse-auctions`,a].filter(Boolean).join(` `),"data-lockerverse-theme":o,style:{"--lockerverse-accent":c.community?.color??`#6f8f6d`,...s},children:[e.onBack&&!p?A(`button`,{className:`lockerverse-auctions__back`,onClick:e.onBack,type:`button`,children:`‹ All items`}):null,j(`div`,{className:`lockerverse-auctions__detail`,children:[A(de,{auction:c,item:u}),j(`div`,{className:`lockerverse-auctions__transaction`,children:[r(c,u)===`active`?A(be,{buyNow:u.saleMode===`buy_now`}):null,y?A(`p`,{className:`lockerverse-auctions__notice`,role:`alert`,children:y}):null,_&&d?A(ye,{...e,auction:c,communityName:e.communityName??c.community?.name,contact:h,item:u,onBack:()=>v(!1),onContactChange:g,onIncludeServiceFeeChange:e=>f(t=>t&&{...t,includeServiceFee:c.serviceFeeEnabled&&e}),onInteractionLockChange:m,onReview:S,selection:d}):A(_e,{auction:c,initialSelection:d,item:u,onBack:e.onBack,onContinue:C,onError:x}),e.onBack&&!p?A(`button`,{className:`lockerverse-auctions__footer-back`,onClick:e.onBack,type:`button`,children:`Back to auction items →`}):null]})]})]}):j(`div`,{children:[A(`p`,{role:`alert`,children:`This auction item is no longer available.`}),e.onBack?A(`button`,{onClick:e.onBack,type:`button`,children:`Back to auction items`}):null]})}function Se(e){let t=y({auctionId:e.auction.id,client:e.client,itemId:e.itemId});if(t.current.client!==e.client||t.current.auctionId!==e.auction.id||t.current.itemId!==e.itemId)throw TypeError(`Auction item identity cannot change. Remount with a new React key.`);if(e.resumePurchase&&(e.resumePurchase.auctionId!==e.auction.id||e.resumePurchase.itemId!==e.itemId||e.resumePurchase.item.id!==e.itemId||e.resumePurchase.item.auctionId!==e.auction.id))throw TypeError(`The purchase recovery record belongs to a different auction item.`);let n=e.auction.items.find(t=>t.id===e.itemId)??e.resumePurchase?.item;return n?A(xe,{...e,item:n}):A(`p`,{role:`alert`,children:`This auction item is not available.`})}export{Se as LockerverseAuctionItem};
|
|
1
|
+
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./use-auction-boundary.js";import{c,s as l,t as u}from"./host-callback.js";import{ArrowRight as d,ChevronDown as f,ChevronLeft as p,ChevronRight as m,Clock3 as h,Gavel as g,Pause as _,Play as v,ShieldCheck as y,TimerReset as b,X as x}from"lucide-react";import{useCallback as S,useEffect as C,useId as w,useMemo as T,useRef as E,useState as D}from"react";import{Fragment as O,jsx as k,jsxs as A}from"react/jsx-runtime";import{LockerverseSdkError as j,calculateLockerverseAuctionPricing as M,getLockerverseAuctionMinimumBid as N}from"@lockerverse/sdk/auctions";import{AddressElement as P,Elements as F,PaymentElement as I,useElements as L,useStripe as R}from"@stripe/react-stripe-js";import{loadStripe as z}from"@stripe/stripe-js/pure/index.js";import{safeParse as B}from"valibot";import{AsYouType as V,getCountries as H,getCountryCallingCode as U,parsePhoneNumberFromString as W}from"libphonenumber-js/max";import{Dialog as G}from"@base-ui/react/dialog";import K from"embla-carousel-autoplay";import q from"embla-carousel-react";const J=/^00/,ee=new Intl.DisplayNames([`en`],{type:`region`}),Y=H().map(e=>({country:e,label:ee.of(e)??e})).sort((e,t)=>e.label.localeCompare(t.label,`en`));function X(e,t){let n=e.normalize(`NFKC`).trim().replace(J,`+`),r=n.startsWith(`+`)?void 0:W(n,{defaultCountry:t,extract:!1});if(r?.isValid()&&!r.ext)return r;let i=W(n,{extract:!1})??W(`+${n}`,{extract:!1});return i?.isValid()&&!i.ext?i:null}function te(e){return String.fromCodePoint(...Array.from(e,e=>127397+e.charCodeAt(0)))}function ne({id:e,value:t,onChange:n}){let r=W(t),[i,a]=D(r?.country??`US`),[o,s]=D(r?.formatNational()??t),c=E(null),l=E(t);C(()=>{if(t===l.current)return;let e=W(t);l.current=t,a(e?.country??`US`),s((e?e.formatNational():null)??t)},[t]),C(()=>{c.current?.setCustomValidity(o&&!X(o,i)?`Enter a valid phone number.`:``)},[i,o]);function u(e,t,r=!1){let i=e.normalize(`NFKC`).trim().replace(J,`+`),o=X(e,t),c=i.startsWith(`+`)?o?.country??t:t,u=(o?o.formatNational():null)??new V(c).input(i);a(c),s(r?e:u),l.current=o?o.number:``,n(l.current)}return A(`div`,{className:`lockerverse-auctions__phone`,dir:`ltr`,children:[A(`div`,{className:`lockerverse-auctions__phone-country`,children:[A(`span`,{"aria-hidden":`true`,children:[k(`span`,{className:`lockerverse-auctions__phone-flag`,children:te(i)}),` `,`+`,U(i),` `,k(f,{"aria-hidden":`true`,size:14})]}),k(`select`,{"aria-label":`Phone number country`,onChange:e=>{let t=Y.find(t=>t.country===e.target.value);t&&u(o,t.country)},value:i,children:Y.map(e=>A(`option`,{value:e.country,children:[e.label,` +`,U(e.country)]},e.country))})]}),k(`input`,{autoComplete:`tel-national`,id:e,onChange:e=>u(e.target.value,i,e.target.value.length<o.length),onPaste:e=>{let t=X(e.clipboardData.getData(`text`),i);t&&(e.preventDefault(),u(t.number,t.country??i))},placeholder:`(201) 555-0123`,ref:c,required:!0,type:`tel`,value:o})]})}function Z(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 re(e){let{isPurchase:t,item:r,pricing:i,id:a}=e;return A(`form`,{className:`lockerverse-auctions__checkout`,onSubmit:e.onSubmit,children:[A(`div`,{className:`lockerverse-auctions__checkout-header`,children:[A(`div`,{className:`lockerverse-auctions__checkout-navigation`,children:[k(`button`,{"aria-label":`Back`,className:`lockerverse-auctions__checkout-back`,disabled:!e.onBack,onClick:e.onBack,type:`button`,children:k(p,{"aria-hidden":`true`,size:20})}),A(`div`,{children:[k(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Step 2 of 2`}),k(`p`,{children:t?`Secure checkout`:`Secure payment method`})]})]}),k(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:e.communityName}),k(`h2`,{children:t?`Finalize your purchase.`:`Finalize your bid authorization.`}),k(`p`,{className:`lockerverse-auctions__checkout-summary`,children:t?A(O,{children:[`Pay `,k(`strong`,{children:n(i.totalCents)}),` for`,` `,e.quantity,` `,e.quantity===1?`item`:`items`,` of`,` `,k(`strong`,{children:r.name}),`. Your card is charged immediately once checkout succeeds.`]}):A(O,{children:[`Authorize a payment method for your bid of`,` `,k(`strong`,{children:n(i.subtotalCents)}),` on`,` `,k(`strong`,{children:r.name}),`. Your card is only charged if this bid wins the item.`]})}),r.collectShippingAddress&&A(`div`,{className:`lockerverse-auctions__checkout-physical`,children:[k(`p`,{className:`lockerverse-auctions__checkout-eyebrow`,children:`Physical item`}),k(`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.`})]})]}),A(`div`,{className:`lockerverse-auctions__checkout-body`,children:[e.showFields&&A(`fieldset`,{disabled:e.locked,children:[A(`div`,{className:`lockerverse-auctions__checkout-contact`,children:[A(`label`,{className:`lockerverse-auctions__field`,htmlFor:`${a}-email`,children:[`Email`,k(`input`,{autoComplete:`email`,id:`${a}-email`,onChange:t=>e.onEmailChange(t.target.value),placeholder:`example@domain.com`,required:!0,type:`email`,value:e.email})]}),A(`label`,{className:`lockerverse-auctions__field`,htmlFor:`${a}-phone`,children:[`Phone Number`,k(ne,{id:`${a}-phone`,onChange:e.onPhoneChange,value:e.phone})]})]}),A(`section`,{"aria-label":`Payment Information`,className:`lockerverse-auctions__checkout-section`,children:[A(`div`,{className:`lockerverse-auctions__checkout-section-heading`,children:[k(`h3`,{children:`Payment Information`}),k(`p`,{children:t?`Processed securely and charged immediately for this purchase.`:`Stored securely and charged only if your bid finishes on top.`})]}),k(I,{onLoadError:e.onPaymentLoadError,options:Z(t)})]}),A(`section`,{"aria-label":`Billing Details`,className:`lockerverse-auctions__checkout-section`,children:[k(`h3`,{children:`Billing Details`}),k(P,{onChange:e.onBillingChange,options:{mode:`billing`}}),k(`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&&A(`section`,{"aria-label":`Delivery Details`,className:`lockerverse-auctions__checkout-section`,children:[A(`label`,{className:`lockerverse-auctions__checkout-checkbox lockerverse-auctions__checkout-delivery`,children:[k(`input`,{checked:e.sameAsBilling,onChange:t=>e.onSameAsBillingChange(t.target.checked),type:`checkbox`}),A(`span`,{children:[k(`strong`,{children:`Delivery address is the same as billing`}),k(`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&&A(O,{children:[k(`h3`,{children:`Delivery Address`}),k(P,{onChange:e.onShippingChange,options:{mode:`shipping`}})]})]}),e.serviceFeeEnabled&&k(ie,{...e})]}),e.message&&k(`p`,{"aria-live":`polite`,className:`lockerverse-auctions__notice`,role:`status`,children:e.message}),!e.isTerminal&&A(`div`,{className:`lockerverse-auctions__checkout-footer`,children:[A(`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.`:``]}),A(`button`,{className:`lockerverse-auctions__button lockerverse-auctions__checkout-submit`,disabled:e.submitDisabled,type:`submit`,children:[e.buttonText,k(d,{"aria-hidden":`true`,size:16})]})]})]})]})}function ie(e){let{isPurchase:t,pricing:r}=e;return k(`section`,{"aria-label":`Processing fees`,className:`lockerverse-auctions__checkout-section`,children:e.onIncludeServiceFeeChange?A(`label`,{className:`lockerverse-auctions__checkout-checkbox`,children:[k(`input`,{checked:e.includeServiceFee,onChange:t=>e.onIncludeServiceFeeChange?.(t.target.checked),type:`checkbox`}),A(`span`,{children:[A(`strong`,{children:[t?`Add`:`If I win, add`,` `,n(e.serviceFeeCents),` to help cover processing fees`]}),A(`span`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})]})]}):A(`p`,{children:[t?`Total`:`Total if I win`,`:`,` `,n(r.totalCents)]})})}function Q(e,t,n){return M(e,t.saleMode===`buy_now`?(t.buyNowPriceAmount??0)*n.quantity:n.amount,n.includeServiceFee)}function ae(e,t,n){if(e.status!==`active`||t.status!==`active`||Date.parse(e.endAt)<=Date.now())return`This item is not accepting bids or purchases.`;if(t.saleMode===`hybrid`)return`This item type is not supported for checkout.`;if(t.saleMode===`buy_now`){if(t.isSoldOut||t.availableQuantity===0)return`This item is sold out.`;if(!(t.buyNowPriceAmount&&Number.isSafeInteger(n.quantity))||n.quantity<1||t.availableQuantity!==null&&n.quantity>t.availableQuantity)return`Select an available quantity.`}else if(!Number.isSafeInteger(n.amount)||n.amount%100!=0||n.amount<N(t))return`Enter a whole-dollar bid at or above the minimum bid.`;return null}function oe(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(Q(e,n,i))!==JSON.stringify(Q(t,r,i))}function se(e){return{expectedServiceFeeCents:e.serviceFeeCents,expectedSubtotalCents:e.subtotalCents,expectedTotalCents:e.totalCents}}async function ce({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 le(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 ue(e,t,n){return e===`busy`?n?`Processing...`:`Authorizing...`:e===`retry`?`Retry original purchase`:t?`Check purchase status`:n?`Buy Now`:`Authorize Bid`}function de(e){let{auction:t,item:n,selection:r,client:i,onReview:a,onBack:o}=e,s=R(),d=L(),f=w(),[p,m]=D(e.contact?.email??``),[h,g]=D(e.contact?.phone??``),[_,v]=D(!0),[y,b]=D(null),[x,S]=D(null),[T,O]=D(e.resumePurchase??null),[A,M]=D(e.resumePurchase?`pending`:`ready`),[N,P]=D(null),F=E(e.resumePurchase?.submission.clientRequestId??null),I=A===`complete`||A===`uncertain`,z=E(!1),V=E(!0),H=E(e);H.current=e;let U=E(!1);function W(e){V.current&&M(e),u(H.current.onInteractionLockChange,e!==`ready`&&e!==`complete`)}function G(e){V.current&&P(e)}function K(e){W(e===`bid`?`uncertain`:`pending`),G(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.`),U.current||(U.current=!0,u(H.current.onUncertain,e))}C(()=>(V.current=!0,()=>{V.current=!1}),[]);let q=!!(T??e.resumePurchase)||n.saleMode===`buy_now`,J=T?.pricing??e.resumePurchase?.pricing??Q(t,n,r),ee=T?.payment??e.resumePurchase?.payment??t.payment;function Y(e){V.current&&O(e),u(H.current.onPurchaseRecoveryChange,e)}function X(e){e.status===`paid`?(F.current=null,Y(null),W(`complete`),G(`Purchase complete. Receipt: ${e.purchaseId}`),U.current||(U.current=!0,u(H.current.onPurchaseComplete,e))):e.status===`pending_payment`?(W(`pending`),G(`Your purchase is pending. Check its status before making another payment.`)):(F.current=null,Y(null),W(`ready`),G(`This purchase is ${e.status.replaceAll(`_`,` `)}. You can start a new purchase.`))}async function te(){if(!(s&&d&&t.payment))throw Error(`Payment details are still loading.`);let e=B(l,p),o=B(c,h);if(!(e.success&&o.success))throw Error(`Enter a valid email and phone number with its country code.`);let u=await i.load(t.slug);if(!V.current)return null;let f=u.items.find(e=>e.id===n.id);if(!f)return a(u,`This item is no longer available.`),null;let m=ae(u,f,r);if(m||oe(t,u,n,f,r))return a(u,m??`The checkout details changed. Review them before continuing.`),null;let g=await ce({billing:y,collectShippingAddress:n.collectShippingAddress,elements:d,email:e.output,phone:o.output,shipping:_?y:x,stripe:s});return V.current?{confirmationToken:g,email:e.output,includeServiceFee:r.includeServiceFee,phone:o.output,...se(J)}:null}async function ne(e){let a=await i.createBid(t.slug,n.id,{...e,amount:r.amount});if(a.requiresAction){if(!(V.current&&s)){K(`bid`);return}await le(s,a)}W(`complete`),G(`Bid submitted. Watch your email for bid and auction updates.`),U.current||(U.current=!0,u(H.current.onBidSubmitted,a))}async function Z(e,r){if(e.requiresAction){if(!(V.current&&s)){K(`purchase`);return}await le(s,e);let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);a?X(a):(W(`pending`),G(`Payment status is not available yet. Check again shortly.`));return}X(e),!V.current&&e.status===`pending_payment`&&K(`purchase`)}async function ie(e){let r=await i.getPurchaseStatus(t.slug,n.id,e.submission.clientRequestId);if(r)await Z(r,e);else{if(!V.current){K(`purchase`);return}W(`retry`),G(`No purchase is recorded yet. You can retry the original purchase with the same request ID.`)}}async function de(e,r){let a=await i.getPurchaseStatus(t.slug,n.id,r.submission.clientRequestId);if(a){await Z(a,r);return}Y(null),W(`ready`),G(`The purchase was rejected. Review the item and payment details before trying again. (${e.status??`validation`})`)}async function $(e,t,n,r){let i=t&&(!(e instanceof j)||e.recoveryRecommended);if(G(e instanceof Error?e.message:`Unable to complete this request.`),q&&n){if(!r&&e instanceof j&&!e.recoveryRecommended)try{await de(e,n);return}catch{}K(`purchase`)}else i?K(`bid`):W(`ready`)}function fe(){return F.current??=globalThis.crypto.randomUUID(),F.current}function pe(){return V.current?!0:(T||(Y(null),W(`ready`)),!1)}async function me(e,r){if(r){await ie(e);return}pe()&&await Z(await i.createPurchase(t.slug,n.id,e.submission),e)}let he=s&&d&ⅇasync function ge(e){if(e.preventDefault(),z.current||I)return;if(!he){G(`Payment details are still loading.`);return}let i=A===`retry`;z.current=!0,U.current=!1,W(`busy`),G(null);let a=!1,o=T;try{if(!o){let e=await te();if(!(e&&V.current)){W(`ready`);return}if(!q){a=!0,await ne(e);return}o=Object.freeze({auctionId:t.id,item:n,itemId:n.id,payment:Object.freeze({...he}),pricing:J,submission:Object.freeze({...e,clientRequestId:fe(),paymentMethodTypes:Object.freeze([`card`]),quantity:r.quantity})}),Y(o)}a=!0,await me(o,!!T&&!i)}catch(e){await $(e,a,o,T!==null&&!i)}finally{z.current=!1}}let _e=ue(A,T!==null,q),ve=A!==`ready`;return k(re,{buttonText:_e,communityName:e.communityName??t.name,email:p,id:f,includeServiceFee:r.includeServiceFee,isPurchase:q,isTerminal:I,item:n,locked:ve,message:N,onBack:A===`ready`?o:void 0,onBillingChange:b,onEmailChange:t=>{m(t),e.onContactChange?.({email:t,phone:h})},onIncludeServiceFeeChange:e.onIncludeServiceFeeChange,onPaymentLoadError:()=>G(`Unable to load payment form.`),onPhoneChange:t=>{g(t),e.onContactChange?.({email:p,phone:t})},onSameAsBillingChange:v,onShippingChange:S,onSubmit:ge,phone:h,pricing:J,quantity:r.quantity,sameAsBilling:_,serviceFeeCents:T?J.serviceFeeCents:Q(t,n,{...r,includeServiceFee:t.serviceFeeEnabled}).serviceFeeCents,serviceFeeEnabled:t.serviceFeeEnabled,showFields:!(T||I),submitDisabled:A===`busy`||!s||!d})}const $=6e3;function fe(e,t){let n=E($),r=E(null),[i,a]=D($),o=T(()=>K({delay:i,playOnInit:!1,stopOnFocusIn:!1,stopOnInteraction:!0,stopOnMouseEnter:!1}),[i]),[s,c]=q({duration:t?0:25,loop:!0},[o]),l=S(()=>{r.current&&(r.current.style.transform=`scaleX(${1-n.current/$})`)},[]),u=S(()=>{let e=o.timeUntilNext();e!==null&&(n.current=Math.max(1,Math.min($,e))),o.stop(),l()},[o,l]),d=S(()=>{n.current=$,a($),o.reset(),l()},[o,l]);return C(()=>{c&&(e?i===n.current?o.play():a(n.current):u())},[c,e,o,i,a,n,u]),C(()=>{if(!c)return;let t=0,r=()=>{let i=o.timeUntilNext();!e||i===null||(n.current=Math.max(0,Math.min($,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 pe({photos:e,name:t,selected:n,paused:i=!1,photoButtonRef:a,onSelect:o,onExpand:s}){let c=E(null),l=E([]),[u,d]=D(!0),[f,h]=D(!1),[g,y]=D(!1),[b,x]=D(!1),[S,w]=D(!1),{ref:T,visible:j}=r(),[M,N]=D(!1),[P,F]=D(!0),I=E(null),L=`lockerverse-auction-gallery__control ${P||M||g?`is-visible`:``}`,R=()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>N(!1),2e3)},z=e=>{if(e.pointerType!==`mouse`){F(!0);return}N(!0),I.current&&clearTimeout(I.current),e.target instanceof Element&&e.target.closest(`[data-gallery-control]`)||R()};C(()=>{let e=window.matchMedia(`(hover: none), (pointer: coarse)`),t=()=>F(e.matches);return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),clearTimeout(I.current??void 0)}},[]);let B=!(i||u||f||g||b||S)&&j,V=e.length,H=V?(n%V+V)%V:0,{viewportRef:U,embla:W,progressRef:G,freeze:K,reset:q}=fe(B&&V>1,u);C(()=>{let e=window.matchMedia(`(prefers-reduced-motion: reduce)`),t=()=>d(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),C(()=>{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]),C(()=>{W&&W.selectedScrollSnap()!==H&&W.scrollTo(H,!0)},[W,H]),C(()=>{let e=()=>{document.hidden&&K()},t=()=>w(!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+V)%V,u),q()};return C(()=>{let e=c.current,t=l.current[H];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)},[H,V]),A(`section`,{"aria-label":`${t} photos`,className:`lockerverse-auction-gallery`,onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||y(!1)},onFocusCapture:e=>y(e.target.matches(`:focus-visible`)),onKeyDown:e=>{V<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),J(H+(e.key===`ArrowRight`?1:-1)))},onPointerEnter:e=>{e.pointerType===`mouse`&&h(!0)},onPointerLeave:e=>{e.pointerType===`mouse`&&h(!1)},ref:T,children:[V?A(`div`,{className:`lockerverse-auction-gallery__stage`,onPointerEnter:z,onPointerLeave:R,onPointerMove:z,children:[k(`div`,{className:`lockerverse-auction-gallery__viewport`,onPointerDownCapture:()=>{K(),w(!0)},ref:U,children:k(`div`,{className:`lockerverse-auction-gallery__track`,children:e.map((e,n)=>k(`div`,{"aria-hidden":n!==H,className:`lockerverse-auction-gallery__slide`,children:k(`button`,{"aria-label":`View photo ${n+1} of ${t} at full size`,className:`lockerverse-auction-gallery__photo`,onClick:()=>{s(n)},ref:n===H?a:void 0,tabIndex:n===H?0:-1,type:`button`,children:k(`img`,{alt:`${t}, ${n+1} of ${V}`,className:`lockerverse-auction-gallery__image`,draggable:!1,height:900,loading:n===0||n===H||n===(H+1)%V?`eager`:`lazy`,sizes:`(max-width: 1280px) 100vw, 45vw`,src:e,width:1200})})},`${e}-${n}`))})}),V>1&&!u&&A(`div`,{className:`lockerverse-auction-gallery__rotation`,children:[k(`div`,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__progress-track`,children:k(`div`,{className:`lockerverse-auction-gallery__progress`,ref:G,style:{transform:`scaleX(0)`}})}),k(`button`,{"aria-label":b?`Play photo rotation`:`Pause photo rotation`,className:`lockerverse-auction-gallery__play ${L}`,"data-gallery-control":!0,onClick:()=>x(e=>!e),title:b?`Play photo rotation`:`Pause photo rotation`,type:`button`,children:k(b?v:_,{"aria-hidden":`true`,size:13})})]}),V>1&&A(O,{children:[k(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__previous ${L}`,"data-gallery-control":!0,onClick:()=>J(H-1),type:`button`,children:k(p,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})}),k(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__next ${L}`,"data-gallery-control":!0,onClick:()=>J(H+1),type:`button`,children:k(m,{"aria-hidden":`true`,className:`lockerverse-auction-gallery__chevron`})})]})]}):k(`div`,{className:`lockerverse-auction-gallery__empty`,children:`No photo available`}),V>1&&k(`section`,{"aria-label":`Choose a photo`,className:`lockerverse-auction-gallery__strip`,ref:c,children:k(`div`,{className:`lockerverse-auction-gallery__thumbnails`,children:e.map((e,t)=>k(`button`,{"aria-label":`Show photo ${t+1} of ${V}`,"aria-pressed":H===t,className:`lockerverse-auction-gallery__thumbnail ${H===t?`is-selected`:``}`,onClick:()=>J(t),ref:e=>{l.current[t]=e},type:`button`,children:k(`img`,{alt:``,className:`lockerverse-auction-gallery__thumbnail-image`,height:66,sizes:`88px`,src:e,width:88})},`${e}-${t}`))})})]})}function me({images:e,fallbackImage:t,name:n}){let r=[...new Set(e.filter(Boolean))];!r.length&&t&&r.push(t);let[i,a]=D(0),[o,s]=D(!1),c=E(null),l=E(null),u=r.length,d=u?(i%u+u)%u:0;return A(O,{children:[k(pe,{name:n,onExpand:e=>{a(e),s(!0)},onSelect:a,paused:o,photoButtonRef:c,photos:r,selected:d}),u>0&&k(G.Root,{onOpenChange:s,open:o,children:A(G.Portal,{children:[k(G.Backdrop,{className:`lockerverse-auction-gallery__backdrop`}),A(G.Popup,{"aria-describedby":void 0,className:`lockerverse-auction-gallery__viewer`,finalFocus:c,onKeyDown:e=>{u<2||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&(e.preventDefault(),a((d+(e.key===`ArrowRight`?1:-1)+u)%u))},children:[A(G.Title,{className:`lockerverse-auction-gallery__sr-only`,children:[n,` · Photo `,d+1,` of `,u]}),A(`div`,{className:`lockerverse-auction-gallery__full-image`,onTouchCancel:()=>{l.current=null},onTouchEnd:e=>{let t=l.current;l.current=null;let n=e.changedTouches.item(0);if(!(t&&n)||u<2)return;let r=n.clientX-t.x,i=n.clientY-t.y;Math.abs(r)>=45&&Math.abs(r)>Math.abs(i)*1.3&&a((d+(r<0?1:-1)+u)%u)},onTouchMove:e=>{e.touches.length!==1&&(l.current=null)},onTouchStart:e=>{let t=e.touches.item(0);l.current=e.touches.length===1&&t?{x:t.clientX,y:t.clientY}:null},children:[k(`img`,{alt:`${n}, ${d+1} of ${u}`,height:900,src:r[d],width:1200}),o&&u>1&&k(`img`,{alt:``,"aria-hidden":`true`,className:`lockerverse-auction-gallery__preload`,height:900,loading:`eager`,src:r[(d+1)%u],width:1200})]}),k(G.Close,{"aria-label":`Close photo viewer`,className:`lockerverse-auction-gallery__viewer-close`,children:k(x,{"aria-hidden":`true`,size:22})}),u>1&&A(O,{children:[k(`button`,{"aria-label":`Previous photo`,className:`lockerverse-auction-gallery__viewer-previous`,onClick:()=>a((d-1+u)%u),type:`button`,children:k(p,{"aria-hidden":`true`,size:28})}),k(`button`,{"aria-label":`Next photo`,className:`lockerverse-auction-gallery__viewer-next`,onClick:()=>a((d+1)%u),type:`button`,children:k(m,{"aria-hidden":`true`,size:28})})]})]})]})})]})}function he(e){return k(e===`Buy Now`?y:e===`Available`||e===`Increment`?b:g,{"aria-hidden":`true`,size:16})}function ge(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??0)]]}function _e({auction:r,item:i}){s(r.startAt,r.endAt);let[c,l]=D(!1),u=w(),d=e(r,i),p={active:`Closes`,draft:`Opens`,finished:`Closed`}[d],m=a(r,d),g=i.saleMode===`buy_now`,_=t(i.description??``).length>240,v=ge(i,d);return A(`section`,{className:`lockerverse-auctions__item-summary`,children:[k(me,{fallbackImage:i.image??r.configuration.image??r.community?.banner??r.community?.thumbnail??null,images:i.images,name:i.name}),A(`div`,{className:`lockerverse-auctions__item-copy`,children:[A(`p`,{className:`lockerverse-auctions__eyebrow`,children:[p,` `,m,` `,k(`span`,{"aria-hidden":`true`,children:` · `}),` Public item`]}),k(`h2`,{children:i.name}),i.description?A(`div`,{className:`lockerverse-auctions__item-description`,children:[k(o,{className:!c&&_?`lockerverse-auctions__description-clamped`:void 0,description:i.description,id:u}),_?A(`button`,{"aria-controls":u,"aria-expanded":c,className:`lockerverse-auctions__description-toggle`,onClick:()=>l(!c),type:`button`,children:[c?`Hide description`:`Read full description`,` `,k(f,{"aria-hidden":`true`,size:16,style:{transform:c?`rotate(180deg)`:void 0}})]}):null]}):null,A(`dl`,{className:`lockerverse-auctions__stat-panel`,children:[v.map(([e,t])=>A(`div`,{className:`lockerverse-auctions__stat-row`,children:[A(`dt`,{children:[he(e),e]}),k(`dd`,{children:t})]},e)),A(`div`,{className:`lockerverse-auctions__stat-row`,children:[A(`dt`,{children:[k(h,{"aria-hidden":`true`,size:16}),p]}),k(`dd`,{className:`lockerverse-auctions__stat-date`,children:m})]}),!g&&d===`finished`?A(`div`,{className:`lockerverse-auctions__stat-footer`,children:[A(`div`,{children:[k(`dt`,{children:`Floor`}),k(`dd`,{children:n(i.minBidAmount??0)})]}),A(`div`,{children:[k(`dt`,{children:`Bid increment`}),k(`dd`,{children:n(i.bidIncrementAmount??0)})]})]}):null]})]})]})}const ve=/^\d+$/;function ye(e,t){return ve.test(e)&&Number.isSafeInteger(Number(e)*t)?`Total: ${n(Number(e)*t)}`:`Enter a whole-number quantity.`}function be(e,t,n){return String(e?t?t.quantity:1:t?t.amount/100:n)}function xe(e,t){return i(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 Se(e,t,n){return i(t)?`All available quantities have been purchased.`:n===`draft`?`This item opens ${a(e,`draft`)}.`:t.saleMode===`buy_now`?`This item is no longer available to purchase.`:`Bidding has closed for this item.`}function Ce(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 we({auction:t,item:r,initialSelection:a,onContinue:o,onError:c,onBack:l}){let u=r.saleMode===`buy_now`,f=Math.ceil(N(r)/100),[p,m]=D(be(u,a,f)),[h,g]=D(null),_=w();s(t.startAt,t.endAt);let v=e(t,r),y=v===`active`&&!i(r)&&r.saleMode!==`hybrid`;function b(e){if(e.preventDefault(),!ve.test(p)){g(u?`Enter a whole-number quantity.`:`Enter a whole-dollar bid amount.`);return}let n=Ce(t,u,a,p),i=ae(t,r,n);if(i){g(i),c(i);return}try{Q(t,r,n)}catch{g(`Enter a valid amount or quantity.`);return}o(n)}return y?A(`form`,{className:`lockerverse-auctions__selection`,onSubmit:b,children:[k(Te,{buyNow:u,item:r,minimum:f}),A(`div`,{className:`lockerverse-auctions__selection-body`,children:[A(`label`,{className:`lockerverse-auctions__field`,htmlFor:_,children:[u?`Quantity`:`Your bid amount`,A(`span`,{className:`lockerverse-auctions__amount-control`,children:[u?null:k(`span`,{"aria-hidden":`true`,children:`$`}),k(`input`,{"aria-describedby":`${_}-help`,"aria-invalid":!!h,autoComplete:`off`,id:_,inputMode:`numeric`,onChange:e=>{m(e.target.value),g(null)},placeholder:u?`1`:String(f),required:!0,value:p})]})]}),h?k(`p`,{role:`alert`,children:h}):null,k(`p`,{id:`${_}-help`,children:u?ye(p,r.buyNowPriceAmount??0):`Enter a whole-dollar bid of at least ${n(f*100)}. Bid increment: ${n(r.bidIncrementAmount??0)}.`}),A(`div`,{className:`lockerverse-auctions__selection-footer`,children:[k(`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.`}),A(`button`,{className:`lockerverse-auctions__button`,disabled:!t.payment,type:`submit`,children:[u?`Continue to Checkout`:`Continue to Payment`,` `,k(d,{"aria-hidden":`true`,size:16})]})]}),t.payment?null:k(`p`,{role:`alert`,children:`Payments are not configured for this auction.`})]})]}):A(`div`,{className:`lockerverse-auctions__selection lockerverse-auctions__read-only`,children:[k(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Item status`}),k(`h3`,{children:xe(r,v)}),k(`p`,{children:Se(t,r,v)}),l?A(`button`,{className:`lockerverse-auctions__button`,onClick:l,type:`button`,children:[`Browse auction items `,k(d,{"aria-hidden":`true`,size:16})]}):null]})}function Te({item:e,buyNow:t,minimum:r}){return A(`div`,{className:`lockerverse-auctions__selection-header`,children:[k(`p`,{className:`lockerverse-auctions__eyebrow`,children:`Step 1 of 2`}),k(`h3`,{children:t?`Buy this item now.`:`Place your bid.`}),k(`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.`}),A(`p`,{children:[t?`Price: `:`Minimum qualifying bid: `,k(`strong`,{children:n(t?e.buyNowPriceAmount??0:r*100)})]}),t&&e.availableQuantity!==null?A(`p`,{children:[e.availableQuantity,` available`]}):null,e.collectShippingAddress?k(`p`,{children:`The next step will also collect a delivery address for seller fulfillment.`}):null]})}function Ee(e){let{auction:t,item:n,selection:r,theme:i=`dark`,stripeLoader:a=z,style:o,onBack:s,resumePurchase:c}=e,[l,u]=D(null),[d,f]=D(!1),[p,m]=D(0),h=c?.payment??t.payment;if(C(()=>{let e=!0;if(!h){f(!0);return}return Promise.resolve().then(()=>a(h.publishableKey,h.connectedAccountId?{stripeAccount:h.connectedAccountId}:void 0)).then(t=>{e&&(u(t),f(!t))},()=>{e&&f(!0)}),()=>{e=!1}},[h,a,p]),d)return A(`div`,{children:[k(`p`,{role:`alert`,children:`Payment details could not load.`}),c?null:k(`button`,{onClick:s,type:`button`,children:`Back to item`}),k(`button`,{onClick:()=>{f(!1),u(null),m(e=>e+1)},type:`button`,children:`Try again`})]});if(!l)return A(`div`,{children:[k(`p`,{role:`status`,children:`Loading secure payment details…`}),c?null:k(`button`,{onClick:s,type:`button`,children:`Back to item`})]});let g={mode:`setup`,setupFutureUsage:`off_session`};c?g={amount:c.pricing.totalCents,currency:`usd`,mode:`payment`}:n.saleMode===`buy_now`&&(g={amount:Q(t,n,r).totalCents,currency:`usd`,mode:`payment`});let _={...g,appearance:{theme:i===`dark`?`night`:`stripe`,variables:{borderRadius:`18px`,colorBackground:i===`dark`?`#0F1014`:`#FFFFFF`,colorDanger:`#EF4444`,colorText:i===`dark`?`#FFFFFF`:`#121416`,colorTextSecondary:i===`dark`?`#C0BBC8`:`#55515E`,...o?.[`--lockerverse-accent`]?{colorPrimary:o[`--lockerverse-accent`]}:void 0,...o?.[`--lockerverse-font-family`]?{fontFamily:o[`--lockerverse-font-family`]}:void 0}},currency:`usd`,paymentMethodTypes:[`card`],syncAddressCheckbox:`none`};return k(F,{options:_,stripe:l,children:k(de,{...e})})}function De({buyNow:e}){return A(`div`,{className:`lockerverse-auctions__progress`,children:[A(`span`,{children:[k(e?y:g,{"aria-hidden":`true`,size:16}),e?`Choose quantity`:`Place bid`]}),A(`span`,{children:[k(y,{"aria-hidden":`true`,size:16}),e?`Pay securely`:`Secure card`]}),A(`span`,{children:[k(b,{"aria-hidden":`true`,size:16}),e?`Get confirmation`:`Wait for close`]})]})}function Oe(t){let{auction:n,itemId:r,resumePurchase:i,className:a,theme:o=`dark`,style:c}=t,[l,f]=D(n),m=E(n);s(l.startAt,l.endAt);let h=l.items.find(e=>e.id===r)??i?.item,[g,_]=D(()=>i?{amount:0,includeServiceFee:i.submission.includeServiceFee??!1,quantity:i.submission.quantity}:null),[v,y]=D(!!i),b=E(!0),x=E(t);x.current=t;let w=E(null),T=S(e=>{b.current&&y(e),w.current!==e&&(w.current=e,u(x.current.onInteractionLockChange,e))},[]),O=!!i;C(()=>(b.current=!0,T(O),()=>{b.current=!1}),[O,T]);let[j,M]=D({email:``,phone:``}),[N,P]=D(!!i),[F,I]=D(null);C(()=>{!(N||v||i)&&m.current!==n&&(m.current=n,f(n))},[n,N,v,i]);function L(e,t){T(!1),m.current=x.current.auction,f(e),_(null),P(!1),I(t)}function R(e){I(null),_(e),P(!0)}return h?A(`section`,{className:[`lockerverse-auctions`,a].filter(Boolean).join(` `),"data-lockerverse-theme":o,style:{"--lockerverse-accent":l.community?.color??`#6f8f6d`,...c},children:[t.onBack&&!v?A(`button`,{className:`lockerverse-auctions__back`,onClick:t.onBack,type:`button`,children:[k(p,{"aria-hidden":`true`,size:16}),` All items`]}):null,A(`div`,{className:`lockerverse-auctions__detail`,children:[k(_e,{auction:l,item:h}),A(`div`,{className:`lockerverse-auctions__transaction`,children:[e(l,h)===`active`?k(De,{buyNow:h.saleMode===`buy_now`}):null,F?k(`p`,{className:`lockerverse-auctions__notice`,role:`alert`,children:F}):null,N&&g?k(Ee,{...t,auction:l,communityName:t.communityName??l.community?.name,contact:j,item:h,onBack:()=>P(!1),onContactChange:M,onIncludeServiceFeeChange:e=>_(t=>t&&{...t,includeServiceFee:l.serviceFeeEnabled&&e}),onInteractionLockChange:T,onReview:L,selection:g}):k(we,{auction:l,initialSelection:g,item:h,onBack:t.onBack,onContinue:R,onError:I}),t.onBack&&!v?A(`button`,{className:`lockerverse-auctions__footer-back`,onClick:t.onBack,type:`button`,children:[`Back to auction items `,k(d,{"aria-hidden":`true`,size:16})]}):null]})]})]}):A(`div`,{children:[k(`p`,{role:`alert`,children:`This auction item is no longer available.`}),t.onBack?k(`button`,{onClick:t.onBack,type:`button`,children:`Back to auction items`}):null]})}function ke(e){let t=E({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 k(Oe,{...e})}export{ke as LockerverseAuctionItem};
|
|
2
2
|
//# sourceMappingURL=auction-item.js.map
|