1import{u as G,r as g,j as t}from"./vendor-react-BoyrKzsG.js";import{P as I}from"./PageHeader-D3Dh_hTn.js";import{u as y,a as C,e as R,L as w,B as O}from"./index-CKCEYSTE.js";import{C as f}from"./vendor-firebase-DbFCdLkQ.js";/* empty css */import"./vendor-ui-Cy9YOY35.js";const _=()=>{const a=G(),{user:o,loading:d,loadUserProfile:E,userProfile:c}=y(),{lumoVariant:h}=C(),[e,b]=g.useState("checking"),[m,N]=g.useState(null);return g.useEffect(()=>{var r;(r=c==null?void 0:c.subscription)!=null&&r.tier&&!m&&(console.log("[PROCESSING-PAGE] Captured prior tier:",c.subscription.tier),N(c.subscription.tier))},[c,m]),g.useEffect(()=>{let r,i,l=!1;if(f.isNativePlatform()){console.log("[PROCESSING-PAGE] Starting aggressive browser closure loop...");const n=async()=>{try{console.log("[PROCESSING-PAGE] Attempting Browser.close()..."),await O.close()}catch{console.warn("[PROCESSING-PAGE] Browser closure failed (expected if already closed)")}};n();let P=0;r=setInterval(()=>{P++,P>3?clearInterval(r):n()},2e3)}const S=new URLSearchParams(window.location.search),s=localStorage.getItem("bp_onboarding_in_progress")==="true";return S.get("status")==="cancel"&&(b("cancelled"),i=setTimeout(()=>{l||(l=!0,s?a("/profile-setup/",{replace:!0}):a("/subscription/",{replace:!0}))},800)),()=>{r&&clearInterval(r),i&&clearTimeout(i)}},[a]),g.useEffect(()=>{if(e==="cancelled")return;if(!f.isNativePlatform()&&!o&&!d){console.log("[PROCESSING-PAGE] On web without session, showing manual return options");return}if(!o)return;const i=new URLSearchParams(window.location.search).get("tier");console.log("[PROCESSING-PAGE] Session active, starting listener for:",o.uid,"Target Tier:",i);
1const l=R.subscribeToTierUpdate(o.uid,async s=>{console.log("[PROCESSING-PAGE] Subscription update detected. Current Tier:",s);let n=!1;if(i?n=s===i:m?n=s!==m&&s!=="free":n=s!=="free",n){console.log("[PROCESSING-PAGE] Tier target met!",s),l();try{await E(o.uid),console.error("[PROCESSING-PAGE] Profile refreshed successfully")}catch(p){console.error("[PROCESSING-PAGE] Profile refresh failed:",p)}if(localStorage.getItem("bp_onboarding_in_progress")==="true"){const p=localStorage.getItem("lumo_onboarding_progress");if(p)try{const u=JSON.parse(p);u.currentStep=17,u.timestamp=Date.now(),u.planType="pro",localStorage.setItem("lumo_onboarding_progress",JSON.stringify(u))}catch(u){console.error("[PROCESSING-PAGE] Failed to update onboarding progress:",u)}console.log("[PROCESSING-PAGE] Redirecting to onboarding completion..."),a("/profile-setup?step=17",{replace:!0})}else console.log("[PROCESSING-PAGE] Standard success redirect..."),a(`/?upgraded=${s}`,{replace:!0})}}),S=setTimeout(()=>{console.log("[PROCESSING-PAGE] Timeout reached"),l(),b("timeout")},3e4);return()=>{l(),clearTimeout(S)}},[o,a,e,d]),t.jsxs("div",{className:"subscription-status-page processing",children:[t.jsx(I,{title:"Processing..."}),t.jsxs("div",{className:"status-content",children:[t.jsx("div",{className:"status-icon-container",children:t.jsx(w,{pose:"encouraging",size:"medium",variant:h,className:"lumo-bouncing"})}),t.jsx("h1",{children:e==="checking"?`${h==="coffee"?"Lumo":"Blobby"} is checking your status...`:e==="cancelled"?"Action Cancelled":"Still taking a bit..."}),t.jsx("p",{className:"status-message",children:e==="checking"?d?"Initializing session...":!o&&!f.isNativePlatform()?"Payment initiated! If you're using the app, please click 'Return to App' below to see your updated status.":"We're waiting for Stripe to confirm your payment. This usually takes just a few seconds.":e==="cancelled"?"You closed the checkout or cancelled the action. Redirecting back to plans...":"Stripe hasn't confirmed your payment yet. If you completed the payment, it might take another minute to reflect."}),(e==="timeout"||e==="cancelled"||!o&&!d&&e==="checking")&&t.jsxs("div",{className:"status-actions",children:[!f.isNativePlatform()&&t.jsx("a",{href:`bnb://subscription/processing?status=${e==="checking"?"success":"cancel"}`,className:"status-btn primary return-to-app",children:"Return to App"}),t.jsx("button",{className:"status-btn primary",onClick:()=>a("/subscription/"),children:"Back to Plans"})]})]})]})};export{_ as default};
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.