PageSourceSearch

https://onramp-production-app.onrender.com/assets/OnboardingStep4-abZjj5zo.js

js onramp-production-app.onrender.com collected 2026-10-03 11:42:30 UTC 9,293 bytes, 1 lines download raw bytes

1import{q as T,c as F,r as n,b8 as l,j as e,C as D,I as L,J as M,bp as z,e as G,ck as q,ci as E,cl as _,cm as V,cn as H,aJ as Y,B as u,h as v,T as J,L as Q,z as U,ad as W,cf as K}from"./index-CuZ9Rod0.js";import{S as X,B as g}from"./settings-ChiV8AjE.js";function ee(){var w;const{toast:m}=T(),[,S]=F(),[h,N]=n.useState(!1),d=window.Capacitor,r=((w=d==null?void 0:d.isNativePlatform)==null?void 0:w.call(d))??!1,[o,x]=n.useState("unknown"),[c,j]=n.useState("unknown"),[p,b]=n.useState(!1),[i,k]=n.useState(null),[y,P]=n.useState(!1),a=n.useCallback(async()=>{if(r)try{const[s,t]=await Promise.all([l.getBluetoothPermission(),l.getManagerState()]);j(s.permission),x(t.state)}catch{}},[r]);n.useEffect(()=>{r&&a()},[r,a]);const O=n.useCallback(async()=>{if(r){if(y){if(o!=="poweredOn"&&(await a(),(await l.getManagerState()).state!=="poweredOn"))return}else try{const s=await l.initialize();if(x(s.state),P(!0),s.state!=="poweredOn"){await new Promise(f=>setTimeout(f,1e3));const t=await l.getManagerState();if(x(t.state),t.state!=="poweredOn"){const f=await l.getBluetoothPermission();j(f.permission);return}}}catch(s){console.error("[ONBOARDING FLIC] Failed to initialize:",s),x("unavailable");return}b(!0);try{const s=await l.scanForButton();k(s.button)}catch(s){console.error("[ONBOARDING FLIC] Scan failed:",s);const t=s.message||"";t.includes("PAIRING_ALREADY_EXISTS")?m({title:"Stale Bluetooth Pairing",description:'Go to iPhone Settings > Bluetooth, find "Flic 2", tap the (i) icon, and choose "Forget This Device". Then return here and try pairing again.',variant:"destructive",duration:1e4}):m({title:"Scan Failed",description:t||"Failed to scan for Brain Button. Try again.",variant:"destructive"})}finally{b(!1)}}},[r,y,o,a,m]),R=n.useCallback(async()=>{try{await l.requestBluetoothPermission(),setTimeout(a,500),setTimeout(a,1500),setTimeout(a,3e3)}catch(s){console.error("[ONBOARDING FLIC] Permission request failed:",s)}},[a]),A=n.useCallback(async()=>{try{await l.openAppSettings(),setTimeout(a,1e3),setTimeout(a,3e3),setTimeout(a,5e3)}catch(s){console.error("[ONBOARDING FLIC] Open settings failed:",s)}},[a]),B=async s=>{N(!0);try{const t={};s?t.skip=!0:i?t.flicButtonUuid=i.uuid:t.skip=!0,await U("POST","/api/onboarding/step3",t),await W.invalidateQueries({queryKey:["/api/auth/me"]}),K("onboarding_step_completed",{step:3,action:s?"skipped":"completed",flic_paired:!!i}),S("/")}catch(t){m({title:"Error completing onboarding",description:t.message||"Failed to complete onboarding. Please try again.",variant:"destructive"})}finally{N(!1)}},C=c==="denied"||c==="restricted"||o==="unauthorized"||o!=="poweredOn"&&c!=="granted"&&c!=="unknown",I=c==="denied"||c==="restricted"||o==="unauthorized"||o==="poweredOff";return e.jsx("div",{className:"flex min-h-full items-center justify-center bg-background p-4 pb-20",children:e.jsxs("div",{className:"w-full max-w-2xl",children:[e.jsxs("div",{className:"flex justify-center mb-6",children:[e.jsx("img",{src:"/onramp-logo.png",alt:"OnRamp",className:"h-12 w-auto dark:hidden"}),e.jsx("img",{src:"/onramp-logo-white.png",alt:"OnRamp",className:"h-12 w-auto hidden dark:block"})]}),e.jsxs(D,{className:"w-full max-w-2xl",children:[e.jsxs(L,{className:"text-center space-y-2",children:[e.jsx(M,{className:"text-2xl font-bold",children:r?"Connect Your Brain Button":"Get the ONRAMP App"}),e.jsx(z,{className:"text-base",children:r?"Pair a Brain Button to start and stop voice sessions with a single press, even when your phone is locked.":"ONRAMP's AI voice coaching is designed for hands-free use on your mobile device."})]}),e.jsxs(G,{className:"space-y-6",children:[r&&e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:"/BrainButton.png",alt:"Brain Button",className:"w-32 h-32 object-contain",style:{filter:"drop-shadow(0 0 12px rgba(26,160,255,0.2))"}})}),r?C?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 bg-amber-50 dark:bg-amber-950 border border-amber-200 dark:border-amber-800 rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Y,{className:"w-5 h-5 text-amber-600 flex-shrink-0"}),e.jsx("p",{className:"font-medium text-amber-800 dark:text-amber-200",children:"Bluetooth Access Required"})]}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:c==="denied"||o==="unauthorized"?"Bluetooth access was previously declined. To use your Brain Button, please enable Bluetooth for ONRAMP in y
1our phone's settings.":o==="poweredOff"?"Bluetooth is turned off on your device. Please enable Bluetooth to connect your Brain Button.":"To connect a Brain Button for hands-free voice control, ONRAMP needs access to Bluetooth."}),(c==="denied"||o==="unauthorized")&&e.jsxs("div",{className:"mt-2 p-3 bg-amber-100 dark:bg-amber-900 rounded text-xs text-amber-800 dark:text-amber-200 space-y-1",children:[e.jsx("p",{className:"font-medium",children:"If the button below doesn't open the right page:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-0.5",children:[e.jsxs("li",{children:["Open your iPhone ",e.jsx("strong",{children:"Settings"})," app"]}),e.jsxs("li",{children:["Scroll down and tap ",e.jsx("strong",{children:"ONRAMP"})]}),e.jsxs("li",{children:["Turn on ",e.jsx("strong",{children:"Bluetooth"})]}),e.jsx("li",{children:"Return to this app"})]})]})]}),I?e.jsxs(u,{onClick:A,className:"w-full",children:[e.jsx(X,{className:"w-4 h-4 mr-2"}),"Open Settings"]}):e.jsxs(u,{onClick:R,className:"w-full",children:[e.jsx(g,{className:"w-4 h-4 mr-2"}),"Continue"]})]}):i?e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"p-4 bg-muted/50 rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"w-5 h-5 text-green-700"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:i.nickname||i.name||"Brain Button"}),e.jsx("p",{className:"text-xs text-muted-foreground capitalize",children:i.state})]})]}),i.batteryVoltage>0&&e.jsxs(J,{variant:i.batteryVoltage<2.65?"destructive":"secondary",children:[i.batteryVoltage.toFixed(2),"V"]})]}),e.jsxs("div",{className:"text-sm space-y-1",children:[e.jsxs("p",{className:"flex items-center gap-2 text-green-700",children:[e.jsx(v,{className:"w-4 h-4"}),"Button paired successfully"]}),e.jsx("p",{className:"text-muted-foreground text-xs ml-6",children:"Press your Brain Button to start or stop a voice session"})]})]})}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(u,{onClick:O,disabled:p,className:"w-full",children:[e.jsx(g,{className:"w-4 h-4 mr-2"}),p?"Scanning for Brain Button...":"Pair Brain Button"]}),p&&e.jsxs("div",{className:"flex flex-col items-center gap-3 py-2",children:[e.jsx(g,{className:"w-10 h-10 text-blue-500 animate-pulse"}),e.jsxs("p",{className:"text-base text-center text-muted-foreground",children:[e.jsx("span",{className:"font-bold text-foreground",children:"PRESS AND HOLD"})," your Brain Button to pair it with ONRAMP"]})]})]}):e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-center gap-6",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"rounded-xl bg-blue-50 dark:bg-blue-950 p-3",children:e.jsx(q,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"iPhone"})]}),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"rounded-xl bg-blue-50 dark:bg-blue-950 p-3",children:e.jsx(E,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Headset"})]}),e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("div",{className:"rounded-xl bg-blue-50 dark:bg-blue-950 p-3",children:e.jsx(_,{className:"w-8 h-8 text-blue-600 dark:text-blue-400"})}),e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Brain Button"})]})]}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"ONRAMP Works Best on Mobile"}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"Download the ONRAMP app on your iPhone or Android phone, log in, and all your jobs will be ready for hands-free AI voice coaching with your Bluetooth headset and Brain Button."})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx("div",{className:"rounded-lg bg-white p-3",children:e.jsx(V,{value:H,size:140})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Scan with your phone's camera to get the app"})]})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx(u,{type:"button",variant:"outline",className:"flex-1",onClick:()=>B(!0),disabled:h,children:"Skip for Now"}),e.jsx(u,{type:"button",className:"flex-1",onClick:()=>B(!1),disabled:h,children:h?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"w-4 h-4 mr-2 animate-spin"}
1),"Finishing..."]}):"Go to Dashboard"})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"You can pair or change your Brain Button later under Profile."})]})]})]})})}export{ee 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.