1import{j as e}from"./vendor-motion-0RUSUsFi.js";import{c as z,a,L as E}from"./vendor-router-BySvYurK.js";import{ag as G,ah as _,ab as H,cB as J,I as V,H as q,d5 as U,P as K,ad as I,az as X,ch as f,T as Y,bA as p,a3 as Z,bB as ee,bD as se,bE as te,bF as ae,bG as re,J as L,cQ as ne,ac as B,cJ as ie,cM as le,cC as oe,x as de,cP as ce}from"./index-CyDkdwrf.js";import{S as me,P as ue}from"./projectUi-BDkKWAdC.js";import{M as xe,a as pe}from"./ProjectDetailPage-G011OBKm.js";import{T as ge}from"./trophy-BLBLn0PB.js";import{A as O}from"./alert-circle-CdJRBqmt.js";import"./vendor-firebase-JEFnLeA1.js";import"./projectHandoff-9IXYXoDZ.js";import"./estimateLink-DtWX8K_Y.js";import"./DocumentsPanel-CxMnQ8la.js";import"./image-BhgxbYWD.js";import"./download-C280mMAf.js";import"./pencil-BUY_Xf-6.js";import"./trash-2-bjFTbf9c.js";import"./purchaseOrderApi-B65eQS_A.js";import"./truck-CvAX_fxZ.js";import"./send-Dgo7ckSL.js";import"./moneyTypes-XnrczmBP.js";import"./invoicesApi-BXH0a858.js";import"./equipmentCost-CBw3cIIu.js";import"./BidGuardPanel-Bn09dLzl.js";import"./costingApi-Bkl_Si-6.js";import"./costSettingsApi-BLqOzSwa.js";import"./coinsOperations-B0ykpgJa.js";import"./siteGeo-haX5-ibl.js";import"./bidGuard-0GCxZljR.js";import"./sliders-horizontal-BxDJ0XW_.js";import"./usePageTitle-rWW94EJR.js";import"./x-circle-CiXiTd8H.js";import"./activity-egRhvj2T.js";function Ve(){const r=z(),g=a.useCallback(async()=>(await G(),_()),[]),{data:l,loading:y,error:h,retry:o}=H(g,[]),[d,m]=a.useState(""),[u,b]=a.useState(null),[k,j]=a.useState(null),[w,N]=a.useState(null),[R,S]=a.useState(null),[W,C]=a.useState(!1),[M,v]=a.useState(""),c=Date.now(),D=a.useMemo(()=>(l??[]).filter(s=>s.salesStage!=="won"&&s.salesStage!=="lost"),[l]),n=a.useMemo(()=>D.filter(s=>J(s,d)),[D,d]),F=a.useMemo(()=>V(n),[n]),x=a.useMemo(()=>q(l??[],c),[l,c]),P=a.useMemo(()=>U(n,c),[n,c]);async function T(s,t){if(N(null),S(null),t===s.salesStage)return;const i=ie(s,t);if(!i.ok){v(`${s.title}: ${i.message}`);return}C(!0),v("");try{const A=await le(s.id,t);A.ok||v(`${s.title}: ${A.message}`),o()}finally{C(!1)}}const $=(l??[]).length>0;return e.jsxs("div",{className:"",children:[e.jsxs("div",{className:"mx-auto max-w-7xl px-4 pb-16 pt-6 sm:px-6 lg:px-8",children:[e.jsx(K,{title:"Pipeline",subtitle:"The same projects the dashboard and Operations see â this is the sales view of them.",primary:e.jsx(E,{to:"/projects",children:e.jsxs(I,{children:[e.jsx(X,{size:15})," All projects"]})})}),$&&e.jsxs("div",{className:"mb-5 grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(f,{icon:Y,label:"Open",value:String(x.openCount),sub:p(x.openValue)}),e.jsx(f,{icon:Z,label:"Forecast",value:p(x.forecast),sub:"Weighted by stage"}),e.jsx(f,{icon:ge,label:"Won",value:String(x.wonCount),sub:p(x.wonValue)}),e.jsx(f,{icon:O,label:"Needs a call",value:String(P.length),sub:"Quiet 14+ days",tone:P.length?"warn":"default"})]}),M&&e.jsxs("div",{className:"mb-4 flex items-start gap-2 rounded-xl border border-warn bg-warn-soft p-3 text-13 text-warn",children:[e.jsx(O,{size:15,className:"mt-0.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"flex-1",children:M}),e.jsx("button",{onClick:()=>v(""),className:"font-semibold hover:underline",children:"Dismiss"})]}),e.jsx("div",{className:"mb-4 max-w-md",children:e.jsx(ee,{value:d,onChange:m,placeholder:"Property, client, PM-2026-â¦"})}),y?e.jsx(se,{rows:5,cols:4}):h?e.jsx(te,{detail:h,onRetry:o}):$?n.length===0?e.jsx(re,{what:"projects",onClear:()=>m("")}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"hidden gap-3 lg:grid lg:grid-cols-5",children:F.map(s=>e.jsxs("div",{onDragOver:t=>{t.preventDefault(),S(s.stage)},onDragLeave:()=>S(t=>t===s.stage?null:t),onDrop:()=>{const t=n.find(i=>i.id===w);t&&T(t,s.stage)},className:`rounded-xl border p-2 transition-colors ${R===s.stage?"border-brand bg-emerald-50/60":"border-line bg-sunk"}`,children:[e.jsxs("header",{className:"px-1.5 pb-2 pt-1",children:[e.jsx("div",{className:"text-12 font-bold text-ink",children:L[s.stage]}),e.jsxs("div",{className:"text-11 tabular-nums text-ink-muted",children:[s.count," · ",p(s.value)]})]}),e.jsxs("div",{className:"space-y-2",children:[s.projects.map(t=>e.jsx(Q,{project:t,now:c,dragging:w===t.id,onDragStart:()=>N(t.id),onDragEnd:()=>N(null),onOpen:()=>r(`/projects/${t.id}`)},t.id)),s.count===0&&e.jsx("p",{className:"px-1.5 py-4 text-center text-11 text-ink-faint",children:"Nothing here"})]})]},s.stage))}),e.jsx("div",{className:"space-y-2 lg:hidden",children:n.map(s=>e.jsxs("div",{className:"rounded-xl border border-line bg-raised p-3",children:[e.jsx(Q,{project:s,now:c,onOpen:()=>r(`/projects/${s.id}`),flat:!0}),e.jsxs("div",{className:"mt-2.5 flex items-center gap-2",children:[e.jsx("select",{value:s.salesStage,disabled:W,onChange:t=>T(s,t.target.value),className:"flex-1 rounded-lg border border-line px-2 py-1.5 text-13","aria-label":`Stage for ${s.title}`,children:ne.map(t=>e.jsx("option",{value:t,children:L[t]},t))}),e.jsx(B,{onClick:()=>b(s),children:"Won"}),e.jsx(B,{onClick:()=>j(s),children:"Lost"})]})]},s.id))}),e.jsxs("div",{className:"mt-4 hidden flex-wrap items-center gap-2 rounded-xl border border-line bg-raised p-3 text-13 text-ink-muted lg:flex",children:[e.jsx("span",{className:"font-medium text-ink",children:"Decide a project:"}),e.jsxs("select",{className:"rounded-lg border border-line px-2 py-1.5 text-13",value:"","aria-label":"Mark a project won",onChange:s=>{const t=n.find(i=>i.id===s.target.value);t&&b(t)},children:[e.jsx("option",{value:"",children:"Mark wonâ¦"}),n.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))]}),e.jsxs("select",{className:"rounded-lg border border-line px-2 py-1.5 text-13",value:"","aria-label":"Mark a project lost",onCh
1ange:s=>{const t=n.find(i=>i.id===s.target.value);t&&j(t)},children:[e.jsx("option",{value:"",children:"Mark lostâ¦"}),n.map(s=>e.jsx("option",{value:s.id,children:s.title},s.id))]})]})]}):e.jsx(ae,{title:"Nothing in the pipeline yet",body:"Projects appear here the moment a property is measured, and move along as the bid progresses.",action:e.jsx(E,{to:"/properties/new",children:e.jsx(I,{children:"Measure a property"})})})]}),u&&e.jsx(xe,{project:u,onClose:()=>b(null),onDone:()=>{b(null),o()}}),k&&e.jsx(pe,{project:k,onClose:()=>j(null),onDone:()=>{j(null),o()}})]})}function Q({project:r,now:g,dragging:l,onDragStart:y,onDragEnd:h,onOpen:o,flat:d}){const m=oe(r,g),u=de(r,g);return e.jsxs("article",{draggable:!d,onDragStart:y,onDragEnd:h,className:`${d?"":"cursor-grab rounded-lg border border-line bg-raised p-2.5 transition hover:shadow"} ${l?"opacity-40":""}`,children:[e.jsxs("button",{onClick:o,className:"block w-full text-left",children:[e.jsx("div",{className:"truncate text-13 font-semibold text-ink",children:r.propertyName||r.title}),e.jsx("div",{className:"truncate text-11 text-ink-muted",children:r.customerName})]}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[e.jsx(me,{serviceTypeId:r.serviceTypeId}),e.jsx(ue,{projectId:r.projectId})]}),e.jsxs("div",{className:"mt-1.5 flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"text-13 font-bold tabular-nums text-ink",children:p(r.value)}),e.jsxs("span",{className:"text-11 tabular-nums text-ink-faint",children:[Math.round(ce(r)*100),"%"]})]}),e.jsx("div",{className:`mt-1 text-11 ${m?"font-semibold text-warn":"text-ink-faint"}`,children:m?`Quiet ${u} days`:`${u}d in stage`})]})}export{Ve 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.