1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/xlsx.min-HJsoRPpl.js","assets/index-C6ghbvAw.js"])))=>i.map(i=>d[i]); 2import{r as o,l as Ft,j as e,k as et,s as Me,_ as Ve,i as Je}from"./index-C6ghbvAw.js";import{H as Pt}from"./Header-Ds9I6hWI.js";import Mt from"./Footer-D8VzQGBK.js";import Et from"./FloatingWhatsApp-CdSytqGl.js";import{u as Tt}from"./useTikTokConversions-DOEg0aL7.js";import{B as A}from"./button-BbS7p2-k.js";import{C as At}from"./calendar-CzSfpfO5.js";import{P as Dt,a as Lt,b as Rt,C as zt}from"./popover-Dtg8uwAs.js";import{S as pe,a as xe,b as fe,c as ge,d as b,C as lt}from"./select-BFGQXtCb.js";import{I as Ne}from"./input-Cbwh2FhS.js";import{T as ot}from"./textarea-8GBgRy3q.js";import{L as V}from"./label-tIvJrmCc.js";import{C as Ge,a as Ye,b as it,c as ct,d as dt}from"./card-DcpNRYUu.js";import{t as Oe}from"./use-toast-C3nhwJwR.js";import{C as It}from"./circle-check-big-CytuKn4U.js";import{C as $t}from"./calendar-C7aIZM4J.js";import{f as We}from"./format-nkMjC4PZ.js";import{C as mt}from"./clock-C4VYBqaB.js";import{C as Bt}from"./checkbox-CAtmi11r.js";import{T as Ut,a as Ot,b as qe,c as He}from"./tabs-DLjdEhAu.js";import{t as he}from"./index-ynMxUyrx.js";import{u as ut}from"./useSEO-BxZ-huKq.js";import{D as Wt}from"./dollar-sign-D0Ub771O.js";import{C as ht}from"./chevron-down-lfBaL0Tq.js";import{M as qt}from"./message-square-ndljZV2b.js";import{P as Ht}from"./phone-CUUs3bXf.js";import{c as oe}from"./createLucideIcon-Dy-MC8t5.js";import{U as Vt}from"./upload-IMMz7Q36.js";import{F as pt,S as tt}from"./sparkles-aNfXL2wy.js";import{X as xt}from"./x-Bp_ez2j9.js";import{L as Te}from"./loader-circle-BDyB7zlj.js";import{E as Gt}from"./eye-CV-iEaYi.js";import{C as Yt}from"./circle-check-B-EPUK-B.js";import{R as Ae}from"./ruler-CPXvhT1d.js";import{P as Jt}from"./pencil-m8Ae8LYG.js";import{M as Zt}from"./mouse-pointer-2-C1mBXL-P.js";import{T as Kt}from"./trash-2-CE20MpM8.js";import{T as Xt}from"./tag-CrVvMEKT.js";import{C as Qt}from"./chevron-right-CjjsFwvR.js";import{S as _t}from"./slider-Ifiudkbo.js";import{Z as es}from"./zap-DES_77W2.js";import{W as ts}from"./wrench-CXoXdtfi.js";import{S as ss}from"./SEOMetadata-oGnP-5Az.js";import"./index-BrhRmS2u.js";import"./index-DHsQl3TH.js";import"./index-C-eifxmw.js";import"./dialog-CPKHOkbx.js";import"./search-tVy8geSf.js";import"./arrow-right-bSGT2rVi.js";import"./badge-check-Csojkx9G.js";import"./linkedin-BEoJGbsh.js";import"./message-circle-CgS41cO6.js";import"./index-C2P2Lrb-.js";import"./en-US-DIdCsyf3.js";import"./endOfMonth-CPKoobw2.js";import"./index-C0pbmnxW.js";import"./index-BHqJpBG2.js";import"./check-Rn0oPDsL.js";import"./useQuery-vdPRfJTf.js";const as=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],rs=oe("circle-dot",as);const ns=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],ls=oe("file-spreadsheet",ns);const os=[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]],is=oe("highlighter",os);const cs=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ds=oe("maximize-2",cs);const ms=[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]],us=oe("move",ms);const hs=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]],ps=oe("pen-tool",hs);const xs=[["path",{d:"M10.83 2.38a2 2 0 0 1 2.34 0l8 5.74a2 2 0 0 1 .73 2.25l-3.04 9.26a2 2 0 0 1-1.9 1.37H7.04a2 2 0 0 1-1.9-1.37L2.1 10.37a2 2 0 0 1 .73-2.25z",key:"2hea0t"}]],fs=oe("pentagon",xs);const gs=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],st=oe("rotate-ccw",gs);const ys=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],bs=oe("square",ys);const js=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],vs=oe("zoom-in",js);const ws=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Ns=oe("zoom-out",ws),at=[{value:"panel-upgrade",label:"Electrical Panel Upgrade"},{value:"residential-repair",label:"Residential Electrical Repair"},{value:"commercial-electrical",label:"Commercial Electrical Services"},{value:"ev-charger",label:"EV Charger Installation"},{value:"lighting",label:"Lighting Installation"},{value:"wiring",label:"Electrical Wiring"},{value:"inspection",label:"Electrical Inspection"},{value:"generator",label:"Generator Installation"},{value:"solar",label:"Solar Installation"},{value:"other",label:"Other Services"}],Ss=["8:00 AM","9:00 AM","10:00 AM","11:00 AM","12:00 PM","1:00 PM","2:00 PM","3:00 PM","4:00 PM","5:00 PM"];
2function ks(){const[r,a]=o.useState(),[h,L]=o.useState(""),[j,N]=o.useState(""),[v,p]=o.useState(""),[d,M]=o.useState(""),[S,x]=o.useState(""),[m,k]=o.useState(""),[w,E]=o.useState(!1),[F,y]=o.useState(!1),{trackSchedule:u}=Tt(),[D]=Ft();o.useEffect(()=>{if(D.get("from")==="estimator"){const f=D.get("name"),T=D.get("email"),q=D.get("phone"),c=D.get("service");if(f&&p(f),T&&M(T),q&&x(q),c){const C=at.find(g=>g.value===c||g.label.toLowerCase().includes(c.toLowerCase()));N(C?.value||"other"),C||k(g=>g||`Service requested: ${c}`)}}},[D]);const R=async f=>{if(f.preventDefault(),!r||!h||!j||!v||!d||!S){Oe({title:"Missing Information",description:"Please fill in all required fields.",variant:"destructive"});return}E(!0);try{const T=We(r,"yyyy-MM-dd"),{error:q}=await Me.from("appointments").insert({full_name:v,email:d,phone:S,service_type:j,preferred_date:T,preferred_time:h,notes:m||null});if(q)throw q;try{await Me.functions.invoke("send-appointment-email",{body:{type:"submitted",customerName:v,customerEmail:d,serviceType:j,preferredDate:We(r,"MMMM d, yyyy"),preferredTime:h,notes:m||void 0}})}catch(c){console.error("Failed to send confirmation email:",c)}y(!0),u({email:d,phone:S}),Oe({title:"Appointment Requested!",description:"We'll contact you shortly to confirm your appointment. Check your email for confirmation."}),a(void 0),L(""),N(""),p(""),M(""),x(""),k("")}catch(T){console.error("Error submitting appointment:",T),Oe({title:"Error",description:"Failed to submit appointment. Please try again.",variant:"destructive"})}finally{E(!1)}};return F?e.jsx(Ge,{className:"max-w-2xl mx-auto",children:e.jsx(Ye,{className:"pt-6",children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx(It,{className:"h-16 w-16 text-green-500 mx-auto mb-4"}),e.jsx("h3",{className:"text-2xl font-bold text-foreground mb-2",children:"Appointment Request Submitted!"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Thank you for scheduling with Crescent Electric. We'll contact you within 24 hours to confirm your appointment."}),e.jsx(A,{onClick:()=>y(!1),children:"Schedule Another Appointment"})]})})}):e.jsxs(Ge,{className:"max-w-2xl mx-auto",children:[e.jsxs(it,{children:[e.jsx(ct,{className:"text-2xl",children:"Schedule an Appointment"}),e.jsx(dt,{children:"Select your service, preferred date and time, and we'll confirm your appointment within 24 hours."})]}),e.jsx(Ye,{children:e.jsxs("form",{onSubmit:R,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"service",children:"Service Type *"}),e.jsxs(pe,{value:j,onValueChange:N,children:[e.jsx(xe,{children:e.jsx(fe,{placeholder:"Select a service"})}),e.jsx(ge,{children:at.map(f=>e.jsx(b,{value:f.value,children:f.label},f.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{children:"Preferred Date *"}),e.jsxs(Dt,{children:[e.jsx(Lt,{asChild:!0,children:e.jsxs(A,{variant:"outline",className:et("w-full justify-start text-left font-normal",!r&&"text-muted-foreground"),children:[e.jsx($t,{className:"mr-2 h-4 w-4"}),r?We(r,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(Rt,{className:"w-auto p-0",align:"start",children:e.jsx(At,{mode:"single",selected:r,onSelect:a,disabled:f=>f<new Date||f.getDay()===0,initialFocus:!0,className:et("p-3 pointer-events-auto")})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{children:"Preferred Time *"}),e.jsxs(pe,{value:h,onValueChange:L,children:[e.jsxs(xe,{children:[e.jsx(mt,{className:"mr-2 h-4 w-4"}),e.jsx(fe,{placeholder:"Select a time"})]}),e.jsx(ge,{children:Ss.map(f=>e.jsx(b,{value:f,children:f},f))})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Contact Information"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"fullName",children:"Full Name *"}),e.jsx(Ne,{id:"fullName",value:v,onChange:f=>p(f.target.value),placeholder:"John Doe",required:!0})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"email",children:"Email *"}),e.jsx(Ne,{id:"email",type:"email",value:d,onChange:f=>M(f.target.value),placeholder:"[email protected]",required:!0})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"phone",children:"Phone *"}),e.jsx(Ne,{id:"phone",type:"tel",value:S,onChange:f=>x(f.target.value),placeholder:"(780) 555-0123",required:!0})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"notes",children:"Additional Notes (Optional)"}),e.jsx(ot,{id:"notes",value:m,onChange:f=>k(f.target.value),placeholder:"Describe your electrical issue or any special requirements...",rows:3})]}),e.jsx(A,{type:"submit",className:"w-full",disabled:w,children:w?"Submitting...":"Request Appointment"}),e.jsx("p",{className:"text-sm text-muted-foreground text-center",children:"We'll contact you within 24 hours to confirm your appointment time."})]})})]})}
2const Cs=({estimate:r,showDetails:a,onToggleDetails:h,phoneForTel:L,takeoffItems:j=[],measurements:N=[]})=>{const v=async()=>{try{const p=await Ve(()=>import("./xlsx.min-HJsoRPpl.js").then(c=>c.x),__vite__mapDeps([0,1])),d=[["Crescent Electric â Project Estimate"],[],["Service Type",r.serviceType||"N/A","","Property Type",r.propertyType||"N/A"],["Square Footage",r.squareFootage?`${r.squareFootage} sq ft`:"N/A","","Time Estimate",r.timeEstimate],[],["COST BREAKDOWN"],["Item","Min Cost ($)","Max Cost ($)","Notes"]];r.lineItems.forEach(c=>{d.push([c.item,c.minCost,c.maxCost,c.notes||""])}),d.push(["TOTAL",r.estimatedMinCost,r.estimatedMaxCost,""]);const M=d.length;if(j.length>0){d.push([]),d.push(["TAKEOFF HIGHLIGHTS"]),d.push(["Category","Count","Labels",""]),j.forEach(C=>{d.push([C.category,C.count,C.labels.join(", "),""])});const c=j.reduce((C,g)=>C+g.count,0);d.push(["TOTAL ITEMS",c,"",""])}const S=d.length;N.length>0&&(d.push([]),d.push(["MEASUREMENTS"]),d.push(["Line #","Distance","Unit",""]),N.forEach((c,C)=>{const g=c.realLength;d.push([`Line ${C+1}`,g!=null?Number(g.toFixed(1)):Math.round(c.pixelLength),g!=null?"ft":"px",""])}));const x=p.utils.aoa_to_sheet(d);x["!cols"]=[{wch:35},{wch:14},{wch:14},{wch:40}],x["!merges"]=[{s:{r:0,c:0},e:{r:0,c:3}}];const m={font:{bold:!0,sz:16,color:{rgb:"FFFFFF"}},fill:{fgColor:{rgb:"1E3A5F"}},alignment:{horizontal:"center"}},k=c=>({font:{bold:!0,sz:12,color:{rgb:"FFFFFF"}},fill:{fgColor:{rgb:c}}}),w=c=>({font:{bold:!0,sz:10,color:{rgb:"FFFFFF"}},fill:{fgColor:{rgb:c}},border:{bottom:{style:"thin",color:{rgb:"000000"}}}}),E={font:{bold:!0,sz:11},fill:{fgColor:{rgb:"E8F5E9"}},border:{top:{style:"medium",color:{rgb:"2E7D32"}}}},F={font:{bold:!0,color:{rgb:"374151"}},fill:{fgColor:{rgb:"F3F4F6"}}},y=(c,C,g)=>{for(let $=0;$<C;$++){const B=p.utils.encode_cell({r:c,c:$});x[B]&&(x[B].s=g)}};y(0,4,m),["A3","D3","A4","D4"].forEach(c=>{x[c]&&(x[c].s=F)}),y(5,4,k("2563EB")),y(6,4,w("3B82F6"));const u="$#,##0",D=7,R=D+r.lineItems.length;for(let c=D;c<R;c++){const C=(c-D)%2===0?"F8FAFC":"FFFFFF";y(c,4,{fill:{fgColor:{rgb:C}},border:{bottom:{style:"thin",color:{rgb:"E2E8F0"}}}});const g=p.utils.encode_cell({r:c,c:1}),$=p.utils.encode_cell({r:c,c:2});x[g]&&(x[g].z=u),x[$]&&(x[$].z=u)}y(R,4,E);const f=p.utils.encode_cell({r:R,c:1}),T=p.utils.encode_cell({r:R,c:2});if(x[f]&&(x[f].z=u),x[T]&&(x[T].z=u),j.length>0){const c=M+1;y(c,4,k("7C3AED")),y(c+1,4,w("8B5CF6"));const C=c+2;for(let g=C;g<C+j.length;g++){const $=(g-C)%2===0?"F5F3FF":"FFFFFF";y(g,4,{fill:{fgColor:{rgb:$}}})}y(C+j.length,4,{font:{bold:!0},fill:{fgColor:{rgb:"EDE9FE"}},border:{top:{style:"medium",color:{rgb:"7C3AED"}}}})}if(N.length>0){const c=S+1;y(c,4,k("0891B2")),y(c+1,4,w("06B6D4"));const C=c+2;for(let g=C;g<C+N.length;g++){const $=(g-C)%2===0?"ECFEFF":"FFFFFF";y(g,4,{fill:{fgColor:{rgb:$}}})}}const q=p.utils.book_new();p.utils.book_append_sheet(q,x,"Estimate"),p.writeFile(q,"Crescent_Electric_Estimate.xlsx"),he.success("Estimate exported to Excel")}catch{he.error("Failed to export")}};return e.jsxs("div",{className:"space-y-4 animate-in fade-in-0 slide-in-from-bottom-4 duration-500",children:[e.jsx("div",{className:"bg-primary/5 rounded-lg p-6 border-2 border-primary/20",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:"Estimated Project Cost"}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-4xl font-bold text-primary",children:[e.jsx(Wt,{className:"h-8 w-8"}),r.estimatedMinCost.toLocaleString()," â $",r.estimatedMaxCost.toLocaleString()]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 mt-2 text-muted-foreground",children:[e.jsx(mt,{className:"h-4 w-4"}),e.jsxs("span",{className:"text-sm",children:["Estimated time: ",r.timeEstimate]})]})]})}),e.jsx("p",{className:"text-sm text-foreground",children:r.summary}),e.jsxs(A,{variant:"ghost",className:"w-full justify-between",onClick:h,children:[e.jsxs("span",{className:"font-medium",children:["Cost Breakdown (",r.lineItems.length," items)"]}),a?e.jsx(lt,{className:"h-4 w-4"}):e.jsx(ht,{className:"h-4 w-4"})]}),a&&e.jsxs("div",{className:"space-y-2",children:[r.lineItems.map((p,d)=>e.jsxs("div",{className:"flex items-start justify-between p-3 rounded-lg bg-muted/50 border border-border",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:p.item}),p.notes&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:p.notes})]}),e.jsxs("p",{className:"text-sm font-semibold text-primary whitespace-nowrap ml-4",children:["$",p.minCost.toLocaleStr
2ing()," â $",p.maxCost.toLocaleString()]})]},d)),j.length>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border",children:[e.jsx("p",{className:"text-xs font-semibold text-muted-foreground mb-2",children:"ð Takeoff Highlights"}),j.map((p,d)=>e.jsxs("div",{className:"flex items-center justify-between text-xs py-1",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full inline-block",style:{backgroundColor:p.color}}),e.jsx("span",{className:"text-muted-foreground",children:p.category})]}),e.jsxs("span",{className:"font-mono font-bold text-foreground",children:["Ã",p.count]})]},d))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground italic border-t pt-3",children:r.disclaimer}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsxs(A,{className:"flex-1",size:"lg",onClick:()=>window.location.href="/#contact",children:[e.jsx(qt,{className:"mr-2 h-4 w-4"}),"Request Detailed Quote"]}),e.jsx(A,{variant:"outline",size:"lg",className:"flex-1",asChild:!0,children:e.jsxs("a",{href:"tel:+1587
25575494",children:[e.jsx(Ht,{className:"mr-2 h-4 w-4"}),"Call Now"]})})]}),e.jsxs(A,{variant:"secondary",className:"w-full",onClick:v,children:[e.jsx(ls,{className:"mr-2 h-4 w-4"}),"Export to Excel",j.length>0?" (with Takeoff)":""]})]})},Fs=r=>{const a=Je.c(15),{uploadedFile:h,isAnalyzing:L,analysisComplete:j,detectedObjects:N,onFileUpload:v,onRemoveFile:p,onAnalyze:d}=r,M=o.useRef(null);let S;a[0]!==v?(S=F=>{const y=F.target.files?.[0];!y||y.size>10485760||!["application/pdf","image/jpeg","image/png","image/webp"].includes(y.type)||v(y)},a[0]=v,a[1]=S):S=a[1];const x=S;let m;a[2]===Symbol.for("react.memo_cache_sentinel")?(m=e.jsx(V,{children:"Upload Blueprint / Drawing (Optional)"}),a[2]=m):m=a[2];let k;a[3]!==j||a[4]!==N||a[5]!==L||a[6]!==d||a[7]!==p||a[8]!==h?(k=e.jsx("div",{className:"border-2 border-dashed border-border rounded-lg p-4 text-center",children:h?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-md p-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(pt,{className:"h-5 w-5 text-primary shrink-0"}),e.jsx("span",{className:"text-sm truncate",children:h.name}),e.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:["(",(h.size/1024/1024).toFixed(1)," MB)"]})]}),e.jsx(A,{variant:"ghost",size:"icon",className:"shrink-0 h-8 w-8",onClick:p,children:e.jsx(xt,{className:"h-4 w-4"})})]}),!j&&e.jsx(A,{onClick:d,disabled:L,variant:"secondary",className:"w-full",children:L?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"mr-2 h-4 w-4 animate-spin"}),"Detecting electrical components..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Gt,{className:"mr-2 h-4 w-4"}),"Analyze Drawing"]})}),j&&N.length>0&&e.jsxs("div",{className:"bg-primary/5 rounded-lg p-3 border border-primary/20 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Yt,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-medium",children:"Detected Components"})]}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:N.map(Ps)})]}),j&&N.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"Analysis complete. Details added to project description."})]}):e.jsxs("div",{className:"cursor-pointer space-y-2",onClick:()=>M.current?.click(),role:"button",tabIndex:0,onKeyDown:F=>F.key==="Enter"&&M.current?.click(),children:[e.jsx(Vt,{className:"h-8 w-8 mx-auto text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Click to upload a blueprint, floor plan, or drawing"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PDF, JPG, PNG, WebP â Max 10MB"})]})}),a[3]=j,a[4]=N,a[5]=L,a[6]=d,a[7]=p,a[8]=h,a[9]=k):k=a[9];let w;a[10]!==x?(w=e.jsx("input",{ref:M,type:"file",accept:".pdf,.jpg,.jpeg,.png,.webp",className:"hidden",onChange:x}),a[10]=x,a[11]=w):w=a[11];let E;return a[12]!==k||a[13]!==w?(E=e.jsxs("div",{className:"space-y-3",children:[m,k,w]}),a[12]=k,a[13]=w,a[14]=E):E=a[14],E};function Ps(r,a){return e.jsxs("div",{className:"text-xs flex justify-between bg-background rounded px-2 py-1.5 border",children:[e.jsx("span",{children:r.name}),e.jsxs("span",{className:"font-semibold text-primary",children:["Ã",r.count]})]},a)}const rt=[{name:"Red",value:"#ef4444"},{name:"Blue",value:"#3b82f6"},{name:"Green",value:"#22c55e"},{name:"Orange",value:"#f97316"},{name:"Purple",value:"#a855f7"},{name:"Cyan",value:"#06b6d4"}],nt=["Outlet","Switch","Light Fixture","Panel","Junction Box","Receptacle","Circuit Breaker","Conduit Run","Custom"],Ms=({file:r,detectedObjects:a,onMeasurementsChange:h,onHighlightsChange:L})=>{const j=o.useRef(null),N=o.useRef(null),[v,p]=o.useState(null),[d,M]=o.useState(1),[S,x]=o.useState({x:0,y:0}),[m,k]=o.useState("measure"),[w,E]=o.useState([]),[F,y]=o.useState(null),[u,D]=o.useState(null),[R,f]=o.useState(!1),[T,q]=o.useState({x:0,y:0}),[c,C]=o.useState(null),[g,$]=o.useState(""),[B,ae]=o.useState(!1),[Y,me]=o.useState(null),[_,ie]=o.useState(!1),[H,Z]=o.useState(!1),[re,ne]=o.useState(0),[Q,ee]=o.useState(1),Ce=o.useRef(null),[J,ce]=o.useState([]),[K,De]=o.useState(rt[0].value),[Se,Le]=o.useState(nt[0]),[Fe,Re]=o.useState(""),[de,ye]=o.useState(null),[U,te]=o.useState(null),[z,be]=o.useState([]),[ve,I]=o.use
2State(!1),[X,le]=o.useState([]),[je,se]=o.useState([]),ke=Se==="Custom"&&Fe?Fe:Se;o.useEffect(()=>{if(!L)return;const t=new Map;J.forEach(s=>{const n=t.get(s.category);n?(n.count++,s.label&&n.labels.push(s.label)):t.set(s.category,{category:s.category,color:s.color,count:1,labels:s.label?[s.label]:[]})}),L(Array.from(t.values()))},[J,L]);const Pe=o.useCallback(t=>{if(p(t),N.current){const s=N.current.clientWidth,n=N.current.clientHeight||500,i=Math.min(s/t.width,n/t.height,1);M(i),x({x:(s-t.width*i)/2,y:(n-t.height*i)/2})}},[]),Ee=o.useCallback(async(t,s)=>{const n=await t.getPage(s),i=n.getViewport({scale:2}),l=document.createElement("canvas");l.width=i.width,l.height=i.height;const P=l.getContext("2d");return await n.render({canvas:l,canvasContext:P,viewport:i}).promise,new Promise(W=>{const G=new Image;G.onload=()=>W(G),G.src=l.toDataURL()})},[]);o.useEffect(()=>{let t=!1;if(r.type==="application/pdf")Z(!0),(async()=>{try{const s=await Ve(()=>import("./pdf-ClZ_1Nv1.js"),[]),{default:n}=await Ve(async()=>{const{default:W}=await import("./pdf.worker.min-LAOCk-LR.js");return{default:W}},[]);s.GlobalWorkerOptions.workerSrc=n;const i=await r.arrayBuffer(),l=await s.getDocument({data:i}).promise;if(t)return;Ce.current=l,ne(l.numPages),ee(1);const P=await Ee(l,1);if(t)return;Pe(P)}catch(s){console.error("PDF load error:",s)}finally{t||Z(!1)}})();else{const s=URL.createObjectURL(r),n=new Image;return n.onload=()=>{t||Pe(n)},n.src=s,()=>{t=!0,URL.revokeObjectURL(s)}}return()=>{t=!0}},[r,Pe,Ee]);const Ze=o.useCallback(async t=>{if(!(!Ce.current||t<1||t>re)){Z(!0),ee(t);try{const s=await Ee(Ce.current,t);Pe(s),E([]),y(null),ce([]),ye(null)}catch(s){console.error("PDF page render error:",s)}finally{Z(!1)}}},[re,Pe,Ee]),Ke=o.useCallback(()=>{const t=j.current,s=t?.getContext("2d");if(!t||!s||!v)return;const n=N.current;n&&(t.width=n.clientWidth,t.height=n.clientHeight||500),s.clearRect(0,0,t.width,t.height),s.fillStyle="hsl(var(--muted) / 0.3)",s.fillRect(0,0,t.width,t.height),s.strokeStyle="hsl(var(--border) / 0.3)",s.lineWidth=1;const i=40*d;for(let l=S.x%i;l<t.width;l+=i)s.beginPath(),s.moveTo(l,0),s.lineTo(l,t.height),s.stroke();for(let l=S.y%i;l<t.height;l+=i)s.beginPath(),s.moveTo(0,l),s.lineTo(t.width,l),s.stroke();if(s.save(),s.translate(S.x,S.y),s.scale(d,d),s.drawImage(v,0,0),s.restore(),J.forEach(l=>{const P=U===l.id;l.type==="pin"?ft(s,l,P):l.type==="rect"&&l.endPosition?gt(s,l,P):(l.type==="polygon"||l.type==="freehand")&&l.points&&l.points.length>1&&yt(s,l,P)}),de&&u&&m==="rect"){s.save(),s.strokeStyle=K,s.lineWidth=2,s.setLineDash([6,3]),s.fillStyle=K+"20";const l=Math.min(de.start.x,u.x),P=Math.min(de.start.y,u.y),W=Math.abs(u.x-de.start.x),G=Math.abs(u.y-de.start.y);s.fillRect(l,P,W,G),s.strokeRect(l,P,W,G),s.setLineDash([]),s.restore()}if(z.length>0&&m==="polygon"&&(s.save(),s.strokeStyle=K,s.lineWidth=2,s.setLineDash([6,3]),s.beginPath(),s.moveTo(z[0].x,z[0].y),z.slice(1).forEach(l=>s.lineTo(l.x,l.y)),u&&s.lineTo(u.x,u.y),s.stroke(),z.forEach(l=>{s.beginPath(),s.arc(l.x,l.y,4,0,Math.PI*2),s.fillStyle=K,s.fill(),s.strokeStyle="#fff",s.lineWidth=1.5,s.stroke()}),s.setLineDash([]),z.length>=3&&u&&we(u,z[0])<15&&(s.beginPath(),s.arc(z[0].x,z[0].y,8,0,Math.PI*2),s.strokeStyle=K,s.lineWidth=2,s.stroke()),s.restore()),ve&&X.length>1&&(s.save(),s.strokeStyle=K,s.lineWidth=2.5,s.lineCap="round",s.lineJoin="round",s.beginPath(),s.moveTo(X[0].x,X[0].y),X.slice(1).forEach(l=>s.lineTo(l.x,l.y)),s.stroke(),s.restore()),w.forEach((l,P)=>{Xe(s,l,P===w.length-1)}),F&&u){const l={start:F.start,end:u,pixelLength:we(F.start,u)};Xe(s,l,!0,!0)}if(B&&Y&&u){s.save(),s.setLineDash([8,4]),s.strokeStyle="#f59e0b",s.lineWidth=3,s.beginPath(),s.moveTo(Y.x,Y.y),s.lineTo(u.x,u.y),s.stroke(),s.setLineDash([]);const l={x:(Y.x+u.x)/2,y:(Y.y+u.y)/2-12};s.fillStyle="#f59e0b",s.font="bold 13px system-ui",s.textAlign="center",s.fillText("ð Set reference distance",l.x,l.y),s.restore()}},[v,d,S,w,F,u,B,Y,J,de,z,ve,X,m,K,U]);o.useEffect(()=>{const t=requestAnimationFrame(Ke);return()=>cancelAnimationFrame(t)},[Ke]);function we(t,s){return Math.sqrt((s.x-t.x)**2+(s.y-t.y)**2)}function ze(t){if(!c||!g)return null;const s=parseFloat(g);return!s||!c?null:t/c*s}function ft(t,s,n){const{x:i,y:l}=s.position,P=n?14:10;t.save(),t.beginPath(),t.arc(i,l,P+4,0,Math.PI*2),t.fillStyle=s.color+"30",t.fill(),t.beginPath(),t.arc(i,l,P,0,Math.PI*2),t.fillStyle=s.color,t.fill(),t.strokeStyle="#fff",t.lineWidth=2.5,t.stroke(),t.beginPath(),t.arc(i,l,3,0,Math.PI*2),t.fillStyle="#fff",t.fill();const W=s.label||s.category;t.font="bold 11px system-ui";const G=t.measureText(W).width+12,O=i-G/2,ue=l-P-20;t.fillStyle=s.color,t.beginPath(),t.roundRect(O,ue,G,18,4),t.fill(),t.fillStyle="#fff",t.textAlign="center",t.textBaseline="middle",t.fillText(W,i,ue+9),t.restore(
2)}function gt(t,s,n){if(!s.endPosition)return;const i=Math.min(s.position.x,s.endPosition.x),l=Math.min(s.position.y,s.endPosition.y),P=Math.abs(s.endPosition.x-s.position.x),W=Math.abs(s.endPosition.y-s.position.y);t.save(),t.fillStyle=s.color+(n?"35":"18"),t.fillRect(i,l,P,W),t.strokeStyle=s.color,t.lineWidth=n?3:2,t.strokeRect(i,l,P,W);const G=s.label||s.category;t.font="bold 11px system-ui";const O=t.measureText(G).width+12;t.fillStyle=s.color,t.beginPath(),t.roundRect(i,l-20,O,18,4),t.fill(),t.fillStyle="#fff",t.textAlign="left",t.textBaseline="middle",t.fillText(G,i+6,l-11),t.restore()}function yt(t,s,n){if(!s.points||s.points.length<2)return;t.save();const i=s.type==="polygon";i&&(t.fillStyle=s.color+(n?"30":"15"),t.beginPath(),t.moveTo(s.points[0].x,s.points[0].y),s.points.slice(1).forEach(O=>t.lineTo(O.x,O.y)),t.closePath(),t.fill()),t.strokeStyle=s.color,t.lineWidth=n?3.5:2.5,t.lineCap="round",t.lineJoin="round",t.beginPath(),t.moveTo(s.points[0].x,s.points[0].y),s.points.slice(1).forEach(O=>t.lineTo(O.x,O.y)),i&&t.closePath(),t.stroke(),i&&s.points.forEach(O=>{t.beginPath(),t.arc(O.x,O.y,3.5,0,Math.PI*2),t.fillStyle=s.color,t.fill(),t.strokeStyle="#fff",t.lineWidth=1.5,t.stroke()});const l=s.points.reduce((O,ue)=>O+ue.x,0)/s.points.length,P=s.points.reduce((O,ue)=>O+ue.y,0)/s.points.length,W=s.label||s.category;t.font="bold 11px system-ui";const G=t.measureText(W).width+12;t.fillStyle=s.color,t.beginPath(),t.roundRect(l-G/2,P-9,G,18,4),t.fill(),t.fillStyle="#fff",t.textAlign="center",t.textBaseline="middle",t.fillText(W,l,P),t.restore()}function Xe(t,s,n,i=!1){const l=i?"#60a5fa":n?"#3b82f6":"#10b981";t.save(),t.strokeStyle=l,t.lineWidth=2.5,t.beginPath(),t.moveTo(s.start.x,s.start.y),t.lineTo(s.end.x,s.end.y),t.stroke(),[s.start,s.end].forEach(_e=>{t.beginPath(),t.arc(_e.x,_e.y,5,0,Math.PI*2),t.fillStyle=l,t.fill(),t.strokeStyle="#fff",t.lineWidth=2,t.stroke()});const P=we(s.start,s.end),W=ze(P/d),G=W?`${W.toFixed(1)} ft`:`${Math.round(P)}px`,O={x:(s.start.x+s.end.x)/2,y:(s.start.y+s.end.y)/2};t.font="bold 12px system-ui";const ue=t.measureText(G).width+16,Ue=22;t.fillStyle=l,t.beginPath(),t.roundRect(O.x-ue/2,O.y-Ue-4,ue,Ue,6),t.fill(),t.fillStyle="#fff",t.textAlign="center",t.textBaseline="middle",t.fillText(G,O.x,O.y-Ue/2-4),t.restore()}function Ie(t){const s=j.current.getBoundingClientRect();return{x:t.clientX-s.left,y:t.clientY-s.top}}function bt(t){for(let s=J.length-1;s>=0;s--){const n=J[s];if(n.type==="pin"&&we(t,n.position)<=14)return n;if(n.type==="rect"&&n.endPosition){const i=Math.min(n.position.x,n.endPosition.x),l=Math.min(n.position.y,n.endPosition.y),P=Math.max(n.position.x,n.endPosition.x),W=Math.max(n.position.y,n.endPosition.y);if(t.x>=i&&t.x<=P&&t.y>=l&&t.y<=W)return n}}return null}const jt=t=>{const s=Ie(t);if(m==="pan"||t.button===1){f(!0),q({x:t.clientX-S.x,y:t.clientY-S.y});return}if(B){if(!Y)me(s);else{const n=we(Y,s);C(n/d),ae(!1),me(null)}return}if(m==="measure")if(!F)y({start:s});else{const n=we(F.start,s),i={id:crypto.randomUUID(),start:F.start,end:s,pixelLength:n,realLength:ze(n/d),label:""},l=[...w,i];E(l),y(null),se(P=>[...P,{type:"measurement",id:i.id}]),h?.(l)}if(m==="pin"){const n={id:crypto.randomUUID(),type:"pin",position:s,label:"",color:K,category:ke};ce(i=>[...i,n]),se(i=>[...i,{type:"highlight",id:n.id}])}if(m==="rect")if(!de)ye({start:s});else{const n={id:crypto.randomUUID(),type:"rect",position:de.start,endPosition:s,label:"",color:K,category:ke};ce(i=>[...i,n]),se(i=>[...i,{type:"highlight",id:n.id}]),ye(null)}if(m==="polygon")if(z.length>=3&&we(s,z[0])<15){const n={id:crypto.randomUUID(),type:"polygon",position:z[0],points:[...z],label:"",color:K,category:ke};ce(i=>[...i,n]),se(i=>[...i,{type:"highlight",id:n.id}]),be([])}else be(n=>[...n,s]);m==="freehand"&&(I(!0),le([s]))},vt=t=>{const s=Ie(t);D(s),R&&x({x:t.clientX-T.x,y:t.clientY-T.y}),ve&&m==="freehand"&&le(i=>[...i,s]);const n=bt(s);te(n?.id||null)},Qe=()=>{if(f(!1),ve&&X.length>3){const t={id:crypto.randomUUID(),type:"freehand",position:X[0],points:[...X],label:"",color:K,category:ke};ce(s=>[...s,t]),se(s=>[...s,{type:"highlight",id:t.id}])}I(!1),le([])},wt=t=>{t.preventDefault();const s=Ie(t),n=t.deltaY<0?1.1:.9,i=Math.max(.1,Math.min(5,d*n));
2x({x:s.x-(s.x-S.x)/d*i,y:s.y-(s.y-S.y)/d*i}),M(i)},Nt=()=>{if(!v||!N.current)return;const t=N.current.clientWidth,s=N.current.clientHeight||500,n=Math.min(t/v.width,s/v.height,1);M(n),x({x:(t-v.width*n)/2,y:(s-v.height*n)/2})},St=()=>{E([]),y(null),ce([]),ye(null),be([]),I(!1),le([]),se([]),h?.([])},$e=o.useCallback(()=>{se(t=>{if(t.length===0)return t;const s=t[t.length-1];return s.type==="measurement"?E(n=>{const i=n.filter(l=>l.id!==s.id);return h?.(i),i}):ce(n=>n.filter(i=>i.id!==s.id)),t.slice(0,-1)})},[h]);o.useEffect(()=>{const t=s=>{(s.ctrlKey||s.metaKey)&&s.key==="z"&&!s.shiftKey&&(s.preventDefault(),$e())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[$e]);const kt=t=>{ce(s=>s.filter(n=>n.id!==t))},Ct=()=>m==="pan"||R?"grab":"crosshair",Be=new Map;return J.forEach(t=>{const s=Be.get(t.category);s?s.count++:Be.set(t.category,{color:t.color,count:1})}),!v&&!H?e.jsxs("div",{className:"rounded-lg border-2 border-dashed border-border p-8 text-center text-muted-foreground",children:[e.jsx(Te,{className:"h-6 w-6 mx-auto mb-2 animate-spin"}),e.jsx("p",{className:"text-sm",children:"Loading blueprint..."})]}):e.jsxs("div",{className:`space-y-3 ${_?"fixed inset-0 z-50 bg-background p-4":""}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg bg-muted/50 p-2 border border-border",children:[e.jsxs("div",{className:"flex items-center gap-1 border-r border-border pr-2",children:[e.jsxs(A,{variant:m==="measure"?"default":"ghost",size:"sm",onClick:()=>k("measure"),title:"Measure distance",children:[e.jsx(Ae,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Measure"})]}),e.jsxs(A,{variant:m==="pin"?"default":"ghost",size:"sm",onClick:()=>k("pin"),title:"Drop pin marker",children:[e.jsx(rs,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Pin"})]}),e.jsxs(A,{variant:m==="rect"?"default":"ghost",size:"sm",onClick:()=>k("rect"),title:"Draw highlight rectangle",children:[e.jsx(bs,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Area"})]}),e.jsxs(A,{variant:m==="pan"?"default":"ghost",size:"sm",onClick:()=>k("pan"),title:"Pan / move",children:[e.jsx(us,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Pan"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 border-r border-border pr-2",children:[e.jsx(A,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>M(t=>Math.min(5,t*1.25)),children:e.jsx(vs,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-xs font-mono text-muted-foreground w-12 text-center",children:[Math.round(d*100),"%"]}),e.jsx(A,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>M(t=>Math.max(.1,t*.8)),children:e.jsx(Ns,{className:"h-4 w-4"})}),e.jsx(A,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:Nt,title:"Fit to view",children:e.jsx(st,{className:"h-4 w-4"})}),e.jsxs(A,{variant:m==="polygon"?"default":"ghost",size:"sm",onClick:()=>{k("polygon"),be([])},title:"Draw polygon",children:[e.jsx(fs,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Polygon"})]}),e.jsxs(A,{variant:m==="freehand"?"default":"ghost",size:"sm",onClick:()=>k("freehand"),title:"Freehand draw",children:[e.jsx(Jt,{className:"h-4 w-4 mr-1"}),e.jsx("span",{className:"hidden sm:inline text-xs",children:"Freehand"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-r border-border pr-2",children:[e.jsxs(A,{variant:B?"secondary":"ghost",size:"sm",onClick:()=>{ae(!B),me(null),k("measure")},className:"text-xs",children:[e.jsx(Zt,{className:"h-3.5 w-3.5 mr-1"}),B?"Click 2 pointsâ¦":"Set Scale"]}),c&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ne,{value:g,onChange:t=>$(t.target.value),placeholder:"ft",className:"h-7 w-16 text-xs",type:"number"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"ft"})]})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[je.length>0&&e.jsxs(A,{variant:"ghost",size:"sm",onClick:$e,className:"text-xs",title:"Undo (Ctrl+Z)",children:[e.jsx(st,{className:"h-3.5 w-3.5 mr-1"}),"Undo"]}),(w.length>0||J.length>0)&&e.jsxs(A,{variant:"ghost",size:"sm",onClick:St,className:"text-xs text-destructive",children:[e.jsx(Kt,{className:"h-3.5 w-3.5 mr-1"}),"Clear All"]}),e.jsx(A,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>ie(!_),children:e.jsx(ds,{className:"h-4 w-4"})})]})]}),(m==="pin"||m==="rect"||m==="polygon"||m==="freehand")&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3 rounded-lg bg-muted/30 p-2 border border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xt,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsxs(pe,{value:Se,onValueChange:Le,children:[e.jsx(xe,{className:"h-7 w-[140px] text-xs",children:e.jsx(fe,{})}),e.jsx(ge,{children:nt.map(t=>e.jsx(b,{value:t,className:"text-xs",children:t},t))})]}
2),Se==="Custom"&&e.jsx(Ne,{value:Fe,onChange:t=>Re(t.target.value),placeholder:"Category name",className:"h-7 w-28 text-xs"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Color:"}),rt.map(t=>e.jsx("button",{onClick:()=>De(t.value),className:`w-5 h-5 rounded-full border-2 transition-transform ${K===t.value?"border-foreground scale-125":"border-transparent"}`,style:{backgroundColor:t.value},title:t.name},t.value))]}),e.jsxs("span",{className:"text-[11px] text-muted-foreground ml-auto",children:[m==="pin"&&"Click to place markers",m==="rect"&&"Click two corners to draw area",m==="polygon"&&(z.length>=3?"Click near first point to close, or keep adding":"Click to add vertices"),m==="freehand"&&"Click & drag to draw a path"]})]}),e.jsxs("div",{ref:N,className:`relative rounded-lg border-2 border-border overflow-hidden bg-muted/20 ${_?"flex-1 h-[calc(100vh-200px)]":"h-[420px]"}`,style:{cursor:Ct()},children:[e.jsx("canvas",{ref:j,className:"absolute inset-0 w-full h-full",onMouseDown:jt,onMouseMove:vt,onMouseUp:Qe,onMouseLeave:Qe,onWheel:wt}),w.length>0&&e.jsxs("div",{className:"absolute bottom-3 left-3 bg-background/90 backdrop-blur-sm border border-border rounded-lg p-3 max-w-[240px]",children:[e.jsxs("p",{className:"text-xs font-semibold mb-1.5 text-foreground",children:["ð Measurements (",w.length,")"]}),e.jsx("div",{className:"space-y-1 max-h-[120px] overflow-y-auto",children:w.map((t,s)=>{const n=ze(t.pixelLength);return e.jsxs("div",{className:"flex items-center justify-between text-xs gap-2",children:[e.jsxs("span",{className:"text-muted-foreground",children:["Line ",s+1]}),e.jsx("span",{className:"font-mono font-medium text-primary",children:n?`${n.toFixed(1)} ft`:`${Math.round(t.pixelLength)}px`})]},t.id)})}),!c&&e.jsx("p",{className:"text-[10px] text-amber-500 mt-1.5",children:"ð¡ Set scale for real-world measurements"})]}),J.length>0&&e.jsxs("div",{className:"absolute bottom-3 right-3 bg-background/90 backdrop-blur-sm border border-border rounded-lg p-3 max-w-[260px]",children:[e.jsxs("p",{className:"text-xs font-semibold mb-1.5 text-foreground",children:[e.jsx(is,{className:"h-3.5 w-3.5 inline mr-1"}),"Takeoff Summary (",J.length,")"]}),e.jsx("div",{className:"space-y-1.5 max-h-[160px] overflow-y-auto",children:Array.from(Be.entries()).map(([t,s])=>e.jsxs("div",{className:"flex items-center justify-between text-xs gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full inline-block",style:{backgroundColor:s.color}}),e.jsx("span",{className:"text-muted-foreground",children:t})]}),e.jsxs("span",{className:"font-mono font-bold text-foreground",children:["Ã",s.count]})]},t))})]}),J.length>0&&e.jsxs("div",{className:"absolute top-3 left-3 bg-background/90 backdrop-blur-sm border border-border rounded-lg p-2 max-w-[200px] max-h-[180px] overflow-y-auto",children:[e.jsx("p",{className:"text-[10px] font-semibold text-muted-foreground mb-1",children:"Markers"}),J.map((t,s)=>e.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-1 py-0.5",children:[e.jsxs("div",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:t.color}}),e.jsxs("span",{className:"truncate text-muted-foreground",children:[t.type==="pin"?"ð":"â¢"," ",t.category]})]}),e.jsx("button",{onClick:()=>kt(t.id),className:"text-muted-foreground hover:text-destructive flex-shrink-0",children:e.jsx(xt,{className:"h-3 w-3"})})]},t.id))]}),a.length>0&&J.length===0&&e.jsxs("div",{className:"absolute top-3 right-3 bg-background/90 backdrop-blur-sm border border-border rounded-lg p-3 max-w-[200px]",children:[e.jsx("p",{className:"text-xs font-semibold mb-1.5 text-foreground",children:"ð Detected"}),e.jsx("div",{className:"space-y-1",children:a.slice(0,6).map((t,s)=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-muted-foreground truncate",children:t.name}),e.jsxs("span",{className:"font-semibold text-primary ml-2",children:["Ã",t.count]})]},s))})]}),H&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/60 backdrop-blur-sm",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(Te,{className:"h-5 w-5 animate-spin"}),"Loading blueprint..."]})})]}),re>1&&e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx(A,{variant:"outline",size:"icon",className:"h-8 w-8",disabled:Q<=1||H,onClick:()=>Ze(Q-1),children:e.jsx(zt,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-muted-foreground font-medium",children:["Page ",Q," of ",re]}),e.jsx(A,{variant:"outline",size:"icon",className:"h-8 w-8",disabled:Q>=re||H,onClick:()=>Ze(Q+1),children:e.jsx(Qt,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-xs text-muted-foreground text-center",children:[m==="measure"&&!B&&"Click two points to measure distance. Scroll to zoom. Set scale for real-world units.",m==="pin"&&"Click anyw
2here to drop a marker. Choose category & color above.",m==="rect"&&"Click two corners to highlight an area. Choose category & color above.",m==="polygon"&&"Click to add vertices. Click near the first point to close the polygon.",m==="freehand"&&"Click and drag to draw a freehand path for conduit runs or cable paths.",m==="pan"&&"Click and drag to pan the view.",B&&"Click two points on a known distance to calibrate scale."]})]})},Es=r=>{const a=Je.c(51),{value:h,onChange:L}=r,[,j]=o.useState(!1),N=Ts;let v;a[0]!==h?(v=N(h),a[0]=h,a[1]=v):v=a[1];const p=v,d=Math.min(h/200*100,100);let M;a[2]===Symbol.for("react.memo_cache_sentinel")?(M=e.jsxs(V,{className:"flex items-center gap-2",children:[e.jsx(Ae,{className:"h-4 w-4 text-primary"}),"Distance: Panel to Work Area"]}),a[2]=M):M=a[2];let S,x;a[3]===Symbol.for("react.memo_cache_sentinel")?(S=()=>j(!0),x=()=>j(!1),a[3]=S,a[4]=x):(S=a[3],x=a[4]);let m;a[5]===Symbol.for("react.memo_cache_sentinel")?(m=e.jsx("div",{className:"absolute inset-0 opacity-[0.04]",style:{backgroundImage:` 3 linear-gradient(hsl(var(--foreground)) 1px, transparent 1px), 4 linear-gradient(90deg, hsl(var(--foreground)) 1px, transparent 1px) 5 `,backgroundSize:"24px 24px"}}),a[5]=m):m=a[5];let k;a[6]===Symbol.for("react.memo_cache_sentinel")?(k=e.jsxs("div",{className:"flex flex-col items-center gap-1 z-10 shrink-0",children:[e.jsxs("div",{className:"w-12 h-14 rounded-md bg-primary/10 border-2 border-primary/40 flex items-center justify-center relative",children:[e.jsx(es,{className:"h-5 w-5 text-primary"}),e.jsx("div",{className:"absolute -bottom-0.5 left-1/2 -translate-x-1/2 w-6 h-1 bg-primary/30 rounded-full"})]}),e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Panel"})]}),a[6]=k):k=a[6];let w;a[7]===Symbol.for("react.memo_cache_sentinel")?(w=e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 left-0 right-0 border-t-2 border-dashed border-muted-foreground/20"}),a[7]=w):w=a[7];const E=`${d}%`;let F;a[8]!==E?(F=e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 left-0 h-0.5 rounded-full transition-all duration-300",style:{width:E,background:"linear-gradient(90deg, hsl(var(--primary)), hsl(var(--primary) / 0.4))"}}),a[8]=E,a[9]=F):F=a[9];let y;a[10]===Symbol.for("react.memo_cache_sentinel")?(y=[20,40,60,80],a[10]=y):y=a[10];let u;a[11]!==d?(u=y.map(ee=>e.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 w-1.5 h-1.5 rounded-full transition-colors duration-300",style:{left:`${ee}%`,backgroundColor:ee<=d?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.2)"}},ee)),a[11]=d,a[12]=u):u=a[12];const D=`${Math.max(10,Math.min(d,90))}%`;let R;a[13]!==D?(R={left:D},a[13]=D,a[14]=R):R=a[14];const f=`px-2 py-0.5 rounded-full text-[11px] font-bold text-white ${p.bg} shadow-sm whitespace-nowrap`;let T;a[15]!==f||a[16]!==h?(T=e.jsxs("div",{className:f,children:[h," ft"]}),a[15]=f,a[16]=h,a[17]=T):T=a[17];let q;a[18]!==R||a[19]!==T?(q=e.jsx("div",{className:"absolute -top-8 transition-all duration-300 -translate-x-1/2",style:R,children:T}),a[18]=R,a[19]=T,a[20]=q):q=a[20];let c;a[21]!==u||a[22]!==q||a[23]!==F?(c=e.jsxs("div",{className:"flex-1 relative mx-2",children:[w,F,u,q]}),a[21]=u,a[22]=q,a[23]=F,a[24]=c):c=a[24];let C;a[25]===Symbol.for("react.memo_cache_sentinel")?(C=e.jsxs("div",{className:"flex flex-col items-center gap-1 z-10 shrink-0",children:[e.jsx("div",{className:"w-12 h-14 rounded-md bg-accent/10 border-2 border-accent/40 flex items-center justify-center",children:e.jsx(ts,{className:"h-5 w-5 text-accent"})}),e.jsx("span",{className:"text-[10px] font-medium text-muted-foreground uppercase tracking-wider",children:"Work"})]}),a[25]=C):C=a[25];let g;a[26]!==c?(g=e.jsxs("div",{className:"relative bg-muted/50 rounded-xl border border-border p-4 overflow-hidden select-none",onMouseEnter:S,onMouseLeave:x,children:[m,e.jsxs("div",{className:"relative flex items-center justify-between gap-2 min-h-[80px]",children:[k,c,C]})]}),a[26]=c,a[27]=g):g=a[27];let $;a[28]!==h?($=[h],a[28]=h,a[29]=$):$=a[29];let B;a[30]!==L?(B=ee=>L(ee[0]),a[30]=L,a[31]=B):B=a[31];let ae;a[32]!==$||a[33]!==B?(ae=e.jsx(_t,{value:$,onValueChange:B,min:5,max:200,step:5,className:"w-full"}),a[32]=$,a[33]=B,a[34]=ae):ae=a[34];let Y;a[35]===Symbol.for("react.memo_cache_sentinel")?(Y=e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"5 ft"}),a[35]=Y):Y=a[35];const me=`text-xs font-medium ${p.color}`;let _;a[36]!==p.label||a[37]!==me?(_=e.jsx("span",{className:me,children:p.label}),a[36]=p.label,a[37]=me,a[38]=_):_=a[38];let ie;a[39]===Symbol.for("react.memo_cache_sentinel")?(ie=e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"200 ft"}),a[39]=ie):ie=a[39];let H;
5a[40]!==_?(H=e.jsxs("div",{className:"flex justify-between mt-1.5",children:[Y,_,ie]}),a[40]=_,a[41]=H):H=a[41];let Z;a[42]!==ae||a[43]!==H?(Z=e.jsxs("div",{className:"px-1",children:[ae,H]}),a[42]=ae,a[43]=H,a[44]=Z):Z=a[44];const re=h<=15?"Minimal additional wiring cost â panel is close to work area.":h<=40?"Short wire runs keep costs reasonable.":h<=75?"Moderate distance may require additional conduit and wire.":h<=120?"Longer runs add material and labour costs.":"Extended distance â expect significant conduit, wire, and trenching costs.";let ne;a[45]!==re?(ne=e.jsx("p",{className:"text-xs text-muted-foreground",children:re}),a[45]=re,a[46]=ne):ne=a[46];let Q;return a[47]!==g||a[48]!==Z||a[49]!==ne?(Q=e.jsxs("div",{className:"space-y-3",children:[M,g,Z,ne]}),a[47]=g,a[48]=Z,a[49]=ne,a[50]=Q):Q=a[50],Q};function Ts(r){return r<=15?{label:"Very Close",color:"text-green-500",bg:"bg-green-500"}:r<=40?{label:"Nearby",color:"text-emerald-500",bg:"bg-emerald-500"}:r<=75?{label:"Moderate",color:"text-yellow-500",bg:"bg-yellow-500"}:r<=120?{label:"Far",color:"text-orange-500",bg:"bg-orange-500"}:{label:"Very Far",color:"text-red-500",bg:"bg-red-500"}}const As=()=>{const{businessPhone:r}=ut(),a=r.replace(/[^0-9]/g,""),[h,L]=o.useState(""),[j,N]=o.useState(""),[v,p]=o.useState(""),[d,M]=o.useState(""),[S,x]=o.useState(""),[m,k]=o.useState(""),[w,E]=o.useState(""),[F,y]=o.useState(""),[u,D]=o.useState(!1),[R,f]=o.useState(""),[T,q]=o.useState(25),[c,C]=o.useState(!1),[g,$]=o.useState(null),[B,ae]=o.useState(!1),[Y,me]=o.useState(!1),[_,ie]=o.useState("describe"),[H,Z]=o.useState(null),[re,ne]=o.useState(!1),[Q,ee]=o.useState([]),[Ce,J]=o.useState(!1),[ce,K]=o.useState([]),[De,Se]=o.useState([]),Le=U=>{Z(U),ee([]),J(!1),ie("blueprint")},Fe=()=>{Z(null),ee([]),J(!1),ie("describe")},Re=async()=>{if(H){ne(!0);try{const U=await new Promise((le,je)=>{const se=new FileReader;se.onload=()=>{const ke=se.result;le(ke.split(",")[1])},se.onerror=je,se.readAsDataURL(H)}),te=H.name.toLowerCase();let z="image/jpeg";te.endsWith(".pdf")?z="application/pdf":te.endsWith(".png")?z="image/png":te.endsWith(".webp")&&(z="image/webp");const{data:be,error:ve}=await Me.functions.invoke("analyze-construction-pdf",{body:{fileBase64:U,fileMimeType:z,fileName:H.name,detectObjects:!0}});if(ve)throw ve;if(!be.success)throw new Error(be.error||"Analysis failed");const{analysis:I}=be;I.propertyType&&p(I.propertyType==="single-family"||I.propertyType==="duplex"||I.propertyType==="townhouse"||I.propertyType==="custom"?"house":I.propertyType),I.squareFootage&&M(I.squareFootage.toString()),I.numBedrooms&&I.numBedrooms>0?N("residential"):I.propertyType&&["retail","office","industrial","warehouse","mixed-use"].includes(I.propertyType)&&N("commercial"),I.detectedObjects&&I.detectedObjects.length>0&&ee(I.detectedObjects);const X=[];if(I.projectDetails&&X.push(I.projectDetails),I.detectedObjects?.length>0){const le=I.detectedObjects.map(je=>`${je.count}x ${je.name}${je.location?` (${je.location})`:""}`).join(", ");X.push(`Detected components: ${le}`)}X.length>0&&L(le=>le?`${le} 6 7${X.join(` 8`)}`:X.join(` 9`)),J(!0),he.success("Blueprint analyzed! Review detected items and generate your estimate.")}catch(U){console.error("Blueprint analysis error:",U),he.error(U.message||"Failed to analyze blueprint. Please try again.")}finally{ne(!1)}}},de=async()=>{if(h.trim().length<10){he.error("Please describe your project in more detail (at least 10 characters).");return}const{data:U}=await Me.auth.getSession();if(!U.session){he.error("Please sign in to get an instant estimate, or call us at 587-557-5494.");return}C(!0),$(null);try{const{data:te,error:z}=await Me.functions.invoke("ai-estimate",{body:{description:h.trim(),serviceType:j||void 0,propertyType:v||void 0,squareFootage:d?parseInt(d):void 0,urgency:S||void 0,buildingAge:m||void 0,numFloors:w?parseInt(w):void 0,existingPanelSize:F||void 0,permitNeeded:u||void 0,accessConcerns:R.trim()||void 0,panelDistance:T||void 0}});if(z)throw z;if(te?.error){he.error(te.error);return}te?.estimate&&($({...te.estimate,serviceType:j||void 0,propertyType:v||void 0,squareFootage:d?parseInt(d):void 0}),he.success("Estimate generated!"))}catch(te){console.error("Estimate error:",te),he.error("Failed to generate estimate. Please try again or call us directly.")}finally{C(!1)}},ye=!!H;return e.jsxs(Ge,{className:"border-primary/20 shadow-lg",children:[e.jsxs(it,{className:"text-center pb-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx(tt,{className:"h-6 w-6 text-primary"}
9),e.jsx(ct,{className:"text-2xl",children:"AI-Powered Estimate"})]}),e.jsx(dt,{className:"text-base",children:"Upload a blueprint to measure & detect components, or describe your project for an instant estimate"})]}),e.jsxs(Ye,{className:"space-y-6",children:[e.jsxs(Ut,{value:_,onValueChange:ie,className:"w-full",children:[e.jsxs(Ot,{className:"grid w-full grid-cols-3",children:[e.jsxs(qe,{value:"describe",className:"gap-1.5",children:[e.jsx(ps,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Describe"})," Project"]}),e.jsxs(qe,{value:"upload",className:"gap-1.5",children:[e.jsx(pt,{className:"h-3.5 w-3.5"}),"Upload"]}),e.jsxs(qe,{value:"blueprint",className:"gap-1.5",disabled:!ye,children:[e.jsx(Ae,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Measure"}),ye&&e.jsx("span",{className:"ml-1 inline-flex h-2 w-2 rounded-full bg-primary animate-pulse"})]})]}),e.jsx(He,{value:"describe",className:"space-y-4 mt-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"project-description",children:"Describe Your Project *"}),e.jsx(ot,{id:"project-description",placeholder:"Example: I need 6 recessed lights installed in my living room ceiling, 2 new outlets in the garage for power tools, and my panel upgraded from 100A to 200A...",value:h,onChange:U=>L(U.target.value),className:"min-h-[120px]",maxLength:5e3}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[h.length,"/5000 characters"]})]})}),e.jsx(He,{value:"upload",className:"mt-4",children:e.jsx(Fs,{uploadedFile:H,isAnalyzing:re,analysisComplete:Ce,detectedObjects:Q,onFileUpload:Le,onRemoveFile:Fe,onAnalyze:Re})}),e.jsx(He,{value:"blueprint",className:"mt-4",children:ye?e.jsx(Ms,{file:H,detectedObjects:Q,onMeasurementsChange:U=>{Se(U)},onHighlightsChange:K}):e.jsxs("div",{className:"rounded-lg border-2 border-dashed border-border p-8 text-center",children:[e.jsx(Ae,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Upload a blueprint (PDF, JPG, PNG, WebP) in the Upload tab to unlock interactive measurements"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"service-type",children:"Service Type"}),e.jsxs(pe,{value:j,onValueChange:N,children:[e.jsx(xe,{id:"service-type",children:e.jsx(fe,{placeholder:"Select type"})}),e.jsxs(ge,{children:[e.jsx(b,{value:"residential",children:"Residential"}),e.jsx(b,{value:"commercial",children:"Commercial"}),e.jsx(b,{value:"new-construction",children:"New Construction"}),e.jsx(b,{value:"renovation",children:"Renovation"}),e.jsx(b,{value:"emergency",children:"Emergency Repair"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"property-type",children:"Property Type"}),e.jsxs(pe,{value:v,onValueChange:p,children:[e.jsx(xe,{id:"property-type",children:e.jsx(fe,{placeholder:"Select property"})}),e.jsxs(ge,{children:[e.jsx(b,{value:"house",children:"House"}),e.jsx(b,{value:"condo",children:"Condo / Townhouse"}),e.jsx(b,{value:"apartment",children:"Apartment"}),e.jsx(b,{value:"mobile-home",children:"Mobile / Modular Home"}),e.jsx(b,{value:"office",children:"Office"}),e.jsx(b,{value:"retail",children:"Retail / Restaurant"}),e.jsx(b,{value:"industrial",children:"Industrial"}),e.jsx(b,{value:"warehouse",children:"Warehouse"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"sqft",children:"Square Footage"}),e.jsx(Ne,{id:"sqft",type:"number",placeholder:"e.g. 2000",value:d,onChange:U=>M(U.target.value)})]})]}),e.jsx(Es,{value:T,onChange:q}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"urgency",children:"Urgency"}),e.jsxs(pe,{value:S,onValueChange:x,children:[e.jsx(xe,{id:"urgency",children:e.jsx(fe,{placeholder:"How soon do you need this?"})}),e.jsxs(ge,{children:[e.jsx(b,{value:"flexible",children:"Flexible / No Rush"}),e.jsx(b,{value:"within-month",children:"Within a Month"}),e.jsx(b,{value:"within-week",children:"Within a Week"}),e.jsx(b,{value:"asap",children:"ASAP (Rush Job)"}),e.jsx(b,{value:"emergency",children:"Emergency (Today/Tonight)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"existing-panel",children:"Existing Panel Size"}),e.jsxs(pe,{value:F,onValueChange:y,children:[e.jsx(xe,{id:"existing-panel",children:e.jsx(fe,{placeholder:"Current electrical panel"})}),e.jsxs(ge,{children:[e.jsx(b,{value:"60A",children:"60A (Older Home)"}),e.jsx(b,{value:"100A",children:"100A (Standard)"}),e.jsx(b,{value:"125A",children:"125A"}),e.jsx(b,{value:"200A",children:"200A (Modern)"}),e.jsx(b,{value:"400A",children:"400A (Commercial)"}),e.jsx(b,{value:"unknown",children:"Not Sure"})]})]})]})]}),e.jsxs(A,{variant:"ghost",className:"w-full justify-between text-muted-foreground",onClick:()=>me(!Y),children:[e.jsx("span",{className:"text-sm",children:"More Details (Optional)"}),Y?e.jsx(lt,{className:"h-4 w-4"}):e.jsx(ht,{className:"h-4 w-4"})]}),Y&&e.jsxs("div",{className:"space-y-4 animate-in fade-in-0 slide-in-from-top-2 duration-300",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"building-age",children:"Building Age"}),e.jsxs(pe,{value:m,onValueChange:k,children:[e.jsx(xe,{id:"building-age",children:e.jsx(fe,{placeholder:"How old is the building?"})}),e.jsxs(ge,{children:[e.jsx(b,{value:"new",children:"New Build (Under Construction)"}),e.jsx(b,{value:"0-10",children:"0â10 Years"}),e.jsx(b,{value:"10-25",children:"10â25 Years"}),e.jsx(b,{value:"25-50",children:"25â50 Years"}),e.jsx(b,{value:"50+",children:"50+ Years"}),e.jsx(b,{value:"unknown",children:"Not Sure"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"num-floors",children:"Number of Floors"}),e.jsxs(pe,{value:w,onValueChange:E,children:[e.jsx(xe,{id:"num-floors",children:e.jsx(fe,{placeholder:"Floors / storeys"})}),e.jsxs(ge,{children:[e.jsx(b,{value:"1",children:"1 Floor (Bungalow / Single Storey)"}),e.jsx(b,{value:"2",children:"2 Floors"}),e.jsx(b,{value:"3",children:"3 Floors"}),e.jsx(b,{value:"4",children:"4+ Floors"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(V,{htmlFor:"access-concerns",children:"Access Concerns"}),e.jsx(Ne,{id:"access-concerns",placeholder:"e.g. Attic crawlspace, finished basement, hard-to-reach areas...",value:R,onChange:U=>f(U.target.value),maxLength:500})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Bt,{id:"permit-needed",checked:u,onCheckedChange:U=>D(U===!0)}),e.jsx(V,{htmlFor:"permit-needed",className:"text-sm font-normal cursor-pointer",children:"Include permit application costs in estimate"})]})]}),e.jsx(A,{size:"lg",className:"w-full",onClick:de,disabled:c||h.trim().length<10,children:c?e.jsxs(e.Fragment,{children:[e.jsx(Te,{className:"mr-2 h-5 w-5 animate-spin"}),"Analyzing Your Project..."]}):e.jsxs(e.Fragment,{children:[e.jsx(tt,{className:"mr-2 h-5 w-5"}),"Get AI Estimate"]})}
9),g&&e.jsx(Cs,{estimate:g,showDetails:B,onToggleDetails:()=>ae(!B),phoneForTel:a,takeoffItems:ce,measurements:De})]})]})},Ds=()=>{const r=Je.c(27),{businessPhone:a}=ut();let h;r[0]===Symbol.for("react.memo_cache_sentinel")?(h=e.jsx(ss,{title:"Book an Electrician | Crescent Electric Fort McMurray",description:"Schedule your electrical service with Crescent Electric in Fort McMurray. Book a licensed Master Electrician online for fast and reliable repairs.",siteUrl:"/book-appointment"}),r[0]=h):h=r[0];let L;r[1]===Symbol.for("react.memo_cache_sentinel")?(L=e.jsx(Pt,{}),r[1]=L):L=r[1];let j,N;r[2]===Symbol.for("react.memo_cache_sentinel")?(j=e.jsx("h1",{className:"text-4xl md:text-5xl font-bold text-foreground mb-4",children:"Book a Fort McMurray Electrician Online"}),N=e.jsx("p",{className:"text-lg text-muted-foreground max-w-2xl mx-auto",children:"Book your electrical service appointment online. Select your service, choose a convenient time, and we'll confirm your appointment within 24 hours."}),r[2]=j,r[3]=N):(j=r[2],N=r[3]);let v;r[4]!==a?(v=e.jsx("section",{className:"bg-gradient-to-b from-primary/10 to-background pt-32 md:pt-36 pb-12",children:e.jsxs("div",{className:"container mx-auto px-4 text-center",children:[j,N,e.jsxs("p",{className:"mt-4 text-primary font-semibold",children:["Or call us directly: ",a]})]})}),r[4]=a,r[5]=v):v=r[5];let p;r[6]===Symbol.for("react.memo_cache_sentinel")?(p=e.jsx("section",{className:"py-12 bg-muted/30",children:e.jsx("div",{className:"container mx-auto px-4 max-w-3xl",children:e.jsx(As,{})})}),r[6]=p):p=r[6];let d;r[7]===Symbol.for("react.memo_cache_sentinel")?(d=e.jsx("section",{className:"py-12",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsx(ks,{})})}),r[7]=d):d=r[7];let M;r[8]===Symbol.for("react.memo_cache_sentinel")?(M=e.jsx("section",{className:"py-12 bg-muted/50",children:e.jsxs("div",{className:"container mx-auto px-4 text-center",children:[e.jsx("h2",{className:"text-2xl font-bold mb-4",children:"Service Areas"}),e.jsx("p",{className:"text-muted-foreground",children:"Serving Fort McMurray, Timberlea, Thickwood, Beacon Hill, Abasand, Downtown, and surrounding areas."})]})}),r[8]=M):M=r[8];let S,x,m;r[9]===Symbol.for("react.memo_cache_sentinel")?(x=e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-foreground mb-4",children:"What to expect when you book a Fort McMurray electrician"}),m=e.jsx("p",{className:"text-muted-foreground mb-4",children:"Booking online is the fastest way to get a licensed Alberta master electrician scheduled at your home or business. After you submit the form, our office reviews the request and confirms an arrival window â usually within 24 hours, often the same day for non-emergency work. We'll send a text or email confirmation with the technician's name, the job number, and any prep work to do before we arrive."}),S=e.jsx("h3",{className:"text-xl font-bold text-foreground mt-6 mb-2",children:"Diagnostic and dispatch fee"}),r[9]=S,r[10]=x,r[11]=m):(S=r[9],x=r[10],m=r[11]);let k,w;r[12]===Symbol.for("react.memo_cache_sentinel")?(k=e.jsxs("p",{className:"text-muted-foreground mb-4",children:["Standard service calls in Fort McMurray include a $150 dispatch and diagnostic fee, which covers the trip out, up to one hour of troubleshooting, and a written quote for any repair or installation work. Most jobs are completed during the same visit. For larger projects â panel upgrades, EV chargers, hot tub circuits, basement wiring â we provide a flat-rate quote so you know the price before we start. See our ",e.jsx("a",{href:"/pricing",className:"text-primary hover:underline",children:"pricing page"})," for full details and current hourly rates."]}),w=e.jsx("h3",{className:"text-xl font-bold text-foreground mt-6 mb-2",children:"Emergency vs. scheduled work"}),r[12]=k,r[13]=w):(k=r[12],w=r[13]);let E;r[14]!==a?(E=e.jsxs("p",{className:"text-muted-foreground mb-4",children:["If you're experiencing a true electrical emergency â burning smell, smoke, sparking outlet, half the house without power, water on energized equipment â please call ",e.jsx("a",{href:"tel:+1587
95575494",className:"text-primary hover:underline",children:a})," directly rather than booking online. Our 24/7 emergency line dispatches a technician immediately. Online booking is best for repairs, upgrades, installations, and inspections that can be scheduled within the next several days."]}),r[14]=a,r[15]=E):E=r[15];let F,y;r[16]===Symbol.for("react.memo_cache_sentinel")?(F=e.jsx("h3",{className:"text-xl font-bold text-foreground mt-6 mb-2",children:"Preparing for your appointment"}),y=e.jsx("p",{className:"text-muted-foreground",children:"A few things help us complete your job faster: clear access to the electrical panel (usually in the basement, garage, or utility room), a list of any breakers that have tripped recently, photos of the affected fixtures or outlets, and a notification to anyone sharing the home about the visit. Pets should be secured, and we appreciate at least 6 feet of working space around the panel. We arrive in marked vehicles with branded uniforms and provide an itemized invoice on completion."}),r[16]=F,r[17]=y):(F=r[16],y=r[17]);let u;r[18]!==E?(u=e.jsx("section",{className:"py-12 border-t border-border",children:e.jsxs("div",{className:"container mx-auto px-4 max-w-4xl",children:[x,m,S,k,w,E,F,y]})}),r[18]=E,r[19]=u):u=r[19];let D;r[20]!==u||r[21]!==v?(D=e.jsxs("main",{className:"flex-grow",children:[v,p,d,M,u]}),r[20]=u,r[21]=v,r[22]=D):D=r[22];let R,f;r[23]===Symbol.for("react.memo_cache_sentinel")?(R=e.jsx(Mt,{}),f=e.jsx(Et,{}),r[23]=R,r[24]=f):(R=r[23],f=r[24]);let T;return r[25]!==D?(T=e.jsxs(e.Fragment,{children:[h,e.jsxs("div",{className:"min-h-screen flex flex-col",children:[L,D,R,f]})]}),r[25]=D,r[26]=T):T=r[26],T},Ba=Ds;export{Ba as component};
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.