1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8537],{37329:(e,t,a)=>{a.d(t,{C:()=>s,P:()=>p});var r=a(37876),l=a(14232),n=a(61941),o=a(68761);let c=(0,l.createContext)(),i="paymentSession",u="paymentChargedSummary";function s(e){let{children:t}=e,{user:a}=(0,n.As)(),{dates:s}=(0,o.Jy)(),[p,d]=(0,l.useState)(null),[m,S]=(0,l.useState)([]),[g,f]=(0,l.useState)(null),[y,v]=(0,l.useState)(null),[C,h]=(0,l.useState)(null),[k,b]=(0,l.useState)(null),[w,I]=(0,l.useState)(""),[A,x]=(0,l.useState)(null),[D,N]=(0,l.useState)({isApplied:!1,couponCode:"",discount:null,prices:null}),E={firstName:"",lastName:"",email:"",phone:"",countryCode:"+52"},[T,J]=(0,l.useState)(E),[O,_]=(0,l.useState)(!1),[M,P]=(0,l.useState)(E),L=(0,l.useCallback)(()=>{J(E),_(!1),P(E)},[]),[F,j]=(0,l.useState)(0),[B,q]=(0,l.useState)(1),[z,G]=(0,l.useState)(!1),[H,K]=(0,l.useState)(!1),[Q,R]=(0,l.useState)(null),[U,V]=(0,l.useState)(!1),[W,X]=(0,l.useState)(!1),[Y,Z]=(0,l.useState)(!1),[$,ee]=(0,l.useState)(!1),[et,ea]=(0,l.useState)(!1),[er,el]=(0,l.useState)(null),en=(0,l.useCallback)(e=>{try{e?localStorage.setItem(u,JSON.stringify({...e,savedAt:Date.now()})):localStorage.removeItem(u)}catch(e){console.error("Error persisting chargedSummary:",e)}el(e)},[]);(0,l.useEffect)(()=>{try{let e=localStorage.getItem(u);if(!e)return;let t=JSON.parse(e),a=(null==t?void 0:t.savedAt)&&Date.now()-t.savedAt<18e5;(null==t?void 0:t.amount)&&(null==t?void 0:t.currency)&&a?el({amount:t.amount,currency:t.currency,reservationId:t.reservationId||null}):localStorage.removeItem(u)}catch(e){console.error("Error reading chargedSummary:",e)}},[]),(0,l.useEffect)(()=>{V(!0)},[]);let eo=(0,l.useCallback)(e=>{if(!U)return null;try{let t=localStorage.getItem(e);return t&&"null"!==t&&"undefined"!==t?t:null}catch(t){return console.error("Error getting ".concat(e," from localStorage:"),t),null}},[U]),ec=(0,l.useCallback)((e,t)=>{if(U)try{localStorage.setItem(e,t)}catch(t){console.error("Error setting ".concat(e," in localStorage:"),t)}},[U]),ei=(0,l.useCallback)(e=>{if(U)try{localStorage.removeItem(e)}catch(t){console.error("Error removing ".concat(e," from localStorage:"),t)}},[U]),eu=(0,l.useCallback)((e,t,a,r)=>{N({isApplied:!0,couponCode:e,discount:t,prices:a,couponId:r}),x(t)},[]),es=(0,l.useCallback)(()=>{N({isApplied:!1,couponCode:"",discount:null,prices:null}),x(null)},[]);(0,l.useCallback)(()=>{if(!U)return;let e=eo("paymentStep"),t=eo("paymentListingId");if(e){let t=parseInt(e,10);!isNaN(t)&&t>0&&t<=3&&q(t),t<=1&&a&&q(2)}else a?q(2):q(1);t&&v(t)},[U,eo,a]);let ep=(0,l.useCallback)(e=>{q(e),ec("paymentStep",e.toString()),e>=2&&y&&ec("paymentListingId",y)},[y,ec]);(0,l.useCallback)(()=>{G(!0)},[]);let ed=()=>{try{let e=eo(i);return e?JSON.parse(e):null}catch(e){return null}},em=()=>{ei(i)},eS=(0,l.useCallback)(()=>{Q&&(clearInterval(Q),R(null))},[Q]),eg=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,r=!(arguments.length>2)||void 0===arguments[2]||arguments[2],l={sessionId:"payment_".concat(Date.now(),"_").concat(Math.random().toString(36).substr(2,9)),propertyId:e,bookingDates:t,startTime:Date.now(),expirationTime:Date.now()+3e5,isActive:!0};ec(i,JSON.stringify(l)),X(!1);let n=a?2:1;q(n),ec("paymentStep",n.toString()),r?ef(l):ea(!0)},ef=e=>{let t=e||ed();if(!t||(eS(),t.completedAt||!t.isActive))return;let a=setInterval(()=>{let e=Date.now(),r=Math.max(0,t.expirationTime-e);j(r),K(!0),r<=0&&(clearInterval(a),R(null),ey())},1e3);R(a)},ey=()=>{G(!0);let e=ed();e&&(e.isActive=!1,e.expiredAt=Date.now(),ec(i,JSON.stringify(e)))},ev=(0,l.useCallback)(()=>{ee(!0),ea(!1);let e=ed();e&&et&&ef(e)},[et]),eC=(0,l.useCallback)(()=>{ee(!1),ea(!1)},[]),eh=(0,l.useCallback)(function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;if(!U||!g)return;let r=ed(),l=r&&r.propertyId===g&&(e=r.bookingDates,!!e&&!!s&&e.length===s.length&&e.every((e,t)=>e===s[t])),n=t>=28,o=!n||$;if(r&&l||eC(),!r)return void eg(g,s,o);if(!l){r.propertyId,em(),eg(g,s,o);return}if(r.completedAt||!r||!r.expirationTime||Date.now()>=r.expirationTime){em(),eC(),eg(g,s,o);return}if(!(!r||!r.startTime||!r.expirationTime||!r.isActive||r.completedAt||r.expiredAt||Date.now()>=r.expirationTime)&&1){let e=a?2:1;B!==e&&q(e),n&&!$?ea(!0):ef(r);return}em(),eC(),eg(g,s,o)}
1,[U,g,s,a,$,eC]),ek=(0,l.useCallback)(()=>{X(!0),eS();let e=ed();e&&(e.isActive=!1,e.completedAt=Date.now(),ec(i,JSON.stringify(e)))},[eS,ec]),eb=(0,l.useCallback)(()=>{Q&&(clearInterval(Q),R(null)),ei(i),ei("paymentStep"),ei("paymentListingId"),ep(1),q(1),j(0),K(!1),v(null),G(!1),X(!1),ee(!1),ea(!1),es()},[Q]),ew=(0,l.useCallback)(()=>{Z(!0),eS(),ei(i),ei("paymentStep"),ei("paymentListingId"),window.location.reload()},[eS,ei]),eI=(0,l.useCallback)(()=>{if(F<=0)return"00:00";let e=Math.floor(F/6e4),t=Math.floor(F%6e4/1e3);return"".concat(String(e).padStart(2,"0"),":").concat(String(t).padStart(2,"0"))},[F]),eA=(0,l.useCallback)(()=>1>Math.floor(F/6e4)?"#FB0C23":"#232426",[F]),ex=(0,l.useCallback)(()=>({isCompleted:W,displayTime:eI(),shouldShowTimer:!W&&H}),[W,eI,H]);return(0,l.useEffect)(()=>()=>{Q&&clearInterval(Q)},[Q]),(0,r.jsx)(c.Provider,{value:{property:p,setProperty:d,allowedDates:m,setAllowedDates:S,listingId:y,setListingId:v,nickname:g,setNickname:f,secretClient:C,setSecretClient:h,idPayment:k,setIdPayment:b,reservationId:w,setReservationId:I,couponDiscount:A,setCouponDiscount:x,appliedCoupon:D,applyCoupon:eu,removeCoupon:es,guest:T,setGuest:J,bookingForSomeoneElse:O,setBookingForSomeoneElse:_,stayGuest:M,setStayGuest:P,resetGuest:L,remainingTime:F,currentStep:B,showTimeoutDialog:z,timerInitialized:H,updateStep:ep,clearPaymentData:eb,getFormattedTime:eI,getTimeColor:eA,handleTimeoutConfirm:ew,initializeTimer:eh,isClient:U,paymentCompleted:W,restartingSession:Y,markPaymentCompleted:ek,getTimerStatus:ex,longStayApproved:$,approveLongStay:ev,pendingTimerStart:et,resetLongStayState:eC,chargedSummary:er,setChargedSummary:en},children:t})}function p(){let e=(0,l.useContext)(c);if(!e)throw Error("usePaymentContext must be used within a PaymentProvider");return e}},70713:(e,t,a)=>{function r(e,t){return t?"en"!==e&&e?"/".concat(e,"/wci/").concat(t,"/checkin"):"/wci/".concat(t,"/checkin"):"en"!==e&&e?"/".concat(e,"/wci"):"/wci"}function l(e,t){return t?"en"!==e&&e?"/".concat(e,"/wci/").concat(t,"/reservation"):"/wci/".concat(t,"/reservation"):"en"!==e&&e?"/".concat(e,"/wci"):"/wci"}a.d(t,{F:()=>l,S:()=>r})}}]);
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.