1import{r as y,R as Nt}from"../vendor-Cc9w-i99.js";import{j as e,H as wt,e as Ce,p as St,k as be,u as He,Z as kt,ac as Ct,X as At,C as ze,w as Pt}from"./hooks-BlLlWTp9.js";import{E as Ne}from"./logger-DfNVpG3P.js";import{useAuth as F,AuthModal as Ge,RechargeWalletModal as It}from"./auth-AbxUcDmb.js";import{bj as Bt,y as Ae,bk as Et,bl as Ot,b9 as Tt,bm as Je,bn as Mt,bo as Lt,x as $t}from"./queue-DaHNt4dN.js";import{T as r,c as ve,w as qe,P as M,V as Dt,D as Y,B as S,C as Ut,b as Ze,M as Ke,a as Rt,I as we,u as Ft,l as Ye,R as Xt,S as $e,d as Vt}from"./ui-Bq7l3oiK.js";import{a as X,b as k,d as pe,W as Wt,T as ye,L as W,k as Ht}from"./config-CNzyBjC_.js";import{u as ne}from"./analytics-DE0c17Pa.js";import{U as zt,k as Gt,B as Pe,E as Qe,am as Jt,a_ as qt,u as Zt,j as Kt,m as Yt,z as De,r as Qt,aN as et,a as en,b1 as tn,o as nn}from"./svg-HUfKeBgT.js";import{u as Ie,C as L,a as sn}from"./currency-B7PYjEev.js";import{F as an,u as on,E as rn,I as cn}from"./contentful-9uMqmgoA.js";import{u as tt,F as nt,a as Be,C as te}from"../react-hook-form-D_m77UuM.js";import{B as ln,f as dn,d as un}from"./payment-CMegBHo6.js";import{W as mn}from"./ticketing-BIN3h7yH.js";var st=y.createContext(null),_n=Object.defineProperty,hn=Object.defineProperties,xn=Object.getOwnPropertyDescriptors,_e=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,Ue=(t,n,s)=>n in t?_n(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,O=(t,n)=>{for(var s in n||(n={}))at.call(n,s)&&Ue(t,s,n[s]);if(_e)for(var s of _e(n))ot.call(n,s)&&Ue(t,s,n[s]);return t},R=(t,n)=>hn(t,xn(n)),me=(t,n)=>{var s={};for(var a in t)at.call(t,a)&&n.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&_e)for(var a of _e(t))n.indexOf(a)<0&&ot.call(t,a)&&(s[a]=t[a]);return s},fe=(t,n,s)=>new Promise((a,i)=>{var d=l=>{try{o(s.next(l))}catch(u){i(u)}},_=l=>{try{o(s.throw(l))}catch(u){i(u)}},o=l=>l.done?a(l.value):Promise.resolve(l.value).then(d,_);o((s=s.apply(t,n)).next())}),Ts=t=>{var n=t,{children:s}=n,a=me(n,["children"]);const[i]=y.useState(a);return e.jsx(st.Provider,{value:i,children:s})},vn=()=>{const t=y.useContext(st);if(!t)throw new Error("useAuctionProvider must be used within an WbkAuctionProvider, refer to usage instructions: https://github.com/nadude/webook-frontend/blob/main/packages/auction/README.md");return t},pn=({mini:t,endAt:n,ended:s})=>{const{locale:a}=X(),{t:i}=k("auction_common"),d=y.useRef(new Date().getTime()/1e3),_=n?new Date(n):new Date,{isTimeUp:o,timer:l}=wt({id:"auction-timer-"+n,initialSeconds:_.getTime()/1e3-d.current});return o||s?null:t?`${l.days?`${l.days}d · `:""}${l.hours}h · ${l.minutes}m · ${l.seconds}s`:e.jsxs("div",{className:"space-y-XS",children:[e.jsx(r,{variant:"label-M",color:"text-secondary",children:i("auction_common:end_in")}),e.jsx("div",{className:"gap-M flex",children:["days","hours","minutes","seconds"].map(u=>e.jsxs("div",{className:"p-S bg-body-dark/10 rounded-S flex-1 grow text-center",children:[e.jsx(r,{variant:"display-XS",className:"leading-none",children:l[u]}),e.jsx(r,{variant:"label-M",color:"text-secondary",children:i(`auction_common:${u}`).toUpperCase()})]},u))}),e.jsxs(r,{variant:"label-M",color:"text-secondary",children:[`${i("auction_common:end_on")}: `,e.jsx(r,{as:"span",className:"text-text",children:Ce(_,a,{dateStyle:"long",timeStyle:"short"})})]})]})},ie=pn,yn=y.createContext({auction:null,notStartedYet:!1,joinAuction:()=>{},submitBid:()=>{},clearBidError:()=>{},joined:!1,currentBid:0,bidInterval:0,totalBids:0,bidders:[],bids:[],outbidded:!1,canBid:!1,isMyBid:!1,wonBid:!1,ended:!1,reservePriceNotMet:!1}),it=yn,$=()=>y.useContext(it),fn=y.createContext({authorized:!1,loading:!1,initiateSocket:()=>{},sendSocketMessage:()=>{},clearSocketMessage:()=>{},messages:{}}),rt=fn,gn=()=>y.useContext(rt),ct=y.createContext(null),jn=()=>{const t=y.useContext(ct);if(!t)throw new Error("useSocketProvider must be used within an WbkSocketProvider, refer to usage instructions: https://github.com/nadude/webook-frontend/blob/main/packages/socket/README.md");return t}
1,q={PING:0,SUBSCRIBE:1,UNSUBSCRIBE:2,CHAT:3,AUTH:4,AUCTION:5},Z={UNAUTHORIZED:0,AUTHORIZED:1,LOGOUT:2,AUCTION_JOIN:0,AUCTION_END:1,AUCTION_BID:2,AUCTION_ERROR:3,AUCTION_WALLET_ALERT:4,AUCTION_STATUS:5},bn=Object.defineProperty,Nn=Object.defineProperties,wn=Object.getOwnPropertyDescriptors,he=Object.getOwnPropertySymbols,lt=Object.prototype.hasOwnProperty,dt=Object.prototype.propertyIsEnumerable,Re=(t,n,s)=>n in t?bn(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,D=(t,n)=>{for(var s in n||(n={}))lt.call(n,s)&&Re(t,s,n[s]);if(he)for(var s of he(n))dt.call(n,s)&&Re(t,s,n[s]);return t},U=(t,n)=>Nn(t,wn(n)),Sn=(t,n)=>{var s={};for(var a in t)lt.call(t,a)&&n.indexOf(a)<0&&(s[a]=t[a]);if(t!=null&&he)for(var a of he(t))n.indexOf(a)<0&&dt.call(t,a)&&(s[a]=t[a]);return s},Fe,kn=({children:t})=>{var n,s;const{endpoint:a,autoInit:i}=jn(),{user:d}=F(),_=(d==null?void 0:d.access_token)||St("token"),[o,l]=y.useState({initialized:!1,authorized:!1,messages:{}}),u=y.useCallback(()=>{if(!a)return new Ne({error:new Error("Missing socket endpoint")}),console.error("Missing socket endpoint");try{const x=new WebSocket(a);x.onopen=()=>{l(m=>U(D({},m),{socket:x,initialized:!0}))},x.onclose=()=>{l(m=>U(D({},m),{socket:void 0})),new Ne({error:new Error("Socket closed")}),clearTimeout(Fe),Fe=setTimeout(()=>{u()},2e3)},x.onerror=()=>{new Ne({error:new Error("Socket Error")})},x.onmessage=m=>{const h=be(m.data);if(h.action===q.AUTH&&l(g=>U(D({},g),{authorized:h.type===Z.AUTHORIZED})),h.body){const g=be(h.body),f=be(h.sender);l(N=>U(D({},N),{messages:U(D({},N.messages),{id:h.id,[h.action]:U(D({},N.messages[h.action]),{[h.type]:g}),sender:f})}))}}}catch(x){l(m=>U(D({},m),{errorMessage:(x==null?void 0:x.message)||"Something went wrong"}))}},[]),c=y.useCallback(({action:x,body:m,type:h,channel:g})=>{if(!o.socket||o.socket.readyState!==WebSocket.OPEN)return;const f=q[x],N=h?Z[h]:void 0;o.socket.send(JSON.stringify({action:f,body:m,type:N,channel:g}))},[o.socket]),v=({action:x,type:m})=>{const h=q[x],g=m?Z[m]:void 0;l(f=>g?U(D({},f),{messages:U(D({},f.messages),{[h]:U(D({},f.messages[h]),{[g]:null})})}):U(D({},f),{messages:U(D({},f.messages),{[h]:null})}))},p=y.useCallback(x=>{c({action:"AUTH",body:`Bearer ${x}`})},[c]);return y.useEffect(()=>{var x;i&&((x=o.socket)==null?void 0:x.readyState)!==WebSocket.OPEN&&u()},[i,u,(n=o.socket)==null?void 0:n.readyState]),y.useEffect(()=>{var x;_&&((x=o.socket)==null?void 0:x.readyState)===WebSocket.OPEN&&p(_)},[p,_,(s=o.socket)==null?void 0:s.readyState]),e.jsx(rt.Provider,{value:U(D({},o),{loading:!o.initialized,initiateSocket:u,sendSocketMessage:c,clearSocketMessage:v}),children:t})},Cn=kn,An=t=>{var n=t,{children:s}=n,a=Sn(n,["children"]);const[i]=y.useState(a);return e.jsx(ct.Provider,{value:i,children:e.jsx(Cn,{children:s})})},Pn=({auction:t,children:n})=>{var s,a,i,d,_,o,l;const[u,c]=y.useState({auction:t,bidInterval:500,bids:[],bidders:[]}),{locale:v}=X(),{supportedCountryCode:p}=pe(),{t:x}=k("auction_common"),{user:m}=F(),{sendSocketMessage:h,clearSocketMessage:g,messages:f,authorized:N,loading:j}=gn(),{data:b,isLoading:w}=Bt({slug:t.slug}),I=y.useRef(void 0),{data:A}=Ae({lang:v,currency:t.currencyCode,country:p??void 0}),[B,J]=y.useState(!1),{trackEvent:E}=ne(),{mutateAsync:T,isPending:re}=Et(),{data:H,isPending:ce}=Ot({auction_key:t.slug},{enabled:!!m}),K=y.useMemo(()=>u.bids.concat(b||[]),[b,u.bids]),se=y.useMemo(()=>{const C=[],z=u.bidders.concat(b||[]);for(let V=0;V<z.length;V++){const G=z[V];C.find(ee=>ee.id===G.id)||C.push(G)}return C},[b,u.bidders]),le=((A==null?void 0:A.total_balance)||0)+((A==null?void 0:A.onhold_amount)||0),ge=!!((s=f[q.AUCTION])!=null&&s[Z.AUCTION_JOIN]),P=((a=f[q.AUCTION])==null?void 0:a[Z.AUCTION_END])||((i=f[q.AUCTION])==null?void 0:i[Z.AUCTION_STATUS]),Te=(d=f[q.AUCTION])==null?void 0:d[Z.AUCTION_BID],ae=K[0],mt=(P==null?void 0:P.increment_by)||u.bidInterval,de=Math.max(ae==null?void 0:ae.amount,P==null?void 0:P.highest_bid_amount)||0,_t=K.length,ue=!!m&&!!de&&(m==null?void 0:m._id)===(ae==null?void 0:ae.id),ht=new Date((P==null?void 0:P.starts_at)||t.startAt)>new Date,je=t.endAt&&new Date(t.endAt)<new Date||!!(P!=null&&P.ended)||B,xt=!!N&&!je,vt=(P==null?void 0:P.highest_bid_user_id)||((_=K==null?void 0:K[0])==null?void 0:_.id),pt=(P==null?void 0:P.reserved_price)||0,Me=de<pt,yt=je&&!!m&&vt===m._id&&!Me;y.useEffect(()=>{const C=P==null?void 0:P.ends_at;if(!C||B)return;const z=24*60*60*1e3,V=Date.now(),Q=new Date(C).getTime()-V;if(Q<=0||Q>z)return;const ee=setTimeout(()=>{J(!0)},Q);return()=>{ee&&clearTimeout(ee)}
1},[P,B]);const ft=le<(P==null?void 0:P.upfront_payment)||!!((o=f[q.AUCTION])!=null&&o[Z.AUCTION_WALLET_ALERT]),oe=(l=f[q.AUCTION])==null?void 0:l[Z.AUCTION_ERROR],gt=y.useMemo(()=>!!se.find(z=>z.id===(m==null?void 0:m._id))&&!ue,[se,ue,m==null?void 0:m._id]),Le=y.useCallback(()=>fe(null,null,function*(){var C;g({action:"AUCTION",type:"AUCTION_WALLET_ALERT"});try{H!=null&&H.isDeposited||(yield T({auction_key:t.slug})),h({action:"AUCTION",type:"AUCTION_JOIN",channel:`auction:${t.slug}`})}catch(z){const V=z,G=(V==null?void 0:V.message)||x("auction_common:deposit_error_message");(C=I.current)==null||C.publish({title:G,type:"error",icon:!0})}}),[t.slug,g,H==null?void 0:H.isDeposited,ge,h]),jt=C=>{g({action:"AUCTION",type:"AUCTION_ERROR"}),h({action:"AUCTION",type:"AUCTION_BID",body:C.toString(),channel:`auction:${t.slug}`})},bt=()=>{g({action:"AUCTION",type:"AUCTION_ERROR"})};return y.useEffect(()=>{N&&(h({action:"SUBSCRIBE",channel:`auction:${t.slug}`}),H!=null&&H.isDeposited&&Le())},[t.slug,N,H==null?void 0:H.isDeposited,h]),y.useEffect(()=>{const C=f.sender,z=Te;if(C&&typeof z=="number"){const V=R(O({},C),{amount:z,date:new Date().toString()});c(G=>{const Q=G.bidders.find(ee=>ee.id===V.id);return R(O({},G),{bids:[V,...G.bids],bidders:Q?G.bidders:[V,...G.bidders]})})}},[Te]),y.useEffect(()=>{ge&&ue&&new Audio("/@wbk/auction/win.mp3").play()},[de]),y.useEffect(()=>{var C;oe&&((C=I.current)==null||C.publish({title:oe,type:"error",icon:!0}),E({event:"error_occured",data:{error_type:"auction_join_error",auction_slug:t.slug,error_message:oe,user_id:m==null?void 0:m._id}}))},[oe,E,t.slug,m==null?void 0:m._id]),e.jsxs(it.Provider,{value:R(O({},u),{bidInterval:mt,notStartedYet:ht,joined:ge,canBid:xt,status:P,currentBid:de,isMyBid:ue,currentBidder:ae,bidders:se,bids:K,outbidded:gt,totalBids:_t,socketLoading:j||ce||re,historyLoading:w,notEnoughWallet:ft,errorMessage:oe,joinAuction:Le,submitBid:jt,clearBidError:bt,ended:je,wonBid:yt,reservePriceNotMet:Me}),children:[e.jsx(ve,{ref:I}),n]})},In=Pn,Bn=()=>{const{auction:t,status:n,currentBid:s,bidders:a,totalBids:i,ended:d,notStartedYet:_}=$(),{t:o}=k("auction_common"),{exchangePrice:l,symbol:u}=Ie(),c=y.useRef(void 0),v=s||(n==null?void 0:n.start_from)||t.startingPrice,p={url:window.location.href,title:t.title,text:`${s>0?o("auction_common:current_bid"):o("auction_common:starting_bid")} ${l(v,t.currencyCode)} ${u}`};return e.jsxs(e.Fragment,{children:[e.jsx(ve,{ref:c}),e.jsx("div",{className:"w-full grow",children:e.jsx("div",{className:"flex flex-col gap-3 lg:flex-row",children:e.jsxs("div",{className:"space-y-M w-full",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx(r,{variant:"heading-XL",className:"break-words",children:t.title}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(qe,{icon:e.jsx(zt,{className:"h-4 w-4 shrink-0"}),data:p,hideText:!0}),e.jsx(an,{event:O({__typename:"Auction"},t),hideLabel:!0})]})]}),e.jsxs(r,{variant:"label-M",className:"text-text-secondary",children:[e.jsx("span",{children:o("auction_common:bidders",{count:a.length})}),e.jsx("span",{children:" · "}),e.jsx("span",{children:o("auction_common:bids",{count:i})})]}),e.jsxs(M,{size:"XS",className:"gap-XS fit px-S flex w-fit items-center !py-1.5",children:[!d&&e.jsx("div",{className:"bg-notice h-2 w-2 rounded-full"}),d?e.jsx(r,{color:"error",variant:"body-S",children:o("auction_common:auction_ended")}):_?e.jsxs(r,{variant:"body-S",children:[o("auction_common:starts_in")," ",e.jsx(ie,{mini:!0,endAt:t.startAt})]}):e.jsxs(r,{variant:"body-S",children:[o("auction_common:ends_in")," ",e.jsx(ie,{mini:!0,endAt:t.endAt})]})]})]})})})]})},En=Bn,On=()=>{const{auction:t,status:n,currentBid:s}=$(),{t:a}=k(["currency_common","auction_common"]),i=(n==null?void 0:n.upfront_payment)||t.upfrontPayment,d=s||(n==null?void 0:n.start_from)||t.startingPrice;return e.jsxs("div",{className:"flex flex-wrap gap-4",children:[e.jsxs("div",{className:"grow",children:[e.jsx(r,{variant:"label-M",className:"text-text-secondary",children:a("auction_common:security_deposit")}),e.jsx(r,{variant:"heading-M",as:"div",children:e.jsx(L,{originalPrice
1:i,currency:t.currencyCode})})]}),e.jsxs("div",{className:"grow",children:[e.jsx(r,{variant:"label-M",className:"text-text-secondary",children:s>0?a("auction_common:current_bid"):a("auction_common:starting_bid")}),e.jsx(r,{variant:"heading-M",as:"div",children:e.jsx(L,{originalPrice:d,currency:t.currencyCode})})]})]})},Ee=On,Tn=()=>{const{mutateAsync:t,isPending:n,isSuccess:s}=Tt(),{locale:a}=X(),{auction:i}=$(),{t:d}=k("auction_common"),{user:_}=F(),o=y.useRef(null),{registerInterestEvent:l}=ne(),u=c=>fe(null,null,function*(){var v,p;const x={venue_id:i.slug,slug:i.slug,name:c.name,phone:c.phone||c.cell_number||"",email:c.email,country_code:c.country||"",type:"auction",lang:a};try{yield t(x),l(x),(v=o.current)==null||v.publish({title:d("auction_common:notify_success")})}catch{(p=o.current)==null||p.publish({title:d("auction_common:notify_error"),type:"error"})}});return e.jsxs(e.Fragment,{children:[e.jsx(ve,{ref:o}),e.jsx(Wt,{children:e.jsx(Ge,{onSuccess:u,render:({open:c})=>e.jsxs("div",{className:"space-y-L",children:[e.jsx(Y,{}),e.jsx(Ee,{}),e.jsxs(M,{className:"space-y-L",children:[e.jsxs("div",{className:"gap-S flex",children:[e.jsx(Jt,{className:"h-6 w-6 shrink-0"}),e.jsxs("div",{children:[e.jsx(r,{variant:"body-L",className:"font-medium",children:d("auction_common:auction_will_start_soon")}),e.jsx(r,{className:"text-text-secondary",children:d("auction_common:get_notified_when_bidding_open")})]})]}),e.jsxs(S,{shape:"outlined",theme:"white",className:"rounded-S flex h-11 w-full items-center",loading:n,disabled:s,onClick:()=>{if(!_)return c();u(_)},children:[e.jsx(qt,{className:"h-5 w-5"}),e.jsx(r,{strong:!0,children:d("auction_common:notify_me")})]})]})]})})})]})},Mn=Tn,Ln=({show:t,onClose:n,onSuccess:s})=>{const{locale:a}=X(),{supportedCountryCode:i}=pe(),{auction:d,status:_}=$(),[o,l]=y.useState(!1),{isMobile:u}=He(),{t:c}=k("auction_common"),{trackEvent:v}=ne(),{data:p}=Ae({lang:a,currency:d.currencyCode,country:i??void 0}),x=(p==null?void 0:p.total_balance)||0,m=(_==null?void 0:_.upfront_payment)||d.upfrontPayment,h=x<m,g=e.jsxs("div",{className:"space-y-6 p-4 lg:p-6",children:[e.jsx(Pe,{className:"mx-auto h-20 w-20"}),e.jsx(r,{className:"text-text-secondary",children:c("auction_common:important_information_desc")}),e.jsxs(M,{className:"overflow-hidden pb-0",children:[e.jsx(r,{variant:"body-S",children:c("auction_common:security_deposit")}),e.jsx(r,{variant:"heading-XL",as:"div",children:e.jsx(L,{originalPrice:m,currency:d.currencyCode,priceClassName:"text-heading-XL font-semibold",currencyClassName:"text-heading-L",className:"[&_svg]:h-6 [&_svg]:w-6"})}),e.jsxs(r,{as:"div",variant:"body-S",className:"pb-M",children:[e.jsx("span",{className:"inline",children:c("auction_common:current_wallet_balance")}),e.jsx(L,{originalPrice:x,className:`ms-1 inline-block ${h?"text-error":"text-success"}`,priceClassName:"text-body-S"})]}),h&&e.jsxs(r,{variant:"body-S",className:"bg-error-800 gap-XXS -mx-4 flex px-4 py-3",children:[e.jsx(Zt,{className:"h-6 w-6"}),c("auction_common:current_wallet_balance_insufficient")]})]}),(d==null?void 0:d.terms)&&e.jsxs("div",{className:"prose text-text",children:[d.terms,e.jsx(Y,{className:"mt-L"})]}),e.jsx(Ut,{label:e.jsx(r,{variant:"body-S",className:"text-text-secondary",children:e.jsx(ye,{i18nKey:"auction_common:terms_and_conditions",children:e.jsx(S,{theme:"transparent",shape:"text",className:"text-text-secondary p-0 underline",as:W,href:`/${a}/terms`})})}),checked:o,onChange:()=>l(!o)})]});return u?e.jsx(Ze,{show:t,className:"pb-28",onClose:n,body:()=>g,stickyFooter:({close:f})=>e.jsx("div",{className:"p-4",children:e.jsx(S,{className:"h-12 w-full",theme:"action",disabled:!o,onClick:()=>{f(),s(),v({event:h?"clicked_on_top_up_wallet":"clicked_on_start_bidding",data:{auction_slug:d.slug}})},children:c(h?"auction_common:top_up_and_join":"auction_common:start_bid")})})}):e.jsx(Ke,{closeButton:!0,show:t,size:"2xl",className:"pb-28",onClose:n,body:()=>g,stickyFooter:({close:f})=>e.jsxs("div",{className:"flex justify-end p-6",children:[e.jsx(S,{theme:"action",shape:"text",className:"h-12",onClick:()=>{f(),n()},children:c("auction_common:cancel")}),e.jsx(S,{className:"h-12",theme:"action",onClick:()=>{f(),s(),v({event:h?"clicked_on_top_up_wallet":"clicked_on_start_bidding",data:{auction_slug:d.slug}})},disabled:!o,children:c(h?"auction_common:top_up_and_join":"auction_common:start_bid")})]})})},$n=Ln,Dn=()=>{const{locale:t}=X(),{supportedCountryCode:n}=pe(),{auction:s,status:a,notEnoughWallet:i,joinAuction:d,bidInterval:_,errorMessage:o}=$(),{user:l,isNewUser:u,loading:c}=F({autoFetch:!0}),[v,p]=y.useState(),{t:x}=k(["auth_common","auction_common"]),{trackEvent:m}=ne(),{data:h}=Ae({lang:t,currency:s.currencyCode,country:n??void 0}),g=(h==null?void 0:h.total_balance)||0,f=(a==null?void 0:a.upfront_payment)||s.upfrontPayment,N=(b=l)=>{!b||u?p("auth"):j("terms")},j=b=>{setTimeout(()=>{p(b)},200)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-L",children:[e.jsx(Y,{}),e.jsx(Ee,{}),!!o&&e.jsx(r,{variant:"body-S",color:"error",children:o}),e.jsx(S,{loading:c,onClick:()=>{m({event:"clicked_on_join_auction",data:{auction_slug:s.slug}}),N()},className:"h-12 w-full",children:e.jsx(r,{variant:"body-L",strong:!0,as:"span",children:x("auction_common:join_auction")})})]}),e.jsx(Ge,{show:v==="auth",onClose:()=>p(void 0),onSuccess:N}),e.jsx($n,{show:v==="terms",onClose:()=>p(void 0),onSuccess:()=>
1{if(!!(l!=null&&l._id)&&g<f||i)return j("wallet");d()}}),e.jsx(It,{show:v==="wallet",onClose:()=>p(void 0),info:e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(r,{variant:"label-S",color:"text-secondary",children:x("auction_common:current_wallet_balance_short")}),e.jsx(r,{variant:"heading-M",as:"div",color:"error",children:e.jsx(L,{originalPrice:g,currency:h==null?void 0:h.currency})})]}),e.jsx(r,{variant:"label-M",color:"text-secondary",children:x("auction_common:top_up_wallet_info",{amount:f-g})})]}),minAmount:g<f?f-g:f,increment:_,redirect:b=>`/auctions/${s.slug}?recharge=${b}`})]})},Xe=Dn,Un=()=>{const{auction:t,status:n,currentBid:s,outbidded:a,isMyBid:i,ended:d,wonBid:_,bidders:o,reservePriceNotMet:l}=$(),{user:u}=F(),{t:c}=k("auction_common"),v=s||(n==null?void 0:n.start_from)||t.startingPrice,p=d&&!_,x=y.useMemo(()=>l?c(d?"auction_common:reserve_not_met_and_auction_ended":a?"auction_common:reserve_not_met_and_out_bidded":"auction_common:reserve_not_met"):_?c("auction_common:won_bid_message"):d?o.find(h=>h.id===(u==null?void 0:u._id))?c("auction_common:lost_bid_message"):null:i?c("auction_common:highest_bid_message"):a?c("auction_common:outbidded"):null,[o,d,i,a,l,c,u==null?void 0:u._id,_]);return e.jsxs(e.Fragment,{children:[e.jsxs(M,{className:"overflow-hidden pb-0",children:[e.jsxs("div",{className:"gap-S flex justify-between",children:[e.jsxs("div",{children:[e.jsxs(r,{variant:"body-S",children:[s>0?c("auction_common:current_bid"):c("auction_common:starting_bid"),i&&` (${c("auction_common:you")} ð)`]}),e.jsx(r,{variant:"heading-M",as:"div",className:"pb-M",children:e.jsx(L,{originalPrice:v,currency:t.currencyCode})})]}),d&&e.jsx(Pe,{className:"h-14 w-14"})]}),s>0&&x&&e.jsxs(r,{variant:"body-S","data-error":a||p||l,className:"bg-success-700 data-[error=true]:bg-error-700 gap-XXS -mx-4 flex px-4 py-3",children:[e.jsx(Qe,{className:"h-5 w-5"}),x]})]}),_&&e.jsx(r,{className:"text-text-secondary",children:c("auction_common:won_bid_message_desc")})]})},ut=Un,Rn=()=>{const{auction:t,status:n,currentBid:s,submitBid:a,bids:i}=$(),{user:d}=F(),{isMobile:_}=He(),o=tt(),{t:l}=k("auction_common"),{trackEvent:u}=ne(),c=+o.watch("other")||+o.watch("amount"),v=s||(n==null?void 0:n.start_from)||t.startingPrice,p=s>0&&v>=+c;y.useEffect(()=>{var m;const h=i==null?void 0:i[0],g=!!d&&(h==null?void 0:h.id)===(d==null?void 0:d._id),f=o.formState.isValid;g&&f&&((m=o.getValues("close"))==null||m())},[s]);const x=()=>{u({event:"confirm_bid",data:{auction_slug:t.slug,amount:c}}),a(c)};return e.jsx(nt,R(O({},o),{children:_?e.jsx(Ze,{closeButton:!0,sectionClassName:"px-M pb-28",stickyHeader:()=>e.jsx(r,{variant:"heading-M",className:"px-M",children:l("auction_common:review_your_bid")}),render:({open:m})=>e.jsx(Ve,{onClick:m}),body:({close:m})=>e.jsx(We,{onClose:()=>{m(),o.reset()}}),stickyFooter:()=>e.jsx("div",{className:"p-M",children:e.jsx(S,{theme:"action",className:"w-full",onClick:x,disabled:p,children:e.jsxs(r,{as:"div",variant:"body-L",className:"gap-XXS flex",strong:!0,children:[l("auction_common:confirm_bid"),c>0&&e.jsx(L,{originalPrice:c,currency:t.currencyCode})]})})})}):e.jsx(Ke,{closeButton:!0,size:"lg",className:"p-M pb-24",stickyHeader:()=>e.jsx(r,{variant:"heading-M",children:l("auction_common:review_your_bid")}),render:({open:m})=>e.jsx(Ve,{onClick:m}),body:({close:m})=>e.jsx(We,{onClose:()=>{m(),o.reset()}}),stickyFooter:({close:m})=>e.jsxs("div",{className:"gap-S p-M flex w-full justify-end",children:[e.jsx(S,{theme:"action",shape:"text",onClick:m,children:e.jsx(r,{variant:"body-L",strong:!0,children:l("auction_common:edit_bid")})}),e.jsx(S,{theme:"action",className:"w-auto",onClick:x,disabled:p,children:e.jsxs(r,{as:"div",variant:"body-L",className:"gap-XXS flex",strong:!0,children:[l("auction_common:confirm_bid"),c>0&&e.jsx(L,{originalPrice:c,currency:t.currencyCode})]})})]})})}))},Ve=({onClick:t})=>{const{auction:n,status:s,canBid:a,currentBid:i,bidInterval:d}=$(),{control:_,getValues:o,setValue:l,handleSubmit:u,formState:{isValid:c}}=Be(),{exchangePrice:v}=Ie(),{t:p}=k("auction_common"),{trackEvent:x}=ne(),m=(s==null?void 0:s.start_from)||n.startingPrice,h=i||m,g=y.useMemo(()=>{const N=h,j=(s==null?void 0:s.start_from)||n.startingPrice;return[1,2,3].map(b=>{const w=i>0?b:b-1,I=d*w,A=N+I,B=A===j;return{text:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(r,{variant:"label-M",as:"div",className:"flex gap-1",children:e.jsx(L,{originalPrice
1:A,currency:n.currencyCode})}),e.jsx(r,{variant:"label-S",as:"div",className:"flex gap-px",color:"text-secondary",children:B?p("auction_common:starting_bid"):e.jsxs(e.Fragment,{children:["+",e.jsx(L,{originalPrice:I,currency:n.currencyCode})]})})]}),value:A.toString()}})},[n.currencyCode,n.startingPrice,d,h,i,s==null?void 0:s.start_from,p]),f=Number(g[0].value);return e.jsxs("form",{className:"space-y-L",onSubmit:u(t),noValidate:!0,children:[e.jsx(r,{variant:"heading-XL",children:p("auction_common:place_bid")}),e.jsx(te,{name:"amount",control:_,defaultValue:"",rules:{deps:"other",validate:N=>{const j=o("other");if(!(!N&&!j))return!!j||N&&+N>=f}},render:({field:N,fieldState:j})=>{var b;return e.jsx(Rt,R(O({},N),{label:"",error:(b=j==null?void 0:j.error)==null?void 0:b.message,onChange:w=>{l("other",""),N.onChange(w)},options:g}))}}),e.jsxs("div",{className:"pt-L !-mb-M",children:[e.jsx(Y,{}),e.jsx(r,{variant:"body-S",color:"text-secondary",className:"bg-body mx-auto h-6 w-16 -translate-y-3 text-center",children:p("auction_common:or")})]}),e.jsx(te,{name:"other",control:_,defaultValue:"",rules:{deps:"amount",validate:N=>{const j=o("amount");if(!(!N&&j))return+j>=f||N&&+N>=f},pattern:{value:/^[1-9]\d*$/,message:p("auction_common:validation.invalid_number")}},render:({field:N,fieldState:j})=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(we,R(O({},N),{type:"number",inputMode:"numeric",label:p("auction_common:your_max_bid"),className:"[&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none",onChange:b=>{const w=b.replace(/\D/g,"");l("amount",""),N.onChange(w)},min:f,error:j==null?void 0:j.invalid,endIcon:e.jsx("div",{className:"mt-2.5 whitespace-nowrap px-2",children:e.jsx(sn,{})}),securityLimit:Math.max(8,f.toString().length+2),hideErrorSpace:!0,hideErrorMark:!0})),e.jsx(r,{variant:"body-S",color:"text-secondary",className:"data-[error=true]:text-error flex gap-1","data-error":j.invalid,children:`${v(f)} ${p("auction_common:or_higher")}`})]})}),e.jsx(S,{className:"h-12 w-full",disabled:!a||!c,onClick:()=>{x({event:"increase_bid",data:{amount_entered:o("amount")||o("other"),auction_slug:n.slug}})},children:e.jsx(r,{variant:"body-L",strong:!0,children:i>0?p("auction_common:increase_bid"):p("auction_common:place_bid")})})]})},We=({onClose:t})=>{const{auction:n,status:s,currentBid:a,currentBidder:i,bidders:d,totalBids:_,ended:o}=$(),{setValue:l,watch:u}=Be(),{t:c}=k("auction_common"),v=u("other")||u("amount"),{user:p}=F(),x=(s==null?void 0:s.start_from)||n.startingPrice,m=a||x,h=+v===x,g=a>0&&m>=+v,f=(i==null?void 0:i.id)===(p==null?void 0:p._id)&&a>0;return y.useEffect(()=>{l("close",t)},[]),e.jsxs("div",{className:"space-y-M",children:[e.jsxs(r,{variant:"label-S",className:"text-text-secondary",children:[e.jsx("span",{children:c("auction_common:bidders",{count:d.length})}),e.jsx("span",{children:" · "}),e.jsx("span",{children:c("auction_common:bids",{count:_})}),e.jsx("span",{children:" · "}),e.jsx("span",{className:"text-text",children:e.jsx(ie,{mini:!0,endAt:n.endAt,ended:o})})]}),f&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Qt,{className:"stroke-success text-transparent"}),e.jsx("span",{children:c("auction_common:bid_lead")})]}),e.jsxs("div",{className:"gap-S xs:flex-row flex flex-col items-center",children:[e.jsxs(M,{className:"w-full grow border-dashed text-center",children:[e.jsx(r,{variant:"body-S",color:"text-secondary",children:e.jsx(ye,{i18nKey:f?"auction_common:current_bid_you":a>0?"auction_common:current_bid":"auction_common:starting_bid",children:e.jsx("strong",{})})}),e.jsx(r,{variant:"heading-XS",as:"div","data-overbidded":!h&&!g,className:"group",children:e.jsx(L,{originalPrice:m,currency:n.currencyCode,className:"justify-center",priceClassName:"group-data-[overbidded=true]:line-through"})})]}),e.jsx("svg",{viewBox:"0 0 35 6",className:"xs:!rotate-0 h-9 w-9 shrink-0 rotate-90 rtl:-rotate-90 rtl:-scale-x-100",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M34.5 3L29.5 0.113249L29.5 5.88675L34.5 3ZM6.16667 3C6.16667 1.52724 4.97276 0.333336 3.5 0.333336C2.02724 0.333336 0.833332 1.52724 0.833332 3C0.833332 4.47276 2.02724 5.66667 3.5 5.66667C4.97276 5.66667 6.16667 4.47276 6.16667 3ZM30 2.5L3.5 2.5L3.5 3.5L30 3.5L30 2.5Z",fill:"white"})}),e.jsxs(M,{className:"bg-success-900 data-[overbidded=true]:bg-error-900 w-full grow text-center",border:!1,"data-overbidded":g,children:[e.jsx(r,{variant:"body-S",color:"text-secondary",children:c(f?"auction_common:your_new_bid":"auction_common:your_bid")}),e.jsx(r,{variant:"heading-XS",as:"div",children:e.jsx(L,{originalPrice
1:+v,currency:n.currencyCode,className:"justify-center"})})]})]}),g&&e.jsxs(r,{variant:"body-S",color:"error",className:"flex gap-1",children:[e.jsx(Qe,{}),c("auction_common:outbidded_long")]}),e.jsx(r,{variant:"body-S",color:"text-secondary",children:c("auction_common:bid_term")})]})},Fn=Rn,Xn=()=>e.jsxs("div",{className:"space-y-L",children:[e.jsx(ut,{}),e.jsx(Fn,{})]}),Vn=Xn,Wn=()=>{const{t}=k("auction_common"),{auction:n}=$();return e.jsxs("div",{className:"space-y-L",children:[e.jsx(Y,{}),e.jsx(Ee,{}),e.jsxs(M,{className:"py-M space-y-S text-center",children:[e.jsx(r,{variant:"label-S",children:t("auction_common:auction_will_start_in")}),e.jsx(r,{variant:"label-L",className:"text-notice",children:e.jsx(ie,{mini:!0,endAt:n.startAt})})]})]})},Hn=Wn,zn=()=>{var t;const{auction:n,ended:s,joined:a,socketLoading:i,notStartedYet:d,status:_}=$(),{user:o,loading:l}=F({autoFetch:!0}),u=(t=n.eventType)==null?void 0:t.includes("offline");return s?e.jsx(ut,{}):u?e.jsx(Mn,{}):d?e.jsx(Hn,{}):!l&&!o?e.jsx(Xe,{}):i||!_?e.jsx("div",{className:"py-20",children:e.jsx(Gt,{className:"mx-auto h-20 w-20"})}):a?e.jsx(Vn,{}):e.jsx(Xe,{})},Gn=zn,Jn=({subscriber:t})=>{const n=t.name.split(" "),s=n[0].charAt(0),a=n[1].charAt(0)||s,i=`${s}${a}`.toUpperCase(),d=i+t.id.slice(-3),{locale:_}=X(),{auction:o}=$(),{user:l}=F(),{t:u}=k("auction_common"),c=!!l&&(l==null?void 0:l._id)===(t==null?void 0:t.id),v=kt({from:new Date(t.date),locale:_,units:["day","hour","minute"],options:{style:"short"}}),p=y.useMemo(()=>Ct(t.id),[t.id]);return e.jsxs("div",{className:"gap-S data-[winner=true]:bg-success-900 flex items-center justify-between",children:[e.jsxs("div",{className:"gap-XS flex items-center",children:[e.jsx(M,{className:"relative flex h-9 w-9 shrink-0 items-center justify-center rounded-full",style:{background:p},children:e.jsx(r,{variant:"label-M",strong:!0,children:i})}),e.jsxs("div",{children:[e.jsxs(r,{variant:"label-M",className:"leading-tight",children:[d,c?` (${u("auction_common:you")})`:""]}),e.jsx(r,{variant:"body-XS",className:"text-text-secondary",children:v||u("auction_common:just_now")})]})]}),e.jsx(r,{as:"div",children:e.jsx(L,{originalPrice:t.amount,currency:o.currencyCode})})]})},qn=Jn,Zn=()=>{const{bids:t,historyLoading:n,ended:s}=$(),{t:a}=k("auction_common"),[i,d]=y.useState(!1),_=5,o=i?t:t.slice(0,_);return e.jsx("ul",{className:"space-y-M py-L",children:n?[1,2,3,4].map(l=>e.jsx("li",{className:"bg-body-dark/10 rounded-S h-10 animate-pulse",children:e.jsx(e.Fragment,{})},l)):o.length>0?e.jsxs(e.Fragment,{children:[e.jsx(Kt,{initial:!1,children:o.map((l,u)=>e.jsxs(Yt.li,{className:"relative",initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.1},children:[u===0&&e.jsx("img",{src:"/@wbk/auction/crown.svg",className:"absolute -top-1 h-9 w-9 -translate-y-1/2 ltr:right-0 ltr:translate-x-1/4 rtl:left-0 rtl:-translate-x-1/4 rtl:-scale-x-100",alt:""}),e.jsx(qn,{subscriber:l})]},u+l.id+l.amount))}),t.length>_&&e.jsx(S,{onClick:()=>d(!i),shape:"outlined",theme:"white",className:"w-full",children:a(i?"auction_common:load_less":"auction_common:load_more")})]}):s?e.jsxs("li",{className:"py-20 text-center",children:[e.jsx(De,{className:"mx-auto h-14 w-14"}),e.jsx(r,{variant:"heading-M",children:a("auction_common:no_bidders_participated")})]}):e.jsxs("li",{className:"py-20 text-center",children:[e.jsx(De,{className:"mx-auto h-14 w-14"}),e.jsx(r,{variant:"heading-M",children:a("auction_common:empty_bids")}),e.jsx(r,{color:"text-secondary",children:a("auction_common:empty_bids_desc")})]})})},Kn=Zn,Yn=()=>{const{auction:t,totalBids:n}=$(),{t:s}=k("auction_common"),a=y.useMemo(()=>{const i={label:`${s("auction_common:bids_title")}${n>0?` (${n})`:""}`,value:"history",content:e.jsx(Kn,{})};return t.overview?[{label:s("auction_common:overview"),value:"overview",content:e.jsx("div",{className:"py-M",children:t.overview})},i]:[i]},[t.overview,s,n]);return e.jsx(Dt,{className:"flex [&>button]:grow",defaultValue:t.overview?"overview":"history",tabs:a})},Qn=Yn,es=()=>{const{t}=k(["currency_common","auction_common"]),{exchangePrice:n}=Ie(),s=y.useRef(void 0);return y.useEffect(()=>{var a,i,d;const _=window.location.search.replace(/\?/g,(p,x)=>x===0?p:"&"),o=new URLSearchParams(_),l=o.get("recharge"),u=o.get("error"),c=(a=l==null?void 0:l.split("/"))==null?void 0:a[0],v=Number(c);u?(i=s.current)==null||i.publish({type:"error",title:e.jsx(r,{variant:"label-S",strong:!0,children:u}),icon:!0}):v>0&&((d=s.current)==null||d.publish({type:"success",title:e.jsx(r,{variant:"label-S",strong:!0,children:t("auction_common:charged_success",{amount:n(v)})}),icon:!0}))},[]),e.jsx(ve,{ref:s})},ts=es,ns=({auction:t})=>{const{socketEndpoint:n}=vn();return e.jsx(An,{endpoint:n,autoInit:!0,children:e.jsxs(In,{auction:t,children:[e.jsx(ts,{}),e.jsxs("div",{className:"space-y-L",children:[e.jsx(En,{}),e.jsx(Gn,{}),e.jsx(Qn,{})]})]})})},Ms=ns,ss=({title:t})=>{const{t:n}=k(["auction_common"]),{locale:s}=X(),{data:a,isLoading:i}=on({lang:s}),d=(a==null?void 0:a.items)||[];return e.jsx("section",{className:"space-y-6 pt-6",children:i?e.jsx("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3",children:Array.from({length:6},(_,o)=>e.jsx(rn,{},o))}):d.length>0?e.jsx(Ft,{className:"gap-x-4 p-1",options:{dragFree:!0},title:t||e.jsx(r,{as:"h2",variant:"heading-L",children:n("auction_common:recommended_auctions")}),arrows:"top",children:d.map(_=>e.jsx("div",{"data-multiple":(d==null?void 0:d.length)>1,className:"group relative w-full shrink-0 sm:basis-[45%] md:basis-[25%] ltr:mr-4",children:e.jsx(cn,{event:_})},_.sys.id))}):null})},Oe=ss,as=t=>{const{t:n}=k(["auction_common"]),{isWinningCard:s,isAwaitingPaymentLink:a,isPaid:i,isPaymentLinkExpired:d,hasEnded:_,isLeading:o}=t,l=Nt.useMemo(()=>s||a?i?{label:n("auction_common:payment_complete"),color:"success"}:d?{label:n("auction_common:payment_link_expired"),color:"error"}:{label:n("auction_common:pending_payment"),color:"secondary"}:_?{label:null,color:"secondary"}:{label:n(o?"auction_common:you_lead":"auction_common:outbid"),color:o?"success":"error"},[s,a,i,d,_,o,n]);return l.label?e.jsx(r,{color:l.color,children:l.label}):null},os=({auction:t,isWinningCard:n})=>{var s,a,i,d,_,o,l;const{t:u}=k(["auction_common"]),{user:c}=F(),{locale:v}=X(),p=Math.max(t.start_from,t.highest_bid_amount),x=!!t.ends_at&&new Date(t.ends_at).getTime()-Date.now()<24*60*60*1e3,m=((s=t.payment_session)==null?void 0:s.status)==="paid",h=c&&t.highest_bid_user_id===c._id,g=!!t.ends_at&&new Date(t.ends_at)<=new Date,f=t.payment_type==="automated",N=!!((i=(a=t.payment_session)==null?void 0:a.expiry)!=null&&i.date)&&new Date(t.payment_session.expiry.date)<new Date,j=!((d=t.payment_session)!=null&&d.waiting_payment_link)&&n&&f,b=n&&!N&&!m&&f;return e.jsx("div",{className:"mb-4",children:e.jsx(M,{border:!!n,className:`curs
1or-pointer ${n||j?"py-6 transition-shadow hover:shadow-lg":"py-4"}`,children:e.jsxs("div",{className:"flex flex-col flex-wrap justify-end gap-4 sm:flex-row sm:items-start sm:gap-6",children:[e.jsxs(W,{to:`/${v}/auction/${t.key}`,className:"flex min-w-0 flex-1 gap-4",children:[e.jsx(Ye,{src:t.poster,alt:t.name,className:`h-28 w-28 shrink-0 overflow-hidden rounded-lg object-cover ${g&&!n?"grayscale":""}`}),e.jsxs("div",{className:"min-w-0 flex-1 justify-center gap-1",children:[e.jsx(as,{isWinningCard:!!n,isAwaitingPaymentLink:!!j,isPaid:m,isPaymentLinkExpired:N,hasEnded:g,isLeading:!!h}),e.jsx(r,{variant:"heading-M",className:"line-clamp-2",children:t.name}),e.jsx("div",{className:"flex items-center gap-2",children:(o=(_=t.payment_session)==null?void 0:_.expiry)!=null&&o.date&&n&&!m?e.jsx(r,{variant:"body-S",color:"text-secondary",children:u("auction_common:pay_before",{date:Ce(t.payment_session.expiry.date,v,{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})})}):e.jsxs(r,{variant:"body-S",color:"text-secondary",children:[u("auction_common:bidders",{count:t.bidders_total})," ⢠",u("auction_common:bids",{count:t.bids_total})]})}),e.jsx(L,{originalPrice:p,className:"text-xl font-semibold"}),!g&&!n&&e.jsxs(r,{as:"span",variant:"body-S",className:`inline-flex max-w-fit items-center gap-1 rounded border-[0.5px] border-gray-800 px-2 py-0.5 ${x?"text-error":""}`,children:[e.jsx("span",{className:"bg-error h-2 w-2 rounded-full"}),e.jsxs("span",{children:[u("auction_common:ends_in")," ",e.jsx(ie,{endAt:t.ends_at,ended:g,mini:!0})]})]})]})]}),e.jsx("div",{className:"flex min-w-[160px] items-center justify-end gap-2 self-end sm:items-center sm:justify-center sm:gap-4",children:b?e.jsxs(e.Fragment,{children:[j&&e.jsx(r,{variant:"body-S",className:"text-text-secondary",children:u("auction_common:payment_link_pending")}),e.jsx(S,{as:W,href:(l=t.payment_session)==null?void 0:l.waiting_payment_link,disabled:j,className:"w-full sm:w-auto",onClick:w=>w.stopPropagation(),children:u("auction_common:pay_now")})]}):g?n&&!f&&!m?e.jsx(r,{variant:"body-S",color:"text-secondary",children:u("auction_common:call_soon")}):null:e.jsx(S,{as:W,href:`/${v}/auction/${t.key}`,theme:h?"action":"primary",shape:h?"outlined":void 0,className:"w-full sm:w-auto",children:u("auction_common:increase_bid")})})]})})})},Se=os,is=()=>{const{locale:t}=X(),{t:n}=k(["auction_common"]),{data:s=[],isLoading:a,error:i}=Je({lang:t}),{user:d}=F(),[_,o]=y.useState("active"),l=y.useMemo(()=>{const c=[],v=[],p=[],x=new Date;for(const m of s){const h=m.ends_at&&new Date(m.ends_at)<=x;h&&d&&(m.highest_bid_user_id===d._id&&m.highest_bid_amount>=Number(m.reserved_price)||m.payment_session&&m.payment_session.waiting_payment_link)?p.push(m):h?v.push(m):c.push(m)}return{hasOrders:c.length>0||v.length>0||p.length>0,active:c,ended:v,winning:p}},[s,d]),u=y.useMemo(()=>_==="active"?l.active:l.ended,[_,l]);return e.jsxs("div",{className:"mb-4 space-y-5",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx(r,{variant:"heading-L",children:n("auction_common:my_bids")}),e.jsxs(S,{as:W,href:`/${t}/profile/bids/purchases`,theme:"action",shape:"outlined",className:"h-9",children:[e.jsx(et,{className:"h-4 w-4"}),n("auction_common:purchases")]})]}),l.winning.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx(r,{as:"h2",variant:"heading-L",children:n("auction_common:you_won")}),e.jsx(r,{color:"text-secondary",variant:"body-S",children:l.winning.some(c=>
1{var v;return((v=c.payment_session)==null?void 0:v.status)!=="paid"})&&n("auction_common:payment_message")})]}),l.winning.map(c=>e.jsx(Se,{auction:c,isWinningCard:!0},c.id))]}),e.jsxs("ul",{className:"flex gap-3 px-0.5",children:[e.jsx("li",{children:e.jsxs(S,{"aria-selected":_==="active",phill:!0,theme:"action",shape:"outlined",className:"aria-[selected=false]:border-paper aria-[selected=false]:text-text-secondary h-9 border-2",onClick:()=>o("active"),children:[n("auction_common:active"),l.active.length>0&&` (${l.active.length})`]})}),e.jsx("li",{children:e.jsxs(S,{"aria-selected":_==="ended",phill:!0,theme:"action",shape:"outlined",className:"aria-[selected=false]:border-paper aria-[selected=false]:text-text-secondary h-9 border-2",onClick:()=>o("ended"),children:[n("auction_common:ended"),l.ended.length>0&&` (${l.ended.length})`]})})]}),i?e.jsx(M,{className:"mx-auto max-w-xl p-6 pb-12",children:e.jsxs("div",{className:"space-y-8",children:[e.jsx(r,{color:"error",variant:"heading-M",className:"text-center",children:(i==null?void 0:i.message)||n("auction_common:unknown_error")}),e.jsx("div",{className:"mx-auto w-full max-w-xs",children:e.jsx(S,{as:W,href:`/${t}`,theme:"action",shape:"outlined",className:"w-full text-lg",children:n("auction_common:go_home")})})]})}):a?e.jsx("div",{className:"space-y-4 py-4",children:[1,2,3,4].map(c=>e.jsx("div",{className:"bg-paper-level-2 h-40 animate-pulse rounded-md xl:h-32"},c))}):u.length>0?e.jsx(y.Suspense,{children:e.jsx("ul",{className:"divide-paper space-y-6 divide-y",children:u.map(c=>e.jsx("li",{children:e.jsx(Se,{auction:c})},`${c.id}-${c.created_at}`))})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container grid min-h-48 place-items-center text-center",children:[e.jsx("span",{className:"flex items-center justify-center",children:e.jsx(Pe,{className:"h-12 w-12"})}),e.jsx(r,{variant:"heading-S",className:"max-w-64",children:n(_==="active"?"auction_common:no_bids_active":"auction_common:no_bids_ended")}),e.jsx(S,{as:W,href:`/${t}/auctions`,theme:"primary",children:n("auction_common:auctions_home")})]}),e.jsx(Oe,{})]})]})},Ls=is,rs=()=>{const{locale:t}=X(),{t:n}=k(["auction_common"]),{data:s=[],isLoading:a,error:i}=Je({lang:t}),{user:d}=F(),_=s.filter(o=>{var l,u;const c=o.payment_session,v=(c==null?void 0:c.status)==="paid",x=!!o.ends_at&&new Date(o.ends_at)<=new Date&&d&&(o.highest_bid_user_id===d._id||(c==null?void 0:c.waiting_payment_link)),m=x&&!v&&((l=c==null?void 0:c.expiry)==null?void 0:l.date),h=m&&new Date(((u=c==null?void 0:c.expiry)==null?void 0:u.date)||0)<new Date;return x&&(!m||!h||v)});return e.jsxs("div",{className:"mb-4 space-y-8",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"mb-2",children:e.jsxs(S,{as:W,href:`/${t}/profile/bids`,shape:"outlined",theme:"transparent",className:"shrink-0 items-center gap-1 px-0 py-0.5 text-xs !ring-0 hover:underline focus:underline",children:[e.jsx(en,{className:"h-2.5 w-2.5 ltr:rotate-180"}),e.jsx(r,{as:"span",variant:"body-XS",children:n("auction_common:back_to_my_bids")})]})}),e.jsx(r,{variant:"heading-L",children:n("auction_common:purchases")})]}),a?e.jsx("div",{className:"space-y-4 py-4",children:[1,2,3,4].map(o=>e.jsx("div",{className:"bg-paper-level-2 h-40 animate-pulse rounded-md xl:h-32"},o))}):i?e.jsx(M,{className:"mx-auto max-w-xl p-6 pb-12",children:e.jsxs("div",{className:"space-y-8",children:[e.jsx(r,{color:"error",variant:"heading-M",className:"text-center",children:(i==null?void 0:i.message)||n("auction_common:unknown_error")}),e.jsx("div",{className:"mx-auto w-full max-w-xs",children:e.jsx(S,{as:W,href:`/${t}`,theme:"action",shape:"outlined",className:"w-full text-lg",children:n("auction_common:go_home")})})]})}):_.length>0?e.jsx(y.Suspense,{children:e.jsx("div",{className:"space-y-4",children:_.map(o=>e.jsx(Se,{auction:o,isWinningCard:!0},o.id))})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"container grid min-h-48 place-items-center text-center",children:[e.jsx(et,{className:"h-12 w-12"}),e.jsx(r,{variant:"heading-S",className:"max-w-48",children:n("auction_common:no_purchases")}),e.jsx(S,{as:W,href:`/${t}/auctions`,theme:"primary",children:n("auction_common:auctions_home")})]}),e.jsx(Oe,{})]})]})},$s=rs,cs=({address:t,order_id:n,render:s})=>{const{t:a}=k("auction_common"),i=tt(),d=i.watch("loading"),_=t?[t.address_details,t.street,t.city,t.country].filter(o=>!!o).join(", "):"";return y.useEffect(()=>{i.reset({country:(t==null?void 0:t.country)||"",city:(t==null?void 0:t.city)||"",cell_country_code:(t==null?void 0:t.cell_country_code)||"",cell_number:(t==null?void 0:t.cell_number)||"",street:(t==null?void 0:t.street)||"",address_details:(t==null?void 0:t.address_details)||"",dialCountry:ze.find(o=>o.code===(t==null?void 0:t.cell_country_code))})},[t]),e.jsx(nt,R(O({},i),{children:e.jsx(Xt,{title:a("auction_common:location.delivery_location"),action:{label:a("auction_common:location.confirm_location"),form:"address-form",loading:d},size:"xl",render:s||(({open:o})=>e.jsxs(M,{className:"flex items-center gap-3",children:[e.jsx(nn,{className:"h-6 w-6 shrink-0"}),e.jsx("div",{className:"grow space-y-1",children:_?e.jsxs(e.Fragment,{children:[e.jsx(r,{children:a("auction_common:location.delivery_location")}),e.jsx(r,{variant:"body-S",color:"text-secondary",children:_})]}):e.jsxs(e.Fragment,{children:[e.jsx(r,{children:a("auction_common:location.no_delivery_address")}),e.jsx(r,{variant:"body-S",className:"text-notice",children:a("auction_common:location.add_delivery_address")})]})}),e.jsx(S,{className:"shrink-0 text-sm underline",type:"button",theme:"white",shape:"text",onClick:o,children:e.jsx(r,{children:a(`auction_common:${_?"edit":"add"}`)})})]})),body:({close:o})=>e.jsx(ls,{onClose:o,order_id:n})})}))},ls=({onClose:t,order_id:n})=>{var s;const{locale:a}=X(),{t:i}=k("auction_common"),{country:d}=pe(),{register:_,control:o,watch:l,setValue:u,handleSubmit:c,formState:{errors:v}}=Be(),{mutateAsync:p,error:x}=Lt(),m=l("country"),h=l("dialCountry"),{data:g,error:f}=$t({country:m||"",lang:a},{enabled:!!m}),N=j=>fe(null,null,function*(){var b;try{u("loading",!0);const w=R(O({},j),{cell_country_code:(b=j.dialCountry)==null?void 0:b.code});yield p(R(O({},w),{lang:a,order_id:n})),t()}finally{u("loading",!1)}});return y.useEffect(()=>{!h&&d&&u("dialCountry",d)},[d,h]),e.jsxs("form",{id:"address-form",onSubmit:c(N),className:"space-y-6",children:[e.jsx(te,{name:"country",control:o,rules:{required:i("auction_common:validation.required")},defaultValue:"",render:j=>{var{field:b}=j,w=b,{onChange:I}=w,A=me(w,["onChange"]),B,J,E;return e.jsx($e,R(O({},A),{id:"country",autoComplete:"off",portal:!1,onChange:T=>{I((T==null?void 0:T.value)||""),u("city","",{shouldValidate:!0})},label:i("auction_common:location.country"),options:ze.map(T=>({id:T.code,value:T.code,text:T.name[a]||T.name.en,icon:e.jsx("img",{className:"shrink-0",src:`https://wbk-assets-backup.s3.eu-west-1.amazonaws.com/flags/w80/${T.code.toLowerCase()}.png`,width:20,height:14,alt:T.name.en})})),error:((B=v.country)==null?void 0:B.message)||((E=(J=x==null?void 0:x.errors)==null?void 0:J.country)==null?void 0:E[0])}))}},`country-${m}`),e.jsx(te,{name:"city",control:o,rules:{required:i("auction_common:validation.required")},defaultValue:"",render:j=>{var{field:b}=j,w=b,{onChange:I}=w,A=me(w,["onChange"]),B,J;return e.jsx($e,R(O({},A),{id:"city",autoComplete:"off",portal:!1,onChange:E=>I((E==null?void 0:E.value)||""),label:i("auction_common:location.city"),options:(B=g||[])==null?void 0:B.map(E=>({id:E._id,value:E.name,text:E.name})),error:((J=v.city)==null?void 0:J.message)||(f==null?void 0:f.message)}))}},`city-${m}-${g==null?void 0:g.length}`),e.jsx(te,{name:"street",control:o,defaultValue:"",rules:{required:i("auction_common:validation.required")},render:({field:j,fieldState:b})=>{var w,I,A;return e.jsx(we,O({label:i("auction_common:location.street"),id:"street",error:((w=b.error)==null?void 0:w.message)||((A=(I=x==null?void 0:x.errors)==null?void 0:I.street)==null?void 0:A[0])},j))}}),e.jsx(we,R(O({label:i("auction_common:location.address_details"),placeholder:i("auction_common:location.address_details_placeholder"),id:"address_details",error:(s=v.address_details)==null?void 0:s.message},_("address_details")),{onChange:j=>{u("address_details",j)}})),e.jsx(Y,{}),e.jsx(r,{as:"div",variant:"heading-L",children:i("auction_common:location.contact_information")}),e.jsx(te,{name:"cell_number",control:o,defaultValue:"",rules:{required:i("auction_common:validation.required"),validate:j=>{var b,w;return((b=h==null?void 0:h.mobile_starts_with)==null?void 0:b.length)?((w=h==null?void 0:h.mobile_starts_with)==null?void 0:w.some(B=>j==null?void 0:j.startsWith(B)))||i("auction_common:validation.invalid_mobile"):!0}},render:j=>{var b=j,{field:w}=b,I=w,{value:A}=I,B=me(I,["value"]),{fieldState:J}=b,E,T,re,H,ce,K;return e.jsx(Vt,R(O({},B),{label:i("auction_common:location.mobile_number"),portal:!1,country:h,mobile:A||"",onChange:(se,le)=>{u(se==="country"?"dialCountry":"cell_number",le)},error:((E=v==null?void 0:v.cell_number)==null?void 0:E.message)||((T=J.error)==null?void 0:T.message)||((H=(re=x==null?void 0:x.errors)==null?void 0:re.cell_number)==null?void 0:H[0]),placeholder:h?`${((ce=h==null?void 0:h.mobile_starts_with)==null?void 0:ce[0])||""}${"x".repeat((((K=h==null?void 0:h.phone_number_lengths)==null?void 0:K[0])||7)-1)}`:""}))}},`phone-${h==null?void 0:h.code}`)]})},ke=cs,ds=({expiry:t})=>{const{locale:n}=X();return e.jsx(M,{size:"XS",border:!1,surface:"level-1",className:"inline-block",children:e.jsx(r,{variant:"body-S",className:"text-start",children:e.jsx(ye,{i18nKey:"auction_common:pay_before_lose",values:{date:Ce(t,n,{dateStyle:"long",timeStyle:"short",timeZone:void 0})},children:e.jsx("span",{className:"font-bold"})})})})},us=ds,ms=({order:t,includePaymentNotice:n})=>{const{t:s}=k(["auction_common"]);return e.jsxs(M,{size:"L",className:"relative space-y-6 pb-10",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Ye,{src:t.poster,alt:t.auction.name,width:64,height:64,className:"rounded-S aspect-1 max-w-28 shrink-0"}),e.jsx(r,{as:"h3",variant:"label-L",children:t.auction.name})]}),e.jsx(Y,{className:"border-dashed"}),t.expiry.date&&n&&e.jsx(us,{expiry:t.expiry.date}),e.jsx(dn,{totals:{gross:t.sub_total,gross_after_discount:0,vat:t.vat_total,net:0,net_after_discount:t.payment_gateway_remaining_amount,security_deposit:-t.wallet_amount},title:e.jsx(r,{variant:"label-L",children:s("auction_common:total")}),className:"hidden lg:block"}),e.jsx(un,{totals:{gross:t.sub_total,gross_after_discount:0,vat:t.vat_total,net:0,net_after_discount:t.payment_gateway_remaining_amount,security_deposit:-t.wallet_amount},title:e.jsx(r,{variant:"heading-M",children:s("auction_common:total")}),className:"lg:hidden"})]})},xe=ms,_s=({payment:t,id:n})=>{const{t:s}=k("auction_common"),{user:a}=F(),{locale:i}=X(),{bookingSource:d}=Ht(),[_,o]=y.useState(!1);At({onShow:()=>{o(!1)}});const{mutateAsync:l,error:u}=Mt(),c=()=>fe(null,null,function*(){o(!0);try{const v=yield l({payment_session_id:n,lang:i,booking_source:d,redirect:`${window.origin}/${i}/payment-success/auctions`,redirect_failed:`${window.origin}/${i}/payment-failed`});v!=null&&v.redirect_url&&(Pt({name:"last_book_page",value:window.location.pathname,expiration:.01}),window.location.href=v.redirect_url)}catch{o(!1)}});return e.jsxs("section",{className:"container relative flex flex-col justify-between gap-6 py-4 lg:flex-row",children:[e.jsxs("div",{className:"grow space-y-8",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{as:"h1",variant:"heading-L",children:s("auction_common:congrats",{name:a!=null&&a.name?`${a==null?void 0:a.name},`:""})}),e.jsx(r,{color:"text-secondary",children:s("auction_common:payment_message")})]}),t.has_delivery_details&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{as:"h2",variant:"heading-M",children:s("auction_common:additional_information")}),e.jsx(ke,{address:t.delivery_details,order_id:n})]}),e.jsx("div",{className:"lg:hidden",children:e.jsx(xe,{order:t,includePaymentNotice:!0})}),e.jsxs("div",{className:"w-full space-y-1 pt-4",children:[(u==null?void 0:u.message)&&e.jsx(r,{color:"error",children:u==null?void 0:u.message}),e.jsx(ln,{totals:{net_after_discount:t.payment_gateway_remaining_amount},loading:_,onClick:c,className:"xs:max-w-xs",disabled:!1}),e.jsx("div",{className:"pt-2",children:e.jsx(r,{variant:"body-XS",color:"text-secondary",children:e.jsxs(ye,{i18nKey:"payment_agree",ns:"auction_common",children:[e.jsx(S,{as:W,shape:"text",theme:"action","data-testid":"ticketing_summary_terms_page_link",className:"text-text-secondary px-0.5 py-0 font-semibold underline",href:`/${i}/terms`,target:"_blank",rel:"noreferrer",children:" "}),e.jsx(S,{as:W,shape:"text",theme:"action","data-testid":"ticketing_summary_privacy_page_link",className:"text-text-secondary px-0.5 py-0 font-semibold underline",href:`/${i}/privacy`,target:"_blank",rel:"noreferrer",children:" "})]})})})]})]}),e.jsx("div",{className:"relative hidden lg:block lg:max-w-[33%]",children:e.jsxs("div",{className:"space-y-6 text-center lg:sticky lg:top-6",children:[e.jsx(xe,{order:t,includePaymentNotice:!0}),e.jsx(mn,{})]})})]})},hs=_s,xs=({id:t,order:n})=>e.jsx(hs,{payment:n,id:t}),Ds=xs,vs=({order:t,order_id:n})=>{const{t:s}=k("auction_common"),a=t.has_delivery_details&&!Object.keys(t.delivery_details||{}).length;return e.jsx(e.Fragment,{children:e.jsxs("section",{className:"container relative flex flex-col justify-between gap-6 py-4 lg:flex-row",children:[e.jsxs("div",{className:"grow space-y-12 overflow-hidden",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(r,{as:"h1",variant:"heading-XL",children:s("auction_common:successful_payment")}),e.jsx(r,{variant:"heading-S",children:s("auction_common:item_delivery")})]}),a&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(r,{variant:"heading-S",children:s("auction_common:additional_details")}),e.jsx(ke,{address:t.delivery_details,order_id:n})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[a&&e.jsx(ke,{address:t.delivery_details,order_id:n,render:({open:i})=>e.jsx(S,{type:"button",theme:"white",onClick:i,children:e.jsx(r,{variant:"body-L",strong:!0,children:s("auction_common:add_delivery_location")})})}),e.jsx(qe,{data:{title:t.auction.name,text:t.auction.name},render:({share:i})=>e.jsxs(S,{theme:"action",shape:"outlined",onClick:i,children:[e.jsx(tn,{}),e.jsx(r,{variant:"body-L",strong:!0,children:s("common:share_auction_details")})]})})]}),e.jsx("div",{className:"lg:hidden",children:e.jsx(xe,{order:t})}),e.jsx(Oe,{title:e.jsx(r,{variant:"heading-S",children:s("auction_common:spotlight_title")})})]}),e.jsx("div",{className:"relative hidden shrink-0 lg:block lg:max-w-[33%]",children:e.jsx("div",{className:"space-y-6 text-center lg:sticky lg:top-6",children:e.jsx(xe,{order:t})})})]})})},ps=vs,ys=({id:t,order:n})=>e.jsx(ps,{order:n,order_id:t}),Us=ys;export{Ms as A,Ls as O,$s as P,Ts as W,Ds as a,Us as b};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.