1import{j as e,aL as S,f as M,cQ as re,B as A,cR as se,H as ne,q as oe,U as ae,cS as ie,a5 as B,au as le,cT as de,ai as ce,aj as ue,p as me,r as pe,cU as xe,aM as fe,cV as he,cW as ye}from"./index-DGo-vssZ.js";import{r as u}from"./vendor-Qgthw7N1.js";import{I as be}from"./ImapConnectionDialog-bvgeU80F.js";import{C as V}from"./calendar-days-COgXMVIl.js";import{U as ge}from"./user-plus-CP6I1wqA.js";import"./ImapProviderPicker-IRBlFdn0.js";import"./index-B1ky1Hhc.js";import"./server-DuiuGkfi.js";const ve=new Set(["showSelector","showNumberInput","connectCalendar","presentQuestionnaire","prepareTimeEntry","presentSelectForm"]);function je(t){for(const r of t)for(const o of r.parts)if(typeof o.type=="string"&&o.type==="tool-completeOnboarding"&&o.state==="output-available")return!0;return!1}const P=["Tax Profile","Add Property","Connect Calendar","Invite Team"];function Ne(t){return t.invitationsSent>0||t.completedModules.includes("invite_team")?4:t.connectedProviders.length>0||t.completedModules.includes("connect_calendar")?3:t.propertiesAdded>0||t.completedModules.includes("add_property")?2:0}function we(){const t=u.useRef(!1),r=u.useRef(new Map),[o,s]=u.useState([]),n=u.useRef([]);n.current=o;const[l,p]=u.useState(!1),[a,d]=u.useState(!1),[x,y]=u.useState(),[i,f]=u.useState(null),[N,b]=u.useState(null),[g,_]=u.useState(0),[Q,c]=u.useState(null);u.useEffect(()=>{const E=localStorage.getItem("accessToken"),I={};E&&(I.Authorization=`Bearer ${E}`),fetch("/api/onboarding/session",{credentials:"include",headers:I}).then(v=>v.ok?v.json():null).then(v=>{v&&_(Ne(v))}).catch(()=>{})},[]);const h=u.useCallback(async E=>{var G;r.current.clear();const I={id:`user-${Date.now()}`,role:"user",parts:[{type:"text",text:E}]};s(C=>[...C,I]),p(!0),d(!0),y(void 0),f("streaming"),b("Thinkingâ¦");const v=`assistant-${Date.now()}`,$={id:v,role:"assistant",parts:[],metadata:{status:"streaming"}};s(C=>[...C,$]);try{const C=localStorage.getItem("accessToken"),U={"Content-Type":"application/json"};C&&(U.Authorization=`Bearer ${C}`);const W=new AbortController,Y=setTimeout(()=>W.abort(),9e4);let F;try{F=await fetch("/api/onboarding/chat",{method:"POST",credentials:"include",headers:U,signal:W.signal,body:JSON.stringify({messages:n.current.concat(I)})})}finally{clearTimeout(Y)}if(!F.ok)throw new Error(`HTTP error: ${F.status}`);const q=(G=F.body)==null?void 0:G.getReader();if(!q)throw new Error("No response body");const J=new TextDecoder;let D="",H="";for(;;){const{done:X,value:Z}=await q.read();if(X)break;D+=J.decode(Z,{stream:!0});const K=D.split(` 2 3`);D=K.pop()??"";for(const ee of K){const te=ee.split(` 4`);for(const z of te)if(z.startsWith("data: "))try{const m=JSON.parse(z.slice(6));if(m.type==="text")H+=m.content,f(null),b(null),s(O=>O.map(T=>{if(T.id!==v)return T;const j=T.parts.filter(R=>R.type!=="text");return{...T,parts:[...j,{type:"text",text:H}]}}));else if(m.type==="tool-call")if(f("tool-call"),b(m.toolName),m.actualToolName&&ve.has(m.actualToolName)){const O={type:`tool-${m.actualToolName}`,toolCallId:m.toolCallId,input:m.input,state:"output-available"};s(T=>T.map(j=>j.id===v?{...j,parts:[...j.parts,O]}:j))}else m.toolCallId&&r.current.set(m.toolCallId,m.input);else if(m.type==="tool-result"){const O=r.current.get(m.toolCallId);r.current.delete(m.toolCallId);const T={type:`tool-${m.toolName}`,toolCallId:m.toolCallId,input:O,output:m.output,state:"output-available"};s(j=>j.map(R=>R.id===v?{...R,parts:[...R.parts,T]}:R))}else if(m.type==="status")f(m.status),b(m.label);else if(m.type==="done"){f(null),b(null);const O=new Date().toISOString();s(T=>T.map(j=>j.id===v?{...j,metadata:{...j.metadata??{},provider:m.provider,model:m.model,status:"done",completedAt:O}}:j))}else m.type==="error"&&y(m.error)}catch(m){console.error("[Onboarding] Failed to parse SSE data:",m)}}}}catch(C){console.error("[Onboarding] Stream error:",C),y(C instanceof Error?C.message:"Stream failed")}finally{p(!1),d(!1),f(null),b(null)}},[]);u.useEffect(()=>{if(t.current)return;t.current=!0;const I=new URLSearchParams(window.location.search).get("calendar_connected");if(I){window.history.replaceState({},"",window.location.pathname),c(I);const v=I==="google"?"Google Calendar":"Outlook Calendar",$={id:`ack-oauth-${Date.now()}`,role:"assistant",parts:[{type:"text",text:`${v}
4 is now connected â REPSShield will start pulling in your property hours automatically.`}]};s([$]),h("")}else h("")},[]);function k(){s([]),y(void 0),t.current=!1}const w=je(o);return{messages:o,send:h,clearMessages:k,setMessages:s,isLoading:l,isStreaming:a,error:x,isComplete:w,pipelineStatus:i,pipelineStatusLabel:N,totalSteps:P.length,modules:P,isFallbackRequired:!!x,sessionStepFloor:g,calendarConnectedViaOAuth:Q}}function Se({currentStep:t}){const r=P.length;return e.jsx("div",{className:"flex items-start gap-0",role:"progressbar","aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":r,"aria-label":`Onboarding step ${t+1} of ${r}: ${P[t]??"Complete"}`,children:P.map((o,s)=>{const n=s<t,l=s===t,p=s===P.length-1;return e.jsxs("div",{className:"flex-1 flex flex-col items-center",children:[e.jsxs("div",{className:"flex items-center w-full",children:[e.jsx("div",{className:S("flex-1 h-px transition-colors duration-300",s===0?"invisible":n||l?"bg-primary/50":"bg-border/60"),"aria-hidden":!0}),e.jsx("div",{className:S("relative shrink-0 flex items-center justify-center rounded-full transition-all duration-300",n?"h-6 w-6 bg-primary text-primary-foreground":l?"h-6 w-6 bg-primary text-primary-foreground shadow-[0_0_0_3px_hsl(var(--primary)/0.18)]":"h-5 w-5 bg-muted border border-border/60 text-muted-foreground/50"),children:n?e.jsx(M,{className:"h-3 w-3",strokeWidth:2.5,"aria-hidden":!0}):l?e.jsx("span",{className:"text-[10px] font-bold",children:s+1}):e.jsx("span",{className:"text-[9px] font-medium",children:s+1})}),e.jsx("div",{className:S("flex-1 h-px transition-colors duration-300",p?"invisible":n?"bg-primary/50":"bg-border/60"),"aria-hidden":!0})]}),e.jsx("span",{className:S("mt-1.5 text-center leading-tight px-0.5 transition-colors duration-300",n||l?"text-[11px] font-medium":"text-[10px] font-normal",n?"text-primary":l?"text-foreground":"text-muted-foreground/40"),children:o})]},o)})})}function ke({toolName:t,args:r,onSubmit:o,disabled:s=!1}){if(t==="showSelector")return e.jsx(Ce,{args:r,onSubmit:o,disabled:s});if(t==="showNumberInput")return e.jsx(Te,{args:r,onSubmit:o,disabled:s});if(t==="presentQuestionnaire"){const n=r;return!(n!=null&&n.steps)||!Array.isArray(n.steps)||n.steps.length===0?null:e.jsx("div",{className:"mt-2 max-w-[90%] overflow-hidden",children:e.jsx(re,{toolCallId:`onboarding-${n.questionnaireId}`,schema:n,onSubmit:o})})}return t==="showSummary"?e.jsx(Me,{args:r,onSubmit:o,disabled:s}):t==="connectCalendar"?e.jsx(Ie,{args:r,disabled:s}):t==="connectGmailImap"?e.jsx(Pe,{args:r,onSubmit:o,disabled:s}):t==="addProperty"?e.jsx(Ee,{args:r}):t==="inviteTeamMember"?e.jsx(Oe,{args:r}):null}function Ce({args:t,onSubmit:r,disabled:o}){const[s,n]=u.useState(null),l=t.options??[];function p(a){o||s!==null||(n(a.id),r(a.label))}return e.jsxs("div",{className:"mt-3 space-y-2.5",children:[t.title&&e.jsx("p",{className:"text-sm font-medium text-foreground",children:t.title}),t.instruction&&e.jsx("p",{className:"text-xs text-muted-foreground/70",children:t.instruction}),e.jsx("div",{className:"flex flex-col gap-2",children:l.map(a=>{const d=s===a.id,x=o||s!==null&&!d;return e.jsxs("button",{type:"button",disabled:x,onClick:()=>p(a),className:S("flex items-start gap-2.5 rounded-xl px-4 py-3 text-sm font-medium w-full text-left","border transition-all duration-150 select-none","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1",d?"bg-primary text-primary-foreground border-primary shadow-sm":x?"border-border/40 bg-muted/20 text-muted-foreground/40 cursor-not-allowed":"border-border/60 bg-background text-foreground hover:border-primary/40 hover:bg-primary/5 curs
4or-pointer shadow-sm"),"aria-pressed":d,children:[e.jsx("span",{className:S("mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full border transition-colors",d?"border-primary-foreground/60 bg-primary-foreground/20":"border-border/50"),children:d&&e.jsx(M,{className:"h-2.5 w-2.5 text-primary-foreground",strokeWidth:3,"aria-hidden":!0})}),e.jsxs("span",{className:"flex flex-col gap-0.5 min-w-0",children:[e.jsx("span",{className:"leading-snug",children:a.label}),a.description&&e.jsx("span",{className:S("text-xs font-normal leading-snug",d?"text-primary-foreground/70":"text-muted-foreground/60"),children:a.description})]})]},a.id)})})]})}function Te({args:t,onSubmit:r,disabled:o}){const[s,n]=u.useState(""),[l,p]=u.useState(!1);function a(){const x=s.trim();!x||l||(p(!0),r(x))}function d(x){x.key==="Enter"&&a()}return l?e.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl border border-primary/40 bg-primary/5 px-4 py-3 text-sm text-foreground shadow-sm",children:[e.jsx(M,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-medium",children:s})]}):e.jsxs("div",{className:"mt-3 space-y-2.5",children:[t.question&&e.jsx("p",{className:"text-sm font-medium text-foreground",children:t.question}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",value:s,onChange:x=>n(x.target.value),onKeyDown:d,placeholder:t.placeholder??"",min:t.min,max:t.max,disabled:o||l,className:S("h-9 w-32 rounded-xl border border-border/60 bg-background px-3 text-sm text-foreground shadow-sm","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","disabled:cursor-not-allowed disabled:opacity-50","[appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none")}),e.jsx(A,{type:"button",size:"sm",disabled:o||l||s.trim()==="",onClick:a,className:"rounded-xl text-xs h-9 px-4 bg-primary hover:bg-primary/90 text-primary-foreground",children:"Save"})]})]})}function Ee({args:t}){const r=(t==null?void 0:t.nickname)??(t==null?void 0:t.address)??(t==null?void 0:t.propertyName)??"Property";return(t==null?void 0:t.error)!=null?e.jsx("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2.5 text-sm text-destructive",children:e.jsxs("span",{children:["Could not add ",r,". Please try again."]})}):e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2.5 text-sm text-foreground",children:[e.jsx(M,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium",children:r})," added successfully."]})]})}function Ie({args:t,disabled:r}){const{openCalendarAuth:o}=ie(),s=(t==null?void 0:t.provider)??"both",n=s==="google"||s==="both",l=s==="microsoft"||s==="both";function p(){o("/onboarding?calendar_connected=google")}function a(){fetch("/api/auth/microsoft/calendar/auth",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({returnUrl:"/onboarding?calendar_connected=microsoft"})}).then(d=>d.json()).then(d=>{d.authUrl&&(window.location.href=d.authUrl)}).catch(console.error)}return e.jsxs("div",{className:"mt-3 space-y-3",children:[(t==null?void 0:t.message)&&e.jsx("p",{className:"text-sm text-muted-foreground/80",children:t.message}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[n&&e.jsxs(A,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:p,className:"flex items-center gap-2 text-sm w-full sm:w-auto rounded-xl border-border/60 hover:border-primary/40 hover:bg-primary/5 shadow-sm",children:[e.jsx(V,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"Connect Google Calendar",e.jsx(B,{className:"h-3.5 w-3.5 shrink-0 opacity-40 ml-auto sm:ml-0","aria-hidden":!0})]}),l&&e.jsxs(A,{type:"button",variant:"outline",size:"sm",disabled:r,onClick:a,className:"flex items-center gap-2 text-sm w-full sm:w-auto rounded-xl border-border/60 hover:border-primary/40 hover:bg-primary/5 shadow-sm",children:[e.jsx(V,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),"Connect Outlook",e.jsx(B,{className:"h-3.5 w-3.5 shrink-0 opacity-40 ml-auto sm:ml-0","aria-hidden":!0})]})]}
4),l&&e.jsx("p",{className:"text-xs text-muted-foreground/70",children:"One connection links both your Outlook Calendar and Mail."})]})}function Pe({args:t,onSubmit:r,disabled:o}){const[s,n]=u.useState(!1),[l,p]=u.useState(!1);return e.jsxs("div",{className:"mt-3 space-y-2.5",children:[(t==null?void 0:t.subtext)&&e.jsx("p",{className:"text-sm text-muted-foreground/80",children:t.subtext}),e.jsxs(A,{type:"button",variant:"outline",size:"sm",disabled:o||l,onClick:()=>n(!0),className:"flex items-center gap-2 text-sm w-full sm:w-auto rounded-xl border-border/60 hover:border-primary/40 hover:bg-primary/5 shadow-sm",children:[e.jsx(le,{className:"h-4 w-4 shrink-0 text-muted-foreground","aria-hidden":!0}),l?"Gmail connected":"Connect Gmail",!l&&e.jsx(B,{className:"h-3.5 w-3.5 shrink-0 opacity-40 ml-auto sm:ml-0","aria-hidden":!0})]}),e.jsx(be,{open:s,onOpenChange:n,onConnected:()=>{p(!0),r("Gmail is connected via IMAP.")}})]})}function Oe({args:t}){const r=(t==null?void 0:t.email)??(t==null?void 0:t.inviteeEmail)??"team member";return(t==null?void 0:t.error)!=null||(t==null?void 0:t.success)===!1?e.jsx("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-destructive/40 bg-destructive/5 px-3 py-2.5 text-sm text-destructive",children:e.jsxs("span",{children:["Could not send invitation to ",r,". Please try again."]})}):e.jsxs("div",{className:"mt-2 flex items-center gap-2 rounded-lg border border-primary/40 bg-primary/5 px-3 py-2.5 text-sm text-foreground",children:[e.jsx(ge,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsxs("span",{children:["Invitation sent to ",e.jsx("span",{className:"font-medium",children:r}),"."]})]})}const Ae={filingStatus:"Filing Status",repType:"REP Type",primaryQualifier:"Primary Qualifier",taxYearGoal:"Tax Year Goal",employmentType:"Employment Type",agiRange:"AGI Range",involvementStyle:"Involvement Style",netRentalIncomeLoss:"Net Rental Income/Loss",primaryGoal:"Primary Goal",priorityFocus:"Priority Focus",trackingHabit:"Tracking Habit",priorYearRepsQualified:"Prior Year REPS",hasActiveCpa:"Active CPA",allowPushback:"AI Coaching",w2HoursPerWeek:"W-2 Hours/Week",otherWorkHoursPerWeek:"Other Work Hours/Week",spouseEmploymentStatus:"Spouse Employment",spouseHoursPerWeek:"Spouse Hours/Week",pmHoursEstimate:"PM Hours Estimate"};function Re(t){return t==null?"â":typeof t=="boolean"?t?"Yes":"No":String(t).replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}function Me({args:t,onSubmit:r,disabled:o}){const[s,n]=u.useState(!1),l=t.taxProfile??{},p=Object.entries(l).filter(([,f])=>f!=null&&f!==""),a=t.propertiesAdded??0,d=t.calendarConnected??!1,x=t.teamMembersInvited??0;function y(){n(!0),r("Looks good â everything is correct.")}function i(){r("Actually, I'd like to make some changes.")}return s?e.jsxs("div",{className:"mt-3 flex items-center gap-2 rounded-xl border border-primary/40 bg-primary/5 px-4 py-3 text-sm text-foreground",children:[e.jsx(M,{className:"h-4 w-4 text-primary shrink-0","aria-hidden":!0}),e.jsx("span",{className:"font-medium",children:"All set! Taking you to your dashboard."})]}):e.jsxs("div",{className:"mt-3 space-y-3 max-w-[92%]",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"Here's a summary of your setup â does everything look right?"}),e.jsxs("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border/40 bg-muted/40",children:[e.jsx(se,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Tax Profile"}),p.length>0&&e.jsxs("span",{className:"ml-auto text-xs text-muted-foreground",children:[p.length," fields"]})]}),p.length===0?e.jsx("p",{className:"px-4 py-2.5 text-xs text-muted-foreground",children:"Skipped"}):e.jsx("div",{className:"px-4 py-2 grid grid-cols-2 gap-x-4 gap-y-1",children:p.map(([f,N])=>e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground leading-tight",children:Ae[f]??f}),e.jsx("span",{className:"text-xs font-medium text-foreground leading-tight",children:Re(N)})]},f))})]}),e.jsx("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[e.jsx(ne,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Properties"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:a===0?"None added":`${a} added`})]})}),e.jsx("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[e.jsx(oe,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Calendar & Email"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:d?"Connected":"Not connected"})]})}),e.jsx("div",{className:"rounded-xl border border-border/50 bg-muted/30 overflow-hidden",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[e.jsx(ae,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0","aria-hidden":!0}),e.jsx("span",{className:"text-xs font-semibold text-foreground",children:"Team"}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:x===0?"No invites sent":`${x} invited`})]})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(A,{size:"sm",disabled:o,onClick:y,className:"bg-primary hover:bg-primary/90 text-primary-foreground rounded-xl text-xs h-8 px-4",children:[e.jsx(M,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":!0}),"Looks good!"]}),e.jsx(A,{size:"sm",variant:"outline",disabled:o,onClick:i,className:"rounded-xl text-xs h-8 px-4 border-border/60",children:"Make changes"})]})]})}const Le=new Set(["tool-showSelector","tool-showNumberInput","tool-presentQuestionnaire","tool-addProperty","tool-connectCalendar","tool-inviteTeamMember","tool-showSummary"]),_e={h1:({children:t})=>e.jsx("p",{className:"font-bold text-sm mt-3 mb-1",children:t}),h2:({children:t})=>e.jsx("p",{className:"font-bold text-sm mt-3 mb-1",children:t}),h3:({children:t})=>e.jsx("p",{className:"font-semibold text-sm mt-2 mb-1",children:t}),h4:({children:t})=>e.jsx("p",{className:"font-semibold text-sm mt-2 mb-0.5",children:t}),ul:({children:t})=>e.jsx("ul",{className:"list-disc pl-4 my-1.5 space-y-0.5",children:t}),ol:({children:t})=>e.jsx("ol",{className:"list-decimal pl-4 my-1.5 space-y-0.5",children:t}),li:({children:t})=>e.jsx("li",{className:"text-sm",children:t}),p:({children:t})=>e.jsx("p",{className:"my-1",children:t}),strong:({children:t})=>e.jsx("strong",{className:"font-semibold",children:t}),a:({href:t,children:r})=>e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-2",children:r}),code:({children:t})=>e.jsx("code",{className:"bg-background rounded px-1 py-0.5 text-xs",children:t})};function Fe(){return e.jsx("span",{className:"inline-flex items-center gap-0.5 h-4","aria-label":"Loading",children:[0,1,2].map(t=>e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current opacity-60",style:{animation:`pulse 1.2s ease-in-out ${t*.2}s infinite`}},t))})}function Qe({message:t,isLatest:r,onToolSubmit:o}){const s=t.role==="user",n=t.parts.filter(i=>i.type==="text").map(i=>i.text).join("").trim(),l=t.parts.filter(i=>!(typeof i.type!="string"||!Le.has(i.type)||i.input==null&&i.args==null)),p=n.length>0||l.length>0,a=r&&!s,d=a&&!p,x=de(n,a),y=a||x.length<n.length;return s&&!n||s&&(n.startsWith("[QUESTIONNAIRE_SUBMIT ")||n.startsWith("[FORM_SUBMIT ")||n.startsWith("[REMEDIATION_
4SUBMIT "))||!s&&!p&&!d?null:s?e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[78%] rounded-2xl rounded-br-md bg-primary text-primary-foreground px-4 py-2.5 text-sm break-words leading-relaxed shadow-sm",children:n})}):e.jsxs("div",{className:"flex flex-col gap-1.5",children:[(n||d)&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-bl-md bg-muted/70 border border-border/30 px-4 py-2.5 text-sm text-foreground break-words overflow-hidden leading-relaxed shadow-sm",children:n?e.jsx("div",{className:"[&>*:first-child]:mt-0 [&>*:last-child]:mb-0",children:y?e.jsx("span",{className:"whitespace-pre-wrap",children:x}):e.jsx(ce,{remarkPlugins:[ue],disallowedElements:["details","summary"],unwrapDisallowed:!0,components:_e,children:n})}):e.jsx(Fe,{})})}),l.map(i=>{const f=i.toolCallId??i.id??i.type,N=i.type.replace(/^tool-/,""),b=i.input??i.args??{};if(N==="addProperty"){if(i.state!=="output-available")return null;const g=i.output;if(!g||typeof g!="object")return null}if(N==="presentQuestionnaire"){const g=i.input??i.args;if(!(g!=null&&g.steps)||!Array.isArray(g.steps))return null}return e.jsx(ke,{toolName:N,args:b,onSubmit:o,disabled:!r},`${t.id}-${f}`)})]})}const $e={single:"Single",mfj:"Married Filing Jointly",mfs:"Married Filing Separately",hoh:"Head of Household",qw:"Qualifying Widow(er)"},De={longTerm:"Long-Term Rentals",shortTerm:"Short-Term Rentals"},Be={w2:"W-2 Employee",self_employed:"Self-Employed",business_owner:"Business Owner",retired:"Retired",full_time_re:"Full-Time Real Estate",selfEmployed:"Self-Employed",w2Employee:"W-2 Employee",unemployed:"Unemployed"};function L({label:t,value:r}){const o=r!=null&&r!=="";return e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-muted-foreground/60 font-medium",children:t}),e.jsx("span",{className:S("text-xs font-medium",o?"text-foreground":"text-muted-foreground/40 italic"),children:o?r:"â"})]})}function Ge(){const{user:t}=me(),[r,o]=u.useState(!1),{data:s}=pe({queryKey:["/api/properties"],queryFn:async()=>{const b=localStorage.getItem("accessToken"),g=await fetch("/api/properties",{credentials:"include",headers:b?{Authorization:`Bearer ${b}`}:{}});return g.ok?g.json():[]},staleTime:3e4}),n=t!=null&&t.filingStatus?$e[t.filingStatus]??t.filingStatus:null,l=t!=null&&t.repType?De[t.repType]??t.repType:null,p=t!=null&&t.employmentType?Be[t.employmentType]??t.employmentType:null,a=(s==null?void 0:s.length)??null,d=!!(t!=null&&t.googleCalendarAccessToken),x=!!(t!=null&&t.microsoftAccessToken),y=d&&x?"Google + Outlook":d?"Google Calendar":x?"Outlook Calendar":null,i=5,f=[n,l,p,a!==null&&a>0?"set":null,y].filter(Boolean).length,N=Math.round(f/i*100);return e.jsxs("div",{className:"border-y border-border/25 bg-muted/20",children:[e.jsxs("button",{type:"button",onClick:()=>o(b=>!b),className:"flex items-center justify-between w-full px-5 sm:px-8 py-2.5 text-muted-foreground hover:text-foreground transition-colors","aria-expanded":r,"aria-controls":"onboarding-summary-panel",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/70",children:"Setup Summary"}),e.jsx("div",{className:"w-16 h-1 rounded-full bg-border/50 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-primary/60 transition-all duration-500",style:{width:`${N}%`}})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("span",{className:"text-[10px] text-muted-foreground/50",children:[N,"%"]}),e.jsx(xe,{className:S("h-3.5 w-3.5 shrink-0 transition-transform duration-200",r&&"rotate-180"),"aria-hidden":!0})]})]}),r&&e.jsx("div",{id:"onboarding-summary-panel",className:"px-5 sm:px-8 pb-3 pt-0.5",children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-x-6 gap-y-2.5",children:[e.jsx(L,{label:"Filing Status",value:n}),e.jsx(L,{label:"REP Type",value:l}),e.jsx(L,{label:"Employment",value:p}),e.jsx(L,{label:"Properties",value:a!==null?a===1?"1 property":`${a} properties`:null}),e.jsx(L,{label:"Calendar",value:y})]})})]})}function Ue({onComplete:t}){const r=fe(),o=u.useRef(null),s=u.useRef(null),[n,l]=u.useState(""),p=u.useRef(!1),a=u.useRef(new Set),{messages:d,send:x,isLoading:y,isComplete:i,calendarConnectedViaOAuth:f,sessionStepFloor:N}=we(),b=(()=>
4{if(!y)return!1;const c=[...d].reverse().find(h=>h.role==="assistant");return c?c.parts.some(h=>typeof h.type=="string"&&h.type==="tool-showSelector"):!1})(),g=(()=>{var h;if(i)return P.length;let c=Math.max(N,f?3:0);for(const k of d)for(const w of k.parts){if(typeof w.type!="string")continue;const E=w.state;w.type==="tool-saveFields"&&E==="output-available"&&((h=w.output)==null?void 0:h.taxProfileComplete)===!0?c=Math.max(c,1):w.type==="tool-addProperty"&&E==="output-available"?c=Math.max(c,2):w.type==="tool-inviteTeamMember"&&E==="output-available"&&(c=Math.max(c,4))}return Math.min(c,P.length)})();u.useEffect(()=>{f&&(r.invalidateQueries({queryKey:["/api/integrations/calendar-status"]}),r.invalidateQueries({queryKey:["/api/auth/user"]}))},[f,r]),u.useEffect(()=>{var c;(c=o.current)==null||c.scrollIntoView({behavior:"smooth"})},[d]),u.useEffect(()=>{for(const c of d)for(const h of c.parts){if(typeof h.type!="string")continue;const k=h.toolCallId??h.id??"";if(a.current.has(k))continue;const w=h.state;h.type==="tool-saveFields"&&w==="output-available"&&(a.current.add(k),r.invalidateQueries({queryKey:["/api/auth/user"]})),h.type==="tool-addProperty"&&w==="output-available"&&(a.current.add(k),r.invalidateQueries({queryKey:["/api/properties"]})),h.type==="tool-connectCalendar"&&(a.current.add(k),r.invalidateQueries({queryKey:["/api/integrations/calendar-status"]}),r.invalidateQueries({queryKey:["/api/auth/user"]})),h.type==="tool-inviteTeamMember"&&w==="output-available"&&(a.current.add(k),r.invalidateQueries({queryKey:["/api/integrations/calendar-status"]}),r.invalidateQueries({queryKey:["/api/auth/user"]}))}},[d,r]),u.useEffect(()=>{if(!i||p.current)return;p.current=!0,r.invalidateQueries({queryKey:["/api/auth/user"]});const c=setTimeout(()=>{t()},1200);return()=>clearTimeout(c)},[i,r,t]);function _(){const c=n.trim();!c||y||(l(""),x(c))}function Q(c){c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),_())}return e.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[e.jsx("div",{className:"shrink-0 px-5 sm:px-8 pt-5 sm:pt-6 pb-4",children:e.jsx(Se,{currentStep:g})}),e.jsx("div",{className:"shrink-0",children:e.jsx(Ge,{})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto","aria-live":"polite","aria-label":"Onboarding conversation",children:e.jsxs("div",{className:"px-5 sm:px-8 pt-4 pb-4 space-y-4",children:[d.map((c,h)=>e.jsx(Qe,{message:c,isLatest:h===d.length-1,onToolSubmit:k=>x(k)},c.id)),i&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl bg-primary/10 border border-primary/20 px-4 py-3 text-sm text-foreground",children:e.jsx("p",{className:"font-medium text-primary",children:"All set â taking you to your dashboard."})})}),e.jsx("div",{ref:o})]})}),e.jsxs("div",{className:"shrink-0 border-t border-border/40 px-5 sm:px-8 pt-3",style:{paddingBottom:"max(env(safe-area-inset-bottom), 1rem)"},children:[e.jsxs("div",{className:S("flex gap-2 items-center",b&&"opacity-50"),children:[e.jsx("input",{ref:s,type:"text",value:n,onChange:c=>l(c.target.value),onKeyDown:Q,placeholder:i?"Onboarding complete":b?"Or type your answerâ¦":"Type a messageâ¦",disabled:y||i,className:S("flex-1 h-11 rounded-xl border border-input bg-background px-4 text-sm","placeholder:text-muted-foreground/60","focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-1","transition-colors disabled:opacity-40 disabled:cursor-not-allowed","shadow-sm"),"aria-label":"Type your message"}),e.jsx(A,{size:"icon",onClick:_,disabled:!n.trim()||y||i,className:"h-11 w-11 shrink-0 rounded-xl bg-primary hover:bg-primary/90 text-primary-foreground shadow-sm disabled:opacity-30","aria-label":"Send message",children:e.jsx(he,{className:"h-4 w-4"})})]}),!i&&!y&&e.jsx("div",{className:"flex justify-center mt-2",children:e.jsx("button",{type:"button",onClick:()=>
4x("Skip everything and take me to the dashboard"),className:"text-xs text-muted-foreground/50 hover:text-muted-foreground transition-colors underline-offset-2 hover:underline",children:"Skip remaining setup"})})]})]})}function Xe({onComplete:t}){const r=u.useRef(!1);async function o(){if(!r.current){r.current=!0;try{await fetch("/api/onboarding/complete",{method:"POST",credentials:"include",headers:(()=>{const s=localStorage.getItem("accessToken");return s?{Authorization:`Bearer ${s}`}:{}})()})}catch{}t()}}return e.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col bg-background",style:{height:"100dvh"},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle at 30% 20%, hsl(var(--primary)) 0%, transparent 60%), radial-gradient(circle at 75% 80%, hsl(var(--primary)) 0%, transparent 55%)"},"aria-hidden":!0}),e.jsxs("header",{className:"relative shrink-0 flex items-center justify-between px-5 sm:px-8",style:{paddingTop:"max(env(safe-area-inset-top), 1rem)",paddingBottom:"0.875rem"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:"/repsshield-logo-main.png",alt:"REPSShield",className:"h-7 w-auto"}),e.jsx("span",{className:"font-semibold text-sm tracking-tight text-foreground",children:"REPSShield"})]}),e.jsx("button",{type:"button",onClick:o,className:"text-xs text-muted-foreground hover:text-foreground transition-colors px-2.5 py-1.5 -mr-1 rounded-lg hover:bg-muted/60",children:"Skip for now"})]}),e.jsx("div",{className:"relative shrink-0 h-px bg-border/40"}),e.jsx(ye,{children:e.jsx("div",{className:"relative flex-1 min-h-0 flex items-center justify-center overflow-hidden px-0 sm:px-4 py-4 sm:py-6",children:e.jsx("div",{className:"w-full max-w-2xl flex flex-col min-h-0 max-h-full overflow-hidden rounded-none sm:rounded-2xl sm:border sm:border-border/40 sm:shadow-lg bg-background",children:e.jsx(Ue,{onComplete:t})})})})]})}export{Xe 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.