1import{S as N,o as z,s as I,l as Y,r as C,e as $,j as e,bJ as J,R as q,ap as H,bK as X,Y as M,bL as O,d as W,h as L,aI as E,X as Z,bM as ee,ae as A,a2 as R,bN as se,bd as te,bO as ne,a3 as B,bP as oe,k as U,bQ as Q,aQ as ae,bR as re,aL as ie,ax as ce,bS as le,L as de,a4 as pe,bT as ue,bU as he}from"./vendor-CrQ2QQj8.js";import{H as me}from"./Helmet-DDYKHY5s.js";import{B as v,h as F,I as _e,D as ge,a as xe,b as je,c as ve,d as fe,e as Ce,i as k,j as Se,A as ye,k as Ne,l as we,u as be}from"./index-C0sApmKC.js";import{u as K}from"./useUserSetup-O3Oap4tc.js";import{u as Ie}from"./useOneDriveAuth-DU2rvjVH.js";import{S as Te}from"./SharedDriveAssignmentDialog-DgzozEO2.js";import{S as De}from"./SystemConnectionsManager-COTx2CgB.js";import{T as Fe,a as ze,b as V,c as G}from"./Tabs-BE541jq7.js";import{g as ke}from"./status_GET.schema-CXpZ-nrl.js";import"./index-BbP3371Q.js";import"./useDebounce-BojFhJ1l.js";import"./Popover-B0J-dgkS.js";import"./Command-CjJdE0VQ.js";import"./Progress-BMfx4Y07.js";import"./index-DSaFsQCx.js";const Ae=z({accessToken:I().min(1,"Access token is required")}),Pe=async(n,t)=>{const l=Ae.parse(n),o=await fetch("/_api/onedrive/accounting-folder/setup",{method:"POST",body:N.stringify(l),...t,headers:{"Content-Type":"application/json"}}),s=await o.text();if(!o.ok){const c=N.parse(s);throw new Error(c.error)}return N.parse(s)},Oe=z({accessToken:I().min(1,"Access token is required")}),Be=async(n,t)=>{const l=Oe.parse(n),o=await fetch("/_api/onedrive/accounting-folder/verify",{method:"POST",body:N.stringify(l),...t,headers:{"Content-Type":"application/json"}}),s=await o.text();if(!o.ok)try{const c=N.parse(s);throw new Error(c.error)}catch{throw new Error("An unexpected error occurred during verification.")}return N.parse(s)},Le=z({error:I()});z({id:I(),name:I(),path:I(),hasChildren:Y()});const Ee=z({accessToken:I().min(1,"Access token is required"),path:I().optional()}),$e=async(n,t)=>{const l=Ee.parse(n),o=await fetch("/_api/onedrive/folders/browse",{method:"POST",body:N.stringify(l),...t,headers:{"Content-Type":"application/json"}});if(!o.ok){const s=N.parse(await o.text()),c=Le.parse(s);throw new Error(c.error)}return N.parse(await o.text())},qe="_container_ozuar_1",He="_header_ozuar_10",Me="_navigation_ozuar_16",Re="_breadcrumbs_ozuar_22",Ve="_breadcrumb_ozuar_22",Ge="_separator_ozuar_56",We="_content_ozuar_61",Ue="_loadingState_ozuar_67",Qe="_folderItemSkeleton_ozuar_73",Ke="_errorState_ozuar_80",Ye="_emptyState_ozuar_90",Je="_folderList_ozuar_104",Xe="_folderItem_ozuar_73",Ze="_selected_ozuar_124",es="_folderInfo_ozuar_129",ss="_folderIcon_ozuar_137",ts="_folderName_ozuar_142",ns="_folderActions_ozuar_149",os="_selectedIcon_ozuar_156",as="_footer_ozuar_160",rs="_selectedInfo_ozuar_170",is="_selectedLabel_ozuar_178",cs="_selectedPath_ozuar_184",m={container:qe,header:He,navigation:Me,breadcrumbs:Re,breadcrumb:Ve,separator:Ge,content:We,loadingState:Ue,folderItemSkeleton:Qe,errorState:Ke,emptyState:Ye,folderList:Je,folderItem:Xe,selected:Ze,folderInfo:es,folderIcon:ss,folderName:ts,folderActions:ns,selectedIcon:os,footer:as,selectedInfo:rs,selectedLabel:is,selectedPath:cs},ls=({accessToken:n,onFolderSelect:t})=>{const[l,o]=C.useState("root"),[s,c]=C.useState(""),[a,h]=C.useState([{name:"My Files",path:"root"}]),{data:f,isFetching:y,error:r,refetch:x}=$({queryKey:["onedrive-folders",l],queryFn:()=>$e({accessToken:n,path:l}),enabled:!!n}),w=i=>{i.hasChildren&&(o(i.path),h([...a,{name:i.name,path:i.path}]))},b=(i,T)=>{o(i),h(a.slice(0,T+1))},j=()=>
1{if(a.length>1){const i=a.slice(0,-1),T=i[i.length-1].path;o(T),h(i)}},p=i=>{c(i)},S=()=>{s&&t(s)},P=()=>y?e.jsx("div",{className:m.loadingState,children:Array.from({length:5}).map((i,T)=>e.jsxs("div",{className:m.folderItemSkeleton,children:[e.jsx(F,{style:{width:"24px",height:"24px"}}),e.jsx(F,{style:{width:"200px",height:"1rem"}})]},T))}):r?e.jsxs("div",{className:m.errorState,children:[e.jsxs("p",{children:["Failed to load folders: ",r.message]}),e.jsx(v,{variant:"outline",size:"sm",onClick:()=>x(),children:"Retry"})]}):!f||f.folders.length===0?e.jsxs("div",{className:m.emptyState,children:[e.jsx(O,{size:48}),e.jsx("p",{children:"No folders found in this location"})]}):e.jsx("div",{className:m.folderList,children:f.folders.map(i=>e.jsxs("div",{className:`${m.folderItem} ${s===i.path?m.selected:""}`,onClick:()=>p(i.path),onDoubleClick:()=>w(i),children:[e.jsxs("div",{className:m.folderInfo,children:[e.jsx(O,{className:m.folderIcon}),e.jsx("span",{className:m.folderName,children:i.name})]}),e.jsxs("div",{className:m.folderActions,children:[s===i.path&&e.jsx(M,{size:16,className:m.selectedIcon}),i.hasChildren&&e.jsx(v,{variant:"ghost",size:"icon",onClick:T=>{T.stopPropagation(),w(i)},children:e.jsx(H,{size:16})})]})]},i.id))});return e.jsxs("div",{className:m.container,children:[e.jsx("div",{className:m.header,children:e.jsxs("div",{className:m.navigation,children:[e.jsx(v,{variant:"ghost",size:"icon",onClick:j,disabled:a.length<=1,children:e.jsx(J,{size:16})}),e.jsx("nav",{className:m.breadcrumbs,children:a.map((i,T)=>e.jsxs(q.Fragment,{children:[T>0&&e.jsx(H,{size:14,className:m.separator}),e.jsxs("button",{onClick:()=>b(i.path,T),className:m.breadcrumb,children:[T===0&&e.jsx(X,{size:14}),i.name==="My Files"?T>0?i.name:null:i.name]})]},i.path))})]})}),e.jsx("div",{className:m.content,children:P()}),s&&e.jsxs("div",{className:m.footer,children:[e.jsxs("div",{className:m.selectedInfo,children:[e.jsx("span",{className:m.selectedLabel,children:"Selected:"}),e.jsx("span",{className:m.selectedPath,children:s})]}),e.jsxs(v,{onClick:S,children:[e.jsx(M,{size:16}),"Select This Folder"]})]})]})},ds=z({error:I()}),ps=z({accessToken:I().min(1,"Access token is required"),folderPath:I().min(1,"Folder path is required")}),us=async(n,t)=>{const l=ps.parse(n),o=await fetch("/_api/onedrive/folders/validate",{method:"POST",body:N.stringify(l),...t,headers:{"Content-Type":"application/json"}});if(!o.ok){const s=N.parse(await o.text()),c=ds.parse(s);throw new Error(c.error)}return N.parse(await o.text())},hs=z({error:I()}),ms=z({customFolderPath:I().min(1,"Custom folder path is required")}),_s=async(n,t)=>{const l=ms.parse(n),o=await fetch("/_api/user/onedrive-folder",{method:"POST",body:N.stringify(l),...t,headers:{"Content-Type":"application/json"}});if(!o.ok){const s=N.parse(await o.text()),c=hs.parse(s);throw new Error(c.error)}return N.parse(await o.text())},gs=n=>{const[t,l]=C.useState(null),[o,s]=C.useState(null),c=W(),a=L({mutationFn:r=>{if(!n)throw new Error("Access token is required");return us({accessToken:n,folderPath:r})},onSuccess:r=>{l(r),s(null)},onError:r=>{s(r.message),l({isValid:!1,error:r.message})}}),h=L({mutationFn:r=>_s({customFolderPath:r}),onSuccess:()=>{c.invalidateQueries({queryKey:["user"]}),s(null)},onError:r=>{s(r.message)}});return{validateFolder:async r=>{if(!n)return console.error("Cannot validate folder: Access token is null"),!1;try{return(await a.mutateAsync(r)).isValid}catch{return!1}},saveCustomFolderPath:async r=>{await h.mutateAsync(r)},isValidating:a.isPending,isSaving:h.isPending,validationResult:t,error:o}},xs="_container_spmpp_1",js="_currentConfig_spmpp_11",vs="_configInfo_spmpp_18",fs="_configIcon_spmpp_25",Cs="_configDetails_spmpp_37",Ss="_configLabel_spmpp_42",ys="_configPath_spmpp_49",Ns="_configStatus_spmpp_58",ws="_configContainer_spmpp_62",bs="_configHeader_spmpp_73",Is="_configTitle_spmpp_81",Ts="_configContent_spmpp_94",Ds="_inputSection_spmpp_100",Fs="_label_spmpp_106",zs="_inputGroup_spmpp_112",ks="_pathInput_spmpp_118",As="_inputHelp_spmpp_124",Ps="_validationResult_spmpp_131",Os="_validationSuccess_spmpp_141",Bs="_validationError_spmpp_147",Ls="_errorMessage_spmpp_153",Es="_configActions_spmpp_165",$s="_browserDialog_spmpp_173",_={container:xs,currentConfig:js,configInfo:vs,configIcon:fs,configDetails:Cs,configLabel:Ss,configPath:ys,configStatus:Ns,configContainer:ws,configHeader:bs,configTitle:Is,configContent:Ts,inputSection:Ds,label:Fs,inputGroup:zs,pathInput:ks,inputHelp:As,validationResult:Ps,validationSuccess:Os,validationError:Bs,errorMessage:Ls,configActions:Es,browserDialog:$s}
1,qs=({accessToken:n,currentFolderPath:t,onFolderPathChange:l})=>{const[o,s]=C.useState(!1),[c,a]=C.useState(!1),[h,f]=C.useState(t||""),{validateFolder:y,saveCustomFolderPath:r,isValidating:x,isSaving:w,validationResult:b,error:j}=gs(n);if(!n)return null;const p=async()=>{if(h.trim())try{await y(h)&&(await r(h),l?.(h),s(!1))}catch(i){console.error("Failed to validate or save folder path:",i)}},S=i=>{f(i),a(!1)},P=()=>{f(t||""),s(!1)};return o?e.jsxs("div",{className:_.configContainer,children:[e.jsxs("div",{className:_.configHeader,children:[e.jsxs("div",{className:_.configTitle,children:[e.jsx(E,{size:20}),e.jsx("h4",{children:"Configure OneDrive Folder"})]}),e.jsx(v,{variant:"ghost",size:"icon",onClick:P,children:e.jsx(Z,{size:16})})]}),e.jsxs("div",{className:_.configContent,children:[e.jsxs("div",{className:_.inputSection,children:[e.jsx("label",{htmlFor:"folder-path",className:_.label,children:"Custom Folder Path"}),e.jsxs("div",{className:_.inputGroup,children:[e.jsx(_e,{id:"folder-path",value:h,onChange:i=>f(i.target.value),placeholder:"/Shared Documents/Company Accounting",className:_.pathInput}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>a(!0),disabled:x||w,children:[e.jsx(ee,{size:16}),"Browse"]})]}),e.jsx("p",{className:_.inputHelp,children:"Enter the path to your shared OneDrive folder where invoices and accounting reports will be stored."})]}),b&&e.jsx("div",{className:`${_.validationResult} ${b.isValid?_.validationSuccess:_.validationError}`,children:b.isValid?e.jsxs(e.Fragment,{children:[e.jsx(A,{size:16}),e.jsx("span",{children:"Folder path is valid and accessible"})]}):e.jsxs(e.Fragment,{children:[e.jsx(R,{size:16}),e.jsx("span",{children:b.error||"Folder path is not accessible"})]})}),j&&e.jsxs("div",{className:_.errorMessage,children:[e.jsx(R,{size:16}),e.jsx("span",{children:j})]}),e.jsxs("div",{className:_.configActions,children:[e.jsx(v,{variant:"outline",onClick:P,disabled:x||w,children:"Cancel"}),e.jsx(v,{onClick:p,disabled:!h.trim()||x||w,children:x?"Validating...":w?"Saving...":e.jsxs(e.Fragment,{children:[e.jsx(se,{size:16}),"Save Configuration"]})})]})]}),e.jsx(ge,{open:c,onOpenChange:a,children:e.jsxs(xe,{className:_.browserDialog,children:[e.jsxs(je,{children:[e.jsx(ve,{children:"Browse OneDrive Folders"}),e.jsx(fe,{children:"Select a folder from your OneDrive to use for storing accounting documents."})]}),e.jsx(ls,{accessToken:n,onFolderSelect:S}),e.jsx(Ce,{children:e.jsx(v,{variant:"outline",onClick:()=>a(!1),children:"Cancel"})})]})})]}):e.jsxs("div",{className:_.container,children:[e.jsxs("div",{className:_.currentConfig,children:[e.jsxs("div",{className:_.configInfo,children:[e.jsx("div",{className:_.configIcon,children:e.jsx(O,{})}),e.jsxs("div",{className:_.configDetails,children:[e.jsx("div",{className:_.configLabel,children:"Accounting Folder"}),e.jsx("div",{className:_.configPath,children:t||"/Accounting (Default)"})]})]}),e.jsx("div",{className:_.configStatus,children:t?e.jsxs(k,{variant:"success",children:[e.jsx(A,{size:12}),"Custom Path"]}):e.jsx(k,{variant:"outline",children:"Default"})})]}),e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>s(!0),children:[e.jsx(E,{size:16}),"Configure Folder"]})]})},Hs="_container_y7woj_1",Ms="_header_y7woj_12",Rs="_titleSection_y7woj_19",Vs="_title_y7woj_19",Gs="_description_y7woj_31",Ws="_switchSection_y7woj_38",Us="_switchContainer_y7woj_42",Qs="_switchLabel_y7woj_49",Ks="_badge_y7woj_58",Ys="_connectedSection_y7woj_63",Js="_userCard_y7woj_68",Xs="_userInfo_y7woj_78",Zs="_userDetails_y7woj_84",et="_userName_y7woj_90",st="_userEmail_y7woj_96",tt="_disconnectButton_y7woj_101",nt="_disconnectedSection_y7woj_105",ot="_disconnectedCard_y7woj_110",at="_disconnectedIcon_y7woj_120",rt="_disconnectedContent_y7woj_132",it="_disconnectedTitle_y7woj_136",ct="_disconnectedText_y7woj_143",lt="_error_y7woj_149",dt="_errorContent_y7woj_160",pt="_errorTitle_y7woj_164",ut="_errorMessage_y7woj_170",ht="_loadingContent_y7woj_175",u={container:Hs,header:Ms,titleSection:Rs,title:Vs,description:Gs,switchSection:Ws,switchContainer:Us,switchLabel:Qs,badge:Ks,connectedSection:Ys,userCard:Js,userInfo:Xs,userDetails:Zs,userName:et,userEmail:st,disconnectButton:tt,disconnectedSection:nt,disconnectedCard:ot,disconnectedIcon:at,disconnectedContent:rt,disconnectedTitle:it,disconnectedText:ct,error:lt,errorContent:dt,errorTitle:pt,errorMessage:ut,loadingContent:ht},mt=({isAuthenticated:n,user:t,login:l,logout:o,isAuthenticating:s,error:c,accessToken:a,currentFolderPath:h,onFolderPathCh
1ange:f})=>{const y=r=>{r&&!n?l():!r&&n&&o()};return s?e.jsx("div",{className:u.container,children:e.jsxs("div",{className:u.loadingContent,children:[e.jsx(F,{style:{width:"100%",height:"3rem"}}),e.jsx(F,{style:{width:"80%",height:"1rem",marginTop:"var(--spacing-2)"}}),e.jsx(F,{style:{width:"60%",height:"1rem",marginTop:"var(--spacing-1)"}})]})}):e.jsxs("div",{className:u.container,children:[e.jsxs("div",{className:u.header,children:[e.jsxs("div",{className:u.titleSection,children:[e.jsx("h3",{className:u.title,children:"OneDrive Integration"}),e.jsx("p",{className:u.description,children:"Connect your Microsoft OneDrive account to manage accounting documents."})]}),e.jsx("div",{className:u.switchSection,children:e.jsxs("div",{className:u.switchContainer,children:[e.jsxs("div",{className:u.switchLabel,children:[e.jsx("span",{children:"Enable OneDrive"}),n&&e.jsxs(k,{variant:"success",className:u.badge,children:[e.jsx(A,{size:12}),"Connected"]})]}),e.jsx(Se,{checked:n,onCheckedChange:y,disabled:s})]})})]}),n&&t&&e.jsxs("div",{className:u.connectedSection,children:[e.jsxs("div",{className:u.userCard,children:[e.jsxs("div",{className:u.userInfo,children:[e.jsxs(ye,{children:[e.jsx(Ne,{src:"",alt:t.displayName}),e.jsx(we,{children:t.displayName.split(" ").map(r=>r[0]).join("").toUpperCase()})]}),e.jsxs("div",{className:u.userDetails,children:[e.jsx("div",{className:u.userName,children:t.displayName}),e.jsx("div",{className:u.userEmail,children:t.mail||t.userPrincipalName||"Microsoft Account"})]})]}),e.jsxs(v,{variant:"outline",size:"sm",onClick:o,className:u.disconnectButton,children:[e.jsx(te,{size:14}),"Disconnect"]})]}),a&&e.jsx(qs,{accessToken:a,currentFolderPath:h,onFolderPathChange:f})]}),!n&&!s&&e.jsx("div",{className:u.disconnectedSection,children:e.jsxs("div",{className:u.disconnectedCard,children:[e.jsx("div",{className:u.disconnectedIcon,children:e.jsx(ne,{size:24})}),e.jsxs("div",{className:u.disconnectedContent,children:[e.jsx("div",{className:u.disconnectedTitle,children:"Not Connected"}),e.jsx("div",{className:u.disconnectedText,children:"Enable the toggle above to connect your OneDrive account and access document management features."})]})]})}),c&&e.jsxs("div",{className:u.error,children:[e.jsx(B,{size:16}),e.jsxs("div",{className:u.errorContent,children:[e.jsx("div",{className:u.errorTitle,children:"Connection Failed"}),e.jsx("div",{className:u.errorMessage,children:c})]})]})]})},_t="_container_17tto_1",gt="_title_17tto_12",xt="_description_17tto_19",jt="_error_17tto_26",vt="_successIcon_17tto_39",ft="_folderInfo_17tto_43",Ct="_loaderIcon_17tto_54",D={container:_t,title:gt,description:xt,error:jt,successIcon:vt,folderInfo:ft,loaderIcon:Ct},St=({onCompleted:n})=>{const{login:t,logout:l,user:o,accessToken:s,isAuthenticated:c,isAuthenticating:a,error:h}=Ie(),f=W(),[y,r]=C.useState(!1),{data:x,isLoading:w,error:b}=$({queryKey:["onedrive","accountingFolder","verify",s],queryFn:()=>{if(!s)throw new Error("Not authenticated");return Be({accessToken:s})},enabled:!!s,retry:!1}),j=L({mutationFn:P=>Pe({accessToken:P}),onSuccess:()=>{f.invalidateQueries({queryKey:["onedrive","accountingFolder","verify"]}),n()}});C.useEffect(()=>{x?.verified&&n()},[x,n]);const p=()=>{s&&(r(!0),j.mutate(s))};if(a||c&&w)return e.jsxs("div",{className:D.container,children:[e.jsx(F,{style:{width:"250px",height:"2rem"}}),e.jsx(F,{style:{width:"400px",height:"1rem",marginTop:"var(--spacing-2)"}}),e.jsx(F,{style:{width:"200px",height:"2.5rem",marginTop:"var(--spacing-6)"}})]});if(!c)return e.jsx(mt,{login:t,logout:l,user:o,isAuthenticated:c,isAuthenticating:a,error:h,accessToken:s,currentFolderPath:void 0,onFolderPathChange:void 0});if(x?.verified)return e.jsxs("div",{className:D.container,children:[e.jsx(A,{size:48,className:D.successIcon}),e.jsx("h3",{className:D.title,children:"OneDrive Connected"}),e.jsx("p",{className:D.description,children:'Your "Accounting" folder is set up and ready to go.'}),e.jsxs("div",{className:D.folderInfo,children:[e.jsx(O,{size:16}),e.jsx("span",{children:x.folder?.name})]})]});const S=h||b||(j.isError?j.error:null);return e.jsxs("div",{className:D.container,children:[e.jsx("h3",{className:D.title,children:"Setup Accounting Folder"}),e.jsx("p",{className:D.description,children:`We'll create an "Accounting" folder in your OneDrive to store invoices, receipts, and financial records.`}),e.jsx(v,{onClick:p,disabled:j.isPending,size:"lg",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(oe,{size:16,className:D.loaderIcon}),"Creating Folder..."]}):"Create Accounting Folder"}),S&&e.jsxs("div",{className:D.error,children:[e.jsx(B,{size:16}),e.jsx("p",{children:S instanceof Error?S.message:"An unknown error occurred."})]}),!y&&x&&!x.verified&&e.jsxs("div",{className:D.error,children:[e.jsx(B,{size:16}),e.jsx("p",{children:x.message})]})]})},yt="_wizardContainer_138m3_1",Nt="_progressHeader_138m3_13",wt="_wizardTitle_138m3_20",bt="_progressPercentage_138m3_28",It="_percentageText_138m3_35",Tt="_progressBar_138m3_41",Dt="_progressBarFill_138m3_49",Ft="_progressContainer_138m3_56",zt="_progressStep_138m3_63",kt="_progressIconWrapper_138m3_73",At="_active_138m3_85",Pt="_completed_138m3_90",Ot="_progressLabel_138m3_95",Bt="_progressConnector_138m3_103",Lt="_contentContainer_138m3_111",Et="_stepContent_138m3_123",$t="_stepTitle_138m3_130",qt="_stepDescription_138m3_137",Ht="_completionIcon_138m3_144",Mt="_navigation_138m3_148",d={wizardContainer:yt,progressHeader:Nt,wizardTitle:wt,progressPercentage:bt,percentageText:It,progressBar:Tt,progressBarFill:Dt,progressContainer:Ft,progressStep:zt,progressIconWrapper:kt,active:At,completed:Pt,progressLabel:Ot,progressConnector:Bt,contentContainer:Lt,stepContent:Et,stepTitle:$t,stepDescription:qt,completionIcon:Ht,navigation:Mt},Rt=()=>e.jsxs("div",{className:d.stepContent,children:[e.jsx("h2",{className:d.stepTitle,children:"Welcome to TowTeamAssist!"}),e.jsx("p",{className:d.stepDescription,children:"Let's get your account set up. This quick process will connect your essential tools and get you ready to streamline your towing operations."}),e.jsx("p",{className:d.stepDescription,children:"This should only take a couple of minutes."})]}),Vt=()=>e.jsxs("div",{className:d.stepContent,children:[e.jsx("h2",{className:d.stepTitle,children:"TowTeamAssist Folder Setup"}),e.jsx("p",{className:d.stepDescription,children:"This step is handled automatically. We are setting up your main TowTeamAssist folder in OneDrive. Please proceed to the next step."})]}),Gt=({onCompleted:n})=>{const[t,l]=q.useState(!1),o=()=>{n()},s=c=>{l(c)};return e.jsxs("div",{className:d.stepContent,children:[e.jsx("h2",{className:d.stepTitle,children:"Shared Drive Access"}),e.jsx("p",{className:d.stepDescription,children:"Assign OneDrive shared drives to team members for accounting, invoices, or other business purposes. This step is optional and can be completed later from the settings page."}),e.jsx(v,{onClick:()=>l(!0),size:"lg",children:"Manage Shared Drive Access"}),e.jsx(v,{variant:"ghost",onClick:o,size:"sm",children:"Skip this
1step"}),e.jsx(Te,{open:t,onOpenChange:s,onCompleted:n})]})},Wt=()=>e.jsxs("div",{className:d.stepContent,children:[e.jsx(Q,{size:48,className:d.completionIcon}),e.jsx("h2",{className:d.stepTitle,children:"Setup Complete!"}),e.jsx("p",{className:d.stepDescription,children:"You're all set. Your folders are configured in OneDrive, and you're ready to start managing your business more efficiently."})]}),Ut=()=>{const n=U(),{data:t,updateStep:l,isUpdating:o}=K(),[s,c]=C.useState(0),a=C.useMemo(()=>[{id:"welcome",title:"Welcome",Icon:Q,isCompleted:()=>!0,component:e.jsx(Rt,{})},{id:"towteamassist",title:"TowTeamAssist Folder",Icon:ae,isCompleted:p=>p?.isTowteamassistFolderSetup===!0,component:e.jsx(Vt,{})},{id:"accounting",title:"Accounting Setup",Icon:re,isCompleted:p=>p?.isAccountingFolderSetup===!0,component:e.jsx(St,{onCompleted:()=>h("accountingFolder")})},{id:"sharedDrives",title:"Shared Drives",Icon:ie,isCompleted:p=>p?.isSharedDrivesSetup===!0,component:e.jsx(Gt,{onCompleted:()=>h("sharedDrives")})},{id:"complete",title:"All Done",Icon:A,isCompleted:p=>p?.setupCompletedAt!=null,component:e.jsx(Wt,{})}],[]);C.useEffect(()=>{if(!t)return;const p=a.findIndex(S=>!S.isCompleted(t));p!==-1&&p>s?c(p):p===-1&&t.setupCompletedAt&&c(a.length-1)},[t,a,s]);const h=async p=>{try{await l(p),c(S=>Math.min(S+1,a.length-1))}catch(S){console.error(`Failed to update step ${p}:`,S)}},f=()=>{s<a.length-1?(a[s].id==="towteamassist"&&!a[s].isCompleted(t)&&h("towteamassistFolder"),c(s+1)):n("/dashboard")},y=()=>{s>0&&c(s-1)},r=a[s],x=r.isCompleted(t),w=r.id==="welcome"||r.id==="towteamassist"||r.id==="sharedDrives"||x,b=t?a.filter(p=>p.isCompleted(t)).length:0,j=Math.round(b/a.length*100);return e.jsxs("div",{className:d.wizardContainer,children:[e.jsxs("div",{className:d.progressHeader,children:[e.jsx("h1",{className:d.wizardTitle,children:"Setup Progress"}),e.jsxs("div",{className:d.progressPercentage,children:[e.jsxs("span",{className:d.percentageText,children:[j,"% Complete"]}),e.jsx("div",{className:d.progressBar,children:e.jsx("div",{className:d.progressBarFill,style:{width:`${j}%`}})})]})]}),e.jsx("div",{className:d.progressContainer,children:a.map((p,S)=>e.jsxs(q.Fragment,{children:[e.jsxs("div",{className:d.progressStep,children:[e.jsx("div",{className:`${d.progressIconWrapper} ${S<=s?d.active:""} ${p.isCompleted(t)?d.completed:""}`,children:p.isCompleted(t)?e.jsx(A,{size:20}):e.jsx(ce,{size:20})}),e.jsx("span",{className:d.progressLabel,children:p.title})]}),S<a.length-1&&e.jsx("div",{className:d.progressConnector})]},p.id))}),e.jsx("div",{className:d.contentContainer,children:r.component}),e.jsxs("div",{className:d.navigation,children:[e.jsx(v,{variant:"outline",onClick:y,disabled:s===0||o,children:"Back"}),e.jsx(v,{onClick:f,disabled:!w||o,children:o?"Saving...":r.id==="complete"?"Go to Dashboard":"Next"})]})]})},Qt="_pageContainer_1np85_1",Kt="_loadingContainer_1np85_11",Yt="_setupContainer_1np85_21",Jt="_setupHeader_1np85_29",Xt="_headerContent_1np85_41",Zt="_titleRow_1np85_45",en="_titleGroup_1np85_53",sn="_headerTitle_1np85_57",tn="_headerDescription_1np85_65",nn="_helpButton_1np85_72",on="_systemStatusOverview_1np85_80",an="_statusInfo_1np85_88",rn="_statusLabel_1np85_94",cn="_readinessIndicator_1np85_100",ln="_readinessText_1np85_107",dn="_readinessBar_1np85_114",pn="_readinessBarFill_1np85_122",un="_tabsContainer_1np85_129",hn="_setupActions_1np85_137",mn="_tabContent_1np85_143",_n="_quickSetupDescription_1np85_149",gn="_advancedSetupDescription_1np85_150",g={pageContainer:Qt,loadingContainer:Kt,setupContainer:Yt,setupHeader:Jt,headerContent:Xt,titleRow:Zt,titleGroup:en,headerTitle:sn,headerDescription:tn,helpButton:nn,systemStatusOverview:on,statusInfo:an,statusLabel:rn,readinessIndicator:cn,readinessText:ln,readinessBar:dn,readinessBarFill:pn,tabsContainer:un,setupActions:hn,tabContent:mn,quickSetupDescription:_n,advancedSetupDescription:gn},kn=()=>{const n=U(),[t]=le(),{authState:l}=be(),{data:o,isLoading:s}=K(),a=t.get("tab")==="advanced"?"advanced":"quick",[h,f]=C.useState(a),{data:y,isFetching:r}=$({queryKey:["systemStatus"],queryFn:ke,enabled:l.type==="authenticated"});C.useEffect(()=>{l.type==="unauthenticated"&&n("/login")},[l,n]),C.useEffect(()=>{o?.setupCompletedAt&&(console.log("Setup already completed, redirecting to dashboard."),n("/dashboard"))},[o,n]),C.useEffect(()=>{const j=t.get("tab");j==="advanced"?f("advanced"):j==="quick"&&f("quick")},[t]);const x=l.type==="loading"||s,w=j=>{switch(j){case"ok":return e.jsxs(k,{variant:"success",children:[e.jsx(A,{size:14})," All Systems Operational"]});case"degraded":return e.jsxs(k,{variant:"warning",children:[e.jsx(B,{size:14})," Some Issues Detected"]});case"error":return e.jsxs(k,{variant:"destructive",children:[e.jsx(he,{size:14})," Critical Issues"]});default:return e.jsx(k,{variant:"outline",children:"Checking..."})}},b=()=>{n("/dashboard")};return e.jsxs(e.Fragment,{children:[e.jsxs(me,{children:[e.jsx("title",{children:"Account Setup - TowTeamAssist"}),e.jsx("meta",{name:"description",content:"Complete your account setup to get started with Floot."})]}),e.jsx("div",{className:g.pageContainer,children:x?e.jsxs("div",{className:g.loadingContainer,children:[e.jsx(F,{style:{width:"250px",height:"2.5rem"}}),e.jsx(F,{style:{width:"400px",height:"1.5rem",marginTop:"var(--spacing-4)"}}),e.jsx(F,{style:{width:"100%",maxWidth:"600px",height:"300px",marginTop:"var(--spacing-8)"}}
1)]}):e.jsxs("div",{className:g.setupContainer,children:[e.jsxs("div",{className:g.setupHeader,children:[e.jsx("div",{className:g.headerContent,children:e.jsxs("div",{className:g.titleRow,children:[e.jsxs("div",{className:g.titleGroup,children:[e.jsx("h1",{className:g.headerTitle,children:"Account Setup"}),e.jsx("p",{className:g.headerDescription,children:"Configure your account and system integrations to get started"})]}),e.jsx(v,{asChild:!0,variant:"outline",className:g.helpButton,children:e.jsxs(de,{to:"/help-guide",target:"_blank",rel:"noopener noreferrer",children:[e.jsx(pe,{size:16}),"Help Guide"]})})]})}),e.jsxs("div",{className:g.systemStatusOverview,children:[e.jsxs("div",{className:g.statusInfo,children:[e.jsx("span",{className:g.statusLabel,children:"System Status:"}),r?e.jsx(F,{style:{width:"120px",height:"1.5rem"}}):w(y?.status)]}),y&&e.jsxs("div",{className:g.readinessIndicator,children:[e.jsxs("span",{className:g.readinessText,children:[y.readinessPercentage,"% Ready"]}),e.jsx("div",{className:g.readinessBar,children:e.jsx("div",{className:g.readinessBarFill,style:{width:`${y.readinessPercentage}%`}})})]})]})]}),e.jsxs(Fe,{value:h,onValueChange:j=>
1f(j),children:[e.jsxs("div",{className:g.tabsContainer,children:[e.jsxs(ze,{children:[e.jsxs(V,{value:"quick",children:[e.jsx(ue,{size:16}),"Quick Setup"]}),e.jsxs(V,{value:"advanced",children:[e.jsx(E,{size:16}),"System Connections"]})]}),e.jsxs("div",{className:g.setupActions,children:[o?.setupCompletedAt&&h==="quick"&&e.jsx(v,{onClick:b,variant:"outline",children:"Go to Dashboard"}),!o?.setupCompletedAt&&e.jsx(v,{onClick:b,variant:"outline",children:"Finish Setup Later"})]})]}),e.jsxs(G,{value:"quick",className:g.tabContent,children:[e.jsx("div",{className:g.quickSetupDescription,children:e.jsx("p",{children:"Follow our guided setup wizard to configure the essential features needed to get started quickly."})}),e.jsx(Ut,{})]}),e.jsxs(G,{value:"advanced",className:g.tabContent,children:[e.jsx("div",{className:g.advancedSetupDescription,children:e.jsx("p",{children:"Monitor and manage all system integrations. Test connections, troubleshoot issues, and configure advanced settings."})}),e.jsx(De,{})]})]})]})})]})};export{kn 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.