1import{u as f,j as e}from"./query-vendor-Dp9tfhuh.js";import{d as T,w as q,f as b,h as l,i as c,k as x,m as u,l as y,s as h}from"./index-CgOeqv80.js";import{T as R,a as P,b as v,c as N}from"./tabs-CaoVN6UB.js";import{D as w}from"./DashboardLayout-v_SFEx5M.js";import{P as A}from"./PageHeader-DAD15sYQ.js";import{B as C}from"./building-2-BMIYvzwG.js";import{F as D}from"./file-text-CuOiBfSM.js";import{D as K}from"./dollar-sign-D0iC4HrG.js";import{W as S}from"./wrench-CDdvezGQ.js";import"./react-vendor-DfslLuwi.js";import"./ui-vendor-DW4RoVmg.js";import"./chart-vendor-BoynbIzZ.js";import"./use-mobile-CojsY12Z.js";import"./input-go5takyh.js";import"./separator-DP1KYTpB.js";import"./sheet-bqYui_d3.js";import"./skeleton-U7PtyM3w.js";import"./tooltip-CSLOX5Ak.js";import"./Logo-Dty4QCqO.js";import"./calendar-days-Cbs598pa.js";import"./users-9XO_ctWv.js";import"./map-pin-B63H-upO.js";import"./wifi-off-BfVaxzCl.js";import"./message-square-B81woyC-.js";import"./credit-card-B-2xvAjl.js";import"./panel-top-BGv8mfXo.js";import"./mail-CObWevXE.js";import"./log-out-SS0g6Uak.js";import"./badge-CarGzGVG.js";import"./scroll-area-DpCy8yLM.js";import"./index-BdQq_4o_.js";import"./bell-D0vTOuek.js";import"./check-check-2zE5w8gN.js";import"./formatDistanceToNow-DExfhm_y.js";import"./en-US-5rFTtd83.js";import"./LanguageSwitcher-DHMsopEY.js";import"./dropdown-menu-BeZf8kFV.js";import"./chevron-right-BdUdHP_I.js";import"./check-v4vwqlB-.js";import"./circle-pSWMGBM_.js";import"./languages-DOZFgZ9Q.js";import"./message-circle-BYe5rrWz.js";import"./activity-CfnIewRD.js";import"./arrow-down-CIVFAk8G.js";import"./arrow-left-BmX2tYO6.js";import"./arrow-right-left-DF8EQ874.js";import"./arrow-right-ksEPM703.js";import"./banknote-CdW1Jv9F.js";import"./bed-B88pYHvh.js";import"./list-ordered-hB6RbGtG.js";import"./book-open-check-DYZCLGLv.js";import"./book-open-D0Y1dKqG.js";import"./brain-BohJitgU.js";import"./building-DasY5zOg.js";import"./calculator-ByooPTmb.js";import"./calendar-D4RFJDPY.js";import"./car-D3b4R55M.js";import"./landmark-BwZdzl4J.js";import"./chart-no-axes-column-increasing-C6Bh1bTG.js";import"./chart-pie-7jztI-xg.js";import"./chevron-down-Bm2Y15mk.js";import"./chevron-left-DCDYd6CA.js";import"./chevron-up-DVBQQKr7.js";import"./circle-check-big-CQmmVCDK.js";import"./circle-check-CLkepror.js";import"./message-square-text-W-2xUYbe.js";import"./circle-help-Cpt-rFJF.js";import"./circle-x-CMEjdGNX.js";import"./clipboard-check-Cvc1fMv5.js";import"./clipboard-list-FvLR_NG8.js";import"./clipboard-viWVwQwk.js";import"./clock-BmPJ466V.js";import"./copy-BEDU18te.js";import"./database-kv95WpLa.js";import"./download-B3iahoQg.js";import"./zoom-out-zrJfLdu9.js";import"./external-link-BIGsQXrz.js";import"./twitter-BaxQU1X8.js";import"./file-chart-column-increasing-DEN9Rsed.js";import"./file-check-cM7E4NaC.js";import"./file-spreadsheet-ZK-q7Zgc.js";import"./filter-Bs-PYMIY.js";import"./folder-open-DFmVGiUq.js";import"./tree-pine-CouWAS-6.js";import"./globe-C_UDh3Yp.js";import"./video-DaS8rS9K.js";import"./hammer-691LkvTd.js";import"./heart-Dv9Odr8c.js";import"./hotel-C1w3GOsr.js";import"./house-5R4LHGOP.js";import"./image-plus-xT5L-tET.js";import"./image-CayqqQKD.js";import"./infinity-wq20aEtI.js";import"./key-round-Dh3U7Shh.js";import"./pen-tool-_n2hBO7N.js";import"./keyboard-CSqz3mRU.js";import"./layers-D0VRol72.js";import"./lightbulb-DlRuWc33.js";import"./list-checks-coQAK2sr.js";import"./list-BJoWfKXY.js";import"./lock-B0M9hAnN.js";import"./map-pinned-B-fJbXg-.js";import"./map-C8rxfYCS.js";import"./maximize-2-CZGGiq67.js";import"./maximize-DHDDLx00.js";import"./menu-DuKtMQlr.js";import"./minus-04ztrfH_.js";import"./mouse-pointer-click-Bc_ivnf4.js";import"./mouse-CUCnDlYq.js";import"./navigation-mR6QetLo.js";import"./pause-DWfQPC5O.js";import"./pencil-d1bR18nI.js";import"./ruler-BoWqmUga.js";import"./phone-I9m-09C5.js";import"./play-CVPqrcf1.js";import"./plus-CYnN_kFu.js";import"./printer-DjW2gpx9.js";import"./refresh-ccw-BR8hKK-Q.js";import"./rocket-DxjHbFsp.js";import"./rotate-ccw-CE2HFYnH.js";import"./rotate-cw-n6J_8Piu.js";import"./route-Df-61sSI.js";import"./save-DF6x0jpO.js";import"./scale-CZXGlUhc.js";import"./search-Dx_o7OfG.js";import"./send-Blf9Z7mq.js";import"./share-2-sKHj2vjO.js";import"./square-plus-Dp1sCmj5.js";import"./skip-forward-eFm9X_4U.js";import"./smartphone-CBjqwShe.js";import"./square-check-big-DF0dFzei.js";import"./square-pen-Bg7uj701.js";import"./square-MsVDU0g-.js";import"./star-DlIZz9Im.js";
1import"./trash-2-DAqLpVlV.js";import"./trending-down-COltpy2W.js";import"./trending-up-CRE5UWZg.js";import"./upload-55xlfOPi.js";import"./user-check-XkucE5f8.js";import"./user-DV5oCLCs.js";import"./volume-2-DTT7l7C1.js";import"./volume-x-BBMkTIRp.js";import"./wallet-_cnDvlQk.js";import"./workflow-Bfwpj-zP.js";import"./zap-BKGpOGd1.js";import"./useIsRTL-D_a81cVb.js";import"./useOrganization-msM7McOc.js";const vr=()=>{const{user:s}=T(),{data:r,isLoading:_}=f({queryKey:["team-properties",s==null?void 0:s.id],queryFn:async()=>{const{data:t}=await h.from("team_memberships").select("team_id").eq("owner_id",s.id).eq("is_active",!0),i=[...new Set((t||[]).map(d=>d.team_id))],[o,n]=await Promise.all([h.from("properties").select(` 2 *, 3 units(count), 4 leases:units(leases(*)) 5 `).eq("owner_id",s.id),i.length>0?h.from("properties").select(` 6 *, 7 units(count), 8 leases:units(leases(*)) 9 `).in("team_id",i):Promise.resolve({data:[],error:null})]);if(o.error)throw o.error;if(n.error)throw n.error;const a=new Map;for(const d of o.data||[])a.set(d.id,d);for(const d of n.data||[])a.set(d.id,d);return Array.from(a.values())},enabled:!!(s!=null&&s.id)}),{data:g}=f({queryKey:["team-portfolios",s==null?void 0:s.id],queryFn:async()=>{if(!r||r.length===0)return[];const t=r.map(n=>n.id),{data:i,error:o}=await h.from("property_portfolios").select("*").in("property_id",t).eq("is_published",!0);if(o)throw o;return i||[]},enabled:!!r&&r.length>0}),{data:p}=f({queryKey:["team-leases",s==null?void 0:s.id],queryFn:async()=>{if(!r||r.length===0)return[];const{data:t}=await h.from("units").select("id").in("property_id",r.map(n=>n.id));if(!t||t.length===0)return[];const{data:i,error:o}=await h.from("leases").select(` 10 *, 11 units(unit_number, properties(name)) 12 `).in("unit_id",t.map(n=>n.id));if(o)throw o;return i||[]},enabled:!!r&&r.length>0}),{data:m}=f({queryKey:["team-financials",s==null?void 0:s.id],queryFn:async()=>{if(!r||r.length===0)return{revenue:0,expenses:0};const{data:t}=await h.from("payments").select("amount").eq("status","paid").in("lease_id",(p==null?void 0:p.map(a=>a.id))||[]),{data:i}=await h.from("expenses").select("amount").in("property_id",r.map(a=>a.id)),o=(t==null?void 0:t.reduce((a,d)=>a+Number(d.amount),0))||0,n=(i==null?void 0:i.reduce((a,d)=>a+Number(d.amount),0))||0;return{revenue:o,expenses:n}},enabled:!!r&&r.length>0&&!!p}),{data:j}=f({queryKey:["team-maintenance",s==null?void 0:s.id],queryFn:async()=>{if(!r||r.length===0)return[];const{data:t,error:i}=await h.from("maintenance_requests").select(` 13 *, 14 properties(name) 15 `).in("property_id",r.map(o=>o.id)).order("created_at",{ascending:!1});if(i)throw i;return t||[]},enabled:!!r&&r.length>0});return _?e.jsx(w,{className:"flex items-center justify-center",children:e.jsx(q,{})}):e.jsxs(w,{children:[e.jsx(A,{title:"Team Overview Portal",subtitle:"Read-only view of all team properties and activities",icon:e.jsx(b,{className:"h-5 w-5"})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(l,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(x,{className:"text-sm font-medium",children:"Total Properties"}),e.jsx(C,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(u,{children:e.jsx("div",{className:"text-2xl font-bold",children:(r==null?void 0:r.length)||0})})]}),e.jsxs(l,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(x,{className:"text-sm font-medium",children:"Active Leases"}),e.jsx(D,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(u,{children:e.jsx("div",{className:"text-2xl font-bold",children:(p==null?void 0:p.filter(t=>t.status==="active").length)||0})})]}),e.jsxs(l,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(x,{className:"text-sm font-medium",children:"Total Revenue"}),e.jsx(K,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(u,{children:e.jsxs("div",{className:"text-2xl font-bold",children:["âª",(m==null?void 0:m.revenue.toFixed(0))||0]})})]}),e.jsxs(l,{children:[e.jsxs(c,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(x,{className:"text-sm font-medium",children:"Maintenance Requests"}),e.jsx(S,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(u,{children:e.jsx("div",{className:"text-2xl font-bold",children:(j==null?void 0:j.length)||0})})]})]}),e.jsxs(R,{defaultValue:"properties",className:"space-y-4",children:[e.jsxs(P,{children:[e.jsx(v,{value:"properties",children:"Properties"}),e.jsx(v,{value:"portfolios",children:"Shared Portfolios"}),e.jsx(v,{value:"leases",children:"Leases"}),e.jsx(v,{value:"financials",children:"Financials"}),e.jsx(v,{value:"maintenance",children:"Maintenance"})]}),e.jsx(N,{value:"properties",className:"space-y-4",children:e.jsxs(l,{children:[e.jsxs(c,{children:[e.jsx(x,{children:"Team Properties"}),e.jsx(y,{children:"All properties managed by your team"})]}),e.jsx(u,{children:e.jsx("div",{className:"space-y-2",children:r==null?void 0:r.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t.address})]}),e.jsx(b,{className:"h-4 w-4 text-muted-foreground"})]},t.id))})})]})}),e.jsx(N,{value:"portfolios",children:e.jsxs(l,{children:[e.jsxs(c,{children:[e.jsx(x,{children:"Shared Portfolios"}),e.jsx(y,{children:"Published property portfolios"})]}),e.jsx(u,{children:e.jsx("div",{className:"space-y-2",children:g==null?void 0:g.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.title}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Views: ",t.view_count]})]}),e.jsx(b,{className:"h-4 w-4 text-muted-foreground"})]},t.id))})})]})}),e.jsx(N,{value:"leases",children:e.jsxs(l,{children:[e.jsxs(c,{children:[e.jsx(x,{children:"Active Leases"}),e.jsx(y,{children:"All lease agreements across the team"})]}),e.jsx(u,{children:e.jsx("div",{className:"space-y-2",children:p==null?void 0:p.map(t=>{var i,o,n;return e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:(o=(i=t.units)==null?void 0:i.properties)==null?void 0:o.name}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unit ",(n=t.units)==null?void 0:n.unit_number," - âª",t.monthly_rent,"/mo"]})]}),e.jsx(b,{className:"h-4 w-4 text-muted-foreground"})]},t.id)})})})]})}),e.jsx(N,{value:"financials",children:e.jsxs(l,{children:[e.jsxs(c,{children:[e.jsx(x,{children:"Financial Overview"}),e.jsx(y,{children:"Team revenue and expenses"})]}),e.jsx(u,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Revenue"}),e.jsxs("p",{className:"text-2xl font-bold text-green-600",children:["âª",(m==null?void 0:m.revenue.toFixed(2))||0]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Expenses"}),e.jsxs("p",{className:"text-2xl font-bold text-red-600",children:["âª",(m==null?void 0:m.expenses.toFixed(2))||0]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Net Income"}),e.jsxs("p",{className:"text-2xl font-bold",children:["âª",(((m==null?void 0:m.revenue)||0)-((m==null?void 0:m.expenses)||0)).toFixed(2)]})]})]})})]})}),e.jsx(N,{value:"maintenance",children:e.jsxs(l,{children:[e.jsxs(c,{children:[e.jsx(x,{children:"Maintenance Requests"}),e.jsx(y,{children:"All maintenance across team properties"})]}),e.jsx(u,{children:e.jsx("div",{className:"space-y-2",children:j==null?void 0:j.map(t=>{var i;return e.jsxs("div",{className:"flex items-center justify-between p-3 border rounded",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:t.title}),e.jsx("p",{className:"text-sm text-muted-foreground",children:(i=t.properties)==null?void 0:i.name})]}),e.jsx("span",{className:`text-xs px-2 py-1 rounded ${t.status==="completed"?"bg-accent text-foreground":t.status==="in_progress"?"bg-muted text-foreground":"bg-muted/50 text-muted-foreground"}`,children:t.status})]},t.id)})})})]})})]})]})};export{vr 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.