PageSourceSearch

https://app.skyware.ai/assets/Clear2Attach-CsfRlG8y.js

js skyware.ai collected 2026-10-05 15:05:07 UTC 153,985 bytes, 3 lines download raw bytes

1import{a as g,j as e}from"./markdown-DXOadQr0.js";import{R as Ft,i as Ge,u as v,M as Wr,a as tr,c as Fr,b as $r,d as Or,e as rr,f as Br,p as or,g as rt,h as Hr,P as Ur,j as qr,w as Kr,k as Yr,l as Vr,F as nr,m as xt,n as mt}from"./RulesConfigPanel-BMtcKkgn.js";import{u as Pe,U as Gr}from"./rulesConfigStore-D_Cr_g_a.js";import{c as sr,X as ze,C as Zr,T as Jr,a as ar,r as Qr,R as Xr,D as ht,L as Me,g as eo,b as be,d as to,e as ro,f as oo,h as no,u as lr,i as ir,j as bt,k as cr,l as it,m as so,n as ao,o as lo,P as io,U as co,M as uo,p as dr,q as po,s as go,S as ct,t as ur,v as fo,w as _e,x as Le,y as xo,A as mo,z as ho}from"./index-D_4K0EPH.js";import{p as pr}from"./csvParser-DRy1_4jL.js";import{L as ge}from"./leaflet-BVyOPZwf.js";import{S as It}from"./search-kp9FbES_.js";import{M as bo}from"./minimize-2-rWemmCxu.js";import{M as vo}from"./useAnchorRect-5flMu7AC.js";import{C as ot}from"./chevron-down-CQpnnUvt.js";import{C as yo}from"./CustomSelect-Cdk9nn3G.js";import{F as gr}from"./file-text-BT1n_Hc8.js";import{G as jo,C as fr}from"./globe-BPtWXqRv.js";import{u as Je}from"./access-CcMMB1Xc.js";import{S as So}from"./sparkles-CmBwtNdh.js";import{c as ko,r as xr,a as Co}from"./c2aOpenRequest-frrZuwmL.js";import{W as wo,S as Ro}from"./wand-sparkles-DySzoaXb.js";import{F as _o}from"./funnel-DyEPYRa_.js";import{A as Io}from"./RulesConfigPreviewModal-CALkU-Z1.js";import{A as Po}from"./arrow-up-D0WwzzJV.js";import{A as zo}from"./arrow-down-DerZDkXh.js";import"./plus-BcTC3T0T.js";import"./save-Bqi9dDMF.js";import"./dashboardReturn-CLaupgiJ.js";import"./copy-BLgnR1tI.js";const Mo=[["path",{d:"M13 7 8.7 2.7a2.41 2.41 0 0 0-3.4 0L2.7 5.3a2.41 2.41 0 0 0 0 3.4L7 13",key:"orapub"}],["path",{d:"m8 6 2-2",key:"115y1s"}],["path",{d:"m18 16 2-2",key:"ee94s4"}],["path",{d:"m17 11 4.3 4.3c.94.94.94 2.46 0 3.4l-2.6 2.6c-.94.94-2.46.94-3.4 0L11 17",key:"cfq27r"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],To=sr("pencil-ruler",Mo);const Eo=[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]],Ao=sr("table",Eo),$t=5,Do=t=>t===""?"(blank)":t;function Lo(t){const r=new Set,o=new Set;for(const n of t){const s=n.Pole_ID;r.has(s)?o.add(s):r.add(s)}return[...o]}function No(t){const r=t.slice(0,$t).map(Do).join(", "),o=t.length-$t;return`Every row needs a unique Pole_ID. ${o>0?`${r} and ${o} more`:r} ${t.length===1?"appears":"appear"} on more than one row. Results are tracked per pole, so those rows would overwrite each other. Please make the IDs unique and upload again.`}function mr(t,r){if(r.length===0)return"CSV is empty";if(!t.includes("Pole_ID"))return"CSV must have a Pole_ID column";const o=Lo(r);return o.length>0?No(o):null}function Wo({scrollTop:t,viewportHeight:r,rowHeight:o,count:n,overscan:s=6,expandedIndex:l=null,expandedExtra:i=0}){if(n<=0||o<=0)return{startIndex:0,endIndex:0,offsetTop:0,totalHeight:0};const a=l==null?0:Math.max(0,i),f=n*o+a,d=Math.max(0,t),b=l==null?1/0:l*o,p=d>b+o+a?d-a:d,j=Math.floor(p/o),k=Math.ceil(r/o)+1,C=Math.max(0,j-s),P=Math.min(n,j+k+s),D=l!=null&&l<C?a:0;return{startIndex:C,endIndex:P,offsetTop:C*o+D,totalHeight:f}}function dt(t,r=o=>{requestAnimationFrame(o)}){let o={},n=!1;const s=()=>{n=!1;const l=o;Object.keys(l).length!==0&&(o={},t(l))};return{push(l,i){o[l]={...o[l],...i},n||(n=!0,r(s))},flushNow:s}}const hr=200,Fo=10;function $o(t,r){if(t.length===0)return[];const o=r>0?r:t.length,n=[];for(let s=0;s<t.length;s+=o)n.push(t.slice(s,s+o));return n}function Oo(t,r){const o=new Map;for(const n of t){const s=r(n),l=JSON.stringify(s??null),i=o.get(l);i?i.items.push(n):o.set(l,{config:s,items:[n]})}return[...o.values()]}function Ot(t,r,o=hr){return Oo(t,r).flatMap(({config:n,items:s})=>$o(s,o).map(l=>({config:n,items:l})))}const Bo=4;function Ho(t){if(t.items.length<=1)return[];const r=Math.ceil(t.items.length/2);return[{config:t.config,items:t.items.slice(0,r)},{config:t.config,items:t.items.slice(r)}]}const Uo=2e3;async function qo(t){const{queue:r,concurrency:o,send:n,onResults:s}=t,l=t.onUnfinished??(()=>{}),i=t.shouldCancel??(()=>!1),a=t.split??Ho,f=t.failureBackoffMs??0,d=t.sleep??(p=>new Promise(j=>
1setTimeout(j,p))),b=async()=>{for(;!i();){const p=r.shift();if(!p)break;try{s(p,await n(p))}catch{const j=a(p);if(j.length>0)r.unshift(...j);else for(const k of p.items)l(k);f>0&&!i()&&await d(f)}}};await Promise.all(Array.from({length:Math.max(1,o)},b))}function Ko(t,r){const o=[],n=[];return t.forEach((s,l)=>{const i=r[l];i&&!i.error?o.push([s,i]):n.push(s)}),{applied:o,unfinished:n}}function Yo(t,r){let o=0,n=0,s=0,l=0,i=0,a=0;for(const f of t){const d=r[f.Pole_ID];if(!d)continue;(d.status==="done"||d.status==="error")&&(o+=1),d.status==="error"&&(i+=1),(d.status==="pending"||d.status==="running")&&(a+=1);const b=d.complianceResult?.compliance_status_existing;b==="PASSED"?n+=1:b==="FAIL"?s+=1:b==="SKIPPED"&&(l+=1)}return{done:o,passed:n,failed:s,skipped:l,errored:i,pending:a}}function Vo(t){const r=t.passed+t.failed;return r>0?t.passed/r:0}function Go(t){let r=0,o=0;for(const n in t){o+=1;const s=t[n].status;(s==="done"||s==="error")&&(r+=1)}return{allDone:r,activeTotal:o}}function Zo(t,r){let o=0,n=0,s=0,l=0,i=0,a=0,f=0,d=0;for(const b of t){const p=r[b.Pole_ID],j=p?.mrResult;if(j&&p?.complianceResult?.compliance_status_existing==="FAIL"){o+=1,j.pole_needs_replacement?s+=1:j.final_compliant?n+=1:l+=1;for(const k of j.actions)i+=1,k.direction==="UP"?a+=1:f+=1,d+=Math.abs(k.delta_ft)}}return{solved:o,resolved:n,replacements:s,review:l,moves:i,raises:a,lowers:f,travelFt:d}}const Re={pending:"#6b7280",running:"#0086a3",passed:"#16a34a",failed:"#dc2626",skipped:"#94a3b8"},Bt="#00a0c6",et=[{id:"streets",label:"Streets",url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",maxZoom:19},{id:"satellite",label:"Satellite",url:"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",maxZoom:19},{id:"topo",label:"Topo",url:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",maxZoom:17}],Jo=["primary","neutral","transformer","fuse","street light","riser","catv","secondary drop","down guy","span guy","fiber","drip loop","communication","comm drop","cutout","comm ","cable ","comm_","fiber_","catv_","midspan"];function Qo(t){const r=t.toLowerCase();return Jo.some(o=>r.startsWith(o))}function Xo({rule:t}){const r=Ge(t.status),[o,n]=g.useState(t.status==="FAIL"||r),s=t.status==="FAIL",l=t.status==="SKIPPED",i=t.status==="PASSED",a=s?"color-mix(in srgb, var(--color-danger) 6%, transparent)":r?"color-mix(in srgb, var(--color-warning) 7%, transparent)":i?"color-mix(in srgb, var(--color-success) 4%, transparent)":"transparent",f=s?"var(--color-danger)":r?"var(--color-warning)":i?"var(--color-success)":"var(--text-muted)";return e.jsxs("div",{style:{marginBottom:3,borderRadius:5,overflow:"hidden",border:`1px solid ${s?"color-mix(in srgb, var(--color-danger) 25%, var(--border-color))":"var(--border-subtle)"}`,background:a},children:[e.jsxs("button",{onClick:()=>n(d=>!d),style:{width:"100%",display:"flex",alignItems:"center",gap:5,padding:"5px 7px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left"},children:[o?e.jsx(ot,{size:9,style:{color:"var(--text-muted)",flexShrink:0}}):e.jsx(ar,{size:9,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("span",{style:{flex:1,fontSize:9.5,fontWeight:600,color:f,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.rule_name}),e.jsx("span",{style:{fontSize:8,fontWeight:700,padding:"1px 4px",borderRadius:3,background:`color-mix(in srgb, ${f} 15%, transparent)`,color:f,flexShrink:0,letterSpacing:"0.04em",textTransform:"uppercase"},children:l?"skip":t.status})]}),o&&e.jsxs("div",{style:{padding:"0 7px 7px 21px",display:"flex",flexDirection:"column",gap:3},children:[t.compliance_code&&e.jsx("span",{style:{fontSize:8,fontFamily:"monospace",color:"var(--text-muted)"},children:t.compliance_code}),!l&&(t.check_value||t.threshold)&&e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs("span",{style:{fontSize:8.5,color:"var(--text-secondary)"},children:["Measured: ",e.jsx("span",{style:{fontFamily:"monospace",fontWeight:600,color:f},children:t.check_value})]}),e.jsxs("span",{style:{fontSize:8.5,color:"var(--text-secondary)"},children:["Required: ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--text-muted)"},children:t.threshold})]})]}),(s||r)&&(t.reason||t.details)&&e.jsx("p",{style:{fontSize:8.5,color:"var(--text-muted)",lineHeight:1.4,fontStyle:"italic"},children:t.reason||t.details})]})]})}function en({point:t,onClose:r}){if(!t)return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",alignItems:"center",justifyContent:"center",padding:16,color:"var(--text-muted)",fontSize:11,textAlign:"center",gap:6},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:"50%",background:"var(--bg-tertiary)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(It,{size:13,style:{color:"var(--text-muted)"}})}),"Select a pole to see details"]}
1);const o=t.row??{},n=t.complianceResult,s=n?.rule_results_existing??[],l=Object.entries(o).filter(([f,d])=>f!=="Pole_ID"&&f!=="Latitude"&&f!=="Longitude"&&d&&d.trim()!==""&&Qo(f)).map(([f,d])=>({col:f,val:d.trim()})),i=t.status==="passed"?"var(--color-success)":t.status==="failed"?"var(--color-danger)":t.status==="running"?"var(--color-brand)":"var(--text-muted)",a=t.status==="passed"?"color-mix(in srgb, var(--color-success) 12%, transparent)":t.status==="failed"?"color-mix(in srgb, var(--color-danger) 12%, transparent)":"color-mix(in srgb, var(--text-muted) 10%, transparent)";return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,padding:"9px 10px 8px",borderBottom:"1px solid var(--border-color)",flexShrink:0},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:11.5,fontWeight:700,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",letterSpacing:"-0.01em"},children:t.poleId}),e.jsxs("p",{style:{fontSize:9,fontFamily:"monospace",color:"var(--text-muted)",marginTop:2},children:[t.latitude.toFixed(6),", ",t.longitude.toFixed(6)]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4,flexShrink:0},children:[e.jsx("button",{onClick:r,style:{display:"flex",alignItems:"center",justifyContent:"center",width:18,height:18,borderRadius:4,border:"none",background:"transparent",cursor:"pointer",color:"var(--text-muted)"},children:e.jsx(ze,{size:11})}),e.jsx("span",{style:{fontSize:8,fontWeight:700,padding:"1.5px 5px",borderRadius:3,background:a,color:i,textTransform:"uppercase",letterSpacing:"0.05em"},children:t.status==="passed"?"Pass":t.status==="failed"?"Fail":t.status==="skipped"?"Skipped":t.status})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",scrollbarWidth:"thin"},children:[l.length>0&&e.jsxs("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("p",{style:{fontSize:8.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",marginBottom:5},children:"Attachments"}),l.map(({col:f,val:d})=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"3px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:9.5,color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:f}),e.jsx("span",{style:{fontSize:9.5,fontFamily:"monospace",fontWeight:600,color:"var(--text-primary)",flexShrink:0,marginLeft:8},children:d})]},f))]}),s.length>0&&e.jsxs("div",{style:{padding:"8px 10px"},children:[e.jsx("p",{style:{fontSize:8.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",marginBottom:5},children:"Compliance"}),s.map(f=>e.jsx(Xo,{rule:f},f.rule_id))]}),!n&&l.length===0&&e.jsx("p",{style:{fontSize:10,color:"var(--text-muted)",textAlign:"center",padding:"20px 12px"},children:"Run compliance to see details"})]})]})}function tn({points:t,onSelect:r,regions:o=[],onAddRegion:n,onUpdateRegion:s,onDeleteRegion:l,onOpenRegionConfig:i}){const a=g.useRef(null),f=g.useRef(null),d=g.useRef(null),b=g.useRef(null),p=g.useRef(!1),j=g.useRef(r);j.current=r;const k=g.useRef(()=>{}),C=g.useRef(null),P=g.useRef([]),D=g.useRef([]),S=g.useRef([]),w=g.useRef([]),R=g.useRef(null),M=g.useRef(null),[x,T]=g.useState("streets"),[z,N]=g.useState(""),[X,U]=g.useState(!1),[Y,V]=g.useState(!1),[ee,se]=g.useState(!1),W=g.useRef(null),q=()=>{se(!0),W.current=setTimeout(()=>{V(!1),se(!1)},200)},[y,B]=g.useState(!1),[m,A]=g.useState(!1),H=g.useRef(null),[F,ae]=g.useState(!1),[G,re]=g.useState([]),[u,E]=g.useState(!1),[L,Z]=g.useState(""),le=t.find(h=>h.isSelected)??null,oe=()=>Ft[o.length%Ft.length];g.useEffect(()=>{le?(H.current&&(clearTimeout(H.current),H.current=null),B(!1),A(!0)):m&&(B(!0),H.current=setTimeout(()=>{A(!1),B(!1),H.current=null},300))},[le?.poleId]),g.useEffect(()=>{if(!a.current||f.current)return;const h=ge.map(a.current,{zoomControl:!1,attributionControl:!1,preferCanvas:!0}),I=ge.Control.extend({onAdd:()=>{const ye=ge.DomUtil.create("div","leaflet-bar leaflet-control"),me=ge.DomUtil.create("a","",ye);return me.href="#",me.title="Center map on assets",me.setAttribute("role","button"),me.setAttribute("aria-label","Center map on assets"),me.style.display="flex",me.style.alignItems="center",me.style.justifyContent="center",me.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="22" x2="18" y1="12" y2="12"/><line x1="6" x2="2" y1="12" y2="12"/><line x1="12" x2="12" y1="6" y2="2"/><line x1="12" x2="12" y1="22" y2="18"/></svg>',ge.DomEvent.on(me,"click",Ne=>{ge.DomEvent.stop(Ne),k.current()}),ye}});new I({position:"bottomright"}).addTo(h),ge.control.zoom({position:"bottomright"}).addTo(h);const _=et[0],ie=ge.tileLayer(_.url,{maxZoom:_.maxZoom});return ie.addTo(h),b.current=ie,d.current=ge.layerGroup().addTo(h),f.current=h,setTimeout(()=>h.invalidateSize(),60),()=>{h.remove(),f.current=null,d.current=null,b.current=null,p.current=!1}},[]),g.useEffect(()=>{if(!f.current||!b.current)return;f.current.removeLayer(b.current);const h=et.find(_=>
1_.id===x)??et[0],I=ge.tileLayer(h.url,{maxZoom:h.maxZoom});I.addTo(f.current),b.current=I},[x]),g.useEffect(()=>(setTimeout(()=>f.current?.invalidateSize(),50),document.body.style.overflow=Y?"hidden":"",()=>{document.body.style.overflow=""}),[Y]),g.useEffect(()=>{setTimeout(()=>f.current?.invalidateSize(),50)},[le?.poleId]),g.useEffect(()=>{if(!f.current||!d.current)return;d.current.clearLayers();const h=t.filter(_=>_.latitude!=null&&_.longitude!=null&&!isNaN(_.latitude)&&!isNaN(_.longitude)&&Math.abs(_.latitude)<=90&&Math.abs(_.longitude)<=180);if(h.length===0)return;const I=[];if(h.forEach(_=>{I.push([_.latitude,_.longitude]);const ie=o.find(me=>rn(_.latitude,_.longitude,me.coordinates)),ye=ge.circleMarker([_.latitude,_.longitude],{radius:_.isSelected?10:6,color:_.isSelected?"white":ie?ie.color:"rgba(255,255,255,0.5)",weight:_.isSelected||ie?2.5:1,fillColor:_.isSelected?Bt:Re[_.status]??"#6b7280",fillOpacity:.9});ye.bindTooltip(_.poleId,{direction:"top",className:"leaflet-c2a-tooltip",offset:[0,-4]}),ye.on("click",()=>{j.current(_.isSelected?null:_.poleId)}),d.current.addLayer(ye)}),!p.current&&I.length>0){p.current=!0;try{f.current.fitBounds(ge.latLngBounds(I),{padding:[30,30],maxZoom:15})}catch{f.current.setView([I[0][0],I[0][1]],13)}}},[t,o]),g.useEffect(()=>{const h=f.current;h&&(P.current.forEach(I=>h.removeLayer(I)),P.current=[],o.forEach(I=>{const _=ge.polygon(I.coordinates,{color:I.color,fillColor:I.color,fillOpacity:.12,weight:2.5,interactive:!1}).addTo(h);_.bindTooltip(I.name,{sticky:!0,className:"leaflet-c2a-tooltip"}),P.current.push(_)}))},[o]),g.useEffect(()=>{const h=f.current;if(h&&(D.current.forEach(I=>I.forEach(_=>h.removeLayer(_))),D.current=[],!(!s||F||u)))return S.current=o.map(I=>I.coordinates.map(_=>[_[0],_[1]])),o.forEach((I,_)=>{const ie=[],ye=P.current[_];I.coordinates.forEach((me,Ne)=>{const Qe=ge.divIcon({className:"",html:`<div style="width:10px;height:10px;border-radius:50%;background:white;border:2.5px solid ${I.color};cursor:grab;box-shadow:0 1px 3px rgba(0,0,0,0.4);box-sizing:border-box"></div>`,iconSize:[10,10],iconAnchor:[5,5]}),de=ge.marker(me,{icon:Qe,draggable:!0,zIndexOffset:1e3}).addTo(h);de.on("drag",Xe=>{const{lat:We,lng:Oe}=Xe.latlng;S.current[_][Ne]=[We,Oe],ye&&ye.setLatLngs(S.current[_])}),de.on("dragend",()=>{s(I.id,[...S.current[_]])}),ie.push(de)}),D.current.push(ie)}),()=>{D.current.forEach(I=>I.forEach(_=>h.removeLayer(_))),D.current=[]}},[o,F,u,s]),g.useEffect(()=>{const h=f.current;if(!h||!F)return;const I=ie=>{re(ye=>[...ye,[ie.latlng.lat,ie.latlng.lng]])},_=()=>{ae(!1),E(!0)};return h.on("click",I),h.on("dblclick",_),h.doubleClickZoom.disable(),h.getContainer().style.cursor="crosshair",()=>{h.off("click",I),h.off("dblclick",_),h.doubleClickZoom.enable(),h.getContainer().style.cursor=""}},[F]),g.useEffect(()=>{const h=f.current;if(!h||(w.current.forEach(_=>h.removeLayer(_)),w.current=[],R.current?.remove(),R.current=null,M.current?.remove(),M.current=null,G.length===0))return;const I=oe();G.forEach(_=>{const ie=ge.circleMarker(_,{radius:5,color:I,fillColor:"white",fillOpacity:1,weight:2,interactive:!1}).addTo(h);w.current.push(ie)}),G.length>1&&(R.current=ge.polyline(G,{color:I,weight:2,dashArray:"6,4",interactive:!1}).addTo(h)),G.length>=3&&(M.current=ge.polygon(G,{color:I,fillColor:I,fillOpacity:.1,weight:2,dashArray:"6,4",interactive:!1}).addTo(h))},[G,o.length]);const O=g.useCallback(()=>{const h=f.current;h&&(w.current.forEach(I=>h.removeLayer(I)),w.current=[],R.current?.remove(),R.current=null,M.current?.remove(),M.current=null)},[]),xe=g.useCallback(()=>{ae(!1),E(!1),re([]),Z(""),O()},[O]),we=g.useCallback(()=>{if(G.length<3)return;const h=L.trim()||`Region ${o.length+1}`,I=oe();n?.(h,G,I),re([]),Z(""),E(!1),O()},[G,L,o.length,n,O]);g.useEffect(()=>{const h=C.current;if(!h)return;const I=_=>_.stopPropagation();return h.addEventListener("wheel",I,{passive:!1}),()=>h.removeEventListener("wheel",I)},[X,z]);const Te=z.trim()?t.filter(h=>h.poleId.toLowerCase().includes(z.toLowerCase())).slice(0,8):[],$e=g.useCallback(h=>{N(h.poleId),U(!1),f.current&&f.current.flyTo([h.latitude,h.longitude],17,{duration:.5}),j.current(h.poleId)},[]),Ce=g.useCallback(()=>{const h=f.current;if(!h)return;const I=t.filter(_=>_.latitude!=null&&_.longitude!=null&&!isNaN(_.latitude)&&!isNaN(_.longitude)&&Math.abs(_.latitude)<=90&&Math.abs(_.longitude)<=180).map(_=>[_.latitude,_.longitude]);if(I.length!==0)try{h.fitBounds(ge.latLngBounds(I),{padding:[30,30],maxZoom:15})}catch{h.setView([I[0][0],I[0][1]],13)}},[t]);k.current=Ce;const ve=Y||ee?{position:"fixed",inset:0,zIndex:9999,display:"flex",background:"var(--bg-primary)"}:{width:"100%",height:"100%",display:"flex"},J=Y?300:260;return e.jsxs("div",{className:ee?"animate-map-fullscreen-out":Y?"animate-map-fullscreen":void 0,style:ve,onMouseDown:h=>h.stopPropagation(),onClick:h=>h.stopPropagation(),onDoubleClick:h=>h.stopPropagation(),onContextMenu:h=>h.stopPropagation(),onWheel:h=>h.stopPropagation(),children:[e.jsxs("div",{style:{flex:1,position:"relative",height:"100%",minHeight:Y?void 0:380},children:[e.jsx("div",{ref:a,style:{width:"100%",height:"100%"}}),e.jsxs("div",{className:"animate-fade-in",style:{position:"absolute",top:8,left:8,zIndex:1e3,display:"flex",flexDirection:"column",gap:4,pointerEvents:"auto"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,padding:"5px 8px",borderRadius:6,background:"var(--card-bg)",border:"1px solid var(--border-color)",boxShadow:"var(--shadow-elevated)"},children:[e.jsx(It,{size:11,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("input",{value:z,onChange:h=>{N(h.target.value),U(!0)},onFocus:()=>U(!0),onBlur:()=>setTimeout(()=>U(!1),150),placeholder:"Search asset...",style:{border:"none",outline:"none",background:"transparent",fontSize:11,color:"var(--text-primary)",width:110}}),z&&e.jsx("button",{onClick:()=>{N(""),U(!1),j.current(null)}
1,style:{border:"none",background:"transparent",cursor:"pointer",color:"var(--text-muted)",display:"flex",padding:0},children:e.jsx(ze,{size:10})})]}),X&&Te.length>0&&e.jsx("div",{className:"animate-fade-in",ref:C,style:{position:"absolute",top:"calc(100% + 3px)",left:0,minWidth:260,maxHeight:220,overflowY:"auto",borderRadius:6,background:"var(--card-bg)",border:"1px solid var(--border-color)",boxShadow:"var(--shadow-elevated)",zIndex:1001,scrollbarWidth:"thin"},children:Te.map(h=>{const I=h.status==="passed"?Re.passed:h.status==="failed"?Re.failed:h.status==="running"?Re.running:h.status==="skipped"?Re.skipped:Re.pending;return e.jsxs("div",{onMouseDown:()=>$e(h),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",cursor:"pointer",borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:_=>{_.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:I,flexShrink:0}}),e.jsx("span",{style:{fontSize:10.5,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.poleId}),e.jsxs("span",{style:{fontSize:8.5,color:"var(--text-muted)",flexShrink:0,fontFamily:"monospace"},children:[h.latitude.toFixed(4),", ",h.longitude.toFixed(4)]})]},h.poleId)})})]}),e.jsx("div",{style:{display:"flex",gap:2,padding:"3px",borderRadius:6,background:"var(--card-bg)",border:"1px solid var(--border-color)",boxShadow:"var(--shadow-elevated)"},children:et.map(h=>e.jsx("button",{onClick:()=>T(h.id),style:{fontSize:9.5,fontWeight:x===h.id?700:400,padding:"2.5px 8px",borderRadius:4,border:"none",cursor:"pointer",background:x===h.id?"var(--color-brand)":"transparent",color:x===h.id?"white":"var(--text-muted)",transition:"all 0.12s"},onMouseEnter:I=>{x!==h.id&&(I.currentTarget.style.background="var(--hover-bg)",I.currentTarget.style.color="var(--text-primary)")},onMouseLeave:I=>{x!==h.id&&(I.currentTarget.style.background="transparent",I.currentTarget.style.color="var(--text-muted)")},children:h.label},h.id))})]}),e.jsx("div",{className:"animate-fade-in",style:{position:"absolute",top:8,right:8,zIndex:1e3,display:"flex",flexDirection:"column",gap:4},children:e.jsx("button",{onClick:()=>Y?q():V(!0),title:Y?"Exit fullscreen":"Fullscreen",style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:"1px solid var(--border-color)",background:"var(--card-bg)",boxShadow:"var(--shadow-elevated)",cursor:"pointer",color:"var(--text-muted)",transition:"color 0.12s, border-color 0.12s"},onMouseEnter:h=>{h.currentTarget.style.color="var(--text-primary)",h.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:h=>{h.currentTarget.style.color="var(--text-muted)",h.currentTarget.style.borderColor="var(--border-color)"},children:Y?e.jsx(bo,{size:12}):e.jsx(vo,{size:12})})}),F&&e.jsxs("div",{style:{position:"absolute",bottom:16,left:"50%",transform:"translateX(-50%)",zIndex:1e3,background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:8,padding:"6px 14px",boxShadow:"var(--shadow-elevated)",display:"flex",alignItems:"center",gap:10,whiteSpace:"nowrap"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--text-secondary)"},children:G.length===0?"Click to add points":G.length<3?`${G.length} point${G.length>1?"s":""} - keep clicking`:`${G.length} points - double-click to finish`}),G.length>=3&&e.jsxs("button",{onClick:()=>{ae(!1),E(!0)},style:{display:"flex",alignItems:"center",gap:4,fontSize:10,padding:"3px 10px",borderRadius:5,border:"none",background:"var(--color-brand)",color:"white",cursor:"pointer",fontWeight:600},children:[e.jsx(Zr,{size:11})," Done"]})]}),u&&e.jsx("div",{style:{position:"absolute",inset:0,zIndex:1500,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.25)"},children:e.jsxs("div",{style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:10,padding:"18px 20px",display:"flex",flexDirection:"column",gap:12,boxShadow:"var(--shadow-elevated)",minWidth:240},children:[e.jsx("p",{style:{fontSize:13,fontWeight:700,color:"var(--text-primary)",margin:0},children:"Name this region"}),e.jsx("input",{autoFocus:!0,value:L,onChange:h=>Z(h.target.value),onKeyDown:h=>{h.key==="Enter"&&we(),h.key==="Escape"&&xe()},placeholder:`Region ${o.length+1}`,style:{fontSize:12,padding:"6px 10px",borderRadius:6,border:"1px solid var(--border-color)",background:"var(--input-bg)",color:"var(--text-primary)",outline:"none"}}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:xe,style:{fontSize:11,padding:"5px 12px",borderRadius:6,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s, border-color 0.12s"},onMouseEnter:h=>{h.currentTarget.style.color="#ef4444",h.currentTarget.style.borderColor="#ef4444"},onMouseLeave:h=>{h.currentTarget.style.color="var(--text-muted)",h.currentTarget.style.borderColor="var(--border-color)"},children:"Cancel"}),e.jsx("button",{onClick:we,style:{fontSize:11,padding:"5px 12px",borderRadius:6,border:"none",background:"var(--color-brand)",color:"white",cursor:"pointer",fontWeight:600,transition:"filter 0.12s"},onMouseEnter:h=>{h.currentTarget.style.filter="brightness(1.12)"},onMouseLeave:h=>{h.currentTarget.style.filter="none"},children:"Save region"})]})]})}),o.length>0&&!F&&!u&&e.jsxs("div",{style:{position:"absolute",bottom:8,left:8,zIndex:1e3,background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:8,padding:"8px 10px",boxShadow:"var(--shadow-elevated)",maxWidth:200},children:[e.jsx("p",{style:{fontSize:8.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",marginBottom:6},children:"Regions"}),o.map(h=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:2,background:h.color,flexShrink:0}}
1),e.jsx("span",{style:{fontSize:10,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:h.name}),l&&e.jsx("button",{onClick:()=>l(h.id),title:"Delete region",style:{display:"flex",border:"none",background:"transparent",cursor:"pointer",color:"var(--text-muted)",padding:1,flexShrink:0},onMouseEnter:I=>{I.currentTarget.style.color="#ef4444"},onMouseLeave:I=>{I.currentTarget.style.color="var(--text-muted)"},children:e.jsx(Jr,{size:9})})]},h.id))]}),Y&&e.jsxs("div",{className:"animate-pop-in",style:{position:"absolute",bottom:88,right:8,zIndex:1e3,padding:"8px 12px",borderRadius:8,background:"var(--card-bg)",border:"1px solid var(--border-color)",boxShadow:"var(--shadow-elevated)"},children:[e.jsx("p",{style:{fontSize:8.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",marginBottom:5},children:"Legend"}),[{color:Re.passed,label:"Compliant"},{color:Re.failed,label:"Non-compliant"},{color:Bt,label:"Selected"},{color:Re.running,label:"Processing"},{color:Re.pending,label:"Pending"},{color:Re.skipped,label:"Skipped"}].map(({color:h,label:I})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:3},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:h,flexShrink:0}}),e.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)"},children:I})]},I))]})]}),m&&e.jsx("div",{className:y?"animate-slide-to-right":"animate-slide-from-right",style:{width:J,flexShrink:0,height:"100%",borderLeft:"1px solid var(--border-color)",background:"var(--card-bg)",display:"flex",flexDirection:"column",overflow:"hidden"},children:e.jsx(en,{point:le,onClose:()=>j.current(null)})})]})}function rn(t,r,o){let n=!1;for(let s=0,l=o.length-1;s<o.length;l=s++){const[i,a]=o[s],[f,d]=o[l];i>t!=f>t&&r<(d-a)*(t-i)/(f-i)+a&&(n=!n)}return n}function vt(t){const r=t.match(/(\d+)'\s*(\d+(?:\.\d+)?)"?/);if(r)return parseInt(r[1],10)+parseFloat(r[2])/12;const o=t.trim();if(!o)return null;const n=Number(o);return Number.isFinite(n)?n:null}function Pt(t,r){return!r||Object.keys(r).length===0?t:t.map(o=>{const n=r[o.column]?.trim();if(!n||n===o.proposed_height)return o;const s=vt(n);if(s===null)return o;const l=vt(o.existing_height);if(l===null)return{...o,proposed_height:n};const i=s-l;return{...o,proposed_height:n,delta_ft:Math.round(Math.abs(i)*1e4)/1e4,direction:i>
1=0?"UP":"DOWN"}})}const zt=100,Ht=["#0f7fc4","#0e9e8a","#6f5be6","#d9822b"];function on(t){const r=t<0?"-":"",o=Math.round(Math.abs(t));return`${r}${Math.floor(o/12)}' ${o%12}"`}function Se(t){const r=Math.round(Math.abs(t));return r<zt?`${t<0?"-":""}${r}"`:on(t)}function br(t){const r=Math.round(Math.abs(t)),o=t<0?"-":"";if(r<zt)return`${o}${r} in`;const n=Math.floor(r/12),s=r%12;return s?`${o}${n} ft ${s} in`:`${o}${n} ft`}function tt(t){return t.replace(/(-?)(\d+)' (\d+)"/g,(r,o,n,s)=>{const l=parseInt(n,10)*12+parseInt(s,10);return l<zt?`${o}${l}"`:r})}function Ue(t){if(t==null)return null;const r=vt(String(t));return r==null||!Number.isFinite(r)||r<=0||r>250?null:r*12}function yt(t){return t.replace(/\s+\d+$/,"").replace(/_/g," ").trim()}function nn(t){const r=new Map;for(const o of t){const n=yt(o);r.set(n,(r.get(n)??0)+1)}return o=>{const n=yt(o);return(r.get(n)??0)>1?o.replace(/_/g," ").trim():n}}const sn=new Set(["Pole_ID","PoleID","pole_id","pole_num","Batch","Latitude","Longitude","latitude","longitude","SourcePath","source_path","type","filename","Notes","Map_Note","Flagged","make_ready_actions","compliance_status","violations","compliance_details","attachments involved in violations"]);function an(t){return t.find(r=>{const o=r.toLowerCase();return o.includes("pole")&&(o.includes("height")||o.includes("_ht")||o.includes(" ht")||o.includes("tip"))||o==="total_height"||o==="pole_h"})??null}function ln(t){const r=t.toLowerCase();return r.includes("primary")||r.includes("phase")?{color:"#ef4444",category:"Power (Primary)",kind:"power"}:r.includes("neutral")?{color:"#f59e0b",category:"Neutral",kind:"power"}:r.includes("transformer")||r.includes("transform")?{color:"#dc2626",category:"Transformer",kind:"power"}:r.includes("secondary")||r.includes("service_drop")||r.includes("drip")||r.includes("fuse")||r.includes("capacitor")||r.includes("cutout")||r.includes("arrestor")||r.includes("riser")?{color:"#fb923c",category:"Power hardware",kind:"power"}:r.includes("guy")&&r.includes("power")?{color:"#9ca3af",category:"Guy / Anchor",kind:"power"}:r.includes("catv")||r.includes("cable_tv")||r.includes("charter")||r.includes("spectrum")||r.includes("comcast")?{color:"#3b82f6",category:"Cable TV",kind:"comm"}:r.includes("fiber")||r.includes("fibre")?{color:"#8b5cf6",category:"Fiber",kind:"comm"}:r.includes("telco")||r.includes("telephone")||r.includes("lumen")||r.includes("centurylink")?{color:"#06b6d4",category:"Telco",kind:"comm"}:r.includes("drop")?{color:"#0ea5e9",category:"Comm drop",kind:"comm"}:r.includes("clec")||r.includes("comm")?{color:"#0891b2",category:"Communication",kind:"comm"}:r.includes("guy")||r.includes("anchor")?{color:"#9ca3af",category:"Guy / Anchor",kind:"other"}:r.includes("street")||r.includes("light")?{color:"#a3a3a3",category:"Street light",kind:"other"}:{color:"#a1a1aa",category:"Other",kind:"other"}}function cn(t){const r=new Map;for(const o of t?.wire_groups??[])for(const n of o.wire_types)r.set(n.toLowerCase(),o.locked_in_make_ready?"power":"comm");return r}function dn(t){let r=null,o=null;const n=new Map((t?.wire_groups??[]).map(s=>[s.id,s]));for(const s of t?.rules??[]){if(s.enabled===!1)continue;const l=s.rule_type,i=Number(s.threshold_in);if(Number.isFinite(i)){if(l==="group_separation"&&r==null){const a=n.get(s.upper_group_id??""),f=n.get(s.lower_group_id??"");a?.locked_in_make_ready&&f&&!f.locked_in_make_ready&&(r=i)}if(l==="group_min_height"&&o==null){const a=n.get(s.group_id??"");a&&!a.locked_in_make_ready&&(o=i)}}}return{separationIn:r,minCommIn:o}}function Ut(t,r){if(r==null)return null;const o=t.filter(a=>a.kind==="power").map(a=>a.inches),n=t.filter(a=>a.kind==="comm").map(a=>a.inches);if(!o.length||!n.length)return null;const s=Math.min(...o),l=Math.max(...n),i=s-l;return{loIn:Math.min(s,l),hiIn:Math.max(s,l),gapIn:i,neededIn:r,ok:i>=r}}function un({row:t,availableColumns:r,actions:o,ruleResults:n=[],config:s}){const l=an(r),i=cn(s),a=r.filter(x=>!sn.has(x)&&x!==l&&Ue(t[x])!=null),f=nn(a),d=a.map(x=>{const T=ln(x),z=i.get(yt(x).toLowerCase())??T.kind;return{column:x,label:f(x),inches:Ue(t[x]),kind:z,color:T.color,category:T.category}}),b=[];o.forEach((x,T)=>{const z=Ue(x.existing_height),N=Ue(x.proposed_height);z==null||N==null||!d.some(X=>X.column===x.column)||b.push({column:x.column,oldIn:z,newIn:N,order:T,hue:""})}),[...b].sort((x,T)=>
1T.newIn-x.newIn).forEach((x,T)=>{x.hue=Ht[T%Ht.length]});const j=new Map(b.map(x=>[x.column,x])),k=d.map(x=>{const T=j.get(x.column);return T?{...x,inches:T.newIn}:x}),C=new Set;for(const x of n)if(x.status==="FAIL")for(const T of x.involved_columns??[])C.add(T);const P=l?Ue(t[l]):null,D=[...d,...k].map(x=>x.inches),S=D.length?Math.max(...D):0,w=Math.max(P??S+40,S+6),{separationIn:R,minCommIn:M}=dn(s);return{attachments:d,after:k,moves:b,moveByColumn:j,violating:C,poleHeightIn:w,minCommIn:M,gapBefore:Ut(d,R),gapAfter:Ut(k,R)}}function jt(t,r,o,n){if(!t.length)return[];const s=[];for(const i of t)for(s.push([i,1]);s.length>1;){const a=s[s.length-2],f=s[s.length-1],d=a[0]/a[1]+(a[1]-1)*r/2;if(f[0]/f[1]-(f[1]-1)*r/2-d<r)s[s.length-2]=[a[0]+f[0],a[1]+f[1]],s.pop();else break}const l=[];for(const[i,a]of s){const f=i/a-(a-1)*r/2;for(let d=0;d<a;d++)l.push(f+d*r)}for(let i=0;i<l.length;i++)l[i]=Math.max(l[i],i===0?o:Math.max(o,l[i-1]+r));for(let i=l.length-1;i>=0;i--)l[i]=Math.min(l[i],i===l.length-1?n:Math.min(n,l[i+1]-r));return l}function pn(t,r=8){const o=t.map(l=>({top:Math.max(l.oldIn,l.newIn),bottom:Math.min(l.oldIn,l.newIn),column:l.column}));o.sort((l,i)=>i.top-l.top||i.bottom-l.bottom);const n=[],s=new Map;for(const l of o){let i=!1;for(let a=0;a<n.length;a++)if(n[a]-r>l.top){n[a]=l.bottom,s.set(l.column,a),i=!0;break}i||(s.set(l.column,n.length),n.push(l.bottom))}return{lanes:s,count:n.length}}function vr(t,r,o){return t*r<=o?r:Math.max(7.5,o/t)}function gn(t,r,o,n,s=7){const l=o.filter(d=>d>t+1&&d<r-1).sort((d,b)=>d-b),i=[t,...l.flatMap(d=>[d-s,d+s]),r];let a=null;for(let d=0;d<i.length;d+=2){const b=i[d],p=i[d+1];p-b>=n&&(!a||p-b>a[1]-a[0])&&(a=[b,p])}if(a)return(a[0]+a[1])/2;const f=d=>o.some(b=>Math.abs(b-d)<n/2+s);for(let d=r+s+n/2;d<r+400;d+=3)if(!f(d))return d;for(let d=t-s-n/2;d>t-400;d-=3)if(!f(d))return d;return r+s+n/2}function fn(t,r,o,n=34){const s=[...t.attachments,...t.after].map(p=>p.inches),l=Math.max(t.poleHeightIn,...s)+16,i=s.length?Math.min(...s):l,a=t.minCommIn==null?i:Math.min(i,t.minCommIn),f=Math.max(0,a-24);if(f<72){const p=(o-r)/l;return{Y:j=>o-j*p,topIn:l,breakTopIn:null,breakY:null}}const d=(o-n-r)/(l-f);return{Y:p=>p<=f?o-p/f*n:o-n-(p-f)*d,topIn:l,breakTopIn:f,breakY:o-n}}const xn=380,Ze=460,De=18,fe=Ze-26,mn=120,yr=186,St=9,hn=140,Ie="Inter, system-ui, -apple-system, sans-serif",qt="cubic-bezier(.22,.9,.24,1)",Kt=1100,Ae="var(--color-danger, #dc2626)",kt="var(--color-brand, #0f7fc4)",bn="var(--text-primary, #0f2138)",Ye="var(--text-muted, #6a7b93)",Fe="var(--border-color, #dce4ef)",Ct="var(--card-bg, #ffffff)",vn="var(--bg-tertiary, #e7edf5)";function Yt(t,r,o){Qr.flushSync(()=>t({step:0,instant:!0,stagger:!1})),r?.offsetWidth,requestAnimationFrame(()=>requestAnimationFrame(()=>t({step:o,instant:!1,stagger:!0})))}function yn({poleId:t,row:r,availableColumns:o,actions:n,ruleResults:s=[],config:l,afterStatus:i=null}){const a=Pe(p=>p.config),f=l??a,d=g.useMemo(()=>un({row:r,availableColumns:o,actions:n,ruleResults:s,config:f}),[r,o,n,s,f]),b=s.filter(p=>p.status==="FAIL").length;return e.jsx(jn,{model:d,failCount:b,afterStatus:i},`${t}:${d.moves.length}`)}function jn({model:t,failCount:r,afterStatus:o}){const n=t.moves.length,[s,l]=g.useState({step:n,instant:!0,stagger:!1}),[i,a]=g.useState(null),f=g.useRef(null),d=g.useId().replace(/:/g,"");g.useEffect(()=>{if(!n)return;const S=window.setTimeout(()=>Yt(l,f.current,n),450);return()=>window.clearTimeout(S)},[n]);function b(S){l({step:Math.max(0,Math.min(n,S)),instant:!1,stagger:!1})}const p=()=>Yt(l,f.current,n),j=g.useMemo(()=>{const S=[...t.attachments,...t.after].map(N=>N.inches),w=fn(t,De,fe),{lanes:R,count:M}=pn(t.moves),x=yr+26+St*Math.max(1,M)+12,T=Math.max(xn,x+hn),z=Math.max(t.poleHeightIn,...S.map(N=>N+6));return{Y:w.Y,W:T,topIn:w.topIn,lanes:R,rightX:x,drawPoleH:z,breakTopIn:w.breakTopIn,breakY:w.breakY}},[t]);if(!t.attachments.length)return e.jsx("div",{className:"mr-empty",children:"No attachment heights were recorded for this asset."});const k=S=>i!=null&&i!==S,C=S=>({onMouseEnter:()=>a(S),onMouseLeave:()=>a(null)}),P=Math.min(220,1200/Math.max(1,n-1));if(!n)return e.jsxs("div",{className:"mr-stage-wrap",children:[e.jsx("div",{className:"mr-stage mr-stage-single",ref:f,children:e.jsxs("div",{className:"mr-card",children:[e.jsxs("div",{className:"mr-card-head",children:[e.jsx("span",{className:"mr-lab mr-lab-before",children:t.violating.size?"Existing":"As recorded"}),e.jsx("span",{className:"mr-note",children:t.violating.size?"No moves proposed":"Every enabled rule passes"})]}),e.jsx(Vt,{model:t,geo:j,uid:d+"a",dimmed:k,hover:C})]})}),e.jsxs("div",{className:"mr-legend",children:[t.violating.size>0&&e.jsxs("span",{children:[e.jsx("i",{className:"viol"}),"Violating today"]}),e.jsxs("span",{children:[e.jsx("i",{}),"Attachment"]})]})]});const D=t.moves.reduce((S,w)=>S+Math.abs(w.newIn-w.oldIn),0);return e.jsxs("div",{className:"mr-stage-wrap",children:[e.jsxs("div",{className:"mr-summary",children:[e.jsxs("span",{className:r?"bad":"good",children:[e.jsx("b",{children:r})," ",r===1?"check fails":"checks fail"," today"]}),e.jsxs("span",{children:[e.jsx("b",{children:n})," ",n===1?"move":"moves"]}),e.jsxs("span",{children:[e.jsx("b",{children:br(D)})," of travel"]}),o&&e.jsxs("span",{className:o==="PASS"?"good":"bad",children:["after make-ready ",e.jsx("b",{children:o==="REPLACE"?"pole replacement":o==="PASS"?"every rule passes":"still fails"})]})]}),e.jsxs("div",{className:"mr-stage",ref:f,children:[e.jsxs("div",{className:"mr-card",children:[e.jsx("div",{className:"mr-card-head",children:e.jsx("span",{className:"mr-lab mr-lab-before",children:"Existing"})}),e.jsx(Vt,{model:t,geo:j,uid:d+"a",dimmed:k,hover:C})]}),e.jsxs("div",{className:"mr-card mr-card-after",onClick:p,children:[e.jsxs("div",{className:"mr-card-head",children:[e.jsx("span",{className:"mr-lab mr-lab-after",children:"After make-ready"}),e.jsx("span",{className:"mr-replay",children:"↻ Replay"})]}),e.jsx(kn,{model:t,geo:j,uid:d+"b",phase:s,gapMs:P,dimmed:k,hover:C})]})]}),n>0&&e.jsxs("div",{className:"mr-stepper",tabIndex:0,"aria-label":"Step through the make-ready moves",onKeyDown:S=>{S.key==="ArrowLeft"&&(S.preventDefault(),b(s.step-1)),S.key==="ArrowRight"&&(S.preventDefault(),b(s.step+1))},children:[e.jsx("button",{className:"mr-st-btn",disabled:s.step===0,onClick:()=>b(s.step-1),"aria-label":"Undo one move",children:"‹"}),e.jsx("div",{className:"mr-st-chips",children:t.moves.map(S=>{const w=S.order+1,R=t.attachments.find(T=>T.column===S.column),M=w<=s.step,x=w===s.step;return e.jsxs("button",{className:`mr-st-chip${M?" on":""}${x?" cur":""}`,style:{"--hue":S.hue},onClick:()=>b(w===s.step?w-1:w),children:[e.jsx("b",{children:w}),R.label,e.jsxs("span",{children:[S.newIn<S.oldIn?"▼":"▲"," ",Se(Math.abs(S.newIn-S.oldIn))]})]},S.column)})}),e.jsx("button",{className:"mr-st-btn",disabled:s.step===n,onClick:()=>b(s.step+1),"aria-label":"Apply one move",children:"›"}),e.jsx("input",{type:"range",className:"mr-st-range",min:0,max:n,value:s.step,onChange:S=>b(+S.target.value),"aria-label":"Moves applied"}),e.jsx("button",{className:"mr-st-play",onClick:p,children:"▶ Play all"}),e.jsx("div",{className:"mr-st-count",children:s.step===0?"Existing state":s.step===n?`All ${n} move${n===1?"":"s"} applied`:`Move ${s.step} of ${n}`})]}),e.jsxs("div",{className:"mr-legend",children:[e.jsxs("span",{children:[e.jsx("i",{className:"viol"}),"Violating today"]}),e.jsxs("span",{children:[e.jsx("i",{}),"Left alone"]}),e.jsxs("span",{children:[e.jsx("i",{className:"ghost"}),"Old height"]}),e.jsxs("span",{children:[e.jsx("i",{className:"new"}),"New height"]})]})]})}function jr({uid:t}){return e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:`pole-${t}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[e.jsx("stop",{offset:"0",stopColor:"#dcc39a"}),e.jsx("stop",{offset:"0.45",stopColor:"#c7a97e"}),e.jsx("stop",{offset:"1",stopColor:"#9c7b52"})]}),e.jsxs("radialGradient",{id:`shadow-${t}`,cx:"0.5",cy:"0.5",r:"0.5",children:[e.jsx("stop",{offset:"0",stopColor:"#3a3128",stopOpacity:"0.30"}),e.jsx("stop",{offset:"1",stopColor:"#3a3128",stopOpacity:"0"})]})]})}function Sr({geo:t,poleX:r,minCommIn:o}){const{Y:n,W:s,topIn:l}=t,i=[];for(let d=6;d<s;d+=11)i.push(d);const a=[];for(let d=10;d*12<l-12;d+=10)(t.breakTopIn==null||d*12>t.breakTopIn)&&a.push(d);const f=(d,b,p)=>{const j=[];for(let k=d,C=0;k<=b;k+=4,C++)j.push(`${k},${p+(C%2?2.4:-2.4)}`);return j.join(" ")};return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:fe,width:s,height:Ze-fe,fill:vn}),o!=null&&o<l&&e.jsxs("g",{children:[e.jsx("rect",{x:26,y:n(o),width:s-32,height:fe-n(o),fill:Ae,opacity:.06}),e.jsx("line",{x1:r-44,y1:n(o),x2:r+44,y2:n(o),stroke:Ae,strokeWidth:1,strokeDasharray:"4 3",opacity:.6}),e.jsxs("text",{x:s-8,y:fe-5,textAnchor:"end",fontFamily:Ie,fontSize:7,fill:Ae,opacity:.85,children:["minimum ",Se(o)]})]}),t.breakY!=null&&e.jsxs("g",{children:[e.jsx("rect",{x:0,y:t.breakY-4,width:s,height:8,fill:Ct}),e.jsx("polyline",{points:f(r-14,r+14,t.breakY-3),fill:"none",stroke:Ye,strokeWidth:.9}),e.jsx("polyline",{points:f(r-14,r+14,t.breakY+3),fill:"none",stroke:Ye,strokeWidth:.9}),e.jsxs("text",{x:s-8,y:t.breakY+2.6,textAnchor:"end",fontFamily:Ie,fontSize:6.6,fill:Ye,opacity:.85,children:["lower ",br(t.breakTopIn)," of the pole, compressed"]})]}),i.map(d=>e.jsx("line",{x1:d,y1:fe+3,x2:d-7,y2:Ze-3,stroke:Fe,strokeWidth:1},d)),e.jsx("line",{x1:0,y1:fe,x2:s,y2:fe,stroke:Fe,strokeWidth:1}),a.map(d=>e.jsxs("g",{children:[e.jsx("line",{x1:26,y1:n(d*12),x2:s-6,y2:n(d*12),stroke:Fe,strokeWidth:1,opacity:.7}),e.jsxs("text",{x:22,y:n(d*12)+3,textAnchor:"end",fontFamily:Ie,fontSize:7.6,fill:Ye,children:[d," ft"]})]},d))]})}function kr({geo:t,poleX:r,uid:o}){const n=t.Y(t.drawPoleH),s=5.5,l=3.8,i=`M ${r-s} ${fe} L ${r-l} ${n+l} A ${l} ${l} 0 0 1 ${r+l} ${n+l} L ${r+s} ${fe} Z`;
1return e.jsxs("g",{children:[e.jsx("ellipse",{cx:r,cy:fe+2.5,rx:30,ry:5,fill:`url(#shadow-${o})`}),e.jsx("path",{d:i,fill:`url(#pole-${o})`,stroke:"#a88860",strokeWidth:.9}),e.jsx("path",{d:`M ${r-2.2} ${fe-4} L ${r-1.5} ${n+9}`,stroke:"#7d6140",strokeWidth:.7,opacity:.28}),e.jsx("path",{d:`M ${r+2.4} ${fe-10} L ${r+1.7} ${n+14}`,stroke:"#f0dfc4",strokeWidth:.7,opacity:.55})]})}function wt({poleX:t,y:r,color:o,opacity:n}){return e.jsxs("g",{opacity:n,children:[e.jsx("line",{x1:t-3,y1:r,x2:t-24,y2:r+14,stroke:o,strokeWidth:1.3}),e.jsx("circle",{cx:t-24,cy:r+14,r:1.9,fill:o})]})}const Rt=t=>t.toLowerCase().includes("guy");function Vt({model:t,geo:r,uid:o,dimmed:n,hover:s}){const{Y:l,W:i}=r,a=mn,f=[...t.attachments].sort((p,j)=>j.inches-p.inches),d=jt(f.map(p=>l(p.inches)),vr(f.length,11,fe-4-(De+8)),De+8,fe-4),b=a+46;return e.jsxs("svg",{viewBox:`0 0 ${i} ${Ze}`,className:"mr-svg",role:"img","aria-label":"Existing attachments",children:[e.jsx(jr,{uid:o}),e.jsx(Sr,{geo:r,poleX:a,minCommIn:t.minCommIn}),e.jsx(kr,{geo:r,poleX:a,uid:o}),e.jsx(Sn,{gap:t.gapBefore,Y:l,x:a-30}),f.map((p,j)=>{const k=l(p.inches),C=d[j],P=t.violating.has(p.column),D=P?Ae:p.color;return e.jsxs("g",{className:"mr-att","data-col":p.column,opacity:n(p.column)?.22:1,...s(p.column),children:[Rt(p.column)&&e.jsx(wt,{poleX:a,y:k,color:D,opacity:.85}),P&&e.jsx("line",{x1:a-19,y1:k,x2:a+19,y2:k,stroke:Ae,strokeWidth:8,strokeLinecap:"round",opacity:.16}),e.jsx("line",{x1:a-15,y1:k,x2:a+15,y2:k,stroke:D,strokeWidth:2.4,strokeLinecap:"round"}),e.jsx("rect",{x:a-5.2,y:k-1.7,width:10.4,height:3.4,rx:1.5,fill:D}),Math.abs(C-k)>2&&e.jsx("line",{x1:a+16,y1:k,x2:b-4,y2:C-3,stroke:Fe,strokeWidth:.9}),e.jsxs("text",{x:b,y:C,fontFamily:Ie,fontSize:8.2,fontWeight:P?700:500,fill:P?Ae:bn,children:[p.label," · ",Se(p.inches)]})]},p.column)})]})}function Sn({gap:t,Y:r,x:o}){if(!t)return null;const n=t.ok?kt:Ae,s=t.gapIn<0?[`comm ${Se(-t.gapIn)}`,"above power"]:[`${Se(t.gapIn)} gap`,`needs ${Se(t.neededIn)}`],l=(r(t.hiIn)+r(t.loIn))/2;return e.jsxs("g",{children:[e.jsx("line",{x1:o,y1:r(t.hiIn),x2:o,y2:r(t.loIn),stroke:n,strokeWidth:1.4}),[r(t.hiIn),r(t.loIn)].map((i,a)=>e.jsx("line",{x1:o-4,y1:i,x2:o+4,y2:i,stroke:n,strokeWidth:1.4},a)),s.map((i,a)=>e.jsx("text",{x:o-7,y:l+a*10-4*(s.length-1),textAnchor:"end",fontFamily:Ie,fontSize:7.8,fontWeight:600,fill:n,children:i},i))]})}function kn({model:t,geo:r,uid:o,phase:n,gapMs:s,dimmed:l,hover:i}){const{Y:a,W:f,lanes:d,rightX:b}=r,p=yr,j=fe-12-(De+8),k=t.after.filter(x=>!t.moveByColumn.has(x.column)).sort((x,T)=>T.inches-x.inches),C=jt(k.map(x=>a(x.inches)),vr(k.length,11,fe-4-(De+8)),De+8,fe-4),P=[...t.moves].map(x=>({...x,att:t.after.find(T=>T.column===x.column)})).sort((x,T)=>T.newIn-x.newIn),D=P.length*20<=j?20:Math.max(11,j/Math.max(1,P.length)),S=D>=17,w=jt(P.map(x=>a(x.newIn)),D,De+8,fe-12),R=t.gapAfter,M=R?R.ok?kt:Ae:kt;return e.jsxs("svg",{viewBox:`0 0 ${f} ${Ze}`,className:"mr-svg",role:"img","aria-label":"After make-ready",children:[e.jsx(jr,{uid:o}),e.jsx(Sr,{geo:r,poleX:p,minCommIn:t.minCommIn}),e.jsx(kr,{geo:r,poleX:p,uid:o}),R&&e.jsxs("g",{children:[e.jsx("rect",{x:p-40,y:a(R.hiIn),width:80,height:Math.max(0,a(R.loIn)-a(R.hiIn)),fill:M,opacity:.09}),[a(R.hiIn),a(R.loIn)].map((x,T)=>e.jsx("line",{x1:p-40,y1:x,x2:p+40,y2:x,stroke:M,strokeWidth:1,strokeDasharray:"3 2",opacity:.7},T))]}),k.map((x,T)=>{const z=a(x.inches),N=C[T],X=p-46;return e.jsxs("g",{className:"mr-att","data-col":x.column,opacity:l(x.column)?.22:1,...i(x.column),children:[Rt(x.column)&&e.jsx(wt,{poleX:p,y:z,color:x.color,opacity:.45}),e.jsx("line",{x1:p-17,y1:z,x2:p+6,y2:z,stroke:x.color,strokeWidth:2.2,strokeLinecap:"round",opacity:.55}),e.jsx("rect",{x:p-5.2,y:z-1.7,width:10.4,height:3.4,rx:1.5,fill:x.color,opacity:.7}),Math.abs(N-z)>2&&e.jsx("line",{x1:p-18,y1:z,x2:X+4,y2:N-3,stroke:Fe,strokeWidth:.9}),e.jsxs("text",{x:X,y:N,textAnchor:"end",fontFamily:Ie,fontSize:7.8,fill:Ye,children:[x.label," · ",Se(x.inches)]})]},x.column)}),P.map(x=>{const T=p+26+St*(d.get(x.column)??0),z=a(x.oldIn);return e.jsxs("g",{className:"mr-ghost","data-col":x.column,opacity:l(x.column)?.22:1,...i(x.column),children:[e.jsx("line",{x1:p-6,y1:z,x2:p+17,y2:z,stroke:x.hue,strokeWidth:2,strokeLinecap:"round",strokeDasharray:"3 2.5",opacity:.55}),e.jsx("circle",{cx:T,cy:z,r:2.4,fill:Ct,stroke:x.hue,strokeWidth:1.3})]},`ghost-${x.column}`)}),P.map((x,T)=>{const z=p+26+St*(d.get(x.column)??0),N=a(x.newIn),X=a(x.oldIn),U=w[T],Y=x.order<n.step,V=x.order===n.step-1,ee=X<N,se=n.stagger?`${Math.round(s*x.order)}ms`:"0ms",W=n.instant?"none":`transform ${Kt}ms ${qt}`,q=n.instant?"none":`stroke-dashoffset ${Kt}ms ${qt}`,y=Math.abs(x.newIn-x.oldIn),B=l(x.column)?.22:1;return e.jsxs("g",{"data-col":x.column,opacity:B,...i(x.column),children:[e.jsx("line",{x1:z,y1:X,x2:z,y2:N,pathLength:1,stroke:x.hue,strokeWidth:1.8,strokeLinecap:"round",strokeDasharray:1,style:{strokeDashoffset:Y?0:1,transition:q,transitionDelay:se}}),e.jsxs("g",{style:{transform:Y?"translateY(0)":`translateY(${(X-N).toFixed(1)}px)`,transition:W,transitionDelay:se,willChange:"transform"},children:[Rt(x.column)&&e.jsx(wt,{poleX:p,y:N,color:x.hue,opacity:.85}),e.jsx("line",{x1:p-10,y1:N,x2:p+21,y2:N,stroke:x.hue,strokeWidth:V?12:8,strokeLinecap:"round",opacity:Y?V?.32:.16:0,style:{transition:"opacity 300ms, stroke-width 300ms"}}),e.jsx("line",{x1:p-6,y1:N,x2:p+17,y2:N,stroke:x.hue,strokeWidth:2.6,strokeLinecap:"round"}),e.jsx("rect",{x:p-5.2,y:N-1.7,width:10.4,height:3.4,rx:1.5,fill:x.hue}),e.jsx("path",{d:`M ${z} ${N} l -3.4 ${ee?-6:6} l 6.8 0 z`,fill:x.hue})]}),e.jsxs("g",{style:{opacity:Y?1:.3,transition:"opacity 300ms"},children:[Math.abs(U-N)>2&&e.jsx("line",{x1:p+18,y1:N,x2:b-4,y2:U-3,stroke:Fe,strokeWidth:.9}),e.jsxs("text",{x:b,y:U,fontFamily:Ie,fontSize:8.2,fontWeight:700,fill:x.hue,children:[x.att.label," · ",Se(x.newIn),e.jsxs("tspan",{dx:6,fontSize:7.6,children:[ee?"▼":"▲"," ",Se(y)]})]}),S&&e.jsxs("text",{x:b,y:U+9,fontFamily:Ie,fontSize:7,fontStyle:"italic",fill:x.hue,opacity:.72,children:["was ",Se(x.oldIn)]})]})]},x.column)}),R&&(()=>{const x=R.gapIn<0?[`comm ${Se(-R.gapIn)}`,"above power"]:[`${Se(R.gapIn)} gap`,`needs ${Se(R.neededIn)}`],T=Math.min(62,4.4*Math.max(...x.map(V=>V.length))+14),z=9.5*x.length+5,N=[...t.after.map(V=>a(V.inches)),...t.moves.map(V=>a(V.oldIn))],X=gn(a(R.hiIn),a(R.loIn),N,z),U=p+18-T,Y=U+T/2;return e.jsxs("g",{children:[e.jsx("rect",{x:U,y:X-z/2,width:T,height:z,rx:5,fill:Ct,stroke:M,strokeWidth:.9}),x.map((V,ee)=>e.jsx("text",{x:Y,y:X-z/2+4+9.5*ee+6.6,textAnchor:"middle",fontFamily:Ie,fontSize:7.2,fontWeight:700,fill:M,children:V},V))]})})()]})}const Cn="Clear2Attach Report";function wn(t){return t.replace(/\.[A-Za-z0-9]+$/,"").replace(/[_-]+/g," ").replace(/\s+/g," ").trim()||Cn}function Rn(t,r){const o=new Map;for(let n=0;n<t;n++){const s=r(n),l=JSON.stringify(s??null),i=o.get(l);i?i.row_indices.push(n):o.set(l,{config:s??null,row_indices:[n]})}return[...o.values()]}function _n(t){const r={};
1return t.mrResultByPoleId&&t.poles.forEach((o,n)=>{const s=t.mrResultByPoleId?.(o.Pole_ID);s&&(r[n]=s)}),{title:t.title.trim(),subtitle:t.subtitle.trim()||null,csv_filename:t.csvFilename,available_columns:t.availableColumns,rows:t.poles.map(o=>({...o})),config_buckets:Rn(t.poles.length,o=>t.resolveConfigForPole(t.poles[o].Pole_ID)),formats:t.formats,mr_results:r,spotlight_count:Math.max(0,Math.min(4,t.spotlightCount??3))}}const ut={fontSize:10,fontWeight:600,color:"var(--text-secondary)",display:"block",marginBottom:4},Gt={width:"100%",padding:"7px 9px",borderRadius:7,border:"1px solid var(--border-color)",background:"var(--input-bg, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:10};function pt(t){return e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 11px",borderRadius:8,cursor:t.disabled?"default":"pointer",border:`1px solid ${t.checked?"color-mix(in srgb, var(--color-brand) 45%, var(--border-color))":"var(--border-color)"}`,background:t.checked?"color-mix(in srgb, var(--color-brand) 7%, var(--card-bg))":"transparent",opacity:t.disabled?.55:1,marginBottom:8,transition:"border-color 0.12s, background 0.12s"},children:[e.jsx("input",{type:"checkbox",checked:t.checked,disabled:t.disabled,onChange:t.onToggle,style:{marginTop:2,accentColor:"var(--color-brand)",width:13,height:13,flexShrink:0}}),e.jsxs("span",{style:{display:"flex",alignItems:"flex-start",gap:8,minWidth:0},children:[e.jsx("span",{style:{color:"var(--color-brand)",display:"flex",marginTop:1},children:t.icon}),e.jsxs("span",{children:[e.jsx("span",{style:{display:"block",fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t.title}),e.jsx("span",{style:{display:"block",fontSize:10,color:"var(--text-muted)",marginTop:1},children:t.detail})]})]})]})}function In({open:t,onClose:r,resolveConfigForPole:o,onExportCsv:n}){const s=v(W=>W.csvFilename),[l,i]=g.useState(!0),[a,f]=g.useState(!1),[d,b]=g.useState(!1),[p,j]=g.useState(""),[k,C]=g.useState(""),[P,D]=g.useState(3),[S,w]=g.useState(null),[R,M]=g.useState(!1),[x,T]=g.useState(null),z=g.useRef(null),[N,X]=g.useState(t);if(t!==N&&(X(t),t&&(i(!0),f(!1),b(!1),j(wn(s)),C(""),D(3),w(null),T(null))),!t)return null;const U=a||d,Y=(l||U)&&(!U||!!p.trim()),V=async()=>{if(T(null),l&&n(),!U){r();return}M(!0);const W=new AbortController;z.current=W;try{await Pe.getState().loadConfig();const q=v.getState(),y=[...a?["pdf"]:[],...d?["html"]:[]],B=_n({title:p,subtitle:k,formats:y,csvFilename:q.csvFilename,availableColumns:q.availableColumns,poles:q.poles,resolveConfigForPole:o,spotlightCount:P,mrResultByPoleId:m=>q.results[m]?.mrResult??null});await eo(B,W.signal,w),r()}catch(q){q.name!=="AbortError"&&T(q instanceof Error?q.message:String(q))}finally{M(!1),z.current=null}},ee=()=>{z.current?.abort()},se=S?Xr[S.phase??""]??"Working":"Starting";return e.jsx("div",{style:{position:"fixed",inset:0,zIndex:60,background:"rgba(15,33,56,0.45)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:r,children:e.jsxs("div",{style:{width:440,borderRadius:12,background:"var(--card-bg)",border:"1px solid var(--border-color)",padding:18},onClick:W=>W.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(ht,{size:15,style:{color:"var(--color-brand)"}}),e.jsx("span",{style:{fontSize:13,fontWeight:700,color:"var(--text-primary)",flex:1},children:"Export results"}),e.jsx("button",{onClick:r,style:{border:"none",background:"transparent",cursor:"pointer",color:"var(--text-muted)",display:"flex",padding:2},children:e.jsx(ze,{size:13})})]}),!R&&e.jsxs(e.Fragment,{children:[e.jsx(pt,{icon:e.jsx(Ao,{size:13}),title:"Results CSV",detail:"Your data with compliance status, violations, and make-ready columns",checked:l,onToggle:()=>i(W=>!W)}),e.jsx(pt,{icon:e.jsx(gr,{size:13}),title:"Compliance report (PDF)",detail:"Print-ready analysis: summary, violations, map, and make-ready plan",checked:a,onToggle:()=>f(W=>!W)}),e.jsx(pt,{icon:e.jsx(jo,{size:13}),title:"Compliance report (HTML)",detail:"The same report as a single self
1-contained web page",checked:d,onToggle:()=>b(W=>!W)}),U&&e.jsxs("div",{className:"animate-fade-in",style:{marginTop:4},children:[e.jsx("label",{style:ut,children:"Report title"}),e.jsx("input",{value:p,onChange:W=>j(W.target.value),maxLength:120,style:Gt}),e.jsx("label",{style:ut,children:"Subtitle (optional, shown under the title on the cover)"}),e.jsx("input",{value:k,onChange:W=>C(W.target.value),maxLength:160,placeholder:"e.g. Distribution circuit survey",style:Gt}),e.jsx("label",{style:ut,children:"Spotlight pole examples"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:14},children:[e.jsx("select",{value:P,onChange:W=>D(Number(W.target.value)),style:{padding:"6px 9px",borderRadius:7,border:"1px solid var(--border-color)",background:"var(--input-bg, transparent)",color:"var(--text-primary)",fontSize:12},children:[0,1,2,3,4].map(W=>e.jsx("option",{value:W,children:W},W))}),e.jsx("span",{style:{fontSize:10,color:"var(--text-muted)"},children:"Failing poles drawn before and after make-ready, worst first"})]})]})]}),R&&e.jsxs("div",{style:{marginBottom:14},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(Me,{size:13,className:"animate-spin",style:{color:"var(--color-brand)"}}),e.jsx("span",{style:{fontSize:12,color:"var(--text-primary)",fontWeight:600},children:se}),S&&S.total_items!=null&&S.phase!=="rendering"&&e.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)"},children:[S.done_items," of ",S.total_items," assets"]})]}),e.jsx("div",{style:{height:4,background:"var(--hover-bg)",borderRadius:99,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${S?.progress_pct??0}%`,background:"var(--color-brand)",transition:"width 0.3s ease",borderRadius:99}})}),e.jsx("p",{style:{fontSize:10,color:"var(--text-muted)",marginTop:8},children:"You can close this and keep working. Generation continues in the background and the files download when ready. Track it under Background Activity."})]}),x&&e.jsx("p",{style:{fontSize:11,color:"var(--color-danger)",marginBottom:10},children:x}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:R?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:ee,style:{padding:"7px 14px",borderRadius:7,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontWeight:600,cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:r,style:{padding:"7px 14px",borderRadius:7,border:"none",background:"var(--color-brand)",color:"white",fontSize:11,fontWeight:700,cursor:"pointer"},children:"Continue in background"})]}):e.jsxs("button",{onClick:V,disabled:!Y,style:{padding:"7px 14px",borderRadius:7,border:"none",background:"var(--color-brand)",color:"white",fontSize:11,fontWeight:700,cursor:Y?"pointer":"not-allowed",opacity:Y?1:.6,display:"flex",alignItems:"center",gap:5},children:[e.jsx(ht,{size:11})," Export selected"]})})]})})}function Pn(t,{mappingStarted:r,poleCount:o}){return{block:o>0&&t.matchRatio<Wr&&!r,warn:Object.keys(t.csvOnly).length>0}}const zn=8;function Mn({insight:t,rows:r,onManual:o,onApply:n}){const[s,l]=g.useState(!1),[i,a]=g.useState(null),[f,d]=g.useState(null),[b,p]=g.useState(null),[j,k]=g.useState(!1),C=g.useRef(null),P=tr(s);g.useEffect(()=>{be.c2aMappingAvailable().then(M=>{d(M.available),M.available||p("provider")}).catch(M=>{d(!1);const x=M instanceof Error?M.status:void 0;p(Fr(x))})},[]),g.useEffect(()=>()=>C.current?.abort(),[]);const D=async()=>{const M=new AbortController;C.current=M,l(!0),a(null);try{const x=await be.suggestC2AMapping(Or(t,r),M.signal);n(x.config,x.unplaced,x.extra_group_names)}catch(x){M.signal.aborted||a(x instanceof Error?x.message:"The mapping could not be completed.")}finally{l(!1)}},S=Object.keys(t.csvOnly).sort(),w=j?S:S.slice(0,zn),R=S.length-w.length;return e.jsxs("div",{style:{maxWidth:620,margin:"48px auto",textAlign:"center"},children:[e.jsx("h2",{style:{fontSize:16,fontWeight:700,color:"var(--text-primary)"},children:"This file does not match your attachment list"}),e.jsxs("p",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:8},children:[Math.round(t.matchRatio*100),"% of the ",t.heightBearing.length," attachment columns in this CSV match a wire group. Running compliance now would check only those and report the rest as clear."]}),S.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:14,marginBottom:0},children:"These attachment columns have no wire-group mapping and would be skipped:"}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,justifyContent:"center",marginTop:8},children:[w.map(M=>e.jsx("span",{style:{padding:"1px 8px",borderRadius:999,fontSize:10,background:"var(--hover-bg)",color:"var(--text-secondary)",border:"1px solid var(--border-color)"},children:M},M)),R>0&&e.jsxs("button",{onClick:()=>k(!0),style:{padding:"1px 8px",borderRadius:999,fontSize:10,background:"transparent",color:"var(--text-muted)",border:"1px dashed var(--border-color)",cursor:"pointer"},children:["+",R," more"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:10,justifyContent:"center",marginTop:20},children:[e.jsxs("button",{onClick:o,disabled:s,style:{padding:"9px 16px",borderRadius:8,fontSize:12,fontWeight:700,border:"1px solid var(--border-color)",background:"var(--card-bg)",color:"var(--text-primary)",cursor:s?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:6},children:[e.jsx(To,{size:13})," Map manually"]}),f!==!1&&e.jsxs("button",{onClick:D,disabled:s||f===null,style:{padding:"9px 16px",borderRadius:8,fontSize:12,fontWeight:700,border:"1px solid color-mix(in srgb, var(--color-brand) 40%, var(--border-color))",background:"color-mix(in srgb, var(--color-brand) 15%, var(--card-bg))",color:"var(--color-brand)",cursor:s||f===null?"not-allowed":"pointer",opacity:f===null?.6:1,display:"flex",alignItems:"center",gap:6},children:[s||f===null?e.jsx(Me,{size:13,className:"animate-spin"}):e.jsx(So,{size:13}),s?"Mapping...":f===null?"Checking AI...":"Suggest with AI"]})]}),s&&e.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:10},children:["Mapping... ",P,"s",P>=10?" - large files can take a minute":""," ",e.jsx("button",{onClick:()=>C.current?.abort(),style:{color:"var(--text-muted)",background:"none",border:"none",padding:0,cursor:"pointer",textDecoration:"underline",fontSize:11},onMouseEnter:M=>{M.currentTarget.style.color="var(--color-danger)"},onMouseLeave:M=>{M.currentTarget.style.color="var(--text-muted)"},children:"Cancel"})]}),f===!1&&e.jsx("p",{style:{fontSize:11,color:"var(--text-muted)",marginTop:10},children:$r(b)}),i&&e.jsx("p",{style:{fontSize:11,color:"var(--color-danger)",marginTop:10},children:i})]})}const Cr=Br;function Zt(t,r,o){let n=0;for(const s of r)rr(s)===o&&Cr(t[s])&&n++;return n}function Tn(t,r){const o=(t?.wire_groups??[]).find(n=>n.id===r);return new Set(o?.wire_types??[])}function En(t,r,o,n){switch(t.kind){case"has_attachment":{const s=Zt(r,o,t.base)>0;return t.negate?!s:s}case"has_group":{const s=Tn(n,t.groupId),l=o.some(i=>s.has(rr(i))&&Cr(r[i]));return t.negate?!l:l}case"count_attachment":{const s=Zt(r,o,t.base);return t.op===">="?s>=t.n:t.op==="<="?s<=t.n:s===t.n}}}function An(t,r,o,n){const s=t.when;if(!s||!s.conditions||s.conditions.length===0)return!0;const l=s.conditions.map(i=>En(i,r,o,n));return s.match==="any"?l.some(Boolean):l.every(Boolean)}function Dn(t,r,o){const n=t?.rules??[];return n.some(s=>s.when&&s.when.conditions?.length)?{...t,rules:n.filter(s=>An(s,r,o,t))}:t}function Ln(t){const{poleId:r,pole:o,perPoleConfigs:n,availableColumns:s,regions:l,regionConfigs:i,batchConfigs:a,mappingConfig:f,projectConfig:d}=t,b=n[r];if(b)return b;if(o&&o.Latitude&&o.Longitude){const j=parseFloat(o.Latitude),k=parseFloat(o.Longitude);if(!isNaN(j)&&!isNaN(k)){for(const C of l)if(or(j,k,C.coordinates)&&i[C.id])return i[C.id]}}const p=o?rt(o):r.includes("_")?r.split("_")[0]:null;return p&&a[p]?a[p]:f??d}function wr(t){const r=Ln(t);return!r||!t.pole?r:Dn(r,t.pole,t.availableColumns??[])}function Nn(t,r,o,n=null){if(!t)return{start:!1,screen:"none"};if(t.nonce===r)return{start:!1,screen:"none"};if(t.nonce===n)return{start:!1,screen:"none"};if(o.req?.nonce===t.nonce){if(o.status==="loading")return{start:!1,screen:"loading"};if(o.status==="error")return{start:!1,screen:"error"}}return{start:!0,screen:"loading"}}
1class Ve extends Error{constructor(){super("Canceled."),this.name="C2AOpenAborted"}}async function Wn(t,r,o){const n=await o.acquireLease();try{if(r.aborted)throw new Ve;const{download_url:s}=await o.requestCsv(t,n,r);if(r.aborted)throw new Ve;const l=await o.fetchText(s,r);if(r.aborted)throw new Ve;const{columns:i,rows:a}=pr(l),f=mr(i,a);if(f)throw new Error(f);return{columns:i,rows:a}}finally{try{await o.releaseLease(n)}catch{}}}const Fn={acquireLease:()=>oo(no("c2a")),releaseLease:t=>ro(t),requestCsv:(t,r,o)=>{const n={include_compliance:!1,include_unannotated:t.includeUnannotated},s=t.scope;return s.kind==="batch"?be.exportBatchCsv(s.batchId,n,o,r):s.kind==="circuit"?be.exportCircuitCsv(s.projectId,s.circuitName,n,o,r):be.exportProjectCsv(s.projectId,n,o,r)},fetchText:async(t,r)=>{const o=await fetch(t,{signal:r});if(!o.ok)throw new Error(`Could not download the prepared file (${o.status}).`);return o.text()}};function $n(t,r){if(t instanceof Ve)return"Canceled.";if(t instanceof to)return t.message;if(t instanceof DOMException&&t.name==="AbortError")return"Canceled.";const o=t,n=ko(r);return o?.status===403?/export at '?\w+'? level/i.test(o.message??"")?`Your organization does not allow exporting at ${n} level.`:`You do not have export access to this ${n}.`:o?.message||"The data could not be prepared."}function On(){const t=lr(),r=ir(),o=xr(t.state),n=v(C=>C.openRequestNonce),s=v(C=>C.openState),l=v(C=>C.dismissedOpenNonce),{canCompliance:i}=Je(),a=g.useRef(null),f=g.useRef(null),d=Nn(o,n,s,l),b=g.useCallback(C=>{a.current?.abort();const P=new AbortController;a.current=P;const D=v.getState();if(D.setOpenState({status:"loading",req:C,error:null}),i===!1){D.setOpenState({status:"error",error:"Your account does not have Clear2Attach compliance access."});return}const S=f.current,w=(S?S.catch(()=>{}):Promise.resolve()).then(()=>{if(P.signal.aborted)throw new Ve;return Wn(C,P.signal,Fn)});w.then(({columns:R,rows:M})=>{if(P.signal.aborted)return;const x=v.getState();x.loadRows(Co(C),M,R,{openNonce:C.nonce}),x.setOpenState({status:"idle",req:null,error:null})}).catch(R=>{if(P.signal.aborted)return;const M=v.getState();M.openState.req?.nonce===C.nonce&&M.setOpenState({status:"error",error:$n(R,C)})}),f.current=w.catch(()=>{})},[i]);g.useEffect(()=>{d.start&&o&&i!==null&&b(o)},[o?.nonce,d.start,i]),g.useEffect(()=>()=>{a.current?.abort();const C=v.getState();C.openState.status==="loading"&&C.setOpenState({status:"idle",req:null,error:null})},[]);const p=g.useCallback(()=>{t.key==="default"?r("/dashboard"):r(-1)},[r,t.key]),j=g.useCallback(()=>{a.current?.abort(),v.getState().setOpenState({status:"idle",req:null,error:null}),p()},[p]),k=g.useCallback(()=>{o&&v.getState().setOpenState({status:"idle",req:null,error:null})},[o]);return{screen:d.screen,req:o,error:s.error,cancel:j,retry:k,goBack:p}}function Bn(){const t=lr(),r=ir();return g.useCallback(()=>{const o=xr(t.state);o&&(v.getState().setDismissedOpenNonce(o.nonce),r(t.pathname+t.search,{replace:!0,state:null}))},[t,r])}function Hn({screen:t,req:r,error:o,elapsed:n,onCancel:s,onRetry:l,onGoBack:i}){const a=f=>({padding:"7px 16px",borderRadius:7,fontSize:12,fontWeight:600,cursor:"pointer",border:f?"none":"1px solid var(--border-color)",background:f?"var(--color-brand)":"transparent",color:f?"white":"var(--text-secondary)"});return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full animate-fade-in",style:{padding:"32px 24px",gap:14,textAlign:"center"},...t==="loading"?{role:"status","aria-live":"polite"}:{},children:[t==="loading"?e.jsx(Me,{size:22,className:"animate-spin",style:{color:"var(--color-brand)"}}):e.jsx(bt,{size:22,style:{color:"#e67e22"}}),e.jsx("h2",{style:{fontSize:16,fontWeight:700,color:"var(--text-primary)",margin:0},children:t==="loading"?`Preparing ${r.label}`:`Could not open ${r.label}`}),t==="loading"?e.jsxs(e.Fragment,{children:[typeof r.expectedPoles=="number"&&e.jsxs("p",{style:{fontSize:12,color:"var(--text-secondary)",margin:0},children:[r.expectedPoles," assets"]}),e.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",margin:0},children:[n,"s",n>=10?" - large scopes can take a minute":""]}),e.jsx("button",{type:"button",onClick:s,style:a(!1),children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{fontSize:12,color:"var(--text-secondary)",margin:0,maxWidth:460},children:o}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{type:"button",onClick:i,style:a(!1),children:"Go back"}),e.jsx("button",{type:"button",onClick:l,style:a(!0),children:"Try again"})]})]})]})}function Un(t,r){if(!r)return!0;const o=t.toLowerCase(),n=r.toLowerCase().trim();if(!n)return!0;const s=a=>a.replace(/(^|[^0-9])0+([1-9])/g,"$1$2");if(o.includes(n))return!0;const l=s(o),i=s(n);return!!(l.includes(n)||o.includes(i)||l.includes(i))}function Rr(t,r){const o=r==="UP"?"var(--color-success)":"var(--color-warning)",n=r==="UP"?"▲":"▼";return e.jsxs("span",{style:{color:o,fontFamily:"monospace",fontWeight:700,fontSize:11}
1,children:[n," ",Se(Math.abs(t)*12)]})}const Jt=320,qn=34;function Kn(){const{setCsvData:t}=v(),[r,o]=g.useState(!1),[n,s]=g.useState(null),l=g.useRef(null),{canCompliance:i}=Je(),a=i!==!1,f=async d=>{if(!a){s("Your account does not have Clear2Attach compliance access.");return}if(!d.name.endsWith(".csv")){s("Please upload a .csv file");return}const b=await d.text(),{columns:p,rows:j}=pr(b),k=mr(p,j);if(k){s(k);return}t(d,j,p),s(null)};return e.jsxs("div",{className:"flex flex-col items-center justify-center h-full animate-workspace-in",style:{padding:"32px 24px",gap:32},children:[e.jsxs("div",{className:"animate-section-in",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:12,display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--color-brand) 12%, var(--card-bg))",border:"1px solid color-mix(in srgb, var(--color-brand) 25%, var(--border-color))"},children:e.jsx(io,{size:20,style:{color:"var(--color-brand)"}})}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("h1",{className:"sw-display",style:{fontSize:25,fontWeight:700,color:"var(--text-primary)",lineHeight:1.2},children:"Clear2Attach"}),e.jsx("p",{style:{fontSize:13,marginTop:4,color:"var(--text-muted)",lineHeight:1.5},children:"Batch NESC compliance & make-ready for a full dataset"})]})]}),e.jsxs("div",{className:"animate-section-in",onClick:()=>{a&&l.current?.click()},onDragOver:d=>{a&&(d.preventDefault(),o(!0))},onDragLeave:()=>o(!1),onDrop:d=>{if(d.preventDefault(),o(!1),!a)return;const b=d.dataTransfer.files[0];b&&f(b)},style:{animationDelay:"80ms",width:"100%",maxWidth:460,padding:"40px 32px",borderRadius:16,cursor:a?"pointer":"not-allowed",border:`2px dashed ${r?"var(--color-brand)":"var(--border-color)"}`,background:r?"color-mix(in srgb, var(--color-brand) 5%, var(--card-bg))":"var(--card-bg)",boxShadow:"var(--shadow-card)",transition:"border-color 0.15s, background 0.15s",display:"flex",flexDirection:"column",alignItems:"center",gap:16,opacity:a?1:.55},children:[e.jsx("div",{style:{width:44,height:44,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:r?"color-mix(in srgb, var(--color-brand) 15%, var(--bg-tertiary))":"var(--bg-tertiary)",transition:"background 0.15s"},children:e.jsx(co,{size:20,style:{color:r?"var(--color-brand)":"var(--text-muted)"}})}),e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("p",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",lineHeight:1.4},children:"Drop your compliance CSV here"}),e.jsxs("p",{style:{fontSize:11,marginTop:4,color:"var(--text-muted)",lineHeight:1.5},children:["Same format as HeightIQ output - requires",e.jsx("br",{}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:10.5},children:"Pole_ID"}),","," ",e.jsx("span",{style:{fontFamily:"monospace",fontSize:10.5},children:"Latitude"}),","," ",e.jsx("span",{style:{fontFamily:"monospace",fontSize:10.5},children:"Longitude"})," columns"]})]}),e.jsx("button",{style:{fontSize:12.5,fontWeight:600,padding:"9px 26px",borderRadius:20,background:"linear-gradient(135deg, var(--sky-500) 0%, var(--sky-700) 100%)",color:"white",boxShadow:"0 2px 8px rgba(15,127,196,0.30), inset 0 1px 0 rgba(255,255,255,0.18)",border:"none",cursor:"pointer",outline:"none",minWidth:120,transition:"opacity 0.15s, transform 0.12s"},onMouseEnter:d=>{d.currentTarget.style.opacity="0.85"},onMouseLeave:d=>{d.currentTarget.style.opacity="1"},children:"Browse file"})]}),n&&e.jsx("p",{style:{fontSize:11,color:"var(--color-danger)"},children:n}),!a&&i===!1&&e.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",textAlign:"center",maxWidth:360,lineHeight:1.5},children:"Your account doesn't have Clear2Attach compliance access. Contact your administrator to upload and run checks."}),e.jsx("input",{ref:l,type:"file",accept:".csv",style:{display:"none"},disabled:!a,onChange:d=>{const b=d.target.files?.[0];b&&f(b),d.target.value=""}})]})}const Qt=t=>t>=80?"var(--color-success)":t>=50?"var(--color-warning)":"var(--color-danger)",Xt=(t,r)=>Math.min(Math.round(t),r?100:99);function gt(t,r=0,o=900,n=0){const[s,l]=g.useState(r);return g.useEffect(()=>{const i=window.matchMedia("(prefers-reduced-motion: reduce)").matches;let a=0;const f=performance.now()+n,d=b=>{if(i){l(t);return}const p=Math.min(1,Math.max(0,(b-f)/o));l(r+(t-r)*(1-Math.pow(1-p,3))),p<1&&(a=requestAnimationFrame(d))};return a=requestAnimationFrame(d),()=>cancelAnimationFrame(a)},[t,r,o,n]),s}function ft({label:t,sub:r,delay:o,children:n}){return e.jsxs("div",{className:"flex-1 rounded-lg animate-pop-in",style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",padding:6,animationDelay:`${o}ms`},children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase",style:{color:"var(--text-muted)",letterSpacing:"0.06em"},children:t}),e.jsx("p",{className:"text-[22px] font-bold mt-0.5 font-mono",children:n}),e.jsx("p",{style:{fontSize:9,color:"var(--text-muted)",marginTop:2},children:r})]})}function Yn({passedCount:t,doneCount:r,failedCount:o,impact:n}){const s=r>0?t/r*100:0,l=r>0?(t+n.resolved)/r*100:0,i=t+n.resolved,a=o-n.resolved,f=o-n.solved,d=Xt(s,o===0),b=Xt(l,a<=0),p=b-d,j=gt(l,s,1100,350),k=Math.round(gt(n.resolved,0,900,150)),C=Math.round(gt(n.replacements,0,900,300));return e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsxs(ft,{label:"Pass Rate",delay:110,sub:`${t} of ${r} assets clear today · ${i} of ${r} after make-ready`,children:[e.jsxs("span",{style:{color:Qt(s)},children:[d,"%"]}),e.jsxs("span",{style:{fontSize:14,fontWeight:400,color:"var(--text-muted)"},children:[" ","→"," "]}),e.jsxs("span",{style:{color:Qt(l)},children:[Math.min(Math.round(j),b),"%"]}),p>0&&e.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"var(--color-success)",marginLeft:8,whiteSpace:"nowrap"},children:["+",p," pts"]})]}),e.jsx(ft,{label:"Violations Resolved",delay:150,sub:e.jsxs(e.Fragment,{children:[a," remaining",n.review>0&&` · ${n.review} need${n.review===1?"s":""} review`,f>0&&` · ${f} not solved yet`]}),children:e.jsx("span",{style:{color:"var(--color-success)"},children:k})}),e.jsx(ft,{label:"Replacements",delay:190,sub:n.replacements>0?`pole${n.replacements===1?"":"s"} flagged for replacement`:"no pole replacements needed",children:e.jsx("span",{style:{color:n.replacements>0?"var(--color-danger)":"var(--color-success)"},children:C})})]})}function qe({label:t,value:r,color:o,delay:n}){return e.jsxs("div",{className:"flex-1 rounded-lg animate-pop-in",style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",padding:6,animationDelay:n?`${n}ms`:void 0},children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase",style:{color:"var(--text-muted)",letterSpacing:"0.06em"},children:t}),e.jsx("p",{className:"text-[22px] font-bold mt-0.5 font-mono",style:{color:o??"var(--text-primary)"},children:r})]})}function _r({result:t}){const r=Ge(t.status),[o,n]=g.useState(t.status==="FAIL"||r),s=xt
1(t.status);return e.jsxs("div",{style:{marginBottom:3},children:[e.jsxs("button",{onClick:()=>n(l=>!l),style:{width:"100%",display:"flex",alignItems:"center",gap:5,padding:"3px 0",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",outline:"none"},children:[s?e.jsx(_e,{size:11,style:{color:"var(--color-success)",flexShrink:0}}):e.jsx(Le,{size:11,style:{color:"var(--color-danger)",flexShrink:0}}),e.jsx("span",{className:"text-[10px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:t.rule_name}),t.status==="SKIPPED"?e.jsx("span",{className:"text-[9px]",style:{color:"var(--text-muted)"},children:"skipped"}):r?e.jsx("span",{className:"text-[9px] font-mono",style:{color:"var(--color-warning)"},children:mt}):e.jsx("span",{className:"text-[9px] font-mono",style:{color:s?"var(--color-success)":"var(--color-danger)"},children:t.check_value}),o?e.jsx(ot,{size:9,style:{color:"var(--text-muted)"}}):e.jsx(ar,{size:9,style:{color:"var(--text-muted)"}})]}),o&&e.jsxs("div",{style:{padding:"3px 8px 4px 16px",fontSize:9,lineHeight:1.5,color:"var(--text-muted)"},children:[e.jsx("span",{style:{fontFamily:"monospace"},children:t.compliance_code}),t.threshold&&` · required ${t.threshold}`,t.details&&e.jsx("div",{style:{marginTop:2},children:t.details})]})]})}function Vn({status:t}){const r={PASSED:{bg:"color-mix(in srgb, var(--color-success) 15%, transparent)",text:"var(--color-success)",label:"PASS"},FAIL:{bg:"color-mix(in srgb, var(--color-danger) 15%, transparent)",text:"var(--color-danger)",label:"FAIL"},SKIPPED:{bg:"var(--hover-bg)",text:"var(--text-muted)",label:"Skipped"},pending:{bg:"var(--hover-bg)",text:"var(--text-muted)",label:"-"},running:{bg:"color-mix(in srgb, var(--color-brand) 12%, transparent)",text:"var(--color-brand)",label:"..."},error:{bg:"color-mix(in srgb, var(--color-warning) 15%, transparent)",text:"var(--color-warning)",label:"ERR"}},o=r[t??"pending"]??r.pending;return e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 6px",borderRadius:4,background:o.bg,color:o.text,fontFamily:"monospace",whiteSpace:"nowrap"},children:o.label})}const _t=t=>t?.complianceResult?.compliance_status_existing==="FAIL"&&t.mrResult!=null&&!t.mrResult.pole_needs_replacement&&t.mrResult.final_compliant,er=t=>t?.complianceResult?.compliance_status_existing==="FAIL"&&t.mrResult?.pole_needs_replacement===!0;function Gn({poles:t}){const r=v(u=>u.poles),o=t??r,n=v(u=>u.results),{canMakeReady:s}=Je(),l=s!==!1,i=v(u=>u.selectedPoleId),a=v(u=>u.setSelectedPoleId),f=v(u=>u.setMrSelectedPoleId),d=v(u=>u.resultsFilter),b=v(u=>u.setResultsFilter),[p,j]=g.useState("status"),[k,C]=g.useState("asc"),[P,D]=g.useState(null),S=g.useRef(null),[w,R]=g.useState(0),[M,x]=g.useState(qn),[T,z]=g.useState(0),N=g.useCallback(u=>{if(!u)return;const E=u.getBoundingClientRect().height;E<=0||P&&u.dataset.poleId===P||x(L=>Math.abs(L-E)>.5?E:L)},[P]),X=u=>{p===u?C(E=>E==="asc"?"desc":"asc"):(j(u),C("asc"))},U=o.filter(u=>n[u.Pole_ID]?.complianceResult?.compliance_status_existing==="FAIL").length,Y=o.filter(u=>n[u.Pole_ID]?.complianceResult?.compliance_status_existing==="PASSED").length,V=o.filter(u=>n[u.Pole_ID]?.complianceResult?.compliance_status_existing==="SKIPPED").length,ee=o.filter(u=>n[u.Pole_ID]?.status==="error").length,se=o.filter(u=>_t(n[u.Pole_ID])).length,W=o.filter(u=>er(n[u.Pole_ID])).length,q=d==="error"&&ee===0||d==="skipped"&&V===0||d==="mr_resolved"&&se===0||d==="mr_replacement"&&W===0?"all":d,y=g.useMemo(()=>o.filter(u=>{const E=n[u.Pole_ID];return q==="failed"?E?.complianceResult?.compliance_status_existing==="FAIL":q==="passed"?E?.complianceResult?.compliance_status_existing==="PASSED":q==="skipped"?E?.complianceResult?.compliance_status_existing==="SKIPPED":q==="error"?E?.status==="error":q==="mr_resolved"?_t(E):q==="mr_replacement"?er(E):!0}),[o,n,q]),B=g.useMemo(()=>[...y].sort((u,E)=>{const L=n[u.Pole_ID],Z=n[E.Pole_ID];let le=0;if(p==="pole_id")le=u.Pole_ID.localeCompare(E.Pole_ID);else if(p==="status"){const oe=O=>O?.complianceResult?.compliance_status_existing==="FAIL"?0:O?.status==="error"?1:O?.complianceResult?.compliance_status_existing==="PASSED"?2:O?.complianceResult?.compliance_status_existing==="SKIPPED"?3:O?.status==="running"?4:5;le=oe(L)-oe(Z)}else if(p==="fails"){const oe=O=>O?.complianceResult?.rule_results_existing.filter(xe=>xe.status==="FAIL").length??0;le=oe(Z)-oe(L)}else if(p==="mr"){const oe=O=>O?.mrResult?O.mrResult.final_compliant?1:0:2;le=oe(L)-oe(Z)}return k==="asc"?le:-le}),[y,p,k,n]),m=g.useMemo(()=>P?B.findIndex(u=>u.Pole_ID===P):-1,[B,P]),A=g.useMemo(()=>
1Wo({scrollTop:w,viewportHeight:Jt,rowHeight:M,count:B.length,expandedIndex:m>=0?m:null,expandedExtra:T}),[w,M,B.length,m,T]),H=g.useMemo(()=>B.slice(A.startIndex,A.endIndex),[B,A.startIndex,A.endIndex]);g.useEffect(()=>{if(m<0){z(0);return}const u=S.current?.querySelector('[data-expanded="true"]');z(u?u.getBoundingClientRect().height:0)},[m,P,n]);const F=({k:u})=>p!==u?e.jsx(Io,{size:10,style:{color:"var(--text-muted)",opacity:.5}}):k==="asc"?e.jsx(Po,{size:10,style:{color:"var(--color-brand)"}}):e.jsx(zo,{size:10,style:{color:"var(--color-brand)"}}),ae=u=>{a(u===i?null:u),D(u===P?null:u)},G=(u,E)=>{E.stopPropagation(),f(u),document.getElementById("mr-section")?.scrollIntoView({behavior:"smooth",block:"start"})};if(o.length===0)return null;const re=[["all",`All (${o.length})`],["failed",`Failed (${U})`],["passed",`Passed (${Y})`]];return V>0&&re.push(["skipped",`Skipped (${V})`]),ee>0&&re.push(["error",`Errors (${ee})`]),se>0&&re.push(["mr_resolved",`Resolved (${se})`]),W>0&&re.push(["mr_replacement",`Replacements (${W})`]),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8,flexWrap:"wrap"},children:[e.jsx(_o,{size:12,style:{color:"var(--text-muted)",flexShrink:0}}),re.map(([u,E])=>e.jsx("button",{onClick:()=>b(u),style:{padding:"3px 10px",borderRadius:6,fontSize:10,fontWeight:600,border:"none",cursor:"pointer",outline:"none",background:q===u?"var(--color-brand)":"var(--hover-bg)",color:q===u?"white":"var(--text-secondary)",transition:"all 0.12s"},onMouseEnter:L=>{q!==u&&(L.currentTarget.style.background="var(--bg-tertiary)")},onMouseLeave:L=>{q!==u&&(L.currentTarget.style.background="var(--hover-bg)")},children:E},u)),e.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--text-muted)"},children:[B.length," shown"]})]}),e.jsxs("div",{style:{border:"1px solid var(--border-color)",borderRadius:10,overflow:"hidden",background:"var(--card-bg)"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr 120px 100px 80px",padding:"7px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-color)"},children:[["status","Status"],["pole_id","Pole ID"],[null,"Rules"],["mr","Make Ready"],[null,""]].map(([u,E],L)=>e.jsxs("div",{onClick:()=>u&&X(u),style:{display:"flex",alignItems:"center",gap:4,cursor:u?"pointer":"default",fontSize:9.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",userSelect:"none"},children:[E,u&&e.jsx(F,{k:u})]},L))}),e.jsxs("div",{ref:S,onScroll:u=>R(u.target.scrollTop),style:{height:Jt,overflowY:"auto",scrollbarWidth:"thin"},children:[B.length===0&&e.jsx("div",{style:{padding:"20px 16px",textAlign:"center",fontSize:11,color:"var(--text-muted)"},children:"No results match the current filter."}),e.jsx("div",{style:{height:A.totalHeight,position:"relative"},children:e.jsx("div",{style:{transform:`translateY(${A.offsetTop}px)`},children:H.map((u,E)=>{const L=A.startIndex+E,Z=n[u.Pole_ID],le=Z?.complianceResult,oe=Z?.mrResult,O=u.Pole_ID===i,xe=u.Pole_ID===P,we=le?.compliance_status_existing??Z?.status,Te=le?.rule_results_existing.filter(J=>J.status==="FAIL")??[],$e=le?.rule_results_existing.filter(J=>J.status==="PASSED")??[];let Ce="-",ve="var(--text-muted)";return oe?oe.final_compliant?(Ce="✓ Resolved",ve="var(--color-success)"):oe.actions.length>0?(Ce=`${oe.actions.length} action${oe.actions.length>1?"s":""}`,ve="var(--color-warning)"):oe.pole_needs_replacement&&(Ce="Replacement",ve="var(--color-danger)"):Z?.status==="running"&&(Ce="...",ve="var(--color-brand)"),e.jsxs("div",{ref:E===0?N:void 0,"data-pole-id":u.Pole_ID,style:{borderBottom:L<B.length-1?"1px solid var(--border-subtle)":"none",background:O?"var(--active-bg)":L%2===0?"transparent":"var(--bg-primary)",cursor:"pointer",transition:"background 0.12s"},onMouseEnter:J=>{O||(J.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:J=>{O||(J.currentTarget.style.background=L%2===0?"transparent":"var(--bg-primary)")},children:[e.jsxs("div",{onClick:()=>ae(u.Pole_ID),style:{display:"grid",gridTemplateColumns:"100px 1fr 120px 100px 80px",padding:"8px 12px",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5}
1,children:[Z?.status==="running"?e.jsx(Me,{size:10,className:"animate-spin",style:{color:"var(--color-brand)",flexShrink:0}}):e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",flexShrink:0,background:we==="PASSED"?"var(--color-success)":we==="FAIL"?"var(--color-danger)":we==="error"?"var(--color-warning)":"var(--text-muted)"}}),e.jsx(Vn,{status:we})]}),e.jsx("span",{style:{fontSize:11,fontFamily:"monospace",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:u.Pole_ID}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[le?e.jsxs(e.Fragment,{children:[Te.length>0&&e.jsxs("span",{style:{fontSize:9.5,color:"var(--color-danger)",fontWeight:700,fontFamily:"monospace"},children:[Te.length," fail"]}),e.jsxs("span",{style:{fontSize:9.5,color:"var(--text-muted)",fontFamily:"monospace"},children:[$e.length," pass"]})]}):e.jsx("span",{style:{fontSize:9.5,color:"var(--text-muted)"},children:"-"}),xe?e.jsx(fr,{size:10,style:{color:"var(--text-muted)",marginLeft:"auto"}}):e.jsx(ot,{size:10,style:{color:"var(--text-muted)",marginLeft:"auto"}})]}),e.jsx("span",{style:{fontSize:10,fontWeight:600,color:ve},children:Ce}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:l&&le?.compliance_status_existing==="FAIL"&&e.jsx("button",{onClick:J=>G(u.Pole_ID,J),title:"Jump to Make Ready",style:{fontSize:9,fontWeight:600,padding:"2px 6px",borderRadius:4,border:"1px solid color-mix(in srgb, var(--color-brand) 40%, var(--border-color))",background:"color-mix(in srgb, var(--color-brand) 8%, transparent)",color:"var(--color-brand)",cursor:"pointer",outline:"none",transition:"background 0.12s, border-color 0.12s"},onMouseEnter:J=>{J.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 18%, transparent)",J.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 65%, transparent)"},onMouseLeave:J=>{J.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 8%, transparent)",J.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 40%, var(--border-color))"},children:"MR ↓"})})]}),xe&&le&&e.jsxs("div",{"data-expanded":"true",style:{padding:"6px 12px 10px 24px",borderTop:"1px solid var(--border-subtle)",background:"var(--bg-primary)"},onClick:J=>J.stopPropagation(),children:[le.rule_results_existing.map(J=>e.jsx(_r,{result:J},J.rule_id)),Z?.error&&e.jsx("p",{style:{fontSize:9.5,color:"var(--color-warning)",marginTop:4},children:Z.error})]})]},u.Pole_ID)})})})]})]})]})}function Zn({poleId:t}){const r=v(a=>a.results[t]),o=r?.mrResult,n=r?.complianceResult;if(!o&&!n)return e.jsx("div",{style:{padding:24,textAlign:"center",fontSize:11,color:"var(--text-muted)"},children:"Run compliance and make-ready to see comparison."});if(!o){const a=n?.compliance_status_existing==="SKIPPED";if((n?.compliance_status_existing==="PASSED"||a)&&n){const d=n.rule_results_existing,b=d.filter(j=>j.status==="PASSED").length,p=d.filter(j=>j.status==="SKIPPED").length;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",marginBottom:12,borderRadius:8,background:a?"var(--hover-bg)":"color-mix(in srgb, var(--color-success) 10%, var(--card-bg))",border:a?"1px solid var(--border-color)":"1px solid color-mix(in srgb, var(--color-success) 30%, var(--border-color))"},children:[a?e.jsx(xo,{size:14,style:{color:"var(--text-muted)",flexShrink:0}}):e.jsx(_e,{size:14,style:{color:"var(--color-success)",flexShrink:0}}),e.jsx("span",{style:{fontSize:11,fontWeight:600,color:a?"var(--text-muted)":"var(--text-primary)"},children:a?"No attachments to assess.":"All rules passed - this asset is already compliant"}),!a&&e.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)",marginLeft:"auto"},children:[b," passed",p>0?` · ${p} skipped`:""]})]}),!a&&e.jsxs("div",{style:{border:"1px solid var(--border-color)",borderRadius:10,overflow:"hidden"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 80px 80px 44px",padding:"7px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-color)"},children:["Rule","Measured","Required",""].map((j,k)=>e.jsx("span",{style:{fontSize:9.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",textAlign:k>0?"center":"left"},children:j},k))}),d.map((j,k)=>{const C=j.status==="SKIPPED";return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 80px 80px 44px",padding:"8px 12px",alignItems:"center",borderBottom:k<d.length-1?"1px solid var(--border-subtle)":"none",background:C?"transparent":"color-mix(in srgb, var(--color-success) 3%, transparent)"},children:[e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:10,fontWeight:600,color:"var(--text-primary)"},children:j.rule_name}),e.jsx("p",{style:{fontSize:9,fontFamily:"monospace",color:"var(--text-muted)",marginTop:1},children:j.compliance_code})]}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",textAlign:"center",color:C?"var(--text-muted)":"var(--color-success)",fontWeight:C?400:600},children:C?"-":tt(j.check_value)}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",textAlign:"center",color:"var(--text-muted)"},children:C?"-":tt(j.threshold)}),e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:C?e.jsx("span",{style:{fontSize:9,color:"var(--text-muted)"},children:"skip"}):e.jsx(_e,{size:12,style:{color:"var(--color-success)"}})})]},j.rule_id)})]}),!a&&e.jsx("p",{style:{fontSize:9,color:"var(--text-muted)",opacity:.6,fontStyle:"italic",marginTop:6,paddingLeft:2},children:"Measured = actual clearance · Required = minimum required clearance"})]})}return e.jsxs("div",{style:{padding:"12px 0"},children:[e.jsx("p",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10},children:"Make-ready not yet generated. Showing current compliance results."}),n?.rule_results_existing.map(d=>e.jsx(_r,{result:d},d.rule_id))]})}const s=o.initial_rule_results,l=o.final_rule_results,i=o.actions;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",marginBottom:12,borderRadius:8,background:o.final_compliant?"color-mix(in srgb, var(--color-success) 10%, var(--card-bg))":"color-mix(in srgb, var(--color-danger) 10%, var(--card-bg))",border:`1px solid color-mix(in srgb, ${o.final_compliant?"var(--color-success)":"var(--color-danger)"} 30%, var(--border-color))`},children:[o.final_compliant?e.jsx(_e,{size:14,style:{color:"var(--color-success)",flexShrink:0}}):e.jsx(Le,{size:14,style:{color:"var(--color-danger)",flexShrink:0}}),e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)"},children:o.final_compliant?`All violations resolved with ${i.length} change${i.length!==1?"s":""}`:dr(o)?"Rules could not be evaluated for this asset - check the rule configuration":o.pole_needs_replacement?"Asset replacement required - violations cannot be resolved by repositioning":`${i.length} action${i.length!==1?"s":""} proposed - ${l.filter(a=>a.status==="FAIL").length} violation${l.filter(a=>a.status==="FAIL").length!==1?"s":""} remain`})]}),e.jsxs("div",{style:{border:"1px solid var(--border-color)",borderRadius:10,overflow:"hidden"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 88px 60px 88px 60px",padding:"7px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-color)"},children:["Rule","Before","Status","After","Status"].map((a,f)=>e.jsx("span",{style:{fontSize:9.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",textAlign:f>0?"center":"left"},children:a},f))}),s.map((a,f)=>{const d=l.find(k=>
1k.rule_id===a.rule_id)??a,b=a.status!==d.status,p=xt(a.status),j=xt(d.status);return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 88px 60px 88px 60px",padding:"8px 12px",borderBottom:f<s.length-1?"1px solid var(--border-subtle)":"none",background:b?"color-mix(in srgb, var(--color-success) 4%, transparent)":"transparent",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:10,fontWeight:600,color:"var(--text-primary)"},children:a.rule_name}),e.jsx("p",{style:{fontSize:9,color:"var(--text-muted)",fontFamily:"monospace"},children:a.compliance_code})]}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",textAlign:"center",color:p?"var(--color-success)":"var(--color-danger)",fontWeight:600},children:a.status==="SKIPPED"?"-":Ge(a.status)?mt:tt(a.check_value)}),e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:a.status==="SKIPPED"?e.jsx("span",{style:{fontSize:9,color:"var(--text-muted)"},children:"skip"}):p?e.jsx(_e,{size:12,style:{color:"var(--color-success)"}}):e.jsx(Le,{size:12,style:{color:"var(--color-danger)"}})}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",textAlign:"center",color:j?"var(--color-success)":"var(--color-danger)",fontWeight:600},children:d.status==="SKIPPED"?"-":Ge(d.status)?mt:tt(d.check_value)}),e.jsx("div",{style:{display:"flex",justifyContent:"center"},children:d.status==="SKIPPED"?e.jsx("span",{style:{fontSize:9,color:"var(--text-muted)"},children:"skip"}):j?e.jsx(_e,{size:12,style:{color:"var(--color-success)"}}):e.jsx(Le,{size:12,style:{color:"var(--color-danger)"}})})]},a.rule_id)})]}),e.jsx("p",{style:{fontSize:9,color:"var(--text-muted)",opacity:.6,fontStyle:"italic",marginTop:6,paddingLeft:2},children:"Before / After = clearance value before and after make-ready"}),o.notes.length>0&&e.jsx("div",{style:{marginTop:10,padding:"8px 10px",borderRadius:6,background:"var(--bg-tertiary)"},children:o.notes.map((a,f)=>e.jsxs("p",{style:{fontSize:10,color:"var(--text-secondary)",lineHeight:1.5},children:["· ",a]},f))}),i.length>0&&e.jsxs("div",{style:{marginTop:12},children:[e.jsx("p",{style:{fontSize:9.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",marginBottom:6},children:"Proposed Changes"}),i.map(a=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,flex:1,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:a.column}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",color:"var(--text-muted)",flexShrink:0},children:a.existing_height}),e.jsx(mo,{size:9,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",fontWeight:700,flexShrink:0,color:a.direction==="UP"?"var(--color-success)":"var(--color-warning)"},children:a.proposed_height}),e.jsx("span",{style:{flexShrink:0},children:Rr(a.delta_ft,a.direction)})]},a.column))]})]})}function Jn({measurementCols:t,hiddenColumns:r,toggleHiddenColumn:o}){const[n,s]=g.useState(""),l=t.filter(i=>i.toLowerCase().includes(n.toLowerCase()));return e.jsxs("div",{style:{padding:"10px 12px"},children:[e.jsx("p",{style:{fontSize:9,color:"var(--text-muted)",marginBottom:8,lineHeight:1.5},children:"Hidden attachments won't appear in Measurements unless they have a Make Ready proposed value."}),e.jsx("input",{value:n,onChange:i=>s(i.target.value),placeholder:"Search columns...",style:{width:"100%",marginBottom:8,fontSize:10,padding:"4px 8px",borderRadius:5,border:"1px solid var(--border-color)",background:"var(--bg-primary)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}),l.length===0&&e.jsx("p",{style:{fontSize:9,color:"var(--text-muted)",fontStyle:"italic"},children:"No columns found."}),l.map(i=>{const a=r.includes(i);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:7,padding:"3px 0",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:a,onChange:()=>o(i),style:{width:11,height:11}}
1),e.jsx("span",{style:{fontSize:10,color:a?"var(--text-muted)":"var(--text-primary)",textDecoration:a?"line-through":"none"},children:i})]},i)})]})}function Qn({poleId:t,allAvailableCols:r,onClose:o,isClosing:n=!1}){const[s,l]=g.useState("hide"),[i,a]=g.useState(""),f=["hide","rules"],d=u=>{const E=f.indexOf(s),L=f.indexOf(u);a(L>E?"animate-tab-from-right":"animate-tab-from-left"),l(u)},[b,p]=g.useState(!1),[j,k]=g.useState("idle"),{canCompliance:C,canMakeReady:P}=Je(),D=C!==!1,S=P!==!1,w=D||S,R=D&&S?"Run Compliance & MR":S?"Generate Make Ready":"Run Compliance",M=v(u=>u.hiddenColumns),x=v(u=>u.toggleHiddenColumn),T=v(u=>u.perPoleConfigs),z=v(u=>u.setPerPoleConfig),N=v(u=>u.clearPerPoleConfig),X=v(u=>u.availableColumns),U=v(u=>u.batchConfigs),Y=v(u=>u.mappingConfig),V=Pe(u=>u.config),se=v(u=>u.poles).find(u=>u.Pole_ID===t),W=se?rt(se):null,q=W&&U[W]?U[W]:Y??V,y=!!T[t],B={version:"1.0",created_at:"",updated_at:"",wire_groups:[],rules:[],make_ready_settings:{pole_tip_clearance_in:0,tolerance_in:0,move_increment_in:0}},[m,A]=g.useState(()=>{const u=T[t];return u?JSON.parse(JSON.stringify(u)):q?JSON.parse(JSON.stringify(q)):B}),[H,F]=g.useState([]);g.useEffect(()=>{be.getAttachmentsConfig().then(u=>F(u.attachment_types)).catch(()=>{})},[]);const ae=r.filter(u=>!Ir.has(u.toLowerCase())),G=()=>{N(t),A(q?JSON.parse(JSON.stringify(q)):B),k("idle")},re=async()=>{if(!D&&!S)return;p(!0),k("idle"),z(t,m);const u=v.getState(),E=u.poles.find(L=>L.Pole_ID===t);if(!E){p(!1);return}u.upsertResult(t,{status:"running",complianceResult:null,mrResult:null});try{if(D){const L=await be.checkCompliance({pole:{...E},config_override:m,available_columns:u.availableColumns});if(u.upsertResult(t,{complianceResult:L,status:"done",mrResult:null}),S&&L.compliance_status_existing==="FAIL"){const Z=await be.suggestMakeReady({pole:{...E},config_override:m,available_columns:u.availableColumns});u.upsertResult(t,{mrResult:Z})}}else if(S){const L=await be.suggestMakeReady({pole:{...E},config_override:m,available_columns:u.availableColumns});u.upsertResult(t,{mrResult:L,status:"done"})}k("done")}catch(L){const Z=L instanceof Error?L.message:String(L);u.upsertResult(t,{status:"error",error:Z}),k("error")}p(!1)};return e.jsxs("div",{className:n?"animate-slide-to-right":"animate-slide-from-right",style:{position:"absolute",inset:0,zIndex:10,background:"var(--card-bg)",display:"flex",flexDirection:"column",borderLeft:"1px solid var(--border-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",flexShrink:0},children:[e.jsx("button",{onClick:o,style:{padding:3,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",display:"flex",transition:"color 0.12s"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-muted)"},children:e.jsx(ze,{size:12})}),e.jsx("span",{style:{fontSize:11,fontWeight:700,fontFamily:"monospace",color:"var(--color-brand)",flex:1},children:t}),y&&e.jsx("span",{style:{fontSize:8,padding:"2px 6px",borderRadius:4,background:"var(--color-brand)",color:"white",fontWeight:700},children:"Custom"}),j==="done"&&e.jsx("span",{style:{fontSize:9,color:"var(--color-success)",fontWeight:600},children:"✓ Done"}),j==="error"&&e.jsx("span",{style:{fontSize:9,color:"var(--color-danger)",fontWeight:600},children:"✗ Error"})]}),e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--border-color)",flexShrink:0},children:["hide","rules"].map(u=>e.jsx("button",{onClick:()=>d(u),style:{flex:1,padding:"6px 0",fontSize:10,fontWeight:600,border:"none",cursor:"pointer",background:s===u?"var(--card-bg)":"var(--bg-secondary)",color:s===u?"var(--color-brand)":"var(--text-muted)",borderBottom:s===u?"2px solid var(--color-brand)":"2px solid transparent",transition:"color 0.12s, background 0.12s"},onMouseEnter:E=>{s!==u&&(E.currentTarget.style.color="var(--text-primary)")},onMouseLeave:E=>{s!==u&&(E.currentTarget.style.color="var(--text-muted)")},children:u==="hide"?"Hide Attachments":"Rules Config"},u))}),e.jsx("div",{style:{flex:1,overflow:"hidden",position:"relative"},children:e.jsxs("div",{className:i,style:{position:"absolute",inset:0,overflowY:"auto",scrollbarWidth:"thin"},children:[s==="hide"&&e.jsx(Jn,{measurementCols:ae,hiddenColumns:M,toggleHiddenColumn:x}),s==="rules"&&e.jsx(nr,{config:m,onChange:A,allWireTypes:H,availableColumns:X})]},s)}),e.jsxs("div",{style:{padding:"8px 10px",borderTop:"1px solid var(--border-color)",display:"flex",gap:6,flexShrink:0},children:[y&&e.jsx("button",{onClick:G,title:"Reset to batch or project rules",style:{padding:"6px 10px",borderRadius:6,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-muted)",fontSize:10,
1cursor:"pointer",whiteSpace:"nowrap",transition:"color 0.12s, border-color 0.12s"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)",u.currentTarget.style.borderColor="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-muted)",u.currentTarget.style.borderColor="var(--border-color)"},children:W&&U[W]?"Reset to batch":"Reset to project"}),e.jsxs("button",{onClick:re,disabled:b||!w,style:{flex:1,padding:"8px",borderRadius:7,border:"none",background:"var(--color-brand)",color:"white",fontWeight:700,fontSize:11,cursor:b||!w?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,opacity:b||!w?.7:1,transition:"opacity 0.12s, filter 0.12s"},onMouseEnter:u=>{!b&&w&&(u.currentTarget.style.filter="brightness(1.1)")},onMouseLeave:u=>{u.currentTarget.style.filter="none"},title:w?void 0:"No Clear2Attach run access",children:[b?e.jsx(Me,{size:12,className:"animate-spin"}):e.jsx(ur,{size:12}),b?"Running...":R]})]})]})}const Ir=new Set(["pole_id","latitude","lat","longitude","lng","lon","gpslatitude","gpslongitude","source_path","filename","wide_image_path","type","index","order","batch","batch_id","batch_name"]);function Xn({poleId:t}){const r=v(m=>m.results[t]),o=v(m=>m.availableColumns),n=v(m=>m.hiddenColumns),s=v(m=>m.mrOverrides[t]),l=v(m=>m.setMrOverride),i=v(m=>m.clearMrOverride),[a,f]=g.useState({}),[d,b]=g.useState({}),[p,j]=g.useState(null),[k,C]=g.useState(null),P=g.useRef({}),D=r?.row,S=r?.complianceResult,w=r?.mrResult,R=w!=null,M=S!=null;g.useEffect(()=>{f({}),b({}),j(null),C(null),Object.values(P.current).forEach(clearTimeout),P.current={}},[t]),g.useEffect(()=>()=>{Object.values(P.current).forEach(clearTimeout)},[]);const x=g.useCallback(async(m,A)=>{if(D){f(H=>({...H,[m]:"checking"}));try{const H={...D};if(w){const u=v.getState().mrOverrides[t];for(const E of w.actions)E.column!==m&&(H[E.column]=u?.[E.column]??E.proposed_height)}H[m]=A;const F=v.getState(),ae=wr({poleId:t,pole:F.poles.find(u=>u.Pole_ID===t),perPoleConfigs:F.perPoleConfigs,availableColumns:F.availableColumns,regions:F.regions,regionConfigs:F.regionConfigs,batchConfigs:F.batchConfigs,mappingConfig:F.mappingConfig,projectConfig:Pe.getState().config??null}),G=await be.checkCompliance({pole:H,config_override:ae,available_columns:o}),re=G.compliance_status_existing==="SKIPPED"?"PASSED":G.compliance_status_existing;if(f(u=>({...u,[m]:re})),re==="FAIL"){const u=G.rule_results_existing.filter(Z=>Z.status==="FAIL"),E=u.find(Z=>Z.involved_columns?.includes(m))??u[0],L=E?.reason||E?.details||"";b(Z=>({...Z,[m]:L}))}else b(u=>({...u,[m]:""}))}catch{f(H=>({...H,[m]:null}))}}},[D,w,o,t]),T=o.filter(m=>{if(Ir.has(m.toLowerCase()))return!1;const A=D?.[m];if(A===void 0||A===""||A===null)return!1;const H=String(A).trim();return!(!/^[\d]/.test(H)||H.includes("/")||H.includes("\\")||n.includes(m)&&!w?.actions.some(F=>F.column===m))}),z=S?.rule_results_existing??w?.initial_rule_results??[],N=new Map;for(const m of z)if(m.status!=="SKIPPED")for(const A of m.involved_columns??[])m.status==="FAIL"?N.set(A,"failed"):m.status==="PASSED"&&N.get(A)!=="failed"&&N.set(A,"passed");const X=new Map;if(R){for(const m of w.final_rule_results)if(m.status!=="SKIPPED")for(const A of m.involved_columns??[])m.status==="FAIL"?X.set(A,"failed"):m.status==="PASSED"&&X.get(A)!=="failed"&&X.set(A,"passed")}const U=new Map;for(const m of[...N.keys()]){const A=N.get(m);if(!R)U.set(m,A==="failed"?"failed":"passed");else{const H=X.get(m)??A;A==="failed"&&H==="passed"?U.set(m,"fixed"):H==="failed"?U.set(m,"failed"):U.set(m,"passed")}}const Y=new Map(w?.actions.map(m=>[m.column,m])??[]),V=new Map(Pt(w?.actions??[],s).map(m=>[m.column,m])),ee=[...T].sort((m,A)=>{const H=F=>F==="failed"?0:F==="fixed"?1:F==="passed"?2:3;return H(U.get(m))-H(U.get(A))});if(ee.length===0)return e.jsx("div",{style:{padding:24,textAlign:"center",fontSize:11,color:"var(--text-muted)"},children:S?.compliance_status_existing==="SKIPPED"?"No attachments to assess.":"No measurement data available for this pole."});const se=z.filter(m=>m.status==="FAIL"||Ge(m.status)).length,W=z.filter(m=>m.status==="PASSED").length,q=w?.actions.length??0,y=R?w.initial_rule_results.filter(m=>m.status==="FAIL").length-w.final_rule_results.filter(m=>
1m.status==="FAIL").length:0,B=R?"1fr 80px 1fr 96px":"1fr 90px";return e.jsxs("div",{children:[(M||R)&&(()=>{const m=R?[{label:"Attachments Changed",value:q,color:"var(--color-warning)"},{label:"Violations Resolved",value:y,color:"var(--color-success)"},{label:"After Status",value:w.final_compliant?"PASS":"FAIL",color:w.final_compliant?"var(--color-success)":"var(--color-danger)"}]:[{label:"Rules Failed",value:se,color:"var(--color-danger)"},{label:"Rules Passed",value:W,color:"var(--color-success)"},{label:"Status",value:S.compliance_status_existing==="SKIPPED"?"Skipped":S.compliance_status_existing,color:S.compliance_status_existing==="PASSED"?"var(--color-success)":S.compliance_status_existing==="SKIPPED"?"var(--text-muted)":"var(--color-danger)"}];return e.jsx("div",{style:{display:"flex",gap:8,marginBottom:14},children:m.map(({label:A,value:H,color:F})=>e.jsxs("div",{style:{flex:1,padding:"8px 12px",borderRadius:8,background:"var(--card-bg)",border:"1px solid var(--border-color)"},children:[e.jsx("p",{style:{fontSize:9.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)"},children:A}),e.jsx("p",{style:{fontSize:20,fontWeight:700,fontFamily:"monospace",color:F,marginTop:2},children:H})]},A))})})(),e.jsxs("div",{style:{border:"1px solid var(--border-color)",borderRadius:10,overflow:"hidden"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:B,padding:"7px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-color)"},children:(R?["Attachment","Current","Proposed","Change"]:["Attachment","Current"]).map((m,A)=>e.jsx("span",{style:{fontSize:9.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",textAlign:A>0?"center":"left"},children:m},m))}),ee.map((m,A)=>{const H=D?.[m]??"-",F=U.get(m),ae=Y.get(m),G=s?.[m],re=a[m],u=d[m]??"",E=G!==void 0,L=p===m,Z=k===m,le=F==="failed"?"color-mix(in srgb, var(--color-danger) 11%, var(--card-bg))":F==="fixed"?"color-mix(in srgb, var(--color-brand) 10%, var(--card-bg))":F==="passed"?"color-mix(in srgb, var(--color-success) 9%, var(--card-bg))":"transparent",oe=F==="failed"?"3px solid var(--color-danger)":F==="fixed"?"3px solid var(--color-brand)":F==="passed"?"3px solid var(--color-success)":"3px solid transparent";return e.jsxs("div",{onMouseEnter:()=>C(m),onMouseLeave:()=>C(null),style:{display:"grid",gridTemplateColumns:B,padding:"7px 12px",alignItems:"center",borderBottom:A<ee.length-1?"1px solid var(--border-subtle)":"none",background:le,borderLeft:oe},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--text-primary)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",color:"var(--text-secondary)",textAlign:"center"},children:ae?ae.existing_height:String(H)}),R&&(ae?L?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4},children:[e.jsx("input",{autoFocus:!0,value:G??ae.proposed_height,onChange:O=>{const xe=O.target.value;l(t,m,xe),f(we=>({...we,[m]:null})),clearTimeout(P.current[m]),P.current[m]=setTimeout(()=>{xe.trim()&&x(m,xe.trim())},600)},onBlur:()=>{j(null);const O=s?.[m];O!==void 0&&(!O.trim()||O.trim()===ae.proposed_height)&&(i(t,m),f(xe=>({...xe,[m]:null})),b(xe=>({...xe,[m]:""})))},onKeyDown:O=>{O.key==="Escape"&&j(null)},style:{width:72,fontSize:10,fontFamily:"monospace",fontWeight:700,padding:"2px 6px",borderRadius:4,outline:"none",background:"var(--bg-primary)",border:re==="PASSED"?"1px solid var(--color-success)":re==="FAIL"?"1px solid var(--color-danger)":"1px solid var(--border-color)",color:ae.direction==="UP"?"var(--color-success)":"var(--color-warning)"}}),re==="checking"&&e.jsx(Me,{size:11,className:"animate-spin",style:{color:"var(--text-muted)",flexShrink:0}}),re==="PASSED"&&e.jsx(_e,{size:12,style:{color:"var(--color-success)",flexShrink:0}}),re==="FAIL"&&e.jsx(Le,{size:12,style:{color:"var(--color-danger)",flexShrink:0}})]}),re==="FAIL"&&u&&e.jsx("span",{style:{fontSize:8.5,color:"var(--color-danger)",textAlign:"center",maxWidth:140,lineHeight:1.3},children:u})]}):e.jsxs("div",{onClick:()=>j(m),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:1,cursor:"text"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,justifyContent:"center"},children:[e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",fontWeight:700,color:ae.direction==="UP"?"var(--color-success)":"var(--color-warning)"},children:G??ae.proposed_height}),re==="PASSED"&&e.jsx(_e,{size:11,style:{color:"var(--color-success)",flexShrink:0}}),re==="FAIL"&&e.jsx(Le,{size:11,style:{color:"var(--color-danger)",flexShrink:0}}),!re&&Z&&e.jsx(ho,{size:10,style:{color:"var(--text-muted)",flexShrink:0}})]}),re==="FAIL"&&u&&e.jsx("span",{style:{fontSize:8.5,color:"var(--color-danger)",textAlign:"center",maxWidth:140,lineHeight:1.3},title:u,children:u.length>40?u.slice(0,40)+"...":u})]}):e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",color:"var(--text-muted)",textAlign:"center"},children:String(H)})),R&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4},children:[ae?(()=>{const O=V.get(m)??ae;return Rr(O.delta_ft,O.direction)}
1)():e.jsx("span",{style:{fontSize:10,color:"var(--text-muted)"},children:"-"}),ae&&E&&e.jsx("button",{onClick:()=>{i(t,m),f(O=>({...O,[m]:null})),b(O=>({...O,[m]:""}))},title:"Reset to suggested value",style:{background:"none",border:"none",cursor:"pointer",padding:2,color:"var(--text-muted)",lineHeight:1,flexShrink:0},onMouseEnter:O=>{O.currentTarget.style.color="var(--color-brand)"},onMouseLeave:O=>{O.currentTarget.style.color="var(--text-muted)"},children:e.jsx(Gr,{size:11})})]})]},m)})]}),(M||R)&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:10,marginTop:10,paddingTop:8,borderTop:"1px solid var(--border-subtle)"},children:[{bg:"color-mix(in srgb, var(--color-danger) 11%, var(--card-bg))",border:"var(--color-danger)",icon:e.jsx(Le,{size:9,style:{color:"var(--color-danger)"}}),label:"Still failing"},...R?[{bg:"color-mix(in srgb, var(--color-brand) 10%, var(--card-bg))",border:"var(--color-brand)",icon:e.jsx(_e,{size:9,style:{color:"var(--color-brand)"}}),label:"Resolved by MR"}]:[],{bg:"color-mix(in srgb, var(--color-success) 9%, var(--card-bg))",border:"var(--color-success)",icon:e.jsx(_e,{size:9,style:{color:"var(--color-success)"}}),label:"Compliant"},{bg:"transparent",border:"var(--border-subtle)",icon:e.jsx("span",{style:{fontSize:8,color:"var(--text-muted)",lineHeight:1},children:"-"}),label:"Not in rules"}].map(({bg:m,border:A,icon:H,label:F})=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[e.jsx("div",{style:{width:30,height:15,borderRadius:3,flexShrink:0,background:m,borderLeft:`3px solid ${A}`,border:`1px solid color-mix(in srgb, ${A} 25%, var(--border-subtle))`,borderLeftWidth:3,display:"flex",alignItems:"center",justifyContent:"center"},children:H}),e.jsx("span",{style:{fontSize:9.5,color:"var(--text-muted)"},children:F})]},F))})]})}function es(){const t=v(y=>y.poles),r=v(y=>y.results),o=v(y=>y.mrOverrides),n=v(y=>y.availableColumns),s=v(y=>y.mrSelectedPoleId),l=v(y=>y.setMrSelectedPoleId),i=v(y=>y.mrTab),a=v(y=>y.setMrTab),f=v(y=>y.perPoleConfigs),[d,b]=g.useState(""),[p,j]=g.useState("all"),[k,C]=g.useState(""),[P,D]=g.useState(!1),[S,w]=g.useState(!1),R=g.useRef(null),M=["comparison","measurements","visualization"],x=()=>{w(!0),R.current=setTimeout(()=>{D(!1),w(!1)},300)},T=y=>{const B=M.indexOf(i),m=M.indexOf(y);C(m>B?"animate-tab-from-right":"animate-tab-from-left"),a(y)},z=t.filter(y=>r[y.Pole_ID]?.status==="done"||r[y.Pole_ID]?.status==="error"),N=z.filter(y=>r[y.Pole_ID]?.complianceResult?.compliance_status_existing==="FAIL").length,X=z.filter(y=>r[y.Pole_ID]?.complianceResult?.compliance_status_existing==="PASSED").length,U=z.filter(y=>r[y.Pole_ID]?.complianceResult?.compliance_status_existing==="SKIPPED").length,Y=z.filter(y=>r[y.Pole_ID]?.status==="error").length,V=z.filter(y=>{const B=r[y.Pole_ID],m=B?.complianceResult?.compliance_status_existing;return!(p==="failed"&&m!=="FAIL"||p==="passed"&&m!=="PASSED"||p==="skipped"&&m!=="SKIPPED"||p==="error"&&B?.status!=="error"||d&&!Un(y.Pole_ID,d))}),ee=s?r[s]:null,se=s?t.find(y=>y.Pole_ID===s):void 0,W=Pt(ee?.mrResult?.actions??[],s?o[s]:void 0);if(z.length===0)return e.jsx("div",{style:{padding:"24px 16px",borderRadius:10,border:"1px solid var(--border-color)",background:"var(--card-bg)",textAlign:"center",color:"var(--text-muted)",fontSize:11},children:"Run compliance to populate the Make Ready section."});const q=[{key:"comparison",label:"Comparison Table"},{key:"measurements",label:"Measurements"},{key:"visualization",label:"Pole Diagram"}];return e.jsxs("div",{style:{display:"flex",position:"relative",border:"1px solid var(--border-color)",borderRadius:10,overflow:"hidden",background:"var(--card-bg)",height:i==="visualization"?"auto":540,minHeight:540},children:[e.jsxs("div",{style:{width:210,flexShrink:0,borderRight:"1px solid var(--border-color)",display:"flex",flexDirection:"column",overflow:"hidden",...i==="visualization"?{position:"absolute",top:0,bottom:0,left:0}:null},children:[e.jsx("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-tertiary)",flexShrink:0},children:e.jsx("p",{style:{fontSize:9.5,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)"},children:"Select Asset"})}),e.jsx("div",{style:{padding:"6px 8px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,padding:"4px 8px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-color)"},children:[e.jsx(It,{size:10,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("input",{type:"text",placeholder:"Search assets...",value:d,onChange:y=>b(y.target.value),style:{flex:1,background:"transparent",border:"none",outline:"none",fontSize:10,
1color:"var(--text-primary)"}}),d&&e.jsx("button",{onClick:()=>b(""),style:{background:"none",border:"none",cursor:"pointer",padding:0,color:"var(--text-muted)",lineHeight:1,transition:"color 0.12s"},onMouseEnter:y=>{y.currentTarget.style.color="var(--text-primary)"},onMouseLeave:y=>{y.currentTarget.style.color="var(--text-muted)"},children:e.jsx(ze,{size:9})})]})}),e.jsx("div",{style:{display:"flex",gap:3,padding:"5px 8px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0,flexWrap:"wrap"},children:[["all",`All (${z.length})`],["failed",`Fail (${N})`],["passed",`Pass (${X})`],["skipped",`Skipped (${U})`],["error",`Err (${Y})`]].map(([y,B])=>e.jsx("button",{onClick:()=>j(y),style:{padding:"2px 7px",borderRadius:5,fontSize:9,fontWeight:600,border:"none",cursor:"pointer",outline:"none",background:p===y?"var(--color-brand)":"var(--hover-bg)",color:p===y?"white":"var(--text-secondary)",transition:"all 0.12s"},onMouseEnter:m=>{p!==y&&(m.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 18%, var(--hover-bg))",m.currentTarget.style.color="var(--text-primary)")},onMouseLeave:m=>{p!==y&&(m.currentTarget.style.background="var(--hover-bg)",m.currentTarget.style.color="var(--text-secondary)")},children:B},y))}),e.jsxs("div",{style:{flex:1,overflowY:"auto",scrollbarWidth:"thin"},children:[V.length===0&&e.jsx("div",{style:{padding:"16px 10px",textAlign:"center",fontSize:10,color:"var(--text-muted)"},children:"No assets match."}),V.map(y=>{const B=r[y.Pole_ID],m=y.Pole_ID===s,A=B?.complianceResult?.compliance_status_existing,H=A==="PASSED"?"var(--color-success)":A==="FAIL"?"var(--color-danger)":"var(--text-muted)";return e.jsxs("button",{onClick:()=>l(y.Pole_ID),style:{width:"100%",display:"flex",alignItems:"center",gap:7,padding:"7px 10px",background:m?"var(--active-bg)":"transparent",border:"none",cursor:"pointer",outline:"none",borderBottom:"1px solid var(--border-subtle)",textAlign:"left",transition:"background 0.12s"},onMouseEnter:F=>{m||(F.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:F=>{m||(F.currentTarget.style.background="transparent")},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:H,flexShrink:0}}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:y.Pole_ID}),B?.mrResult&&e.jsx("span",{style:{fontSize:9,fontWeight:700,color:B.mrResult.final_compliant?"var(--color-success)":"var(--color-warning)",flexShrink:0},children:"MR"})]},y.Pole_ID)})]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",marginLeft:i==="visualization"?210:0},children:s?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:1,padding:"6px 12px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",flexShrink:0},children:[e.jsx("span",{style:{fontSize:11,fontWeight:700,fontFamily:"monospace",color:"var(--color-brand)",marginRight:10},children:s}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginLeft:"auto"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:1,padding:2,borderRadius:8,background:"var(--hover-bg)"},children:q.map(y=>e.jsx("button",{onClick:()=>T(y.key),style:{padding:"4px 12px",borderRadius:6,fontSize:11,fontWeight:600,border:"none",cursor:"pointer",outline:"none",background:i===y.key?"var(--card-bg)":"transparent",color:i===y.key?"var(--color-brand)":"var(--text-muted)",boxShadow:i===y.key?"var(--shadow-card)":"none",transition:"all 0.12s cubic-bezier(0.4,0,0.2,1)"},onMouseEnter:B=>{i!==y.key&&(B.currentTarget.style.color="var(--text-primary)")},onMouseLeave:B=>{i!==y.key&&(B.currentTarget.style.color="var(--text-muted)")},children:y.label},y.key))}),e.jsxs("button",{onClick:()=>P?x():D(!0),title:"Per-asset settings",style:{position:"relative",padding:5,border:"none",borderRadius:6,cursor:"pointer",background:P?"var(--active-bg)":"transparent",color:P?"var(--color-brand)":"var(--text-muted)",display:"flex",alignItems:"center",transition:"color 0.12s, background 0.12s"},onMouseEnter:y=>{P||(y.currentTarget.style.color="var(--text-primary)",y.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:y=>{P||(y.currentTarget.style.color="var(--text-muted)",y.currentTarget.style.background="transparent")},children:[e.jsx(fo,{size:13}),s&&f[s]&&e.jsx("span",{style:{position:"absolute",top:3,right:3,width:5,height:5,borderRadius:"50%",background:"var(--color-brand)"}})]})]})]}),e.jsxs("div",{style:{flex:1,overflow:i==="visualization"?"visible":"hidden",position:"relative"},children:[e.jsxs("div",{className:k,style:i==="visualization"?{position:"relative",padding:"14px 16px"}:{position:"absolute",inset:0,overflowY:"auto",scrollbarWidth:"thin",padding:"14px 16px"},children:[i==="comparison"&&e.jsx(Zn,{poleId:s}),i==="measurements"&&e.jsx(Xn,{poleId:s}),i==="visualization"&&se&&s&&e.jsx(yn,{poleId:s,row:se,availableColumns:n,actions:W,ruleResults:ee?.complianceResult?.rule_results_existing??[],config:ee?.complianceResult?.config_used??null,afterStatus:ee?.mrResult?ee.mrResult.pole_needs_replacement?"REPLACE":ee.mrResult.final_compliant?"PASS":"FAIL":null}),i==="visualization"&&!se&&e.jsx("div",{style:{textAlign:"center",fontSize:11,color:"var(--text-muted)",padding:24},children:"No row data available for this pole."})]},i),(P||S)&&s&&e.jsx(Qn,{poleId:s,allAvailableCols:n,onClose:x,isClosing:S})]})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted)",fontSize:11},children:"Select an asset from the list to inspect make-ready details."})})]})}function Ke({children:t}){return e.jsx("h2",{style:{fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-muted)",marginBottom:10},children:t})}function ts({batchId:t,initialConfig:r,onApply:o,onReset:n,onClose:s}
1){const l={version:"1.0",created_at:"",updated_at:"",wire_groups:[],rules:[],make_ready_settings:{pole_tip_clearance_in:0,tolerance_in:0,move_increment_in:0}},[i,a]=g.useState(r?JSON.parse(JSON.stringify(r)):l),[f,d]=g.useState([]),b=v(p=>p.availableColumns);return g.useEffect(()=>{be.getAttachmentsConfig().then(p=>d(p.attachment_types)).catch(()=>{})},[]),e.jsx("div",{className:"fixed inset-0 flex items-center justify-center",style:{zIndex:200,background:"rgba(0,0,0,0.55)"},onClick:s,children:e.jsxs("div",{className:"flex flex-col rounded-2xl overflow-hidden",style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",boxShadow:"var(--shadow-elevated)",width:520,maxHeight:"85vh"},onClick:p=>p.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",flexShrink:0},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)"},children:"Batch Rules"}),e.jsxs("p",{style:{fontSize:9,color:"var(--text-muted)",marginTop:1},children:["Batch: ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--color-brand)"},children:t})]})]}),e.jsx("button",{onClick:s,style:{padding:4,border:"none",background:"transparent",color:"var(--text-muted)",cursor:"pointer",display:"flex",transition:"color 0.12s"},onMouseEnter:p=>{p.currentTarget.style.color="var(--text-primary)"},onMouseLeave:p=>{p.currentTarget.style.color="var(--text-muted)"},children:e.jsx(ze,{size:14})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",scrollbarWidth:"thin"},children:e.jsx(nr,{config:i,onChange:a,allWireTypes:f,availableColumns:b})}),e.jsxs("div",{style:{display:"flex",gap:6,padding:"8px 12px",borderTop:"1px solid var(--border-color)",flexShrink:0},children:[e.jsx("button",{onClick:n,style:{padding:"6px 12px",borderRadius:7,fontSize:11,fontWeight:600,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s, border-color 0.12s"},onMouseEnter:p=>{p.currentTarget.style.color="var(--text-primary)",p.currentTarget.style.borderColor="var(--text-primary)"},onMouseLeave:p=>{p.currentTarget.style.color="var(--text-muted)",p.currentTarget.style.borderColor="var(--border-color)"},children:"Reset to Project"}),e.jsx("div",{style:{flex:1}}),e.jsx("button",{onClick:s,style:{padding:"6px 12px",borderRadius:7,fontSize:11,fontWeight:600,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-muted)",cursor:"pointer",transition:"color 0.12s, border-color 0.12s"},onMouseEnter:p=>{p.currentTarget.style.color="var(--text-primary)",p.currentTarget.style.borderColor="var(--text-primary)"},onMouseLeave:p=>{p.currentTarget.style.color="var(--text-muted)",p.currentTarget.style.borderColor="var(--border-color)"},children:"Cancel"}),e.jsx("button",{onClick:()=>o(i),style:{padding:"6px 16px",borderRadius:7,fontSize:11,fontWeight:700,border:"none",background:"var(--color-brand)",color:"white",cursor:"pointer",transition:"opacity 0.12s"},onMouseEnter:p=>{p.currentTarget.style.opacity="0.85"},onMouseLeave:p=>{p.currentTarget.style.opacity="1"},children:"Apply to Batch"})]})]})})}function rs(){const t=v(c=>c.csvFilename),r=v(c=>c.poles),o=v(c=>c.availableColumns),n=v(c=>c.results),s=v(c=>c.complianceRunning),l=v(c=>c.mrRunning),i=v(c=>c.mrFailedPoleIds),a=v(c=>c.cancelRequested),f=v(c=>c.selectedPoleId),d=v(c=>c.setSelectedPoleId),b=v(c=>c.reset),p=Bn(),{canCompliance:j,canMakeReady:k,canExport:C}=Je(),P=j!==!1,D=k!==!1,S=C!==!1,w=Pe(c=>c.config),R=v(c=>c.mappingConfig),{activeTool:M,setActiveTool:x}=cr(),T=g.useMemo(()=>Kr(R??w),[R,w]),z=g.useMemo(()=>Yr(o,r,T),[o,r,T]),N=v(c=>c.setMappingExtraGroups),X=v(c=>c.mappingStarted),U=v(c=>c.setMappingStarted),[Y,V]=g.useState(!1),[ee,se]=g.useState(!1),[W,q]=g.useState(!1);g.useEffect(()=>{V(!1),se(!1),q(!1)},[t]);const y=Pn(z,{mappingStarted:X,poleCount:r.length}),B=v(c=>c.regions),m=v(c=>c.regionConfigs),A=v(c=>c.addRegion),H=v(c=>c.updateRegionCoordinates),F=v(c=>c.deleteRegion),ae=v(c=>c.setPendingRulesTab),G=v(c=>c.batchConfigs),re=v(c=>c.setBatchConfig),[u,E]=g.useState(null),[L,Z]=g.useState(null),[le,oe]=g.useState(!1),[O,xe]=g.useState(null),[we,Te]=g.useState(!1),$e=Object.keys(m).length>0,Ce=g.useMemo(()=>Vr(r),[r]),ve=g.useCallback(c=>{const K=v.getState(),te=Pe.getState().config??null;return wr({poleId:c,pole:K.poles.find(ce=>ce.Pole_ID===c),perPoleConfigs:K.perPoleConfigs,availableColumns:K.availableColumns,regions:K.regions,regionConfigs:K.regionConfigs,batchConfigs:K.batchConfigs,mappingConfig:K.mappingConfig,projectConfig:te})},[]),J=g.useMemo(()=>L?r.filter(c=>rt(c)===L):r,[r,L]),h=g.useMemo(()=>Yo(J,n),[J,n]),I=h.done,_=h.passed,ie=h.failed,ye=h.skipped,me=h.errored,Ne=h.pending,Qe=I>0,de=s||l,Xe=g.useMemo(()=>Go(n),[n]),We=Xe.allDone,Oe=Xe.activeTotal,nt=g.useMemo(()=>r.filter(c=>n[c.Pole_ID]?.complianceResult?.compliance_status_existing==="FAIL"),[r,n]),st=g.useMemo(()=>r.filter(c=>n[c.Pole_ID]?.mrResult!=null).length,[r,n]),Pr=s?We:l?st:We,Mt=l?nt.length:Oe,zr=Mt>0?Math.round(Pr/Mt*100):0,at=Math.round(Vo({passed:_,failed:ie})*100),Tt=g.useMemo(()=>Zo(J,n),[J,n]),Et=g.useCallback(async()=>{await Pe.getState().loadConfig();const c=v.getState();c.setComplianceRunning(!0),c.setCancelRequested(!1),c.clearResults(),c.seedResults(c.poles,c.availableColumns);const K=dt(ne=>v.getState().upsertResults(ne)),te=Ot(c.poles,ne=>ve(ne.Pole_ID),hr),ce=async()=>{for(;!v.getState().cancelRequested;){const ne=te.shift();if(!ne)break;for(const he of ne.items)K.push(he.Pole_ID,{status:"running"});try{const{results:he}=await be.checkComplianceBatch({poles:ne.items.map($=>({...$})),config_override:ne.config,available_columns:c.availableColumns});
1ne.items.forEach(($,ue)=>{const pe=he[ue];K.push($.Pole_ID,pe?.error?{status:"error",error:pe.error}:{complianceResult:pe,status:"done"})})}catch(he){const $=he instanceof Error?he.message:String(he);for(const ue of ne.items)K.push(ue.Pole_ID,{status:"error",error:$})}}};await Promise.all(Array.from({length:4},ce)),K.flushNow(),v.getState().setComplianceRunning(!1),v.getState().setCancelRequested(!1)},[]),Mr=g.useCallback(async()=>{const c=v.getState(),K=c.regions.filter($=>c.regionConfigs[$.id]),te=c.poles.filter($=>{if(!$.Latitude||!$.Longitude)return!1;const ue=parseFloat($.Latitude),pe=parseFloat($.Longitude);return isNaN(ue)||isNaN(pe)?!1:K.some(ke=>or(ue,pe,ke.coordinates))});if(te.length===0){xe("No assets found inside configured regions. Check that your region polygons contain assets with valid coordinates."),setTimeout(()=>xe(null),5e3);return}c.setComplianceRunning(!0),c.setCancelRequested(!1),c.clearResults(),c.seedResults(te,c.availableColumns);const ce=dt($=>v.getState().upsertResults($)),ne=[...te],he=async()=>{for(;!v.getState().cancelRequested;){const $=ne.shift();if(!$)break;ce.push($.Pole_ID,{status:"running"});try{const ue=await be.checkCompliance({pole:{...$},config_override:ve($.Pole_ID),available_columns:c.availableColumns});ce.push($.Pole_ID,{complianceResult:ue,status:"done"})}catch(ue){const pe=ue instanceof Error?ue.message:String(ue);ce.push($.Pole_ID,{status:"error",error:pe})}}};await Promise.all(Array.from({length:4},he)),ce.flushNow(),v.getState().setComplianceRunning(!1),v.getState().setCancelRequested(!1)},[ve]),At=g.useCallback(async c=>{const K=v.getState();K.setMrRunning(!0),K.setCancelRequested(!1),K.setMrFailedPoleIds([]);const te=c??K.poles.filter($=>K.results[$.Pole_ID]?.complianceResult?.compliance_status_existing==="FAIL"),ce=dt($=>v.getState().upsertResults($)),ne=Ot(te,$=>ve($.Pole_ID),Fo);await qo({queue:ne,concurrency:Bo,failureBackoffMs:Uo,shouldCancel:()=>v.getState().cancelRequested,send:async $=>{const{results:ue}=await be.suggestMakeReadyBatch({poles:$.items.map(pe=>({...pe})),config_override:$.config,available_columns:K.availableColumns});return ue},onResults:($,ue)=>{const{applied:pe}=Ko($.items,ue);for(const[ke,Q]of pe)ce.push(ke.Pole_ID,{mrResult:Q})}}),ce.flushNow();const he=v.getState().results;v.getState().setMrFailedPoleIds(te.filter($=>!he[$.Pole_ID]?.mrResult).map($=>$.Pole_ID)),v.getState().setMrRunning(!1),v.getState().setCancelRequested(!1)},[ve]),Tr=g.useCallback(()=>{const c=v.getState(),{poles:K,availableColumns:te,results:ce,csvFilename:ne}=c,he=new Set(c.mrFailedPoleIds),$=["compliance_status","violations","attachments involved in violations","compliance_details","make_ready_actions"],ue=new Set($.map(je=>je.toLowerCase())),ke=[...te.filter(je=>!ue.has(je.toLowerCase())),...$],Q=je=>je.includes(",")||je.includes('"')||je.includes(`
2`)?`"${je.replace(/"/g,'""')}"`:je,Er=K.map(je=>{const Nt=ce[je.Pole_ID],Be=Nt?.complianceResult,He=Nt?.mrResult,Lr=He&&He.actions.length>0?Pt(He.actions,c.mrOverrides[je.Pole_ID]).map(Ee=>`${Ee.direction==="UP"?"Raise":"Lower"} ${Ee.column} from ${Ee.existing_height} to ${Ee.proposed_height}.`).join(" "):He?.pole_needs_replacement?uo:dr(He)?po:he.has(je.Pole_ID)?go:"",Wt={compliance_status:Be?.compliance_status_existing??"",violations:Be?.existing_violations.join(", ")??"","attachments involved in violations":Be?.involved_columns.join(", ")??"",compliance_details:Be?JSON.stringify({check:Be.rule_results_existing}):"",make_ready_actions:Lr};return ke.map(Ee=>{const Nr=Ee in Wt?Wt[Ee]:je[Ee]??"";return Q(String(Nr))}).join(",")}),Ar=[ke.map(Q).join(","),...Er].join(`
3`),Dr=new Blob([Ar],{type:"text/csv"}),Lt=URL.createObjectURL(Dr),lt=document.createElement("a");lt.href=Lt,lt.download=ne.replace(".csv","_compliance.csv"),lt.click(),URL.revokeObjectURL(Lt)},[]),Dt=g.useMemo(()=>r.map(c=>{const K=parseFloat(c.Latitude??""),te=parseFloat(c.Longitude??"");if(!isFinite(K)||!isFinite(te))return null;const ce=n[c.Pole_ID];let ne="pending";return ce?.status==="running"?ne="running":ce?.complianceResult?.compliance_status_existing==="PASSED"?ne="passed":ce?.complianceResult?.compliance_status_existing==="FAIL"?ne="failed":ce?.complianceResult?.compliance_status_existing==="SKIPPED"&&(ne="skipped"),{poleId:c.Pole_ID,latitude:K,longitude:te,status:ne,isSelected:c.Pole_ID===f,row:c,complianceResult:ce?.complianceResult??null}}
3).filter(Boolean),[r,n,f]);return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden animate-workspace-in",style:{background:"var(--bg-primary)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b shrink-0 animate-section-in",style:{height:44,paddingLeft:10,paddingRight:10,borderColor:"var(--border-color)",background:"var(--bg-secondary)"},children:[e.jsx(gr,{size:14,style:{color:"var(--color-brand)",flexShrink:0}}),e.jsx("span",{className:"text-[12px] font-semibold truncate flex-1",style:{color:"var(--text-primary)"},children:t}),e.jsxs("span",{style:{fontSize:10,fontFamily:"monospace",color:"var(--text-muted)",flexShrink:0},children:[r.length," assets"]}),w&&e.jsxs("span",{style:{fontSize:9,color:"var(--text-muted)",flexShrink:0},children:["· ",w.rules.filter(c=>c.enabled).length," rules active"]}),Ce.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,flexShrink:0},children:[e.jsx("span",{style:{fontSize:9,color:"var(--text-muted)",flexShrink:0},children:"Batch:"}),e.jsx(yo,{value:L??"",options:[{value:"",label:"All batches"},...Ce.map(c=>({value:c,label:c}))],onChange:c=>Z(c||null),style:{fontSize:9,padding:"2px 6px",borderRadius:4,width:120,border:"1px solid var(--border-color)",background:L?"color-mix(in srgb, var(--color-brand) 10%, var(--card-bg))":"var(--hover-bg)",color:L?"var(--color-brand)":"var(--text-muted)"}})]}),e.jsx("button",{onClick:()=>{p(),b()},style:{fontSize:11,padding:"3px 8px",borderRadius:5,color:"var(--text-muted)",background:"var(--hover-bg)",border:"1px solid transparent",cursor:"pointer",outline:"none",transition:"color 0.12s, border-color 0.12s"},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-brand)",c.currentTarget.style.borderColor="var(--color-brand)"},onMouseLeave:c=>{c.currentTarget.style.color="var(--text-muted)",c.currentTarget.style.borderColor="transparent"},children:"Change file"})]}),e.jsx("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:e.jsx("div",{style:{flex:1,overflowY:"auto",scrollbarWidth:"thin",padding:"16px 20px 32px"},children:y.block?e.jsx(Mn,{insight:z,rows:r,onManual:()=>{U(!0),x("rules")},onApply:(c,K,te)=>{v.getState().applyMappingSuggestion(R??w??null,{config:c,unplaced:K,extra_group_names:te}),N(te),U(!0)}}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"animate-section-in",style:{animationDelay:"60ms",display:"flex",flexDirection:"column",gap:8,marginBottom:20,padding:"14px 16px",borderRadius:10,background:"var(--card-bg)",border:"1px solid var(--border-color)"},children:[e.jsxs("div",{style:{display:"flex",gap:8},children:[P&&e.jsxs("button",{onClick:()=>{$e&&!de?oe(!0):Et()},disabled:de,title:de?"A run is already in progress":void 0,style:{flex:1,padding:"9px 16px",borderRadius:8,border:"1px solid color-mix(in srgb, var(--color-brand) 40%, var(--border-color))",background:"color-mix(in srgb, var(--color-brand) 15%, var(--card-bg))",color:"var(--color-brand)",fontWeight:700,fontSize:12,cursor:de?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,opacity:de?.6:1,outline:"none",transition:"opacity 0.15s, background 0.12s, border-color 0.12s"},onMouseEnter:c=>{de||(c.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 25%, var(--card-bg))",c.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 65%, var(--border-color))")},onMouseLeave:c=>{c.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 15%, var(--card-bg))",c.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 40%, var(--border-color))"},children:[s?e.jsx(Me,{size:13,className:"animate-spin"}):e.jsx(ct,{size:13}),s?`Checking... (${We}/${Oe})`:"Run Compliance"]}),D&&e.jsxs("button",{onClick:()=>At(),disabled:ie===0||de,title:de?"A run is already in progress":ie===0?"Enabled when failed poles exist - run compliance first":void 0,style:{flex:1,padding:"9px 16px",borderRadius:8,border:"1px solid color-mix(in srgb, var(--color-warning) 40%, var(--border-color))",background:"color-mix(in srgb, var(--color-warning) 15%, var(--card-bg))",color:"var(--color-warning)",fontWeight:700,fontSize:12,cursor:ie===0||de?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:6,opacity:ie===0||de?.45:1,outline:"none",transition:"opacity 0.15s, background 0.12s, border-color 0.12s"},onMouseEnter:c=>{ie>0&&!de&&(c.currentTarget.style.background="color-mix(in srgb, var(--color-warning) 25%, var(--card-bg))",c.currentTarget.style.borderColor="color-mix(in srgb, var(--color-warning) 65%, var(--border-color))")},onMouseLeave:c=>{c.currentTarget.style.background="color-mix(in srgb, var(--color-warning) 15%, var(--card-bg))",c.currentTarget.style.borderColor="color-mix(in srgb, var(--color-warning) 40%, var(--border-color))"},children:[l?e.jsx(Me,{size:13,className:"animate-spin"}):e.jsx(wo,{size:13}),l?`Generating... (${st}/${nt.length})`:"Generate Make Ready"]}),de&&!a&&e.jsxs("button",{onClick:()=>v.getState().setCancelRequested(!0),style:{padding:"9px 14px",borderRadius:8,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-secondary)",fontWeight:600,fontSize:12,cursor:"pointer",display:"flex",alignItems:"center",gap:5,outline:"none",flexShrink:0},onMouseEnter:c=>{c.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[e.jsx(Ro,{size:11})," Cancel"]}),de&&a&&e.jsxs("div",{style:{padding:"9px 14px",borderRadius:8,border:"1px solid var(--border-color)",color:"var(--color-warning)",fontWeight:600,fontSize:12,display:"flex",alignItems:"center",gap:5,flexShrink:0},children:[e.jsx(Me,{size:11,className:"animate-spin"})," Stopping..."]})]}),y.warn&&!Y&&e.jsxs("div",{className:"animate-fade-in",style:{display:"flex",flexDirection:"column",gap:6,padding:"7px 10px",borderRadius:8,fontSize:11,border:"1px solid var(--border-color)",background:"var(--hover-bg)",color:"var(--text-secondary)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(bt,{size:12,style:{flexShrink:0,color:"var(--color-warning)",opacity:.8}}),e.jsxs("button",{onClick:()=>se(c=>!c),title:ee?"Hide the unmapped columns":"Show the unmapped columns",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:5,padding:0,border:0,background:"transparent",textAlign:"left",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",outline:"none"},children:[e.jsxs("span",{children:[Object.keys(z.csvOnly).length," attachment column",Object.keys(z.csvOnly).length===1?"":"s"," not mapped - skipped by Run Compliance"]}),ee?e.jsx(fr,{size:11,style:{flexShrink:0,color:"var(--text-muted)"}}):e.jsx(ot,{size:11,style:{flexShrink:0,color:"var(--text-muted)"}})]}),e.jsx("button",{onClick:()=>{x("rules"),V(!0)},style:{padding:"3px 10px",borderRadius:6,flexShrink:0,border:"1px solid var(--border-color)",background:"var(--card-bg)",color:"var(--text-secondary)",fontWeight:600,fontSize:11,cursor:"pointer",outline:"none"},onMouseEnter:c=>{c.currentTarget.style.color="var(--text-primary)"},onMouseLeave:c=>{c.currentTarget.style.color="var(--text-secondary)"},children:"Map now"}),e.jsx("button",{onClick:()=>V(!0),"aria-label":"Dismiss",title:"Dismiss",style:{flexShrink:0,display:"flex",alignItems:"center",padding:3,borderRadius:4,border:0,background:"transparent",color:"var(--text-muted)",cursor:"pointer",outline:"none"},children:e.jsx(ze,{size:12})})]}),ee&&e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:20},children:Object.keys(z.csvOnly).sort().map(c=>e.jsx("span",{style:{padding:"1px 8px",borderRadius:999,fontSize:10,background:"var(--card-bg)",color:"var(--text-secondary)",border:"1px solid var(--border-color)"},children:c},c))})]}),!de&&!W&&i.length>0&&e.jsxs("div",{className:"animate-fade-in",style:{display:"flex",alignItems:"center",gap:10,marginTop:10,padding:"9px 12px",borderRadius:8,fontSize:12,border:"1px solid color-mix(in srgb, var(--color-danger) 40%, var(--border-color))",background:"color-mix(in srgb, var(--color-danger) 10%, var(--card-bg))",color:"var(--color-danger)"},children:[e.jsx(bt,{size:14,style:{flexShrink:0}}),e.jsxs("span",{style:{flex:1,fontWeight:600},children:["Make-ready did not complete for ",i.length," ",i.length===1?"asset":"assets",". Their make-ready column is empty, not clear - re-run before exporting."]}),e.jsxs("button",{onClick:()=>{const c=v.getState(),K=new Set(c.mrFailedPoleIds);At(c.poles.filter(te=>K.has(te.Pole_ID)))},style:{padding:"6px 12px",borderRadius:6,flexShrink:0,border:"1px solid color-mix(in srgb, var(--color-danger) 55%, var(--border-color))",background:"transparent",color:"var(--color-danger)",fontWeight:700,fontSize:11,cursor:"pointer",display:"flex",alignItems:"center",gap:5,outline:"none"},onMouseEnter:c=>{c.currentTarget.style.background="color-mix(in srgb, var(--color-danger) 18%, transparent)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[e.jsx(ur,{size:11})," Re-run ",i.length]}),e.jsx("button",{onClick:()=>q(!0),"aria-label":"Dismiss",title:"Dismiss",style:{flexShrink:0,display:"flex",alignItems:"center",padding:3,borderRadius:4,border:0,background:"transparent",color:"var(--color-danger)",cursor:"pointer",opacity:.75,outline:"none"},children:e.jsx(ze,{size:13})})]}),de&&e.jsxs("div",{className:"animate-fade-in",children:[e.jsx("div",{style:{height:4,background:"var(--hover-bg)",borderRadius:99,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${zr}%`,background:a?"var(--color-warning)":"var(--color-brand)",transition:"width 0.3s ease",borderRadius:99}})}
3),e.jsxs("p",{style:{fontSize:10,color:"var(--text-muted)",marginTop:4},children:[s?`Compliance check - ${We} of ${Oe} assets processed`:`Make-ready - ${st} of ${nt.length} failed assets processed`,a&&" · canceling..."]})]}),O&&e.jsxs("div",{className:"animate-pop-in",style:{padding:"7px 10px",borderRadius:6,background:"color-mix(in srgb, #dc2626 10%, var(--card-bg))",border:"1px solid color-mix(in srgb, #dc2626 30%, var(--border-color))",display:"flex",alignItems:"flex-start",gap:6},children:[e.jsx("span",{style:{fontSize:12,flexShrink:0},children:"⚠"}),e.jsx("p",{style:{fontSize:10,color:"#dc2626",margin:0},children:O})]}),!de&&me>0&&e.jsx("div",{style:{padding:"7px 10px",borderRadius:6,background:"color-mix(in srgb, var(--color-warning) 10%, var(--card-bg))",border:"1px solid color-mix(in srgb, var(--color-warning) 30%, var(--border-color))"},children:e.jsxs("p",{style:{fontSize:10,color:"var(--color-warning)",fontWeight:600},children:["⚠ ",me," pole",me!==1?"s":"",' failed to check. Filter by "Errors" in the table below for details.']})}),Qe&&S&&e.jsxs("button",{className:"animate-fade-in",onClick:()=>Te(!0),style:{alignSelf:"flex-start",padding:"6px 12px",borderRadius:7,fontSize:11,fontWeight:600,border:"1px solid var(--border-color)",color:"var(--text-secondary)",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",gap:5,outline:"none"},onMouseEnter:c=>{c.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[e.jsx(ht,{size:11})," Export Results"]})]}),L&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:10,padding:"5px 10px",borderRadius:7,background:"color-mix(in srgb, var(--color-brand) 8%, var(--card-bg))",border:"1px solid color-mix(in srgb, var(--color-brand) 25%, var(--border-color))"},children:[e.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)"},children:"Viewing batch:"}),e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",fontWeight:700,color:"var(--color-brand)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L}),e.jsx("button",{onClick:()=>Z(null),style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",display:"flex",padding:2,transition:"color 0.12s"},onMouseEnter:c=>{c.currentTarget.style.color="var(--text-primary)"},onMouseLeave:c=>{c.currentTarget.style.color="var(--text-muted)"},children:e.jsx(ze,{size:11})})]}),e.jsxs("div",{className:"animate-section-in",style:{animationDelay:"100ms",display:"flex",gap:8,marginBottom:20},children:[e.jsx(qe,{label:"Total Assets",value:J.length,delay:110}),e.jsx(qe,{label:"Passed",value:_,color:"var(--color-success)",delay:150}),e.jsx(qe,{label:"Failed",value:ie,color:"var(--color-danger)",delay:190}),ye>0&&e.jsx(qe,{label:"Skipped",value:ye,color:"var(--text-muted)",delay:210}),Ne>0&&e.jsx(qe,{label:"Pending",value:Ne,color:"var(--text-muted)",delay:230}),Qe&&e.jsxs("div",{className:"flex-1 rounded-lg animate-pop-in",style:{animationDelay:"270ms",background:"var(--card-bg)",border:"1px solid var(--border-color)",padding:6},children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase",style:{color:"var(--text-muted)",letterSpacing:"0.06em"},children:"Pass Rate"}),e.jsxs("p",{className:"text-[22px] font-bold mt-0.5 font-mono",style:{color:at>=80?"var(--color-success)":at>=50?"var(--color-warning)":"var(--color-danger)"},children:[at,"%"]})]})]}),!de&&Tt.solved>0&&e.jsxs("div",{className:"animate-section-in",style:{animationDelay:"120ms",marginBottom:20},children:[e.jsx(Ke,{children:"Make-Ready Impact"}),e.jsx(Yn,{passedCount:_,doneCount:I,failedCount:ie,impact:Tt})]}),Ce.length>0&&e.jsxs("div",{className:"animate-section-in",style:{animationDelay:"140ms",marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(Ke,{children:"Batch Summary"}),e.jsx("span",{style:{fontSize:9,color:"var(--text-muted)",marginBottom:8},children:"click to filter"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:Ce.map((c,K)=>{const te=r.filter(Q=>rt(Q)===c),ce=te.filter(Q=>n[Q.Pole_ID]?.complianceResult?.compliance_status_existing==="PASSED").length,ne=te.filter(Q=>n[Q.Pole_ID]?.complianceResult?.compliance_status_existing==="FAIL").length,he=te.filter(Q=>n[Q.Pole_ID]?.complianceResult?.compliance_status_existing==="SKIPPED").length,$=te.filter(Q=>!n[Q.Pole_ID]?.complianceResult).length,ue=te.filter(Q=>_t(n[Q.Pole_ID])).length,pe=!!G[c],ke=L===c;return e.jsxs("div",{className:"animate-fade-in",onClick:()=>Z(ke?null:c),style:{animationDelay:`${Math.min(K,12)*35}ms`,display:"flex",alignItems:"center",gap:10,padding:"7px 12px",borderRadius:8,cursor:"pointer",background:ke?"color-mix(in srgb, var(--color-brand) 10%, var(--card-bg))":pe?"color-mix(in srgb, var(--color-brand) 5%, var(--card-bg))":"var(--card-bg)",border:ke?"1px solid color-mix(in srgb, var(--color-brand) 50%, var(--border-color))":pe?"1px solid color-mix(in srgb, var(--color-brand) 25%, var(--border-color))":"1px solid var(--border-color)",transition:"background 0.12s, border-color 0.12s"},onMouseEnter:Q=>{ke||(Q.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 10%, var(--card-bg))",Q.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 35%, var(--border-color))")},onMouseLeave:Q=>{ke||(Q.currentTarget.style.background=pe?"color-mix(in srgb, var(--color-brand) 5%, var(--card-bg))":"var(--card-bg)",Q.currentTarget.style.borderColor=pe?"color-mix(in srgb, var(--color-brand) 25%, var(--border-color))":"var(--border-color)")},children:[e.jsx("span",{style:{fontSize:10,fontFamily:"monospace",fontWeight:600,color:ke?"var(--color-brand)":"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:c}),e.jsxs("span",{style:{fontSize:9,color:"var(--text-muted)",flexShrink:0},children:[te.length," assets"]}),ce>0&&e.jsxs("span",{style:{fontSize:9,fontWeight:700,color:"var(--color-success)",flexShrink:0},children:[ce," pass"]}),ne>0&&e.jsxs("span",{style:{fontSize:9,fontWeight:700,color:"var(--color-danger)",flexShrink:0},children:[ne," fail"]}),ue>0&&e.jsxs("span",{style:{fontSize:9,fontWeight:700,color:"var(--color-brand)",flexShrink:0},children:[ue," resolvable"]}),he>0&&e.jsxs("span",{style:{fontSize:9,color:"var(--text-muted)",flexShrink:0},children:[he," skipped"]}),$>0&&e.jsxs("span",{style:{fontSize:9,color:"var(--text-muted)",flexShrink:0},children:[$," pending"]}),pe&&e.jsx("span",{style:{fontSize:8,padding:"1px 5px",borderRadius:3,background:"var(--color-brand)",color:"white",fontWeight:700,flexShrink:0},children:"Custom rules"}),e.jsx("button",{onClick:Q=>{Q.stopPropagation(),E(c)},title:"Configure rules for this batch",style:{fontSize:9,fontWeight:600,padding:"3px 8px",borderRadius:5,border:"1px solid var(--border-color)",background:"var(--hover-bg)",color:"var(--text-muted)",cursor:"pointer",flexShrink:0},onMouseEnter:Q=>{Q.currentTarget.style.color="var(--color-brand)",Q.currentTarget.style.borderColor="var(--color-brand)"},onMouseLeave:Q=>{Q.currentTarget.style.color="var(--text-muted)",Q.currentTarget.style.borderColor="var(--border-color)"},children:"Rules"})]}
3,c)})})]}),J.length>0&&e.jsxs("div",{className:"animate-section-in",style:{animationDelay:"170ms",marginBottom:24},children:[e.jsx(Ke,{children:"Compliance Results"}),e.jsx(Gn,{poles:J})]}),Dt.length>0&&e.jsxs("div",{className:"animate-section-in",style:{animationDelay:"200ms",marginBottom:24},children:[e.jsx(Ke,{children:"Map View"}),e.jsx("div",{style:{height:380,borderRadius:10,overflow:"hidden",border:"1px solid var(--border-color)",display:"flex"},children:e.jsx(tn,{points:Dt,onSelect:d,regions:B,onAddRegion:(c,K,te)=>A(c,K,te),onUpdateRegion:(c,K)=>H(c,K),onDeleteRegion:c=>F(c),onOpenRegionConfig:()=>{x("rules"),ae("region")}})})]}),D&&e.jsxs("div",{id:"mr-section",className:"animate-section-in",style:{animationDelay:"230ms"},children:[e.jsx(Ke,{children:"Make Ready"}),e.jsx(es,{})]})]})})}),le&&e.jsx("div",{className:"fixed inset-0 flex items-center justify-center",style:{zIndex:500,background:"rgba(0,0,0,0.45)"},onClick:()=>oe(!1),children:e.jsxs("div",{className:"animate-pop-in",style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:12,padding:"22px 24px",width:340,boxShadow:"var(--shadow-elevated)",display:"flex",flexDirection:"column",gap:16},onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[e.jsx("p",{style:{fontSize:13,fontWeight:700,color:"var(--text-primary)",margin:0},children:"Run Compliance"}),e.jsxs("p",{style:{fontSize:11,color:"var(--text-muted)",margin:0},children:[Object.keys(m).length," region",Object.keys(m).length>1?"s":""," with custom config detected. Choose scope:"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("button",{onClick:()=>{oe(!1),Mr()},style:{padding:"11px 14px",borderRadius:8,border:"1px solid color-mix(in srgb, var(--color-brand) 35%, var(--border-color))",background:"color-mix(in srgb, var(--color-brand) 10%, var(--card-bg))",color:"var(--color-brand)",fontWeight:600,fontSize:12,cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:3,transition:"background 0.12s, border-color 0.12s"},onMouseEnter:c=>{c.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 18%, var(--card-bg))",c.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 60%, var(--border-color))"},onMouseLeave:c=>{c.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 10%, var(--card-bg))",c.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 35%, var(--border-color))"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ct,{size:13}),"Regions only"]}),e.jsx("span",{style:{fontSize:10,fontWeight:400,color:"var(--text-secondary)",paddingLeft:19},children:"Run compliance only for assets inside configured regions"})]}),e.jsxs("button",{onClick:()=>{oe(!1),Et()},style:{padding:"11px 14px",borderRadius:8,border:"1px solid var(--border-color)",background:"var(--hover-bg)",color:"var(--text-primary)",fontWeight:600,fontSize:12,cursor:"pointer",textAlign:"left",display:"flex",flexDirection:"column",gap:3,transition:"background 0.12s, border-color 0.12s"},onMouseEnter:c=>{c.currentTarget.style.background="var(--bg-tertiary)",c.currentTarget.style.borderColor="var(--text-muted)"},onMouseLeave:c=>{c.currentTarget.style.background="var(--hover-bg)",c.currentTarget.style.borderColor="var(--border-color)"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx(ct,{size:13}),"All assets"]}),e.jsx("span",{style:{fontSize:10,fontWeight:400,color:"var(--text-secondary)",paddingLeft:19},children:"Run compliance for all poles, applying region config where applicable"})]})]}),e.jsx("button",{onClick:()=>oe(!1),style:{alignSelf:"flex-end",fontSize:11,color:"var(--text-muted)",background:"none",border:"none",cursor:"pointer",padding:0,transition:"color 0.12s"},onMouseEnter:c=>{c.currentTarget.style.color="var(--text-primary)"},onMouseLeave:c=>{c.currentTarget.style.color="var(--text-muted)"},children:"Cancel"})]})}),u&&e.jsx(ts,{batchId:u,initialConfig:G[u]??w,onApply:c=>{re(u,c),E(null)},onReset:()=>{v.getState().clearBatchConfig(u),E(null)},onClose:()=>E(null)}),e.jsx(In,{open:we,onClose:()=>Te(!1),resolveConfigForPole:ve,onExportCsv:Tr})]})}function Is(){const t=v(R=>R.view),r=On(),o=tr(r.screen==="loading");g.useEffect(()=>{const{config:R}=Pe.getState();R||be.getRulesConfigDefaults().then(M=>Pe.setState({config:M.config,isDirty:!1}
3)).catch(()=>{})},[]);const{activeTool:n,setActiveTool:s}=cr(),l=n==="settings"||n==="rules",i=it(R=>R.setRightPanelWidth),a=it(R=>R.resetRightPanelWidth),f=Hr(),d=it(R=>R.rightPanelWidth),[b,p]=g.useState(null),j=so(`(min-width: ${lo}px)`),k=(j?b:null)??f,[C,P]=g.useState(l),[D,S]=g.useState(!1),w=g.useRef(null);return g.useEffect(()=>{l?(w.current&&(clearTimeout(w.current),w.current=null),S(!1),P(!0)):C&&(S(!0),w.current=setTimeout(()=>{P(!1),S(!1),w.current=null},140))},[l]),e.jsxs("div",{className:"flex h-full overflow-hidden animate-fade-in",style:{background:"var(--bg-primary)"},children:[e.jsx("div",{className:"flex flex-col flex-1 overflow-hidden",children:r.screen!=="none"&&r.req?e.jsx(Hn,{screen:r.screen,req:r.req,error:r.error,elapsed:o,onCancel:r.cancel,onRetry:r.retry,onGoBack:r.goBack}):t==="landing"?e.jsx(Kn,{}):e.jsx(rs,{})}),C&&e.jsxs("div",{className:D?"animate-panel-slide-out":"animate-panel-slide-in","data-panel-bounds":"",style:{width:k,flexShrink:0,"--right-panel-width":`${k}px`,transition:b===null?"width 0.2s cubic-bezier(0.4, 0, 0.2, 1)":"none",borderLeft:"1px solid var(--border-color)",background:"var(--card-bg)",display:"flex",flexDirection:"column",position:"relative",zIndex:1},children:[j&&e.jsx(Ur,{width:k,canReset:d!==ao,onDrag:p,onCommit:R=>{p(null),i(R)},onReset:()=>{p(null),a()}}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minWidth:0,minHeight:0,overflow:"hidden"},children:e.jsx(qr,{onBack:()=>s("height")})})]})]})}export{Is 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.