1import{c as Re,j as e,B as A,o as ze,p as $e,r as n,d as j,m as x,y as Le}from"./index-CvhEPo2M.js";import{S as Ie}from"./StatusBadge-Ds21wLAM.js";import{f as pe,c as xe,a as he,b as ue,d as Be,A as Ue,R as Ye}from"./ReviewSendDialog-CyvGjCFW.js";import{I as y}from"./input-CHRd2-Lm.js";import{L as ge}from"./label-Qtmz7rLD.js";import{h as Y}from"./moment-BLMuvzoS.js";import{T as Ne}from"./trash-2-B5cb3D1K.js";import{P as qe}from"./plus-af7bFCj9.js";import{A as Je}from"./ActivityTimeline-CtJgm-JZ.js";import{P as Ge}from"./PhotoGallery-C2WNxtbQ.js";import{T as He}from"./textarea-6jV0uxEq.js";import{S as fe,a as be,b as je,c as ye,d as ve}from"./select-Cq-3rJYF.js";import{R as Ve}from"./index-DmJzsmQh.js";import{D as Qe}from"./DeliveryStatusPanel-D6yr5OSu.js";import{g as Ke}from"./generatePdf-Bg8WVKez.js";import{P as Xe}from"./projectTypes-9hGo-tV6.js";import{A as Ze}from"./arrow-left-3vqynk7g.js";import{C as et}from"./circle-check-DmEhb-nO.js";import{M as tt}from"./mail-DGJTuk1B.js";import{S as st}from"./save-C7-fhMxf.js";import{E as at}from"./eye-DuD1eR7d.js";import{S as rt}from"./send-CSyqvPTb.js";import{D as nt}from"./download-0vRTQRU1.js";import{C as it}from"./clock-CxqEv_1B.js";import"./circle-alert-CcmzNkEW.js";import"./calendar-CvMazm_l.js";import"./zap-BjhVKHsB.js";import"./lightbulb-DP9qt-Sc.js";import"./circle-x-CL74CZ5l.js";import"./arrow-right-JkvnrXY7.js";import"./phone-DgwbSwH-.js";import"./circle-9JkV8fwH.js";import"./dialog-Bk0iYciO.js";import"./index-DPIFgJ2q.js";import"./Combination-DpbOz2Eo.js";import"./switch-ihqWggwm.js";import"./index-WjD40g8o.js";import"./package-Dy3DPh6S.js";import"./chevron-down-qbBoSQB4.js";import"./dollar-sign-CHql5ybH.js";import"./publicUrl-Bxe4W2FQ.js";import"./pencil-CyViz0bv.js";import"./minus-Cn0jGSaX.js";import"./square-C3RtZiX-.js";import"./image-_0Eb35f6.js";import"./upload-4tqesLPj.js";import"./index-GSR3RYIu.js";import"./check-DXHh8cc5.js";import"./isEqual-CszTRBly.js";import"./credit-card-Clezeip2.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ot=[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]],lt=Re("FilePen",ot),dt=()=>`${Date.now()}_${Math.random().toString(36).slice(2,8)}`,ct=r=>"$"+(r||0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});function q(r){return Array.isArray(r)?r.reduce((h,l)=>h+(parseFloat(l.amount)||0),0):0}function mt({changeOrders:r,onChange:h}){const l=Array.isArray(r)?r:[],v=()=>{h([...l,{id:dt(),description:"",amount:"",date:Y().format("YYYY-MM-DD")}])},a=(d,c,s)=>{const o=l.map((f,u)=>u===d?{...f,[c]:s}:f);h(o)},N=d=>{h(l.filter((c,s)=>s!==d))},i=q(l);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-sm font-heading font-semibold",children:"Change Orders"}),l.length>0&&e.jsx("span",{className:"ml-auto text-sm font-bold text-amber-400",children:ct(i)})]}),e.jsx("div",{className:"space-y-2",children:l.map((d,c)=>e.jsxs("div",{className:"grid grid-cols-12 gap-2 items-center bg-amber-500/5 rounded-lg p-2 border border-amber-500/20",children:[e.jsx(y,{value:d.description,onChange:s=>a(c,"description",s.target.value),placeholder:"e.g. Add ceiling to living room â 2 coats",className:"col-span-12 sm:col-span-6 bg-secondary/40 rounded-lg h-9"}),e.jsxs("div",{className:"col-span-6 sm:col-span-3 relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground text-sm",children:"$"}),e.jsx(y,{type:"number",value:d.amount,onChange:s=>a(c,"amount",s.target.value),placeholder:"0.00",className:"bg-secondary/40 rounded-lg h-9 pl-7"})]}),e.jsx(y,{type:"date",value:d.date||"",onChange:s=>a(c,"date",s.target.value),className:"col-span-5 sm:col-span-2 bg-secondary/40 rounded-lg h-9"}),e.jsx("button",{onClick:()=>N(c),className:"col-span-1 flex justify-center text-muted-foreground hover:text-red-500 transition-colors",children:e.jsx(Ne,{className:"w-4 h-4"})})]},d.id))}),l.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground text-center py-3",children:"No change orders yet. Add work that wasn't in the original scope."}),e.jsxs(A,{variant:"outline",size:"sm",onClick:v,className:"gap-1.5 rounded-lg text-xs border-amber-500/30 text-amber-400 hover:bg-amber-500/10",children:[e.jsx(qe,{className:"w-3.5 h-3.5"})," Add Change Order"]})]})}const pt=`<h2 class="ql-align-center"><u>TERMS & CONDITIONS </u></h2><p class="ql-align-center"><br></p><p>1. Scope of Work: The quote outlines the scope of work agreed upon by the customer and Gallagher Painting. Any additional work not specified in the quote will incur additional charges. </p><p><br></p><p>2. Preparation: Gallagher Painting will prepare the work area before starting any painting work, including covering all floors and furniture, patching small holes, filling cracks in trim, sanding and cleaning glossy surfaces, and scraping peeling paint on exterior surfaces. </p><p><br></p><p>3. Paint/Materials: The quote will specify the type and amount of paint and materials required for the job. The customer must choose colors at least one week before the project start date, and any changes after work begins may result in additional charges. </p><p><br></p><p>4. Unforeseen Conditions: If any unforeseen repairs or additional work arise, the customer will be notified, and an additional work order will be written up for the customer to sign for. </p><p>5. Customer Responsibility: The customer is responsible for ensuring that the work area is clean and free of other trades before Gallagher Painting arrives. Wall hangings must be removed, and large furniture can be placed in the center of the room. The customer must also be available for a thorough walk-through with the crew lead on the last day of the project. </p><p><br></p><p>6. Work Standard: Gallagher Painting follows all proper work protocol and craftsmanship per industry standards. </p><p><br></p><p>7. Insurance: Gallagher Painting has insurance, and the customer will be provided with a copy of the insurance information upon request. </p><p><br></p><p>8. Warranty: The painting business offers a warranty that covers any defects in workmanship and materials for a specified period. The warranty excludes incidental damage caused by accident or abuse, normal wear and tear, temperature changes, and cracks/bubbling caused by heat/expansion. </p><p><br></p><p>9. Cancellation: Cancellations made within 48 hours of signing receive a full deposit refund. After 48 hours, the deposit may be applied toward rescheduling or materials already purchased. </p><p><br></p><p>10. Payment: The customer must pay a deposit upon acceptance of the quote (40%), and the remainder of the total will be paid upon completion of the project. Progress payments may be required for projects exceeding five (5) business days. </p><p><br></p><p>11. Liability: Gallagher Painting will take every precaution to protect the customer's property throughout the project. In the event of accidental damage, liability shall not exceed the total contract value.</p>`,xt="https://media.base44.com/images/public/6a4af1b4e6161df542abddf0/09de60b9c_GallagherPaintingLogo.png",_=r=>
6(r||0).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2});function ht({estimate:r,areas:h}){const l=s=>(s.items||[]).filter(o=>o.description&&o.type!=="material"),v=(h||[]).filter(s=>!s.is_option),a=(h||[]).filter(s=>s.is_option),N=v.some(s=>l(s).length>0);let i=0,d=0;v.forEach(s=>{i+=(parseFloat(s.hours)||0)*(parseFloat(s.hourly_rate)||0),(s.items||[]).forEach(o=>{o.type==="material"&&(d+=o.total||0)})});let c=0;return a.forEach(s=>{c+=(parseFloat(s.hours)||0)*(parseFloat(s.hourly_rate)||0),(s.items||[]).forEach(o=>{o.type==="material"&&(c+=o.total||0)})}),e.jsxs("div",{style:{background:"#ffffff",color:"#1e293b",fontFamily:"Inter, sans-serif",padding:"32px",width:"800px"},children:[e.jsx("div",{style:{background:"linear-gradient(to right, #506a5b, #7c917c)",padding:"24px",borderRadius:"16px",textAlign:"center",marginBottom:"24px"},children:e.jsx("img",{src:xt,crossOrigin:"anonymous",alt:"Gallagher Painting",style:{width:"150px",filter:"brightness(0) invert"}})}),e.jsx("p",{style:{color:"#506a5b",fontSize:"11px",letterSpacing:"1px",textTransform:"uppercase",fontWeight:600,margin:0},children:"Estimate"}),e.jsx("h1",{style:{fontSize:"28px",fontWeight:700,margin:"4px 0",color:"#0f172a"},children:r.estimate_number}),r.sent_date&&e.jsxs("p",{style:{color:"#64748b",fontSize:"14px",margin:0},children:["Sent ",Y(r.sent_date).format("MMMM D, YYYY")]}),e.jsxs("div",{style:{border:"2px solid #000",borderRadius:"16px",padding:"20px",marginTop:"20px"},children:[e.jsx("p",{style:{color:"#506a5b",fontWeight:600,margin:"0 0 12px"},children:"Prepared For"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",fontSize:"14px"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"#64748b",display:"block",fontSize:"12px"},children:"Name"}),e.jsx("span",{style:{fontWeight:600},children:r.client_name})]}),r.client_email&&e.jsxs("div",{children:[e.jsx("span",{style:{color:"#64748b",display:"block",fontSize:"12px"},children:"Email"}),e.jsx("span",{style:{fontWeight:600},children:r.client_email})]}),r.client_phone&&e.jsxs("div",{children:[e.jsx("span",{style:{color:"#64748b",display:"block",fontSize:"12px"},children:"Phone"}),e.jsx("span",{style:{fontWeight:600},children:r.client_phone})]}),r.project_address&&e.jsxs("div",{children:[e.jsx("span",{style:{color:"#64748b",display:"block",fontSize:"12px"},children:"Project Address"}),e.jsxs("span",{style:{fontWeight:600},children:[r.project_address,r.town?`, ${r.town}`:""]})]})]})]}),e.jsxs("div",{style:{border:"2px solid #000",borderRadius:"16px",padding:"20px",marginTop:"16px"},children:[e.jsx("p",{style:{color:"#506a5b",fontWeight:600,margin:"0 0 16px"},children:"Scope of Work"}),N?e.jsxs(e.Fragment,{children:[v.map((s,o)=>{const f=l(s);if(f.length===0)return null;const u=(parseFloat(s.hours)||0)*(parseFloat(s.hourly_rate)||0);return e.jsxs("div",{style:{marginBottom:"16px"},children:[s.name&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderBottom:"1px solid #e2e8f0",paddingBottom:"6px",marginBottom:"6px"},children:[e.jsx("span",{style:{fontWeight:600,color:"#334155",fontSize:"15px"},children:s.name}),u>0&&e.jsxs("span",{style:{fontWeight:600,color:"#506a5b",fontSize:"15px"},children:["$",_(u)]})]}),f.map((w,g)=>e.jsxs("div",{style:{display:"flex",gap:"10px",padding:"4px 0",fontSize:"14px",color:"#334155"},children:[e.jsx("span",{style:{color:"#7c917c"},children:"â¢"}),e.jsx("span",{children:w.description})]},g))]},o)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"12px"},children:e.jsxs("div",{style:{width:"280px",border:"1px solid #506a5b",borderRadius:"12px",overflow:"hidden"},children:[d>0&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #506a5b",fontSize:"14px"},children:[e.jsx("span",{style:{color:"#475569"},children:"Material"}),e.jsxs("span",{style:{fontWeight:600},children:["$",_(d)]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #506a5b",fontSize:"14px"},children:[e.jsx("span",{style:{color:"#475569"},children:"Labor"}),e.jsxs("span",{style:{fontWeight:600},children:["$",_(i)]})]}),r.discount>0&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 16px",borderBottom:"1px solid #506a5b",fontSize:"14px"},children:[e.jsx("span",{style:{color:"#475569"},children:"Discount"}),e.jsxs("span",{style:{fontWeight:600,color:"#b91c1c"},children:["-$",_(r.discount)]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"14px 16px",background:"linear-gradient(to right, #506a5b, #7c917c)",fontSize:"15px"},children:[e.jsx("span",{style:{fontWeight:600,color:"#fff"},children:"Total"}),e.jsxs("span",{style:{fontWeight:700,color:"#fff"},children:["$",_(r.total)]})]})]})})]}):e.jsx("p",{style:{color:"#64748b",fontSize:"14px",textAlign:"center",padding:"12px"},children:"No line items added yet"})]}),a.some(s=>l(s).length>
60)&&e.jsxs("div",{style:{border:"2px solid #000",borderRadius:"16px",padding:"20px",marginTop:"16px"},children:[e.jsx("p",{style:{color:"#b45309",fontWeight:600,margin:"0 0 16px"},children:"Optional Add-ons"}),a.map((s,o)=>{const f=l(s);if(f.length===0)return null;const u=(parseFloat(s.hours)||0)*(parseFloat(s.hourly_rate)||0),w=(s.items||[]).filter(g=>g.type==="material").reduce((g,T)=>g+(T.total||0),0);return e.jsxs("div",{style:{marginBottom:"16px"},children:[s.name&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",borderBottom:"1px solid #e2e8f0",paddingBottom:"6px",marginBottom:"6px"},children:[e.jsx("span",{style:{fontWeight:600,color:"#334155",fontSize:"15px"},children:s.name}),u+w>0&&e.jsxs("span",{style:{fontWeight:600,color:"#b45309",fontSize:"15px"},children:["$",_(u+w)]})]}),f.map((g,T)=>e.jsxs("div",{style:{display:"flex",gap:"10px",padding:"4px 0",fontSize:"14px",color:"#334155"},children:[e.jsx("span",{style:{color:"#7c917c"},children:"â¢"}),e.jsx("span",{children:g.description})]},T))]},o)}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:"12px"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"280px",border:"1px solid #b45309",borderRadius:"12px",padding:"10px 16px",fontSize:"14px"},children:[e.jsx("span",{style:{color:"#475569"},children:"Optional Total"}),e.jsxs("span",{style:{fontWeight:600,color:"#b45309"},children:["$",_(c)]})]})})]}),r.terms_warranty&&e.jsxs("div",{style:{border:"2px solid #000",borderRadius:"16px",padding:"20px",marginTop:"16px"},children:[e.jsx("p",{style:{color:"#506a5b",fontWeight:600,margin:"0 0 8px"},children:"Terms & Warranty"}),e.jsx("div",{style:{fontSize:"13px",color:"#475569"},dangerouslySetInnerHTML:{__html:r.terms_warranty}})]}),r.valid_until&&e.jsxs("p",{style:{fontSize:"12px",color:"#64748b",textAlign:"center",marginTop:"16px"},children:["This estimate is valid until ",Y(r.valid_until).format("MMMM D, YYYY")]}),e.jsxs("div",{style:{textAlign:"center",fontSize:"13px",color:"#334155",marginTop:"24px",fontWeight:600,lineHeight:1.6},children:[e.jsx("div",{children:"Mike Gallagher"}),e.jsx("div",{children:"Founder & Owner"}),e.jsx("div",{children:"781.369.1907"}),e.jsx("div",{children:"[email protected]"})]})]})}const ut={toolbar:[[{header:[1,2,3,!1]}],["bold","italic","underline","strike"],[{align:[]}],[{list:"ordered"},{list:"bullet"}],[{indent:"-1"},{indent:"+1"}],["clean"]]};function ps(){const{id:r}=ze(),h=$e(),[l,v]=n.useState(!0),[a,N]=n.useState(null),[i,d]=n.useState([]),[c,s]=n.useState(0),[o,f]=n.useState(""),[u,w]=n.useState(""),[g,T]=n.useState(""),[E,J]=n.useState(""),[D,G]=n.useState(""),[P,H]=n.useState(""),[M,V]=n.useState(""),[W,Q]=n.useState(""),[we,K]=n.useState("interior_residential"),[C,O]=n.useState([]),[k,X]=n.useState(0),[Z,ee]=n.useState(!1),[R,te]=n.useState(!1),[se,ae]=n.useState(!1),[Se,z]=n.useState(!1),S=n.useRef(null),$=n.useRef(!1),L=n.useRef(null),_e=async()=>{if(L.current){ae(!0);try{await Ke(L.current,`${a.estimate_number||"estimate"}.pdf`)}catch{x.error("Failed to generate PDF")}ae(!1)}},F=n.useCallback(async()=>{v(!0);try{const t=await j.entities.Estimate.get(r);N(t);let p=t.hourly_rate||0;if(!p)try{const m=await j.entities.RateSetting.list();m.length>0&&(p=m[0].hourly_rate||0)}catch{}s(p);try{const m=JSON.parse(t.areas||"[]");d(m.length>0?m:[{id:"1",name:"",items:[],hours:0,hourly_rate:p}])}catch{d([{id:"1",name:"",items:[],hours:0,hourly_rate:p}])}f(t.terms_warranty||pt),w(t.notes||""),T(t.valid_until||""),J(t.town||""),G(t.client_name||""),H(t.client_email||""),V(t.client_phone||""),Q(t.project_address||""),K(t.project_type||"interior_residential"),X(t.discount||0);try{const m=JSON.parse(t.change_orders||"[]");O(Array.isArray(m)?m:[])}catch{O([])}}catch{x.error("Estimate not found"),h("/estimates")}v(!1),$.current=!0},[r,h]);n.useEffect(()=>{F()},[F]),n.useEffect(()=>{if(!(!$.current||!a))return S.current&&clearTimeout(S.current),S.current=setTimeout(async()=>{try{const t=pe(i),p=xe(i),m=he(i),ce=ue(i),b=q(C),me=Math.round((p+m)*100)/100,We=Math.max(0,parseFloat(k)||0),Oe=Math.round((me+b-We)*100)/100;await j.entities.Estimate.update(a.id,{areas:JSON.stringify(i),line_items:JSON.stringify(t),change_orders:JSON.stringify(C),hourly_rate:parseFloat(c)||0,total_hours:ce,labor:m,material_estimated:p,subtotal:me,discount:parseFloat(k)||0,tax_rate:0,tax_amount:0,total:Oe,terms_warranty:o,notes:u,valid_until:g,town:E,client_name:D,client_email:P,client_phone:M,project_address:W})}catch{}},1500),()=>{S.current&&clearTimeout(S.current)}},[i,c,o,u,g,E,D,P,M,W,C,k,a]);const Te=pe(i),I=xe(i),B=he(i),re=ue(i),U=q(C),ne=Math.round((I+B)*100)/100,Ce=Math.max(0,parseFloat(k)||0),ie=Math.round((ne+U-Ce)*100)/100,oe=Be(i),ke=async()=>{ee(!0);try{await j.entities.Estimate.update(a.id,{areas:JSON.stringify(i),line_items:JSON.stringify(Te),change_orders:JSON.stringify(C),hourly_rate:parseFloat(c)||0,total_hours:re,labor:B,material_estimated:I,subtotal:ne,discount:parseFloat(k)||0,tax_rate:0,tax_amount:0,total:ie,terms_warranty:o,notes:u,valid_until:g,town:E,client_name:D,client_email:P,client_phone:M,project_address:W}),x.success("Estimate saved"),F()}catch{x.error("Failed to save")}ee(!1)},Ae=()=>{if(!a.client_email){x.error("Add a client email first");return}z(!0)},Fe=async({to:t,subject:p,body:m,noTracking:ce})=>{te(!0);try{await j.functions.invoke("sendEstimateEmail",{to:t,subject:p,body:m});let b=[];try{b=JSON.parse(a.view_history||"[]")}catch{}b.push({type:"sent",timestamp:new Date().toISOString()}),await j.entities.Estimate.update(a.id,{status:"sent",sent_date:new Date().toISOString(),view_history:JSON.stringify(b)}),x.success(`Estimate sent to ${t}`),z(!1),F()}catch(b){console.error("Send estimate error:",b),x.error("Failed to send estimate: "+((b==null?void 0:b.message)||"Unknown error"))}te(!1)},[le,de]=n.useState(!1),Ee=async()=>{de(!0);try{const t=await j.functions.invoke("onEstimateAccepted",{estimateId:a.id});x.success(`Accepted â project, deposit invoice & sub-offer created${t!=null&&t.emailSentTo?`, email sent to ${t.emailSentTo}`:""}`),F()}catch(t){x.error("Failed to accept estimate: "+((t==null?void 0:t.message)||"Unknown error"))}de(!1)},De=async t=>{const p=a.status;await j.entities.Estimate.update(a.id,{status:t}),N(m=>({...m,status:t})),t==="accepted"&&p!=="accepted"?x.success("Status updated â creating project, deposit invoice & sub-offer"):x.success("Status updated")},Pe=async t=>{K(t),N(p=>({...p,project_type:t}));try{await j.entities.Estimate.update(a.id,{project_type:t})}catch{x.error("Failed to update project type")}},Me=async()=>
6{if(confirm(`Delete estimate ${a.estimate_number}?`)){S.current&&clearTimeout(S.current),$.current=!1,h("/estimates");try{await j.entities.Estimate.delete(a.id),x.success("Estimate deleted")}catch{x.error("Failed to delete estimate")}}};return l||!a?e.jsx("div",{className:"flex items-center justify-center h-full min-h-[400px]",children:e.jsx("div",{className:"w-8 h-8 border-4 border-secondary border-t-accent rounded-full animate-spin"})}):e.jsxs("div",{className:"p-6 md:p-8 max-w-6xl mx-auto",children:[e.jsxs("button",{onClick:()=>h("/estimates"),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground transition-colors mb-4",children:[e.jsx(Ze,{className:"w-4 h-4"})," Back to Estimates"]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-heading font-bold tracking-tight",children:a.estimate_number}),e.jsx(Ie,{status:a.status,type:"estimate"})]}),e.jsx("p",{className:"text-muted-foreground text-sm",children:a.client_name})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs(fe,{value:we,onValueChange:Pe,children:[e.jsx(be,{className:"w-[180px] rounded-xl h-9 text-xs",children:e.jsx(je,{})}),e.jsx(ye,{children:Xe.map(t=>e.jsx(ve,{value:t.value,className:"text-xs",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{background:t.color}}),t.label]})},t.value))})]}),e.jsxs(fe,{value:a.status,onValueChange:De,children:[e.jsx(be,{className:"w-[140px] rounded-xl h-9 text-xs capitalize",children:e.jsx(je,{})}),e.jsx(ye,{children:["draft","sent","viewed","accepted","rejected","expired"].map(t=>e.jsx(ve,{value:t,className:"capitalize text-xs",children:t},t))})]}),a.status!=="accepted"&&e.jsxs(A,{onClick:Ee,disabled:le,className:"rounded-xl gap-2 text-xs h-9 bg-green-600 hover:bg-green-700 text-white",children:[e.jsx(et,{className:"w-3.5 h-3.5"})," ",le?"Accepting...":"Accept & Create Project"]}),e.jsxs(A,{variant:"outline",onClick:Me,className:"rounded-xl gap-2 text-xs h-9 hover:bg-red-50 hover:text-red-500",children:[e.jsx(Ne,{className:"w-3.5 h-3.5"})," Delete"]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-5",children:[e.jsxs("h2",{className:"font-heading font-semibold text-sm mb-3 flex items-center gap-2",children:[e.jsx(tt,{className:"w-4 h-4 text-muted-foreground"})," Client Information"]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs block mb-0.5",children:"Name"}),e.jsx(y,{value:D,onChange:t=>G(t.target.value),placeholder:"Client name",className:"h-7 text-sm rounded-lg"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs block mb-0.5",children:"Email"}),e.jsx(y,{type:"email",value:P,onChange:t=>H(t.target.value),placeholder:"[email protected]",className:"h-7 text-sm rounded-lg"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs block mb-0.5",children:"Phone"}),e.jsx(y,{value:M,onChange:t=>V(t.target.value),placeholder:"555-123-4567",className:"h-7 text-sm rounded-lg"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs block mb-0.5",children:"Address"}),e.jsx(y,{value:W,onChange:t=>Q(t.target.value),placeholder:"Job site address",className:"h-7 text-sm rounded-lg"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs block mb-0.5",children:"Town"}),e.jsx(y,{value:E,onChange:t=>J(t.target.value),placeholder:"Enter town",className:"h-7 text-sm rounded-lg"})]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-5",children:[e.jsxs("h2",{className:"font-heading font-semibold text-sm mb-3 flex items-center gap-2",children:[e.jsx(Le,{className:"w-4 h-4 text-muted-foreground"})," Areas & Line Items"]}),e.jsx(Ue,{areas:i,onChange:d,defaultHourlyRate:c})]}),e.jsx("div",{className:"rounded-2xl border border-border bg-card p-5",children:e.jsx(Ge,{parentType:"estimate",parentId:a.id})}),e.jsx("div",{className:"rounded-2xl border border-amber-500/20 bg-card p-5",children:e.jsx(mt,{changeOrders:C,onChange:O})}),e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-5",children:[e.jsx("h2",{className:"font-heading font-semibold text-sm mb-3",children:"Terms & Warranty"}),e.jsx("div",{className:"rounded-lg border border-border overflow-hidden",children:e.jsx(Ve,{theme:"snow",value:o,onChange:f,modules:ut,className:"estimates-quill"})}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"This content is shown to the customer on the public estimate."})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-5",children:[e.jsx(ge,{className:"text-sm font-heading font-semibold",children:"Internal Notes"}),e.jsx(He,{value:u,onChange:t=>w(t.target.value),placeholder:"Admin-only notes â not shown to customer...",className:"rounded-xl mt-2 min-h-[70px]"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"These notes are private and only visible to you."})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-5 sticky top-0",children:[e.jsx("h2",{className:"font-heading font-semibold text-sm mb-4",children:"Summary"}),e.jsxs("div",{className:"space-y-2.5 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Labor (",re.toLocaleStr
6ing()," hrs)"]}),e.jsxs("span",{className:"font-medium",children:["$",B.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Materials"}),e.jsxs("span",{className:"font-medium",children:["$",I.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),U!==0&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("span",{className:"text-muted-foreground",children:"Change Orders"}),e.jsxs("span",{className:"font-medium text-amber-400",children:["$",U.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2.5",children:[e.jsx("span",{className:"text-muted-foreground",children:"Discount ($)"}),e.jsx(y,{type:"number",value:k,onChange:t=>X(t.target.value),className:"h-7 w-24 text-right rounded-lg",placeholder:"0"})]}),e.jsxs("div",{className:"border-t border-border pt-2.5 mt-2.5 flex justify-between items-center",children:[e.jsx("span",{className:"font-heading font-semibold",children:"Total"}),e.jsxs("span",{className:"font-heading font-bold text-xl text-accent",children:["$",ie.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]}),oe>0&&e.jsxs("div",{className:"flex justify-between pt-2.5 mt-2.5 border-t border-border",children:[e.jsx("span",{className:"text-amber-400 font-medium",children:"Optional Add-ons"}),e.jsxs("span",{className:"font-medium text-amber-400",children:["$",oe.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})]})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx(ge,{className:"text-xs",children:"Valid Until"}),e.jsx(y,{type:"date",value:g,onChange:t=>T(t.target.value),className:"rounded-lg mt-1 h-9 text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-4",children:[e.jsxs(A,{onClick:ke,disabled:Z,className:"bg-accent hover:bg-accent/90 text-white rounded-xl gap-2 h-9",children:[e.jsx(st,{className:"w-3.5 h-3.5"})," ",Z?"Saving...":"Save"]}),e.jsxs("a",{href:`${window.location.origin}/estimate/${a.id}?preview=true`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center justify-center gap-2 h-9 rounded-xl border border-input bg-transparent text-sm font-medium hover:bg-accent hover:text-accent-foreground transition-colors px-3",children:[e.jsx(at,{className:"w-3.5 h-3.5"})," Preview"]}),e.jsxs(A,{variant:"outline",onClick:Ae,disabled:R,className:"rounded-xl gap-2 h-9",children:[e.jsx(rt,{className:"w-3.5 h-3.5"})," ",R?"Sending...":"Send"]}),e.jsxs(A,{variant:"outline",onClick:_e,disabled:se,className:"rounded-xl gap-2 h-9",children:[e.jsx(nt,{className:"w-3.5 h-3.5"})," ",se?"...":"PDF"]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-card p-5",children:[e.jsxs("h2",{className:"font-heading font-semibold text-sm mb-4 flex items-center gap-2",children:[e.jsx(it,{className:"w-4 h-4 text-muted-foreground"})," Activity Tracking"]}),e.jsx(Je,{estimate:a})]})]})]}),e.jsx(Qe,{record:a,type:"estimate"}),e.jsx(Ye,{open:Se,onOpenChange:z,estimate:a,areas:i,onSend:Fe,sending:R}),e.jsx("div",{style:{position:"fixed",left:"-9999px",top:0,pointerEvents:"none"},"aria-hidden":!0,children:e.jsx("div",{ref:L,children:e.jsx(ht,{estimate:a,areas:i})})})]})}export{ps 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.