1import{a as i,j as e}from"./markdown-DXOadQr0.js";import{c as Gt,r as Mr,L as ee,a1 as Yt,b as A,X as fe,C as Pn,j as Ja,J as aa,K as Qa,i as Za,u as eo,a2 as to,B as oa,a3 as Te,W as Y,a4 as $t,a5 as ro,a6 as Tr,a7 as no,a8 as ao,a9 as me,aa as oo,ab as io,ac as so,ad as Rr,ae as Wr,t as Tn,U as lo,T as pe,a as de,F as co,z as ut,af as zn,ag as uo,N as po,m as ho,w as go,ah as Dr,P as mo,H as fo,ai as xo,aj as bo,Z as yo,ak as vo}from"./index-D_4K0EPH.js";import{h as jo,A as ze}from"./heightiqUrl-ob5aTwex.js";import{s as Nn,t as Mn,f as Rn,v as ko}from"./trackDelete-COpuU6WP.js";import{U as So}from"./UploadWidget-qzhyapIg.js";import{u as _o,r as wo,B as Co,P as Io,a as Po,C as To,m as zo}from"./manualPoles-BCTn_qVU.js";import{A as No}from"./AccessPanel-BF8jidNs.js";import{S as Ne,c as Mo,F as Ft,d as Ro,a as Wo}from"./unannotatedPrompt-BaxYmXVM.js";import{C as Re}from"./chevron-down-CQpnnUvt.js";import{S as ia}from"./search-kp9FbES_.js";import{P as Ao,B as Do,p as Eo,c as Lo}from"./statusFilters-BnkCSARl.js";import{R as $o}from"./RuleScopeModal-CXyZWZi7.js";import{u as Wn,D as pt,C as Fo}from"./ChoiceDialog-B3kE6rlH.js";import{D as Bo}from"./DeleteConfirmModal-DQ-w2JU8.js";import{P as Bt}
1from"./PaginationBar-CqyaCHPR.js";import{r as Oo,p as Ho,t as An,s as Uo}from"./dashboardReturn-CLaupgiJ.js";import{r as Ko,d as Yo,a as zr,f as te}from"./drillCounts-TUDJZbxR.js";import{o as Nr,p as Go,b as Dn,d as En}from"./c2aOpenRequest-frrZuwmL.js";import{G as Kt}from"./git-branch-CURf3RJy.js";import{C as oe}from"./chart-column-DlT9v-WE.js";import{I as sa}from"./image-CyeGbrQK.js";import{F as la}from"./file-spreadsheet-GC__50FI.js";import{C as Xo}from"./clock-CZiqAA0M.js";import{F as qo}from"./flag-Dvi6eOhK.js";import"./leaflet-BVyOPZwf.js";import"./csvParser-DRy1_4jL.js";import"./plus-BcTC3T0T.js";import"./file-text-BT1n_Hc8.js";import"./access-CcMMB1Xc.js";import"./map-C272HwnR.js";import"./RulesConfigPreviewModal-CALkU-Z1.js";import"./useAnchorRect-5flMu7AC.js";import"./copy-BLgnR1tI.js";import"./funnel-DyEPYRa_.js";import"./wrench-DBbN-nN-.js";import"./mapLegend-CatE-S44.js";import"./file-archive-DrREUSgk.js";import"./arrow-left-Dkjg-Ft6.js";const Vo=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],Ln=Gt("calendar-days",Vo);const Jo=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],Qo=Gt("house",Jo);const Zo=[["path",{d:"M13.172 2a2 2 0 0 1 1.414.586l6.71 6.71a2.4 2.4 0 0 1 0 3.408l-4.592 4.592a2.4 2.4 0 0 1-3.408 0l-6.71-6.71A2 2 0 0 1 6 9.172V3a1 1 0 0 1 1-1z",key:"16rjxf"}],["path",{d:"M2 7v6.172a2 2 0 0 0 .586 1.414l6.71 6.71a2.4 2.4 0 0 0 3.191.193",key:"178nd4"}],["circle",{cx:"10.5",cy:"6.5",r:".5",fill:"currentColor",key:"12ikhr"}]],ei=Gt("tags",Zo);const ti=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],ht=Gt("user-round",ti);function ca(n){return n.filter(a=>!!a.batch_id)}function da(n,a){const o=ca(n);return a.level==="root"?o:a.level==="project"?o.filter(s=>s.project_id===a.projectId):a.level==="circuit"?o.filter(s=>s.project_id===a.projectId&&s.circuit_name===a.circuitName):o.filter(s=>s.batch_id===a.batchId)}function ri(n){return{projectId:n.project_id,projectName:n.project_name,circuitId:n.circuit_id,circuitName:n.circuit_name,batchId:n.batch_id,batchName:n.batch_name}}function ni(n,a){if(a.level==="batch")return{projectId:a.projectId,projectName:a.projectName,circuitId:"",circuitName:a.circuitName,batchId:a.batchId,batchName:a.batchName};const o=da(n,a);return o.length!==1?null:ri(o[0])}function ai(n){const a=new Map;for(const o of ca(n))a.has(o.project_id)||a.set(o.project_id,o.project_name||o.project_id);return Array.from(a.entries()).map(([o,s])=>({id:o,name:s})).sort((o,s)=>o.name.localeCompare(s.name))}function oi(n){const a=ai(n);return a.length!==1?null:{projectId:a[0].id,projectName:a[0].name}}function ii(n,a){if(a.level==="batch"){const s=ni(n,a);return s?{action:"batch",target:s}:{action:"empty"}}if(da(n,a).length===0)return{action:"empty"};if(a.level==="circuit")return{action:"scope",projectId:a.projectId,projectName:a.projectName,circuitName:a.circuitName};if(a.level==="project")return{action:"choose",projectId:a.projectId,projectName:a.projectName};const o=oi(n);return o?{action:"choose",...o}:{action:"choose"}}function ua(n,a){const o=(n||a||"?").trim(),s=o.split(/\s+/);return s.length>=2?(s[0][0]+s[1][0]).toUpperCase():o.slice(0,2).toUpperCase()}const $n=["#3b82f6","#8b5cf6","#ec4899","#f59e0b","#10b981","#06b6d4","#ef4444","#6366f1"];function pa(n){let a=0;for(let o=0;o<n.length;o++)a=a*31+n.charCodeAt(o)>>>0;return $n[a%$n.length]}function Fn({a:n,size:a}){return e.jsx("div",{style:{width:a,height:a,borderRadius:"50%",flexShrink:0,background:pa(n.user_id),color:"white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(8,Math.round(a*.4)),fontWeight:700,boxShadow:"0 0 0 2px var(--card-bg)"},children:ua(n.user_name,n.user_email)})}function si({batchId:n,annotators:a,max:o=3,size:s=24}){const[u,h]=i.useState(!1),[m,p]=i.useState(null),[d,f]=i.useState(null),[v,I]=i.useState(!1),[w,T]=i.useState(new Set),N=i.useRef(null);if(i.useEffect(()=>{if(!u)return;const P=D=>{D.key==="Escape"&&h(!1)};return window.addEventListener("keydown",P,!0),()=>window.removeEventListener("keydown",P,!0)},[u]),!a||a.length===0)return e.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"-"});const C=a.slice(0,o),L=a.length-C.length,R=a.map(P=>P.user_name||P.user_email).join(` 2`),O=P=>{if(P.stopPropagation(),u){h(!1);return}const D=N.current?.getBoundingClientRect();if(D){const U=Math.max(8,Math.min(D.left,window.innerWidth-300-8)),K=window.innerHeight-D.bottom-14;K>=180||K>=D.top-14?p({top:D.bottom+6,left:U,maxHeight:Math.min(340,K)}):p({bottom:window.innerHeight-D.top+6,left:U,maxHeight:Math.min(340,D.top-14)})}h(!0),!d&&!v&&(I(!0),A.getBatchAnnotators(n).then(H=>f(H.annotators)).catch(()=>f([])).finally(()=>I(!1)))};return e.jsxs(e.Fragment,{children:[e.jsxs("button",{ref:N,onClick:O,title:R,style:{display:"flex",alignItems:"center",background:"transparent",border:0,padding:0,cursor:"pointer"},children:[C.map((P,D)=>e.jsx("div",{style:{marginLeft:D===0?0:-7},children:e.jsx(Fn,{a:P,size:s})},P.user_id)),L>0&&e.jsxs("div",{style:{marginLeft:-7,width:s,height:s,borderRadius:"50%",background:"var(--bg-tertiary, #334155)",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(8,Math.round(s*.38)),fontWeight:700,boxShadow:"0 0 0 2px var(--card-bg)"},children:["+",L]})]}),u&&m&&Mr.createPortal(e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:P=>{P.stopPropagation(),h(!1)},style:{position:"fixed",inset:0,zIndex:1e4}}),e.jsxs("div",{onClick:P=>P.stopPropagation(),style:{position:"fixed",top:m.top,bottom:m.bottom,left:m.left,width:300,zIndex:10001,maxHeight:m.maxHeight,overflowY:"auto",background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.3)",padding:10,scrollbarWidth:"thin"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:"var(--text-muted)",padding:"2px 4px 8px"},children:"Annotated by"}),v&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"10px 4px",fontSize:12,color:"var(--text-muted)"},children:[e.jsx(ee,{size:13,style:{animation:"spin 1s linear infinite"}})," Loading..."]}),!v&&d&&d.length===0&&e.jsx("div",{style:{padding:"10px 4px",fontSize:12,color:"var(--text-muted)"},children:"No annotators yet."}),!v&&d&&d.map(P=>{const H=w.has(P.user_id),U=H?P.poles:P.poles.slice(0,8),K=P.poles.length-U.length;return e.jsxs("div",{style:{display:"flex",gap:8,padding:"8px 4px",borderTop:"1px solid color-mix(in srgb, var(--border-color) 60%, transparent)"},children:[e.jsx(Fn,{a:P,size:26}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.user_name||P.user_email}),e.jsxs("div",{style:{fontSize:10.5,color:"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[P.user_email," · ",P.poles.length," pole",P.poles.length===1?"":"s"]}),e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,marginTop:5},children:[U.map(G=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,fontFamily:"monospace",color:"var(--text-secondary)",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:4,padding:"1px 5px"},children:[e.jsx(Yt,{size:9,strokeWidth:2,style:{color:"var(--text-muted)"}}),G]},G)),P.poles.length>8&&e.jsx("button",{onClick:()=>T(G=>{const X=new Set(G);return H?X.delete(P.user_id):X.add(P.user_id),X}),style:{fontSize:10,fontWeight:600,color:"var(--color-brand)",background:"color-mix(in srgb, var(--color-brand) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--color-brand) 25%, transparent)",borderRadius:4,padding:"1px 6px",cursor:"pointer"},children:H?"Show less":`+${K} more`})]})]})]},P.user_id)})]})]}),document.body)]})}const ha={all:"Any time",today:"Today",yesterday:"Yesterday",last_3_days:"Last 3 days",last_7_days:"Last 7 days",this_week:"This week",last_30_days:"Last 30 days",custom:"Custom"};function Bn(n){const a=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),s=String(n.getDate()).padStart(2,"0");return`${a}-${o}-${s}`}function ga(n){return new Date(n.getFullYear(),n.getMonth(),n.getDate())}function li(n){const a=n.getDay(),o=a===0?6:a-1,s=ga(n);return s.setDate(s.getDate()-o),s}function ci(n,a,o){if(n==="all")return{};if(n==="custom"){const m={};return a&&(m.date_from=a),o&&(m.date_to=o),m}const s=ga(new Date);let u=s,h=s;return n==="yesterday"?(u=new Date(s),u.setDate(u.getDate()-1),h=u):n==="last_3_days"?(u=new Date(s),u.setDate(u.getDate()-2)):n==="last_7_days"?(u=new Date(s),u.setDate(u.getDate()-6)):n==="this_week"?u=li(s):n==="last_30_days"&&(u=new Date(s),u.setDate(u.getDate()-29)),{date_from:Bn(u),date_to:Bn(h)}}const vt={statuses:[],annotatorIds:[],datePreset:"all",customFrom:"",customTo:""};function di(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||void 0}catch{return}}function On(n){const a=ci(n.datePreset,n.customFrom,n.customTo),o=a.date_from||a.date_to?di():void 0;return{progress:n.statuses.length?n.statuses.join(","):"all",...n.annotatorIds.length?{annotator_id:n.annotatorIds.join(",")}:{},...a,...o?{tz:o}:{}}}function Ar(n){return n.statuses.length>0||n.annotatorIds.length>0||n.datePreset!=="all"}function ui(n,a,o){return n==="root"?"root":n==="pole"?"batch:":`${n}:${a??""}`}function pi(n,a,o){if(n==="root")return["root"];const s=[];if(n==="pole"){s.push(`batch:${o??""}`);for(let u=a.length-1;u>=0;u--){const h=a[u];h.level==="pole"||h.level==="batch"||s.push(`${h.level}:${h.id}`)}}else{s.push(ui(n,a[a.length-1]?.id??null));for(let u=a.length-2;u>=0;u--){const h=a[u];s.push(h.level==="root"?"root":`${h.level}:${h.id}`)}}return s.includes("root")||s.push("root"),s}function hi(n,a){if(a[0]in n)return n[a[0]];for(let o=1;o<a.length;o++){const s=n[a[o]];if(s)return s}return vt}const ma={id:"not_started",label:"Not started",color:"var(--pole-not-started)",activeColor:"var(--text-secondary)",hint:"No annotation work at all"},fa={id:"in_progress",label:"In progress",color:"var(--pole-in-progress)",hint:"Opened, some assets still not started"}
2,xa={id:"complete",label:"Complete",color:"var(--pole-annotated)",hint:"Every pole finished - annotated, annotated + flag, or skipped"},ba={id:"annotated",label:"Annotated",color:"var(--pole-annotated)",hint:"Carries measurements"},ya={id:"flagged",label:"Flagged",color:"var(--pole-flagged)",hint:"Flagged for review (may also carry measurements)"},va={id:"skipped",label:"Skipped",color:"var(--pole-skipped)",hint:"Opened but not annotated"},gi={root:"project",project:"circuit",circuit:"batch"};function mi(n){if(n==="batch")return[];const a=gi[n],o=n==="circuit"?"How far the batch as a whole has got":`Keeps the ${a} when any batch inside it is in that state`;return[{key:"batch",title:n==="circuit"?"Batch progress":"Contains a batch that is",hint:o,options:[ma,fa,xa]},{key:"contains",title:"Has an asset that is",hint:`Matches the ${a} if any one asset inside it qualifies`,options:[ba,va,ya]}]}const fi=[ma,fa,xa,ba,va,ya],xi=["all","today","yesterday","last_3_days","last_7_days","this_week","last_30_days","custom"],Hn=4;function Un(n,a){return n.includes(a)?n.filter(o=>o!==a):[...n,a]}function bi(n,a){const o=s=>JSON.stringify({s:[...s.statuses].sort(),a:[...s.annotatorIds].sort(),p:s.datePreset,from:s.datePreset==="custom"?s.customFrom:"",to:s.datePreset==="custom"?s.customTo:""});return o(n)===o(a)}function Ot(n){const a=new Date(`${n}T00:00:00`);return Number.isNaN(a.getTime())?n:a.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function yi(n){return n.datePreset!=="custom"?ha[n.datePreset]:n.customFrom&&n.customTo?`${Ot(n.customFrom)} - ${Ot(n.customTo)}`:n.customFrom?`From ${Ot(n.customFrom)}`:n.customTo?`Until ${Ot(n.customTo)}`:"Custom range"}function Kn({a:n,size:a=20}){return e.jsx("span",{style:{width:a,height:a,borderRadius:"50%",flexShrink:0,background:pa(n.user_id),color:"#fff",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:Math.max(8,Math.round(a*.42)),fontWeight:700,letterSpacing:0},children:ua(n.user_name,n.user_email)})}function vi({filters:n,onChange:a,annotators:o,annotatorsLoading:s,level:u="circuit",resultCount:h=null,resultNoun:m="results"}){const[p,d]=i.useState(!1),[f,v]=i.useState(""),I=i.useRef(null),w=i.useMemo(()=>mi(u),[u]),T=i.useRef(()=>{}),[N,C]=i.useState(n);i.useEffect(()=>{p&&(C(n),v(""))},[p,n]),i.useEffect(()=>{if(!p)return;const S=F=>{F.key==="Escape"&&d(!1);const q=document.activeElement;F.key==="Enter"&&q instanceof HTMLInputElement&&I.current?.contains(q)&&(F.preventDefault(),T.current())},M=F=>{I.current&&!I.current.contains(F.target)&&d(!1)};return document.addEventListener("keydown",S),document.addEventListener("mousedown",M),()=>{document.removeEventListener("keydown",S),document.removeEventListener("mousedown",M)}},[p]);const L=Ar(n),R=(n.statuses.length?1:0)+(n.annotatorIds.length?1:0)+(n.datePreset!=="all"?1:0),O=i.useMemo(()=>{const S=[];for(const M of n.statuses){const F=fi.find(q=>q.id===M);S.push({key:`s:${M}`,label:F?.label??M,color:F?.color,onRemove:()=>a({...n,statuses:n.statuses.filter(q=>q!==M)})})}for(const M of n.annotatorIds){const F=o.find(q=>q.user_id===M);S.push({key:`a:${M}`,label:F?F.user_name||F.user_email:"Annotator",annotator:F,onRemove:()=>a({...n,annotatorIds:n.annotatorIds.filter(q=>q!==M)})})}return n.datePreset!=="all"&&S.push({key:"d",label:yi(n),onRemove:()=>a({...n,datePreset:"all",customFrom:"",customTo:""})}),S},[n,o,a]),P=O.slice(0,Hn),D=O.length-P.length,H=i.useMemo(()=>{const S=f.trim().toLowerCase();return S?o.filter(M=>(M.user_name||"").toLowerCase().includes(S)||M.user_email.toLowerCase().includes(S)):o},[o,f]),U=!bi(N,n),K=(N.statuses.length?1:0)+(N.annotatorIds.length?1:0)+(N.datePreset!=="all"?1:0),G=i.useCallback(()=>{a(N),d(!1)},[a,N]);i.useEffect(()=>{T.current=G},[G]);const X=u==="batch"&&N.statuses.length>0&&N.statuses.every(S=>S==="not_started")&&(N.annotatorIds.length>0||N.datePreset!=="all"),re=()=>{a(vt),C(vt)},he={fontSize:9.5,fontWeight:700,letterSpacing:"0.07em",textTransform:"uppercase",color:"var(--text-muted)",display:"flex",alignItems:"center",gap:5},We={width:"100%",padding:"4px 8px",borderRadius:7,border:"1px solid var(--border-color)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:11.5,outline:"none"},J=(S,M)=>({display:"inline-flex",alignItems:"center",gap:5,padding:"2.5px 8px",borderRadius:999,border:`1px solid ${S?`color-mix(in srgb,${M??"var(--color-brand)"} 45%,transparent)`:"var(--border-color)"}`,background:S?`color-mix(in srgb,${M??"var(--color-brand)"} 13%,transparent)`:"var(--bg-tertiary)",color:S?M??"var(--color-brand)":"var(--text-secondary)",fontSize:11,fontWeight:S?650:500,cursor:"pointer",transition:"background 0.12s, border-color 0.12s, color 0.12s",whiteSpace:"nowrap"}),Qe=S=>({display:"flex",alignItems:"center",gap:7,width:"100%",padding:"3.5px 6px",borderRadius:6,border:0,background:S?"color-mix(in srgb,var(--color-brand) 11%,transparent)":"transparent",color:"var(--text-primary)",fontSize:12,cursor:"pointer",textAlign:"left",transition:"background 0.12s"}),xe=S=>({width:14,height:14,borderRadius:4,flexShrink:0,border:`1.5px solid ${S?"var(--color-brand)":"color-mix(in srgb,var(--text-muted) 55%,transparent)"}`,background:S?"var(--color-brand)":"transparent",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"#fff",transition:"background 0.12s, border-color 0.12s"}),jt={height:1,background:"color-mix(in srgb,var(--border-color) 70%,transparent)",margin:"0 -11px"}
2,kt={fontSize:10,color:"var(--text-muted)"};return e.jsxs("div",{ref:I,style:{position:"relative",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[e.jsx("style",{children:` 3 @keyframes cfpPanelIn { from { opacity: 0; transform: translateY(-6px) scale(0.985); } to { opacity: 1; transform: translateY(0) scale(1); } } 4 @keyframes cfpChipIn { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } } 5 .cfp-row:hover { background: var(--hover-bg) !important; } 6 .cfp-chip-x:hover { background: color-mix(in srgb,#ef4444 14%,transparent) !important; color: #ef4444 !important; } 7 .cfp-opt:hover { border-color: color-mix(in srgb,var(--color-brand) 40%,transparent) !important; } 8 `}),e.jsxs("button",{type:"button",onClick:()=>d(S=>!S),"aria-expanded":p,"aria-haspopup":"dialog",title:L?`${R} filter group${R===1?"":"s"} active`:"Filter this list",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:8,border:`1px solid ${p||L?"color-mix(in srgb,var(--color-brand) 45%,transparent)":"var(--border-color)"}`,background:p||L?"color-mix(in srgb,var(--color-brand) 10%,transparent)":"var(--card-bg)",color:p||L?"var(--color-brand)":"var(--text-secondary)",fontSize:12.5,fontWeight:600,cursor:"pointer",boxShadow:"var(--shadow-soft)",transition:"background 0.12s, border-color 0.12s, color 0.12s"},children:[e.jsx(Ne,{size:13,strokeWidth:2.4}),"Filters",R>0&&e.jsx("span",{style:{fontSize:10,fontWeight:700,minWidth:16,textAlign:"center",padding:"1px 5px",borderRadius:20,background:"var(--color-brand)",color:"#fff"},children:R}),e.jsx(Re,{size:12,strokeWidth:2.6,style:{transform:p?"rotate(180deg)":"none",transition:"transform 0.15s",opacity:.7}})]}),O.length>0&&e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[P.map(S=>e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,height:21,padding:S.annotator?"0 3px":"0 3px 0 8px",borderRadius:999,background:"var(--bg-tertiary)",border:"1px solid var(--border-color)",fontSize:11,fontWeight:600,color:"var(--text-secondary)",maxWidth:170,animation:"cfpChipIn 0.14s ease-out both"},children:[S.annotator?e.jsx(Kn,{a:S.annotator,size:15}):S.color?e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:S.color,flexShrink:0}}):e.jsx(Ln,{size:10,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.label}),e.jsx("button",{type:"button",className:"cfp-chip-x",onClick:S.onRemove,title:"Remove filter",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:15,height:15,borderRadius:"50%",flexShrink:0,border:0,background:"transparent",color:"var(--text-muted)",cursor:"pointer",transition:"background 0.12s, color 0.12s"},children:e.jsx(fe,{size:9,strokeWidth:3})})]},S.key)),D>0&&e.jsxs("span",{title:O.slice(Hn).map(S=>S.label).join(", "),style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:["+",D," more"]}),h!==null&&e.jsxs("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)"},children:[h," ",m]}),e.jsx("button",{type:"button",onClick:re,style:{border:0,background:"transparent",padding:"0 2px",fontSize:11.5,fontWeight:600,color:"var(--text-muted)",cursor:"pointer",textDecoration:"underline",textUnderlineOffset:3},children:"Clear all"})]}),p&&e.jsxs("div",{style:{position:"absolute",top:"calc(100% + 8px)",left:0,zIndex:60,width:"min(288px, calc(100vw - 28px))",maxHeight:"min(76vh, 500px)",background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:11,boxShadow:"0 14px 34px rgba(0,0,0,0.22)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"cfpPanelIn 0.15s cubic-bezier(0.16,1,0.3,1) both"},children:[e.jsxs("div",{title:"Any value inside a group · all groups must match",style:{display:"flex",alignItems:"center",gap:8,padding:"7px 11px",borderBottom:"1px solid color-mix(in srgb,var(--border-color) 70%,transparent)"},children:[e.jsx("span",{style:{flex:1,fontSize:12,fontWeight:700,color:"var(--text-primary)"},children:"Filters"}),K>0&&e.jsx("button",{type:"button",onClick:()=>C(vt),style:{border:0,background:"transparent",padding:0,fontSize:11,fontWeight:600,color:"var(--color-brand)",cursor:"pointer"},children:"Reset"})]}),e.jsxs("div",{style:{padding:11,display:"flex",flexDirection:"column",gap:10,overflowY:"auto",scrollbarWidth:"thin"},children:[w.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:6},children:[e.jsx("span",{style:he,children:"Status"}),e.jsx("span",{style:{flex:1}}),e.jsx("span",{style:kt,children:N.statuses.length?`${N.statuses.length} selected`:"Any"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:w.map(S=>e.jsxs("div",{children:[e.jsx("div",{title:S.hint,style:{fontSize:10.5,fontWeight:600,marginBottom:4,color:"var(--text-secondary)"},children:S.title}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:S.options.map(M=>{const F=N.statuses.includes(M.id);return e.jsxs("button",{type:"button",className:"cfp-opt",title:M.hint,"aria-pressed":F,onClick:()=>C(q=>
8({...q,statuses:Un(q.statuses,M.id)})),style:J(F,M.activeColor??M.color),children:[e.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:M.color,flexShrink:0,opacity:F?1:.55}}),M.label]},M.id)})})]},S.key))})]}),e.jsx("div",{style:jt})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:6},children:[e.jsx("span",{style:he,children:"Annotator"}),e.jsx("span",{style:{flex:1}}),e.jsx("span",{style:kt,children:N.annotatorIds.length?`${N.annotatorIds.length} selected`:"Anyone"})]}),o.length>5&&e.jsxs("div",{style:{position:"relative",marginBottom:5},children:[e.jsx(ia,{size:11,style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:"var(--text-muted)"}}),e.jsx("input",{value:f,onChange:S=>v(S.target.value),placeholder:"Search annotators...",style:{...We,paddingLeft:23}})]}),e.jsx("div",{style:{maxHeight:108,overflowY:"auto",scrollbarWidth:"thin",border:"1px solid var(--border-color)",borderRadius:8,background:"color-mix(in srgb,var(--bg-tertiary) 45%,transparent)",padding:3},children:s?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"7px 6px",fontSize:11.5,color:"var(--text-muted)"},children:[e.jsx(ee,{size:11,style:{animation:"spin 1s linear infinite"}})," Loading..."]}):o.length===0?e.jsx("div",{style:{padding:"7px 6px",fontSize:11.5,color:"var(--text-muted)"},children:u==="root"?"Nobody has annotated anything yet.":`No annotators in this ${u} yet.`}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"cfp-row",onClick:()=>C(S=>({...S,annotatorIds:[]})),style:Qe(N.annotatorIds.length===0),children:[e.jsx("span",{style:xe(N.annotatorIds.length===0),children:N.annotatorIds.length===0&&e.jsx(Pn,{size:10,strokeWidth:3.4})}),e.jsx("span",{style:{fontWeight:600},children:"Anyone"})]}),H.map(S=>{const M=N.annotatorIds.includes(S.user_id);return e.jsxs("button",{type:"button",className:"cfp-row",title:S.user_email,onClick:()=>C(F=>({...F,annotatorIds:Un(F.annotatorIds,S.user_id)})),style:Qe(M),children:[e.jsx("span",{style:xe(M),children:M&&e.jsx(Pn,{size:10,strokeWidth:3.4})}),e.jsx(Kn,{a:S,size:17}),e.jsx("span",{style:{minWidth:0,flex:1,fontWeight:550,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.user_name||S.user_email})]},S.user_id)}),H.length===0&&e.jsxs("div",{style:{padding:"7px 6px",fontSize:11.5,color:"var(--text-muted)"},children:['No match for "',f,'".']})]})})]}),e.jsx("div",{style:jt}),e.jsxs("div",{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",marginBottom:6},children:e.jsxs("span",{style:he,children:[e.jsx(Ln,{size:10})," Date range"]})}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:xi.map(S=>{const M=N.datePreset===S;return e.jsx("button",{type:"button",className:"cfp-opt",onClick:()=>C(F=>({...F,datePreset:S})),style:J(M),children:ha[S]},S)})}),N.datePreset==="custom"&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:6,marginTop:7},children:[e.jsx("input",{type:"date","aria-label":"From date",value:N.customFrom,max:N.customTo||void 0,onChange:S=>C(M=>({...M,customFrom:S.target.value})),style:We}),e.jsx("input",{type:"date","aria-label":"To date",value:N.customTo,min:N.customFrom||void 0,onChange:S=>C(M=>({...M,customTo:S.target.value})),style:We})]})]})]}),X&&e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:6,padding:"7px 11px",borderTop:"1px solid color-mix(in srgb,var(--border-color) 70%,transparent)",background:"color-mix(in srgb,var(--color-warning) 10%,transparent)",color:"var(--text-secondary)",fontSize:11,lineHeight:1.4},children:[e.jsx(Ja,{size:12,style:{color:"var(--color-warning)",flexShrink:0,marginTop:1}}),e.jsx("span",{children:'"Not started" assets have no annotator and no save date, so this combination will always come back empty.'})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:6,padding:"7px 11px",borderTop:"1px solid color-mix(in srgb,var(--border-color) 70%,transparent)",background:"color-mix(in srgb,var(--bg-tertiary) 35%,transparent)"},children:[e.jsx("button",{type:"button",onClick:()=>d(!1),style:{padding:"4px 11px",borderRadius:7,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-secondary)",fontSize:11.5,fontWeight:550,cursor:"pointer"},children:"Cancel"}),e.jsx("button",{type:"button",onClick:G,disabled:!U,style:{padding:"4px 14px",borderRadius:7,border:"none",background:U?"var(--color-brand)":"color-mix(in srgb,var(--text-muted) 25%,transparent)",color:U?"#fff":"var(--text-muted)",fontSize:11.5,fontWeight:650,cursor:U?"pointer":"default",transition:"background 0.12s"},children:"Apply"})]})]})]})}const ji={display:"flex",alignItems:"center",gap:2,padding:3,borderRadius:11,background:"var(--bg-tertiary)",border:"1px solid var(--border-color)",maxWidth:"100%",overflowX:"auto",scrollbarWidth:"none"};function Yn(n,a){return{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:8,border:0,fontSize:12,fontWeight:n?600:500,background:n?"var(--card-bg)":"transparent",color:n?a??"var(--color-brand)":"var(--text-secondary)",boxShadow:n?"var(--shadow-soft)":"none",cursor:"pointer",whiteSpace:"nowrap",transition:"background 0.15s, color 0.15s, box-shadow 0.15s"}}function Gn(n,a){return{fontSize:10,fontWeight:700,padding:"1px 6px",borderRadius:20,background:n?`color-mix(in srgb, ${a??"var(--color-brand)"} 16%, transparent)`:"var(--bg-tertiary)",color:n?a??"var(--color-brand)":"var(--text-muted)",fontVariantNumeric:"tabular-nums"}}function ki({options:n,counts:a,selected:o,onChange:s,mode:u="multi",allLabel:h="All",busy:m}){const p=o.length===0,d=v=>{if(u==="single"){s(o.length===1&&o[0]===v?[]:[v]);return}s(o.includes(v)?o.filter(I=>I!==v):[...o,v])},f=v=>({onMouseEnter:I=>{v||(I.currentTarget.style.background="var(--hover-bg)",I.currentTarget.style.color="var(--text-primary)")},onMouseLeave:I=>{v||(I.currentTarget.style.background="transparent",I.currentTarget.style.color="var(--text-secondary)")}});return e.jsxs("div",{style:{...ji,opacity:m?.6:1,transition:"opacity 0.15s"},children:[e.jsxs("button",{type:"button",onClick:()=>s([]),style:Yn(p),title:"Show everything",...f(p),children:[h,p&&a?.all!=null&&e.jsx("span",{style:Gn(p),children:a.all})]}),n.map(v=>{const I=o.includes(v.id),w=a?.[v.id],T=v.activeColor??v.color;return e.jsxs("button",{type:"button",onClick:()=>d(v.id),title:v.hint,style:Yn(I,T),...f(I),children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:v.color,opacity:I?1:.55}}),v.label,I&&w!=null&&e.jsx("span",{style:Gn(I,T),children:w})]},v.id)})]})}function Xn(n){const a=Number(new URLSearchParams(n).get("pg"));return Number.isInteger(a)&&a>0?a:1}function Si(n,a){const o=new URLSearchParams(n);a>1?o.set("pg",String(a)):o.delete("pg");const s=o.toString();return s?`?${s}`:""}const _i={uploading:{label:"IN PROGRESS",colour:"#1689d4"},partial:{label:"PARTIAL UPLOAD",colour:"#d97706"}};function gt(n){return n==="uploading"||n==="partial"?_i[n]:null}const Ht=300;function wi({segments:n}){const a=n.reduce((h,m)=>h+m.value,0);if(a<=0)return null;const o=[];let s=0;for(const h of n){if(h.value<=0)continue;const m=h.value/a*100,p=Math.min(3,m/3);o.push(`${h.color} ${(s+p).toFixed(2)}%`),o.push(`${h.color} ${(s+m-p).toFixed(2)}%`),s+=m}const u="linear-gradient(90deg, #000 0%, rgba(0, 0, 0, 0.7) 100%)";return e.jsx("div",{"aria-hidden":!0,style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${o.join(", ")})`,WebkitMaskImage:u,maskImage:u}})}function Ci(n){const a=n.reduce((m,p)=>m+p,0);if(a<=0)return n.map(()=>0);const o=n.map(m=>m/a*100),s=o.map(Math.floor);let u=100-s.reduce((m,p)=>m+p,0);const h=o.map((m,p)=>({i:p,fraction:m-s[p]}
8)).filter(({i:m})=>n[m]>0).sort((m,p)=>p.fraction-m.fraction);for(const{i:m}of h){if(u<=0)break;s[m]+=1,u-=1}return s}function Ii({title:n,segments:a,scopeTotal:o,accent:s}){const u=a.reduce((p,d)=>p+d.value,0),h=Ci(a.map(p=>p.value)),m=o>0?Math.round(u/o*100):0;return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,marginBottom:10},children:[e.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)"},children:n}),e.jsx("span",{style:{fontSize:15,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.01em"},children:u.toLocaleString()})]}),u>0?e.jsx("div",{"aria-hidden":!0,style:{display:"flex",gap:2,height:8,borderRadius:4,overflow:"hidden",marginBottom:12,animation:"dashBarReveal 0.35s cubic-bezier(0.25, 1, 0.4, 1) both"},children:a.filter(p=>p.value>0).map(p=>e.jsx("span",{style:{flex:`${p.value} 1 0%`,minWidth:4,background:p.color}},p.key))}):e.jsx("div",{"aria-hidden":!0,style:{height:8,borderRadius:4,background:"var(--bg-tertiary)",marginBottom:12}}),e.jsx("div",{style:{display:"grid",gap:9},children:a.map((p,d)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"9px 1fr auto 32px",columnGap:8,alignItems:"start",opacity:p.value>0?1:.45},children:[e.jsx("span",{style:{width:9,height:9,borderRadius:3,background:p.color,marginTop:3.5}}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",lineHeight:"16px"},children:p.label}),e.jsx("div",{style:{fontSize:10.5,color:"var(--text-muted)",fontWeight:500,lineHeight:1.4,marginTop:1},children:p.hint})]}),e.jsx("div",{style:{fontSize:12.5,fontWeight:700,color:"var(--text-primary)",fontVariantNumeric:"tabular-nums",lineHeight:"16px"},children:p.value.toLocaleString()}),e.jsxs("div",{style:{fontSize:10.5,fontWeight:600,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums",textAlign:"right",lineHeight:"16px"},children:[h[d],"%"]})]},p.key))}),o>0&&e.jsxs("div",{style:{marginTop:12,paddingTop:10,borderTop:"1px solid var(--border-color)"},children:[e.jsx("div",{"aria-hidden":!0,style:{height:3,borderRadius:1.5,marginBottom:7,background:`color-mix(in srgb, ${s} 16%, transparent)`},children:e.jsx("div",{style:{width:`${Math.min(100,u/o*100)}%`,height:"100%",borderRadius:1.5,background:s}})}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,fontSize:10.5,fontWeight:500,color:"var(--text-muted)"},children:[e.jsxs("span",{children:[u.toLocaleString()," of ",o.toLocaleString()," assets in scope"]}),e.jsxs("span",{style:{fontWeight:600,fontVariantNumeric:"tabular-nums"},children:[m,"%"]})]})]})]})}const Pi={annotated:{key:"annotated",label:"Annotated",color:"var(--pole-annotated)",hint:"Measured, nothing flagged"},annotatedFlagged:{key:"annotatedFlagged",label:"Annotated + flagged",color:"var(--pole-annotated-flagged)",hint:"Measured, but flagged for review"},skipped:{key:"skipped",label:"Skipped",color:"var(--pole-skipped)",hint:"Opened but not annotated"},notStarted:{key:"notStarted",label:"Not started",color:"var(--pole-not-started)",hint:"Nobody has opened this asset yet"}};function ja(n,a){return a.map(o=>({...Pi[o],value:n[o]}))}function Ti(n){return ja(n,["annotated","annotatedFlagged","skipped"])}function zi(n){return ja(n,["notStarted"])}function ka(n){return{batch_id:n.batch_id,batch_name:n.batch_name,circuit_id:n.circuit_id||"",circuit_name:n.circuit_name||"",project_id:n.project_id,project_name:n.project_name||"",total_poles:0,annotated_poles:0,flagged_poles:0,flag_only_poles:0,in_progress_poles:0,last_activity:null,created_on:null}}function Ni(n){const a=new Map;for(const o of n){a.has(o.project_id)||a.set(o.project_id,new Map);const s=a.get(o.project_id),u=o.circuit_name||"";s.has(u)||s.set(u,[]),s.get(u).push(o)}return Array.from(a.entries()).map(([o,s])=>{const h=Array.from(s.values()).flat().find(d=>d.project_name)?.project_name??o,m=Array.from(s.entries()).filter(([d,f])=>d!==""||f.some(v=>!!v.batch_id)).map(([d,f])=>{const v=f.filter(w=>!!w.batch_id),I=v.filter(w=>w.total_poles>0&&te(w)>=w.total_poles).length;return{circuitName:d,circuitId:f[0]?.circuit_id||"",projectId:o,batches:v,totalPoles:v.reduce((w,T)=>w+T.total_poles,0),annotatedPoles:v.reduce((w,T)=>w+T.annotated_poles,0),finishedPoles:v.reduce((w,T)=>w+te(T),0),flaggedPoles:v.reduce((w,T)=>w+(T.flagged_poles||0),0),completedBatches:I,lastActivity:v.reduce((w,T)=>T.last_activity?w?T.last_activity>w?T.last_activity:w:T.last_activity:w,null),lastModified:v.reduce((w,T)=>T.created_on?w?T.created_on>w?T.created_on:w:T.created_on:w,null)}}),p=m.filter(d=>d.batches.length>0&&d.completedBatches===d.batches.length).length;return{projectId:o,projectName:h,circuits:m,totalPoles:m.reduce((d,f)=>d+f.totalPoles,0),annotatedPoles:m.reduce((d,f)=>d+f.annotatedPoles,0),finishedPoles:m.reduce((d,f)=>d+f.finishedPoles,0),flaggedPoles:m.reduce((d,f)=>d+f.flaggedPoles,0),completedCircuits:p,lastActivity:m.reduce((d,f)=>f.lastActivity?d?f.lastActivity>d?f.lastActivity:d:f.lastActivity:d,null),lastModified:m.reduce((d,f)=>f.lastModified?d?f.lastModified>d?f.lastModified:d:f.lastModified:d,null)}})}let qn=!1;function Mi(n,a){const o=me.getState();for(const s of n){if(o.tasks.some(h=>h.jobId===s.job_id))continue;const u=`Rename ${s.entity_type} · "${s.old_name}" â "${s.new_name}" (interrupted)`;o.addTask({id:`stale-${s.job_id}`,type:"rename",label:u,status:"interrupted",progress:0,canCancel:!0,jobId:s.job_id,cancel:async()=>{try{const h=await A.undoRenameJob(s.job_id);h&&h.already_completed?Y.success(`Rename had already completed - "${s.new_name}" is the current name`):Y.success(`Undo complete - "${s.old_name}" is unchanged`),a()}catch(h){Y.error(h.message)}}})}}const Vn={root:"projects",project:"circuits",circuit:"batches",batch:"assets",pole:"files"};function Ri(n,a,o="desc"){const s=(p,d)=>o==="desc"?(d??"").localeCompare(p??""):(p??"").localeCompare(d??""),u=(p,d)=>d>0?p/d:0,h=(p,d)=>o==="desc"?d.localeCompare(p):p.localeCompare(d),m=(p,d)=>o==="desc"?d-p:p-d;return[...n].sort((p,d)=>a==="name"?h(p.projectName,d.projectName):a==="progress"?m(u(p.finishedPoles,p.totalPoles),u(d.finishedPoles,d.totalPoles)):s(p.lastModified,d.lastModified)).map(p=>({...p,circuits:[...p.circuits].sort((d,f)=>a==="name"?h(d.circuitName,f.circuitName):a==="progress"?m(u(d.finishedPoles,d.totalPoles),u(f.finishedPoles,f.totalPoles)):s(d.lastModified,f.lastModified)).map(d=>({...d,batches:[...d.batches].sort((f,v)=>a==="name"?h(f.batch_name,v.batch_name):a==="progress"?m(u(te(f),f.total_poles),u(te(v),v.total_poles)):s(f.created_on,v.created_on))}))}))}function Er(n){if(!n)return"";try{const a=Date.now()-new Date(n).getTime(),o=Math.floor(a/864e5);return o===0?"Today":o===1?"Yesterday":o<7?`${o}d ago`:o<30?`${Math.floor(o/7)}w ago`:o<365?`${Math.floor(o/30)}mo ago`:new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}catch{return n}}function mt(n){return Er(n)||"No uploads"}function Xe(n){return Er(n)||"Not started"}function qe({count:n,title:a}){const o=typeof n=="boolean"?n?1:0:n??0;return o?e.jsx("span",{title:a??(o===1?"Contains a flagged asset":`${o} assets flagged for review`),style:{display:"inline-flex",alignItems:"center",color:"var(--pole-flagged)",flexShrink:0},children:e.jsx(qo,{size:12,strokeWidth:2.5})}):null}function Jn(n,a){return n?Er(n):a!=="none"?"Unknown":"Not started"}const Sa=[{key:"projects",label:"Projects",icon:Wr,accent:"#1a4576",hiddenAt:["project","circuit","batch","pole"]},{key:"circuits",label:"Circuits",icon:Kt,accent:"#7c5cf0",hiddenAt:["circuit","batch","pole"]},{key:"batches",label:"Batches",icon:Rr,accent:"#0e9aa7",hiddenAt:["batch","pole"]},{key:"poles",label:"Assets",icon:Yt,accent:"#1689d4",hiddenAt:["pole"],info:"An asset is a pole or a midspan - a midsp
8an is the span of wires between poles."},{key:"annotated",label:"Complete",icon:go,accent:"var(--pole-annotated)",hiddenAt:["pole"]},{key:"remaining",label:"Remaining",icon:Xo,accent:"var(--pole-not-started)",hiddenAt:["pole"]}];function Wi(n){return Sa.filter(a=>!a.hiddenAt.includes(n)).map(a=>a.key)}const Ai="(max-width: 1099px)";function Di(n,a){const o=Math.max(n,1);return a&&o>3?Math.ceil(o/2):o}function Ei({label:n,value:a,icon:o,accent:s,sub:u,info:h,segments:m,scopeTotal:p}){const[d,f]=i.useState(null),v=i.useRef(null),I=i.useRef(null),[w,T]=i.useState(null),N=i.useCallback(()=>{const C=I.current?.getBoundingClientRect();if(!C||!m?.length)return;const L=C.left+C.width/2,R=Math.max(8,Math.min(L-Ht/2,window.innerWidth-Ht-8));T({top:C.bottom+10,left:R,caretX:Math.max(16,Math.min(L-R,Ht-16))})},[m]);return i.useEffect(()=>{if(!d)return;const C=R=>{v.current?.contains(R.target)||f(null)},L=R=>{R.key==="Escape"&&f(null)};return document.addEventListener("mousedown",C),document.addEventListener("keydown",L),()=>{document.removeEventListener("mousedown",C),document.removeEventListener("keydown",L)}},[d]),e.jsxs("div",{style:{position:"relative",background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:12,padding:"14px 16px",display:"flex",flexDirection:"column",gap:8,height:"100%",boxShadow:"var(--shadow-card)",overflow:"hidden",transition:"transform 0.18s cubic-bezier(0.4,0,0.2,1), box-shadow 0.18s ease, border-color 0.18s ease"},ref:I,onMouseEnter:C=>{C.currentTarget.style.transform="translateY(-2px)",C.currentTarget.style.boxShadow="var(--shadow-elevated)",C.currentTarget.style.borderColor=`color-mix(in srgb, ${s} 40%, var(--border-color))`,N()},onMouseLeave:C=>{C.currentTarget.style.transform="translateY(0)",C.currentTarget.style.boxShadow="var(--shadow-card)",C.currentTarget.style.borderColor="var(--border-color)",T(null)},onClick:()=>w?T(null):N(),children:[m?.length?e.jsx(wi,{segments:m}):e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:3,background:`linear-gradient(90deg, ${s}, color-mix(in srgb, ${s} 35%, transparent))`}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:11,fontWeight:700,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:"0.06em",display:"flex",alignItems:"center",gap:4},children:[n,h&&e.jsx("button",{ref:v,onClick:()=>{const C=v.current?.getBoundingClientRect();f(d||!C?null:{top:C.bottom+6,left:Math.min(C.left,window.innerWidth-260)})},title:"What's this?",style:{display:"flex",border:0,background:"transparent",padding:0,cursor:"pointer",color:d?"var(--color-brand)":"var(--text-muted)"},children:e.jsx(yo,{size:11,strokeWidth:2.2})}),h&&d&&Mr.createPortal(e.jsx("div",{style:{position:"fixed",top:d.top,left:d.left,zIndex:1e4,maxWidth:250,background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:8,boxShadow:"var(--shadow-elevated)",padding:"8px 11px",fontSize:11.5,fontWeight:500,lineHeight:1.55,color:"var(--text-secondary)",textTransform:"none",letterSpacing:"normal",animation:"dashFadeUp 0.15s ease-out"},children:h}),document.body)]}),e.jsx("div",{style:{width:24,height:24,borderRadius:6,background:`color-mix(in srgb, ${s} 15%, transparent)`,color:s,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(o,{size:13,strokeWidth:2.2})})]}),e.jsx("div",{style:{fontSize:26,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1},children:typeof a=="number"?a.toLocaleString():a}),e.jsx("div",{style:{fontSize:10.5,color:"var(--text-muted)",fontWeight:600,lineHeight:"14px",minHeight:14},children:u??""}),m&&m.length>0&&w&&Mr.createPortal(e.jsxs("div",{style:{position:"fixed",top:w.top,left:w.left,zIndex:1e4,width:Ht,boxSizing:"border-box",background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:12,boxShadow:"var(--shadow-elevated)",padding:"13px 15px 12px",pointerEvents:"none",transformOrigin:`${w.caretX}px -8px`,animation:"dashPopIn 0.18s cubic-bezier(0.2, 0.9, 0.3, 1) both"},children:[e.jsx("span",{"aria-hidden":!0,style:{position:"absolute",top:-5.5,left:w.caretX-5,width:10,height:10,background:"var(--card-bg)",borderTop:"1px solid var(--border-color)",borderLeft:"1px solid var(--border-color)",transform:"rotate(45deg)",borderTopLeftRadius:2}}),e.jsx(Ii,{title:n,segments:m,scopeTotal:p??0,accent:s})]}),document.body)]})}function Li({level:n,kpis:a}){const o=Wi(n),s=oa(),u=ho(Ai);return e.jsx("div",{style:{display:"grid",gridTemplateColumns:s?"repeat(2, minmax(0, 1fr))":`repeat(${Di(o.length,u)}, minmax(0, 1fr))`,alignItems:"stretch",gap:10,transition:"grid-template-columns 0.38s cubic-bezier(0.4, 0, 0.2, 1), gap 0.3s ease"},children:o.map((h,m)=>{const p=Sa.find(v=>v.key===h),d=h==="annotated"&&a.poles>0?`${Dr(a.annotated,a.poles)}% complete`:void 0,f=h==="annotated"?Ti(a.breakdown):h==="remaining"?zi(a.breakdown):void 0;return e.jsx("div",{style:{minWidth:0,height:"100%",animation:"dashKpiIn 0.38s cubic-bezier(0.34, 1.2, 0.64, 1) both",animationDelay:`${m*40}ms`},children:e.jsx(Ei,{label:p.label,value:a[h],icon:p.icon,accent:p.accent,sub:d,info:p.info,segments:f,scopeTotal:a.poles})},h)})})}function ft({completed:n,total:a}){const o=Dr(n,a),s=vo(n,a),u=n>0,[h,m]=i.useState(0);return i.useEffect(()=>{const p=requestAnimationFrame(()=>m(o));return()=>cancelAnimationFrame(p)},[o]),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,width:"100%"},children:[e.jsx("div",{style:{flex:1,minWidth:24,maxWidth:80,height:3.5,background:"var(--bg-tertiary)",borderRadius:999,overflow:"hidden"},children:e.jsx("div",{style:{width:`${h}%`,height:"100%",borderRadius:999,background:s?"linear-gradient(90deg, #22c07a, var(--color-success))":u?"linear-gradient(90deg, var(--sky-400), var(--sky-600))":"color-mix(in srgb, var(--text-muted) 45%, transparent)",transition:"width 0.7s cubic-bezier(0.4, 0, 0.2, 1)"}})}),e.jsxs("span",{className:"sw-num",style:{fontSize:10,fontWeight:600,color:"var(--text-secondary)",whiteSpace:"nowrap",flexShrink:0,minWidth:52,textAlign:"left"},children:[n,"/",a]})]})}function $i(n){if(n.length===0)return"";const a=new URLSearchParams;for(const o of n)o.level==="project"?(a.set("p",o.id),a.set("pn",o.name)):o.level==="circuit"?(a.set("c",o.id
8),a.set("cn",o.name),o.projectId&&a.set("p",o.projectId)):o.level==="batch"?(a.set("b",o.id),a.set("bn",o.name),o.projectId&&a.set("p",o.projectId),o.circuitName&&a.set("cn",o.circuitName)):o.level==="pole"&&(a.set("pole",o.id),a.set("polen",o.name));return a.toString()}function Fi(n,a){const o=new URLSearchParams(n),s=[],u=o.get("p"),h=o.get("pn");u&&h&&s.push({id:u,name:h,level:"project"});const m=o.get("c"),p=o.get("cn"),d=p&&u&&(m||a.find(T=>T.project_id===u&&T.circuit_name===p)?.circuit_id)||"";d&&p&&u&&s.push({id:d,name:p,level:"circuit",projectId:u,circuitName:p});const f=o.get("b"),v=o.get("bn");if(f&&v&&u){const T=a.find(N=>N.batch_id===f)??ka({batch_id:f,batch_name:v,circuit_id:m||"",circuit_name:p||"",project_id:u,project_name:h||""});s.push({id:f,name:v,level:"batch",projectId:u,circuitName:p||T.circuit_name,batchSummary:T})}const I=o.get("pole"),w=o.get("polen");return I&&w&&s.push({id:I,name:w,level:"pole"}),s}function Bi(n,a){return n.length!==a.length?!1:n.every((o,s)=>o.level===a[s].level&&o.id===a[s].id)}const xt="minmax(160px,2fr) minmax(52px,0.6fr) minmax(110px,1.3fr) minmax(76px,0.9fr) minmax(76px,0.9fr) minmax(150px,1.1fr)",Qn="minmax(160px,1.6fr) minmax(80px,0.8fr) minmax(80px,0.8fr) minmax(150px,1.4fr) minmax(100px,0.9fr)",Zn="minmax(160px,1.5fr) minmax(90px,0.8fr) minmax(78px,0.7fr) minmax(80px,0.8fr) minmax(140px,1.2fr) minmax(100px,0.9fr)",ea="minmax(0,1fr) 76px minmax(0,1fr) 96px",ta="minmax(160px,2fr) minmax(52px,0.6fr) minmax(110px,1.3fr) minmax(76px,0.9fr) minmax(76px,0.9fr) minmax(90px,0.9fr) minmax(176px,1.1fr)",Oi=16,bt={fontSize:12,fontWeight:700,fontFamily:"monospace",color:"var(--text-primary)"};function Ve({label:n,column:a,activeSortBy:o,sortDir:s,onSort:u,style:h}){const[m,p]=i.useState(!1),d=o===a,f=d||m;return e.jsxs("button",{onClick:()=>u(a),onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{display:"flex",alignItems:"center",gap:4,background:"transparent",border:0,padding:0,cursor:"pointer",fontSize:10.5,fontWeight:700,letterSpacing:"0.07em",textTransform:"uppercase",color:d?"var(--color-brand)":"var(--text-secondary)",whiteSpace:"nowrap",...h},children:[n,e.jsx("span",{style:{display:"inline-flex",opacity:f?1:0,transition:"opacity 0.15s, transform 0.2s",transform:f?"scaleY(1)":"scaleY(0)",color:d?"var(--color-brand)":"var(--text-secondary)"},children:d&&s==="asc"?e.jsx(Re,{size:11,strokeWidth:2.5,style:{transform:"rotate(180deg)"}}):e.jsx(Re,{size:11,strokeWidth:2.5})})]})}const ra=190;function Hi({x:n,y:a,options:o,onClose:s,expandLeft:u}){const h=i.useRef(null);i.useEffect(()=>{const d=f=>{h.current&&!h.current.contains(f.target)&&s()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[s]);const m=u?n-ra:Math.max(n,8),p=Math.min(a,window.innerHeight-o.length*38-12);return e.jsx("div",{ref:h,style:{position:"fixed",left:m,top:p,zIndex:600,background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:10,overflow:"hidden",boxShadow:"0 8px 32px rgba(0,0,0,0.18)",minWidth:ra,padding:"4px 0"},children:o.map((d,f)=>e.jsxs("button",{onClick:()=>{d.onClick(),s()},disabled:d.disabled,style:{display:"flex",alignItems:"center",gap:9,width:"100%",padding:"8px 14px",background:"transparent",border:0,cursor:d.disabled?"default":"pointer",fontSize:12.5,color:d.danger?"#ef4444":d.disabled?"var(--text-muted)":"var(--text-primary)",textAlign:"left",opacity:d.disabled?.5:1,borderTop:d.danger&&f>0?"1px solid var(--border-color)":"none",marginTop:d.danger&&f>0?4:0},onMouseEnter:v=>{d.disabled||(v.currentTarget.style.background=d.danger?"color-mix(in srgb,#ef4444 8%,transparent)":"var(--hover-bg)")},onMouseLeave:v=>{v.currentTarget.style.background="transparent"},children:[d.icon&&e.jsx(d.icon,{size:13,strokeWidth:2,style:{flexShrink:0}}),d.label]},f))})}function yt({isOpen:n,onClick:a}){return e.jsx("button",{type:"button",title:"More actions",className:"sw-icon-btn","aria-expanded":n,style:Me,onMouseDown:o=>o.stopPropagation(),onClick:a,onMouseEnter:o=>{o.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:e.jsx(fo,{size:12,strokeWidth:2.5})})}function Je({title:n,onClick:a}){return e.jsx("button",{type:"button",title:n,className:"sw-icon-btn",style:{...Me,color:"#ef4444"},onClick:a,onMouseEnter:o=>{o.currentTarget.style.background="color-mix(in srgb,#ef4444 12%,transparent)"},onMouseLeave:o=>{o.currentTarget.style.background="transparent"},children:e.jsx(pe,{size:12})})}function Ui({title:n,level:a,stats:o,onClose:s}){const u=a==="project"?"#1a4576":a==="circuit"?"#7c5cf0":a==="batch"?"#0e9aa7":"#d97706";return e.jsx("div",{onClick:s,style:{position:"fixed",inset:0,zIndex:400,background:"rgba(0,0,0,0.4)",backdropFilter:"blur(3px)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{onClick:h=>h.stopPropagation(),style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:16,minWidth:320,maxWidth:400,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.25)",animation:"dashFadeUp 0.2s ease-out"},children:[e.jsxs("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[e.jsx("div",{style:{width:7,height:7,borderRadius:"50%",background:u}}),e.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-muted)"},children:a==="pole"?"asset":a})]}),e.jsx("div",{style:{fontSize:15,fontWeight:700,color:"var(--text-primary)"},children:n})]}),e.jsx("button",{onClick:s,style:{background:"transparent",border:0,cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:e.jsx(fe,{size:15})})]}),e.jsx("div",{style:{padding:"14px 18px",display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:o.map(h=>e.jsxs("div",{style:{background:"var(--bg-secondary)",borderRadius:10,padding:"10px 14px"},children:[e.jsx("div",{style:{fontSize:9.5,color:"var(--text-muted)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:4},children:h.label}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:h.accent??"var(--text-primary)",letterSpacing:"-0.02em"}
8,children:typeof h.value=="number"?h.value.toLocaleString():h.value})]},h.label))})]})})}function Ki({title:n,description:a,onConfirm:o,onClose:s}){return e.jsx("div",{onClick:s,style:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.45)",backdropFilter:"blur(3px)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{onClick:u=>u.stopPropagation(),style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:16,minWidth:"min(340px, 92vw)",maxWidth:420,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",animation:"dashFadeUp 0.2s ease-out"},children:[e.jsxs("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("div",{style:{width:30,height:30,borderRadius:8,background:"color-mix(in srgb,#ef4444 12%,transparent)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(pe,{size:14,strokeWidth:2.2,style:{color:"#ef4444"}})}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)"},children:n})]}),e.jsx("button",{onClick:s,style:{background:"transparent",border:0,cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:e.jsx(fe,{size:15})})]}),e.jsxs("div",{style:{padding:"16px 18px 20px"},children:[e.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.55},children:a}),e.jsx("p",{style:{margin:"10px 0 0",fontSize:11.5,color:"#ef4444",fontWeight:600},children:"This action cannot be undone."})]}),e.jsxs("div",{style:{padding:"0 18px 16px",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:s,style:{padding:"7px 16px",borderRadius:8,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-secondary)",fontSize:12.5,fontWeight:500,cursor:"pointer"},onMouseEnter:u=>{u.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:"Cancel"}),e.jsx("button",{onClick:()=>{o(),s()},style:{padding:"7px 16px",borderRadius:8,border:"1px solid color-mix(in srgb,#ef4444 40%,transparent)",background:"color-mix(in srgb,#ef4444 10%,transparent)",color:"#ef4444",fontSize:12.5,fontWeight:600,cursor:"pointer"},onMouseEnter:u=>{u.currentTarget.style.background="color-mix(in srgb,#ef4444 18%,transparent)"},onMouseLeave:u=>{u.currentTarget.style.background="color-mix(in srgb,#ef4444 10%,transparent)"},children:"Delete"})]})]})})}function Yi({entityType:n,currentName:a,onConfirm:o,onClose:s}){const[u,h]=i.useState(a),m=i.useRef(null);i.useEffect(()=>{setTimeout(()=>{m.current?.select()},30)},[]);const p=u.trim(),d=u?ko(u):null,f=!p||p===a||!!d,v=()=>{f||(o(p),s())};return e.jsx("div",{onClick:s,style:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.45)",backdropFilter:"blur(3px)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{onClick:I=>I.stopPropagation(),style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:16,minWidth:340,maxWidth:440,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",animation:"dashFadeUp 0.2s ease-out"},children:[e.jsxs("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)",textTransform:"capitalize"},children:["Rename ",n]}),e.jsx("button",{onClick:s,style:{background:"transparent",border:0,cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:e.jsx(fe,{size:15})})]}),e.jsxs("div",{style:{padding:"16px 18px 20px"},children:[e.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"New name"}),e.jsx("input",{ref:m,value:u,onChange:I=>h(I.target.value),onKeyDown:I=>{I.key==="Enter"&&v(),I.key==="Escape"&&s()},style:{width:"100%",boxSizing:"border-box",padding:"8px 12px",borderRadius:8,border:`1px solid ${d?"var(--color-danger, #dc2626)":"var(--border-color)"}`,background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:13,fontFamily:"monospace",outline:"none"}}),d&&e.jsx("div",{style:{marginTop:6,fontSize:11.5,color:"var(--color-danger, #dc2626)"},children:d})]}),e.jsxs("div",{style:{padding:"0 18px 16px",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:s,style:{padding:"7px 16px",borderRadius:8,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-secondary)",fontSize:12.5,fontWeight:500,cursor:"pointer"},onMouseEnter:I=>{I.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:I=>
8{I.currentTarget.style.background="transparent"},children:"Cancel"}),e.jsx("button",{onClick:v,disabled:f,style:{padding:"7px 16px",borderRadius:8,border:0,background:f?"var(--bg-tertiary)":"var(--color-brand)",color:f?"var(--text-muted)":"white",fontSize:12.5,fontWeight:600,cursor:f?"default":"pointer",opacity:f?.6:1},children:"Rename"})]})]})})}function Gi({projectId:n,projectName:a,onClose:o}){const[s,u]=i.useState("both"),[h,m]=i.useState([]),[p,d]=i.useState(!0),[f,v]=i.useState(!1),[I,w]=i.useState("");i.useEffect(()=>{A.getProjectInputModes(n).then(C=>{u(C.input_modes),m(C.org_modes)}).catch(()=>w("Could not load the current setting.")).finally(()=>d(!1))},[n]);const T=async()=>{v(!0),w("");try{await A.setProjectInputModes(n,s),o()}catch{w("Could not save. Please try again."),v(!1)}},N=[{key:"drone",label:"Drone capture only",hint:"Flight CSV + multiple shots per pole"},{key:"standard",label:"Standard batch only",hint:"Batch CSV + one image + one-row pole CSV"},{key:"both",label:"Both",hint:"Accept either format (within the organisation allowance)"}];return e.jsx("div",{onClick:o,style:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.45)",backdropFilter:"blur(3px)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:16,minWidth:340,maxWidth:440,overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.28)",animation:"dashFadeUp 0.2s ease-out"},children:[e.jsxs("div",{style:{padding:"14px 18px 12px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)"},children:["Input data mode - ",a]}),e.jsx("button",{onClick:o,style:{background:"transparent",border:0,cursor:"pointer",color:"var(--text-muted)",padding:4,display:"flex"},children:e.jsx(fe,{size:15})})]}),e.jsxs("div",{style:{padding:"16px 18px 20px"},children:[p?e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)"},children:"Loading..."}):e.jsxs(e.Fragment,{children:[N.map(C=>e.jsxs("label",{style:{display:"block",margin:"8px 0",cursor:"pointer"},children:[e.jsx("input",{type:"radio",checked:s===C.key,onChange:()=>u(C.key)})," ",e.jsx("strong",{style:{fontSize:13,color:"var(--text-primary)"},children:C.label}),e.jsx("div",{style:{fontSize:12,color:"var(--text-muted)",marginLeft:20},children:C.hint})]},C.key)),e.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",marginTop:8},children:["Organisation allows: ",h.join(", ")||"drone",". The effective allowance is the overlap of both settings."]})]}),I&&e.jsx("div",{style:{color:"crimson",fontSize:12,marginTop:8},children:I})]}),e.jsxs("div",{style:{padding:"0 18px 16px",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:o,style:{padding:"7px 16px",borderRadius:8,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-secondary)",fontSize:12.5,fontWeight:500,cursor:"pointer"},onMouseEnter:C=>{C.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:C=>{C.currentTarget.style.background="transparent"},children:"Cancel"}),e.jsx("button",{onClick:T,disabled:p||f,style:{padding:"7px 16px",borderRadius:8,border:0,background:p||f?"var(--bg-tertiary)":"var(--color-brand)",color:p||f?"var(--text-muted)":"white",fontSize:12.5,fontWeight:600,cursor:p||f?"default":"pointer",opacity:p||f?.6:1},children:f?"Saving...":"Save"})]})]})})}function na({page:n,totalPages:a,total:o,label:s,onPrev:u,onNext:h,indent:m=0}){if(a<=1)return null;const p=d=>({display:"flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:5,border:"1px solid var(--border-color)",background:"transparent",color:d?"var(--text-muted)":"var(--text-secondary)",cursor:d?"default":"pointer",fontSize:13,fontWeight:500,opacity:d?.35:1,transition:"border-color 0.1s, color 0.1s"});return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:`5px 18px 5px ${18+m}px`,borderTop:"1px solid color-mix(in srgb,var(--border-color) 60%,transparent)",background:"var(--bg-tertiary)"}
8,children:[e.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)",flex:1},children:[o," ",s," · page ",n," of ",a]}),e.jsx("button",{onClick:u,disabled:n<=1,style:p(n<=1),onMouseEnter:d=>{n>1&&(d.currentTarget.style.borderColor="var(--color-brand)",d.currentTarget.style.color="var(--color-brand)")},onMouseLeave:d=>{d.currentTarget.style.borderColor="var(--border-color)",d.currentTarget.style.color="var(--text-secondary)"},children:"â¹"}),e.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:"var(--text-secondary)",minWidth:14,textAlign:"center"},children:n}),e.jsx("button",{onClick:h,disabled:n>=a,style:p(n>=a),onMouseEnter:d=>{n<a&&(d.currentTarget.style.borderColor="var(--color-brand)",d.currentTarget.style.color="var(--color-brand)")},onMouseLeave:d=>{d.currentTarget.style.borderColor="var(--border-color)",d.currentTarget.style.color="var(--text-secondary)"},children:"âº"})]})}function Xi({fileKey:n,size:a=40}){const[o,s]=i.useState(null);return i.useEffect(()=>{let u=!1;return A.getThumbnailPresignedUrl(n,100).then(h=>{u||s(h)}).catch(()=>{}),()=>{u=!0}},[n]),o?e.jsx("img",{src:o,alt:"",style:{width:a,height:a,objectFit:"cover",borderRadius:7,border:"1px solid color-mix(in srgb,#10b981 25%,transparent)",flexShrink:0}}):e.jsx("div",{style:{width:a,height:a,borderRadius:7,flexShrink:0,background:"color-mix(in srgb,#10b981 14%,transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(sa,{size:a*.45,strokeWidth:1.5,style:{color:"#10b981"}})})}function qi({fileKey:n,title:a,onClose:o}){const[s,u]=i.useState(null),h=i.useRef(null),m=i.useRef(null),p=i.useRef(1),d=i.useRef(0),f=i.useRef(0),v=i.useRef(!1),I=i.useRef({x:0,y:0,ox:0,oy:0});i.useEffect(()=>{let R=!1;return A.getImageUrl(n).then(O=>{R||u(O)}).catch(()=>{}),()=>{R=!0}},[n]),i.useEffect(()=>{p.current=1,d.current=0,f.current=0,w()},[n]);const w=i.useCallback(()=>{const R=m.current;R&&(R.style.transform=`translate(${d.current}px, ${f.current}px) scale(${p.current})`)},[]),T=i.useCallback(()=>{const R=h.current,O=m.current;if(!R||!O)return;const P=R.clientWidth,D=R.clientHeight,H=O.clientWidth,U=O.clientHeight,K=H*p.current,G=U*p.current,X=Math.max(0,(K-P)/2),re=Math.max(0,(G-D)/2);d.current=Math.max(-X,Math.min(X,d.current)),f.current=Math.max(-re,Math.min(re,f.current))},[]);i.useEffect(()=>{const R=h.current;if(!R)return;const O=P=>{if(P.preventDefault(),P.stopPropagation(),P.ctrlKey||P.metaKey){const D=R.getBoundingClientRect(),H=P.clientX-D.left-D.width/2,U=P.clientY-D.top-D.height/2,K=1-P.deltaY*.01,G=Math.min(20,Math.max(.1,p.current*K)),X=G/p.current;d.current=H+(d.current-H)*X,f.current=U+(f.current-U)*X,p.current=G}else d.current-=P.deltaX,f.current-=P.deltaY;T(),w()};return R.addEventListener("wheel",O,{passive:!1}),()=>R.removeEventListener("wheel",O)},[T,w]);const N=R=>{R.button===0&&(v.current=!0,I.current={x:R.clientX,y:R.clientY,ox:d.current,oy:f.current},R.preventDefault())},C=R=>{v.current&&(d.current=I.current.ox+(R.clientX-I.current.x),f.current=I.current.oy+(R.clientY-I.current.y),T(),w())},L=()=>{v.current=!1};return e.jsxs("div",{style:{position:"fixed",inset:0,zIndex:500,display:"flex",flexDirection:"column",background:"var(--bg-primary)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-color)",flexShrink:0},children:[e.jsx("span",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),e.jsxs("button",{onClick:o,style:{display:"flex",alignItems:"center",gap:5,background:"transparent",border:"1px solid var(--border-color)",borderRadius:7,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 10px",fontSize:12,flexShrink:0},children:[e.jsx(fe,{size:13})," Close"]})]}),e.jsx("div",{ref:h,onMouseDown:N,onMouseMove:C,onMouseUp:L,onMouseLeave:L,style:{flex:1,minHeight:0,overflow:"hidden",position:"relative",cursor:"grab",display:"flex",alignItems:"center",justifyContent:"center"},children:s?e.jsx("img",{ref:m,src:s,alt:a,draggable:!1,onLoad:w,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",transformOrigin:"center center",transform:"translate(0px, 0px) scale(1)",userSelect:"none",pointerEvents:"none"}}):e.jsx(ee,{size:28,style:{color:"var(--color-brand)",animation:"spin 1s linear infinite"}})}),e.jsx("div",{style:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",fontSize:11,color:"var(--text-muted)",background:"var(--bg-secondary)",border:"1px solid var(--border-color)",borderRadius:6,padding:"3px 10px",pointerEvents:"none"},children:"Pinch or Ctrl+scroll to zoom · drag to pan"})]})}function Vi({title:n,files:a,onClose:o}){const[s,u]=i.useState(0),h=a[s];return h?e.jsx("div",{onClick:o,style:{position:"fixed",inset:0,zIndex:500,background:"rgba(0,0,0,0.65)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:e.jsxs("div",{onClick:m=>m.stopPropagation(),style:{background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:14,width:"90vw",maxWidth:920,maxHeight:"80vh",display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 20px 60px rgba(0,0,0,0.3)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"11px 16px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(la,{size:13,style:{color:"#6366f1"}}),e.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",fontFamily:"monospace"},children:n}),a.length>1&&a.map((m,p)=>e.jsx("button",{onClick:()=>u(p),style:{padding:"3px 8px",borderRadius:5,fontSize:11,cursor:"pointer",border:`1px solid ${s===p?"var(--color-brand)":"var(--border-color)"}`,background:s===p?"color-mix(in srgb,var(--color-brand) 10%,transparent)":"transparent",color:s===p?"var(--color-brand)":"var(--text-muted)",fontWeight:s===p?600:400},children:m.filename},p)),e.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:[h.row_count," rows · ",h.columns.length," cols"]})]}),e.jsx("button",{onClick:o,style:{background:"transparent",border:0,cursor:"pointer",color:"var(--text-muted)",display:"flex"},children:e.jsx(fe,{size:15})})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{children:e.jsx("tr",{children:h.columns.map(m=>e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontWeight:700,fontSize:10,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-muted)",borderBottom:"1px solid var(--border-color)",background:"var(--bg-secondary)",whiteSpace:"nowrap",position:"sticky",top:0},children:m},m))})}),e.jsx("tbody",{children:h.rows.map((m,p)=>e.jsx("tr",{style:{borderTop:p>0?"1px solid color-mix(in srgb,var(--border-color) 50%,transparent)":"none"},children:h.columns.map(d=>e.jsx("td",{style:{padding:"7px 12px",color:"var(--text-primary)",fontFamily:"monospace",fontSize:11,whiteSpace:"nowrap",maxWidth:200,overflow:"hidden",textOverflow:"ellipsis"},children:m[d]==null?e.jsx("span",{style:{color:"var(--text-muted)"},children:"-"}):String(m[d])},d))},p))})]})})]})}):null}function Ji({admin:n}){const a=Za(),o=eo(),s=to(),u=oa(),h=u?14:32,[m,p]=i.useState(!1),d=i.useRef(null),f=i.useCallback(t=>{d.current?.disconnect(),t&&typeof ResizeObserver<"u"&&(d.current=ne
8w ResizeObserver(l=>{p(l[0].contentRect.width<900)}),d.current.observe(t))},[]),[v,I]=i.useState([]),[w,T]=i.useState(!0),[N,C]=i.useState(null),[L,R]=i.useState(null),[O,P]=i.useState(null),[D,H]=i.useState(null),[U,K]=i.useState(null),[G,X]=i.useState(!1),[re,he]=i.useState(""),We=i.useRef(o.search);i.useEffect(()=>{We.current!==o.search&&(We.current=o.search,X(!1))},[o.search]);const[J,Qe]=i.useState(0),[xe,jt]=i.useState({}),[kt,S]=i.useState([]),[M,F]=i.useState(!1),[q,Xt]=i.useState(null),[_a,wa]=i.useState(null),[Lr,Ca]=i.useState(null),[V,Ia]=i.useState("activity"),[Q,Pa]=i.useState("desc"),Ze=Te(t=>t.refreshKey),[ne,qt]=i.useState(()=>Xn(o.search)),[ae,Vt]=i.useState(()=>{const t=localStorage.getItem("dashboard-page-size");return t?Number(t):25}),[St,et]=i.useState(0),[Jt,tt]=i.useState(0),[$r,Fr]=i.useState([]),[Br,Or]=i.useState([]),[Ae,rt]=i.useState(!1),[_t,Hr]=i.useState(null),[wt,Ta]=i.useState(null),[be,Ur]=i.useState(null),[Qt,Kr]=i.useState(null),[za,Na]=i.useState(new Set),[Ma,Ra]=i.useState(new Set),[Ct,Wa]=i.useState(25),It=8,Pt=10,[Zt,er]=i.useState(1),[tr,rr]=i.useState({}),[nr,ar]=i.useState({}),[$,Yr]=i.useState([]),ye=i.useRef([]);i.useEffect(()=>{ye.current=$},[$]);const[Gr,or]=i.useState([]),[nt,ir]=i.useState(!1),[ve,Xr]=i.useState(null),[Aa,qr]=i.useState(!1),[Vr,Jr]=i.useState(!1),[Da,sr]=i.useState(null),[Qr,lr]=i.useState([]),[Zr,cr]=i.useState(!1),dr=i.useRef(null),[Ea,De]=i.useState(!1);i.useEffect(()=>{const t=l=>{dr.current&&!dr.current.contains(l.target)&&De(!1)};return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[]);const[ie,ur]=i.useState(null),[Tt,Z]=i.useState(null),[pr,en]=i.useState(null),[hr,tn]=i.useState(null),[Ee,gr]=i.useState(null),[Le,mr]=i.useState(null),se=i.useCallback(t=>new Promise(l=>mr({title:t.title,message:t.message,confirmLabel:t.confirmLabel??"Delete",resolve:l})),[]),j=$.length===0?"root":$[$.length-1].level,k=$[$.length-1]??null,je=_o(j==="batch"?k?.id??null:null),$e=`${j}:${k?.id??""}`,ke=j==="batch"||j==="pole",fr=!ke,xr=i.useMemo(()=>$.find(t=>t.level==="circuit")?.id??null,[$]),at=i.useMemo(()=>$.find(t=>t.level==="batch")?.id??null,[$]),br=i.useMemo(()=>$.find(t=>t.level==="project")?.id??null,[$]),yr=i.useMemo(()=>pi(j,$,at),[j,$,at]),rn=yr[0],le=i.useMemo(()=>hi(xe,yr),[xe,yr]),vr=i.useCallback(t=>{jt(l=>({...l,[rn]:t}))},[rn]),La=i.useCallback(t=>{vr({...le,statuses:t})},[le,vr]),Se=i.useMemo(()=>On(le),[le]),nn=j==="batch"||j==="pole"?"batch":j,$a=nn==="batch"?Ao:Do,Fa=j==="batch"?q:j==="root"?_a:_t?.scopeKey===$e?_t.facets:null,an=j==="root"?w:j==="batch"?nt:Ae,zt=i.useMemo(()=>On(xe.root??vt),[xe]),on=i.useRef(zt);i.useEffect(()=>{on.current=zt},[zt]);const jr=i.useCallback(async t=>{T(!0),C(null);try{if(await A.reconcileUploadSessions().catch(()=>{}),t?.aborted)return;const l=n&&!qn,[r,b,g]=await Promise.all([A.getDashboardBatches(on.current),n?A.getCleanupStatus().catch(()=>null):Promise.resolve(null),l?A.getStaleRenameJobs().catch(()=>[]):Promise.resolve([])]);if(t?.aborted)return;I(r.items),wa(r.facets??null),Ca(r.aggregates??null),b&&Qe(b.pending),l&&(qn=!0,g.length&&Mi(g,()=>{jr()}))}catch(l){if(t?.aborted)return;C(l.message)}finally{t?.aborted||T(!1)}},[n]),Ba=JSON.stringify(zt);i.useEffect(()=>{const t=new AbortController;return jr(t.signal),()=>t.abort()},[jr,Ze,Ba]),i.useEffect(()=>{if(!n||J===0)return;const t=setInterval(()=>{A.getCleanupStatus().then(l=>{Qe(l.pending),l.pending===0&&clearInterval(t)}).catch(()=>{})},5e3);return()=>clearInterval(t)},[n,J]),i.useEffect(()=>{if(j!=="project"||!k?.id)return;let t=!1;return rt(!0),A.getCircuitsPage(k.id,{page:ne,page_size:ae,sort_by:V,sort_dir:Q,...Se}).then(l=>{t||(Fr(l.items),et(l.total),tt(l.total_pages),Hr({scopeKey:$e,facets:l.facets??null,aggregates:l.aggregates??null}))}).catch(l=>{t||Y.error(`Failed to load circuits: ${l.message}`)}).finally(()=>{t||rt(!1)}),()=>{t=!0}},[j,k?.id,$e,ne,ae,V,Q,Se,Ze]),i.useEffect(()=>{let t=!1;return F(!0),(at?A.getBatchAnnotators(at):xr?A.getCircuitAnnotators(xr):br?A.getProjectAnnotators(br):A.getOrgAnnotators()).then(r=>{t||S(r.annotators)}).catch(()=>{t||S([])}).finally(()=>{t||F(!1)}),()=>{t=!0}},[br,xr,at,Ze]),i.useEffect(()=>{if(j!=="circuit"||!k?.id)return;let t=!1;return rt(!0),A.getBatchesPage(k.id,{page:ne,page_size:ae,sort_by:V,sort_dir:Q,...Se}).then(l=>{t||(Or(l.items),et(l.total),tt(l.total_pages),Hr({scopeKey:$e,facets:l.facets??null,aggregates:l.aggregates??null}))}).catch(l=>{t||Y.error(`Failed to load batches: ${l.message}`)}).finally(()=>{t||rt(!1)}),()=>{t=!0}},[j,k?.id,$e,ne,ae,V,Q,Se,Ze]),i.useEffect(()=>{if(j!=="batch"||!k?.id)return;let t=!1;return ir(!0),Xr(null),(async()=>
8{if(n)try{const b=await A.listManualBatchPoles(k.id);if(t)return;if(b.manual_mode){const g=await A.getBatchPoles(k.id).catch(()=>({poles:[]}));if(t)return;const z=zo(b.poles,g.poles),c=le.statuses,_=c.length?z.filter(E=>c.some(W=>Eo(E.annotation_status,E.flagged,W))):z,y=Lo(z.map(E=>({status:E.annotation_status,flagged:E.flagged})));Xr({circuit_id:b.circuit_id,batch_id:b.batch_id}),or(_),et(_.length),tt(1),Xt({all:y.all??z.length,not_started:y.not_started??0,skipped:y.skipped??0,annotated:y.annotated??0,flagged:y.flagged??0,in_progress:0,complete:0});return}}catch{}const r=await A.getPolesPage(k.id,{page:ne,page_size:ae,...Se});t||(or(r.items),et(r.total),tt(r.total_pages),Xt(r.facets??null))})().catch(r=>{t||Y.error(`Failed to load poles: ${r.message}`)}).finally(()=>{t||ir(!1)}),()=>{t=!0}},[n,j,k?.id,ne,ae,Se,le.statuses,Ze]),i.useEffect(()=>{if(j!=="pole"||!k?.id)return;let t=!1;return cr(!0),lr([]),Promise.all([A.scanPole(k.id).catch(()=>null),A.getPoleCSV(k.id).catch(()=>null)]).then(([l,r])=>{if(t)return;const b=[];if(l){const g=new Set,z=l.source_path||l.wide_image_key;z&&(b.push({id:z,name:l.filename||z.split("/").pop()||"wide.jpg",kind:"image",description:"Wide angle",fileKey:z}),g.add(z));for(const c of l.related_images||[])!c.key||g.has(c.key)||(g.add(c.key),b.push({id:c.key,name:c.filename||c.key.split("/").pop()||"image.jpg",kind:"image",description:c.description||"Image",fileKey:c.key}))}if(r?.csv_files)for(const g of r.csv_files)b.push({id:`csv-${g.filename}`,name:g.filename,kind:"csv",description:`${g.row_count} rows · ${g.columns.length} cols`,csvData:g});lr(b)}).finally(()=>{t||cr(!1)}),()=>{t=!0}},[j,k?.id]);const kr=$t(t=>t.allowed),sn=$t(t=>t.capabilities),Fe=$t(t=>t.exportScopes),Oa=aa(t=>t.user),Be=ro(Oa),ln=$t(t=>t.ensureLoaded);i.useEffect(()=>{ln()},[ln]);const cn=i.useMemo(()=>Tr(Fe,"project",Be),[Fe,Be]),Sr=i.useMemo(()=>Tr(Fe,"circuit",Be),[Fe,Be]),_r=i.useMemo(()=>Tr(Fe,"batch",Be),[Fe,Be]),dn=t=>t.reduce((l,r)=>l+(r.annotated_poles??0),0),Oe=i.useCallback((t,l)=>no(kr,{annotatedPoles:t,grantCanExport:l,capabilities:sn}),[kr,sn]),Nt=t=>t.length>0&&t.every(l=>l.my_can_export===!1)?!1:null,ot=t=>{if(!(t.level==="project"?cn:t.level==="circuit"?Sr:_r)||!kr?.clear2attach)return[];const r=Oe(t.annotated,t.grantCanExport).c2a;return[{label:r?`Open in Clear2Attach (${r})`:"Open in Clear2Attach",icon:mo,disabled:!!r,onClick:()=>{const b=Ro(t.total,t.annotated);if(!b.ask){Nr(t.build(!1),a);return}H({build:t.build,label:t.label,noun:t.level,unannotated:b.unannotated,total:b.total})}}]},un=i.useCallback((t,l)=>{const r=Y.computing(`Classifying poles and midspans in ${l}...`),b=()=>Y.update(r,{variant:"error",message:Wn.getState().error??"The batch could not be classified.",action:{label:"Retry",onClick:()=>un(t,l)}});Wn.getState().classifyBatchAssets(t).then(g=>{if(g==null){b();return}Y.update(r,{variant:"success",message:Mo(l,g)})}).catch(b)},[]),pn=t=>{const l=Wo(n,t.my_role);return{label:l?"Classify poles and midspans (read-only access)":"Classify poles and midspans",icon:ei,disabled:l,onClick:()=>un(t.batch_id,t.batch_name)}},it=i.useCallback(async(t,l,r)=>{ao(t)||await wo(t,l,r)},[]),_e=i.useCallback((t,l)=>
8{if(!(!t.batch_id||!t.batch_name)&&!(l&&l.has_images===!1)){if(!l&&t.total_poles===0){const r=new URLSearchParams({p:t.project_id,pn:t.project_name||t.project_id,c:t.circuit_id,cn:t.circuit_name,b:t.batch_id,bn:t.batch_name});a({pathname:"/dashboard",search:`?${r.toString()}`});return}R(l?`${t.batch_id}:${l.pole_id}`:t.batch_id),sessionStorage.setItem("heightiq-batch-id",t.batch_id),Oo(o.pathname+o.search),a(jo(t.project_name,t.circuit_name,t.batch_name,l?.pole_name||"_"))}},[a,o.pathname,o.search]),Ha=i.useCallback(async t=>{if(!ve){sr("Could not find this batch's circuit.");return}Jr(!0),sr(null);try{await A.setupManualBatch({circuit_id:ve.circuit_id,batch_id:ve.batch_id,pole_names:t}),Te.getState().invalidate(),Y.success(t.length===1?"Pole folder created":`${t.length} pole folders created`),qr(!1)}catch(l){sr(l.message||"Could not create pole folders.")}finally{Jr(!1)}},[ve]),[st,hn]=i.useState([]),[gn,wr]=i.useState(!1);i.useEffect(()=>{const t=re.trim();if(!t){hn([]),wr(!1);return}wr(!0);const l=k?.level==="project"?{projectId:k.id}:k?.level==="circuit"?{projectId:k.projectId,circuitName:k.circuitName}:k?.level==="batch"?{batchId:k.id}:void 0,r=setTimeout(()=>{A.dashboardSearch(t,30,l).then(b=>{hn(b.map(g=>{if(g.kind==="project")return{kind:"project",id:g.id,name:g.name};if(g.kind==="circuit")return{kind:"circuit",id:g.id,name:g.name,projectId:g.project_id,projectName:g.project_name};const z=(c,_)=>v.find(y=>y.batch_id===c)??ka({batch_id:c,batch_name:_,circuit_id:g.circuit_id||"",circuit_name:g.circuit_name||"",project_id:g.project_id,project_name:g.project_name});return g.kind==="batch"?{kind:"batch",id:g.id,name:g.name,projectId:g.project_id,projectName:g.project_name,circuitId:g.circuit_id||"",circuitName:g.circuit_name||"",batchSummary:z(g.id,g.name)}:{kind:"pole",id:g.id,name:g.name,projectId:g.project_id,projectName:g.project_name,circuitId:g.circuit_id||"",circuitName:g.circuit_name||"",batchId:g.batch_id||"",batchName:g.batch_name||"",batchSummary:z(g.batch_id||"",g.batch_name||"")}}))}).catch(()=>{}).finally(()=>wr(!1))},280);return()=>clearTimeout(r)},[re,v,k]);const Ua=i.useMemo(()=>v,[v]),mn=_t?.scopeKey===$e?_t:null,ue=Ua,we=i.useMemo(()=>Ri(Ni(ue),V,Q),[ue,V,Q]),Ka=j==="root"?we.length:St;i.useEffect(()=>{er(1),rr({}),ar({})},[we]);const Ya=i.useMemo(()=>{const t=j==="root"?Lr:mn?.aggregates,l=Ko(k?.level??"root",t);if(l)return l;let r=ue;k?.level==="project"?r=ue.filter(W=>W.project_id===k.id):k?.level==="circuit"?r=ue.filter(W=>W.project_id===k.projectId&&W.circuit_name===k.circuitName):k?.level==="batch"&&(r=ue.filter(W=>W.batch_id===k.id));const b=new Set(r.map(W=>W.project_id)),g=new Set(r.filter(W=>W.circuit_name).map(W=>`${W.project_id}
8::${W.circuit_name}`)),z=r.filter(W=>W.batch_id).length,c=W=>r.reduce((x,Ge)=>x+(W(Ge)||0),0),_=c(W=>W.total_poles),y=c(W=>W.annotated_poles),E={total_poles:_,annotated_poles:y,flagged_poles:c(W=>W.flagged_poles),flag_only_poles:c(W=>W.flag_only_poles),in_progress_poles:c(W=>W.in_progress_poles)};return{projects:b.size,circuits:g.size,batches:z,poles:_,annotated:te(E),remaining:zr(E),breakdown:Yo(E)}},[ue,k,j,mn,Lr]),He=i.useCallback(t=>{Pa(l=>t===V&&l==="desc"?"asc":"desc"),Ia(t)},[V]),fn=i.useCallback(t=>Na(l=>{const r=new Set(l);return r.has(t)?r.delete(t):r.add(t),r}),[]),xn=i.useCallback(t=>Ra(l=>{const r=new Set(l);return r.has(t)?r.delete(t):r.add(t),r}),[]),Ue=i.useCallback(async(t,l,r)=>{const b=async g=>{const z=crypto.randomUUID(),c=ye.current.map(y=>y.name).join(" ⺠")||void 0,_=Nn(Mn(t,l),z,c);try{await r(z,g),Rn(_),Te.getState().invalidate()}catch(y){const E=y;if(E.status===409&&/upload in progress/i.test(E.message||"")&&!g&&me.getState().activeUploadSessions.size===0){me.getState().removeTask(_),await se({title:`Delete ${t} anyway?`,message:`"${l}" has an unfinished upload that was interrupted. Delete the ${t} and discard that upload?`,confirmLabel:"Delete anyway"})&&await b(!0);return}me.getState().updateTask(_,{status:"failed",error:E.message?.slice(0,80)}),Y.error(E.message)}};await b(!1)},[se]),bn=i.useCallback((t,l)=>{gr({id:t,name:l})},[]),Ga=i.useCallback(async()=>{if(!Ee)return;const{id:t,name:l}=Ee,r=async b=>{const g=crypto.randomUUID(),z=ye.current.map(_=>_.name).join(" ⺠")||void 0,c=Nn(Mn("project",l),g,z);try{await A.deleteProject(t,g,b),Rn(c),Te.getState().invalidate(),gr(null)}catch(_){const y=_;if(y.status===409&&/upload in progress/i.test(y.message||"")&&!b&&me.getState().activeUploadSessions.size===0&&(me.getState().removeTask(c),await se({title:"Delete project anyway?",message:`"${l}" has an unfinished upload that was interrupted. Delete the project and discard that upload?`,confirmLabel:"Delete anyway"}))){await r(!0);return}throw me.getState().updateTask(c,{status:"failed",error:y.message?.slice(0,80)}),Y.error(y.message),_}};await r(!1)},[Ee,se]),Mt=i.useCallback(async(t,l)=>{await se({title:"Delete circuit?",message:`Delete circuit "${l}" and all its batches and assets? This cannot be undone.`})&&await Ue("circuit",l,(b,g)=>A.deleteCircuit(t,b,g))},[se,Ue]),Rt=i.useCallback(async(t,l)=>{await se({title:"Delete batch?",message:`Delete batch "${l}" and all its assets? This cannot be undone.`})&&await Ue("batch",l,(b,g)=>A.deleteBatch(t,b,g))},[se,Ue]),yn=i.useCallback(async(t,l)=>{await se({title:"Delete asset?",message:`Delete asset "${l}" and all its files? This cannot be undone.`})&&await Ue("asset",l,(b,g)=>A.deletePole(t,b,g))},[se,Ue]),Xa=i.useCallback(async(t,l,r,b)=>{const g=new AbortController,z=me.getState(),c=z.addTask({type:"rename",label:b,status:"running",progress:0,canCancel:!1});try{const _=await r(t,g.signal);if(!_?.job_id)throw new Error("No job id returned");for(z.updateTask(c,{jobId:_.job_id}),Y.success("Renaming started");;){if(g.signal.aborted)throw new DOMException("Aborted","AbortError");const y=await A.getJob(_.job_id),E=y.status;if(E==="completed"){z.updateTask(c,{progress:100,status:"completed"}),Yr(W=>W.map(x=>x.id===l?{...x,name:t}:x)),Te.getState().invalidate(),Y.success("Renamed successfully");return}if(E==="failed"||E==="cancelled"){z.updateTask(c,{progress:y.progress_pct??0,status:E,error:E==="failed"&&y.error||void 0}),E==="failed"&&Y.error(y.error||"Rename failed");return}z.updateTask(c,{progress:y.progress_pct??0,status:"running"}),await new Promise(W=>setTimeout(W,2e3))}}catch(_){const y=_.name==="AbortError";z.updateTask(c,{status:y?"cancelled":"failed",error:y?void 0:_.message?.slice(0,80),canCancel:!1}),y||Y.error(_.message)}},[]),lt=i.useCallback((t,l,r,b)=>{Ur({entityType:t,id:l,currentName:r,apiFn:b})},[]),Wt=i.useCallback((t,l=1)=>{ye.current=t,Yr(t),or([]),Xt(null),lr([]),Fr([]),Or([]);const r=t.length===0?"root":t[t.length-1].level,b=t[t.length-1]?.id;rt(!!b&&(r==="project"||r==="circuit")),ir(!!b&&r==="batch"),cr(!!b&&r==="pole"),qt(l),et(0),tt(0)},[]),Ke=i.useCallback(t=>{const l=$i(t);a({pathname:"/dashboard",search:l?`?${l}`:""}),Wt(t,1)},[a,Wt]),ge=i.useCallback(t=>{qt(t),a({pathname:"/dashboard",search:Si(o.search,t)},{replace:!0})},[a,o.search]),At=JSON.stringify(Se),vn=i.useRef(At);i.useEffect(()=>{vn.current!==At&&(vn.current=At,ge(1))},[At,ge]),i.useEffect(()=>{const t=Ho();if(!t)return;if(o.pathname+o.search===t){An();return}if(Uo(s,o.pathname,o.search)){a(t,{replace:!0});return}An()},[s,o.pathname,o.search,a]);const jn=i.useRef(null);i.useEffect(()=>{if(w||jn.current===o.search)return;jn.current=o.search;const t=Fi(o.search,v),l=Xn(o.search);Bi(t,ye.current)?l!==ne&&qt(l):Wt(t,l)},[o.search,w,v,Wt,ne]);const ce=i.useCallback(t=>{Ke([...ye.current,t])},[Ke]),ct=i.useCallback(t=>{Ke(t)},[Ke]),kn=i.useCallback(t=>{const l=t<0?[]:ye.current.slice(0,t+1);Ke(l)},[Ke]),qa=i.useCallback(t=>{he(""),De(!1),t.kind==="project"?ct([{id:t.id,name:t.name,level:"project"}]):t.kind==="circuit"?ct([{id:t.projectId,name:t.projectName,level:"project"},{id:t.id,name:t.name,level:"circuit",projectId:t.projectId,circuitName:t.name}]):t.kind==="batch"?ct([{id:t.projectId,name:t.projectName,level:"project"},{id:t.circuitId||t.circuitName,name:t.circuitName,level:"circuit",projectId:t.projectId,circuitName:t.circuitName},{id:t.id,name:t.name,level:"batch",projectId:t.projectId,circuitName:t.circuitName,batchSummary:t.batchSummary}]):t.kind==="pole"&&ct([{id:t.projectId,name:t.projectName,level:"project"},{id:t.circuitId||t.circuitName,name:t.circuitName,level:"circuit",projectId:t.projectId,circuitName:t.circuitName},{id:t.batchId,name:t.batchName,level:"batch",projectId:t.projectId,circuitName:t.circuitName,batchSummary:t.batchSummary}])},[ct]),Cr=i.useMemo(()=>
8{if(!k)return{};if(k.level==="project")return{lockedProjectId:k.id};if(k.level==="circuit")return{lockedProjectId:k.projectId,lockedFdhId:k.circuitName};if(k.level==="batch")return{lockedProjectId:k.projectId,lockedFdhId:k.batchSummary?.circuit_name,initialBatchId:k.id};if(k.level==="pole"){const t=$.find(l=>l.level==="batch");return{lockedProjectId:t?.projectId,lockedFdhId:t?.batchSummary?.circuit_name,initialBatchId:t?.id}}return{}},[k,$]),Ce=i.useMemo(()=>{if(j!=="pole"||!k)return null;const t=$.find(l=>l.level==="batch")?.batchSummary;return t?.batch_id?{batch:t,pole:{pole_id:k.id,pole_name:k.name,annotation_status:"none"},openKey:`${t.batch_id}:${k.id}`}:null},[j,k,$]),Dt=i.useMemo(()=>{if(j==="root")return{level:"root"};if(!k)return null;const t=$.find(l=>l.level==="project");if(j==="project")return{level:"project",projectId:k.id,projectName:k.name};if(j==="circuit"){const l=k.projectId||t?.id;return l?{level:"circuit",projectId:l,projectName:t?.name||l,circuitId:k.id,circuitName:k.circuitName||k.name}:null}if(j==="batch"){const l=k.batchSummary,r=k.projectId||l?.project_id||t?.id,b=k.circuitName||l?.circuit_name;return!r||!b?null:{level:"batch",projectId:r,projectName:l?.project_name||t?.name||r,circuitName:b,batchId:k.id,batchName:k.name}}return null},[j,k,$]),Sn=i.useCallback(t=>{a(oo(t.projectId,t.circuitName,t.batchId),{state:{returnTo:o.pathname+o.search,projectName:t.projectName,circuitName:t.circuitName,batchName:t.batchName}})},[a,o.pathname,o.search]),_n=i.useCallback(t=>{a(io({projectId:t.projectId,circuitName:t.circuitName}),{state:{returnTo:o.pathname+o.search,projectName:t.projectName,circuitName:t.circuitName??null}})},[a,o.pathname,o.search]),Va=i.useCallback(()=>{if(!Dt)return;const t=ii(ue,Dt);switch(t.action){case"batch":Sn(t.target);return;case"scope":_n(t);return;case"choose":a(so(t.projectId),{state:{returnTo:o.pathname+o.search,projectName:t.projectName??null}});return;case"empty":Y.error("No batches available to open on the map.");return;default:return t}},[ue,a,o.pathname,o.search,Sn,_n,Dt]),Ie=i.useMemo(()=>j==="root"?we.map(t=>({type:"project",data:t})):j==="project"?$r.map(t=>({type:"circuit",data:t})):j==="circuit"?Br.map(t=>({type:"batch",data:t})):j==="batch"?Gr.map(t=>({type:"pole",data:t})):j==="pole"?Qr.map(t=>({type:"file",data:t})):[],[j,$r,Br,we,Gr,Qr]);i.useEffect(()=>{localStorage.setItem("dashboard-page-size",String(ae))},[ae]);const Ir=Ie,Ye=i.useCallback((t,l)=>{t.preventDefault(),ur({x:t.clientX,y:t.clientY,options:l})},[]),dt=i.useCallback((t,l,r)=>{if(t.preventDefault(),t.stopPropagation(),!l.length)return;const b=t.currentTarget.getBoundingClientRect();ur(g=>g?.toggleId===r?null:{x:b.left-8,y:b.top,options:l,expandLeft:!0,toggleId:r})},[]),Et=(t,l)=>`${Dr(t,l)}%`,wn=t=>[{label:"Circuits",value:t.circuits.length,accent:"#7c5cf0"},{label:"Batches",value:t.circuits.reduce((l,r)=>l+r.batches.length,0),accent:"#0e9aa7"},{label:"Assets",value:t.totalPoles,accent:"#1689d4"},{label:"Complete",value:t.finishedPoles,accent:"var(--pole-annotated)"},{label:"Remaining",value:t.totalPoles-t.finishedPoles,accent:"var(--pole-not-started)"},{label:"Progress",value:Et(t.finishedPoles,t.totalPoles),accent:"#1a4576"}],Cn=t=>[{label:"Batches",value:t.batches.length,accent:"#0e9aa7"},{label:"Assets",value:t.totalPoles,accent:"#1689d4"},{label:"Complete",value:t.finishedPoles,accent:"var(--pole-annotated)"},{label:"Remaining",value:t.totalPoles-t.finishedPoles,accent:"var(--pole-not-started)"},{label:"Progress",value:Et(t.finishedPoles,t.totalPoles),accent:"#7c5cf0"}],Lt=t=>[{label:"Assets",value:t.total_poles,accent:"#1689d4"},{label:"Complete",value:te(t),accent:"var(--pole-annotated)"},{label:"Remaining",value:zr(t),accent:"var(--pole-not-started)"},{label:"Progress",value:Et(te(t),t.total_poles),accent:"#0e9aa7"},{label:"Last activity",value:Xe(t.last_activity)}];return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:` 9 @keyframes spin { to { transform: rotate(360deg); } } 10 @keyframes dashFadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } } 11 @keyframes dashPopIn { from { opacity: 0; transform: translateY(4px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } } 12 @keyframes dashBarReveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } } 13 @keyframes dashKpiIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } } 14 @keyframes dashRowIn { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: translateY(0); } } 15 @keyframes drillBarSlide { 0% { transform: translateX(-100%) scaleX(0.4); } 50% { transform: translateX(20%) scaleX(0.8); } 100% { transform: translateX(120%) scaleX(0.4); } } 16 @keyframes dashSearchDrop { from { opacity:0; transform:translateY(-4px) scaleY(0.96); } to { opacity:1; transform:translateY(0) scaleY(1); } }
17 /* Table cell alignment: middle columns centered, the first (ID/name) 18 column left-aligned, the last (Actions) column right-aligned. Keeps 19 headers + rows consistent in one place. */ 20 .dashtbl-row > * { justify-self: center; } 21 /* First column stretches to its track (not content-sized) so a long 22 name truncates with an ellipsis instead of overflowing into the next 23 column; its content still flows left. */ 24 .dashtbl-row > :first-child { justify-self: stretch; min-width: 0; } 25 .dashtbl-row > :last-child { justify-self: end; } 26 `}),e.jsxs("div",{style:{...Qi,padding:`${ke?10:20}px ${h}px`,flexDirection:u?"column":void 0,alignItems:u?"stretch":void 0,gap:u?10:void 0,flexWrap:u?void 0:"wrap",transition:"padding 0.35s cubic-bezier(0.4,0,0.2,1)"},children:[e.jsxs("div",{style:{overflow:"hidden",maxHeight:ke?0:80,opacity:ke?0:1,flex:ke?"0 0 0":"1 1 260px",minWidth:0,transition:"max-height 0.38s cubic-bezier(0.4,0,0.2,1), opacity 0.28s ease, flex 0.35s cubic-bezier(0.4,0,0.2,1)",pointerEvents:ke?"none":"auto"},children:[e.jsx("h1",{style:Zi,children:"Dashboard"}),e.jsx("div",{style:es,children:n?"All projects, circuits, and batches across the org":"Batches you have read or write access to"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginLeft:u?void 0:"auto",flexShrink:u?1:0,flexWrap:u?"wrap":void 0,width:u?"100%":void 0},children:[e.jsxs("div",{ref:dr,style:{position:"relative",flex:u?"1 1 100%":void 0,minWidth:u?0:void 0},children:[e.jsxs("div",{style:{...ts,width:u?"100%":void 0},children:[e.jsx(ia,{size:13,style:{color:"var(--text-muted)"}}),e.jsx("input",{value:re,onChange:t=>{he(t.target.value),De(!0)},onFocus:()=>{re&&De(!0)},onKeyDown:t=>{t.key==="Escape"&&(he(""),De(!1))},autoComplete:"off",placeholder:"Search projects, circuits, batches...",style:{flex:1,background:"transparent",border:0,outline:"none",fontSize:12,color:"var(--text-primary)",width:u?void 0:220}}),re&&e.jsx("button",{onClick:()=>{he(""),De(!1)},style:{color:"var(--text-muted)",background:"transparent",border:0,padding:0,display:"flex",cursor:"pointer",transition:"color 0.12s"},onMouseEnter:t=>{t.currentTarget.style.color="var(--text-primary)"},onMouseLeave:t=>{t.currentTarget.style.color="var(--text-muted)"},children:e.jsx(fe,{size:12})})]}),Ea&&(gn||st.length>0)&&e.jsxs("div",{style:{position:"absolute",top:"calc(100% + 6px)",right:0,width:u?"min(380px, 90vw)":380,zIndex:400,background:"var(--card-bg)",border:"1px solid var(--border-color)",borderRadius:12,boxShadow:"0 12px 36px rgba(0,0,0,0.22)",overflow:"hidden",animation:"dashSearchDrop 0.14s ease-out",transformOrigin:"top right"},onMouseDown:t=>t.preventDefault(),children:[e.jsx("div",{style:{padding:"6px 12px",borderBottom:"1px solid var(--border-color)",fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.07em",color:"var(--text-muted)",background:"var(--bg-secondary)",display:"flex",alignItems:"center",gap:6},children:gn?e.jsxs(e.Fragment,{children:[e.jsx(ee,{size:11,style:{animation:"spin 1s linear infinite"}})," Searching..."]}):e.jsxs(e.Fragment,{children:[st.length," result",st.length!==1?"s":""]})}),e.jsx("div",{style:{maxHeight:320,overflowY:"auto",scrollbarWidth:"thin"},children:st.map((t,l)=>{const r={project:{label:"Project",color:"#1a4576",bg:"color-mix(in srgb,#1a4576 14%,transparent)",Icon:Wr},circuit:{label:"Circuit",color:"#7c5cf0",bg:"color-mix(in srgb,#7c5cf0 14%,transparent)",Icon:Kt},batch:{label:"Batch",color:"#0e9aa7",bg:"color-mix(in srgb,#0e9aa7 14%,transparent)",Icon:Rr},pole:{label:"Pole",color:"#d97706",bg:"color-mix(in srgb,#d97706 14%,transparent)",Icon:Yt}}[t.kind],b=t.kind==="circuit"?t.projectName:t.kind==="batch"?`${t.circuitName?t.circuitName+" · ":""}${t.projectName}`:t.kind==="pole"?`${t.batchName} · ${t.projectName}`:null;return e.jsxs("button",{onClick:()=>qa(t),style:{display:"flex",alignItems:"center",gap:10,width:"100%",textAlign:"left",padding:"9px 14px",background:"transparent",border:0,cursor:"pointer",borderBottom:l<st.length-1?"1px solid color-mix(in srgb,var(--border-color) 60%,transparent)":"none",transition:"background 0.1s"},onMouseEnter:g=>{g.currentTarget.style.background="var(--hover-bg)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:[e.jsx("div",{style:{width:28,height:28,borderRadius:7,background:r.bg,color:r.color,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:e.jsx(r.Icon,{size:13,strokeWidth:2.2})}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{style:{fontSize:12.5,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:t.kind!=="project"?"monospace":void 0},children:t.name}),b&&e.jsx("div",{style:{fontSize:10.5,color:"var(--text-muted)",marginTop:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:b})]}),e.jsx("span",{style:{fontSize:9.5,fontWeight:700,padding:"2px 7px",borderRadius:5,background:r.bg,color:r.color,flexShrink:0,letterSpacing:"0.04em",textTransform:"uppercase"},children:r.label})]},l)})})]})]}),e.jsxs("button",{onClick:()=>Te.getState().invalidate(),disabled:w||Ae,style:{...ns,transition:"border-color 0.12s, color 0.12s"},onMouseEnter:t=>{!w&&!Ae&&(t.currentTarget.style.borderColor="var(--color-brand)",t.currentTarget.style.color="var(--color-brand)")},onMouseLeave:t=>{t.currentTarget.style.borderColor="var(--border-color)",t.currentTarget.style.color="var(--text-secondary)"},children:[e.jsx(Tn,{size:12,style:w||Ae?{animation:"spin 1s linear infinite"}:{}})," Refresh"]}),n&&e.jsxs("button",{onClick:()=>J===0&&X(!0),disabled:J>0,title:J>0?"Waiting for cleanup to finish before uploading":void 0,style:{...rs,opacity:J>0?.45:1,cursor:J>0?"not-allowed":"pointer",transition:"opacity 0.12s, filter 0.12s"},onMouseEnter:t=>{J===0&&(t.currentTarget.style.filter="brightness(1.12)")},onMouseLeave:t=>{t.currentTarget.style.filter="none"},children:[e.jsx(lo,{size:13,strokeWidth:2.5})," Add / Upload"]})]})]}),n&&J>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:`10px ${h}px`,background:"color-mix(in srgb,#d97706 8%,transparent)",borderBottom:"1px solid color-mix(in srgb,#d97706 22%,transparent)"},children:[e.jsx(pe,{size:13,style:{color:"#d97706",flexShrink:0}}),e.jsx(ee,{size:13,style:{color:"#d97706",flexShrink:0,animation:"spin 1s linear infinite"}}),e.jsxs("span",{style:{fontSize:12,color:"var(--text-primary)"},children:[e.jsx("strong",{children:"Purging deleted data"})," - this can take a few minutes. Uploads are paused until it finishes."]})]}),!w&&!N&&e.jsx("div",{style:{display:"grid",gridTemplateRows:fr?"1fr":"0fr",opacity:fr?1:0,transition:"grid-template-rows 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease",pointerEvents:fr?"auto":"none"},children:e.jsx("div",{style:{overflow:"hidden",minHeight:0},children:e.jsx("div",{style:{padding:`16px ${h}px 8px`},children:e.jsx(Li,{level:j,kpis:Ya})})})}),!w&&!N&&e.jsxs("div",{style:{padding:`${ke?12:10}px ${h}px 0`,display:"flex",flexDirection:"column",gap:14,transition:"padding 0.35s cubic-bezier(0.4,0,0.2,1)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,minHeight:30},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,flex:1,minWidth:0,flexWrap:"wrap"},children:[e.jsxs("button",{onClick:()=>kn(-1),style:{display:"flex",alignItems:"center",gap:5,padding:"4px 10px",borderRadius:8,border:`1px solid ${$.length===0?"color-mix(in srgb,var(--color-brand) 28%,transparent)":"transparent"}`,background:$.length===0?"color-mix(in srgb,var(--color-brand) 9%,transparent)":"transparent",color:$.length===0?"var(--color-brand)":"var(--text-secondary)",fontSize:12.5,fontWeight:600,cursor:"pointer"},onMouseEnter:t=>{$.length>0&&(t.currentTarget.style.color="var(--text-primary)")},onMouseLeave:t=>{$.length>0&&(t.currentTarget.style.color="var(--text-secondary)")},children:[e.jsx(Qo,{size:13,strokeWidth:2.2})," All projects"]}),$.map((t,l)=>{const r=l===$.length-1,b=t.level==="project"?"var(--sky-500)":t.level==="circuit"?"#7c5cf0":t.level==="batch"?"#0e9aa7":"#d97706";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2},children:[e.jsx(de,{size:12,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("button",{onClick:()=>!r&&kn(l),style:{maxWidth:200,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",padding:"4px 10px",borderRadius:8,border:r?`1px solid color-mix(in srgb,${b} 30%,transparent)`:"1px solid transparent",background:r?`color-mix(in srgb,${b} 10%,transparent)`:"transparent",color:r?b:"var(--text-secondary)",fontSize:12.5,fontWeight:r?700:500,fontFamily:t.level!=="project"?"monospace":void 0,cursor:r?"default":"pointer"},onMouseEnter:g=>{r||(g.currentTarget.style.color="var(--text-primary)")},onMouseLeave:g=>{r||(g.currentTarget.style.color="var(--text-secondary)")},children:t.name})]},l)}),(nt||Zr)&&Ie.length>0&&e.jsx(ee,{size:13,style:{color:"var(--color-brand)",animation:"spin 1s linear infinite",marginLeft:4}})]}),Ce&&e.jsx("button",{onClick:()=>_e(Ce.batch,Ce.pole),disabled:L===Ce.openKey,style:{display:"flex",alignItems:"center",gap:5,flexShrink:0,height:32,padding:"0 12px",borderRadius:8,background:"color-mix(in srgb, var(--color-brand) 10%, transparent)",color:"var(--color-brand)",fontSize:12.5,fontWeight:600,border:"1px solid color-mix(in srgb, var(--color-brand) 25%, transparent)",cursor:L===Ce.openKey?"wait":"pointer",transition:"background 0.12s, border-color 0.12s"}
26,title:"Open pole in HeightIQ",onMouseEnter:t=>{L!==Ce.openKey&&(t.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 22%, transparent)",t.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 50%, transparent)")},onMouseLeave:t=>{t.currentTarget.style.background="color-mix(in srgb, var(--color-brand) 10%, transparent)",t.currentTarget.style.borderColor="color-mix(in srgb, var(--color-brand) 25%, transparent)"},children:L===Ce.openKey?e.jsx(ee,{size:12,style:{animation:"spin 1s linear infinite"}}):e.jsxs(e.Fragment,{children:["Open ",e.jsx(ze,{size:12,strokeWidth:2.5})]})})]}),j!=="pole"&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,flexWrap:"wrap"},children:[e.jsx(ki,{options:$a,counts:Fa,selected:le.statuses,onChange:t=>La(t),busy:an}),e.jsx(vi,{filters:le,onChange:vr,annotators:kt,annotatorsLoading:M,level:nn,resultCount:Ar(le)&&!an?Ka:null,resultNoun:Vn[j]}),Dt&&e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Co,{onOpen:Va})})]})]}),e.jsx("div",{style:{padding:`10px ${h}px 32px`},children:w||Ae&&Ie.length===0||nt&&Ie.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:48},children:[e.jsx(ee,{size:28,style:{color:"var(--color-brand)",animation:"spin 1s linear infinite"}}),e.jsx("span",{style:{fontSize:12,color:"var(--text-muted)"},children:j==="project"?"Loading circuits...":j==="circuit"?"Loading batches...":j==="batch"?"Loading poles...":"Loading..."})]}):N?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:48},children:[e.jsx(co,{size:28,style:{color:"#dc2626"}}),e.jsx("p",{style:{fontSize:14,color:"var(--text-secondary)",margin:0},children:N}),e.jsxs("button",{onClick:()=>Te.getState().invalidate(),style:as,children:[e.jsx(Tn,{size:11})," Retry"]})]}):Ie.length===0&&!nt&&!Zr?e.jsx("div",{style:is,children:j==="pole"?"No files found for this asset.":Ar(le)?`No ${Vn[j]} match the current filters. Adjust or clear filters above.`:j==="batch"&&n&&ve?"No assets in this batch yet. Use Add / Upload to put photos or asset folders into it.":j==="batch"?"No assets found in this batch.":j==="circuit"?"No batches in this circuit.":j==="project"?"No circuits in this project.":re?"No results match your search.":n?"No batches yet. Upload data to get started.":"No batches accessible. Contact an admin."}):e.jsx(e.Fragment,{children:e.jsx("div",{ref:f,style:{overflowX:"auto",animation:"dashFadeUp 0.3s ease-out both",animationDelay:"100ms"},children:e.jsxs("div",{style:{...os,minWidth:["batch","pole"].includes(j)?u?600:540:j==="circuit"?u?980:860:u?940:780,position:"relative"},children:[(Ae||nt)&&Ie.length>0&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:2,zIndex:10,background:"var(--bg-tertiary, #e2e8f0)",borderRadius:"12px 12px 0 0",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",background:"var(--color-brand)",animation:"drillBarSlide 1.2s ease-in-out infinite",transformOrigin:"left"}})}),(j==="root"||j==="project")&&e.jsxs("div",{className:"dashtbl-row",style:{...Ut,gridTemplateColumns:xt},children:[e.jsx(Ve,{label:j==="root"?"Name":"Circuit (FDH)",column:"name",activeSortBy:V,sortDir:Q,onSort:He}),e.jsx("div",{style:{textAlign:"right"},children:"Assets"}),e.jsx(Ve,{label:"Progress",column:"progress",activeSortBy:V,sortDir:Q,onSort:He}),e.jsx(Ve,{label:"Last Modified",column:"activity",activeSortBy:V,sortDir:Q,onSort:He,style:{justifyContent:"flex-end"}}),e.jsx("div",{style:{textAlign:"right"},children:"Last Annotated"}),e.jsx("div",{style:{textAlign:"right"},children:"Actions"})]}),j==="circuit"&&e.jsxs("div",{className:"dashtbl-row",style:{...Ut,gridTemplateColumns:ta},children:[e.jsx(Ve,{label:"Batch",column:"name",activeSortBy:V,sortDir:Q,onSort:He}),e.jsx("div",{style:{textAlign:"right"},children:"Assets"}),e.jsx(Ve,{label:"Progress",column:"progress",activeSortBy:V,sortDir:Q,onSort:He}),e.jsx(Ve,{label:"Last Modified",column:"activity",activeSortBy:V,sortDir:Q,onSort:He,style:{justifyContent:"flex-end"}}),e.jsx("div",{style:{textAlign:"right"},children:"Last Annotated"}),e.jsx("div",{children:"Annotated by"}),e.jsx("div",{style:{textAlign:"right"},children:"Actions"})]}),j==="batch"&&e.jsx(Io,{state:je,variant:"toolbar"}),j==="batch"&&e.jsxs("div",{className:"dashtbl-row",style:{...Ut,gridTemplateColumns:je.allowed?Zn:Qn},children:[e.jsx("div",{children:"Asset"}),e.jsx("div",{children:"Status"}),je.allowed&&e.jsx("div",{children:"PLA"}),e.jsx("div",{children:"Last Activity"}),e.jsx("div",{children:"Annotated by"}),e.jsx("div",{style:{textAlign:"right"},children:"Actions"})]}),j==="pole"&&e.jsxs("div",{style:{...Ut,gridTemplateColumns:ea},children:[e.jsx("div",{children:"File"}),e.jsx("div",{children:"Type"}),e.jsx("div",{children:"Info"}),e.jsx("div",{style:{textAlign:"right"},children:"Preview"})]}),j==="root"&&(()=>{const t=Math.max(1,Math.ceil(we.length/Ct)),l=we.slice((Zt-1)*Ct,Zt*Ct);return e.jsxs(e.Fragment,{children:[l.map((r,b)=>
26{const g=za.has(r.projectId),z=[...ot({level:"project",label:`${r.projectName} (project)`,total:r.totalPoles,annotated:r.annotatedPoles,grantCanExport:Nt(r.circuits.flatMap(c=>c.batches)),build:c=>Go({projectId:r.projectId,projectName:r.projectName,totalPoles:r.totalPoles,annotatedPoles:r.annotatedPoles},c)}),{label:"NESC rules",icon:Ne,onClick:()=>K({kind:"project",projectId:r.projectId,projectName:r.projectName,affectedScope:{circuits:r.circuits.length,batches:r.circuits.reduce((c,_)=>c+_.batches.length,0),poles:r.totalPoles}})},...n?[{label:"Manage access",icon:ht,onClick:()=>P({scopeType:"project",scopeId:r.projectId,scopeName:r.projectName})},{label:"Input data mode...",icon:Ne,onClick:()=>Kr({projectId:r.projectId,projectName:r.projectName})},{label:"Rename",icon:ut,onClick:()=>lt("project",r.projectId,r.projectName,(c,_)=>A.renameProject(r.projectId,c,_))}]:[]];return e.jsxs("div",{children:[e.jsxs("div",{className:"dashtbl-row",style:{display:"grid",gridTemplateColumns:xt,columnGap:16,padding:"11px 20px",borderTop:"1px solid var(--border-color)",alignItems:"center",background:"var(--bg-secondary)",animation:"dashRowIn 0.2s ease-out both",animationDelay:`${b*20}ms`,cursor:"pointer",transition:"background 0.1s"},onClick:()=>ce({id:r.projectId,name:r.projectName,level:"project"}),onMouseEnter:c=>c.currentTarget.style.background="var(--hover-bg)",onMouseLeave:c=>c.currentTarget.style.background="var(--bg-secondary)",onContextMenu:c=>Ye(c,[{label:"Expand/Collapse",icon:g?Re:de,onClick:()=>fn(r.projectId)},{label:"Stats",icon:oe,onClick:()=>Z({title:r.projectName,level:"project",stats:wn(r)})},...z,...n?[{label:"Delete",icon:pe,onClick:()=>bn(r.projectId,r.projectName),danger:!0}]:[]]),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),fn(r.projectId)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:20,height:20,flexShrink:0,background:"transparent",border:0,cursor:"pointer",color:"var(--text-muted)",padding:0},children:g?e.jsx(Re,{size:13,strokeWidth:2.5}):e.jsx(de,{size:13,strokeWidth:2.5})}),e.jsx("div",{style:{width:22,height:22,borderRadius:6,flexShrink:0,background:"color-mix(in srgb,#1a4576 14%,transparent)",color:"#1a4576",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Wr,{size:12,strokeWidth:2.2})}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),ce({id:r.projectId,name:r.projectName,level:"project"})},style:{display:"flex",alignItems:"center",gap:3,background:"transparent",border:0,padding:0,cursor:"pointer",fontSize:13,fontWeight:700,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100%"},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-brand)"},onMouseLeave:c=>{c.currentTarget.style.color="var(--text-primary)"},title:`Open ${r.projectName}`,children:[e.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.projectName}),e.jsx(qe,{count:r.flaggedPoles}),e.jsx(de,{size:11,strokeWidth:2.5,style:{flexShrink:0,opacity:.5}})]}),e.jsxs("div",{style:{fontSize:10,color:"var(--text-muted)"},children:[r.circuits.length," FDH · ",r.circuits.reduce((c,_)=>c+_.batches.length,0)," batches"]})]})]}),e.jsx("div",{style:bt,children:r.totalPoles.toLocaleString()}),e.jsx(ft,{completed:r.completedCircuits,total:r.circuits.length}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:mt(r.lastModified)}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:Xe(r.lastActivity)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2},onClick:c=>c.stopPropagation(),children:[e.jsx(yt,{isOpen:ie?.toggleId===`project:${r.projectId}`,onClick:c=>dt(c,z,`project:${r.projectId}`)}),e.jsx("button",{onClick:()=>Z({title:r.projectName,level:"project",stats:wn(r)}),title:"Stats",className:"sw-icon-btn",style:Me,children:e.jsx(oe,{size:12})}),cn&&e.jsx(pt,{variant:"icon",scope:"project",align:"right",title:"Download",disabledActions:Oe(r.circuits.reduce((c,_)=>c+dn(_.batches),0),Nt(r.circuits.flatMap(c=>c.batches))),onSelect:(c,_)=>it(c,{kind:"project",projectId:r.projectId},_)}),n&&e.jsx(Je,{title:"Delete project",onClick:()=>bn(r.projectId,r.projectName)})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateRows:g?"1fr":"0fr",transition:"grid-template-rows 0.25s cubic-bezier(0.4,0,0.2,1)"},children:e.jsxs("div",{style:{overflow:"hidden",minHeight:0},children:[r.circuits.slice(((tr[r.projectId]??1)-1)*It,(tr[r.projectId]??1)*It).map((c,_)=>{const y=`${r.projectId}::${c.circuitName}`,E=Ma.has(y),W=[...ot({level:"circuit",label:`${c.circuitName} (circuit)`,total:c.totalPoles,annotated:c.annotatedPoles,grantCanExport:Nt(c.batches),build:x=>Dn({projectId:r.projectId,circuitName:c.circuitName,circuitId:c.circuitId,totalPoles:c.totalPoles,annotatedPoles:c.annotatedPoles},x)}),{label:"NESC rules",icon:Ne,onClick:()=>K({kind:"circuit",projectId:r.projectId,projectName:r.projectName,circuitName:c.circuitName,circuitId:c.circuitId,affectedScope:{batches:c.batches.length,poles:c.totalPoles}})},...n?[{label:"Manage access",icon:ht,onClick:()=>P({scopeType:"fdh",scopeId:c.circuitId,scopeName:c.circuitName||"-"})},{label:"Rename",icon:ut,onClick:()=>lt("circuit",c.circuitId,c.circuitName||"-",(x,Ge)=>A.renameCircuit(c.circuitId,x,Ge))}]:[]];return e.jsxs("div",{children:[e.jsxs("div",{className:"dashtbl-row",style:{display:"grid",gridTemplateColumns:xt,columnGap:16,padding:"8px 20px",borderTop:"1px solid color-mix(in srgb,var(--border-color) 85%,transparent)",alignItems:"center",background:"color-mix(in srgb,var(--bg-secondary) 50%,var(--card-bg))",transition:"background 0.1s"},onMouseEnter:x=>x.currentTarget.style.background="var(--hover-bg)",onMouseLeave:x=>x.currentTarget.style.background="color-mix(in srgb,var(--bg-secondary) 50%,var(--card-bg))",onContextMenu:x=>Ye(x,[{label:"Expand/Collapse",icon:E?Re:de,onClick:()=>xn(y)},{label:"Stats",icon:oe,onClick:()=>Z({title:c.circuitName||"-",level:"circuit",stats:Cn(c)})},...W,...n?[{label:"Delete",icon:pe,onClick:()=>Mt(c.circuitId,c.circuitName||"-"),danger:!0}]:[]]),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,paddingLeft:26},children:[e.jsx("button",{type:"button",onClick:()=>xn(y),style:{display:"flex",alignItems:"center",justifyContent:"center",width:18,height:18,flexShrink:0,background:"transparent",border:0,cursor:"pointer",color:"var(--text-muted)",padding:0}
26,children:E?e.jsx(Re,{size:12,strokeWidth:2.5}):e.jsx(de,{size:12,strokeWidth:2.5})}),e.jsx("div",{style:{width:20,height:20,borderRadius:5,flexShrink:0,background:"color-mix(in srgb,#7c5cf0 14%,transparent)",color:"#7c5cf0",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Kt,{size:11,strokeWidth:2.2})}),e.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:m?"column":"row",alignItems:m?"stretch":"baseline",gap:m?0:6,lineHeight:1.2},children:[e.jsx("span",{title:c.circuitName||void 0,style:{fontSize:12,fontWeight:600,color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,fontFamily:"monospace"},children:c.circuitName||"-"}),e.jsxs("span",{style:{fontSize:9,color:"var(--text-muted)",flexShrink:0,fontFamily:"monospace"},children:[c.batches.length," ",c.batches.length===1?"batch":"batches"]})]}),e.jsx(qe,{count:c.flaggedPoles})]}),e.jsx("div",{style:bt,children:c.totalPoles.toLocaleString()}),e.jsx(ft,{completed:c.completedBatches,total:c.batches.length}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:mt(c.lastModified)}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:Xe(c.lastActivity)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2},onClick:x=>x.stopPropagation(),children:[e.jsx(yt,{isOpen:ie?.toggleId===`circuit:${c.circuitId}`,onClick:x=>dt(x,W,`circuit:${c.circuitId}`)}),e.jsx("button",{onClick:()=>Z({title:c.circuitName||"-",level:"circuit",stats:Cn(c)}),title:"Stats",className:"sw-icon-btn",style:Me,children:e.jsx(oe,{size:12})}),Sr&&e.jsx(pt,{variant:"icon",scope:"circuit",align:"right",title:"Download",disabledActions:Oe(dn(c.batches),Nt(c.batches)),onSelect:(x,Ge)=>it(x,{kind:"circuit",projectId:r.projectId,circuitName:c.circuitName,circuitId:c.circuitId},Ge)}),n&&e.jsx(Je,{title:"Delete circuit",onClick:()=>Mt(c.circuitId,c.circuitName||"-")})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateRows:E?"1fr":"0fr",transition:"grid-template-rows 0.25s cubic-bezier(0.4,0,0.2,1)"},children:e.jsxs("div",{style:{overflow:"hidden",minHeight:0},children:[c.batches.slice(((nr[`${r.projectId}::${c.circuitName}`]??1)-1)*Pt,(nr[`${r.projectId}::${c.circuitName}`]??1)*Pt).map((x,Ge)=>{const Pe=!!x.batch_id,In=Pe?[...ot({level:"batch",label:x.batch_name,total:x.total_poles,annotated:x.annotated_poles,grantCanExport:x.my_can_export===!1?!1:null,build:B=>En(x,B)}),{label:"NESC rules",icon:Ne,onClick:()=>K({kind:"batch",batchId:x.batch_id,batchName:x.batch_name,projectName:r.projectName,circuitName:c.circuitName,affectedScope:{poles:x.total_poles}})},pn(x),...n?[{label:"Manage access",icon:ht,onClick:()=>P({scopeType:"batch",scopeId:x.batch_id,scopeName:x.batch_name})},{label:"Rename",icon:ut,onClick:()=>lt("batch",x.batch_id,x.batch_name,(B,Pr)=>A.renameBatch(x.batch_id,B,Pr))}]:[]]:[];return e.jsxs("div",{className:"dashtbl-row",style:{display:"grid",gridTemplateColumns:xt,columnGap:16,padding:"9px 20px",borderTop:"1px solid color-mix(in srgb,var(--border-color) 70%,transparent)",alignItems:"center",cursor:Pe?"pointer":"default",transition:"background 0.1s"},onClick:()=>Pe&&ce({id:x.batch_id,name:x.batch_name,level:"batch",projectId:r.projectId,circuitName:c.circuitName,batchSummary:x}),onContextMenu:B=>Pe&&Ye(B,[{label:"Open assets",icon:Ft,onClick:()=>ce({id:x.batch_id,name:x.batch_name,level:"batch",projectId:r.projectId,circuitName:c.circuitName,batchSummary:x})},{label:"Open in HeightIQ",icon:ze,onClick:()=>_e(x)},{label:"Stats",icon:oe,onClick:()=>Z({title:x.batch_name,level:"batch",stats:Lt(x)})},...In,...n?[{label:"Delete",icon:pe,onClick:()=>Rt(x.batch_id,x.batch_name),danger:!0}]:[]]),onMouseEnter:B=>{Pe&&(B.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:B=>{B.currentTarget.style.background="transparent"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0,paddingLeft:52},children:[e.jsx("div",{style:{width:5,height:5,borderRadius:"50%",flexShrink:0,background:gt(x.upload_status)?.colour??"var(--text-muted)",opacity:gt(x.upload_status)?1:.5}}),e.jsxs("div",{style:{minWidth:0,maxWidth:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,width:"fit-content",maxWidth:"100%",minWidth:0},children:[e.jsx("span",{title:x.batch_name||void 0,style:{fontSize:12,fontFamily:"monospace",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:x.batch_name||"-"}),e.jsx(qe,{count:x.flagged_poles}),Pe&&e.jsx(de,{size:10,strokeWidth:2.5,style:{color:"var(--text-muted)",flexShrink:0,opacity:.5}})]}),(()=>{const B=gt(x.upload_status);return B&&e.jsx("div",{style:{fontSize:9,color:B.colour,fontWeight:700},children:B.label})})()]})]}),e.jsx("div",{style:{...bt,fontWeight:600},children:x.total_poles}),e.jsx(ft,{completed:te(x),total:x.total_poles}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:mt(x.created_on)}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:Xe(x.last_activity)}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2},onClick:B=>B.stopPropagation(),children:Pe&&e.jsxs(e.Fragment,{children:[e.jsx(yt,{isOpen:ie?.toggleId===`batch:${x.batch_id}`,onClick:B=>dt(B,In,`batch:${x.batch_id}`)}),e.jsxs("button",{onClick:()=>_e(x),disabled:L===x.batch_id,style:{display:"flex",alignItems:"center",gap:3,background:"color-mix(in srgb,var(--color-brand) 12%,transparent)",color:"var(--color-brand)",cursor:"pointer",border:"1px solid color-mix(in srgb,var(--color-brand) 30%,transparent)",width:30,height:28,justifyContent:"center",borderRadius:7,transition:"background 0.12s,border-color 0.12s"}
26,title:"Open in HeightIQ",onMouseEnter:B=>{L!==x.batch_id&&(B.currentTarget.style.background="color-mix(in srgb,var(--color-brand) 24%,transparent)",B.currentTarget.style.borderColor="color-mix(in srgb,var(--color-brand) 55%,transparent)")},onMouseLeave:B=>{B.currentTarget.style.background="color-mix(in srgb,var(--color-brand) 12%,transparent)",B.currentTarget.style.borderColor="color-mix(in srgb,var(--color-brand) 30%,transparent)"},children:[L===x.batch_id&&e.jsx(ee,{size:10,style:{animation:"spin 1s linear infinite"}}),e.jsx(ze,{size:14,strokeWidth:2.5})]}),e.jsx("button",{onClick:()=>Z({title:x.batch_name,level:"batch",stats:Lt(x)}),title:"Stats",className:"sw-icon-btn",style:Me,children:e.jsx(oe,{size:12})}),_r&&e.jsx(pt,{variant:"icon",scope:"batch",align:"right",title:"Download",disabledActions:Oe(x.annotated_poles,x.my_can_export),spaniqBatch:{batchId:x.batch_id,batchName:x.batch_name},onSelect:(B,Pr)=>it(B,{kind:"batch",batchId:x.batch_id},Pr)}),n&&e.jsx(Je,{title:"Delete batch",onClick:()=>Rt(x.batch_id,x.batch_name)})]})})]},x.batch_id||`${x.project_id}-${x.batch_name}`)}),e.jsx(na,{page:nr[`${r.projectId}::${c.circuitName}`]??1,totalPages:Math.max(1,Math.ceil(c.batches.length/Pt)),total:c.batches.length,label:"batches",indent:52,onPrev:()=>ar(x=>({...x,[`${r.projectId}::${c.circuitName}`]:Math.max(1,(x[`${r.projectId}::${c.circuitName}`]??1)-1)})),onNext:()=>ar(x=>({...x,[`${r.projectId}::${c.circuitName}`]:Math.min(Math.ceil(c.batches.length/Pt),(x[`${r.projectId}::${c.circuitName}`]??1)+1)}))})]})})]},y)}),e.jsx(na,{page:tr[r.projectId]??1,totalPages:Math.max(1,Math.ceil(r.circuits.length/It)),total:r.circuits.length,label:"circuits",indent:26,onPrev:()=>rr(c=>({...c,[r.projectId]:Math.max(1,(c[r.projectId]??1)-1)})),onNext:()=>rr(c=>({...c,[r.projectId]:Math.min(Math.ceil(r.circuits.length/It),(c[r.projectId]??1)+1)}))})]})})]},r.projectId)}),e.jsx(Bt,{page:Zt,pageSize:Ct,total:we.length,totalPages:t,onPageChange:r=>er(r),onPageSizeChange:r=>{Wa(r),er(1)}})]})})(),j==="project"&&Ir.map((t,l)=>{const r=t.data,b=r.project_id,g=k?.name??"",z=[{label:"Batches",value:r.batch_count,accent:"#0e9aa7"},{label:"Assets",value:r.total_poles,accent:"#1689d4"},{label:"Complete",value:te(r),accent:"var(--pole-annotated)"},{label:"Remaining",value:zr(r),accent:"var(--pole-not-started)"},{label:"Progress",value:Et(te(r),r.total_poles),accent:"#7c5cf0"}],c=[...ot({level:"circuit",label:`${r.circuit_name} (circuit)`,total:r.total_poles,annotated:r.annotated_poles,grantCanExport:r.my_can_export===!1?!1:null,build:_=>Dn({projectId:b,circuitName:r.circuit_name,circuitId:r.circuit_id,totalPoles:r.total_poles,annotatedPoles:r.annotated_poles},_)}),{label:"NESC rules",icon:Ne,onClick:()=>K({kind:"circuit",projectId:b,projectName:g,circuitName:r.circuit_name,circuitId:r.circuit_id,affectedScope:{batches:r.batch_count,poles:r.total_poles}})},...n?[{label:"Manage access",icon:ht,onClick:()=>P({scopeType:"fdh",scopeId:r.circuit_id,scopeName:r.circuit_name||"-"})},{label:"Rename",icon:ut,onClick:()=>lt("circuit",r.circuit_id,r.circuit_name||"-",(_,y)=>A.renameCircuit(r.circuit_id,_,y))}]:[]];return e.jsxs("div",{className:"dashtbl-row",style:{display:"grid",gridTemplateColumns:xt,columnGap:16,padding:"9px 20px",borderTop:"1px solid var(--border-color)",alignItems:"center",cursor:"pointer",transition:"background 0.1s",animation:"dashRowIn 0.2s ease-out both",animationDelay:`${l*20}ms`},onClick:()=>ce({id:r.circuit_id||r.circuit_name,name:r.circuit_name,level:"circuit",projectId:b,circuitName:r.circuit_name}),onContextMenu:_=>Ye(_,[{label:"Open",icon:Ft,onClick:()=>ce({id:r.circuit_id||r.circuit_name,name:r.circuit_name,level:"circuit",projectId:b,circuitName:r.circuit_name})},{label:"Stats",icon:oe,onClick:()=>Z({title:r.circuit_name||"-",level:"circuit",stats:z})},...c,...n?[{label:"Delete",icon:pe,onClick:()=>Mt(r.circuit_id,r.circuit_name||"-"),danger:!0}]:[]]),onMouseEnter:_=>_.currentTarget.style.background="var(--hover-bg)",onMouseLeave:_=>_.currentTarget.style.background="transparent",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[e.jsx("div",{style:{width:24,height:24,borderRadius:6,flexShrink:0,background:"color-mix(in srgb,#7c5cf0 14%,transparent)",color:"#7c5cf0",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Kt,{size:13,strokeWidth:2.2})}),e.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:m?"column":"row",alignItems:m?"stretch":"baseline",gap:m?0:6,lineHeight:1.2},children:[e.jsx("span",{title:r.circuit_name||void 0,style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0,fontFamily:"monospace"},children:r.circuit_name||"-"}),e.jsxs("span",{style:{fontSize:9.5,color:"var(--text-muted)",flexShrink:0,fontFamily:"monospace"},children:[r.batch_count," ",r.batch_count===1?"batch":"batches"]})]}),e.jsx(qe,{count:r.flagged_poles}),e.jsx(de,{size:12,style:{color:"var(--text-muted)",flexShrink:0,opacity:.5}})]}
26),e.jsx("div",{style:bt,children:r.total_poles.toLocaleString()}),e.jsx(ft,{completed:te(r),total:r.total_poles}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:mt(r.last_modified)}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:Xe(r.last_activity)}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2},onClick:_=>_.stopPropagation(),children:[e.jsx(yt,{isOpen:ie?.toggleId===`drill-circuit:${r.circuit_id}`,onClick:_=>dt(_,c,`drill-circuit:${r.circuit_id}`)}),e.jsx("button",{onClick:()=>Z({title:r.circuit_name||"-",level:"circuit",stats:z}),title:"Stats",className:"sw-icon-btn",style:Me,children:e.jsx(oe,{size:12})}),Sr&&e.jsx(pt,{variant:"icon",scope:"circuit",align:"right",title:"Download",disabledActions:Oe(r.annotated_poles,r.my_can_export),onSelect:(_,y)=>it(_,{kind:"circuit",projectId:b,circuitName:r.circuit_name,circuitId:r.circuit_id},y)}),n&&e.jsx(Je,{title:"Delete circuit",onClick:()=>Mt(r.circuit_id,r.circuit_name||"-")})]})]},r.circuit_id||r.circuit_name)}),j==="project"&&e.jsx(Bt,{page:ne,pageSize:ae,total:St,totalPages:Jt,onPageChange:ge,onPageSizeChange:t=>{Vt(t),ge(1)}}),j==="circuit"&&Ir.map((t,l)=>{const r=t.data,b=r.project_id,g=r.project_name,z=r.circuit_name;r.circuit_id;const c=!!r.batch_id,_=c?[...ot({level:"batch",label:r.batch_name,total:r.total_poles,annotated:r.annotated_poles,grantCanExport:r.my_can_export===!1?!1:null,build:y=>En(r,y)}),{label:"NESC rules",icon:Ne,onClick:()=>K({kind:"batch",batchId:r.batch_id,batchName:r.batch_name,projectName:g,circuitName:z,affectedScope:{poles:r.total_poles}})},pn(r),...n?[{label:"Manage access",icon:ht,onClick:()=>P({scopeType:"batch",scopeId:r.batch_id,scopeName:r.batch_name})},{label:"Rename",icon:ut,onClick:()=>lt("batch",r.batch_id,r.batch_name,(y,E)=>A.renameBatch(r.batch_id,y,E))}]:[]]:[];return e.jsxs("div",{className:"dashtbl-row",style:{display:"grid",gridTemplateColumns:ta,columnGap:16,padding:"9px 20px",borderTop:"1px solid var(--border-color)",alignItems:"center",cursor:c?"pointer":"default",transition:"background 0.1s",animation:"dashRowIn 0.2s ease-out both",animationDelay:`${l*20}ms`},onClick:()=>c&&ce({id:r.batch_id,name:r.batch_name,level:"batch",projectId:b,circuitName:z,batchSummary:r}),onContextMenu:y=>c&&Ye(y,[{label:"Open assets",icon:Ft,onClick:()=>ce({id:r.batch_id,name:r.batch_name,level:"batch",projectId:b,circuitName:z,batchSummary:r})},{label:"Open in HeightIQ",icon:ze,onClick:()=>_e(r)},{label:"Stats",icon:oe,onClick:()=>Z({title:r.batch_name,level:"batch",stats:Lt(r)})},..._,...n?[{label:"Delete",icon:pe,onClick:()=>Rt(r.batch_id,r.batch_name),danger:!0}]:[]]),onMouseEnter:y=>{c&&(y.currentTarget.style.background="var(--hover-bg)")},onMouseLeave:y=>{y.currentTarget.style.background="transparent"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[e.jsx("div",{style:{width:5,height:5,borderRadius:"50%",flexShrink:0,background:gt(r.upload_status)?.colour??"var(--text-muted)",opacity:.6}}),e.jsx("div",{style:{width:24,height:24,borderRadius:6,flexShrink:0,background:"color-mix(in srgb,#0e9aa7 14%,transparent)",color:"#0e9aa7",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(Rr,{size:13,strokeWidth:2.2})}),e.jsxs("div",{style:{minWidth:0,maxWidth:"100%"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:3,width:"fit-content",maxWidth:"100%",minWidth:0},children:[e.jsx("span",{title:r.batch_name||void 0,style:{fontSize:12.5,fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace",minWidth:0},children:r.batch_name||"-"}),e.jsx(qe,{count:r.flagged_poles}),c&&e.jsx(de,{size:11,style:{color:"var(--text-muted)",flexShrink:0,opacity:.5}})]}),(()=>{const y=gt(r.upload_status);return y&&e.jsx("div",{style:{fontSize:9,color:y.colour,fontWeight:700},children:y.label})})()]})]}),e.jsx("div",{style:bt,children:r.total_poles}),e.jsx(ft,{completed:te(r),total:r.total_poles}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:mt(r.created_on)}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",textAlign:"right"},children:Xe(r.last_activity)}),e.jsx("div",{onClick:y=>y.stopPropagation(),style:{display:"flex",alignItems:"center"},children:e.jsx(si,{batchId:r.batch_id,annotators:r.annotators??[]})}),e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:2},onClick:y=>y.stopPropagation(),children:c&&e.jsxs(e.Fragment,{children:[e.jsx(yt,{isOpen:ie?.toggleId===`drill-batch:${r.batch_id}`,onClick:y=>dt(y,_,`drill-batch:${r.batch_id}`)}),e.jsxs("button",{onClick:()=>_e(r),disabled:L===r.batch_id,style:{display:"flex",alignItems:"center",gap:3,background:"color-mix(in srgb,var(--color-brand) 12%,transparent)",color:"var(--color-brand)",cursor:"pointer",border:"1px solid color-mix(in srgb,var(--color-brand) 30%,transparent)",width:30,height:28,justifyContent:"center",borderRadius:7,transition:"background 0.12s,border-color 0.12s"}
26,title:"Open in HeightIQ",onMouseEnter:y=>{L!==r.batch_id&&(y.currentTarget.style.background="color-mix(in srgb,var(--color-brand) 24%,transparent)",y.currentTarget.style.borderColor="color-mix(in srgb,var(--color-brand) 55%,transparent)")},onMouseLeave:y=>{y.currentTarget.style.background="color-mix(in srgb,var(--color-brand) 12%,transparent)",y.currentTarget.style.borderColor="color-mix(in srgb,var(--color-brand) 30%,transparent)"},children:[L===r.batch_id&&e.jsx(ee,{size:10,style:{animation:"spin 1s linear infinite"}}),e.jsx(ze,{size:14,strokeWidth:2.5})]}),e.jsx("button",{onClick:()=>Z({title:r.batch_name,level:"batch",stats:Lt(r)}),title:"Stats",className:"sw-icon-btn",style:Me,children:e.jsx(oe,{size:12})}),_r&&e.jsx(pt,{variant:"icon",scope:"batch",align:"right",title:"Download",disabledActions:Oe(r.annotated_poles,r.my_can_export),spaniqBatch:{batchId:r.batch_id,batchName:r.batch_name},onSelect:(y,E)=>it(y,{kind:"batch",batchId:r.batch_id},E)}),n&&e.jsx(Je,{title:"Delete batch",onClick:()=>Rt(r.batch_id,r.batch_name)})]})})]},r.batch_id||`${r.project_id}-${r.batch_name}`)}),j==="circuit"&&e.jsx(Bt,{page:ne,pageSize:ae,total:St,totalPages:Jt,onPageChange:ge,onPageSizeChange:t=>{Vt(t),ge(1)}}),j==="batch"&&Ir.map((t,l)=>{const r=t.data,b=k.batchSummary,g=r.annotation_status,z=g==="none"?"var(--text-muted)":xo(g),c=bo(g),_=!!(ve&&r.has_images===!1);return e.jsxs("div",{className:"dashtbl-row",style:{display:"grid",gridTemplateColumns:je.allowed?Zn:Qn,columnGap:16,padding:"9px 18px",borderTop:"1px solid color-mix(in srgb,var(--border-color) 85%,transparent)",alignItems:"center",cursor:_?"default":"pointer",transition:"background 0.1s",animation:"dashRowIn 0.2s ease-out both",animationDelay:`${l*10}ms`},onClick:()=>{_||ce({id:r.pole_id,name:r.pole_name,level:"pole"})},onContextMenu:y=>Ye(y,[..._?[]:[{label:"Open",icon:Ft,onClick:()=>ce({id:r.pole_id,name:r.pole_name,level:"pole"})},{label:"Open in HeightIQ",icon:ze,onClick:()=>_e(b,r)}],{label:"Stats",icon:oe,onClick:()=>Z({title:r.pole_name,level:"pole",stats:[{label:"Status",value:c,accent:z},{label:"Last activity",value:Jn(r.last_activity??null,g)},{label:"Flagged",value:r.flagged?"Yes":"No",accent:r.flagged?"var(--pole-flagged)":void 0},{label:"Latitude",value:zn(r)?.latitude.toFixed(6)??"-"},{label:"Longitude",value:zn(r)?.longitude.toFixed(6)??"-"}]})},...n?[{label:"Delete",icon:pe,onClick:()=>yn(r.pole_id,r.pole_name),danger:!0}]:[]]),onMouseEnter:y=>y.currentTarget.style.background="var(--hover-bg)",onMouseLeave:y=>y.currentTarget.style.background="transparent",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,minWidth:0},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:z}}),e.jsx(Yt,{size:13,strokeWidth:2,style:{color:"var(--text-muted)",flexShrink:0}}),e.jsx("span",{title:r.pole_name||void 0,style:{fontSize:12.5,fontFamily:"monospace",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.pole_name}),_&&e.jsx("span",{style:{fontSize:9.5,fontWeight:700,color:"var(--text-muted)",letterSpacing:"0.04em"},children:"EMPTY"}),e.jsx(qe,{count:!!r.flagged,title:"Flagged for review"}),!_&&e.jsx(de,{size:11,style:{color:"var(--text-muted)",flexShrink:0,opacity:.4}})]}),e.jsx("div",{children:e.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:z,padding:"2px 7px",borderRadius:4,background:`color-mix(in srgb,${z} 12%,transparent)`,whiteSpace:"nowrap"},children:c})}),je.allowed&&e.jsx("div",{children:je.byPoleId[r.pole_id]?e.jsx(Po,{row:je.byPoleId[r.pole_id]}):e.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"-"})}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:Jn(r.last_activity??null,g)}),e.jsx("div",{title:r.annotated_by_email||void 0,style:{fontSize:11.5,color:r.annotated_by_email?"var(--text-secondary)":"var(--text-muted)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.annotated_by_email||"-"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:3},onClick:y=>y.stopPropagation(),children:[e.jsx("button",{onClick:()=>_e(b,r),disabled:_||L===`${b.batch_id}:${r.pole_id}`,style:{display:"flex",alignItems:"center",gap:3,background:"color-mix(in srgb,var(--color-brand) 10%,transparent)",color:"var(--color-brand)",fontSize:10.5,fontWeight:600,cursor:_?"not-allowed":"pointer",border:"1px solid color-mix(in srgb,var(--color-brand) 25%,transparent)",padding:"3px 8px",borderRadius:5,transition:"background 0.12s,border-color 0.12s",opacity:_?.4:1},title:_?"No photos yet: upload a folder named after this asset to fill it":"Open pole in HeightI
26Q",onMouseEnter:y=>{_||(y.currentTarget.style.background="color-mix(in srgb,var(--color-brand) 22%,transparent)",y.currentTarget.style.borderColor="color-mix(in srgb,var(--color-brand) 50%,transparent)")},onMouseLeave:y=>{y.currentTarget.style.background="color-mix(in srgb,var(--color-brand) 10%,transparent)",y.currentTarget.style.borderColor="color-mix(in srgb,var(--color-brand) 25%,transparent)"},children:L===`${b.batch_id}:${r.pole_id}`?e.jsx(ee,{size:10,style:{animation:"spin 1s linear infinite"}}):e.jsxs(e.Fragment,{children:["Open ",e.jsx(ze,{size:10,strokeWidth:2.5})]})}),n&&e.jsx(Je,{title:"Delete asset",onClick:()=>yn(r.pole_id,r.pole_name)})]})]},r.pole_id)}),j==="batch"&&!ve&&e.jsx(Bt,{page:ne,pageSize:ae,total:St,totalPages:Jt,onPageChange:ge,onPageSizeChange:t=>{Vt(t),ge(1)}}),j==="pole"&&Ie.map((t,l)=>{const r=t.data,b=r.kind==="image",g=b?"#10b981":"#6366f1",z=b?sa:la;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:ea,columnGap:16,padding:"10px 18px",borderTop:"1px solid var(--border-subtle)",alignItems:"center",transition:"background 0.1s",animation:"dashRowIn 0.2s ease-out both",animationDelay:`${l*10}ms`},onMouseEnter:c=>c.currentTarget.style.background="var(--hover-bg)",onMouseLeave:c=>c.currentTarget.style.background="transparent",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,minWidth:0},children:[b&&r.fileKey?e.jsx(Xi,{fileKey:r.fileKey,size:36}):e.jsx("div",{style:{width:36,height:36,borderRadius:7,flexShrink:0,background:`color-mix(in srgb,${g} 14%,transparent)`,color:g,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(z,{size:16,strokeWidth:1.8})}),e.jsx("span",{title:r.name||void 0,style:{fontSize:12.5,fontFamily:"monospace",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.name})]}),e.jsx("div",{children:e.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:g,padding:"2px 7px",borderRadius:4,background:`color-mix(in srgb,${g} 12%,transparent)`},children:b?"Image":"CSV"})}),e.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:r.description}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsxs("button",{onClick:()=>{b&&r.fileKey?en({fileKey:r.fileKey,title:r.name}):!b&&r.csvData&&tn({title:r.name,files:[r.csvData]})},style:{display:"flex",alignItems:"center",gap:4,fontSize:11,fontWeight:600,color:g,background:`color-mix(in srgb,${g} 10%,transparent)`,border:`1px solid color-mix(in srgb,${g} 25%,transparent)`,padding:"3px 9px",borderRadius:6,cursor:"pointer"},children:[e.jsx(uo,{size:11,strokeWidth:2})," Preview"]})})]},r.id)})]})})})}),ie&&e.jsx(Hi,{x:ie.x,y:ie.y,options:ie.options,expandLeft:ie.expandLeft,onClose:()=>ur(null)}),D&&e.jsx(Fo,{title:`Open ${D.label} in Clear2Attach`,message:e.jsxs("span",{children:[D.unannotated," of ",D.total," poles in this ",D.noun," have no annotation yet."]}),onDismiss:()=>H(null),options:[{label:"Annotated poles only",variant:"primary",description:"Only poles with measurements are opened. Recommended.",onSelect:()=>{const t=D.build(!1);H(null),Nr(t,a)}},{label:"Include them",variant:"neutral",description:"They appear on the map and in the table with no attachments and are reported as Skipped, not passed.",onSelect:()=>{const t=D.build(!0);H(null),Nr(t,a)}}]}),Tt&&e.jsx(Ui,{title:Tt.title,level:Tt.level,stats:Tt.stats,onClose:()=>Z(null)}),wt&&e.jsx(Ki,{title:wt.title,description:wt.description,onConfirm:wt.onConfirm,onClose:()=>Ta(null)}),be&&e.jsx(Yi,{entityType:be.entityType,currentName:be.currentName,onConfirm:t=>Xa(t,be.id,be.apiFn,`Rename ${be.entityType} · ${be.currentName} â ${t}`),onClose:()=>Ur(null)}),Qt&&e.jsx(Gi,{projectId:Qt.projectId,projectName:Qt.projectName,onClose:()=>Kr(null)}),pr&&e.jsx(qi,{fileKey:pr.fileKey,title:pr.title,onClose:()=>en(null)}),hr&&e.jsx(Vi,{title:hr.title,files:hr.files,onClose:()=>tn(null)}),U&&e.jsx($o,{scope:U,onClose:()=>K(null)}),Aa&&e.jsx(To,{onCancel:()=>{Vr||qr(!1)},onConfirm:t=>{Ha(t)},creating:Vr,error:Da}),O&&e.jsx(No,{scopeType:O.scopeType,scopeId:O.scopeId,scopeName:O.scopeName,onClose:()=>P(null)}),Ee&&e.jsx(Bo,{title:"Delete project?",confirmName:Ee.name,confirmLabel:"Delete project",busyLabel:"Moving to trash...",onClose:()=>gr(null),onConfirm:Ga,warning:e.jsxs(e.Fragment,{children:[e.jsx("strong",{style:{color:"var(--text-primary)"},children:Ee.name})," and"," ",e.jsx("strong",{style:{color:"#dc2626"},children:"all of its circuits, batches, assets and their data"})," ","will be permanently deleted.",e.jsx("br",{}),e.jsx("strong",{style:{color:"var(--text-primary)"},children:"This cannot be undone."})]})}),Le&&e.jsx(po,{title:Le.title,message:Le.message,confirmLabel:Le.confirmLabel,danger:!0,onConfirm:()=>{Le.resolve(!0),mr(null)},onCancel:()=>{Le.resolve(!1),mr(null)}}),G&&e.jsx("div",{style:{position:"fixed",inset:0,zIndex:100,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(So,{onClose:()=>X(!1),lockedProjectId:Cr.lockedProjectId,lockedFdhId:Cr.lockedFdhId,initialBatchId:Cr.initialBatchId})})]})}function Ks(){const n=aa(a=>a.user);return n?e.jsx("div",{className:"flex-1 overflow-y-auto",style:{background:"var(--bg-primary)",display:"flex",flexDirection:"column"}
26,children:e.jsx(Ji,{admin:Qa(n)})}):e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",minHeight:300},children:[e.jsx(ee,{size:28,style:{color:"var(--color-brand)",animation:"spin 1s linear infinite"}}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]})}const Qi={padding:"20px 32px",display:"flex",alignItems:"center",justifyContent:"space-between",gap:16},Zi={fontFamily:"var(--font-display)",fontSize:18,fontWeight:700,letterSpacing:"-0.02em",color:"var(--text-primary)",margin:0},es={fontSize:12,color:"var(--text-secondary)",marginTop:4},ts={display:"flex",alignItems:"center",gap:8,height:32,padding:"0 12px",borderRadius:8,background:"var(--card-bg)",border:"1px solid var(--border-color)",boxShadow:"var(--shadow-soft)"},rs={display:"flex",alignItems:"center",gap:6,height:32,padding:"0 14px",borderRadius:8,border:0,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)",fontSize:13,fontWeight:600,letterSpacing:"-0.005em",cursor:"pointer"},ns={display:"flex",alignItems:"center",gap:6,height:32,padding:"0 12px",borderRadius:8,border:"1px solid var(--border-color)",background:"var(--card-bg)",color:"var(--text-secondary)",fontSize:12.5,fontWeight:500,cursor:"pointer",boxShadow:"var(--shadow-soft)"},as={display:"inline-flex",alignItems:"center",gap:6,padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-color)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,cursor:"pointer"},os={border:"1px solid var(--border-color)",borderRadius:12,background:"var(--card-bg)",overflow:"hidden",boxShadow:"var(--shadow-card)"},Ut={display:"grid",alignItems:"center",columnGap:Oi,padding:"9px 20px",borderBottom:"1px solid var(--border-color)",background:"var(--bg-tertiary)",fontSize:10.5,fontWeight:700,letterSpacing:"0.07em",textTransform:"uppercase",color:"var(--text-secondary)"},is={padding:48,textAlign:"center",borderRadius:12,border:"1px dashed var(--border-color)",color:"var(--text-muted)",fontSize:13},Me={width:28,height:28,borderRadius:8,border:0,padding:0,background:"transparent",color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",transition:"background 0.12s, color 0.12s"};export{Ks 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.