@commandgarden/cli 2.8.0 → 2.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -404,7 +404,7 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
404
404
  *
405
405
  * This source code is licensed under the ISC license.
406
406
  * See the LICENSE file in the root directory of this source tree.
407
- */const L1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],P1=K("triangle-alert",L1),I1={reached:$v,on_track:A1,behind:_c,at_risk:P1},O1={reached:"text-success",on_track:"text-success",behind:"text-warning",at_risk:"text-error"},_1={reached:"bg-success/10",on_track:"bg-success/5",behind:"bg-warning/10",at_risk:"bg-error/10"};function M1(e,t,n){const s=n.find(r=>r.projectId===e&&r.activity===t);return(s==null?void 0:s.totalHours)??0}function D1({goals:e,activityHours:t,projectNames:n,activityNames:s,month:r,today:a}){return e.length===0?null:i.jsx("div",{className:"border border-base-300",children:e.map((o,l)=>{const c=M1(o.projectId,o.activity,t),u=Nv({targetHours:o.targetHours,actualHours:c,month:r,today:a}),m=n.get(o.projectId),d=I1[u.status];return i.jsxs("div",{className:`grid grid-cols-[auto_1fr_auto_1fr] gap-0 ${_1[u.status]} ${l>0?"border-t border-base-300":""}`,children:[i.jsx("div",{className:"p-3 border-r border-base-300 flex items-center justify-center",children:i.jsx(d,{size:18,className:O1[u.status]})}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-display font-semibold text-sm",children:m??o.projectId}),i.jsxs("div",{className:"font-mono text-[0.6rem] opacity-50 mt-0.5",children:[m?`${o.projectId} · `:"",s.get(`${o.projectId}\0${o.activity}`)??o.activity]})]}),i.jsxs("div",{className:"p-3 border-r border-base-300 text-right min-w-[7rem]",children:[i.jsxs("div",{className:"font-display font-semibold text-sm",children:[Math.round(c*10)/10,"/",o.targetHours,"h"]}),i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mt-0.5",children:[o.targetDays,"d target"]})]}),i.jsxs("div",{className:"p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Cv,{percentage:u.percentage,status:u.status,className:"flex-1"}),i.jsxs("span",{className:"font-mono text-xs font-medium min-w-[3rem] text-right",children:[Math.round(u.percentage),"%"]})]}),u.status==="reached"?i.jsx("div",{className:"font-mono text-[0.6rem] font-medium text-success uppercase tracking-[0.1em]",children:"Goal reached"}):i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:u.workingDaysRemaining>0?`Book ${Math.round(u.hoursPerDayNeeded*10)/10}h/day · ${u.workingDaysRemaining} days left`:`${Math.round(u.daysRemaining*10)/10} days remaining`})]})]},o.id)})})}function $1({goals:e,month:t,onGoalChange:n,knownCombos:s,projectNames:r,activityNames:a,onRefreshProjects:o,refreshingProjects:l}){const[c,u]=b.useState(""),[m,d]=b.useState(""),[f,v]=b.useState(null),[y,x]=b.useState(""),[w,g]=b.useState(!1),p=b.useMemo(()=>{const T=new Set(e.map(L=>`${L.projectId}\0${L.activity}`));return s.filter(L=>!T.has(`${L.projectId}\0${L.activity}`))},[s,e]);function h(T){const L=T.indexOf("\0");return L<0?null:{projectId:T.slice(0,L),activity:T.slice(L+1)}}function j(T){return r.get(T)??T}function k(T,L){const F=a.get(`${T}\0${L}`);return F?`${j(T)} / ${F}`:`${j(T)} / ${L}`}async function C(){const T=h(c),L=parseFloat(m);if(!(!T||isNaN(L)||L<.5||L>31)){g(!0);try{await B.upsertGoal({month:t,projectId:T.projectId,activity:T.activity,targetDays:L}),u(""),d(""),n()}finally{g(!1)}}}async function S(T){g(!0);try{await B.deleteGoal(T),n()}finally{g(!1)}}async function N(T){const L=parseFloat(y);if(isNaN(L)||L<.5||L>31){v(null);return}g(!0);try{await B.upsertGoal({month:T.month,projectId:T.projectId,activity:T.activity,targetDays:L}),v(null),n()}finally{g(!1)}}return i.jsxs("details",{children:[i.jsxs("summary",{className:"cursor-pointer text-sm font-semibold mb-2",children:["Manage goals (",e.length,")"]}),i.jsxs("div",{className:"mt-2 space-y-3",children:[e.length>0&&i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-xs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Project"}),i.jsx("th",{children:"Activity"}),i.jsx("th",{className:"text-right",children:"Target (days)"}),i.jsx("th",{className:"text-right",children:"Target (hours)"}),i.jsx("th",{children:"Actions"})]})}),i.jsx("tbody",{children:e.map(T=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("div",{className:"text-sm",children:j(T.projectId)}),r.has(T.projectId)&&i.jsx("div",{className:"font-mono text-[0.6rem] opacity-50",children:T.projectId})]}),i.jsxs("td",{children:[i.jsx("div",{className:"text-sm",children:a.get(`${T.projectId}\0${T.activity}`)??T.activity}),i.jsx("div",{className:"font-mono text-[0.6rem] opacity-50",children:T.activity})]}),i.jsx("td",{className:"text-right",children:f===T.id?i.jsx("input",{type:"number",step:"0.5",className:"input input-bordered input-xs w-20 text-right",value:y,onChange:L=>x(L.target.value),onBlur:()=>N(T),onKeyDown:L=>{L.key==="Enter"&&N(T),L.key==="Escape"&&v(null)},autoFocus:!0}):T.targetDays}),i.jsx("td",{className:"text-right",children:T.targetHours}),i.jsxs("td",{className:"flex gap-1",children:[i.jsx("button",{className:"btn btn-ghost btn-xs font-mono",onClick:()=>{v(T.id),x(String(T.targetDays))},disabled:w,"aria-label":`Edit goal ${T.projectId} ${T.activity}`,children:"Edit"}),i.jsx("button",{className:"btn btn-ghost btn-xs text-error font-mono",onClick:()=>S(T.id),disabled:w,"aria-label":`Delete goal ${T.projectId} ${T.activity}`,children:"Del"})]})]},T.id))})]})}),i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsxs("select",{className:"select select-bordered select-sm",value:c,onChange:T=>u(T.target.value),children:[i.jsx("option",{value:"",children:"Select project / activity…"}),p.map(T=>i.jsx("option",{value:`${T.projectId}\0${T.activity}`,children:k(T.projectId,T.activity)},`${T.projectId}\0${T.activity}`))]}),i.jsx("input",{type:"number",step:"0.5",min:"0.5",max:"31",placeholder:"Days",className:"input input-bordered input-sm w-24",value:m,onChange:T=>d(T.target.value)}),i.jsx("button",{className:"btn btn-primary btn-sm",onClick:C,disabled:w||!c,children:"Add"}),i.jsx("button",{className:"btn btn-ghost btn-sm font-mono text-xs opacity-60",onClick:o,disabled:l,children:l?"Refreshing…":"Refresh projects"})]})]})]})}function R1(e,t){var G;const[n,s]=b.useState([]),[r,a]=b.useState([]),[o,l]=b.useState(null),[c,u]=b.useState([]),m=b.useRef(c);m.current=c;const[d,f]=b.useState(!1),v=b.useCallback(async()=>{try{const E=await B.getGoals(e);s(E.goals)}catch{}},[e]),y=b.useCallback(async()=>{try{const E=await B.getCachedReport(e);E.data?(a(E.data),l(E.fetchedAt)):(a([]),l(null))}catch{}},[e]),x=b.useCallback(async()=>{try{const E=await B.getCachedProjects();E.data&&u(E.data)}catch{}},[]),w=b.useCallback(async()=>{f(!0);try{const E=await B.run("timetracking/projects",{month:e});if(E.ok&&E.data&&E.data.length>0){const D=E.data.map(I=>({projectId:String(I.projectId??""),projectName:String(I.projectName??""),activityNumber:String(I.activityNumber??""),activityName:String(I.activityName??""),category:String(I.category??""),linePropertyId:String(I.linePropertyId??"")}));u(D),await B.cacheProjects(D)}}catch{}f(!1)},[e]);b.useEffect(()=>{v(),y(),x()},[v,y,x]);const g=t==null?void 0:t.data;b.useEffect(()=>{if(g&&g.length>0){l(null),B.cacheReport(e,g).catch(()=>{});const E=new Set,D=[];for(const I of g){const R=String(I.projectId??""),A=String(I.activity??"");if(!R||!A)continue;const _=`${R}\0${A}`;E.has(_)||(E.add(_),D.push({projectId:R,projectName:I.projectName?String(I.projectName):R,activityNumber:A,activityName:I.activityName?String(I.activityName):A,category:String(I.category??""),linePropertyId:""}))}if(D.length>0){const I=new Map;for(const A of m.current)I.set(`${A.projectId}\0${A.activityNumber}`,A);for(const A of D)I.set(`${A.projectId}\0${A.activityNumber}`,A);const R=Array.from(I.values());u(R),B.cacheProjects(R).catch(()=>{})}}},[g,e]);const p=((t==null?void 0:t.data)??[]).length>0?(t==null?void 0:t.data)??[]:r,h=p===r&&r.length>0&&!((G=t==null?void 0:t.data)!=null&&G.length),{projectNames:j,activityNames:k}=b.useMemo(()=>{const E=new Map,D=new Map;for(const I of c)I.projectId&&I.projectName&&E.set(I.projectId,I.projectName),I.projectId&&I.activityNumber&&I.activityName&&D.set(`${I.projectId}\0${I.activityNumber}`,I.activityName);for(const I of p){const R=String(I.projectId??""),A=I.projectName?String(I.projectName):null;R&&A&&E.set(R,A);const _=String(I.activity??""),$=I.activityName?String(I.activityName):null;R&&_&&$&&D.set(`${R}\0${_}`,$)}return{projectNames:E,activityNames:D}},[c,p]),{projectList:C,totalHours:S,draftCount:N,workingDayCount:T}=b.useMemo(()=>{const E=new Map;let D=0,I=0;const R=new Set;for(const A of p){const _=String(A.projectId??"Unknown"),$=Number(A.hours??0),z=String(A.date??""),J=String(A.status??""),xe=String(A.activity??"");D+=$,z&&R.add(z),J==="draft"&&I++,E.has(_)||E.set(_,{projectId:_,totalHours:0,entryCount:0,activities:new Set});const Me=E.get(_);if(Me.totalHours+=$,Me.entryCount++,xe){const un=k.get(`${_}\0${xe}`)??xe;Me.activities.add(un)}}return{projectList:Array.from(E.values()).sort((A,_)=>_.totalHours-A.totalHours),totalHours:D,draftCount:I,workingDayCount:R.size}},[p,k]),L=b.useMemo(()=>{const E=new Map;for(const D of p){const I=String(D.projectId??"Unknown"),R=String(D.activity??""),A=Number(D.hours??0),_=`${I}\0${R}`,$=E.get(_);$?$.totalHours+=A:E.set(_,{projectId:I,activity:R,totalHours:A})}return Array.from(E.values())},[p]),F=b.useMemo(()=>c.length>0?c.map(E=>({projectId:E.projectId,activity:E.activityNumber})):L.map(E=>({projectId:E.projectId,activity:E.activity})),[c,L]),H=new Date().toISOString().slice(0,10);return{goals:n,loadGoals:v,rows:p,isCached:h,cachedAt:o,projectNames:j,activityNames:k,projectList:C,totalHours:S,draftCount:N,workingDayCount:T,activityHours:L,allCombos:F,todayStr:H,refreshProjects:w,refreshingProjects:d}}function z1(){const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function F1(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function B1(){const[e,t]=b.useState(z1()),[n,s]=b.useState(!1),{running:r,result:a,error:o,approvalPending:l,approvalId:c,run:u,handleApproval:m,reset:d}=Sr(),{goals:f,loadGoals:v,rows:y,isCached:x,cachedAt:w,projectNames:g,activityNames:p,projectList:h,totalHours:j,draftCount:k,workingDayCount:C,activityHours:S,allCombos:N,todayStr:T,refreshProjects:L,refreshingProjects:F}=R1(e,a),H=(o==null?void 0:o.includes("auth_required"))||(o==null?void 0:o.includes("sign in")),G=b.useCallback(async()=>{const E={};e&&(E.month=e),await u("timetracking/report",E),await v()},[e,u,v]);return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Time Tracking"}),i.jsxs("div",{className:"flex items-end gap-4 mb-6",children:[i.jsxs("label",{className:"form-control",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Month"}),i.jsx("input",{type:"month",className:"input input-bordered input-sm",value:e,onChange:E=>{t(E.target.value),d()},onClick:E=>{var D,I;return(I=(D=E.target).showPicker)==null?void 0:I.call(D)}})]}),i.jsx("button",{className:"btn btn-primary btn-sm",onClick:G,disabled:r,children:r?"Loading...":"Load report"})]}),r&&!l&&i.jsx(ht,{label:"Fetching timetracking data..."}),l&&i.jsxs("div",{className:"alert alert-warning mb-4",children:[i.jsx("span",{children:"This connector requires approval before proceeding."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>m(!0),disabled:!c,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>m(!1),disabled:!c,children:"Reject"})]})]}),H&&i.jsx(Tn,{message:"Sign in to the timetracking portal in Chrome, then try again."}),o&&!H&&i.jsx("div",{className:"alert alert-error mb-4",children:i.jsx("span",{children:o})}),y.length>0&&i.jsxs(i.Fragment,{children:[x&&w&&i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-2",children:["Showing cached data from ",F1(w)]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 border border-base-300 mb-6",children:[i.jsxs("div",{className:"p-3 border-r border-b border-base-300 md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Total hours"}),i.jsx("div",{className:"font-display text-xl font-bold",children:j.toFixed(1)})]}),i.jsxs("div",{className:"p-3 border-b border-base-300 md:border-r md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Working days"}),i.jsx("div",{className:"font-display text-xl font-bold",children:C})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Projects"}),i.jsx("div",{className:"font-display text-xl font-bold",children:h.length})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Draft entries"}),i.jsx("div",{className:"font-display text-xl font-bold",children:k})]})]}),i.jsx("h3",{className:"font-display text-base font-semibold mb-3",children:"By project"}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-6",children:i.jsxs("table",{className:"table table-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Project"}),i.jsx("th",{children:"Activities"}),i.jsx("th",{className:"text-right",children:"Hours"}),i.jsx("th",{className:"text-right",children:"Entries"})]})}),i.jsx("tbody",{children:h.map(E=>i.jsxs("tr",{children:[i.jsx("td",{children:g.has(E.projectId)?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-sm",children:g.get(E.projectId)}),i.jsx("div",{className:"font-mono text-[0.6rem] opacity-50",children:E.projectId})]}):i.jsx("span",{className:"font-mono text-sm",children:E.projectId})}),i.jsx("td",{className:"text-sm",children:Array.from(E.activities).join(", ")}),i.jsx("td",{className:"text-right font-semibold",children:E.totalHours.toFixed(1)}),i.jsx("td",{className:"text-right",children:E.entryCount})]},E.projectId))})]})}),i.jsxs("details",{open:n,onToggle:E=>s(E.target.open),children:[i.jsxs("summary",{className:"cursor-pointer text-sm font-semibold mb-2",children:["Raw booking lines (",y.length,")"]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"table table-xs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Date"}),i.jsx("th",{children:"Project"}),i.jsx("th",{children:"Activity"}),i.jsx("th",{className:"text-right",children:"Hours"}),i.jsx("th",{children:"Status"})]})}),i.jsx("tbody",{children:y.map((E,D)=>i.jsxs("tr",{children:[i.jsx("td",{children:String(E.date??"")}),i.jsx("td",{className:"font-mono text-xs",children:String(E.projectId??"")}),i.jsx("td",{children:String(E.activity??"")}),i.jsx("td",{className:"text-right",children:Number(E.hours??0).toFixed(1)}),i.jsx("td",{children:i.jsx(W,{variant:String(E.status)==="posted"?"success":"warning",size:"xs",children:String(E.status??"")})})]},D))})]})})]})]}),a&&(a.data??[]).length===0&&y.length===0&&!o&&i.jsxs("p",{className:"text-sm opacity-50",children:["No entries found for ",e,"."]}),f.length>0&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h3",{className:"font-display text-base font-semibold mb-3",children:"Goal progress"}),i.jsx(D1,{goals:f,activityHours:S,projectNames:g,activityNames:p,month:e,today:T})]}),i.jsx("div",{className:"mt-6",children:i.jsx($1,{goals:f,month:e,onGoalChange:v,knownCombos:N,projectNames:g,activityNames:p,onRefreshProjects:L,refreshingProjects:F})})]})}const Qh={"MBTMY THE BASE CAMP":"res-rere-m6vz23ty@mercedes-benz.com","MBTMY THE TRAILHEAD":"res-rere-m6vc2q4d@mercedes-benz.com","MBTMY THE FOOTHILLS":"res-rere-m6vcb79c@mercedes-benz.com","MBTMY THE BRIDGE":"res-rere-m6vgcah6@mercedes-benz.com","MBTMY THE RIDGE":"res-rere-m6vjxdkc@mercedes-benz.com","MBTMY THE MEADOW":"res-rere-m6vhkzmd@mercedes-benz.com","MBTMY THE FOREST":"res-rere-m6vhsc6h@mercedes-benz.com","MBTMY THE LOOKOUT":"res-rere-m6vjqgrq@mercedes-benz.com","MBTMY THE CLIFFSIDE":"res-rere-m6vjl2tw@mercedes-benz.com","MBTMY THE LEDGE":"res-rere-m6vjfbmr@mercedes-benz.com","MBTMY THE HIGHPOINT":"res-rere-m6vjblgb@mercedes-benz.com","MBTMY THE VISTA":"RES-RERE-M6VJ7ZUW@mercedes-benz.com","MBTMY THE SHOULDER":"res-rere-m6vj3tuq@mercedes-benz.com","MBTMY THE PINNACLE":"res-rere-m6vhxd4c@mercedes-benz.com","MBTMY THE DESCENT":"res-rere-m6vzgysp@mercedes-benz.com"},U1=Object.fromEntries(Object.entries(Qh).map(([e,t])=>[t.toLowerCase(),e.replace(/^MBTMY\s+/i,"")])),hd={free:"success",busy:"error",tentative:"warning",oof:"secondary",elsewhere:"info"},W1={free:"bg-success/20 border-success/40",busy:"bg-error/20 border-error/40",tentative:"bg-warning/20 border-warning/40",oof:"bg-secondary/20 border-secondary/40",elsewhere:"bg-info/20 border-info/40"},H1={free:"bg-success/35 border-success/60",busy:"bg-error/35 border-error/60",tentative:"bg-warning/35 border-warning/60",oof:"bg-secondary/35 border-secondary/60",elsewhere:"bg-info/35 border-info/60"};function Mn(e){const t=e.match(/(\d{1,2}:\d{2})/);return t?t[1]:e}function V1({rows:e}){var r,a;const[t,n]=b.useState(null),s=e.reduce((o,l)=>o+(l.durationMin??0),0);return i.jsxs("div",{children:[s>0&&i.jsxs("div",{className:"mb-6",children:[i.jsx("div",{className:"flex h-10 overflow-hidden gap-px border border-base-300",children:e.map((o,l)=>{const c=s>0?(o.durationMin??0)/s*100:0;if(c<.5)return null;const u=t===l,m=u?H1[o.state??""]??"bg-base-300":W1[o.state??""]??"bg-base-300";return i.jsxs("div",{className:`${m} border flex items-center justify-center text-xs transition-colors duration-75 cursor-default relative`,style:{width:`${c}%`},onMouseEnter:()=>n(l),onMouseLeave:()=>n(null),children:[c>12&&i.jsx("span",{className:"opacity-60 truncate px-1 font-mono text-[0.65rem] uppercase tracking-wide",children:o.state}),u&&i.jsxs("div",{className:"absolute -top-9 left-1/2 -translate-x-1/2 bg-base-300 border border-base-content/10 px-2 py-1 text-[0.65rem] font-mono whitespace-nowrap z-10 pointer-events-none",children:[o.state,": ",Mn(o.start??""),"–",Mn(o.end??"")," (",o.durationMin,"m)"]})]},l)})}),i.jsxs("div",{className:"flex justify-between mt-1",children:[i.jsx("span",{className:"font-mono text-[0.6rem] opacity-30",children:Mn(((r=e[0])==null?void 0:r.start)??"")}),i.jsx("span",{className:"font-mono text-[0.6rem] opacity-30",children:Mn(((a=e[e.length-1])==null?void 0:a.end)??"")})]})]}),i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Start"}),i.jsx("th",{children:"End"}),i.jsx("th",{children:"State"}),i.jsx("th",{className:"text-right",children:"Duration"})]})}),i.jsx("tbody",{children:e.map((o,l)=>i.jsxs("tr",{className:`transition-colors duration-75 ${t===l?"bg-base-200":"hover:bg-base-200"}`,onMouseEnter:()=>n(l),onMouseLeave:()=>n(null),children:[i.jsx("td",{className:"font-mono text-sm",children:Mn(o.start??"")}),i.jsx("td",{className:"font-mono text-sm",children:Mn(o.end??"")}),i.jsx("td",{children:i.jsx(W,{variant:hd[o.state??""]??"neutral",children:o.state})}),i.jsxs("td",{className:"text-right font-mono text-sm",children:[o.durationMin,"m"]})]},l))})]})}),i.jsx("div",{className:"flex flex-wrap gap-4 mt-3",children:Object.entries(hd).map(([o,l])=>i.jsx("div",{className:"flex items-center gap-1.5",children:i.jsx(W,{variant:l,size:"xs",children:o})},o))})]})}const K1=[{id:1,name:"The Base Camp",x:685,y:75,w:160,h:85,capacity:10},{id:2,name:"The Trailhead",x:880,y:130,w:95,h:100,capacity:4},{id:3,name:"The Foothills",x:880,y:255,w:95,h:100,capacity:5},{id:4,name:"The Bridge",x:880,y:380,w:95,h:100,capacity:4},{id:5,name:"The Ridge",x:650,y:620,w:250,h:110,capacity:18},{id:6,name:"The Meadow",x:535,y:480,w:92,h:80,capacity:6},{id:7,name:"The Forest",x:428,y:480,w:92,h:80,capacity:16},{id:8,name:"The Lookout",x:540,y:795,w:110,h:75,capacity:4},{id:9,name:"The Cliffside",x:410,y:795,w:110,h:75,capacity:4},{id:10,name:"The Ledge",x:280,y:795,w:110,h:75,capacity:4},{id:11,name:"The Highpoint",x:150,y:795,w:110,h:75,capacity:10},{id:12,name:"The Vista",x:30,y:750,w:100,h:115,capacity:12},{id:13,name:"The Shoulder",x:30,y:620,w:100,h:110,capacity:4},{id:14,name:"The Pinnacle",x:30,y:300,w:120,h:260,capacity:16},{id:15,name:"The Descent",x:30,y:60,w:120,h:170,capacity:6}],G1=[{name:"The Summit",x:170,y:60,w:230,h:500},{name:"The Lodge",x:670,y:60,w:190,h:500},{name:"The Plateau",x:150,y:620,w:470,h:150}],q1=[{x:90,y:28,dir:"down"},{x:355,y:28,dir:"down"},{x:765,y:28,dir:"down"},{x:24,y:596,dir:"left"}],Y1={free:"fill-success/15 stroke-success",busy:"fill-error/15 stroke-error",unknown:"fill-base-200/60 stroke-base-300"};function li(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"").replace(/^mbtmy/,"").replace(/^the/,"")}function Q1({statuses:e={},selected:t,onSelect:n}){const r=`hatch-${b.useId().replace(/[^a-zA-Z0-9]/g,"")}`,a=new Map(Object.entries(e).map(([c,u])=>[li(c),u])),o=t?li(t):null,l=c=>a.get(li(c.name))??"unknown";return i.jsxs("div",{className:"border border-base-300 p-3 sm:p-4",children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("svg",{viewBox:"0 0 1000 900",className:"min-w-[560px] w-full h-auto select-none",role:"group","aria-label":"Office floor plan",children:[i.jsx("defs",{children:i.jsx("pattern",{id:r,width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"7",strokeWidth:"1",className:"stroke-base-300"})})}),i.jsx("rect",{x:"14",y:"40",width:"972",height:"846",className:"fill-base-100 stroke-base-content/60",strokeWidth:"2"}),G1.map(c=>i.jsxs("g",{children:[i.jsx("rect",{x:c.x,y:c.y,width:c.w,height:c.h,className:"fill-base-200/30 stroke-base-300",strokeWidth:"1",strokeDasharray:"4 4"}),i.jsx("text",{x:c.x+c.w/2,y:c.y+c.h/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:"13",letterSpacing:"2",className:"fill-base-content/25 font-mono uppercase",children:c.name})]},c.name)),i.jsxs("g",{children:[i.jsx("rect",{x:"420",y:"60",width:"232",height:"405",fill:`url(#${r})`,className:"stroke-base-300",strokeWidth:"1"}),i.jsx("rect",{x:"437",y:"192",width:"198",height:"140",className:"fill-base-100 stroke-base-300",strokeWidth:"1"}),i.jsx("text",{x:"536",y:"255",textAnchor:"middle",fontSize:"12",letterSpacing:"2",className:"fill-base-content/40 font-mono uppercase",children:"Courtyard"}),i.jsx("text",{x:"536",y:"275",textAnchor:"middle",fontSize:"8",letterSpacing:"1.5",className:"fill-base-content/25 font-mono uppercase",children:"Reflective pool"})]}),i.jsx("rect",{x:"680",y:"758",width:"220",height:"112",fill:`url(#${r})`,className:"stroke-base-300",strokeWidth:"1"}),i.jsx("text",{x:"790",y:"818",textAnchor:"middle",fontSize:"9",letterSpacing:"1.5",className:"fill-base-content/30 font-mono uppercase",children:"Facilities"}),q1.map((c,u)=>i.jsx("g",{children:c.dir==="left"?i.jsxs(i.Fragment,{children:[i.jsx("path",{d:`M ${c.x} ${c.y-6} L ${c.x} ${c.y+6} L ${c.x-7} ${c.y} Z`,className:"fill-base-content/40"}),i.jsx("text",{x:c.x+10,y:c.y,textAnchor:"start",dominantBaseline:"central",fontSize:"8",letterSpacing:"1",className:"fill-base-content/40 font-mono uppercase",children:"Entry"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:`M ${c.x-6} ${c.y} L ${c.x+6} ${c.y} L ${c.x} ${c.y+7} Z`,className:"fill-base-content/40"}),i.jsx("text",{x:c.x,y:c.y-5,textAnchor:"middle",fontSize:"8",letterSpacing:"1",className:"fill-base-content/40 font-mono uppercase",children:"Entry"})]})},u)),K1.map(c=>{const u=l(c),m=o!==null&&li(c.name)===o,d=c.w<100;return i.jsxs("g",{role:n?"button":void 0,tabIndex:n?0:void 0,onClick:n?()=>n(c.name):void 0,onKeyDown:n?f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),n(c.name))}:void 0,className:n?"cursor-pointer hover:opacity-75 focus:outline-none transition-opacity":void 0,children:[i.jsx("title",{children:`${c.name} — ${u==="unknown"?"not checked":u}`}),i.jsx("rect",{x:c.x,y:c.y,width:c.w,height:c.h,strokeWidth:u==="unknown"?1:1.5,className:Y1[u]}),m&&i.jsx("rect",{x:c.x+3,y:c.y+3,width:c.w-6,height:c.h-6,className:"fill-none stroke-primary",strokeWidth:"2"}),i.jsx("circle",{cx:c.x+15,cy:c.y+15,r:"9",className:"fill-base-100 stroke-base-content/30",strokeWidth:"1"}),i.jsx("text",{x:c.x+15,y:c.y+15,textAnchor:"middle",dominantBaseline:"central",fontSize:"8.5",className:"fill-base-content/60 font-mono",children:c.id}),i.jsx("text",{x:c.x+c.w/2,y:c.y+c.h/2+(c.h>90?10:8),textAnchor:"middle",fontSize:d?12:13.5,letterSpacing:"0.8",className:"fill-base-content/80 font-mono uppercase font-medium",children:c.name.replace(/^The\s+/i,"")}),i.jsxs("text",{x:c.x+c.w/2,y:c.y+c.h/2+(c.h>90?10:8)+(d?14:16),textAnchor:"middle",fontSize:10.5,letterSpacing:"0.5",className:"fill-base-content/40 font-mono",children:[c.capacity,"p"]})]},c.id)})]})}),i.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-1 mt-3 font-mono text-[0.6rem] uppercase tracking-[0.1em] opacity-70",children:[i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"w-2.5 h-2.5 inline-block bg-success/15 border border-success"})," Available"]}),i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"w-2.5 h-2.5 inline-block bg-error/15 border border-error"})," Busy"]}),i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"w-2.5 h-2.5 inline-block bg-base-200 border border-base-300"})," Not checked"]}),n&&i.jsx("span",{className:"opacity-60",children:"Click a room to select it"})]})]})}function J1(){return new Date().toISOString().slice(0,10)}const pd=[15,30,45,60,90,120,180,240,300,360,420,480,540],Rs=15,gd=Array.from({length:24*4},(e,t)=>{const n=Math.floor(t/4),s=t%4*15;return`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`});function yd(){const e=new Date,t=e.getHours()*60+Math.round(e.getMinutes()/15)*15,n=Math.floor(t/60)%24,s=t%60;return`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function zs(e){const[t,n]=e.split(":").map(Number);return t*60+n}function na(e){const t=Math.floor(e/60)%24,n=e%60;return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function Xn(e){const[t,n]=e.split(":").map(Number),s=t<12?"AM":"PM";return`${t%12===0?12:t%12}:${String(n).padStart(2,"0")} ${s}`}function X1(e){if(e<60)return`${e} min`;const t=Math.floor(e/60),n=e%60;return n===0?`${t}h`:`${t}h ${n}m`}function xd(e){try{const t=new Date(e+"T00:00:00"),n=new Date;n.setHours(0,0,0,0);const s=t.getTime()-n.getTime(),r=Math.round(s/864e5);return r===0?"Today":r===1?"Tomorrow":r===-1?"Yesterday":t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}catch{return e}}function vd(e,t){if(!e)return null;let n=new Date(e);return Number.isNaN(n.getTime())?(n=new Date(`${t}T${e}`),Number.isNaN(n.getTime())?null:n):n}function Z1(e,t,n,s){const r=new Date(`${t}T${n}:00`),a=new Date(r.getTime()+s*6e4);return!e.some(l=>{if(l.state==="free")return!1;const c=vd(l.start,t),u=vd(l.end,t);return c===null||u===null?!1:c<a&&r<u})}const vt=24*60;function vl(e,t){return Math.max(0,Math.min(vt-t,e))}function bd(e){return Math.round(e/15)*15}function eb({startMinutes:e,durationMinutes:t,onChange:n}){const s=b.useRef(null),r=b.useRef(!1),a=v=>{const y=s.current;if(!y)return e;const x=y.getBoundingClientRect(),g=Math.max(0,Math.min(1,(v-x.left)/x.width))*vt;return bd(g)},o=v=>{const y=a(v)-t/2;n(vl(bd(y),t))},l=v=>{r.current=!0,v.currentTarget.setPointerCapture(v.pointerId),o(v.clientX)},c=v=>{r.current&&o(v.clientX)},u=()=>{r.current=!1},m=e/vt*100,d=t/vt*100,f=e+t;return i.jsxs("div",{children:[i.jsxs("div",{ref:s,className:"relative h-10 bg-base-200 border border-base-300 rounded cursor-pointer select-none touch-none",onPointerDown:l,onPointerMove:c,onPointerUp:u,children:[i.jsx("div",{className:"absolute inset-0 flex",children:Array.from({length:8},(v,y)=>i.jsx("div",{className:"flex-1 border-r border-base-300/60 last:border-r-0"},y))}),i.jsx("div",{className:"absolute top-0 h-full bg-primary/20 border border-primary/50 rounded cursor-grab active:cursor-grabbing",style:{left:`${m}%`,width:`${d}%`}}),i.jsx("div",{className:"absolute top-0 h-full flex items-center text-xs font-mono font-semibold text-base-content whitespace-nowrap pointer-events-none",style:{left:d<10?`${m+d+.5}%`:`${m}%`,width:d<10?"auto":`${d}%`,justifyContent:d<10?"flex-start":"center"},children:i.jsxs("span",{className:d<10?"text-base-content/80":"",children:[Xn(na(e)),"–",Xn(na(f))]})})]}),i.jsxs("div",{className:"flex justify-between font-mono text-[0.55rem] opacity-50 mt-1",children:[i.jsx("span",{children:"12 AM"}),i.jsx("span",{children:"3 AM"}),i.jsx("span",{children:"6 AM"}),i.jsx("span",{children:"9 AM"}),i.jsx("span",{children:"12 PM"}),i.jsx("span",{children:"3 PM"}),i.jsx("span",{children:"6 PM"}),i.jsx("span",{children:"9 PM"}),i.jsx("span",{children:"12 AM"})]})]})}function tb(){var gt;const[e,t]=b.useState(J1()),[n,s]=b.useState(()=>zs(yd())),r=na(n),[a,o]=b.useState(120),[l,c]=b.useState("duration"),[u,m]=b.useState(()=>zs(yd())+120),[d,f]=b.useState(1),v=l==="endtime"?Math.max(Rs,u-n):a,y=b.useCallback(O=>{if(O!==l){if(O==="endtime")m(Math.min(vt,n+a));else{const q=Math.max(Rs,u-n),ce=pd.reduce((rt,Ts)=>Math.abs(Ts-q)<Math.abs(rt-q)?Ts:rt);o(ce)}c(O)}},[l,n,a,u]),x=b.useCallback(O=>{const q=Math.max(n+Rs,Math.min(vt,O));m(q)},[n]),w=b.useCallback(O=>{const q=vl(O,l==="endtime"?Rs:a);s(q),l==="endtime"&&m(ce=>Math.max(q+Rs,Math.min(vt,ce)))},[l,a]),[g,p]=b.useState(null),[h,j]=b.useState(null),[k,C]=b.useState(null),[S,N]=b.useState(!1),T=b.useRef(e),{running:L,result:F,error:H,approvalPending:G,approvalId:E,run:D,handleApproval:I}=Sr();b.useEffect(()=>{let O=!1;return B.getCachedRoomAvailability(e).then(q=>{O||(q.data&&q.data.length>0?(j(q.data),C(q.fetchedAt),N(!0)):(j(null),C(null),N(!1)))}).catch(()=>{}),()=>{O=!0}},[e]),b.useEffect(()=>{if(F!=null&&F.data&&F.data.length>0){const O=new Date().toISOString();C(O),N(!1),j(F.data),B.cacheRoomAvailability(T.current,F.data).catch(()=>{})}},[F]);const R=b.useCallback(async()=>{N(!1),T.current=e;const O=Object.entries(Qh).map(([q,ce])=>`${q}:${ce}`).join(",");await D("teams/rooms-availability",{rooms:O,date:e})},[D,e]),A=(H==null?void 0:H.includes("auth_required"))||(H==null?void 0:H.includes("sign in")),_=(F==null?void 0:F.data)??h??[],$=b.useMemo(()=>_.map(O=>({room:String(O.roomEmail??O.room??""),capacity:O.capacity===null||O.capacity===void 0||O.capacity===""?null:Number(O.capacity),start:String(O.start??""),end:String(O.end??""),state:String(O.state??""),durationMin:Number(O.durationMin??0)})),[_]),z=b.useMemo(()=>{const O=new Map;for(const ce of $){const rt=ce.room.toLowerCase();O.has(rt)||O.set(rt,[]),O.get(rt).push(ce)}const q=new Map;for(const[ce,rt]of O)q.set(U1[ce]??ce,rt);return q},[$]),J=b.useMemo(()=>{var q;const O={};for(const[ce,rt]of z){const Ts=((q=rt.find(ep=>ep.capacity!==null))==null?void 0:q.capacity)??null,Xh=Ts===null||Ts>=d,Zh=Z1(rt,e,r,v);O[ce]=Zh&&Xh?"free":"busy"}return O},[z,e,r,v,d]),xe=g?z.get(g)??[]:[],Me=((gt=xe.find(O=>O.capacity!==null))==null?void 0:gt.capacity)??null,un=b.useCallback(O=>{p(q=>q===O?null:O)},[]);return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Room Availability"}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end gap-3 mb-6",children:[i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Date"}),i.jsx("input",{type:"date",className:"input input-bordered input-sm w-full sm:w-auto",value:e,onChange:O=>t(O.target.value),onClick:O=>{var q,ce;return(ce=(q=O.target).showPicker)==null?void 0:ce.call(q)}})]}),i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Start time"}),i.jsx("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:r,onChange:O=>w(zs(O.target.value)),children:gd.map(O=>i.jsx("option",{value:O,children:Xn(O)},O))})]}),i.jsxs("div",{className:"form-control w-full sm:w-auto",children:[i.jsxs("div",{className:"join mb-1",children:[i.jsx("button",{type:"button",className:`join-item btn btn-xs px-3 font-mono text-[0.6rem] uppercase tracking-[0.1em] ${l==="duration"?"btn-primary":"btn-ghost opacity-40"}`,onClick:()=>y("duration"),children:"Duration"}),i.jsx("button",{type:"button",className:`join-item btn btn-xs px-3 font-mono text-[0.6rem] uppercase tracking-[0.1em] ${l==="endtime"?"btn-primary":"btn-ghost opacity-40"}`,onClick:()=>y("endtime"),children:"End time"})]}),l==="duration"?i.jsx("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:a,onChange:O=>{const q=Number(O.target.value);o(q),s(ce=>vl(ce,q))},children:pd.map(O=>i.jsx("option",{value:O,children:X1(O)},O))}):i.jsxs("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:u===vt?"24:00":na(u),onChange:O=>{const q=O.target.value;x(q==="24:00"?vt:zs(q))},children:[gd.filter(O=>zs(O)>n).map(O=>i.jsx("option",{value:O,children:Xn(O)},O)),i.jsx("option",{value:"24:00",children:"End of day"},"eod")]})]}),i.jsxs("label",{className:"form-control w-full sm:w-24",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"People"}),i.jsx("input",{type:"number",min:1,className:"input input-bordered input-sm w-full sm:w-24",value:d,onFocus:O=>O.target.select(),onChange:O=>f(Math.max(1,Number(O.target.value)||1))})]}),i.jsx("button",{className:"btn btn-primary btn-sm w-full sm:w-auto",onClick:R,disabled:L,children:L?"Checking floor...":"Check floor plan"})]}),i.jsxs("div",{className:"mb-6",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1 block",children:"Drag to pick a time · bar width = duration"}),i.jsx(eb,{startMinutes:n,durationMinutes:v,onChange:O=>{s(O),l==="endtime"&&m(Math.min(vt,O+v))}})]}),L&&!G&&i.jsx(ht,{label:"Checking all rooms on the floor plan (this drives Outlook UI and can take a few minutes)..."}),G&&i.jsxs("div",{className:"alert alert-warning mb-4",children:[i.jsx("span",{children:"This connector requires approval before proceeding."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>I(!0),disabled:!E,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>I(!1),disabled:!E,children:"Reject"})]})]}),A&&i.jsx(Tn,{message:"Sign in to Microsoft Teams in Chrome, then try again."}),H&&!A&&i.jsx("div",{className:"alert alert-error mb-4",children:i.jsx("span",{children:H})}),k&&i.jsxs("div",{className:"flex items-center gap-2 mb-4 font-mono text-xs opacity-50",children:[S&&i.jsx("span",{className:"badge badge-sm badge-outline",children:"cached"}),i.jsxs("span",{children:["Last fetched ",new Date(k).toLocaleString()]})]}),!F&&!h&&!L&&!H&&i.jsxs("div",{className:"border border-base-300 p-8 text-center mb-8",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"Pick a date, time, duration and party size, then check the floor plan"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"Rooms that are free and big enough will show green; everything else red."})]}),i.jsxs("div",{className:"mt-2",children:[i.jsxs("h3",{className:"font-display text-base font-semibold mb-3",children:["Floor plan · ",Xn(r),"–",Xn((()=>{const[O,q]=r.split(":").map(Number),ce=(O*60+q+v)%(24*60);return`${String(Math.floor(ce/60)).padStart(2,"0")}:${String(ce%60).padStart(2,"0")}`})())," · ",xd(e)," · ",d," ",d===1?"person":"people"]}),i.jsx(Q1,{statuses:J,selected:g??void 0,onSelect:un})]}),g&&xe.length>0&&i.jsxs("div",{className:"mt-8",children:[i.jsxs("h3",{className:"font-display text-base font-semibold mb-3",children:[g,Me!==null&&i.jsxs("span",{className:"ml-2 font-mono text-xs font-normal opacity-50 uppercase tracking-[0.08em]",children:["Capacity ",Me]})," ","· ",xd(e)]}),i.jsx(V1,{rows:xe})]}),g&&xe.length===0&&i.jsx("div",{className:"mt-8 border border-base-300 p-6 text-center",children:i.jsxs("p",{className:"text-sm opacity-50",children:["No data for ",g,' yet — run "Check floor plan" first.']})})]})}function nb({data:e}){const{timetracking:t,meetings:n,jira:s,git:r}=e,a=t?Math.min(100,Math.round(t.totalHours/t.targetHours*100)):0,o=t&&t.totalHours<t.targetHours*.8,l=(s==null?void 0:s.blockers.length)??0,c=(r==null?void 0:r.repos.length)??0;return i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 border border-base-300",children:[i.jsxs("div",{className:"p-3 border-r border-b border-base-300 md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Hours Logged"}),i.jsx("div",{className:`font-display text-xl font-bold ${o?"text-warning":"text-success"}`,children:t?`${t.totalHours}h`:"—"}),i.jsxs("div",{className:"text-xs opacity-40",children:["/ ",(t==null?void 0:t.targetHours)??40,"h target"]}),t&&i.jsx("progress",{className:`progress ${o?"progress-warning":"progress-success"} w-full mt-1`,value:a,max:100})]}),i.jsxs("div",{className:"p-3 border-b border-base-300 md:border-r md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Meetings"}),i.jsx("div",{className:`font-display text-xl font-bold ${n&&n.totalHours>20?"text-warning":"text-info"}`,children:n?String(n.totalCount):"—"}),i.jsx("div",{className:"text-xs opacity-40",children:n?`${n.totalHours}h · avg ${n.avgDurationMin}min`:""})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Tickets Done"}),i.jsx("div",{className:"font-display text-xl font-bold text-accent",children:s?String(s.resolved.length):"—"}),i.jsx("div",{className:"text-xs opacity-40",children:s?i.jsxs(i.Fragment,{children:[s.inProgress.length," in progress",l>0&&i.jsxs("span",{className:"text-error font-semibold ml-1",children:["· ",l," blocked"]})]}):""})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Commits"}),i.jsx("div",{className:"font-display text-xl font-bold text-primary",children:r?String(r.totalCommits):"—"}),i.jsx("div",{className:"text-xs opacity-40",children:r?`${r.totalPRsMerged} PRs · ${c} repo${c!==1?"s":""}`:""})]})]})}const sb=["Mon","Tue","Wed","Thu","Fri"];function rb(e){const t=new Date(e).getDay();return sb[t-1]??e}function ib({data:e}){const{timetracking:t,meetings:n,git:s,jira:r}=e,a=new Set;t==null||t.daily.forEach(f=>a.add(f.date)),n==null||n.daily.forEach(f=>a.add(f.date)),s==null||s.daily.forEach(f=>a.add(f.date));const o=[...a].sort().filter(f=>{const v=new Date(f+"T00:00:00").getDay();return v===0||v===6?(t==null?void 0:t.daily.some(x=>x.date===f&&x.hours>0))||(n==null?void 0:n.daily.some(x=>x.date===f&&x.count>0))||(s==null?void 0:s.daily.some(x=>x.date===f&&x.commits>0)):!0}),l=(t==null?void 0:t.totalHours)??0,c=(n==null?void 0:n.totalCount)??0,u=(n==null?void 0:n.totalHours)??0,m=(s==null?void 0:s.totalCommits)??0,d=(r==null?void 0:r.resolved.length)??0;return o.length===0?i.jsx("div",{className:"text-base-content/60",children:"No daily data available."}):i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"font-mono text-[0.6rem] uppercase tracking-[0.1em] opacity-50",children:[i.jsx("th",{children:"Day"}),i.jsx("th",{children:"Date"}),i.jsx("th",{children:"Hours Logged"}),i.jsx("th",{children:"Meetings"}),i.jsx("th",{children:"Commits"}),i.jsx("th",{children:"Tickets"})]})}),i.jsx("tbody",{children:o.map(f=>{const v=t==null?void 0:t.daily.find(p=>p.date===f),y=n==null?void 0:n.daily.find(p=>p.date===f),x=s==null?void 0:s.daily.find(p=>p.date===f),w=t==null?void 0:t.gaps.includes(f),g=(r==null?void 0:r.resolved.filter(p=>p.resolvedDate===f))??[];return i.jsxs("tr",{className:w?"bg-warning/10":"",children:[i.jsx("td",{className:"font-medium",children:rb(f)}),i.jsx("td",{className:"text-xs text-base-content/60",children:f}),i.jsxs("td",{children:[i.jsx("span",{className:w?"text-warning font-semibold":"",children:v?`${v.hours}h`:"—"}),w&&i.jsx("span",{className:"ml-1 text-warning text-xs",children:"⚠"})]}),i.jsx("td",{children:y?`${y.count} (${y.hours}h)`:"—"}),i.jsx("td",{children:x?`${x.commits}`:"0"}),i.jsx("td",{className:"text-xs",children:g.length>0?g.map(p=>p.key).join(", "):"—"})]},f)})}),i.jsx("tfoot",{children:i.jsxs("tr",{className:"font-semibold border-t border-base-300",children:[i.jsx("td",{colSpan:2,children:"Total"}),i.jsx("td",{children:l>0?`${l}h`:"—"}),i.jsx("td",{children:c>0?`${c} (${u}h)`:"—"}),i.jsx("td",{children:m}),i.jsx("td",{className:"text-xs",children:d>0?`${d} done`:"—"})]})})]})})}function ab({insights:e,errors:t}){return i.jsxs("div",{className:"space-y-3",children:[e.length>0&&i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsx("p",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em] mb-2",children:"Insights"}),i.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm",children:e.map((n,s)=>i.jsx("li",{children:n},s))})]}),t.length>0&&i.jsx("div",{className:"alert alert-warning text-sm",children:i.jsxs("div",{children:[i.jsx("p",{className:"font-semibold",children:"Some data sources had issues:"}),i.jsx("ul",{className:"list-disc list-inside mt-1",children:t.map((n,s)=>i.jsx("li",{children:n},s))})]})})]})}function Jh(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}function ob(){const e=new Date;return e.setDate(e.getDate()-e.getDay()),Jh(e)}function jd(e,t){const n=new Date(e+"T00:00:00");return n.setDate(n.getDate()+t*7),Jh(n)}function lb(e){const t=new Date(e+"T00:00:00"),n=new Date(t);n.setDate(n.getDate()+6);const s=r=>r.toLocaleDateString("en-GB",{day:"numeric",month:"short"});return`${s(t)} – ${s(n)}, ${t.getFullYear()}`}function cb(){const[e,t]=b.useState(ob()),[n,s]=b.useState(!1),[r,a]=b.useState(null),[o,l]=b.useState(null),[c,u]=b.useState(null);async function m(){s(!0),l(null),a(null),u(null);const d=Date.now();try{const f=await B.generateJournal({weekStart:e});u(Date.now()-d),a(f)}catch(f){l(f instanceof Error?f.message:"Unknown error")}finally{s(!1)}}return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Dev Work Journal"}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-6",children:[i.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>t(jd(e,-1)),disabled:n,children:"◄"}),i.jsx("span",{className:"font-medium text-lg",children:lb(e)}),i.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>t(jd(e,1)),disabled:n,children:"►"}),i.jsx("button",{className:"btn btn-primary ml-4",onClick:m,disabled:n,children:n?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"loading loading-spinner loading-xs"}),"Generating…"]}):"Generate"}),c!==null&&!n&&i.jsxs("span",{className:"text-xs text-base-content/40 ml-2",children:["Generated in ",(c/1e3).toFixed(1),"s"]})]}),n&&i.jsxs("div",{className:"flex items-center gap-3 text-base-content/60 mb-4",children:[i.jsx("span",{className:"loading loading-spinner loading-md"}),i.jsx("span",{children:"Gathering data from Git, Outlook, Jira…"})]}),o&&i.jsx("div",{role:"alert",className:"alert alert-error mb-4",children:i.jsx("span",{children:o})}),(r==null?void 0:r.status)==="partial"&&i.jsx("div",{role:"alert",className:"alert alert-warning text-sm mb-4",children:i.jsxs("div",{children:[i.jsx("p",{className:"font-semibold",children:"Some data sources were unavailable. Results may be incomplete."}),i.jsx("ul",{className:"list-disc list-inside mt-1",children:r.errors.map((d,f)=>i.jsx("li",{children:d},f))})]})}),r&&r.status!=="error"&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("section",{className:"space-y-4",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Summary"}),i.jsx(nb,{data:r})]}),i.jsxs("section",{className:"space-y-4",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Daily Breakdown"}),i.jsx(ib,{data:r})]}),i.jsx("section",{className:"space-y-4",children:i.jsx(ab,{insights:r.insights,errors:r.errors})})]}),(r==null?void 0:r.status)==="error"&&i.jsx("div",{role:"alert",className:"alert alert-error mb-4",children:i.jsxs("span",{children:["Failed to generate journal. ",r.errors.join("; ")]})})]})}function ub(){const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function db(){const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function fb(e){const[t,n]=e.split("-").map(Number);return new Date(t,n-1,1).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}function mb(e){return new Date(e+"T00:00:00").toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function hb(e){const[t,n]=e.split("-").map(Number),s=new Date(t,n,0).getDate();let r=0;for(let a=1;a<=s;a++){const o=new Date(t,n-1,a).getDay();o!==0&&o!==6&&r++}return r}function pb(e,t){const n=db(),[s,r]=t.split("-").map(Number),a=new Date(n+"T00:00:00"),o=new Date(s,r,0).getDate(),l=[];for(let d=1;d<=o;d++){const f=new Date(s,r-1,d);if(f>a)break;const v=f.getDay();v!==0&&v!==6&&l.push(`${s}-${String(r).padStart(2,"0")}-${String(d).padStart(2,"0")}`)}const c=new Set(e.filter(d=>d.date&&d.status&&/released/i.test(String(d.status))).map(d=>d.date)),u=l.filter(d=>c.has(d)),m=l.filter(d=>!c.has(d));return{workingDaysTotal:hb(t),workingDaysElapsed:l.length,releasedDates:u,unreleasedDates:m}}function gb(e){return e.isOverdue?"badge badge-error badge-sm":typeof e.daysUntilDue=="number"&&e.daysUntilDue<=7?"badge badge-warning badge-sm":typeof e.daysUntilDue=="number"&&e.daysUntilDue<=30?"badge badge-info badge-sm":"badge badge-ghost badge-sm"}function yb(e){return e.isOverdue?"Overdue":e.daysUntilDue==null||e.daysUntilDue===9999?"No deadline":e.daysUntilDue===0?"Due today":e.daysUntilDue===1?"Due tomorrow":`${e.daysUntilDue}d left`}function xb(){const[e]=b.useState(ub()),[t,n]=b.useState([]),s=Sr(),r=Sr();function a(){s.reset(),r.reset(),n([]),s.run("timetracking/report",{month:e}),r.run("saba/pending-training",{}),B.getGoals(e).then(y=>n(y.goals)).catch(()=>{})}const o=b.useMemo(()=>{var y;return((y=s.result)==null?void 0:y.data)??null},[s.result]),l=b.useMemo(()=>o?pb(o,e):null,[o,e]),c=b.useMemo(()=>{const y=new Map;if(o)for(const x of o){const w=typeof x.projectId=="string"?x.projectId:null,g=typeof x.hours=="number"?x.hours:0;w&&y.set(w,(y.get(w)??0)+g)}return y},[o]),u=b.useMemo(()=>{var y;return((y=r.result)==null?void 0:y.data)??[]},[r.result]),m=typeof r.error=="string"&&(r.error.toLowerCase().includes("auth_required")||r.error.toLowerCase().includes("sign in")),d=typeof s.error=="string"&&(s.error.toLowerCase().includes("auth_required")||s.error.toLowerCase().includes("sign in")),f=s.running||r.running,v=s.result!==null||r.result!==null;return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsxs("div",{className:"flex items-center justify-between mb-5",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em]",children:"Daily Check-in"}),i.jsx("p",{className:"text-sm opacity-40 mt-0.5",children:fb(e)})]}),i.jsx("button",{className:"btn btn-primary btn-sm",onClick:a,disabled:f,children:f?"Loading…":v?"Refresh":"Load"})]}),f&&!s.approvalPending&&!r.approvalPending&&i.jsx("div",{className:"mb-4",children:i.jsx(ht,{label:"Fetching time tracking and Saba training…"})}),i.jsxs("section",{className:"space-y-4 mb-6",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Time Tracking"}),s.approvalPending&&i.jsxs("div",{className:"alert alert-warning",children:[i.jsx("span",{children:"Time tracking requires approval."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>s.handleApproval(!0),disabled:!s.approvalId,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>s.handleApproval(!1),disabled:!s.approvalId,children:"Reject"})]})]}),d&&i.jsx(Tn,{message:"Sign in to the timetracking portal in Chrome, then try again."}),s.error&&!d&&i.jsx("div",{className:"alert alert-error text-sm",children:i.jsx("span",{children:s.error})}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-4 border border-base-300",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Working days"}),i.jsx("div",{className:"font-display text-xl font-bold",children:l.workingDaysTotal}),i.jsx("div",{className:"text-xs opacity-40",children:"in month"})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Elapsed"}),i.jsx("div",{className:"font-display text-xl font-bold",children:l.workingDaysElapsed}),i.jsx("div",{className:"text-xs opacity-40",children:"so far"})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Released"}),i.jsx("div",{className:"font-display text-xl font-bold text-success",children:l.releasedDates.length}),i.jsx("div",{className:"text-xs opacity-40",children:"days"})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Unreleased"}),i.jsx("div",{className:`font-display text-xl font-bold ${l.unreleasedDates.length>0?"text-error":"text-success"}`,children:l.unreleasedDates.length}),i.jsx("div",{className:"text-xs opacity-40",children:"to action"})]})]}),l.unreleasedDates.length>0&&i.jsxs("div",{className:"border border-base-300 p-4 space-y-2",children:[i.jsx("p",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Unreleased dates"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:l.unreleasedDates.map(y=>i.jsx("span",{className:"badge badge-error badge-outline badge-sm",children:mb(y)},y))})]}),l.unreleasedDates.length===0&&i.jsx("div",{className:"border border-base-300 p-4 text-center",children:i.jsx("p",{className:"text-sm text-success font-medium",children:"All days released ✓"})})]}),l&&t.length>0&&i.jsxs("div",{className:"border border-base-300 p-4 space-y-3",children:[i.jsx("p",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Goals Progress"}),i.jsx("div",{className:"space-y-3",children:t.map(y=>{const x=Math.round((c.get(y.projectId)??0)*100)/100,w=Math.round((y.targetHours-x)*100)/100,g=Math.min(100,Math.round(x/y.targetHours*100)),p=w<=0;return i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between text-sm",children:[i.jsx("span",{className:"font-medium",children:y.projectId}),i.jsx("span",{className:`font-mono text-xs ${p?"text-success":"text-warning"}`,children:p?"✓ Goal met":`${w}h to go`})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("progress",{className:`progress flex-1 ${p?"progress-success":"progress-warning"}`,value:g,max:100}),i.jsxs("span",{className:"font-mono text-xs opacity-50 w-24 text-right",children:[x,"h / ",y.targetHours,"h"]})]})]},y.id)})})]}),o===null&&!s.error&&!s.running&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm opacity-40",children:"Click Load to check your time tracking status."}),i.jsx("p",{className:"font-mono text-xs opacity-25 mt-1",children:"Drives your browser — sign in to the portal first."})]})]}),i.jsxs("section",{className:"space-y-4",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Pending Training (Saba)"}),r.approvalPending&&i.jsxs("div",{className:"alert alert-warning",children:[i.jsx("span",{children:"This connector requires approval before proceeding."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>r.handleApproval(!0),disabled:!r.approvalId,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>r.handleApproval(!1),disabled:!r.approvalId,children:"Reject"})]})]}),m&&i.jsx(Tn,{message:"Sign in to Saba Cloud (daimler.sabacloud.com) in Chrome, then try again."}),r.error&&!m&&i.jsx("div",{className:"alert alert-error text-sm font-mono whitespace-pre-wrap",children:i.jsx("span",{children:r.error})}),r.result&&u.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-3 border border-base-300",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Pending"}),i.jsx("div",{className:"font-display text-xl font-bold",children:u.length})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Overdue"}),i.jsx("div",{className:`font-display text-xl font-bold ${u.filter(y=>y.isOverdue).length>0?"text-error":""}`,children:u.filter(y=>y.isOverdue).length})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Due ≤ 30d"}),i.jsx("div",{className:`font-display text-xl font-bold ${u.filter(y=>!y.isOverdue&&typeof y.daysUntilDue=="number"&&y.daysUntilDue<=30).length>0?"text-warning":""}`,children:u.filter(y=>!y.isOverdue&&typeof y.daysUntilDue=="number"&&y.daysUntilDue<=30).length})]})]}),i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"font-mono text-[0.6rem] uppercase tracking-[0.1em] opacity-50",children:[i.jsx("th",{children:"Course"}),i.jsx("th",{children:"Type"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Due"}),i.jsx("th",{children:"Urgency"})]})}),i.jsx("tbody",{children:u.map((y,x)=>i.jsxs("tr",{className:"hover",children:[i.jsx("td",{className:`font-medium text-sm ${y.isOverdue?"text-error":""}`,children:y.title??"—"}),i.jsx("td",{className:"font-mono text-xs opacity-60",children:y.type??"—"}),i.jsx("td",{className:"text-xs opacity-70",children:y.status??"—"}),i.jsx("td",{className:"font-mono text-xs",children:y.dueDate||"—"}),i.jsx("td",{children:i.jsx("span",{className:gb(y),children:yb(y)})})]},x))})]})})]}),r.result&&u.length===0&&!r.error&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm text-success font-medium",children:"No pending training ✓"}),i.jsx("p",{className:"font-mono text-xs opacity-30 mt-0.5",children:"You're all caught up."})]}),!r.result&&!r.error&&!r.running&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm opacity-40",children:"Click Load to fetch your pending Saba training."}),i.jsx("p",{className:"font-mono text-xs opacity-25 mt-1",children:"Requires an active Saba Cloud session in Chrome."})]})]})]})}const vb={socket:"info",wiz:"secondary",tldrsec:"warning"},bb={socket:"SOCKET",wiz:"WIZ",tldrsec:"TLDR SEC"};function jb(e,t){try{const n=new Date(e);if(isNaN(n.getTime()))return!1;const s=Date.now()-t*24*60*60*1e3;return n.getTime()>=s}catch{return!1}}function wb(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const s=new Date().getTime()-t.getTime(),r=Math.floor(s/36e5);if(r<1)return"just now";if(r<24)return`${r}h ago`;const a=Math.floor(r/24);return a===1?"yesterday":a<7?`${a}d ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return e}}function kb(e){return(e.data??[]).map(t=>({title:String(t.title??""),summary:String(t.summary??""),url:String(t.url??""),date:String(t.date??""),source:"socket",author:String(t.author??""),tags:String(t.tags??"")}))}function Nb(e){return(e.data??[]).map(t=>({title:String(t.title??""),summary:String(t.excerpt??""),url:String(t.url??""),date:String(t.publishedAt??""),source:"wiz",author:String(t.authors??""),tags:String(t.tags??"")}))}function Sb(e){return(e.data??[]).map(t=>({title:String(t.title??""),summary:String(t.excerpt??""),url:String(t.url??""),date:String(t.publishedAt??""),source:"tldrsec",author:String(t.authors??""),tags:String(t.tags??"")}))}const wd={7:"Past 7 days",30:"Past 30 days"};function Cb(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Eb(){const[e,t]=b.useState(7),[n,s]=b.useState("idle"),[r,a]=b.useState("idle"),[o,l]=b.useState("idle"),[c,u]=b.useState([]),[m,d]=b.useState([]),[f,v]=b.useState([]),[y,x]=b.useState(null),[w,g]=b.useState(null),[p,h]=b.useState(null),[j,k]=b.useState(null),[C,S]=b.useState(!1);b.useEffect(()=>{let E=!1;return B.getCachedSecurityNews().then(D=>{if(!E&&D.data&&D.data.length>0){if(s(_=>_==="loading"?(E=!0,_):"done"),E)return;const I=[],R=[],A=[];for(const _ of D.data){const $=_;$.source==="wiz"?R.push($):$.source==="tldrsec"?A.push($):I.push($)}u(I),d(R),v(A),k(D.fetchedAt),S(!0),a("done"),l("done")}}).catch(()=>{}),()=>{E=!0}},[]);const N=n==="loading"||r==="loading"||o==="loading",T=c.length>0||m.length>0||f.length>0,L=b.useMemo(()=>[...c,...m,...f].filter(D=>jb(D.date,e)).sort((D,I)=>new Date(I.date).getTime()-new Date(D.date).getTime()),[c,m,f,e]),F=b.useMemo(()=>{const E=L.filter(R=>R.source==="socket").length,D=L.filter(R=>R.source==="wiz").length,I=L.filter(R=>R.source==="tldrsec").length;return{total:L.length,socketCount:E,wizCount:D,tldrsecCount:I}},[L]),H=b.useCallback(async()=>{s("loading"),a("loading"),l("loading"),x(null),g(null),h(null),u([]),d([]),v([]),S(!1);let E=[],D=[],I=[];const R=B.run("socket/security-news",{}).then(z=>{!z.ok&&z.error?(x(z.error),s("error")):(E=kb(z),u(E),s("done"))}).catch(z=>{x(z instanceof Error?z.message:"Failed to fetch"),s("error")}),A=B.run("wiz/blog-security",{}).then(z=>{!z.ok&&z.error?(g(z.error),a("error")):(D=Nb(z),d(D),a("done"))}).catch(z=>{g(z instanceof Error?z.message:"Failed to fetch"),a("error")}),_=B.run("tldrsec/newsletter",{}).then(z=>{!z.ok&&z.error?(h(z.error),l("error")):(I=Sb(z),v(I),l("done"))}).catch(z=>{h(z instanceof Error?z.message:"Failed to fetch"),l("error")});await Promise.allSettled([R,A,_]);const $=[...E,...D,...I];if($.length>0){const z=new Date().toISOString();k(z),B.cacheSecurityNews($).catch(()=>{})}},[]),G=E=>(E==null?void 0:E.includes("auth_required"))||(E==null?void 0:E.includes("sign in"));return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Security News"}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end gap-3 mb-6",children:[i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Range"}),i.jsxs("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:e,onChange:E=>t(Number(E.target.value)),children:[i.jsx("option",{value:7,children:"Past 7 days"}),i.jsx("option",{value:30,children:"Past 30 days"})]})]}),i.jsx("button",{className:"btn btn-primary btn-sm w-full sm:w-auto",onClick:H,disabled:N,children:N?"Loading...":"Load news"}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(mo,{label:"Socket",status:n}),i.jsx(mo,{label:"Wiz",status:r}),i.jsx(mo,{label:"tl;dr sec",status:o})]})]}),N&&i.jsx(ht,{label:"Fetching security news..."}),y&&(G(y)?i.jsx(Tn,{message:"Sign in to Socket.dev in Chrome, then try again."}):i.jsx("div",{className:"alert alert-error mb-3",children:i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold",children:"Socket:"})," ",y]})})),w&&(G(w)?i.jsx(Tn,{message:"Sign in to Wiz in Chrome, then try again."}):i.jsx("div",{className:"alert alert-error mb-3",children:i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold",children:"Wiz:"})," ",w]})})),p&&i.jsx("div",{className:"alert alert-error mb-3",children:i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold",children:"tl;dr sec:"})," ",p]})}),j&&!N&&i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-2",children:[C?"Showing cached data from":"Last fetched"," ",Cb(j)]}),T&&!N&&i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 border border-base-300 mb-6",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:wd[e]}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.total})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Socket"}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.socketCount})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Wiz"}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.wizCount})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"tl;dr sec"}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.tldrsecCount})]})]}),L.length>0&&i.jsx("div",{className:"space-y-px",children:L.map((E,D)=>i.jsxs("article",{className:"border border-base-300 p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[i.jsx("a",{href:E.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-semibold hover:text-primary transition-colors leading-snug",children:E.title}),i.jsx(W,{variant:vb[E.source]??"neutral",size:"xs",children:bb[E.source]??E.source.toUpperCase()})]}),E.summary&&i.jsx("p",{className:"text-sm opacity-60 leading-relaxed mb-2 line-clamp-2",children:E.summary}),i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsx("span",{className:"font-mono text-[0.6rem] opacity-40",children:wb(E.date)}),E.author&&i.jsx("span",{className:"font-mono text-[0.6rem] opacity-40",children:E.author}),E.tags&&i.jsx("div",{className:"flex gap-1 flex-wrap",children:E.tags.split(",").slice(0,3).map(I=>i.jsx(W,{variant:"neutral",size:"xs",children:I.trim()},I.trim()))})]})]},`${E.source}-${D}`))}),T&&L.length===0&&!N&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsxs("p",{className:"text-sm opacity-50 mb-1",children:["No news from the ",wd[e].toLowerCase()]}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"All sources returned data, but nothing within the date window."})]}),!T&&!N&&!y&&!w&&!p&&i.jsxs("div",{className:"border border-base-300 p-8 text-center",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"Security news from Socket, Wiz, and tl;dr sec"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"Select a range and press Load news to fetch the latest posts."})]})]})}function mo({label:e,status:t}){const n={idle:"opacity-30",loading:"bg-warning animate-pulse",done:"bg-success",error:"bg-error"}[t];return i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:`w-1.5 h-1.5 ${n}`,"aria-hidden":"true"}),i.jsx("span",{className:"font-mono text-[0.6rem] opacity-50 uppercase",children:e})]})}function ci(e){if(!e)return null;try{const t=new Date(e);if(isNaN(t.getTime()))return null;const n=new Date;return n.setHours(0,0,0,0),t.setHours(0,0,0,0),Math.ceil((t.getTime()-n.getTime())/(24*60*60*1e3))}catch{return null}}function kd(e){return e===null?"none":e<0?"expired":e<=7?"critical":e<=30?"warning":"ok"}function Tb(e,t){switch(e){case"expired":return i.jsx(W,{variant:"error",size:"xs",children:"EXPIRED"});case"critical":return i.jsxs(W,{variant:"error",size:"xs",children:[t,"d LEFT"]});case"warning":return i.jsxs(W,{variant:"warning",size:"xs",children:[t,"d LEFT"]});case"ok":return i.jsxs(W,{variant:"success",size:"xs",children:[t,"d LEFT"]});case"none":return i.jsx(W,{variant:"neutral",size:"xs",children:"NO EXPIRY"});default:return null}}function Ab(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?e:t.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return e}}function Lb(e){switch(e){case"expired":return"bg-red-500/5";case"critical":return"bg-red-500/5";case"warning":return"bg-amber-500/5";default:return""}}function Pb(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Ib(){const[e,t]=b.useState("idle"),[n,s]=b.useState(""),[r,a]=b.useState([]),[o,l]=b.useState(null),[c,u]=b.useState("all"),[m,d]=b.useState(null),[f,v]=b.useState(!1),y=e==="clients"||e==="trustedby";b.useEffect(()=>{let j=!1;return B.getCachedTrustedPeers().then(k=>{if(!j&&k.data&&k.data.length>0){if(t(S=>S==="clients"||S==="trustedby"?(j=!0,S):"done"),j)return;const C=k.data;a(C),d(k.fetchedAt),v(!0),s(`Loaded ${C.length} trusted peers from cache.`)}}).catch(()=>{}),()=>{j=!0}},[]);const x=b.useCallback(async()=>{t("clients"),l(null),a([]),v(!1),s("Fetching client list (all regions)...");try{const j=await B.run("tokenmaster/clients-list",{region:"all"});if(!j.ok&&j.error){l(j.error),t("error");return}const k=(j.data??[]).map(N=>({id:String(N.id??""),name:String(N.name??""),region:String(N.region??"emea")}));if(k.length===0){s("No clients found."),t("done");return}t("trustedby");const C=[],S=k.length;for(let N=0;N<k.length;N++){const T=k[N];s(`Fetching trusted peers... (${N+1}/${S}) — ${T.name||T.id}`);try{const L=await B.run("tokenmaster/client-trustedby",{clientid:T.id,region:T.region});if(L.ok&&L.data)for(const F of L.data)C.push({parentClientId:T.id,parentClientName:T.name||T.id,peerId:String(F.id??""),peerName:String(F.name??""),peerIdDisplay:String(F.idDisplay??""),expiryDate:F.expiry_date?String(F.expiry_date):null,region:String(F.region??T.region)})}catch{}}if(a(C),s(`Loaded ${C.length} trusted peers from ${S} clients.`),t("done"),C.length>0){const N=new Date().toISOString();d(N),B.cacheTrustedPeers(C).catch(()=>{})}}catch(j){l(j instanceof Error?j.message:"Unknown error"),t("error")}},[]),w=b.useMemo(()=>[...c==="all"?r:r.filter(k=>k.region===c)].sort((k,C)=>{const S=ci(k.expiryDate),N=ci(C.expiryDate);return S===null&&N===null?0:S===null?1:N===null?-1:S-N}),[r,c]),g=b.useMemo(()=>{let j=0,k=0,C=0;for(const S of w){const N=kd(ci(S.expiryDate));N==="expired"?j++:N==="critical"?k++:N==="warning"&&C++}return{total:w.length,expired:j,critical:k,warning:C}},[w]),p=b.useMemo(()=>{const j=new Set(r.map(k=>k.region));return Array.from(j).sort()},[r]),h=j=>(j==null?void 0:j.includes("auth_required"))||(j==null?void 0:j.includes("sign in"));return i.jsxs("div",{className:"max-w-5xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Trusted Peer Expiry"}),m&&!y&&i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-3",children:[f?"Showing cached data from":"Last fetched"," ",Pb(m)]}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end gap-3 mb-6",children:[i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Region"}),i.jsxs("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:c,onChange:j=>u(j.target.value),children:[i.jsx("option",{value:"all",children:"All regions"}),p.map(j=>i.jsx("option",{value:j,children:j.toUpperCase()},j))]})]}),i.jsx("button",{className:"btn btn-primary btn-sm w-full sm:w-auto",onClick:x,disabled:y,children:y?"Loading...":"Load trusted peers"})]}),y&&i.jsx(ht,{label:n}),o&&(h(o)?i.jsx(Tn,{message:"Sign in to TokenMaster in Chrome, then try again."}):i.jsx("div",{className:"alert alert-error mb-3",children:i.jsx("span",{children:o})})),r.length>0&&!y&&i.jsxs("div",{className:"grid grid-cols-4 border border-base-300 mb-6",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Total"}),i.jsx("div",{className:"font-display text-xl font-bold",children:g.total})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Expired"}),i.jsx("div",{className:`font-display text-xl font-bold ${g.expired>0?"text-red-500":""}`,children:g.expired})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"≤ 7 days"}),i.jsx("div",{className:`font-display text-xl font-bold ${g.critical>0?"text-red-500":""}`,children:g.critical})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"≤ 30 days"}),i.jsx("div",{className:`font-display text-xl font-bold ${g.warning>0?"text-amber-500":""}`,children:g.warning})]})]}),w.length>0&&i.jsx("div",{className:"border border-base-300 overflow-x-auto",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-base-300",children:[i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Status"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Expiry Date"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Days Left"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Trusted Peer"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Peer ID"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Parent Client"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Region"})]})}),i.jsx("tbody",{children:w.map((j,k)=>{const C=ci(j.expiryDate),S=kd(C);return i.jsxs("tr",{className:`border-b border-base-300/50 ${Lb(S)}`,children:[i.jsx("td",{children:Tb(S,C)}),i.jsx("td",{className:"font-mono text-sm",children:Ab(j.expiryDate)}),i.jsx("td",{className:"font-mono text-sm",children:C!==null?C<0?`${Math.abs(C)}d overdue`:`${C}d`:"—"}),i.jsx("td",{className:"text-sm font-semibold",children:j.peerName||j.peerId}),i.jsx("td",{className:"font-mono text-xs opacity-60",children:j.peerIdDisplay||j.peerId}),i.jsx("td",{className:"text-sm",children:j.parentClientName}),i.jsx("td",{children:i.jsx(W,{variant:"neutral",size:"xs",children:j.region.toUpperCase()})})]},`${j.parentClientId}-${j.peerId}-${j.region}-${k}`)})})]})}),e==="done"&&!y&&r.length>0&&i.jsx("div",{className:"mt-1 font-mono text-xs opacity-40",children:n}),e==="done"&&r.length===0&&!y&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"No trusted peers found"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"No clients returned from TokenMaster, or no trustedby relationships exist."})]}),e==="idle"&&i.jsxs("div",{className:"border border-base-300 p-8 text-center",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"TokenMaster trusted peer expiry monitor"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:'Press "Load trusted peers" to fetch all clients and their trusted peer expiry dates across all regions.'})]})]})}const Ob={client:"border-sky-500/50 bg-sky-500/10 text-sky-700 dark:text-sky-400",daemon:"border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-400",extension:"border-emerald-500/50 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",browser:"border-violet-500/50 bg-violet-500/10 text-violet-700 dark:text-violet-400"},_b={client:"bg-sky-400/20",daemon:"bg-amber-400/20",extension:"bg-emerald-400/20",browser:"bg-violet-400/20"};function bl({flow:e}){const{lanes:t,steps:n,title:s}=e,r=t.length,a=`repeat(${r}, 1fr)`;return i.jsxs("div",{className:"border border-base-300 p-4 overflow-x-auto",children:[i.jsx("h4",{className:"font-semibold text-sm mb-3",children:s}),i.jsxs("div",{style:{minWidth:r*130},children:[i.jsx("div",{className:"grid",style:{gridTemplateColumns:a},children:t.map(o=>i.jsx("div",{className:"flex justify-center",children:i.jsx("span",{className:`px-2 py-1 text-[0.65rem] font-mono font-semibold border ${Ob[o.color]}`,children:o.label})},o.id))}),i.jsxs("div",{className:"relative py-1",children:[i.jsx("div",{className:"absolute inset-0 grid pointer-events-none",style:{gridTemplateColumns:a},children:t.map(o=>i.jsx("div",{className:"flex justify-center",children:i.jsx("div",{className:`w-0.5 h-full ${_b[o.color]}`})},o.id))}),i.jsx("div",{className:"relative",children:n.map((o,l)=>{if(o.type==="action"){const w=(t.findIndex(g=>g.id===o.lane)+.5)/r*100;return i.jsx("div",{className:"relative",style:{height:26},children:i.jsx("div",{className:"absolute top-1/2 -translate-x-1/2 -translate-y-1/2 z-10",style:{left:`${w}%`},children:i.jsx("span",{className:"block px-2 py-0.5 text-[0.6rem] font-mono bg-base-200/90 border border-base-300/60 text-base-content/60 whitespace-nowrap",children:o.label})})},l)}const c=t.findIndex(x=>x.id===o.from),u=t.findIndex(x=>x.id===o.to),m=(c+.5)/r*100,d=(u+.5)/r*100,f=Math.min(m,d),v=Math.abs(d-m),y=c<u;return i.jsxs("div",{className:"relative",style:{height:30},children:[i.jsx("div",{className:"absolute top-1/2 h-px bg-base-content/20",style:{left:`${f}%`,width:`${v}%`}}),i.jsx("div",{className:"absolute top-1/2 w-1.5 h-1.5 rounded-full bg-base-content/30 -translate-x-1/2 -translate-y-1/2",style:{left:`${m}%`}}),i.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 text-[0.55rem] leading-none text-base-content/40",style:{left:`${d}%`,transform:`translate(${y?"-100%":"0"}, -50%)`},children:y?"▸":"◂"}),i.jsx("div",{className:"absolute top-1/2 -translate-x-1/2 -translate-y-1/2 z-10",style:{left:`${(m+d)/2}%`},children:i.jsx("span",{className:"px-1.5 py-px text-[0.6rem] font-mono bg-base-100 text-base-content/60 whitespace-nowrap",children:o.label})})]},l)})})]})]})]})}const Mb=[{name:"CLI Client",tech:"Node.js / Commander.js",port:null,desc:"Terminal interface. Sends commands to the Daemon over HTTP, formats output as table / JSON / CSV.",pkg:"@commandgarden/cli"},{name:"GUI",tech:"React SPA / Vite / Tailwind / DaisyUI",port:null,desc:"Browser-based interface. Talks to the App Server — never to the Daemon directly.",pkg:null},{name:"App Server",tech:"Fastify / SQLite",port:"9092",desc:"GUI backend. Proxies Daemon calls, enriches responses, and owns app-specific state (preferences, cached reports, goals).",pkg:"@commandgarden/app"},{name:"Daemon",tech:"Fastify / WebSocket / SQLite",port:"9091",desc:"Core service. Validates auth and capabilities, loads connectors, relays pipelines to the Chrome Extension, writes audit log.",pkg:"@commandgarden/daemon"},{name:"Chrome Extension",tech:"MV3 / TypeScript / Service Worker",port:null,desc:"Runs connector pipelines inside browser tabs via content scripts and CDP. Connects to the Daemon via WebSocket.",pkg:null}],Db=[{name:"Audit Log",tech:"SQLite",path:"~/.commandgarden/audit.db",desc:"Every command execution, denial, auth failure, and config change."},{name:"App DB",tech:"SQLite",path:"~/.commandgarden/app.db",desc:"Preferences, cached reports, goals, and saved views."},{name:"Config",tech:"YAML",path:"~/.commandgarden/config.yaml",desc:"Daemon + security + connector + audit settings."},{name:"Session Token",tech:"File",path:"~/.commandgarden/session-token",desc:"Bearer token generated on daemon start. CLI and App Server read it for auth."}],$b=[{title:"Command execution (CLI path)",lanes:[{id:"cli",label:"CLI",color:"client"},{id:"daemon",label:"Daemon :9091",color:"daemon"},{id:"ext",label:"Extension",color:"extension"},{id:"browser",label:"Browser Tab",color:"browser"}],steps:[{type:"arrow",from:"cli",to:"daemon",label:"POST /api/run (HTTP)"},{type:"action",lane:"daemon",label:"validate token + CSRF"},{type:"action",lane:"daemon",label:"check connector, domains, capabilities"},{type:"action",lane:"daemon",label:"audit: command.start"},{type:"action",lane:"daemon",label:"split pipeline (extension vs daemon steps)"},{type:"arrow",from:"daemon",to:"ext",label:"relay extension steps (WS)"},{type:"arrow",from:"ext",to:"browser",label:"execute pipeline steps"},{type:"arrow",from:"browser",to:"ext",label:"page data"},{type:"arrow",from:"ext",to:"daemon",label:"results (WS)"},{type:"action",lane:"daemon",label:"run daemon-side steps (transform, map)"},{type:"action",lane:"daemon",label:"audit: command.success / error"},{type:"arrow",from:"daemon",to:"cli",label:"structured data response"}]},{title:"Command execution (GUI path)",lanes:[{id:"gui",label:"GUI",color:"client"},{id:"app",label:"App Server :9092",color:"daemon"},{id:"daemon",label:"Daemon :9091",color:"daemon"}],steps:[{type:"arrow",from:"gui",to:"app",label:"POST /api/run (HTTP)"},{type:"arrow",from:"app",to:"daemon",label:"proxy to daemon (HTTP)"},{type:"action",lane:"daemon",label:"validate, execute, audit (same as CLI path)"},{type:"arrow",from:"daemon",to:"app",label:"structured data"},{type:"arrow",from:"app",to:"gui",label:"enriched response"}]},{title:"Step approval flow",lanes:[{id:"client",label:"CLI / GUI",color:"client"},{id:"daemon",label:"Daemon",color:"daemon"},{id:"ext",label:"Extension",color:"extension"}],steps:[{type:"action",lane:"daemon",label:"detect approval-required capability"},{type:"arrow",from:"daemon",to:"client",label:"HTTP 202 + requestId"},{type:"arrow",from:"daemon",to:"client",label:"approval prompt (SSE)"},{type:"arrow",from:"daemon",to:"ext",label:"approval notification (WS)"},{type:"arrow",from:"client",to:"daemon",label:"POST /api/approval"},{type:"arrow",from:"ext",to:"daemon",label:"resolve via WS"},{type:"action",lane:"daemon",label:"first responder wins → continue or abort"},{type:"action",lane:"daemon",label:"audit: approval.granted / rejected"}]},{title:"Extension connection",lanes:[{id:"ext",label:"Extension",color:"extension"},{id:"daemon",label:"Daemon",color:"daemon"}],steps:[{type:"arrow",from:"ext",to:"daemon",label:"WS connect :9091"},{type:"action",lane:"daemon",label:"validate origin"},{type:"action",lane:"daemon",label:"attach WS relay"},{type:"action",lane:"ext",label:"ready for commands"},{type:"arrow",from:"ext",to:"daemon",label:"heartbeat"}]}],Rb=[{name:"shared",desc:"Connector schema (Zod), protocol messages, audit events, expression parser, pipeline definitions",published:!1},{name:"daemon",desc:"HTTP + WebSocket server, auth, connector registry, capability validation, audit store, WebSocket relay",published:!1},{name:"cli",desc:"CLI client (Commander.js) — run, list, inspect, validate, daemon/gui management, audit queries, config",published:!0},{name:"chrome",desc:"Chrome MV3 extension — service worker, content scripts, domain guard, pipeline step execution engine",published:!1},{name:"app",desc:"Web GUI — Fastify app server + React SPA (Vite, Tailwind, DaisyUI)",published:!1},{name:"connectors",desc:"Built-in YAML connector definitions",published:!1}];function zb(){return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-1",children:"Architecture"}),i.jsx("p",{className:"text-sm opacity-60 mb-6",children:"How commandGarden's components fit together."}),i.jsx("div",{id:"arch-diagram",className:"border border-base-300 p-5 mb-8 overflow-x-auto scroll-mt-4",children:i.jsxs("svg",{viewBox:"0 0 780 300",className:"w-full text-base-content",style:{minWidth:620},children:[i.jsxs("defs",{children:[i.jsx("marker",{id:"arch-ah",viewBox:"0 0 10 8",refX:"10",refY:"4",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("path",{d:"M0 0L10 4L0 8z",fill:"currentColor",fillOpacity:.5})}),i.jsx("marker",{id:"arch-ah-rev",viewBox:"0 0 10 8",refX:"0",refY:"4",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("path",{d:"M10 0L0 4L10 8z",fill:"currentColor",fillOpacity:.5})})]}),i.jsx("rect",{x:15,y:8,width:120,height:50,rx:3,fill:"rgba(56,189,248,0.15)",stroke:"rgba(56,189,248,0.6)",strokeWidth:1}),i.jsx("text",{x:75,y:29,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"CLI Client"}),i.jsx("text",{x:75,y:44,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Node.js"}),i.jsx("rect",{x:15,y:120,width:120,height:50,rx:3,fill:"rgba(56,189,248,0.15)",stroke:"rgba(56,189,248,0.6)",strokeWidth:1}),i.jsx("text",{x:75,y:141,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"GUI"}),i.jsx("text",{x:75,y:156,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"React SPA"}),i.jsx("rect",{x:190,y:120,width:145,height:50,rx:3,fill:"rgba(251,191,36,0.15)",stroke:"rgba(251,191,36,0.6)",strokeWidth:1}),i.jsx("text",{x:262,y:141,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"App Server"}),i.jsx("text",{x:262,y:156,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Fastify :9092"}),i.jsx("rect",{x:395,y:10,width:160,height:84,rx:3,fill:"rgba(251,191,36,0.15)",stroke:"rgba(251,191,36,0.7)",strokeWidth:1.5}),i.jsx("text",{x:475,y:38,textAnchor:"middle",fill:"currentColor",fontSize:13,fontWeight:700,children:"Daemon"}),i.jsx("text",{x:475,y:56,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Fastify :9091"}),i.jsx("text",{x:475,y:78,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"auth · registry · audit"}),i.jsx("rect",{x:615,y:20,width:150,height:60,rx:3,fill:"rgba(52,211,153,0.15)",stroke:"rgba(52,211,153,0.6)",strokeWidth:1}),i.jsx("text",{x:690,y:44,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"Extension"}),i.jsx("text",{x:690,y:62,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Chrome MV3"}),i.jsx("rect",{x:630,y:200,width:130,height:50,rx:3,fill:"rgba(167,139,250,0.15)",stroke:"rgba(167,139,250,0.6)",strokeWidth:1}),i.jsx("text",{x:695,y:221,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"Browser Tab"}),i.jsx("text",{x:695,y:237,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"target page"}),i.jsx("rect",{x:195,y:240,width:100,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:245,y:257,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"App DB"}),i.jsx("text",{x:245,y:269,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"SQLite"}),i.jsx("rect",{x:390,y:200,width:105,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:442,y:217,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"Audit Log"}),i.jsx("text",{x:442,y:229,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"SQLite"}),i.jsx("rect",{x:500,y:200,width:85,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:542,y:217,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"Config"}),i.jsx("text",{x:542,y:229,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"YAML"}),i.jsx("rect",{x:75,y:200,width:105,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:127,y:217,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"Session Token"}),i.jsx("text",{x:127,y:229,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"file"}),i.jsx("line",{x1:137,y1:33,x2:393,y2:45,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("text",{x:255,y:28,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"HTTP :9091"}),i.jsx("line",{x1:137,y1:145,x2:188,y2:145,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("line",{x1:337,y1:138,x2:393,y2:78,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("text",{x:354,y:97,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"proxy"}),i.jsx("line",{x1:557,y1:50,x2:613,y2:50,stroke:"currentColor",strokeOpacity:.4,strokeWidth:1.5,markerEnd:"url(#arch-ah)",markerStart:"url(#arch-ah-rev)"}),i.jsx("text",{x:585,y:40,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"WebSocket"}),i.jsx("line",{x1:695,y1:82,x2:695,y2:198,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("text",{x:720,y:132,fill:"currentColor",fontSize:8,opacity:.55,fontFamily:"ui-monospace,monospace",children:"Content"}),i.jsx("text",{x:720,y:144,fill:"currentColor",fontSize:8,opacity:.55,fontFamily:"ui-monospace,monospace",children:"Scripts"}),i.jsx("text",{x:720,y:160,fill:"currentColor",fontSize:8,opacity:.55,fontFamily:"ui-monospace,monospace",children:"+ CDP"}),i.jsx("line",{x1:245,y1:172,x2:245,y2:238,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:442,y1:96,x2:442,y2:198,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:520,y1:96,x2:542,y2:198,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:75,y1:60,x2:110,y2:198,stroke:"currentColor",strokeOpacity:.18,strokeDasharray:"3 2"}),i.jsx("line",{x1:200,y1:172,x2:155,y2:198,stroke:"currentColor",strokeOpacity:.18,strokeDasharray:"3 2"})]})}),i.jsx("h3",{id:"arch-components",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Components"}),i.jsx("div",{className:"space-y-2 mb-8",children:Mb.map(e=>i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsxs("div",{className:"flex items-center gap-3 flex-wrap mb-1",children:[i.jsx("span",{className:"font-semibold",children:e.name}),i.jsx(W,{size:"xs",children:e.tech}),e.port&&i.jsxs(W,{variant:"info",size:"xs",children:[":",e.port]}),e.pkg&&i.jsx(W,{variant:"secondary",size:"xs",children:e.pkg})]}),i.jsx("p",{className:"text-sm opacity-60",children:e.desc})]},e.name))}),i.jsx("h3",{id:"arch-stores",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Data Stores"}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-8",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{children:"Store"}),i.jsx("th",{children:"Format"}),i.jsx("th",{children:"Path"}),i.jsx("th",{children:"Purpose"})]})}),i.jsx("tbody",{children:Db.map(e=>i.jsxs("tr",{className:"hover:bg-base-200",children:[i.jsx("td",{className:"font-semibold text-sm",children:e.name}),i.jsx("td",{children:i.jsx(W,{size:"xs",children:e.tech})}),i.jsx("td",{className:"font-mono text-xs opacity-60",children:e.path}),i.jsx("td",{className:"text-sm opacity-60",children:e.desc})]},e.name))})]})}),i.jsx("h3",{id:"arch-flows",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Data Flows"}),i.jsxs("p",{className:"text-sm opacity-60 mb-4",children:["For a plain-language walkthrough of these same flows, see"," ",i.jsxs(we,{to:"/concepts",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Concepts ",i.jsx(qe,{className:"w-3 h-3"})]}),"."]}),i.jsx("div",{className:"space-y-4 mb-8",children:$b.map(e=>i.jsx(bl,{flow:e},e.title))}),i.jsx("h3",{id:"arch-security",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Security Model"}),i.jsx("div",{className:"border border-base-300 p-4 mb-8",children:i.jsxs("ul",{className:"space-y-2",children:[i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Session token"})," — generated on daemon start, stored at ~/.commandgarden/session-token. Every API call (except /api/status) requires Bearer auth + X-CommandGarden CSRF header."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Domain guard"})," — connector YAML declares allowed domains. Extension refuses to run on undeclared domains."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Capability gating"})," — each pipeline step requires a declared capability. High-risk capabilities (js_evaluate, cookie_write) require explicit approval."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Audit-or-fail"})," — if the audit store is unavailable, commands are blocked."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"No credentials stored"})," — commandGarden reuses existing Chrome sessions. No passwords or cookies are persisted."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Localhost only"})," — daemon and app server bind to 127.0.0.1 by default."]})]})}),i.jsx("h3",{id:"arch-packages",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Workspace Packages"}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-8",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{children:"Package"}),i.jsx("th",{children:"Description"}),i.jsx("th",{children:"Published"})]})}),i.jsx("tbody",{children:Rb.map(e=>i.jsxs("tr",{className:"hover:bg-base-200",children:[i.jsx("td",{className:"font-mono text-sm font-semibold",children:e.name}),i.jsx("td",{className:"text-sm opacity-60",children:e.desc}),i.jsx("td",{children:e.published?i.jsx(W,{variant:"success",size:"xs",children:"npm"}):i.jsx(W,{size:"xs",children:"bundled"})})]},e.name))})]})}),i.jsx("h3",{id:"arch-build",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Build Order"}),i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsx("div",{className:"flex flex-wrap items-center gap-2 font-mono text-sm",children:["shared","daemon","cli","chrome","app"].map((e,t)=>i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-2 py-1 border border-base-300 bg-base-200",children:e}),t<4&&i.jsx("span",{className:"opacity-40",children:"→"})]},e))}),i.jsxs("p",{className:"text-sm opacity-60 mt-2",children:["Run ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"npm run build"})," from the commandGarden root to build all packages in dependency order."]})]})]})}const Fb={GET:"success",POST:"warning",PUT:"info",DELETE:"error",WS:"secondary",SSE:"secondary"},Bb=[{method:"GET",path:"/api/status",auth:!1,desc:"Health check. Returns daemon status, extension connection, and connector count."},{method:"GET",path:"/api/connectors",auth:!0,desc:"List all loaded connectors with key, description, access, domains, and capabilities."},{method:"GET",path:"/api/connectors/:site/:name",auth:!0,desc:"Full connector definition including pipeline, args, and columns.",params:"site, name — connector key segments"},{method:"POST",path:"/api/run",auth:!0,desc:"Execute a connector pipeline. Returns structured data. Returns 202 with requestId if step approval is required.",body:"{ connector: string, args: Record<string, string> }"},{method:"GET",path:"/api/audit",auth:!0,desc:"List audit events with optional filters.",params:"since?, connector?, type?, limit?"},{method:"GET",path:"/api/audit/:id",auth:!0,desc:"Single audit event with full detail including pipeline steps."},{method:"GET",path:"/api/config",auth:!0,desc:"Read the full config.yaml as JSON."},{method:"POST",path:"/api/config",auth:!0,desc:"Set a config value. Key must be section.property format.",body:"{ key: string, value: string }"},{method:"POST",path:"/api/approval",auth:!0,desc:"Resolve a pending step approval.",body:"{ approvalId: string, approved: boolean }"},{method:"SSE",path:"/api/run/events/:requestId",auth:!0,desc:"Server-Sent Events stream for approval-required runs. Sends approval and result events."},{method:"WS",path:"/ws/extension",auth:!1,desc:"WebSocket endpoint for Chrome Extension. Origin validated against security.extensionId."}],Ub=[{method:"GET",path:"/api/status",auth:!1,desc:"Proxied daemon status (same as daemon /api/status)."},{method:"GET",path:"/api/connectors",auth:!1,desc:"Enriched connector list with hasAppPage, appRoute, isHighRisk, isApproved, isAutoApproved."},{method:"GET",path:"/api/connectors/:site/:name",auth:!1,desc:"Proxied connector detail."},{method:"POST",path:"/api/run",auth:!1,desc:"Proxied connector execution."},{method:"GET",path:"/api/audit",auth:!1,desc:"Proxied audit event list."},{method:"GET",path:"/api/audit/:id",auth:!1,desc:"Proxied single audit event."},{method:"GET",path:"/api/config",auth:!1,desc:"Proxied config read."},{method:"POST",path:"/api/config",auth:!1,desc:"Proxied config write."},{method:"POST",path:"/api/approval",auth:!1,desc:"Proxied approval resolution."},{method:"GET",path:"/api/preferences",auth:!1,desc:"Read app preferences (SQLite-backed).",response:"{ ok, preferences }"},{method:"PUT",path:"/api/preferences",auth:!1,desc:"Set an app preference.",body:"{ key: string, value: string }"},{method:"GET",path:"/api/goals",auth:!1,desc:"Read goals for a month.",params:"month (YYYY-MM)"},{method:"POST",path:"/api/goals",auth:!1,desc:"Create or update a goal.",body:"{ month, projectId, activity, targetDays }"},{method:"DELETE",path:"/api/goals/:id",auth:!1,desc:"Delete a goal."},{method:"GET",path:"/api/timetracking/cache",auth:!1,desc:"Get cached timetracking report for a month.",params:"month (YYYY-MM)"},{method:"POST",path:"/api/timetracking/cache",auth:!1,desc:"Store timetracking report in cache.",body:"{ month, data }"},{method:"GET",path:"/api/timetracking/projects",auth:!1,desc:"Get cached project/activity list."},{method:"POST",path:"/api/timetracking/projects",auth:!1,desc:"Store project/activity list in cache.",body:"{ data }"},{method:"POST",path:"/api/journal/generate",auth:!1,desc:"Generate a dev journal for a given week.",body:"{ weekStart: string }"},{method:"GET",path:"/api/security-news/cache",auth:!1,desc:"Get cached security news articles."},{method:"POST",path:"/api/security-news/cache",auth:!1,desc:"Store security news in cache.",body:"{ data }"}],Wb=[{cmd:"cg up",desc:"Start daemon + GUI, open browser.",opts:["--no-open Skip opening browser"]},{cmd:"cg down",desc:"Stop GUI + daemon."},{cmd:"cg run <connector>",desc:"Run a connector command.",args:"Connector key (site/name), plus connector-specific args as --key value",opts:["-f, --format <format> Output format: table, json, csv (default: table)"],example:"cg run timetracking/report --month 2026-07 --format json"},{cmd:"cg list",desc:"List all installed connectors with access, domains, and capabilities."},{cmd:"cg inspect <connector>",desc:"Show full details of a connector (args, columns, pipeline).",example:"cg inspect teams/room-availability"},{cmd:"cg validate <file>",desc:"Validate a connector YAML file against the schema.",example:"cg validate connectors/my-connector.yaml"},{cmd:"cg daemon status",desc:"Check if the daemon is running."},{cmd:"cg daemon start",desc:"Start the daemon in background."},{cmd:"cg daemon stop",desc:"Stop the daemon."},{cmd:"cg gui",desc:"Start the GUI app server (foreground by default).",opts:["-b, --background Run in background","--no-open Skip opening browser"]},{cmd:"cg gui stop",desc:"Stop the GUI app server."},{cmd:"cg gui status",desc:"Check if the GUI is running."},{cmd:"cg audit list",desc:"List recent audit events.",opts:["--since <duration> Time window (e.g. 7d, 2w, 12h)","--connector <pattern> Filter by connector (e.g. test/*)","--type <pattern> Filter by event type (e.g. auth.failed)","--limit <n> Max events (default: 100)"]},{cmd:"cg audit show <id>",desc:"Show full details of a single audit event including pipeline steps."},{cmd:"cg audit export",desc:"Export audit events.",opts:["--format <format> Export format: json, csv (default: json)","--since <duration> Time window","--connector <pattern> Filter","--type <pattern> Filter"]},{cmd:"cg config show",desc:"Show current config.yaml contents."},{cmd:"cg config set <key> <value>",desc:"Set a config value (section.property format).",example:"cg config set daemon.port 9999"},{cmd:"cg extension setup",desc:"Show extension path and instructions for Chrome installation."}],Hb=[{step:"navigate",capability:"navigate",desc:"Open a URL in the browser tab"},{step:"wait",capability:"navigate",desc:"Wait for a selector or timeout"},{step:"extract",capability:"dom_read",desc:"Read data from DOM elements"},{step:"extract_tree",capability:"dom_read",desc:"Recursive DOM tree walk with ancestry"},{step:"extract_html",capability:"dom_read",desc:"Capture element HTML as a variable"},{step:"click",capability:"dom_write",desc:"Click an element"},{step:"click_all",capability:"dom_write",desc:"Click all matching elements (with re-scan loop)"},{step:"type",capability:"dom_write",desc:"Type text into an input"},{step:"intercept",capability:"intercept_response",desc:"Capture a network response body"},{step:"cookie",capability:"cookie_read",desc:"Read cookies for a domain"},{step:"fetch",capability:"cookie_read",desc:"HTTP request from page context"},{step:"map",capability:"—",desc:"Transform/rename extracted fields"},{step:"filter",capability:"—",desc:"Filter rows by condition"},{step:"set",capability:"—",desc:"Set a variable for later steps"},{step:"transform",capability:"—",desc:"Server-side data transform (e.g. HTML→Markdown)"}];function Nd({ep:e}){const[t,n]=b.useState(!1),s=e.params||e.body||e.response;return i.jsxs("div",{className:"border-b border-base-300/50 last:border-b-0",children:[i.jsxs("button",{className:`flex items-center gap-3 w-full text-left px-3 py-2.5 ${s?"cursor-pointer hover:bg-base-200/50":""}`,onClick:()=>s&&n(!t),disabled:!s,children:[i.jsx(W,{variant:Fb[e.method]??"neutral",size:"xs",className:"w-10 justify-center shrink-0",children:e.method}),i.jsx("span",{className:"font-mono text-sm flex-1",children:e.path}),e.auth&&i.jsx(W,{variant:"warning",size:"xs",children:"auth"}),s&&i.jsx("span",{className:"text-xs opacity-40",children:t?"▾":"▸"})]}),i.jsx("div",{className:"px-3 pb-2 pl-16 text-sm opacity-60",children:e.desc}),t&&s&&i.jsxs("div",{className:"px-3 pb-3 pl-16 space-y-1.5",children:[e.params&&i.jsxs("div",{className:"text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Params: "}),i.jsx("span",{className:"font-mono opacity-60",children:e.params})]}),e.body&&i.jsxs("div",{className:"text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Body: "}),i.jsx("code",{className:"font-mono bg-base-200 px-1 py-0.5 opacity-70",children:e.body})]}),e.response&&i.jsxs("div",{className:"text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Response: "}),i.jsx("code",{className:"font-mono bg-base-200 px-1 py-0.5 opacity-70",children:e.response})]})]})]})}function Vb(){const[e,t]=b.useState("cli");return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-1",children:"API & CLI Reference"}),i.jsx("p",{className:"text-sm opacity-60 mb-6",children:"CLI commands, Daemon API endpoints, and App Server endpoints."}),i.jsx("div",{id:"api-endpoints",className:"border border-base-300 bg-base-200/30 p-3 mb-6 scroll-mt-4",children:i.jsxs("p",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold",children:"Authentication:"})," Daemon endpoints (except ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"/api/status"})," and ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"/ws/extension"}),") require an ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"Authorization: Bearer <token>"})," header and an ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"X-CommandGarden: 1"})," CSRF header. The App Server handles auth internally — GUI requests don't need tokens."]})}),i.jsx("div",{className:"flex border-b border-base-300 mb-4",children:[{id:"cli",label:"CLI Commands",sub:"cg"},{id:"daemon-api",label:"Daemon API",sub:":9091"},{id:"app-api",label:"App Server API",sub:":9092"}].map(n=>i.jsxs("button",{className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${e===n.id?"border-primary text-primary":"border-transparent opacity-60 hover:opacity-100"}`,onClick:()=>t(n.id),children:[n.label," ",i.jsx("span",{className:"font-mono text-xs opacity-40 ml-1",children:n.sub})]},n.id))}),e==="cli"&&i.jsx("div",{className:"space-y-2 mb-8",children:Wb.map(n=>i.jsxs("div",{className:"border border-base-300 p-3",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("code",{className:"font-mono text-sm font-semibold bg-base-200 px-2 py-0.5 shrink-0",children:n.cmd}),i.jsx("span",{className:"text-sm opacity-60 pt-0.5",children:n.desc})]}),n.args&&i.jsxs("div",{className:"mt-2 ml-1 text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Args: "}),i.jsx("span",{className:"opacity-60",children:n.args})]}),n.opts&&n.opts.length>0&&i.jsx("div",{className:"mt-1.5 ml-1 space-y-0.5",children:n.opts.map((s,r)=>i.jsx("div",{className:"text-xs font-mono opacity-50",children:s},r))}),n.example&&i.jsx("div",{className:"mt-2 ml-1",children:i.jsx("code",{className:"text-xs font-mono bg-base-200/70 px-2 py-1 block opacity-60",children:n.example})})]},n.cmd))}),e==="daemon-api"&&i.jsx("div",{className:"border border-base-300 mb-8",children:Bb.map((n,s)=>i.jsx(Nd,{ep:n},s))}),e==="app-api"&&i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"text-sm opacity-50 mb-3",children:["The App Server on ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:":9092"})," proxies all daemon endpoints and adds app-specific routes for preferences, caching, goals, and journal generation."]}),i.jsx("div",{className:"border border-base-300 mb-8",children:Ub.map((n,s)=>i.jsx(Nd,{ep:n},s))})]}),i.jsx("h3",{id:"api-pipeline",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Pipeline Steps"}),i.jsxs("p",{className:"text-sm opacity-50 mb-3",children:["Available steps for connector YAML pipeline definitions. For why each capability runs where it does, see"," ",i.jsxs(we,{to:"/concepts#concepts-worlds",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Capability & World Model ",i.jsx(qe,{className:"w-3 h-3"})]}),"."]}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-8",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{children:"Step"}),i.jsx("th",{children:"Capability"}),i.jsx("th",{children:"Description"})]})}),i.jsx("tbody",{children:Hb.map(n=>i.jsxs("tr",{className:"hover:bg-base-200",children:[i.jsx("td",{className:"font-mono text-sm font-semibold",children:n.step}),i.jsx("td",{children:i.jsx(W,{size:"xs",variant:n.capability==="—"?"neutral":"info",children:n.capability})}),i.jsx("td",{className:"text-sm opacity-60",children:n.desc})]},n.step))})]})}),i.jsx("h3",{id:"api-expressions",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Expression Syntax"}),i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsxs("p",{className:"text-sm opacity-60 mb-3",children:["Use ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"${{ }}"})," for template expressions (no JS eval):"]}),i.jsxs("div",{className:"space-y-1.5 font-mono text-xs",children:[i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Variable access"}),i.jsx("code",{className:"opacity-70",children:"args.month, vars.token, cookies.name"})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Row access (map)"}),i.jsx("code",{className:"opacity-70",children:"row.id, row.name"})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Concatenation"}),i.jsx("code",{className:"opacity-70",children:'"Bearer " + vars.token'})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Pipe filters"}),i.jsx("code",{className:"opacity-70",children:'args.month | default("2026-06"), value | number, text | trim'})]})]})]})]})}function Kb(e){const n=e.replace(/^---\s*\n[\s\S]*?\n---\s*\n/,"").split(`
407
+ */const L1=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],P1=K("triangle-alert",L1),I1={reached:$v,on_track:A1,behind:_c,at_risk:P1},O1={reached:"text-success",on_track:"text-success",behind:"text-warning",at_risk:"text-error"},_1={reached:"bg-success/10",on_track:"bg-success/5",behind:"bg-warning/10",at_risk:"bg-error/10"};function M1(e,t,n){const s=n.find(r=>r.projectId===e&&r.activity===t);return(s==null?void 0:s.totalHours)??0}function D1({goals:e,activityHours:t,projectNames:n,activityNames:s,month:r,today:a}){return e.length===0?null:i.jsx("div",{className:"border border-base-300",children:e.map((o,l)=>{const c=M1(o.projectId,o.activity,t),u=Nv({targetHours:o.targetHours,actualHours:c,month:r,today:a}),m=n.get(o.projectId),d=I1[u.status];return i.jsxs("div",{className:`grid grid-cols-[auto_1fr_auto_1fr] gap-0 ${_1[u.status]} ${l>0?"border-t border-base-300":""}`,children:[i.jsx("div",{className:"p-3 border-r border-base-300 flex items-center justify-center",children:i.jsx(d,{size:18,className:O1[u.status]})}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-display font-semibold text-sm",children:m??o.projectId}),i.jsxs("div",{className:"font-mono text-[0.6rem] opacity-50 mt-0.5",children:[m?`${o.projectId} · `:"",s.get(`${o.projectId}\0${o.activity}`)??o.activity]})]}),i.jsxs("div",{className:"p-3 border-r border-base-300 text-right min-w-[7rem]",children:[i.jsxs("div",{className:"font-display font-semibold text-sm",children:[Math.round(c*10)/10,"/",o.targetHours,"h"]}),i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mt-0.5",children:[o.targetDays,"d target"]})]}),i.jsxs("div",{className:"p-3",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Cv,{percentage:u.percentage,status:u.status,className:"flex-1"}),i.jsxs("span",{className:"font-mono text-xs font-medium min-w-[3rem] text-right",children:[Math.round(u.percentage),"%"]})]}),u.status==="reached"?i.jsx("div",{className:"font-mono text-[0.6rem] font-medium text-success uppercase tracking-[0.1em]",children:"Goal reached"}):i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:u.workingDaysRemaining>0?`Book ${Math.round(u.hoursPerDayNeeded*10)/10}h/day · ${u.workingDaysRemaining} days left`:`${Math.round(u.daysRemaining*10)/10} days remaining`})]})]},o.id)})})}function $1({goals:e,month:t,onGoalChange:n,knownCombos:s,projectNames:r,activityNames:a,onRefreshProjects:o,refreshingProjects:l}){const[c,u]=b.useState(""),[m,d]=b.useState(""),[f,v]=b.useState(null),[y,x]=b.useState(""),[w,g]=b.useState(!1),p=b.useMemo(()=>{const T=new Set(e.map(L=>`${L.projectId}\0${L.activity}`));return s.filter(L=>!T.has(`${L.projectId}\0${L.activity}`))},[s,e]);function h(T){const L=T.indexOf("\0");return L<0?null:{projectId:T.slice(0,L),activity:T.slice(L+1)}}function j(T){return r.get(T)??T}function k(T,L){const F=a.get(`${T}\0${L}`);return F?`${j(T)} / ${F}`:`${j(T)} / ${L}`}async function C(){const T=h(c),L=parseFloat(m);if(!(!T||isNaN(L)||L<.5||L>31)){g(!0);try{await B.upsertGoal({month:t,projectId:T.projectId,activity:T.activity,targetDays:L}),u(""),d(""),n()}finally{g(!1)}}}async function S(T){g(!0);try{await B.deleteGoal(T),n()}finally{g(!1)}}async function N(T){const L=parseFloat(y);if(isNaN(L)||L<.5||L>31){v(null);return}g(!0);try{await B.upsertGoal({month:T.month,projectId:T.projectId,activity:T.activity,targetDays:L}),v(null),n()}finally{g(!1)}}return i.jsxs("details",{children:[i.jsxs("summary",{className:"cursor-pointer text-sm font-semibold mb-2",children:["Manage goals (",e.length,")"]}),i.jsxs("div",{className:"mt-2 space-y-3",children:[e.length>0&&i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-xs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Project"}),i.jsx("th",{children:"Activity"}),i.jsx("th",{className:"text-right",children:"Target (days)"}),i.jsx("th",{className:"text-right",children:"Target (hours)"}),i.jsx("th",{children:"Actions"})]})}),i.jsx("tbody",{children:e.map(T=>i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("div",{className:"text-sm",children:j(T.projectId)}),r.has(T.projectId)&&i.jsx("div",{className:"font-mono text-[0.6rem] opacity-50",children:T.projectId})]}),i.jsxs("td",{children:[i.jsx("div",{className:"text-sm",children:a.get(`${T.projectId}\0${T.activity}`)??T.activity}),i.jsx("div",{className:"font-mono text-[0.6rem] opacity-50",children:T.activity})]}),i.jsx("td",{className:"text-right",children:f===T.id?i.jsx("input",{type:"number",step:"0.5",className:"input input-bordered input-xs w-20 text-right",value:y,onChange:L=>x(L.target.value),onBlur:()=>N(T),onKeyDown:L=>{L.key==="Enter"&&N(T),L.key==="Escape"&&v(null)},autoFocus:!0}):T.targetDays}),i.jsx("td",{className:"text-right",children:T.targetHours}),i.jsxs("td",{className:"flex gap-1",children:[i.jsx("button",{className:"btn btn-ghost btn-xs font-mono",onClick:()=>{v(T.id),x(String(T.targetDays))},disabled:w,"aria-label":`Edit goal ${T.projectId} ${T.activity}`,children:"Edit"}),i.jsx("button",{className:"btn btn-ghost btn-xs text-error font-mono",onClick:()=>S(T.id),disabled:w,"aria-label":`Delete goal ${T.projectId} ${T.activity}`,children:"Del"})]})]},T.id))})]})}),i.jsxs("div",{className:"flex items-end gap-2",children:[i.jsxs("select",{className:"select select-bordered select-sm",value:c,onChange:T=>u(T.target.value),children:[i.jsx("option",{value:"",children:"Select project / activity…"}),p.map(T=>i.jsx("option",{value:`${T.projectId}\0${T.activity}`,children:k(T.projectId,T.activity)},`${T.projectId}\0${T.activity}`))]}),i.jsx("input",{type:"number",step:"0.5",min:"0.5",max:"31",placeholder:"Days",className:"input input-bordered input-sm w-24",value:m,onChange:T=>d(T.target.value)}),i.jsx("button",{className:"btn btn-primary btn-sm",onClick:C,disabled:w||!c,children:"Add"}),i.jsx("button",{className:"btn btn-ghost btn-sm font-mono text-xs opacity-60",onClick:o,disabled:l,children:l?"Refreshing…":"Refresh projects"})]})]})]})}function R1(e,t){var G;const[n,s]=b.useState([]),[r,a]=b.useState([]),[o,l]=b.useState(null),[c,u]=b.useState([]),m=b.useRef(c);m.current=c;const[d,f]=b.useState(!1),v=b.useCallback(async()=>{try{const E=await B.getGoals(e);s(E.goals)}catch{}},[e]),y=b.useCallback(async()=>{try{const E=await B.getCachedReport(e);E.data?(a(E.data),l(E.fetchedAt)):(a([]),l(null))}catch{}},[e]),x=b.useCallback(async()=>{try{const E=await B.getCachedProjects();E.data&&u(E.data)}catch{}},[]),w=b.useCallback(async()=>{f(!0);try{const E=await B.run("timetracking/projects",{month:e});if(E.ok&&E.data&&E.data.length>0){const D=E.data.map(I=>({projectId:String(I.projectId??""),projectName:String(I.projectName??""),activityNumber:String(I.activityNumber??""),activityName:String(I.activityName??""),category:String(I.category??""),linePropertyId:String(I.linePropertyId??"")}));u(D),await B.cacheProjects(D)}}catch{}f(!1)},[e]);b.useEffect(()=>{v(),y(),x()},[v,y,x]);const g=t==null?void 0:t.data;b.useEffect(()=>{if(g&&g.length>0){l(null),B.cacheReport(e,g).catch(()=>{});const E=new Set,D=[];for(const I of g){const R=String(I.projectId??""),A=String(I.activity??"");if(!R||!A)continue;const _=`${R}\0${A}`;E.has(_)||(E.add(_),D.push({projectId:R,projectName:I.projectName?String(I.projectName):R,activityNumber:A,activityName:I.activityName?String(I.activityName):A,category:String(I.category??""),linePropertyId:""}))}if(D.length>0){const I=new Map;for(const A of m.current)I.set(`${A.projectId}\0${A.activityNumber}`,A);for(const A of D)I.set(`${A.projectId}\0${A.activityNumber}`,A);const R=Array.from(I.values());u(R),B.cacheProjects(R).catch(()=>{})}}},[g,e]);const p=((t==null?void 0:t.data)??[]).length>0?(t==null?void 0:t.data)??[]:r,h=p===r&&r.length>0&&!((G=t==null?void 0:t.data)!=null&&G.length),{projectNames:j,activityNames:k}=b.useMemo(()=>{const E=new Map,D=new Map;for(const I of c)I.projectId&&I.projectName&&E.set(I.projectId,I.projectName),I.projectId&&I.activityNumber&&I.activityName&&D.set(`${I.projectId}\0${I.activityNumber}`,I.activityName);for(const I of p){const R=String(I.projectId??""),A=I.projectName?String(I.projectName):null;R&&A&&E.set(R,A);const _=String(I.activity??""),$=I.activityName?String(I.activityName):null;R&&_&&$&&D.set(`${R}\0${_}`,$)}return{projectNames:E,activityNames:D}},[c,p]),{projectList:C,totalHours:S,draftCount:N,workingDayCount:T}=b.useMemo(()=>{const E=new Map;let D=0,I=0;const R=new Set;for(const A of p){const _=String(A.projectId??"Unknown"),$=Number(A.hours??0),z=String(A.date??""),J=String(A.status??""),xe=String(A.activity??"");D+=$,z&&R.add(z),J==="draft"&&I++,E.has(_)||E.set(_,{projectId:_,totalHours:0,entryCount:0,activities:new Set});const Me=E.get(_);if(Me.totalHours+=$,Me.entryCount++,xe){const un=k.get(`${_}\0${xe}`)??xe;Me.activities.add(un)}}return{projectList:Array.from(E.values()).sort((A,_)=>_.totalHours-A.totalHours),totalHours:D,draftCount:I,workingDayCount:R.size}},[p,k]),L=b.useMemo(()=>{const E=new Map;for(const D of p){const I=String(D.projectId??"Unknown"),R=String(D.activity??""),A=Number(D.hours??0),_=`${I}\0${R}`,$=E.get(_);$?$.totalHours+=A:E.set(_,{projectId:I,activity:R,totalHours:A})}return Array.from(E.values())},[p]),F=b.useMemo(()=>c.length>0?c.map(E=>({projectId:E.projectId,activity:E.activityNumber})):L.map(E=>({projectId:E.projectId,activity:E.activity})),[c,L]),H=new Date().toISOString().slice(0,10);return{goals:n,loadGoals:v,rows:p,isCached:h,cachedAt:o,projectNames:j,activityNames:k,projectList:C,totalHours:S,draftCount:N,workingDayCount:T,activityHours:L,allCombos:F,todayStr:H,refreshProjects:w,refreshingProjects:d}}function z1(){const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function F1(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function B1(){const[e,t]=b.useState(z1()),[n,s]=b.useState(!1),{running:r,result:a,error:o,approvalPending:l,approvalId:c,run:u,handleApproval:m,reset:d}=Sr(),{goals:f,loadGoals:v,rows:y,isCached:x,cachedAt:w,projectNames:g,activityNames:p,projectList:h,totalHours:j,draftCount:k,workingDayCount:C,activityHours:S,allCombos:N,todayStr:T,refreshProjects:L,refreshingProjects:F}=R1(e,a),H=(o==null?void 0:o.includes("auth_required"))||(o==null?void 0:o.includes("sign in")),G=b.useCallback(async()=>{const E={};e&&(E.month=e),await u("timetracking/report",E),await v()},[e,u,v]);return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Time Tracking"}),i.jsxs("div",{className:"flex items-end gap-4 mb-6",children:[i.jsxs("label",{className:"form-control",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Month"}),i.jsx("input",{type:"month",className:"input input-bordered input-sm",value:e,onChange:E=>{t(E.target.value),d()},onClick:E=>{var D,I;return(I=(D=E.target).showPicker)==null?void 0:I.call(D)}})]}),i.jsx("button",{className:"btn btn-primary btn-sm",onClick:G,disabled:r,children:r?"Loading...":"Load report"})]}),r&&!l&&i.jsx(ht,{label:"Fetching timetracking data..."}),l&&i.jsxs("div",{className:"alert alert-warning mb-4",children:[i.jsx("span",{children:"This connector requires approval before proceeding."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>m(!0),disabled:!c,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>m(!1),disabled:!c,children:"Reject"})]})]}),H&&i.jsx(Tn,{message:"Sign in to the timetracking portal in Chrome, then try again."}),o&&!H&&i.jsx("div",{className:"alert alert-error mb-4",children:i.jsx("span",{children:o})}),y.length>0&&i.jsxs(i.Fragment,{children:[x&&w&&i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-2",children:["Showing cached data from ",F1(w)]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 border border-base-300 mb-6",children:[i.jsxs("div",{className:"p-3 border-r border-b border-base-300 md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Total hours"}),i.jsx("div",{className:"font-display text-xl font-bold",children:j.toFixed(1)})]}),i.jsxs("div",{className:"p-3 border-b border-base-300 md:border-r md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Working days"}),i.jsx("div",{className:"font-display text-xl font-bold",children:C})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Projects"}),i.jsx("div",{className:"font-display text-xl font-bold",children:h.length})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Draft entries"}),i.jsx("div",{className:"font-display text-xl font-bold",children:k})]})]}),i.jsx("h3",{className:"font-display text-base font-semibold mb-3",children:"By project"}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-6",children:i.jsxs("table",{className:"table table-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Project"}),i.jsx("th",{children:"Activities"}),i.jsx("th",{className:"text-right",children:"Hours"}),i.jsx("th",{className:"text-right",children:"Entries"})]})}),i.jsx("tbody",{children:h.map(E=>i.jsxs("tr",{children:[i.jsx("td",{children:g.has(E.projectId)?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-sm",children:g.get(E.projectId)}),i.jsx("div",{className:"font-mono text-[0.6rem] opacity-50",children:E.projectId})]}):i.jsx("span",{className:"font-mono text-sm",children:E.projectId})}),i.jsx("td",{className:"text-sm",children:Array.from(E.activities).join(", ")}),i.jsx("td",{className:"text-right font-semibold",children:E.totalHours.toFixed(1)}),i.jsx("td",{className:"text-right",children:E.entryCount})]},E.projectId))})]})}),i.jsxs("details",{open:n,onToggle:E=>s(E.target.open),children:[i.jsxs("summary",{className:"cursor-pointer text-sm font-semibold mb-2",children:["Raw booking lines (",y.length,")"]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"table table-xs",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Date"}),i.jsx("th",{children:"Project"}),i.jsx("th",{children:"Activity"}),i.jsx("th",{className:"text-right",children:"Hours"}),i.jsx("th",{children:"Status"})]})}),i.jsx("tbody",{children:y.map((E,D)=>i.jsxs("tr",{children:[i.jsx("td",{children:String(E.date??"")}),i.jsx("td",{className:"font-mono text-xs",children:String(E.projectId??"")}),i.jsx("td",{children:String(E.activity??"")}),i.jsx("td",{className:"text-right",children:Number(E.hours??0).toFixed(1)}),i.jsx("td",{children:i.jsx(W,{variant:String(E.status)==="posted"?"success":"warning",size:"xs",children:String(E.status??"")})})]},D))})]})})]})]}),a&&(a.data??[]).length===0&&y.length===0&&!o&&i.jsxs("p",{className:"text-sm opacity-50",children:["No entries found for ",e,"."]}),f.length>0&&i.jsxs("div",{className:"mb-6",children:[i.jsx("h3",{className:"font-display text-base font-semibold mb-3",children:"Goal progress"}),i.jsx(D1,{goals:f,activityHours:S,projectNames:g,activityNames:p,month:e,today:T})]}),i.jsx("div",{className:"mt-6",children:i.jsx($1,{goals:f,month:e,onGoalChange:v,knownCombos:N,projectNames:g,activityNames:p,onRefreshProjects:L,refreshingProjects:F})})]})}const Qh={"MBTMY THE BASE CAMP":"res-rere-m6vz23ty@mercedes-benz.com","MBTMY THE TRAILHEAD":"res-rere-m6vc2q4d@mercedes-benz.com","MBTMY THE FOOTHILLS":"res-rere-m6vcb79c@mercedes-benz.com","MBTMY THE BRIDGE":"res-rere-m6vgcah6@mercedes-benz.com","MBTMY THE RIDGE":"res-rere-m6vjxdkc@mercedes-benz.com","MBTMY THE MEADOW":"res-rere-m6vhkzmd@mercedes-benz.com","MBTMY THE FOREST":"res-rere-m6vhsc6h@mercedes-benz.com","MBTMY THE LOOKOUT":"res-rere-m6vjqgrq@mercedes-benz.com","MBTMY THE CLIFFSIDE":"res-rere-m6vjl2tw@mercedes-benz.com","MBTMY THE LEDGE":"res-rere-m6vjfbmr@mercedes-benz.com","MBTMY THE HIGHPOINT":"res-rere-m6vjblgb@mercedes-benz.com","MBTMY THE VISTA":"RES-RERE-M6VJ7ZUW@mercedes-benz.com","MBTMY THE SHOULDER":"res-rere-m6vj3tuq@mercedes-benz.com","MBTMY THE PINNACLE":"res-rere-m6vhxd4c@mercedes-benz.com","MBTMY THE DESCENT":"res-rere-m6vzgysp@mercedes-benz.com"},U1=Object.fromEntries(Object.entries(Qh).map(([e,t])=>[t.toLowerCase(),e.replace(/^MBTMY\s+/i,"").replace(/\b\w+/g,n=>n[0].toUpperCase()+n.slice(1).toLowerCase())])),hd={free:"success",busy:"error",tentative:"warning",oof:"secondary",elsewhere:"info"},W1={free:"bg-success/20 border-success/40",busy:"bg-error/20 border-error/40",tentative:"bg-warning/20 border-warning/40",oof:"bg-secondary/20 border-secondary/40",elsewhere:"bg-info/20 border-info/40"},H1={free:"bg-success/35 border-success/60",busy:"bg-error/35 border-error/60",tentative:"bg-warning/35 border-warning/60",oof:"bg-secondary/35 border-secondary/60",elsewhere:"bg-info/35 border-info/60"};function Mn(e){const t=e.match(/(\d{1,2}:\d{2})/);return t?t[1]:e}function V1({rows:e}){var r,a;const[t,n]=b.useState(null),s=e.reduce((o,l)=>o+(l.durationMin??0),0);return i.jsxs("div",{children:[s>0&&i.jsxs("div",{className:"mb-6",children:[i.jsx("div",{className:"flex h-10 overflow-hidden gap-px border border-base-300",children:e.map((o,l)=>{const c=s>0?(o.durationMin??0)/s*100:0;if(c<.5)return null;const u=t===l,m=u?H1[o.state??""]??"bg-base-300":W1[o.state??""]??"bg-base-300";return i.jsxs("div",{className:`${m} border flex items-center justify-center text-xs transition-colors duration-75 cursor-default relative`,style:{width:`${c}%`},onMouseEnter:()=>n(l),onMouseLeave:()=>n(null),children:[c>12&&i.jsx("span",{className:"opacity-60 truncate px-1 font-mono text-[0.65rem] uppercase tracking-wide",children:o.state}),u&&i.jsxs("div",{className:"absolute -top-9 left-1/2 -translate-x-1/2 bg-base-300 border border-base-content/10 px-2 py-1 text-[0.65rem] font-mono whitespace-nowrap z-10 pointer-events-none",children:[o.state,": ",Mn(o.start??""),"–",Mn(o.end??"")," (",o.durationMin,"m)"]})]},l)})}),i.jsxs("div",{className:"flex justify-between mt-1",children:[i.jsx("span",{className:"font-mono text-[0.6rem] opacity-30",children:Mn(((r=e[0])==null?void 0:r.start)??"")}),i.jsx("span",{className:"font-mono text-[0.6rem] opacity-30",children:Mn(((a=e[e.length-1])==null?void 0:a.end)??"")})]})]}),i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"Start"}),i.jsx("th",{children:"End"}),i.jsx("th",{children:"State"}),i.jsx("th",{className:"text-right",children:"Duration"})]})}),i.jsx("tbody",{children:e.map((o,l)=>i.jsxs("tr",{className:`transition-colors duration-75 ${t===l?"bg-base-200":"hover:bg-base-200"}`,onMouseEnter:()=>n(l),onMouseLeave:()=>n(null),children:[i.jsx("td",{className:"font-mono text-sm",children:Mn(o.start??"")}),i.jsx("td",{className:"font-mono text-sm",children:Mn(o.end??"")}),i.jsx("td",{children:i.jsx(W,{variant:hd[o.state??""]??"neutral",children:o.state})}),i.jsxs("td",{className:"text-right font-mono text-sm",children:[o.durationMin,"m"]})]},l))})]})}),i.jsx("div",{className:"flex flex-wrap gap-4 mt-3",children:Object.entries(hd).map(([o,l])=>i.jsx("div",{className:"flex items-center gap-1.5",children:i.jsx(W,{variant:l,size:"xs",children:o})},o))})]})}const K1=[{id:1,name:"The Base Camp",x:685,y:75,w:160,h:85,capacity:10},{id:2,name:"The Trailhead",x:880,y:130,w:95,h:100,capacity:4},{id:3,name:"The Foothills",x:880,y:255,w:95,h:100,capacity:5},{id:4,name:"The Bridge",x:880,y:380,w:95,h:100,capacity:4},{id:5,name:"The Ridge",x:650,y:620,w:250,h:110,capacity:18},{id:6,name:"The Meadow",x:535,y:480,w:92,h:80,capacity:6},{id:7,name:"The Forest",x:428,y:480,w:92,h:80,capacity:16},{id:8,name:"The Lookout",x:540,y:795,w:110,h:75,capacity:4},{id:9,name:"The Cliffside",x:410,y:795,w:110,h:75,capacity:4},{id:10,name:"The Ledge",x:280,y:795,w:110,h:75,capacity:4},{id:11,name:"The Highpoint",x:150,y:795,w:110,h:75,capacity:10},{id:12,name:"The Vista",x:30,y:750,w:100,h:115,capacity:12},{id:13,name:"The Shoulder",x:30,y:620,w:100,h:110,capacity:4},{id:14,name:"The Pinnacle",x:30,y:300,w:120,h:260,capacity:16},{id:15,name:"The Descent",x:30,y:60,w:120,h:170,capacity:6}],G1=[{name:"The Summit",x:170,y:60,w:230,h:500},{name:"The Lodge",x:670,y:60,w:190,h:500},{name:"The Plateau",x:150,y:620,w:470,h:150}],q1=[{x:90,y:28,dir:"down"},{x:355,y:28,dir:"down"},{x:765,y:28,dir:"down"},{x:24,y:596,dir:"left"}],Y1={free:"fill-success/15 stroke-success",busy:"fill-error/15 stroke-error",unknown:"fill-base-200/60 stroke-base-300"};function li(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"").replace(/^mbtmy/,"").replace(/^the/,"")}function Q1({statuses:e={},selected:t,onSelect:n}){const r=`hatch-${b.useId().replace(/[^a-zA-Z0-9]/g,"")}`,a=new Map(Object.entries(e).map(([c,u])=>[li(c),u])),o=t?li(t):null,l=c=>a.get(li(c.name))??"unknown";return i.jsxs("div",{className:"border border-base-300 p-3 sm:p-4",children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("svg",{viewBox:"0 0 1000 900",className:"min-w-[560px] w-full h-auto select-none",role:"group","aria-label":"Office floor plan",children:[i.jsx("defs",{children:i.jsx("pattern",{id:r,width:"7",height:"7",patternUnits:"userSpaceOnUse",patternTransform:"rotate(45)",children:i.jsx("line",{x1:"0",y1:"0",x2:"0",y2:"7",strokeWidth:"1",className:"stroke-base-300"})})}),i.jsx("rect",{x:"14",y:"40",width:"972",height:"846",className:"fill-base-100 stroke-base-content/60",strokeWidth:"2"}),G1.map(c=>i.jsxs("g",{children:[i.jsx("rect",{x:c.x,y:c.y,width:c.w,height:c.h,className:"fill-base-200/30 stroke-base-300",strokeWidth:"1",strokeDasharray:"4 4"}),i.jsx("text",{x:c.x+c.w/2,y:c.y+c.h/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:"13",letterSpacing:"2",className:"fill-base-content/25 font-mono uppercase",children:c.name})]},c.name)),i.jsxs("g",{children:[i.jsx("rect",{x:"420",y:"60",width:"232",height:"405",fill:`url(#${r})`,className:"stroke-base-300",strokeWidth:"1"}),i.jsx("rect",{x:"437",y:"192",width:"198",height:"140",className:"fill-base-100 stroke-base-300",strokeWidth:"1"}),i.jsx("text",{x:"536",y:"255",textAnchor:"middle",fontSize:"12",letterSpacing:"2",className:"fill-base-content/40 font-mono uppercase",children:"Courtyard"}),i.jsx("text",{x:"536",y:"275",textAnchor:"middle",fontSize:"8",letterSpacing:"1.5",className:"fill-base-content/25 font-mono uppercase",children:"Reflective pool"})]}),i.jsx("rect",{x:"680",y:"758",width:"220",height:"112",fill:`url(#${r})`,className:"stroke-base-300",strokeWidth:"1"}),i.jsx("text",{x:"790",y:"818",textAnchor:"middle",fontSize:"9",letterSpacing:"1.5",className:"fill-base-content/30 font-mono uppercase",children:"Facilities"}),q1.map((c,u)=>i.jsx("g",{children:c.dir==="left"?i.jsxs(i.Fragment,{children:[i.jsx("path",{d:`M ${c.x} ${c.y-6} L ${c.x} ${c.y+6} L ${c.x-7} ${c.y} Z`,className:"fill-base-content/40"}),i.jsx("text",{x:c.x+10,y:c.y,textAnchor:"start",dominantBaseline:"central",fontSize:"8",letterSpacing:"1",className:"fill-base-content/40 font-mono uppercase",children:"Entry"})]}):i.jsxs(i.Fragment,{children:[i.jsx("path",{d:`M ${c.x-6} ${c.y} L ${c.x+6} ${c.y} L ${c.x} ${c.y+7} Z`,className:"fill-base-content/40"}),i.jsx("text",{x:c.x,y:c.y-5,textAnchor:"middle",fontSize:"8",letterSpacing:"1",className:"fill-base-content/40 font-mono uppercase",children:"Entry"})]})},u)),K1.map(c=>{const u=l(c),m=o!==null&&li(c.name)===o,d=c.w<100;return i.jsxs("g",{role:n?"button":void 0,tabIndex:n?0:void 0,onClick:n?()=>n(c.name):void 0,onKeyDown:n?f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),n(c.name))}:void 0,className:n?"cursor-pointer hover:opacity-75 focus:outline-none transition-opacity":void 0,children:[i.jsx("title",{children:`${c.name} — ${u==="unknown"?"not checked":u}`}),i.jsx("rect",{x:c.x,y:c.y,width:c.w,height:c.h,strokeWidth:u==="unknown"?1:1.5,className:Y1[u]}),m&&i.jsx("rect",{x:c.x+3,y:c.y+3,width:c.w-6,height:c.h-6,className:"fill-none stroke-primary",strokeWidth:"2"}),i.jsx("circle",{cx:c.x+15,cy:c.y+15,r:"9",className:"fill-base-100 stroke-base-content/30",strokeWidth:"1"}),i.jsx("text",{x:c.x+15,y:c.y+15,textAnchor:"middle",dominantBaseline:"central",fontSize:"8.5",className:"fill-base-content/60 font-mono",children:c.id}),i.jsx("text",{x:c.x+c.w/2,y:c.y+c.h/2+(c.h>90?10:8),textAnchor:"middle",fontSize:d?12:13.5,letterSpacing:"0.8",className:"fill-base-content/80 font-mono uppercase font-medium",children:c.name.replace(/^The\s+/i,"")}),i.jsxs("text",{x:c.x+c.w/2,y:c.y+c.h/2+(c.h>90?10:8)+(d?14:16),textAnchor:"middle",fontSize:10.5,letterSpacing:"0.5",className:"fill-base-content/40 font-mono",children:[c.capacity,"p"]})]},c.id)})]})}),i.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-1 mt-3 font-mono text-[0.6rem] uppercase tracking-[0.1em] opacity-70",children:[i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"w-2.5 h-2.5 inline-block bg-success/15 border border-success"})," Available"]}),i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"w-2.5 h-2.5 inline-block bg-error/15 border border-error"})," Busy"]}),i.jsxs("span",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:"w-2.5 h-2.5 inline-block bg-base-200 border border-base-300"})," Not checked"]}),n&&i.jsx("span",{className:"opacity-60",children:"Click a room to select it"})]})]})}function J1(){return new Date().toISOString().slice(0,10)}const pd=[15,30,45,60,90,120,180,240,300,360,420,480,540],Rs=15,gd=Array.from({length:24*4},(e,t)=>{const n=Math.floor(t/4),s=t%4*15;return`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`});function yd(){const e=new Date,t=e.getHours()*60+Math.round(e.getMinutes()/15)*15,n=Math.floor(t/60)%24,s=t%60;return`${String(n).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function zs(e){const[t,n]=e.split(":").map(Number);return t*60+n}function na(e){const t=Math.floor(e/60)%24,n=e%60;return`${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function Xn(e){const[t,n]=e.split(":").map(Number),s=t<12?"AM":"PM";return`${t%12===0?12:t%12}:${String(n).padStart(2,"0")} ${s}`}function X1(e){if(e<60)return`${e} min`;const t=Math.floor(e/60),n=e%60;return n===0?`${t}h`:`${t}h ${n}m`}function xd(e){try{const t=new Date(e+"T00:00:00"),n=new Date;n.setHours(0,0,0,0);const s=t.getTime()-n.getTime(),r=Math.round(s/864e5);return r===0?"Today":r===1?"Tomorrow":r===-1?"Yesterday":t.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}catch{return e}}function vd(e,t){if(!e)return null;let n=new Date(e);return Number.isNaN(n.getTime())?(n=new Date(`${t}T${e}`),Number.isNaN(n.getTime())?null:n):n}function Z1(e,t,n,s){const r=new Date(`${t}T${n}:00`),a=new Date(r.getTime()+s*6e4);return!e.some(l=>{if(l.state==="free")return!1;const c=vd(l.start,t),u=vd(l.end,t);return c===null||u===null?!1:c<a&&r<u})}const vt=24*60;function vl(e,t){return Math.max(0,Math.min(vt-t,e))}function bd(e){return Math.round(e/15)*15}function eb({startMinutes:e,durationMinutes:t,onChange:n}){const s=b.useRef(null),r=b.useRef(!1),a=v=>{const y=s.current;if(!y)return e;const x=y.getBoundingClientRect(),g=Math.max(0,Math.min(1,(v-x.left)/x.width))*vt;return bd(g)},o=v=>{const y=a(v)-t/2;n(vl(bd(y),t))},l=v=>{r.current=!0,v.currentTarget.setPointerCapture(v.pointerId),o(v.clientX)},c=v=>{r.current&&o(v.clientX)},u=()=>{r.current=!1},m=e/vt*100,d=t/vt*100,f=e+t;return i.jsxs("div",{children:[i.jsxs("div",{ref:s,className:"relative h-10 bg-base-200 border border-base-300 rounded cursor-pointer select-none touch-none",onPointerDown:l,onPointerMove:c,onPointerUp:u,children:[i.jsx("div",{className:"absolute inset-0 flex",children:Array.from({length:8},(v,y)=>i.jsx("div",{className:"flex-1 border-r border-base-300/60 last:border-r-0"},y))}),i.jsx("div",{className:"absolute top-0 h-full bg-primary/20 border border-primary/50 rounded cursor-grab active:cursor-grabbing",style:{left:`${m}%`,width:`${d}%`}}),i.jsx("div",{className:"absolute top-0 h-full flex items-center text-xs font-mono font-semibold text-base-content whitespace-nowrap pointer-events-none",style:{left:d<10?`${m+d+.5}%`:`${m}%`,width:d<10?"auto":`${d}%`,justifyContent:d<10?"flex-start":"center"},children:i.jsxs("span",{className:d<10?"text-base-content/80":"",children:[Xn(na(e)),"–",Xn(na(f))]})})]}),i.jsxs("div",{className:"flex justify-between font-mono text-[0.55rem] opacity-50 mt-1",children:[i.jsx("span",{children:"12 AM"}),i.jsx("span",{children:"3 AM"}),i.jsx("span",{children:"6 AM"}),i.jsx("span",{children:"9 AM"}),i.jsx("span",{children:"12 PM"}),i.jsx("span",{children:"3 PM"}),i.jsx("span",{children:"6 PM"}),i.jsx("span",{children:"9 PM"}),i.jsx("span",{children:"12 AM"})]})]})}function tb(){var gt;const[e,t]=b.useState(J1()),[n,s]=b.useState(()=>zs(yd())),r=na(n),[a,o]=b.useState(120),[l,c]=b.useState("duration"),[u,m]=b.useState(()=>zs(yd())+120),[d,f]=b.useState(1),v=l==="endtime"?Math.max(Rs,u-n):a,y=b.useCallback(O=>{if(O!==l){if(O==="endtime")m(Math.min(vt,n+a));else{const q=Math.max(Rs,u-n),ce=pd.reduce((rt,Ts)=>Math.abs(Ts-q)<Math.abs(rt-q)?Ts:rt);o(ce)}c(O)}},[l,n,a,u]),x=b.useCallback(O=>{const q=Math.max(n+Rs,Math.min(vt,O));m(q)},[n]),w=b.useCallback(O=>{const q=vl(O,l==="endtime"?Rs:a);s(q),l==="endtime"&&m(ce=>Math.max(q+Rs,Math.min(vt,ce)))},[l,a]),[g,p]=b.useState(null),[h,j]=b.useState(null),[k,C]=b.useState(null),[S,N]=b.useState(!1),T=b.useRef(e),{running:L,result:F,error:H,approvalPending:G,approvalId:E,run:D,handleApproval:I}=Sr();b.useEffect(()=>{let O=!1;return B.getCachedRoomAvailability(e).then(q=>{O||(q.data&&q.data.length>0?(j(q.data),C(q.fetchedAt),N(!0)):(j(null),C(null),N(!1)))}).catch(()=>{}),()=>{O=!0}},[e]),b.useEffect(()=>{if(F!=null&&F.data&&F.data.length>0){const O=new Date().toISOString();C(O),N(!1),j(F.data),B.cacheRoomAvailability(T.current,F.data).catch(()=>{})}},[F]);const R=b.useCallback(async()=>{N(!1),T.current=e;const O=Object.entries(Qh).map(([q,ce])=>`${q}:${ce}`).join(",");await D("teams/rooms-availability",{rooms:O,date:e})},[D,e]),A=(H==null?void 0:H.includes("auth_required"))||(H==null?void 0:H.includes("sign in")),_=(F==null?void 0:F.data)??h??[],$=b.useMemo(()=>_.map(O=>({room:String(O.roomEmail??O.room??""),capacity:O.capacity===null||O.capacity===void 0||O.capacity===""?null:Number(O.capacity),start:String(O.start??""),end:String(O.end??""),state:String(O.state??""),durationMin:Number(O.durationMin??0)})),[_]),z=b.useMemo(()=>{const O=new Map;for(const ce of $){const rt=ce.room.toLowerCase();O.has(rt)||O.set(rt,[]),O.get(rt).push(ce)}const q=new Map;for(const[ce,rt]of O)q.set(U1[ce]??ce,rt);return q},[$]),J=b.useMemo(()=>{var q;const O={};for(const[ce,rt]of z){const Ts=((q=rt.find(ep=>ep.capacity!==null))==null?void 0:q.capacity)??null,Xh=Ts===null||Ts>=d,Zh=Z1(rt,e,r,v);O[ce]=Zh&&Xh?"free":"busy"}return O},[z,e,r,v,d]),xe=g?z.get(g)??[]:[],Me=((gt=xe.find(O=>O.capacity!==null))==null?void 0:gt.capacity)??null,un=b.useCallback(O=>{p(q=>q===O?null:O)},[]);return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Room Availability"}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end gap-3 mb-6",children:[i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Date"}),i.jsx("input",{type:"date",className:"input input-bordered input-sm w-full sm:w-auto",value:e,onChange:O=>t(O.target.value),onClick:O=>{var q,ce;return(ce=(q=O.target).showPicker)==null?void 0:ce.call(q)}})]}),i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Start time"}),i.jsx("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:r,onChange:O=>w(zs(O.target.value)),children:gd.map(O=>i.jsx("option",{value:O,children:Xn(O)},O))})]}),i.jsxs("div",{className:"form-control w-full sm:w-auto",children:[i.jsxs("div",{className:"join mb-1",children:[i.jsx("button",{type:"button",className:`join-item btn btn-xs px-3 font-mono text-[0.6rem] uppercase tracking-[0.1em] ${l==="duration"?"btn-primary":"btn-ghost opacity-40"}`,onClick:()=>y("duration"),children:"Duration"}),i.jsx("button",{type:"button",className:`join-item btn btn-xs px-3 font-mono text-[0.6rem] uppercase tracking-[0.1em] ${l==="endtime"?"btn-primary":"btn-ghost opacity-40"}`,onClick:()=>y("endtime"),children:"End time"})]}),l==="duration"?i.jsx("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:a,onChange:O=>{const q=Number(O.target.value);o(q),s(ce=>vl(ce,q))},children:pd.map(O=>i.jsx("option",{value:O,children:X1(O)},O))}):i.jsxs("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:u===vt?"24:00":na(u),onChange:O=>{const q=O.target.value;x(q==="24:00"?vt:zs(q))},children:[gd.filter(O=>zs(O)>n).map(O=>i.jsx("option",{value:O,children:Xn(O)},O)),i.jsx("option",{value:"24:00",children:"End of day"},"eod")]})]}),i.jsxs("label",{className:"form-control w-full sm:w-24",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"People"}),i.jsx("input",{type:"number",min:1,className:"input input-bordered input-sm w-full sm:w-24",value:d,onFocus:O=>O.target.select(),onChange:O=>f(Math.max(1,Number(O.target.value)||1))})]}),i.jsx("button",{className:"btn btn-primary btn-sm w-full sm:w-auto",onClick:R,disabled:L,children:L?"Checking floor...":"Check floor plan"})]}),i.jsxs("div",{className:"mb-6",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1 block",children:"Drag to pick a time · bar width = duration"}),i.jsx(eb,{startMinutes:n,durationMinutes:v,onChange:O=>{s(O),l==="endtime"&&m(Math.min(vt,O+v))}})]}),L&&!G&&i.jsx(ht,{label:"Checking all rooms on the floor plan (this drives Outlook UI and can take a few minutes)..."}),G&&i.jsxs("div",{className:"alert alert-warning mb-4",children:[i.jsx("span",{children:"This connector requires approval before proceeding."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>I(!0),disabled:!E,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>I(!1),disabled:!E,children:"Reject"})]})]}),A&&i.jsx(Tn,{message:"Sign in to Microsoft Teams in Chrome, then try again."}),H&&!A&&i.jsx("div",{className:"alert alert-error mb-4",children:i.jsx("span",{children:H})}),k&&i.jsxs("div",{className:"flex items-center gap-2 mb-4 font-mono text-xs opacity-50",children:[S&&i.jsx("span",{className:"badge badge-sm badge-outline",children:"cached"}),i.jsxs("span",{children:["Last fetched ",new Date(k).toLocaleString()]})]}),!F&&!h&&!L&&!H&&i.jsxs("div",{className:"border border-base-300 p-8 text-center mb-8",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"Pick a date, time, duration and party size, then check the floor plan"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"Rooms that are free and big enough will show green; everything else red."})]}),i.jsxs("div",{className:"mt-2",children:[i.jsxs("h3",{className:"font-display text-base font-semibold mb-3",children:["Floor plan · ",Xn(r),"–",Xn((()=>{const[O,q]=r.split(":").map(Number),ce=(O*60+q+v)%(24*60);return`${String(Math.floor(ce/60)).padStart(2,"0")}:${String(ce%60).padStart(2,"0")}`})())," · ",xd(e)," · ",d," ",d===1?"person":"people"]}),i.jsx(Q1,{statuses:J,selected:g??void 0,onSelect:un})]}),g&&xe.length>0&&i.jsxs("div",{className:"mt-8",children:[i.jsxs("h3",{className:"font-display text-base font-semibold mb-3",children:[g,Me!==null&&i.jsxs("span",{className:"ml-2 font-mono text-xs font-normal opacity-50 uppercase tracking-[0.08em]",children:["Capacity ",Me]})," ","· ",xd(e)]}),i.jsx(V1,{rows:xe})]}),g&&xe.length===0&&i.jsx("div",{className:"mt-8 border border-base-300 p-6 text-center",children:i.jsxs("p",{className:"text-sm opacity-50",children:["No data for ",g,' yet — run "Check floor plan" first.']})})]})}function nb({data:e}){const{timetracking:t,meetings:n,jira:s,git:r}=e,a=t?Math.min(100,Math.round(t.totalHours/t.targetHours*100)):0,o=t&&t.totalHours<t.targetHours*.8,l=(s==null?void 0:s.blockers.length)??0,c=(r==null?void 0:r.repos.length)??0;return i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 border border-base-300",children:[i.jsxs("div",{className:"p-3 border-r border-b border-base-300 md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Hours Logged"}),i.jsx("div",{className:`font-display text-xl font-bold ${o?"text-warning":"text-success"}`,children:t?`${t.totalHours}h`:"—"}),i.jsxs("div",{className:"text-xs opacity-40",children:["/ ",(t==null?void 0:t.targetHours)??40,"h target"]}),t&&i.jsx("progress",{className:`progress ${o?"progress-warning":"progress-success"} w-full mt-1`,value:a,max:100})]}),i.jsxs("div",{className:"p-3 border-b border-base-300 md:border-r md:border-b-0",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Meetings"}),i.jsx("div",{className:`font-display text-xl font-bold ${n&&n.totalHours>20?"text-warning":"text-info"}`,children:n?String(n.totalCount):"—"}),i.jsx("div",{className:"text-xs opacity-40",children:n?`${n.totalHours}h · avg ${n.avgDurationMin}min`:""})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Tickets Done"}),i.jsx("div",{className:"font-display text-xl font-bold text-accent",children:s?String(s.resolved.length):"—"}),i.jsx("div",{className:"text-xs opacity-40",children:s?i.jsxs(i.Fragment,{children:[s.inProgress.length," in progress",l>0&&i.jsxs("span",{className:"text-error font-semibold ml-1",children:["· ",l," blocked"]})]}):""})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Commits"}),i.jsx("div",{className:"font-display text-xl font-bold text-primary",children:r?String(r.totalCommits):"—"}),i.jsx("div",{className:"text-xs opacity-40",children:r?`${r.totalPRsMerged} PRs · ${c} repo${c!==1?"s":""}`:""})]})]})}const sb=["Mon","Tue","Wed","Thu","Fri"];function rb(e){const t=new Date(e).getDay();return sb[t-1]??e}function ib({data:e}){const{timetracking:t,meetings:n,git:s,jira:r}=e,a=new Set;t==null||t.daily.forEach(f=>a.add(f.date)),n==null||n.daily.forEach(f=>a.add(f.date)),s==null||s.daily.forEach(f=>a.add(f.date));const o=[...a].sort().filter(f=>{const v=new Date(f+"T00:00:00").getDay();return v===0||v===6?(t==null?void 0:t.daily.some(x=>x.date===f&&x.hours>0))||(n==null?void 0:n.daily.some(x=>x.date===f&&x.count>0))||(s==null?void 0:s.daily.some(x=>x.date===f&&x.commits>0)):!0}),l=(t==null?void 0:t.totalHours)??0,c=(n==null?void 0:n.totalCount)??0,u=(n==null?void 0:n.totalHours)??0,m=(s==null?void 0:s.totalCommits)??0,d=(r==null?void 0:r.resolved.length)??0;return o.length===0?i.jsx("div",{className:"text-base-content/60",children:"No daily data available."}):i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"font-mono text-[0.6rem] uppercase tracking-[0.1em] opacity-50",children:[i.jsx("th",{children:"Day"}),i.jsx("th",{children:"Date"}),i.jsx("th",{children:"Hours Logged"}),i.jsx("th",{children:"Meetings"}),i.jsx("th",{children:"Commits"}),i.jsx("th",{children:"Tickets"})]})}),i.jsx("tbody",{children:o.map(f=>{const v=t==null?void 0:t.daily.find(p=>p.date===f),y=n==null?void 0:n.daily.find(p=>p.date===f),x=s==null?void 0:s.daily.find(p=>p.date===f),w=t==null?void 0:t.gaps.includes(f),g=(r==null?void 0:r.resolved.filter(p=>p.resolvedDate===f))??[];return i.jsxs("tr",{className:w?"bg-warning/10":"",children:[i.jsx("td",{className:"font-medium",children:rb(f)}),i.jsx("td",{className:"text-xs text-base-content/60",children:f}),i.jsxs("td",{children:[i.jsx("span",{className:w?"text-warning font-semibold":"",children:v?`${v.hours}h`:"—"}),w&&i.jsx("span",{className:"ml-1 text-warning text-xs",children:"⚠"})]}),i.jsx("td",{children:y?`${y.count} (${y.hours}h)`:"—"}),i.jsx("td",{children:x?`${x.commits}`:"0"}),i.jsx("td",{className:"text-xs",children:g.length>0?g.map(p=>p.key).join(", "):"—"})]},f)})}),i.jsx("tfoot",{children:i.jsxs("tr",{className:"font-semibold border-t border-base-300",children:[i.jsx("td",{colSpan:2,children:"Total"}),i.jsx("td",{children:l>0?`${l}h`:"—"}),i.jsx("td",{children:c>0?`${c} (${u}h)`:"—"}),i.jsx("td",{children:m}),i.jsx("td",{className:"text-xs",children:d>0?`${d} done`:"—"})]})})]})})}function ab({insights:e,errors:t}){return i.jsxs("div",{className:"space-y-3",children:[e.length>0&&i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsx("p",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em] mb-2",children:"Insights"}),i.jsx("ul",{className:"list-disc list-inside space-y-1 text-sm",children:e.map((n,s)=>i.jsx("li",{children:n},s))})]}),t.length>0&&i.jsx("div",{className:"alert alert-warning text-sm",children:i.jsxs("div",{children:[i.jsx("p",{className:"font-semibold",children:"Some data sources had issues:"}),i.jsx("ul",{className:"list-disc list-inside mt-1",children:t.map((n,s)=>i.jsx("li",{children:n},s))})]})})]})}function Jh(e){const t=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),s=String(e.getDate()).padStart(2,"0");return`${t}-${n}-${s}`}function ob(){const e=new Date;return e.setDate(e.getDate()-e.getDay()),Jh(e)}function jd(e,t){const n=new Date(e+"T00:00:00");return n.setDate(n.getDate()+t*7),Jh(n)}function lb(e){const t=new Date(e+"T00:00:00"),n=new Date(t);n.setDate(n.getDate()+6);const s=r=>r.toLocaleDateString("en-GB",{day:"numeric",month:"short"});return`${s(t)} – ${s(n)}, ${t.getFullYear()}`}function cb(){const[e,t]=b.useState(ob()),[n,s]=b.useState(!1),[r,a]=b.useState(null),[o,l]=b.useState(null),[c,u]=b.useState(null);async function m(){s(!0),l(null),a(null),u(null);const d=Date.now();try{const f=await B.generateJournal({weekStart:e});u(Date.now()-d),a(f)}catch(f){l(f instanceof Error?f.message:"Unknown error")}finally{s(!1)}}return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Dev Work Journal"}),i.jsxs("div",{className:"flex flex-wrap items-center gap-3 mb-6",children:[i.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>t(jd(e,-1)),disabled:n,children:"◄"}),i.jsx("span",{className:"font-medium text-lg",children:lb(e)}),i.jsx("button",{className:"btn btn-sm btn-ghost",onClick:()=>t(jd(e,1)),disabled:n,children:"►"}),i.jsx("button",{className:"btn btn-primary ml-4",onClick:m,disabled:n,children:n?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"loading loading-spinner loading-xs"}),"Generating…"]}):"Generate"}),c!==null&&!n&&i.jsxs("span",{className:"text-xs text-base-content/40 ml-2",children:["Generated in ",(c/1e3).toFixed(1),"s"]})]}),n&&i.jsxs("div",{className:"flex items-center gap-3 text-base-content/60 mb-4",children:[i.jsx("span",{className:"loading loading-spinner loading-md"}),i.jsx("span",{children:"Gathering data from Git, Outlook, Jira…"})]}),o&&i.jsx("div",{role:"alert",className:"alert alert-error mb-4",children:i.jsx("span",{children:o})}),(r==null?void 0:r.status)==="partial"&&i.jsx("div",{role:"alert",className:"alert alert-warning text-sm mb-4",children:i.jsxs("div",{children:[i.jsx("p",{className:"font-semibold",children:"Some data sources were unavailable. Results may be incomplete."}),i.jsx("ul",{className:"list-disc list-inside mt-1",children:r.errors.map((d,f)=>i.jsx("li",{children:d},f))})]})}),r&&r.status!=="error"&&i.jsxs("div",{className:"space-y-6",children:[i.jsxs("section",{className:"space-y-4",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Summary"}),i.jsx(nb,{data:r})]}),i.jsxs("section",{className:"space-y-4",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Daily Breakdown"}),i.jsx(ib,{data:r})]}),i.jsx("section",{className:"space-y-4",children:i.jsx(ab,{insights:r.insights,errors:r.errors})})]}),(r==null?void 0:r.status)==="error"&&i.jsx("div",{role:"alert",className:"alert alert-error mb-4",children:i.jsxs("span",{children:["Failed to generate journal. ",r.errors.join("; ")]})})]})}function ub(){const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function db(){const e=new Date;return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function fb(e){const[t,n]=e.split("-").map(Number);return new Date(t,n-1,1).toLocaleDateString("en-GB",{month:"long",year:"numeric"})}function mb(e){return new Date(e+"T00:00:00").toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})}function hb(e){const[t,n]=e.split("-").map(Number),s=new Date(t,n,0).getDate();let r=0;for(let a=1;a<=s;a++){const o=new Date(t,n-1,a).getDay();o!==0&&o!==6&&r++}return r}function pb(e,t){const n=db(),[s,r]=t.split("-").map(Number),a=new Date(n+"T00:00:00"),o=new Date(s,r,0).getDate(),l=[];for(let d=1;d<=o;d++){const f=new Date(s,r-1,d);if(f>a)break;const v=f.getDay();v!==0&&v!==6&&l.push(`${s}-${String(r).padStart(2,"0")}-${String(d).padStart(2,"0")}`)}const c=new Set(e.filter(d=>d.date&&d.status&&/released/i.test(String(d.status))).map(d=>d.date)),u=l.filter(d=>c.has(d)),m=l.filter(d=>!c.has(d));return{workingDaysTotal:hb(t),workingDaysElapsed:l.length,releasedDates:u,unreleasedDates:m}}function gb(e){return e.isOverdue?"badge badge-error badge-sm":typeof e.daysUntilDue=="number"&&e.daysUntilDue<=7?"badge badge-warning badge-sm":typeof e.daysUntilDue=="number"&&e.daysUntilDue<=30?"badge badge-info badge-sm":"badge badge-ghost badge-sm"}function yb(e){return e.isOverdue?"Overdue":e.daysUntilDue==null||e.daysUntilDue===9999?"No deadline":e.daysUntilDue===0?"Due today":e.daysUntilDue===1?"Due tomorrow":`${e.daysUntilDue}d left`}function xb(){const[e]=b.useState(ub()),[t,n]=b.useState([]),s=Sr(),r=Sr();function a(){s.reset(),r.reset(),n([]),s.run("timetracking/report",{month:e}),r.run("saba/pending-training",{}),B.getGoals(e).then(y=>n(y.goals)).catch(()=>{})}const o=b.useMemo(()=>{var y;return((y=s.result)==null?void 0:y.data)??null},[s.result]),l=b.useMemo(()=>o?pb(o,e):null,[o,e]),c=b.useMemo(()=>{const y=new Map;if(o)for(const x of o){const w=typeof x.projectId=="string"?x.projectId:null,g=typeof x.hours=="number"?x.hours:0;w&&y.set(w,(y.get(w)??0)+g)}return y},[o]),u=b.useMemo(()=>{var y;return((y=r.result)==null?void 0:y.data)??[]},[r.result]),m=typeof r.error=="string"&&(r.error.toLowerCase().includes("auth_required")||r.error.toLowerCase().includes("sign in")),d=typeof s.error=="string"&&(s.error.toLowerCase().includes("auth_required")||s.error.toLowerCase().includes("sign in")),f=s.running||r.running,v=s.result!==null||r.result!==null;return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsxs("div",{className:"flex items-center justify-between mb-5",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em]",children:"Daily Check-in"}),i.jsx("p",{className:"text-sm opacity-40 mt-0.5",children:fb(e)})]}),i.jsx("button",{className:"btn btn-primary btn-sm",onClick:a,disabled:f,children:f?"Loading…":v?"Refresh":"Load"})]}),f&&!s.approvalPending&&!r.approvalPending&&i.jsx("div",{className:"mb-4",children:i.jsx(ht,{label:"Fetching time tracking and Saba training…"})}),i.jsxs("section",{className:"space-y-4 mb-6",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Time Tracking"}),s.approvalPending&&i.jsxs("div",{className:"alert alert-warning",children:[i.jsx("span",{children:"Time tracking requires approval."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>s.handleApproval(!0),disabled:!s.approvalId,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>s.handleApproval(!1),disabled:!s.approvalId,children:"Reject"})]})]}),d&&i.jsx(Tn,{message:"Sign in to the timetracking portal in Chrome, then try again."}),s.error&&!d&&i.jsx("div",{className:"alert alert-error text-sm",children:i.jsx("span",{children:s.error})}),l&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-4 border border-base-300",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Working days"}),i.jsx("div",{className:"font-display text-xl font-bold",children:l.workingDaysTotal}),i.jsx("div",{className:"text-xs opacity-40",children:"in month"})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Elapsed"}),i.jsx("div",{className:"font-display text-xl font-bold",children:l.workingDaysElapsed}),i.jsx("div",{className:"text-xs opacity-40",children:"so far"})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Released"}),i.jsx("div",{className:"font-display text-xl font-bold text-success",children:l.releasedDates.length}),i.jsx("div",{className:"text-xs opacity-40",children:"days"})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Unreleased"}),i.jsx("div",{className:`font-display text-xl font-bold ${l.unreleasedDates.length>0?"text-error":"text-success"}`,children:l.unreleasedDates.length}),i.jsx("div",{className:"text-xs opacity-40",children:"to action"})]})]}),l.unreleasedDates.length>0&&i.jsxs("div",{className:"border border-base-300 p-4 space-y-2",children:[i.jsx("p",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Unreleased dates"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:l.unreleasedDates.map(y=>i.jsx("span",{className:"badge badge-error badge-outline badge-sm",children:mb(y)},y))})]}),l.unreleasedDates.length===0&&i.jsx("div",{className:"border border-base-300 p-4 text-center",children:i.jsx("p",{className:"text-sm text-success font-medium",children:"All days released ✓"})})]}),l&&t.length>0&&i.jsxs("div",{className:"border border-base-300 p-4 space-y-3",children:[i.jsx("p",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Goals Progress"}),i.jsx("div",{className:"space-y-3",children:t.map(y=>{const x=Math.round((c.get(y.projectId)??0)*100)/100,w=Math.round((y.targetHours-x)*100)/100,g=Math.min(100,Math.round(x/y.targetHours*100)),p=w<=0;return i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between text-sm",children:[i.jsx("span",{className:"font-medium",children:y.projectId}),i.jsx("span",{className:`font-mono text-xs ${p?"text-success":"text-warning"}`,children:p?"✓ Goal met":`${w}h to go`})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("progress",{className:`progress flex-1 ${p?"progress-success":"progress-warning"}`,value:g,max:100}),i.jsxs("span",{className:"font-mono text-xs opacity-50 w-24 text-right",children:[x,"h / ",y.targetHours,"h"]})]})]},y.id)})})]}),o===null&&!s.error&&!s.running&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm opacity-40",children:"Click Load to check your time tracking status."}),i.jsx("p",{className:"font-mono text-xs opacity-25 mt-1",children:"Drives your browser — sign in to the portal first."})]})]}),i.jsxs("section",{className:"space-y-4",children:[i.jsx("h3",{className:"font-mono text-[0.65rem] font-medium opacity-50 uppercase tracking-[0.12em]",children:"Pending Training (Saba)"}),r.approvalPending&&i.jsxs("div",{className:"alert alert-warning",children:[i.jsx("span",{children:"This connector requires approval before proceeding."}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("button",{className:"btn btn-sm btn-success",onClick:()=>r.handleApproval(!0),disabled:!r.approvalId,children:"Approve"}),i.jsx("button",{className:"btn btn-sm btn-error",onClick:()=>r.handleApproval(!1),disabled:!r.approvalId,children:"Reject"})]})]}),m&&i.jsx(Tn,{message:"Sign in to Saba Cloud (daimler.sabacloud.com) in Chrome, then try again."}),r.error&&!m&&i.jsx("div",{className:"alert alert-error text-sm font-mono whitespace-pre-wrap",children:i.jsx("span",{children:r.error})}),r.result&&u.length>0&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"grid grid-cols-3 border border-base-300",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Pending"}),i.jsx("div",{className:"font-display text-xl font-bold",children:u.length})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Overdue"}),i.jsx("div",{className:`font-display text-xl font-bold ${u.filter(y=>y.isOverdue).length>0?"text-error":""}`,children:u.filter(y=>y.isOverdue).length})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Due ≤ 30d"}),i.jsx("div",{className:`font-display text-xl font-bold ${u.filter(y=>!y.isOverdue&&typeof y.daysUntilDue=="number"&&y.daysUntilDue<=30).length>0?"text-warning":""}`,children:u.filter(y=>!y.isOverdue&&typeof y.daysUntilDue=="number"&&y.daysUntilDue<=30).length})]})]}),i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"font-mono text-[0.6rem] uppercase tracking-[0.1em] opacity-50",children:[i.jsx("th",{children:"Course"}),i.jsx("th",{children:"Type"}),i.jsx("th",{children:"Status"}),i.jsx("th",{children:"Due"}),i.jsx("th",{children:"Urgency"})]})}),i.jsx("tbody",{children:u.map((y,x)=>i.jsxs("tr",{className:"hover",children:[i.jsx("td",{className:`font-medium text-sm ${y.isOverdue?"text-error":""}`,children:y.title??"—"}),i.jsx("td",{className:"font-mono text-xs opacity-60",children:y.type??"—"}),i.jsx("td",{className:"text-xs opacity-70",children:y.status??"—"}),i.jsx("td",{className:"font-mono text-xs",children:y.dueDate||"—"}),i.jsx("td",{children:i.jsx("span",{className:gb(y),children:yb(y)})})]},x))})]})})]}),r.result&&u.length===0&&!r.error&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm text-success font-medium",children:"No pending training ✓"}),i.jsx("p",{className:"font-mono text-xs opacity-30 mt-0.5",children:"You're all caught up."})]}),!r.result&&!r.error&&!r.running&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm opacity-40",children:"Click Load to fetch your pending Saba training."}),i.jsx("p",{className:"font-mono text-xs opacity-25 mt-1",children:"Requires an active Saba Cloud session in Chrome."})]})]})]})}const vb={socket:"info",wiz:"secondary",tldrsec:"warning"},bb={socket:"SOCKET",wiz:"WIZ",tldrsec:"TLDR SEC"};function jb(e,t){try{const n=new Date(e);if(isNaN(n.getTime()))return!1;const s=Date.now()-t*24*60*60*1e3;return n.getTime()>=s}catch{return!1}}function wb(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const s=new Date().getTime()-t.getTime(),r=Math.floor(s/36e5);if(r<1)return"just now";if(r<24)return`${r}h ago`;const a=Math.floor(r/24);return a===1?"yesterday":a<7?`${a}d ago`:t.toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return e}}function kb(e){return(e.data??[]).map(t=>({title:String(t.title??""),summary:String(t.summary??""),url:String(t.url??""),date:String(t.date??""),source:"socket",author:String(t.author??""),tags:String(t.tags??"")}))}function Nb(e){return(e.data??[]).map(t=>({title:String(t.title??""),summary:String(t.excerpt??""),url:String(t.url??""),date:String(t.publishedAt??""),source:"wiz",author:String(t.authors??""),tags:String(t.tags??"")}))}function Sb(e){return(e.data??[]).map(t=>({title:String(t.title??""),summary:String(t.excerpt??""),url:String(t.url??""),date:String(t.publishedAt??""),source:"tldrsec",author:String(t.authors??""),tags:String(t.tags??"")}))}const wd={7:"Past 7 days",30:"Past 30 days"};function Cb(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Eb(){const[e,t]=b.useState(7),[n,s]=b.useState("idle"),[r,a]=b.useState("idle"),[o,l]=b.useState("idle"),[c,u]=b.useState([]),[m,d]=b.useState([]),[f,v]=b.useState([]),[y,x]=b.useState(null),[w,g]=b.useState(null),[p,h]=b.useState(null),[j,k]=b.useState(null),[C,S]=b.useState(!1);b.useEffect(()=>{let E=!1;return B.getCachedSecurityNews().then(D=>{if(!E&&D.data&&D.data.length>0){if(s(_=>_==="loading"?(E=!0,_):"done"),E)return;const I=[],R=[],A=[];for(const _ of D.data){const $=_;$.source==="wiz"?R.push($):$.source==="tldrsec"?A.push($):I.push($)}u(I),d(R),v(A),k(D.fetchedAt),S(!0),a("done"),l("done")}}).catch(()=>{}),()=>{E=!0}},[]);const N=n==="loading"||r==="loading"||o==="loading",T=c.length>0||m.length>0||f.length>0,L=b.useMemo(()=>[...c,...m,...f].filter(D=>jb(D.date,e)).sort((D,I)=>new Date(I.date).getTime()-new Date(D.date).getTime()),[c,m,f,e]),F=b.useMemo(()=>{const E=L.filter(R=>R.source==="socket").length,D=L.filter(R=>R.source==="wiz").length,I=L.filter(R=>R.source==="tldrsec").length;return{total:L.length,socketCount:E,wizCount:D,tldrsecCount:I}},[L]),H=b.useCallback(async()=>{s("loading"),a("loading"),l("loading"),x(null),g(null),h(null),u([]),d([]),v([]),S(!1);let E=[],D=[],I=[];const R=B.run("socket/security-news",{}).then(z=>{!z.ok&&z.error?(x(z.error),s("error")):(E=kb(z),u(E),s("done"))}).catch(z=>{x(z instanceof Error?z.message:"Failed to fetch"),s("error")}),A=B.run("wiz/blog-security",{}).then(z=>{!z.ok&&z.error?(g(z.error),a("error")):(D=Nb(z),d(D),a("done"))}).catch(z=>{g(z instanceof Error?z.message:"Failed to fetch"),a("error")}),_=B.run("tldrsec/newsletter",{}).then(z=>{!z.ok&&z.error?(h(z.error),l("error")):(I=Sb(z),v(I),l("done"))}).catch(z=>{h(z instanceof Error?z.message:"Failed to fetch"),l("error")});await Promise.allSettled([R,A,_]);const $=[...E,...D,...I];if($.length>0){const z=new Date().toISOString();k(z),B.cacheSecurityNews($).catch(()=>{})}},[]),G=E=>(E==null?void 0:E.includes("auth_required"))||(E==null?void 0:E.includes("sign in"));return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Security News"}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end gap-3 mb-6",children:[i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Range"}),i.jsxs("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:e,onChange:E=>t(Number(E.target.value)),children:[i.jsx("option",{value:7,children:"Past 7 days"}),i.jsx("option",{value:30,children:"Past 30 days"})]})]}),i.jsx("button",{className:"btn btn-primary btn-sm w-full sm:w-auto",onClick:H,disabled:N,children:N?"Loading...":"Load news"}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(mo,{label:"Socket",status:n}),i.jsx(mo,{label:"Wiz",status:r}),i.jsx(mo,{label:"tl;dr sec",status:o})]})]}),N&&i.jsx(ht,{label:"Fetching security news..."}),y&&(G(y)?i.jsx(Tn,{message:"Sign in to Socket.dev in Chrome, then try again."}):i.jsx("div",{className:"alert alert-error mb-3",children:i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold",children:"Socket:"})," ",y]})})),w&&(G(w)?i.jsx(Tn,{message:"Sign in to Wiz in Chrome, then try again."}):i.jsx("div",{className:"alert alert-error mb-3",children:i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold",children:"Wiz:"})," ",w]})})),p&&i.jsx("div",{className:"alert alert-error mb-3",children:i.jsxs("span",{children:[i.jsx("span",{className:"font-semibold",children:"tl;dr sec:"})," ",p]})}),j&&!N&&i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-2",children:[C?"Showing cached data from":"Last fetched"," ",Cb(j)]}),T&&!N&&i.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 border border-base-300 mb-6",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:wd[e]}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.total})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Socket"}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.socketCount})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Wiz"}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.wizCount})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"tl;dr sec"}),i.jsx("div",{className:"font-display text-xl font-bold",children:F.tldrsecCount})]})]}),L.length>0&&i.jsx("div",{className:"space-y-px",children:L.map((E,D)=>i.jsxs("article",{className:"border border-base-300 p-4",children:[i.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[i.jsx("a",{href:E.url,target:"_blank",rel:"noopener noreferrer",className:"text-sm font-semibold hover:text-primary transition-colors leading-snug",children:E.title}),i.jsx(W,{variant:vb[E.source]??"neutral",size:"xs",children:bb[E.source]??E.source.toUpperCase()})]}),E.summary&&i.jsx("p",{className:"text-sm opacity-60 leading-relaxed mb-2 line-clamp-2",children:E.summary}),i.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[i.jsx("span",{className:"font-mono text-[0.6rem] opacity-40",children:wb(E.date)}),E.author&&i.jsx("span",{className:"font-mono text-[0.6rem] opacity-40",children:E.author}),E.tags&&i.jsx("div",{className:"flex gap-1 flex-wrap",children:E.tags.split(",").slice(0,3).map(I=>i.jsx(W,{variant:"neutral",size:"xs",children:I.trim()},I.trim()))})]})]},`${E.source}-${D}`))}),T&&L.length===0&&!N&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsxs("p",{className:"text-sm opacity-50 mb-1",children:["No news from the ",wd[e].toLowerCase()]}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"All sources returned data, but nothing within the date window."})]}),!T&&!N&&!y&&!w&&!p&&i.jsxs("div",{className:"border border-base-300 p-8 text-center",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"Security news from Socket, Wiz, and tl;dr sec"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"Select a range and press Load news to fetch the latest posts."})]})]})}function mo({label:e,status:t}){const n={idle:"opacity-30",loading:"bg-warning animate-pulse",done:"bg-success",error:"bg-error"}[t];return i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("span",{className:`w-1.5 h-1.5 ${n}`,"aria-hidden":"true"}),i.jsx("span",{className:"font-mono text-[0.6rem] opacity-50 uppercase",children:e})]})}function ci(e){if(!e)return null;try{const t=new Date(e);if(isNaN(t.getTime()))return null;const n=new Date;return n.setHours(0,0,0,0),t.setHours(0,0,0,0),Math.ceil((t.getTime()-n.getTime())/(24*60*60*1e3))}catch{return null}}function kd(e){return e===null?"none":e<0?"expired":e<=7?"critical":e<=30?"warning":"ok"}function Tb(e,t){switch(e){case"expired":return i.jsx(W,{variant:"error",size:"xs",children:"EXPIRED"});case"critical":return i.jsxs(W,{variant:"error",size:"xs",children:[t,"d LEFT"]});case"warning":return i.jsxs(W,{variant:"warning",size:"xs",children:[t,"d LEFT"]});case"ok":return i.jsxs(W,{variant:"success",size:"xs",children:[t,"d LEFT"]});case"none":return i.jsx(W,{variant:"neutral",size:"xs",children:"NO EXPIRY"});default:return null}}function Ab(e){if(!e)return"—";try{const t=new Date(e);return isNaN(t.getTime())?e:t.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}catch{return e}}function Lb(e){switch(e){case"expired":return"bg-red-500/5";case"critical":return"bg-red-500/5";case"warning":return"bg-amber-500/5";default:return""}}function Pb(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const s=Math.floor(n/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function Ib(){const[e,t]=b.useState("idle"),[n,s]=b.useState(""),[r,a]=b.useState([]),[o,l]=b.useState(null),[c,u]=b.useState("all"),[m,d]=b.useState(null),[f,v]=b.useState(!1),y=e==="clients"||e==="trustedby";b.useEffect(()=>{let j=!1;return B.getCachedTrustedPeers().then(k=>{if(!j&&k.data&&k.data.length>0){if(t(S=>S==="clients"||S==="trustedby"?(j=!0,S):"done"),j)return;const C=k.data;a(C),d(k.fetchedAt),v(!0),s(`Loaded ${C.length} trusted peers from cache.`)}}).catch(()=>{}),()=>{j=!0}},[]);const x=b.useCallback(async()=>{t("clients"),l(null),a([]),v(!1),s("Fetching client list (all regions)...");try{const j=await B.run("tokenmaster/clients-list",{region:"all"});if(!j.ok&&j.error){l(j.error),t("error");return}const k=(j.data??[]).map(N=>({id:String(N.id??""),name:String(N.name??""),region:String(N.region??"emea")}));if(k.length===0){s("No clients found."),t("done");return}t("trustedby");const C=[],S=k.length;for(let N=0;N<k.length;N++){const T=k[N];s(`Fetching trusted peers... (${N+1}/${S}) — ${T.name||T.id}`);try{const L=await B.run("tokenmaster/client-trustedby",{clientid:T.id,region:T.region});if(L.ok&&L.data)for(const F of L.data)C.push({parentClientId:T.id,parentClientName:T.name||T.id,peerId:String(F.id??""),peerName:String(F.name??""),peerIdDisplay:String(F.idDisplay??""),expiryDate:F.expiry_date?String(F.expiry_date):null,region:String(F.region??T.region)})}catch{}}if(a(C),s(`Loaded ${C.length} trusted peers from ${S} clients.`),t("done"),C.length>0){const N=new Date().toISOString();d(N),B.cacheTrustedPeers(C).catch(()=>{})}}catch(j){l(j instanceof Error?j.message:"Unknown error"),t("error")}},[]),w=b.useMemo(()=>[...c==="all"?r:r.filter(k=>k.region===c)].sort((k,C)=>{const S=ci(k.expiryDate),N=ci(C.expiryDate);return S===null&&N===null?0:S===null?1:N===null?-1:S-N}),[r,c]),g=b.useMemo(()=>{let j=0,k=0,C=0;for(const S of w){const N=kd(ci(S.expiryDate));N==="expired"?j++:N==="critical"?k++:N==="warning"&&C++}return{total:w.length,expired:j,critical:k,warning:C}},[w]),p=b.useMemo(()=>{const j=new Set(r.map(k=>k.region));return Array.from(j).sort()},[r]),h=j=>(j==null?void 0:j.includes("auth_required"))||(j==null?void 0:j.includes("sign in"));return i.jsxs("div",{className:"max-w-5xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-5",children:"Trusted Peer Expiry"}),m&&!y&&i.jsxs("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-3",children:[f?"Showing cached data from":"Last fetched"," ",Pb(m)]}),i.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end gap-3 mb-6",children:[i.jsxs("label",{className:"form-control w-full sm:w-auto",children:[i.jsx("span",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Region"}),i.jsxs("select",{className:"select select-bordered select-sm w-full sm:w-auto",value:c,onChange:j=>u(j.target.value),children:[i.jsx("option",{value:"all",children:"All regions"}),p.map(j=>i.jsx("option",{value:j,children:j.toUpperCase()},j))]})]}),i.jsx("button",{className:"btn btn-primary btn-sm w-full sm:w-auto",onClick:x,disabled:y,children:y?"Loading...":"Load trusted peers"})]}),y&&i.jsx(ht,{label:n}),o&&(h(o)?i.jsx(Tn,{message:"Sign in to TokenMaster in Chrome, then try again."}):i.jsx("div",{className:"alert alert-error mb-3",children:i.jsx("span",{children:o})})),r.length>0&&!y&&i.jsxs("div",{className:"grid grid-cols-4 border border-base-300 mb-6",children:[i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Total"}),i.jsx("div",{className:"font-display text-xl font-bold",children:g.total})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"Expired"}),i.jsx("div",{className:`font-display text-xl font-bold ${g.expired>0?"text-red-500":""}`,children:g.expired})]}),i.jsxs("div",{className:"p-3 border-r border-base-300",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"≤ 7 days"}),i.jsx("div",{className:`font-display text-xl font-bold ${g.critical>0?"text-red-500":""}`,children:g.critical})]}),i.jsxs("div",{className:"p-3",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em] mb-1",children:"≤ 30 days"}),i.jsx("div",{className:`font-display text-xl font-bold ${g.warning>0?"text-amber-500":""}`,children:g.warning})]})]}),w.length>0&&i.jsx("div",{className:"border border-base-300 overflow-x-auto",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-base-300",children:[i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Status"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Expiry Date"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Days Left"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Trusted Peer"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Peer ID"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Parent Client"}),i.jsx("th",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.1em]",children:"Region"})]})}),i.jsx("tbody",{children:w.map((j,k)=>{const C=ci(j.expiryDate),S=kd(C);return i.jsxs("tr",{className:`border-b border-base-300/50 ${Lb(S)}`,children:[i.jsx("td",{children:Tb(S,C)}),i.jsx("td",{className:"font-mono text-sm",children:Ab(j.expiryDate)}),i.jsx("td",{className:"font-mono text-sm",children:C!==null?C<0?`${Math.abs(C)}d overdue`:`${C}d`:"—"}),i.jsx("td",{className:"text-sm font-semibold",children:j.peerName||j.peerId}),i.jsx("td",{className:"font-mono text-xs opacity-60",children:j.peerIdDisplay||j.peerId}),i.jsx("td",{className:"text-sm",children:j.parentClientName}),i.jsx("td",{children:i.jsx(W,{variant:"neutral",size:"xs",children:j.region.toUpperCase()})})]},`${j.parentClientId}-${j.peerId}-${j.region}-${k}`)})})]})}),e==="done"&&!y&&r.length>0&&i.jsx("div",{className:"mt-1 font-mono text-xs opacity-40",children:n}),e==="done"&&r.length===0&&!y&&i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"No trusted peers found"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"No clients returned from TokenMaster, or no trustedby relationships exist."})]}),e==="idle"&&i.jsxs("div",{className:"border border-base-300 p-8 text-center",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"TokenMaster trusted peer expiry monitor"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:'Press "Load trusted peers" to fetch all clients and their trusted peer expiry dates across all regions.'})]})]})}const Ob={client:"border-sky-500/50 bg-sky-500/10 text-sky-700 dark:text-sky-400",daemon:"border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-400",extension:"border-emerald-500/50 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",browser:"border-violet-500/50 bg-violet-500/10 text-violet-700 dark:text-violet-400"},_b={client:"bg-sky-400/20",daemon:"bg-amber-400/20",extension:"bg-emerald-400/20",browser:"bg-violet-400/20"};function bl({flow:e}){const{lanes:t,steps:n,title:s}=e,r=t.length,a=`repeat(${r}, 1fr)`;return i.jsxs("div",{className:"border border-base-300 p-4 overflow-x-auto",children:[i.jsx("h4",{className:"font-semibold text-sm mb-3",children:s}),i.jsxs("div",{style:{minWidth:r*130},children:[i.jsx("div",{className:"grid",style:{gridTemplateColumns:a},children:t.map(o=>i.jsx("div",{className:"flex justify-center",children:i.jsx("span",{className:`px-2 py-1 text-[0.65rem] font-mono font-semibold border ${Ob[o.color]}`,children:o.label})},o.id))}),i.jsxs("div",{className:"relative py-1",children:[i.jsx("div",{className:"absolute inset-0 grid pointer-events-none",style:{gridTemplateColumns:a},children:t.map(o=>i.jsx("div",{className:"flex justify-center",children:i.jsx("div",{className:`w-0.5 h-full ${_b[o.color]}`})},o.id))}),i.jsx("div",{className:"relative",children:n.map((o,l)=>{if(o.type==="action"){const w=(t.findIndex(g=>g.id===o.lane)+.5)/r*100;return i.jsx("div",{className:"relative",style:{height:26},children:i.jsx("div",{className:"absolute top-1/2 -translate-x-1/2 -translate-y-1/2 z-10",style:{left:`${w}%`},children:i.jsx("span",{className:"block px-2 py-0.5 text-[0.6rem] font-mono bg-base-200/90 border border-base-300/60 text-base-content/60 whitespace-nowrap",children:o.label})})},l)}const c=t.findIndex(x=>x.id===o.from),u=t.findIndex(x=>x.id===o.to),m=(c+.5)/r*100,d=(u+.5)/r*100,f=Math.min(m,d),v=Math.abs(d-m),y=c<u;return i.jsxs("div",{className:"relative",style:{height:30},children:[i.jsx("div",{className:"absolute top-1/2 h-px bg-base-content/20",style:{left:`${f}%`,width:`${v}%`}}),i.jsx("div",{className:"absolute top-1/2 w-1.5 h-1.5 rounded-full bg-base-content/30 -translate-x-1/2 -translate-y-1/2",style:{left:`${m}%`}}),i.jsx("div",{className:"absolute top-1/2 -translate-y-1/2 text-[0.55rem] leading-none text-base-content/40",style:{left:`${d}%`,transform:`translate(${y?"-100%":"0"}, -50%)`},children:y?"▸":"◂"}),i.jsx("div",{className:"absolute top-1/2 -translate-x-1/2 -translate-y-1/2 z-10",style:{left:`${(m+d)/2}%`},children:i.jsx("span",{className:"px-1.5 py-px text-[0.6rem] font-mono bg-base-100 text-base-content/60 whitespace-nowrap",children:o.label})})]},l)})})]})]})]})}const Mb=[{name:"CLI Client",tech:"Node.js / Commander.js",port:null,desc:"Terminal interface. Sends commands to the Daemon over HTTP, formats output as table / JSON / CSV.",pkg:"@commandgarden/cli"},{name:"GUI",tech:"React SPA / Vite / Tailwind / DaisyUI",port:null,desc:"Browser-based interface. Talks to the App Server — never to the Daemon directly.",pkg:null},{name:"App Server",tech:"Fastify / SQLite",port:"9092",desc:"GUI backend. Proxies Daemon calls, enriches responses, and owns app-specific state (preferences, cached reports, goals).",pkg:"@commandgarden/app"},{name:"Daemon",tech:"Fastify / WebSocket / SQLite",port:"9091",desc:"Core service. Validates auth and capabilities, loads connectors, relays pipelines to the Chrome Extension, writes audit log.",pkg:"@commandgarden/daemon"},{name:"Chrome Extension",tech:"MV3 / TypeScript / Service Worker",port:null,desc:"Runs connector pipelines inside browser tabs via content scripts and CDP. Connects to the Daemon via WebSocket.",pkg:null}],Db=[{name:"Audit Log",tech:"SQLite",path:"~/.commandgarden/audit.db",desc:"Every command execution, denial, auth failure, and config change."},{name:"App DB",tech:"SQLite",path:"~/.commandgarden/app.db",desc:"Preferences, cached reports, goals, and saved views."},{name:"Config",tech:"YAML",path:"~/.commandgarden/config.yaml",desc:"Daemon + security + connector + audit settings."},{name:"Session Token",tech:"File",path:"~/.commandgarden/session-token",desc:"Bearer token generated on daemon start. CLI and App Server read it for auth."}],$b=[{title:"Command execution (CLI path)",lanes:[{id:"cli",label:"CLI",color:"client"},{id:"daemon",label:"Daemon :9091",color:"daemon"},{id:"ext",label:"Extension",color:"extension"},{id:"browser",label:"Browser Tab",color:"browser"}],steps:[{type:"arrow",from:"cli",to:"daemon",label:"POST /api/run (HTTP)"},{type:"action",lane:"daemon",label:"validate token + CSRF"},{type:"action",lane:"daemon",label:"check connector, domains, capabilities"},{type:"action",lane:"daemon",label:"audit: command.start"},{type:"action",lane:"daemon",label:"split pipeline (extension vs daemon steps)"},{type:"arrow",from:"daemon",to:"ext",label:"relay extension steps (WS)"},{type:"arrow",from:"ext",to:"browser",label:"execute pipeline steps"},{type:"arrow",from:"browser",to:"ext",label:"page data"},{type:"arrow",from:"ext",to:"daemon",label:"results (WS)"},{type:"action",lane:"daemon",label:"run daemon-side steps (transform, map)"},{type:"action",lane:"daemon",label:"audit: command.success / error"},{type:"arrow",from:"daemon",to:"cli",label:"structured data response"}]},{title:"Command execution (GUI path)",lanes:[{id:"gui",label:"GUI",color:"client"},{id:"app",label:"App Server :9092",color:"daemon"},{id:"daemon",label:"Daemon :9091",color:"daemon"}],steps:[{type:"arrow",from:"gui",to:"app",label:"POST /api/run (HTTP)"},{type:"arrow",from:"app",to:"daemon",label:"proxy to daemon (HTTP)"},{type:"action",lane:"daemon",label:"validate, execute, audit (same as CLI path)"},{type:"arrow",from:"daemon",to:"app",label:"structured data"},{type:"arrow",from:"app",to:"gui",label:"enriched response"}]},{title:"Step approval flow",lanes:[{id:"client",label:"CLI / GUI",color:"client"},{id:"daemon",label:"Daemon",color:"daemon"},{id:"ext",label:"Extension",color:"extension"}],steps:[{type:"action",lane:"daemon",label:"detect approval-required capability"},{type:"arrow",from:"daemon",to:"client",label:"HTTP 202 + requestId"},{type:"arrow",from:"daemon",to:"client",label:"approval prompt (SSE)"},{type:"arrow",from:"daemon",to:"ext",label:"approval notification (WS)"},{type:"arrow",from:"client",to:"daemon",label:"POST /api/approval"},{type:"arrow",from:"ext",to:"daemon",label:"resolve via WS"},{type:"action",lane:"daemon",label:"first responder wins → continue or abort"},{type:"action",lane:"daemon",label:"audit: approval.granted / rejected"}]},{title:"Extension connection",lanes:[{id:"ext",label:"Extension",color:"extension"},{id:"daemon",label:"Daemon",color:"daemon"}],steps:[{type:"arrow",from:"ext",to:"daemon",label:"WS connect :9091"},{type:"action",lane:"daemon",label:"validate origin"},{type:"action",lane:"daemon",label:"attach WS relay"},{type:"action",lane:"ext",label:"ready for commands"},{type:"arrow",from:"ext",to:"daemon",label:"heartbeat"}]}],Rb=[{name:"shared",desc:"Connector schema (Zod), protocol messages, audit events, expression parser, pipeline definitions",published:!1},{name:"daemon",desc:"HTTP + WebSocket server, auth, connector registry, capability validation, audit store, WebSocket relay",published:!1},{name:"cli",desc:"CLI client (Commander.js) — run, list, inspect, validate, daemon/gui management, audit queries, config",published:!0},{name:"chrome",desc:"Chrome MV3 extension — service worker, content scripts, domain guard, pipeline step execution engine",published:!1},{name:"app",desc:"Web GUI — Fastify app server + React SPA (Vite, Tailwind, DaisyUI)",published:!1},{name:"connectors",desc:"Built-in YAML connector definitions",published:!1}];function zb(){return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-1",children:"Architecture"}),i.jsx("p",{className:"text-sm opacity-60 mb-6",children:"How commandGarden's components fit together."}),i.jsx("div",{id:"arch-diagram",className:"border border-base-300 p-5 mb-8 overflow-x-auto scroll-mt-4",children:i.jsxs("svg",{viewBox:"0 0 780 300",className:"w-full text-base-content",style:{minWidth:620},children:[i.jsxs("defs",{children:[i.jsx("marker",{id:"arch-ah",viewBox:"0 0 10 8",refX:"10",refY:"4",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("path",{d:"M0 0L10 4L0 8z",fill:"currentColor",fillOpacity:.5})}),i.jsx("marker",{id:"arch-ah-rev",viewBox:"0 0 10 8",refX:"0",refY:"4",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("path",{d:"M10 0L0 4L10 8z",fill:"currentColor",fillOpacity:.5})})]}),i.jsx("rect",{x:15,y:8,width:120,height:50,rx:3,fill:"rgba(56,189,248,0.15)",stroke:"rgba(56,189,248,0.6)",strokeWidth:1}),i.jsx("text",{x:75,y:29,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"CLI Client"}),i.jsx("text",{x:75,y:44,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Node.js"}),i.jsx("rect",{x:15,y:120,width:120,height:50,rx:3,fill:"rgba(56,189,248,0.15)",stroke:"rgba(56,189,248,0.6)",strokeWidth:1}),i.jsx("text",{x:75,y:141,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"GUI"}),i.jsx("text",{x:75,y:156,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"React SPA"}),i.jsx("rect",{x:190,y:120,width:145,height:50,rx:3,fill:"rgba(251,191,36,0.15)",stroke:"rgba(251,191,36,0.6)",strokeWidth:1}),i.jsx("text",{x:262,y:141,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"App Server"}),i.jsx("text",{x:262,y:156,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Fastify :9092"}),i.jsx("rect",{x:395,y:10,width:160,height:84,rx:3,fill:"rgba(251,191,36,0.15)",stroke:"rgba(251,191,36,0.7)",strokeWidth:1.5}),i.jsx("text",{x:475,y:38,textAnchor:"middle",fill:"currentColor",fontSize:13,fontWeight:700,children:"Daemon"}),i.jsx("text",{x:475,y:56,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Fastify :9091"}),i.jsx("text",{x:475,y:78,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"auth · registry · audit"}),i.jsx("rect",{x:615,y:20,width:150,height:60,rx:3,fill:"rgba(52,211,153,0.15)",stroke:"rgba(52,211,153,0.6)",strokeWidth:1}),i.jsx("text",{x:690,y:44,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"Extension"}),i.jsx("text",{x:690,y:62,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Chrome MV3"}),i.jsx("rect",{x:630,y:200,width:130,height:50,rx:3,fill:"rgba(167,139,250,0.15)",stroke:"rgba(167,139,250,0.6)",strokeWidth:1}),i.jsx("text",{x:695,y:221,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"Browser Tab"}),i.jsx("text",{x:695,y:237,textAnchor:"middle",fill:"currentColor",fontSize:9,opacity:.6,fontFamily:"ui-monospace,monospace",children:"target page"}),i.jsx("rect",{x:195,y:240,width:100,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:245,y:257,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"App DB"}),i.jsx("text",{x:245,y:269,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"SQLite"}),i.jsx("rect",{x:390,y:200,width:105,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:442,y:217,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"Audit Log"}),i.jsx("text",{x:442,y:229,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"SQLite"}),i.jsx("rect",{x:500,y:200,width:85,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:542,y:217,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"Config"}),i.jsx("text",{x:542,y:229,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"YAML"}),i.jsx("rect",{x:75,y:200,width:105,height:36,rx:3,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:127,y:217,textAnchor:"middle",fill:"currentColor",fontSize:9,fontWeight:500,opacity:.65,children:"Session Token"}),i.jsx("text",{x:127,y:229,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.45,fontFamily:"ui-monospace,monospace",children:"file"}),i.jsx("line",{x1:137,y1:33,x2:393,y2:45,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("text",{x:255,y:28,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"HTTP :9091"}),i.jsx("line",{x1:137,y1:145,x2:188,y2:145,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("line",{x1:337,y1:138,x2:393,y2:78,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("text",{x:354,y:97,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"proxy"}),i.jsx("line",{x1:557,y1:50,x2:613,y2:50,stroke:"currentColor",strokeOpacity:.4,strokeWidth:1.5,markerEnd:"url(#arch-ah)",markerStart:"url(#arch-ah-rev)"}),i.jsx("text",{x:585,y:40,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"WebSocket"}),i.jsx("line",{x1:695,y1:82,x2:695,y2:198,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#arch-ah)"}),i.jsx("text",{x:720,y:132,fill:"currentColor",fontSize:8,opacity:.55,fontFamily:"ui-monospace,monospace",children:"Content"}),i.jsx("text",{x:720,y:144,fill:"currentColor",fontSize:8,opacity:.55,fontFamily:"ui-monospace,monospace",children:"Scripts"}),i.jsx("text",{x:720,y:160,fill:"currentColor",fontSize:8,opacity:.55,fontFamily:"ui-monospace,monospace",children:"+ CDP"}),i.jsx("line",{x1:245,y1:172,x2:245,y2:238,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:442,y1:96,x2:442,y2:198,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:520,y1:96,x2:542,y2:198,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:75,y1:60,x2:110,y2:198,stroke:"currentColor",strokeOpacity:.18,strokeDasharray:"3 2"}),i.jsx("line",{x1:200,y1:172,x2:155,y2:198,stroke:"currentColor",strokeOpacity:.18,strokeDasharray:"3 2"})]})}),i.jsx("h3",{id:"arch-components",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Components"}),i.jsx("div",{className:"space-y-2 mb-8",children:Mb.map(e=>i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsxs("div",{className:"flex items-center gap-3 flex-wrap mb-1",children:[i.jsx("span",{className:"font-semibold",children:e.name}),i.jsx(W,{size:"xs",children:e.tech}),e.port&&i.jsxs(W,{variant:"info",size:"xs",children:[":",e.port]}),e.pkg&&i.jsx(W,{variant:"secondary",size:"xs",children:e.pkg})]}),i.jsx("p",{className:"text-sm opacity-60",children:e.desc})]},e.name))}),i.jsx("h3",{id:"arch-stores",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Data Stores"}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-8",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{children:"Store"}),i.jsx("th",{children:"Format"}),i.jsx("th",{children:"Path"}),i.jsx("th",{children:"Purpose"})]})}),i.jsx("tbody",{children:Db.map(e=>i.jsxs("tr",{className:"hover:bg-base-200",children:[i.jsx("td",{className:"font-semibold text-sm",children:e.name}),i.jsx("td",{children:i.jsx(W,{size:"xs",children:e.tech})}),i.jsx("td",{className:"font-mono text-xs opacity-60",children:e.path}),i.jsx("td",{className:"text-sm opacity-60",children:e.desc})]},e.name))})]})}),i.jsx("h3",{id:"arch-flows",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Data Flows"}),i.jsxs("p",{className:"text-sm opacity-60 mb-4",children:["For a plain-language walkthrough of these same flows, see"," ",i.jsxs(we,{to:"/concepts",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Concepts ",i.jsx(qe,{className:"w-3 h-3"})]}),"."]}),i.jsx("div",{className:"space-y-4 mb-8",children:$b.map(e=>i.jsx(bl,{flow:e},e.title))}),i.jsx("h3",{id:"arch-security",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Security Model"}),i.jsx("div",{className:"border border-base-300 p-4 mb-8",children:i.jsxs("ul",{className:"space-y-2",children:[i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Session token"})," — generated on daemon start, stored at ~/.commandgarden/session-token. Every API call (except /api/status) requires Bearer auth + X-CommandGarden CSRF header."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Domain guard"})," — connector YAML declares allowed domains. Extension refuses to run on undeclared domains."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Capability gating"})," — each pipeline step requires a declared capability. High-risk capabilities (js_evaluate, cookie_write) require explicit approval."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Audit-or-fail"})," — if the audit store is unavailable, commands are blocked."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"No credentials stored"})," — commandGarden reuses existing Chrome sessions. No passwords or cookies are persisted."]}),i.jsxs("li",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold opacity-100",children:"Localhost only"})," — daemon and app server bind to 127.0.0.1 by default."]})]})}),i.jsx("h3",{id:"arch-packages",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Workspace Packages"}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-8",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{children:"Package"}),i.jsx("th",{children:"Description"}),i.jsx("th",{children:"Published"})]})}),i.jsx("tbody",{children:Rb.map(e=>i.jsxs("tr",{className:"hover:bg-base-200",children:[i.jsx("td",{className:"font-mono text-sm font-semibold",children:e.name}),i.jsx("td",{className:"text-sm opacity-60",children:e.desc}),i.jsx("td",{children:e.published?i.jsx(W,{variant:"success",size:"xs",children:"npm"}):i.jsx(W,{size:"xs",children:"bundled"})})]},e.name))})]})}),i.jsx("h3",{id:"arch-build",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Build Order"}),i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsx("div",{className:"flex flex-wrap items-center gap-2 font-mono text-sm",children:["shared","daemon","cli","chrome","app"].map((e,t)=>i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"px-2 py-1 border border-base-300 bg-base-200",children:e}),t<4&&i.jsx("span",{className:"opacity-40",children:"→"})]},e))}),i.jsxs("p",{className:"text-sm opacity-60 mt-2",children:["Run ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"npm run build"})," from the commandGarden root to build all packages in dependency order."]})]})]})}const Fb={GET:"success",POST:"warning",PUT:"info",DELETE:"error",WS:"secondary",SSE:"secondary"},Bb=[{method:"GET",path:"/api/status",auth:!1,desc:"Health check. Returns daemon status, extension connection, and connector count."},{method:"GET",path:"/api/connectors",auth:!0,desc:"List all loaded connectors with key, description, access, domains, and capabilities."},{method:"GET",path:"/api/connectors/:site/:name",auth:!0,desc:"Full connector definition including pipeline, args, and columns.",params:"site, name — connector key segments"},{method:"POST",path:"/api/run",auth:!0,desc:"Execute a connector pipeline. Returns structured data. Returns 202 with requestId if step approval is required.",body:"{ connector: string, args: Record<string, string> }"},{method:"GET",path:"/api/audit",auth:!0,desc:"List audit events with optional filters.",params:"since?, connector?, type?, limit?"},{method:"GET",path:"/api/audit/:id",auth:!0,desc:"Single audit event with full detail including pipeline steps."},{method:"GET",path:"/api/config",auth:!0,desc:"Read the full config.yaml as JSON."},{method:"POST",path:"/api/config",auth:!0,desc:"Set a config value. Key must be section.property format.",body:"{ key: string, value: string }"},{method:"POST",path:"/api/approval",auth:!0,desc:"Resolve a pending step approval.",body:"{ approvalId: string, approved: boolean }"},{method:"SSE",path:"/api/run/events/:requestId",auth:!0,desc:"Server-Sent Events stream for approval-required runs. Sends approval and result events."},{method:"WS",path:"/ws/extension",auth:!1,desc:"WebSocket endpoint for Chrome Extension. Origin validated against security.extensionId."}],Ub=[{method:"GET",path:"/api/status",auth:!1,desc:"Proxied daemon status (same as daemon /api/status)."},{method:"GET",path:"/api/connectors",auth:!1,desc:"Enriched connector list with hasAppPage, appRoute, isHighRisk, isApproved, isAutoApproved."},{method:"GET",path:"/api/connectors/:site/:name",auth:!1,desc:"Proxied connector detail."},{method:"POST",path:"/api/run",auth:!1,desc:"Proxied connector execution."},{method:"GET",path:"/api/audit",auth:!1,desc:"Proxied audit event list."},{method:"GET",path:"/api/audit/:id",auth:!1,desc:"Proxied single audit event."},{method:"GET",path:"/api/config",auth:!1,desc:"Proxied config read."},{method:"POST",path:"/api/config",auth:!1,desc:"Proxied config write."},{method:"POST",path:"/api/approval",auth:!1,desc:"Proxied approval resolution."},{method:"GET",path:"/api/preferences",auth:!1,desc:"Read app preferences (SQLite-backed).",response:"{ ok, preferences }"},{method:"PUT",path:"/api/preferences",auth:!1,desc:"Set an app preference.",body:"{ key: string, value: string }"},{method:"GET",path:"/api/goals",auth:!1,desc:"Read goals for a month.",params:"month (YYYY-MM)"},{method:"POST",path:"/api/goals",auth:!1,desc:"Create or update a goal.",body:"{ month, projectId, activity, targetDays }"},{method:"DELETE",path:"/api/goals/:id",auth:!1,desc:"Delete a goal."},{method:"GET",path:"/api/timetracking/cache",auth:!1,desc:"Get cached timetracking report for a month.",params:"month (YYYY-MM)"},{method:"POST",path:"/api/timetracking/cache",auth:!1,desc:"Store timetracking report in cache.",body:"{ month, data }"},{method:"GET",path:"/api/timetracking/projects",auth:!1,desc:"Get cached project/activity list."},{method:"POST",path:"/api/timetracking/projects",auth:!1,desc:"Store project/activity list in cache.",body:"{ data }"},{method:"POST",path:"/api/journal/generate",auth:!1,desc:"Generate a dev journal for a given week.",body:"{ weekStart: string }"},{method:"GET",path:"/api/security-news/cache",auth:!1,desc:"Get cached security news articles."},{method:"POST",path:"/api/security-news/cache",auth:!1,desc:"Store security news in cache.",body:"{ data }"}],Wb=[{cmd:"cg up",desc:"Start daemon + GUI, open browser.",opts:["--no-open Skip opening browser"]},{cmd:"cg down",desc:"Stop GUI + daemon."},{cmd:"cg run <connector>",desc:"Run a connector command.",args:"Connector key (site/name), plus connector-specific args as --key value",opts:["-f, --format <format> Output format: table, json, csv (default: table)"],example:"cg run timetracking/report --month 2026-07 --format json"},{cmd:"cg list",desc:"List all installed connectors with access, domains, and capabilities."},{cmd:"cg inspect <connector>",desc:"Show full details of a connector (args, columns, pipeline).",example:"cg inspect teams/room-availability"},{cmd:"cg validate <file>",desc:"Validate a connector YAML file against the schema.",example:"cg validate connectors/my-connector.yaml"},{cmd:"cg daemon status",desc:"Check if the daemon is running."},{cmd:"cg daemon start",desc:"Start the daemon in background."},{cmd:"cg daemon stop",desc:"Stop the daemon."},{cmd:"cg gui",desc:"Start the GUI app server (foreground by default).",opts:["-b, --background Run in background","--no-open Skip opening browser"]},{cmd:"cg gui stop",desc:"Stop the GUI app server."},{cmd:"cg gui status",desc:"Check if the GUI is running."},{cmd:"cg audit list",desc:"List recent audit events.",opts:["--since <duration> Time window (e.g. 7d, 2w, 12h)","--connector <pattern> Filter by connector (e.g. test/*)","--type <pattern> Filter by event type (e.g. auth.failed)","--limit <n> Max events (default: 100)"]},{cmd:"cg audit show <id>",desc:"Show full details of a single audit event including pipeline steps."},{cmd:"cg audit export",desc:"Export audit events.",opts:["--format <format> Export format: json, csv (default: json)","--since <duration> Time window","--connector <pattern> Filter","--type <pattern> Filter"]},{cmd:"cg config show",desc:"Show current config.yaml contents."},{cmd:"cg config set <key> <value>",desc:"Set a config value (section.property format).",example:"cg config set daemon.port 9999"},{cmd:"cg extension setup",desc:"Show extension path and instructions for Chrome installation."}],Hb=[{step:"navigate",capability:"navigate",desc:"Open a URL in the browser tab"},{step:"wait",capability:"navigate",desc:"Wait for a selector or timeout"},{step:"extract",capability:"dom_read",desc:"Read data from DOM elements"},{step:"extract_tree",capability:"dom_read",desc:"Recursive DOM tree walk with ancestry"},{step:"extract_html",capability:"dom_read",desc:"Capture element HTML as a variable"},{step:"click",capability:"dom_write",desc:"Click an element"},{step:"click_all",capability:"dom_write",desc:"Click all matching elements (with re-scan loop)"},{step:"type",capability:"dom_write",desc:"Type text into an input"},{step:"intercept",capability:"intercept_response",desc:"Capture a network response body"},{step:"cookie",capability:"cookie_read",desc:"Read cookies for a domain"},{step:"fetch",capability:"cookie_read",desc:"HTTP request from page context"},{step:"map",capability:"—",desc:"Transform/rename extracted fields"},{step:"filter",capability:"—",desc:"Filter rows by condition"},{step:"set",capability:"—",desc:"Set a variable for later steps"},{step:"transform",capability:"—",desc:"Server-side data transform (e.g. HTML→Markdown)"}];function Nd({ep:e}){const[t,n]=b.useState(!1),s=e.params||e.body||e.response;return i.jsxs("div",{className:"border-b border-base-300/50 last:border-b-0",children:[i.jsxs("button",{className:`flex items-center gap-3 w-full text-left px-3 py-2.5 ${s?"cursor-pointer hover:bg-base-200/50":""}`,onClick:()=>s&&n(!t),disabled:!s,children:[i.jsx(W,{variant:Fb[e.method]??"neutral",size:"xs",className:"w-10 justify-center shrink-0",children:e.method}),i.jsx("span",{className:"font-mono text-sm flex-1",children:e.path}),e.auth&&i.jsx(W,{variant:"warning",size:"xs",children:"auth"}),s&&i.jsx("span",{className:"text-xs opacity-40",children:t?"▾":"▸"})]}),i.jsx("div",{className:"px-3 pb-2 pl-16 text-sm opacity-60",children:e.desc}),t&&s&&i.jsxs("div",{className:"px-3 pb-3 pl-16 space-y-1.5",children:[e.params&&i.jsxs("div",{className:"text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Params: "}),i.jsx("span",{className:"font-mono opacity-60",children:e.params})]}),e.body&&i.jsxs("div",{className:"text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Body: "}),i.jsx("code",{className:"font-mono bg-base-200 px-1 py-0.5 opacity-70",children:e.body})]}),e.response&&i.jsxs("div",{className:"text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Response: "}),i.jsx("code",{className:"font-mono bg-base-200 px-1 py-0.5 opacity-70",children:e.response})]})]})]})}function Vb(){const[e,t]=b.useState("cli");return i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-1",children:"API & CLI Reference"}),i.jsx("p",{className:"text-sm opacity-60 mb-6",children:"CLI commands, Daemon API endpoints, and App Server endpoints."}),i.jsx("div",{id:"api-endpoints",className:"border border-base-300 bg-base-200/30 p-3 mb-6 scroll-mt-4",children:i.jsxs("p",{className:"text-sm opacity-70",children:[i.jsx("span",{className:"font-semibold",children:"Authentication:"})," Daemon endpoints (except ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"/api/status"})," and ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"/ws/extension"}),") require an ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"Authorization: Bearer <token>"})," header and an ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"X-CommandGarden: 1"})," CSRF header. The App Server handles auth internally — GUI requests don't need tokens."]})}),i.jsx("div",{className:"flex border-b border-base-300 mb-4",children:[{id:"cli",label:"CLI Commands",sub:"cg"},{id:"daemon-api",label:"Daemon API",sub:":9091"},{id:"app-api",label:"App Server API",sub:":9092"}].map(n=>i.jsxs("button",{className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${e===n.id?"border-primary text-primary":"border-transparent opacity-60 hover:opacity-100"}`,onClick:()=>t(n.id),children:[n.label," ",i.jsx("span",{className:"font-mono text-xs opacity-40 ml-1",children:n.sub})]},n.id))}),e==="cli"&&i.jsx("div",{className:"space-y-2 mb-8",children:Wb.map(n=>i.jsxs("div",{className:"border border-base-300 p-3",children:[i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("code",{className:"font-mono text-sm font-semibold bg-base-200 px-2 py-0.5 shrink-0",children:n.cmd}),i.jsx("span",{className:"text-sm opacity-60 pt-0.5",children:n.desc})]}),n.args&&i.jsxs("div",{className:"mt-2 ml-1 text-xs",children:[i.jsx("span",{className:"font-semibold opacity-50",children:"Args: "}),i.jsx("span",{className:"opacity-60",children:n.args})]}),n.opts&&n.opts.length>0&&i.jsx("div",{className:"mt-1.5 ml-1 space-y-0.5",children:n.opts.map((s,r)=>i.jsx("div",{className:"text-xs font-mono opacity-50",children:s},r))}),n.example&&i.jsx("div",{className:"mt-2 ml-1",children:i.jsx("code",{className:"text-xs font-mono bg-base-200/70 px-2 py-1 block opacity-60",children:n.example})})]},n.cmd))}),e==="daemon-api"&&i.jsx("div",{className:"border border-base-300 mb-8",children:Bb.map((n,s)=>i.jsx(Nd,{ep:n},s))}),e==="app-api"&&i.jsxs(i.Fragment,{children:[i.jsxs("p",{className:"text-sm opacity-50 mb-3",children:["The App Server on ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:":9092"})," proxies all daemon endpoints and adds app-specific routes for preferences, caching, goals, and journal generation."]}),i.jsx("div",{className:"border border-base-300 mb-8",children:Ub.map((n,s)=>i.jsx(Nd,{ep:n},s))})]}),i.jsx("h3",{id:"api-pipeline",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Pipeline Steps"}),i.jsxs("p",{className:"text-sm opacity-50 mb-3",children:["Available steps for connector YAML pipeline definitions. For why each capability runs where it does, see"," ",i.jsxs(we,{to:"/concepts#concepts-worlds",className:"text-primary hover:underline inline-flex items-center gap-1",children:["Capability & World Model ",i.jsx(qe,{className:"w-3 h-3"})]}),"."]}),i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-8",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{children:"Step"}),i.jsx("th",{children:"Capability"}),i.jsx("th",{children:"Description"})]})}),i.jsx("tbody",{children:Hb.map(n=>i.jsxs("tr",{className:"hover:bg-base-200",children:[i.jsx("td",{className:"font-mono text-sm font-semibold",children:n.step}),i.jsx("td",{children:i.jsx(W,{size:"xs",variant:n.capability==="—"?"neutral":"info",children:n.capability})}),i.jsx("td",{className:"text-sm opacity-60",children:n.desc})]},n.step))})]})}),i.jsx("h3",{id:"api-expressions",className:"font-display text-base font-semibold mb-3 scroll-mt-4",children:"Expression Syntax"}),i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsxs("p",{className:"text-sm opacity-60 mb-3",children:["Use ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"${{ }}"})," for template expressions (no JS eval):"]}),i.jsxs("div",{className:"space-y-1.5 font-mono text-xs",children:[i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Variable access"}),i.jsx("code",{className:"opacity-70",children:"args.month, vars.token, cookies.name"})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Row access (map)"}),i.jsx("code",{className:"opacity-70",children:"row.id, row.name"})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Concatenation"}),i.jsx("code",{className:"opacity-70",children:'"Bearer " + vars.token'})]}),i.jsxs("div",{className:"flex gap-3",children:[i.jsx("span",{className:"opacity-40 w-36 shrink-0",children:"Pipe filters"}),i.jsx("code",{className:"opacity-70",children:'args.month | default("2026-06"), value | number, text | trim'})]})]})]})]})}function Kb(e){const n=e.replace(/^---\s*\n[\s\S]*?\n---\s*\n/,"").split(`
408
408
  `),s=[];let r=null;for(const a of n){const o=a.match(/^(#{1,3})\s+(.+)/);o?(r&&s.push({heading:r.heading,body:r.lines.join(`
409
409
  `).trim()}),r={heading:o[2],lines:[]}):r?r.lines.push(a):a.trim()&&(r||(r={heading:"",lines:[]}),r.lines.push(a))}return r&&s.push({heading:r.heading,body:r.lines.join(`
410
410
  `).trim()}),s}function Gb({content:e}){return i.jsx("pre",{className:"text-sm font-mono whitespace-pre-wrap opacity-70 leading-relaxed overflow-x-auto",children:e})}function Sd({file:e,defaultOpen:t}){const[n,s]=b.useState(t??!1),r=b.useMemo(()=>Kb(e.content),[e.content]);return i.jsxs("div",{className:"border border-base-300/50",children:[i.jsxs("button",{className:"flex items-center gap-2 w-full text-left px-4 py-3 hover:bg-base-200/50 transition-colors",onClick:()=>s(!n),children:[i.jsx("span",{className:"text-xs opacity-50",children:n?"▾":"▸"}),i.jsx("span",{className:"font-mono text-sm font-semibold",children:e.name}),i.jsxs("span",{className:"text-xs opacity-40",children:[r.length," ",r.length===1?"section":"sections"]})]}),n&&i.jsx("div",{className:"px-4 pb-4 space-y-4",children:r.map((a,o)=>i.jsxs("div",{children:[a.heading&&i.jsx("h5",{className:"font-mono text-xs font-semibold uppercase tracking-[0.08em] opacity-50 mb-2",children:a.heading}),i.jsx(Gb,{content:a.body})]},o))})]})}function qb({skill:e}){const[t,n]=b.useState(!1),s=e.files.find(a=>a.name==="SKILL.md"),r=e.files.filter(a=>a.name!=="SKILL.md");return i.jsxs("div",{className:"border border-base-300",children:[i.jsx("div",{className:"p-4",children:i.jsxs("div",{className:"flex items-center justify-between gap-3",children:[i.jsxs("div",{className:"flex items-center gap-3 flex-wrap min-w-0",children:[i.jsx("span",{className:"font-mono text-base font-semibold",children:e.name}),i.jsxs(W,{size:"xs",children:[e.files.length," ",e.files.length===1?"file":"files"]})]}),i.jsx("button",{className:"btn btn-sm btn-ghost font-mono text-xs shrink-0",onClick:()=>n(!t),children:t?"Collapse":"View"})]})}),t&&i.jsxs("div",{className:"border-t border-base-300 p-4 space-y-3",children:[s&&i.jsx(Sd,{file:s,defaultOpen:!0}),r.map(a=>i.jsx(Sd,{file:a},a.name))]})]})}function Yb(){const[e,t]=b.useState([]),[n,s]=b.useState(!0),[r,a]=b.useState(null);return b.useEffect(()=>{B.getSkills().then(o=>t(o.skills)).catch(o=>a(o instanceof Error?o.message:"Failed to load skills")).finally(()=>s(!1))},[]),n?i.jsx(ht,{label:"Loading skills..."}):i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-1",children:"Skills"}),i.jsx("p",{className:"text-sm opacity-60 mb-5",children:"AI agent skills bundled with commandGarden. These teach coding assistants how to use cg and author connectors."}),r?i.jsxs("div",{className:"border border-error/30 p-4",children:[i.jsx("p",{className:"text-sm text-error font-semibold mb-1",children:"Failed to load skills"}),i.jsx("p",{className:"font-mono text-xs opacity-60",children:r})]}):e.length===0?i.jsxs("div",{className:"border border-base-300 p-6 text-center",children:[i.jsx("p",{className:"text-sm opacity-50 mb-1",children:"No skills found"}),i.jsx("p",{className:"font-mono text-xs opacity-30",children:"Skills should be located in the skills/ directory of the commandGarden package."})]}):i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"overflow-x-auto border border-base-300 mb-6",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{children:"Skill"}),i.jsx("th",{children:"Description"}),i.jsx("th",{children:"Files"})]})}),i.jsx("tbody",{children:e.map(o=>i.jsxs("tr",{className:"hover:bg-base-200",children:[i.jsx("td",{className:"font-mono text-sm font-semibold whitespace-nowrap",children:o.name}),i.jsx("td",{className:"text-sm opacity-60",children:o.description}),i.jsx("td",{className:"text-center",children:i.jsx(W,{size:"xs",children:o.files.length})})]},o.name))})]})}),i.jsx("h3",{className:"font-display text-base font-semibold mb-3",children:"Skill Details"}),i.jsx("div",{className:"space-y-3",children:e.map(o=>i.jsx(qb,{skill:o},o.name))}),i.jsxs("div",{className:"border border-base-300 p-4 mt-6",children:[i.jsx("h4",{className:"font-mono text-xs font-semibold uppercase tracking-[0.08em] opacity-50 mb-2",children:"Usage"}),i.jsxs("p",{className:"text-sm opacity-60 mb-2",children:["Copy a skill's ",i.jsx("code",{className:"font-mono text-xs bg-base-200 px-1 py-0.5",children:"SKILL.md"})," into your AI assistant's skill directory to teach it how to use commandGarden."]}),i.jsxs("div",{className:"font-mono text-xs opacity-40",children:[i.jsx("span",{children:"Windsurf: "}),i.jsx("code",{className:"bg-base-200 px-1 py-0.5",children:".windsurf/skills/"}),i.jsx("span",{className:"mx-2",children:"|"}),i.jsx("span",{children:"Claude: "}),i.jsx("code",{className:"bg-base-200 px-1 py-0.5",children:".claude/skills/"})]})]})]})]})}function dn({children:e}){return i.jsx("div",{className:"font-mono text-[0.6rem] font-medium opacity-40 uppercase tracking-[0.12em] mb-2",children:e})}function ui({children:e}){return i.jsx("pre",{className:"bg-base-200 border border-base-300 p-4 overflow-x-auto text-sm font-mono leading-relaxed",children:i.jsx("code",{children:e})})}const Qb={success:Oc,warning:Uh,error:Wh},Jb={success:"text-emerald-600 dark:text-emerald-400",warning:"text-amber-600 dark:text-amber-400",error:"text-red-600 dark:text-red-400"};function ho({label:e,status:t}){const n=Qb[t];return i.jsxs("span",{className:`inline-flex items-center gap-1.5 text-xs font-medium ${Jb[t]}`,children:[i.jsx(n,{className:"w-3.5 h-3.5 shrink-0"}),e]})}const Xb=[{label:"Return format",cg:{label:"Fixed schema",status:"success"},skills:{label:"Loose, varies",status:"warning"},mcp:{label:"Typed schema",status:"success"}},{label:"Parsing cost",cg:{label:"Zero tokens",status:"success"},skills:{label:"Tokens/call",status:"error"},mcp:{label:"Tool-call overhead",status:"warning"}},{label:"Auth handling",cg:{label:"Browser required",status:"warning"},skills:{label:"Agent navigates",status:"error"},mcp:{label:"Server-configured",status:"success"}},{label:"Processing",cg:{label:"Local only",status:"success"},skills:{label:"Cloud/agent",status:"warning"},mcp:{label:"Server-side",status:"warning"}},{label:"Privacy",cg:{label:"Stays on machine",status:"success"},skills:{label:"Through AI",status:"error"},mcp:{label:"Through server",status:"warning"}},{label:"Coverage",cg:{label:"Any website",status:"success"},skills:{label:"Any (expensive)",status:"warning"},mcp:{label:"Server-limited",status:"warning"}}];function Zb(){return i.jsxs("div",{className:"max-w-4xl mx-auto pb-20",children:[i.jsxs("section",{className:"pt-8 pb-16 border-b border-base-300",children:[i.jsx(dn,{children:"For engineers tired of copy-pasting from internal portals"}),i.jsx("h1",{className:"font-display text-3xl sm:text-4xl font-bold tracking-tight leading-tight mb-3",style:{textWrap:"balance"},children:"Turn any website into a CLI command."}),i.jsx("p",{className:"text-base sm:text-lg opacity-70 max-w-[65ch] mb-8 leading-relaxed",style:{textWrap:"pretty"},children:"commandGarden reuses your existing browser sessions to extract structured data from authenticated websites. You're already logged in — it just reads what's on screen."}),i.jsx("div",{className:"flex flex-wrap items-center gap-2 mb-8 font-mono text-xs",children:[{label:"cg run",color:"border-sky-500/50 bg-sky-500/10 text-sky-700 dark:text-sky-400"},{label:"Daemon",color:"border-amber-500/50 bg-amber-500/10 text-amber-700 dark:text-amber-400"},{label:"Chrome Extension",color:"border-emerald-500/50 bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"},{label:"Browser Tab",color:"border-violet-500/50 bg-violet-500/10 text-violet-700 dark:text-violet-400"},{label:"Structured JSON",color:"border-primary/50 bg-primary/10 text-primary"}].map((e,t)=>i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx("span",{className:`px-2.5 py-1 border font-semibold ${e.color}`,children:e.label}),t<4&&i.jsx("span",{className:"opacity-30",children:"→"})]},e.label))}),i.jsx(ui,{children:"npm install -g @commandgarden/cli"})]}),i.jsxs("section",{id:"why-problem",className:"py-16 border-b border-base-300 scroll-mt-4",children:[i.jsx(dn,{children:"Where the data actually lives"}),i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-8",children:"The Problem"}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 mb-12",children:[i.jsxs("div",{className:"border border-base-300 p-5",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(oi,{className:"w-4 h-4 text-primary"}),i.jsx("h3",{className:"font-display font-semibold text-sm",children:"Real-world data lives in browsers"})]}),i.jsx("p",{className:"text-sm opacity-70 leading-relaxed",children:"AI agents can't reach data inside enterprise tools and SaaS dashboards. These systems are where the work happens, but they're locked behind browser sessions."})]}),i.jsxs("div",{className:"border border-base-300 p-5",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Wh,{className:"w-4 h-4 text-error"}),i.jsx("h3",{className:"font-display font-semibold text-sm",children:"APIs are the exception"})]}),i.jsx("p",{className:"text-sm opacity-70 leading-relaxed",children:"Most sites don't provide APIs. When one exists, you need service accounts and OAuth flows before you see a single row of data. What's visible in the UI often has no programmatic equivalent."})]}),i.jsxs("div",{className:"border border-base-300 p-5",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Uh,{className:"w-4 h-4 text-warning"}),i.jsx("h3",{className:"font-display font-semibold text-sm",children:"Browser automation is expensive"})]}),i.jsx("p",{className:"text-sm opacity-70 leading-relaxed",children:"AI browser tools like Playwright burn tokens on every interaction just to understand what's on screen — even when the page layout hasn't changed."})]})]}),i.jsx("p",{className:"text-sm opacity-50 max-w-[65ch]",children:"Skills, MCP servers, and browser agents all re-parse page structure on every call. That parsing only needs to happen once."})]}),i.jsxs("section",{id:"why-solution",className:"py-16 border-b border-base-300 scroll-mt-4",children:[i.jsx(dn,{children:"How commandGarden works"}),i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-4",children:"The Solution"}),i.jsxs("p",{className:"text-sm opacity-70 max-w-[65ch] leading-relaxed mb-10",children:["commandGarden replaces ad-hoc browser automation with ",i.jsx("strong",{className:"text-base-content",children:"connectors"}),": pre-built recipes that know how to navigate a site and return structured JSON. The agent (or a human) runs one CLI command and gets back a fixed-schema response, instead of re-parsing the page from scratch."]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-4",children:[i.jsxs("div",{className:"border border-error/20 bg-error/[0.03] p-5",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium text-error/60 uppercase tracking-[0.12em] mb-4",children:"Without commandGarden"}),i.jsx("div",{className:"space-y-0",children:[{label:"Task received",note:"agent or human",struck:!1},{label:"Launch browser",note:"headless instance",struck:!0},{label:"Navigate + Wait",note:"auth redirects",struck:!0},{label:"Parse HTML",note:"tokens for structure",struck:!0},{label:"Extract Data",note:"tokens for content",struck:!0},{label:"Loose output",note:"varies per run",struck:!1}].map((e,t)=>i.jsxs("div",{children:[i.jsxs("div",{className:`flex items-center gap-2.5 ${e.struck?"opacity-40 line-through decoration-error/50":""}`,children:[i.jsx("span",{className:`w-5 h-5 border flex items-center justify-center font-mono text-[0.6rem] shrink-0 ${e.struck?"border-error/20 text-error/40":"border-error/30 bg-error/10 text-error/60"}`,children:t+1}),i.jsx("span",{className:"text-sm font-medium",children:e.label}),i.jsx("span",{className:"text-xs opacity-40 font-mono",children:e.note})]}),t<5&&i.jsx("div",{className:`ml-2.5 w-px h-2 ${e.struck?"bg-error/15":"bg-error/20"}`})]},t))})]}),i.jsxs("div",{className:"border border-primary/20 bg-primary/[0.03] p-5 flex flex-col",children:[i.jsx("div",{className:"font-mono text-[0.6rem] font-medium text-primary/60 uppercase tracking-[0.12em] mb-4",children:"With commandGarden"}),i.jsx("div",{className:"space-y-0",children:[{label:"Task received",note:"agent or human"},{label:"cg run site/command",note:"one CLI call",accent:!0},{label:"Structured JSON",note:"fixed schema"}].map((e,t)=>i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx("span",{className:"w-5 h-5 border border-primary/30 bg-primary/10 flex items-center justify-center font-mono text-[0.6rem] text-primary/60 shrink-0",children:t+1}),i.jsx("span",{className:`text-sm font-medium ${"accent"in e&&e.accent?"text-primary font-semibold":""}`,children:e.label}),i.jsx("span",{className:"text-xs opacity-40 font-mono",children:e.note})]}),t<2&&i.jsx("div",{className:"ml-2.5 w-px h-2 bg-primary/20"})]},t))})]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-14",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(W,{variant:"error",size:"xs",children:"thousands of tokens"}),i.jsx("span",{className:"text-xs opacity-50",children:"per interaction"})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(W,{variant:"success",size:"xs",children:"0 tokens"}),i.jsx("span",{className:"text-xs opacity-50",children:"parsing done locally"})]})]}),i.jsxs("div",{className:"space-y-8 mb-12",children:[i.jsxs("div",{className:"flex gap-4",children:[i.jsx(oi,{className:"w-5 h-5 shrink-0 mt-0.5 text-primary"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-display font-semibold mb-1",children:"Reuse your browser session"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[60ch] leading-relaxed",children:"A Chrome extension runs inside your already-authenticated browser. No separate login, no stored credentials."})]})]}),i.jsxs("div",{className:"flex gap-4",children:[i.jsx(fo,{className:"w-5 h-5 shrink-0 mt-0.5 text-primary"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-display font-semibold mb-1",children:"Fixed-format parsing, done locally"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[60ch] leading-relaxed",children:"Each connector defines a pipeline that produces the same output shape on every run. Parsing happens in the extension and daemon — nothing leaves your machine."})]})]}),i.jsxs("div",{className:"flex gap-4",children:[i.jsx(Ci,{className:"w-5 h-5 shrink-0 mt-0.5 text-primary"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-display font-semibold mb-1",children:"One CLI for humans and AI agents"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[60ch] leading-relaxed mb-3",children:"The same command works whether a human types it or an AI agent calls it via a skill. Same arguments, same JSON schema."}),i.jsx(ui,{children:"cg run timetracking/report --month 2026-06"})]})]})]}),i.jsx("h3",{className:"font-display font-semibold text-sm mb-3",children:"How it compares"}),i.jsx("div",{className:"overflow-x-auto border border-base-300",children:i.jsxs("table",{className:"table table-sm w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"bg-base-200",children:[i.jsx("th",{className:"sticky left-0 z-10 bg-base-200"}),i.jsx("th",{className:"bg-primary/10 border-x border-primary/20 text-primary",children:"commandGarden"}),i.jsx("th",{children:"AI Skills"}),i.jsx("th",{children:"MCP Servers"})]})}),i.jsx("tbody",{children:Xb.map(e=>i.jsxs("tr",{children:[i.jsx("td",{className:"sticky left-0 z-10 bg-base-100 font-mono text-xs font-medium border-r border-base-300",children:e.label}),i.jsx("td",{className:"bg-primary/5 border-x border-primary/20",children:i.jsx(ho,{...e.cg})}),i.jsx("td",{children:i.jsx(ho,{...e.skills})}),i.jsx("td",{children:i.jsx(ho,{...e.mcp})})]},e.label))})]})}),i.jsxs("p",{className:"text-sm opacity-50 mt-4 max-w-[65ch]",children:["Skills and MCP provide the integration layer; commandGarden does the extraction and parsing locally. The ",i.jsx("span",{className:"font-mono",children:"cg"})," skill lets AI agents call commandGarden commands directly."]})]}),i.jsx("section",{id:"why-architecture",className:"py-16 border-b border-base-300 bg-base-200/30 -mx-4 px-4 md:-mx-5 md:px-5 scroll-mt-4",children:i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx(dn,{children:"Five processes, all on localhost"}),i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-4",children:"Architecture"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[65ch] leading-relaxed mb-8",children:"All communication stays on localhost. Here's what each piece does."}),i.jsx("div",{className:"border border-base-300 bg-base-100 p-5 mb-8 overflow-x-auto",children:i.jsxs("svg",{viewBox:"0 0 700 260",className:"w-full text-base-content",style:{minWidth:560},children:[i.jsxs("defs",{children:[i.jsx("marker",{id:"why-ah",viewBox:"0 0 10 8",refX:"10",refY:"4",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("path",{d:"M0 0L10 4L0 8z",fill:"currentColor",fillOpacity:.5})}),i.jsx("marker",{id:"why-ah-rev",viewBox:"0 0 10 8",refX:"0",refY:"4",markerWidth:"7",markerHeight:"5",orient:"auto",children:i.jsx("path",{d:"M10 0L0 4L10 8z",fill:"currentColor",fillOpacity:.5})})]}),i.jsx("rect",{x:10,y:10,width:110,height:46,rx:0,fill:"rgba(56,189,248,0.15)",stroke:"rgba(56,189,248,0.6)",strokeWidth:1}),i.jsx("text",{x:65,y:30,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"CLI"}),i.jsx("text",{x:65,y:44,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"cg run ..."}),i.jsx("rect",{x:10,y:80,width:110,height:46,rx:0,fill:"rgba(56,189,248,0.15)",stroke:"rgba(56,189,248,0.6)",strokeWidth:1}),i.jsx("text",{x:65,y:100,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"GUI"}),i.jsx("text",{x:65,y:114,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"React SPA"}),i.jsx("rect",{x:160,y:80,width:120,height:46,rx:0,fill:"rgba(251,191,36,0.15)",stroke:"rgba(251,191,36,0.6)",strokeWidth:1}),i.jsx("text",{x:220,y:100,textAnchor:"middle",fill:"currentColor",fontSize:10,fontWeight:600,children:"App Server"}),i.jsx("text",{x:220,y:114,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:":9092"}),i.jsx("rect",{x:320,y:15,width:150,height:76,rx:0,fill:"rgba(251,191,36,0.15)",stroke:"rgba(251,191,36,0.7)",strokeWidth:1.5}),i.jsx("text",{x:395,y:40,textAnchor:"middle",fill:"currentColor",fontSize:13,fontWeight:700,children:"Daemon"}),i.jsx("text",{x:395,y:56,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Fastify :9091"}),i.jsx("text",{x:395,y:78,textAnchor:"middle",fill:"currentColor",fontSize:7,opacity:.45,fontFamily:"ui-monospace,monospace",children:"auth · registry · audit"}),i.jsx("rect",{x:520,y:20,width:130,height:55,rx:0,fill:"rgba(52,211,153,0.15)",stroke:"rgba(52,211,153,0.6)",strokeWidth:1}),i.jsx("text",{x:585,y:42,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"Extension"}),i.jsx("text",{x:585,y:58,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"Chrome MV3"}),i.jsx("rect",{x:530,y:160,width:120,height:46,rx:0,fill:"rgba(167,139,250,0.15)",stroke:"rgba(167,139,250,0.6)",strokeWidth:1}),i.jsx("text",{x:590,y:180,textAnchor:"middle",fill:"currentColor",fontSize:11,fontWeight:600,children:"Browser Tab"}),i.jsx("text",{x:590,y:194,textAnchor:"middle",fill:"currentColor",fontSize:8,opacity:.6,fontFamily:"ui-monospace,monospace",children:"target page"}),i.jsx("rect",{x:310,y:170,width:90,height:30,rx:0,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:355,y:188,textAnchor:"middle",fill:"currentColor",fontSize:8,fontWeight:500,opacity:.65,children:"Audit Log"}),i.jsx("rect",{x:410,y:170,width:80,height:30,rx:0,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:450,y:188,textAnchor:"middle",fill:"currentColor",fontSize:8,fontWeight:500,opacity:.65,children:"Config"}),i.jsx("rect",{x:160,y:170,width:90,height:30,rx:0,fill:"currentColor",fillOpacity:.08,stroke:"currentColor",strokeOpacity:.25,strokeWidth:1}),i.jsx("text",{x:205,y:188,textAnchor:"middle",fill:"currentColor",fontSize:8,fontWeight:500,opacity:.65,children:"App DB"}),i.jsx("line",{x1:122,y1:33,x2:318,y2:45,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#why-ah)"}),i.jsx("text",{x:210,y:28,textAnchor:"middle",fill:"currentColor",fontSize:7,opacity:.6,fontFamily:"ui-monospace,monospace",children:"HTTP"}),i.jsx("line",{x1:122,y1:103,x2:158,y2:103,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#why-ah)"}),i.jsx("line",{x1:282,y1:96,x2:318,y2:72,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#why-ah)"}),i.jsx("text",{x:295,y:76,textAnchor:"middle",fill:"currentColor",fontSize:7,opacity:.6,fontFamily:"ui-monospace,monospace",children:"proxy"}),i.jsx("line",{x1:472,y1:48,x2:518,y2:48,stroke:"currentColor",strokeOpacity:.4,strokeWidth:1.5,markerEnd:"url(#why-ah)",markerStart:"url(#why-ah-rev)"}),i.jsx("text",{x:495,y:38,textAnchor:"middle",fill:"currentColor",fontSize:7,opacity:.6,fontFamily:"ui-monospace,monospace",children:"WebSocket"}),i.jsx("line",{x1:590,y1:77,x2:590,y2:158,stroke:"currentColor",strokeOpacity:.35,markerEnd:"url(#why-ah)"}),i.jsx("line",{x1:370,y1:93,x2:365,y2:168,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:430,y1:93,x2:445,y2:168,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"}),i.jsx("line",{x1:210,y1:128,x2:210,y2:168,stroke:"currentColor",strokeOpacity:.2,strokeDasharray:"3 2"})]})}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 mb-6",children:[{icon:Ci,title:"CLI",mono:"cg",desc:"Entry point for humans and AI agents. One command in, JSON out."},{icon:xl,title:"Daemon",mono:":9091",desc:"Validates auth and capabilities, loads connectors, writes audit log."},{icon:oi,title:"Extension",mono:"MV3",desc:"Runs inside your authenticated Chrome. Accesses cookies and page data."},{icon:fo,title:"Connectors",mono:"YAML",desc:"Declarative pipelines: navigate → wait → extract → map. No code execution."},{icon:md,title:"Audit Log",mono:"SQLite",desc:"Every execution logged: connector, domains, timing, approvals."},{icon:m1,title:"GUI",mono:":9092",desc:"React SPA with app pages, connector browsing, and config management."}].map(({icon:e,title:t,mono:n,desc:s})=>i.jsxs("div",{className:"flex gap-3 p-3 border border-base-300 bg-base-100",children:[i.jsx(e,{className:"w-4 h-4 shrink-0 mt-0.5 opacity-40"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-baseline gap-1.5 mb-0.5",children:[i.jsx("span",{className:"font-display font-semibold text-sm",children:t}),i.jsx("span",{className:"font-mono text-[0.65rem] opacity-40",children:n})]}),i.jsx("p",{className:"text-xs opacity-60 leading-relaxed",children:s})]})]},t))}),i.jsxs("div",{className:"flex flex-wrap gap-4",children:[i.jsxs(we,{to:"/architecture",className:"font-mono text-xs text-primary hover:underline flex items-center gap-1",children:["Full architecture details ",i.jsx(qe,{className:"w-3 h-3"})]}),i.jsxs(we,{to:"/concepts",className:"font-mono text-xs text-primary hover:underline flex items-center gap-1",children:["Concepts deep dive ",i.jsx(qe,{className:"w-3 h-3"})]})]})]})}),i.jsxs("section",{id:"why-apps",className:"py-16 border-b border-base-300 scroll-mt-4",children:[i.jsx(dn,{children:"Ships with six connectors"}),i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-4",children:"Built-in Apps"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[65ch] leading-relaxed mb-8",children:"commandGarden ships with connectors and app pages for common enterprise tasks. Each runs on your local machine using your browser session."}),i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[{icon:_c,title:"Time Tracking",tag:"Administrative",desc:"Monthly report with project breakdown and summary cards",route:"/apps/timetracking",cmd:"timetracking/report"},{icon:Hh,title:"Room Availability",tag:"Administrative",desc:"Meeting room free/busy from Outlook Scheduling Assistant",route:"/apps/rooms",cmd:"teams/room-availability"},{icon:Bh,title:"Dev Journal",tag:"Productivity",desc:"Auto-generated daily journal from Git commits and Jira tickets",route:"/apps/journal",cmd:"ado/git-commits"},{icon:Gh,title:"Security News",tag:"Security",desc:"Aggregated feed from Socket.dev, Wiz, and tl;dr sec",route:"/apps/security-news",cmd:"socket/security-news"},{icon:Jv,title:"Trusted Peer Expiry",tag:"Productivity",desc:"TokenMaster client trust relationships with expiry tracking",route:"/apps/trusted-peer-expiry",cmd:"tokenmaster/clients-list"},{icon:s1,title:"GCS Knowledge Base",tag:"Security",desc:"Browse and read internal security docs, converted to Markdown",route:null,cmd:"gcs/kb-pages"}].map(({icon:e,title:t,tag:n,desc:s,route:r,cmd:a})=>i.jsxs("div",{className:"border border-base-300 p-4",children:[i.jsxs("div",{className:"flex items-start gap-3 mb-2",children:[i.jsx(e,{className:"w-4 h-4 shrink-0 mt-0.5 opacity-40"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("span",{className:"font-display font-semibold text-sm",children:t}),i.jsx(W,{size:"xs",children:n})]}),i.jsx("p",{className:"text-xs opacity-60 leading-relaxed",children:s})]})]}),i.jsxs("div",{className:"flex items-center justify-between mt-3 pt-2 border-t border-base-300/50",children:[i.jsxs("span",{className:"font-mono text-[0.65rem] opacity-30",children:["cg run ",a]}),r&&i.jsxs(we,{to:r,className:"font-mono text-xs text-primary hover:underline flex items-center gap-1",children:["Open ",i.jsx(qe,{className:"w-3 h-3"})]})]})]},t))}),i.jsx("p",{className:"text-xs opacity-40 mt-4 max-w-[65ch]",children:"Each app page combines multiple connector calls into a single view. The GUI handles layout and caching; the connectors provide the raw data."})]}),i.jsxs("section",{id:"why-happy-path",className:"py-16 border-b border-base-300 scroll-mt-4",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-8",children:"From install to first result"}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(Ci,{className:"w-4 h-4 opacity-40"}),i.jsx("h3",{className:"font-display font-semibold text-sm",children:"Human user"})]}),i.jsx("div",{className:"space-y-3 mb-4",children:[{step:"Install",cmd:"npm install -g @commandgarden/cli"},{step:"Start",cmd:"cg up"},{step:"Load extension",cmd:"chrome://extensions → Load unpacked"},{step:"Verify",cmd:"cg daemon status"},{step:"Run",cmd:"cg run timetracking/report --month 2026-06"}].map((e,t)=>i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx("span",{className:"w-5 h-5 border border-base-300 bg-base-200 flex items-center justify-center font-mono text-[0.6rem] opacity-50 shrink-0",children:t+1}),i.jsx("span",{className:"text-xs font-medium opacity-60",children:e.step})]}),i.jsx("div",{className:"ml-[1.875rem] mt-1",children:i.jsx("code",{className:"text-xs font-mono bg-base-200 border border-base-300 px-2 py-0.5 opacity-70",children:e.cmd})}),t<4&&i.jsx("div",{className:"ml-2.5 w-px h-2 bg-base-300"})]},t))}),i.jsxs("p",{className:"text-xs opacity-50 ml-[1.875rem]",children:["Or open the GUI at ",i.jsx("span",{className:"font-mono",children:"localhost:9092"})," and use the visual interface."]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsx(oi,{className:"w-4 h-4 opacity-40"}),i.jsx("h3",{className:"font-display font-semibold text-sm",children:"AI agent"})]}),i.jsx("div",{className:"space-y-3 mb-4",children:[{step:"Load skill",cmd:"cg skill loaded"},{step:"Check status",cmd:"cg daemon status → ready"},{step:"Discover",cmd:"cg list → available connectors"},{step:"Inspect",cmd:"cg inspect timetracking/report → args, columns"},{step:"Run",cmd:"cg run timetracking/report --format json"}].map((e,t)=>i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx("span",{className:"w-5 h-5 border border-base-300 bg-base-200 flex items-center justify-center font-mono text-[0.6rem] opacity-50 shrink-0",children:t+1}),i.jsx("span",{className:"text-xs font-medium opacity-60",children:e.step})]}),i.jsx("div",{className:"ml-[1.875rem] mt-1",children:i.jsx("code",{className:"text-xs font-mono bg-base-200 border border-base-300 px-2 py-0.5 opacity-70",children:e.cmd})}),t<4&&i.jsx("div",{className:"ml-2.5 w-px h-2 bg-base-300"})]},t))}),i.jsx("p",{className:"text-xs opacity-50 ml-[1.875rem]",children:"Same JSON, same schema as the human path."})]})]}),i.jsxs("div",{className:"mt-8 border border-primary/20 bg-primary/[0.03] p-4 flex items-center gap-3",children:[i.jsx(Oc,{className:"w-4 h-4 text-primary shrink-0"}),i.jsx("p",{className:"text-sm opacity-70",children:"Human or agent, the output is the same. Same connector, same schema."})]})]}),i.jsx("section",{id:"why-security",className:"py-16 border-b border-base-300 bg-base-200/30 -mx-4 px-4 md:-mx-5 md:px-5 scroll-mt-4",children:i.jsxs("div",{className:"max-w-4xl mx-auto",children:[i.jsx(dn,{children:"Touching enterprise data means no shortcuts"}),i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-4",children:"Security"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[65ch] leading-relaxed mb-8",children:"This tool has access to your cookies and session tokens. That's a lot of trust, so the defaults are locked down — you have to explicitly open things up."}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 mb-8",children:[{icon:Kh,title:"No credentials stored",desc:"Reuses session cookies already in Chrome. Nothing stored on disk, nothing sent externally."},{icon:N1,title:"Domain-scoped permissions",desc:"Connectors declare allowed domains. Undeclared domains are blocked by the daemon."},{icon:Vh,title:"Capability gating",desc:"Each step requires a declared capability. High-risk ops (js_evaluate, cookie_write) need approval."},{icon:qv,title:"Step-by-step approval",desc:"Sensitive operations pause for confirmation. Approve in CLI or via Chrome notification."},{icon:xl,title:"Local-only processing",desc:"Daemon on :9091, app server on :9092. Bound to localhost. No network exposure."},{icon:fo,title:"Declarative connectors",desc:"Pure YAML pipelines. No JavaScript evaluation unless explicitly declared and approved."},{icon:qh,title:"Audit-or-fail",desc:"Every execution logged to SQLite. Domains, timing, approvals, row counts. If audit fails, commands are blocked."},{icon:md,title:"Per-session auth",desc:"Session token generated on startup with owner-only permissions. Extension verifies its own ID per message."}].map(({icon:e,title:t,desc:n})=>i.jsxs("div",{className:"flex gap-3 p-3 border border-base-300 bg-base-100",children:[i.jsx(e,{className:"w-4 h-4 shrink-0 mt-0.5 opacity-40"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-display font-semibold text-sm mb-0.5",children:t}),i.jsx("p",{className:"text-xs opacity-60 leading-relaxed",children:n})]})]},t))}),i.jsxs("div",{className:"border border-base-300 bg-base-100 p-5",children:[i.jsx("h3",{className:"font-mono text-xs font-medium opacity-50 uppercase tracking-wide mb-3",children:"Limitations"}),i.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-x-8 gap-y-1.5 text-sm opacity-70",children:[i.jsx("p",{children:"Only works while browser is open and you're logged in."}),i.jsx("p",{children:"Connectors may break when a site redesigns its HTML/APIs."}),i.jsx("p",{children:"Chrome-based browsers only for now."}),i.jsx("p",{children:"No credential storage, so sessions expire when you log out."})]})]})]})}),i.jsxs("section",{id:"why-get-started",className:"py-16 border-b border-base-300 scroll-mt-4",children:[i.jsx("h2",{className:"font-display text-xl font-bold uppercase tracking-[0.06em] mb-4",children:"Get started in 60 seconds"}),i.jsx(ui,{children:`# Install
@@ -458,4 +458,4 @@ pipeline:
458
458
  selector: ".ticket-row"
459
459
  fields:
460
460
  id: ".ticket-id"
461
- title: ".ticket-title"`}),i.jsxs("p",{className:"text-xs opacity-50 mt-2",children:["Each ",i.jsx("span",{className:"font-mono",children:"step"})," above maps to one hop in the diagram: navigate opens the tab, wait confirms it loaded, extract reads structured rows back out."]})]})]})]}),i.jsxs("section",{id:"concepts-approval",className:"scroll-mt-4",children:[i.jsx(po,{children:"Not everything runs unattended"}),i.jsx("h3",{className:"font-display text-base font-semibold mb-3",children:"Approval & risk-tiering workflow"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[65ch] leading-relaxed mb-6",children:"Every capability has a risk tier. Low and medium tiers run without interruption. High-risk steps pause and wait for a human to say yes, either in the CLI or as a Chrome notification."}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-8",children:Ed.map((e,t)=>i.jsxs("div",{className:"relative",children:[i.jsxs("div",{className:"border border-base-300 p-4 h-full",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(e.icon,{className:"w-4 h-4 opacity-50"}),i.jsx(W,{variant:e.variant,size:"xs",children:e.label})]}),i.jsx("p",{className:"text-xs opacity-60 leading-relaxed",children:e.desc})]}),t<Ed.length-1&&i.jsx(qe,{className:"hidden sm:block w-4 h-4 opacity-30 absolute top-1/2 -right-2 -translate-y-1/2 translate-x-1/2 z-10"})]},e.label))}),i.jsx(bl,{flow:sj}),i.jsxs("div",{className:"mt-6 border border-primary/20 bg-primary/[0.03] p-4 flex items-center gap-3",children:[i.jsx(Kh,{className:"w-4 h-4 text-primary shrink-0"}),i.jsx("p",{className:"text-sm opacity-70",children:"No credentials are ever stored to make this work. Approval just gates whether an already-authenticated step is allowed to run."})]})]})]})}b.lazy(()=>Og(()=>import("./Slides-Dox8f5zS.js"),[]));function Gs({isActive:e}){return`flex items-center gap-2 px-3 py-2 text-sm transition-colors ${e?"bg-primary text-primary-content font-semibold":"hover:text-primary"}`}function qs({isActive:e}){return`flex items-center gap-2 pl-4 pr-3 py-1.5 text-sm transition-colors ${e?"bg-primary text-primary-content font-semibold":"hover:text-primary"}`}const Fs={"/config":[{label:"Server",id:"cfg-server"},{label:"Security",id:"cfg-security"},{label:"Sources",id:"cfg-sources"},{label:"Audit",id:"cfg-audit"},{label:"Output",id:"cfg-output"},{label:"Journal",id:"cfg-journal"}],"/architecture":[{label:"Diagram",id:"arch-diagram"},{label:"Components",id:"arch-components"},{label:"Data Stores",id:"arch-stores"},{label:"Data Flows",id:"arch-flows"},{label:"Security",id:"arch-security"},{label:"Packages",id:"arch-packages"},{label:"Build Order",id:"arch-build"}],"/api-reference":[{label:"Endpoints",id:"api-endpoints"},{label:"Pipeline Steps",id:"api-pipeline"},{label:"Expressions",id:"api-expressions"}],"/concepts":[{label:"Capability & World Model",id:"concepts-worlds"},{label:"Pipeline Lifecycle",id:"concepts-lifecycle"},{label:"Approval & Risk-Tiering",id:"concepts-approval"}],"/why":[{label:"The Problem",id:"why-problem"},{label:"The Solution",id:"why-solution"},{label:"Architecture",id:"why-architecture"},{label:"Built-in Apps",id:"why-apps"},{label:"Workflow",id:"why-happy-path"},{label:"Security",id:"why-security"},{label:"Get Started",id:"why-get-started"},{label:"Extend",id:"why-extend"}]};function ij({sections:e}){const t=b.useMemo(()=>e.map(r=>r.id),[e]),n=Uy(t),s=r=>{const a=document.getElementById(r);a&&a.scrollIntoView({behavior:"smooth",block:"start"})};return i.jsx("div",{className:"ml-3 border-l border-base-300 py-0.5",children:e.map(r=>i.jsx("button",{onClick:()=>s(r.id),className:`block w-full text-left pl-3 py-1 text-[0.7rem] transition-colors ${n===r.id?"text-primary opacity-100":"opacity-50 hover:opacity-70"}`,children:r.label},r.id))})}const aj=[{label:"Daily",to:"/apps/journal/daily"},{label:"Weekly",to:"/apps/journal/weekly"}];function oj({to:e,label:t,icon:n,items:s}){const a=Rt().pathname.startsWith(e);return i.jsxs(i.Fragment,{children:[i.jsxs(lt,{to:e,className:qs,children:[n,t]}),a&&s.length>0&&i.jsx("div",{className:"ml-3 border-l border-base-300 py-0.5",children:s.map(o=>i.jsx(lt,{to:o.to,className:({isActive:l})=>`block w-full text-left pl-3 py-1 text-[0.7rem] transition-colors ${l?"text-primary opacity-100":"opacity-50 hover:opacity-70"}`,children:o.label},o.to))})]})}function Dn({to:e,label:t,icon:n,sections:s}){const a=Rt().pathname===e;return i.jsxs(i.Fragment,{children:[i.jsxs(lt,{to:e,end:e==="/",className:Gs,children:[n,t]}),a&&s.length>0&&i.jsx(ij,{sections:s})]})}function lj(){const[e,t]=b.useState(!1),[n,s]=b.useState(!1),[r,a]=b.useState(!1),[o,l]=b.useState([]),[c,u]=b.useState(!1),m=b.useRef(null),d=Rt();b.useEffect(()=>{a(!1)},[d.pathname]),b.useEffect(()=>{if(!d.hash)return;const y=d.hash.slice(1),x=document.getElementById(y);x&&x.scrollIntoView({behavior:"smooth",block:"start"})},[d.pathname,d.hash]),b.useEffect(()=>{const y=()=>{B.getStatus().then(w=>{t(w.ok),s(w.extensionConnected)}).catch(()=>{t(!1),s(!1)})};y();const x=setInterval(y,3e4);return()=>clearInterval(x)},[]),b.useEffect(()=>{B.getConnectors().then(y=>{const x=wa(y.connectors).map(([w])=>w);l(x)}).catch(()=>{})},[]);const f=b.useMemo(()=>o.map(y=>({label:y,id:`conn-${y}`})),[o]),v=b.useCallback(()=>{const y=m.current;y&&u(y.scrollHeight-y.scrollTop-y.clientHeight>1)},[]);return b.useEffect(()=>{v();const y=m.current;if(y)return y.addEventListener("scroll",v,{passive:!0}),window.addEventListener("resize",v),()=>{y.removeEventListener("scroll",v),window.removeEventListener("resize",v)}},[v,f,d.pathname,e]),i.jsxs("div",{className:"flex min-h-screen",children:[i.jsx("button",{className:"fixed top-3 left-3 z-50 md:hidden btn btn-sm btn-ghost",onClick:()=>a(!r),"aria-label":r?"Close menu":"Open menu",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:r?i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"}):i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),r&&i.jsx("div",{className:"fixed inset-0 bg-black/30 z-30 md:hidden",onClick:()=>a(!1)}),i.jsxs("aside",{className:`w-56 bg-base-100 border-r border-base-300 flex flex-col fixed top-0 left-0 bottom-0 z-40 transition-transform duration-150 ease-out ${r?"translate-x-0":"-translate-x-full"} md:translate-x-0`,children:[i.jsxs("div",{className:"flex items-start justify-between px-3 py-3 border-b border-base-300",children:[i.jsxs(we,{to:"/",className:"hover:opacity-80 transition-opacity",children:[i.jsxs("h1",{className:"font-display text-lg font-bold tracking-tight",children:[i.jsx("span",{className:"font-normal opacity-50",children:"command"}),"Garden"]}),i.jsx("p",{className:"font-mono text-[0.65rem] opacity-30 mt-1 uppercase tracking-[0.14em]",children:"browser automation"})]}),i.jsx("button",{className:"btn btn-ghost btn-sm btn-square",onClick:()=>{const y=document.documentElement.getAttribute("data-theme")==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",y),localStorage.setItem("theme",y)},"aria-label":"Toggle theme",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]}),i.jsxs("div",{className:"relative flex-1 min-h-0",children:[i.jsxs("nav",{ref:m,className:"h-full px-2 py-2 space-y-0.5 overflow-y-auto",children:[i.jsx("div",{className:"px-3 pt-3 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Overview"}),i.jsxs(lt,{to:"/",end:!0,className:Gs,children:[i.jsx(t1,{className:"w-4 h-4 shrink-0"}),"Dashboard"]}),i.jsxs(lt,{to:"/guide",className:Gs,children:[i.jsx(Bh,{className:"w-4 h-4 shrink-0"}),"Setup Guide"]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Apps"}),i.jsx("div",{className:"pl-5 pr-3 pt-3 pb-1 font-mono text-[0.65rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Administrative"}),i.jsxs(lt,{to:"/apps/timetracking",className:qs,children:[i.jsx(_c,{className:"w-4 h-4 shrink-0"}),"Time Tracking"]}),i.jsxs(lt,{to:"/apps/rooms",className:qs,children:[i.jsx(Hh,{className:"w-4 h-4 shrink-0"}),"Room Availability"]}),i.jsx("div",{className:"pl-5 pr-3 pt-3 pb-1 font-mono text-[0.65rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Productivity"}),i.jsx(oj,{to:"/apps/journal",label:"Dev Journal",icon:i.jsx(d1,{className:"w-4 h-4 shrink-0"}),items:aj}),i.jsxs(lt,{to:"/apps/trusted-peer-expiry",className:qs,children:[i.jsx(Yh,{className:"w-4 h-4 shrink-0"}),"Trusted Peer Expiry"]}),i.jsx("div",{className:"pl-5 pr-3 pt-3 pb-1 font-mono text-[0.65rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Security"}),i.jsxs(lt,{to:"/apps/security-news",className:qs,children:[i.jsx(Gh,{className:"w-4 h-4 shrink-0"}),"Security News"]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Platform"}),i.jsx(Dn,{to:"/connectors",label:"Connectors",icon:i.jsx(p1,{className:"w-4 h-4 shrink-0"}),sections:f}),i.jsxs(lt,{to:"/audit",className:Gs,children:[i.jsx(qh,{className:"w-4 h-4 shrink-0"}),"Audit Log"]}),i.jsx(Dn,{to:"/config",label:"Configuration",icon:i.jsx(v1,{className:"w-4 h-4 shrink-0"}),sections:e?Fs["/config"]:[]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Reference"}),i.jsx(Dn,{to:"/why",label:"Why commandGarden",icon:i.jsx(i1,{className:"w-4 h-4 shrink-0"}),sections:Fs["/why"]}),i.jsx(Dn,{to:"/api-reference",label:"API & CLI",icon:i.jsx(Ci,{className:"w-4 h-4 shrink-0"}),sections:Fs["/api-reference"]}),i.jsxs(lt,{to:"/skills",className:Gs,children:[i.jsx(C1,{className:"w-4 h-4 shrink-0"}),"Skills"]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Deep Dive"}),i.jsx(Dn,{to:"/concepts",label:"Concepts",icon:i.jsx(Zv,{className:"w-4 h-4 shrink-0"}),sections:Fs["/concepts"]}),i.jsx(Dn,{to:"/architecture",label:"Architecture",icon:i.jsx(l1,{className:"w-4 h-4 shrink-0"}),sections:Fs["/architecture"]}),!1]}),c&&i.jsx("div",{className:"pointer-events-none absolute bottom-0 inset-x-0 h-8 bg-gradient-to-t from-base-100 to-transparent","aria-hidden":"true"})]}),i.jsxs("div",{className:"px-3 py-2.5 border-t border-base-300",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[i.jsx("span",{className:`w-1.5 h-1.5 ${e?"bg-success":"bg-error"}`,"aria-hidden":"true"}),i.jsx("span",{className:"opacity-50 text-[0.65rem]",children:e?"DAEMON OK":"DAEMON OFF"})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono mt-1",children:[i.jsx("span",{className:`w-1.5 h-1.5 ${n?"bg-success":"bg-error"}`,"aria-hidden":"true"}),i.jsx("span",{className:"opacity-50 text-[0.65rem]",children:n?"EXTENSION LINKED":"EXTENSION OFF"})]})]})]}),i.jsx("main",{className:"flex-1 p-4 pt-14 md:pt-5 md:p-5 md:ml-56",children:i.jsx(Cy,{})})]})}function cj(){return i.jsx(Dy,{children:i.jsx(Ty,{children:i.jsxs(he,{element:i.jsx(lj,{}),children:[i.jsx(he,{index:!0,element:i.jsx(Vy,{})}),i.jsx(he,{path:"connectors",element:i.jsx(qy,{})}),i.jsx(he,{path:"connectors/:site/:name",element:i.jsx(Yy,{})}),i.jsx(he,{path:"audit",element:i.jsx(Xy,{})}),i.jsx(he,{path:"config",element:i.jsx(mv,{})}),i.jsx(he,{path:"guide",element:i.jsx(jv,{})}),i.jsx(he,{path:"apps/timetracking",element:i.jsx(B1,{})}),i.jsx(he,{path:"apps/rooms",element:i.jsx(tb,{})}),i.jsx(he,{path:"apps/journal",element:i.jsx(Sy,{to:"/apps/journal/daily",replace:!0})}),i.jsx(he,{path:"apps/journal/daily",element:i.jsx(xb,{})}),i.jsx(he,{path:"apps/journal/weekly",element:i.jsx(cb,{})}),i.jsx(he,{path:"apps/security-news",element:i.jsx(Eb,{})}),i.jsx(he,{path:"apps/trusted-peer-expiry",element:i.jsx(Ib,{})}),i.jsx(he,{path:"architecture",element:i.jsx(zb,{})}),i.jsx(he,{path:"api-reference",element:i.jsx(Vb,{})}),i.jsx(he,{path:"skills",element:i.jsx(Yb,{})}),i.jsx(he,{path:"why",element:i.jsx(Zb,{})}),i.jsx(he,{path:"concepts",element:i.jsx(rj,{})}),!1]})})})}Bm(document.getElementById("root")).render(i.jsx(b.StrictMode,{children:i.jsx(cj,{})}));export{Bh as B,Wh as C,md as D,Vh as E,fo as F,oi as G,Kh as L,m1 as P,xl as S,Ci as T,Uh as a,N1 as b,K as c,qv as d,W as e,i as j,b as r,Ym as u};
461
+ title: ".ticket-title"`}),i.jsxs("p",{className:"text-xs opacity-50 mt-2",children:["Each ",i.jsx("span",{className:"font-mono",children:"step"})," above maps to one hop in the diagram: navigate opens the tab, wait confirms it loaded, extract reads structured rows back out."]})]})]})]}),i.jsxs("section",{id:"concepts-approval",className:"scroll-mt-4",children:[i.jsx(po,{children:"Not everything runs unattended"}),i.jsx("h3",{className:"font-display text-base font-semibold mb-3",children:"Approval & risk-tiering workflow"}),i.jsx("p",{className:"text-sm opacity-70 max-w-[65ch] leading-relaxed mb-6",children:"Every capability has a risk tier. Low and medium tiers run without interruption. High-risk steps pause and wait for a human to say yes, either in the CLI or as a Chrome notification."}),i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-8",children:Ed.map((e,t)=>i.jsxs("div",{className:"relative",children:[i.jsxs("div",{className:"border border-base-300 p-4 h-full",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[i.jsx(e.icon,{className:"w-4 h-4 opacity-50"}),i.jsx(W,{variant:e.variant,size:"xs",children:e.label})]}),i.jsx("p",{className:"text-xs opacity-60 leading-relaxed",children:e.desc})]}),t<Ed.length-1&&i.jsx(qe,{className:"hidden sm:block w-4 h-4 opacity-30 absolute top-1/2 -right-2 -translate-y-1/2 translate-x-1/2 z-10"})]},e.label))}),i.jsx(bl,{flow:sj}),i.jsxs("div",{className:"mt-6 border border-primary/20 bg-primary/[0.03] p-4 flex items-center gap-3",children:[i.jsx(Kh,{className:"w-4 h-4 text-primary shrink-0"}),i.jsx("p",{className:"text-sm opacity-70",children:"No credentials are ever stored to make this work. Approval just gates whether an already-authenticated step is allowed to run."})]})]})]})}b.lazy(()=>Og(()=>import("./Slides-D3xcxd9t.js"),[]));function Gs({isActive:e}){return`flex items-center gap-2 px-3 py-2 text-sm transition-colors ${e?"bg-primary text-primary-content font-semibold":"hover:text-primary"}`}function qs({isActive:e}){return`flex items-center gap-2 pl-4 pr-3 py-1.5 text-sm transition-colors ${e?"bg-primary text-primary-content font-semibold":"hover:text-primary"}`}const Fs={"/config":[{label:"Server",id:"cfg-server"},{label:"Security",id:"cfg-security"},{label:"Sources",id:"cfg-sources"},{label:"Audit",id:"cfg-audit"},{label:"Output",id:"cfg-output"},{label:"Journal",id:"cfg-journal"}],"/architecture":[{label:"Diagram",id:"arch-diagram"},{label:"Components",id:"arch-components"},{label:"Data Stores",id:"arch-stores"},{label:"Data Flows",id:"arch-flows"},{label:"Security",id:"arch-security"},{label:"Packages",id:"arch-packages"},{label:"Build Order",id:"arch-build"}],"/api-reference":[{label:"Endpoints",id:"api-endpoints"},{label:"Pipeline Steps",id:"api-pipeline"},{label:"Expressions",id:"api-expressions"}],"/concepts":[{label:"Capability & World Model",id:"concepts-worlds"},{label:"Pipeline Lifecycle",id:"concepts-lifecycle"},{label:"Approval & Risk-Tiering",id:"concepts-approval"}],"/why":[{label:"The Problem",id:"why-problem"},{label:"The Solution",id:"why-solution"},{label:"Architecture",id:"why-architecture"},{label:"Built-in Apps",id:"why-apps"},{label:"Workflow",id:"why-happy-path"},{label:"Security",id:"why-security"},{label:"Get Started",id:"why-get-started"},{label:"Extend",id:"why-extend"}]};function ij({sections:e}){const t=b.useMemo(()=>e.map(r=>r.id),[e]),n=Uy(t),s=r=>{const a=document.getElementById(r);a&&a.scrollIntoView({behavior:"smooth",block:"start"})};return i.jsx("div",{className:"ml-3 border-l border-base-300 py-0.5",children:e.map(r=>i.jsx("button",{onClick:()=>s(r.id),className:`block w-full text-left pl-3 py-1 text-[0.7rem] transition-colors ${n===r.id?"text-primary opacity-100":"opacity-50 hover:opacity-70"}`,children:r.label},r.id))})}const aj=[{label:"Daily",to:"/apps/journal/daily"},{label:"Weekly",to:"/apps/journal/weekly"}];function oj({to:e,label:t,icon:n,items:s}){const a=Rt().pathname.startsWith(e);return i.jsxs(i.Fragment,{children:[i.jsxs(lt,{to:e,className:qs,children:[n,t]}),a&&s.length>0&&i.jsx("div",{className:"ml-3 border-l border-base-300 py-0.5",children:s.map(o=>i.jsx(lt,{to:o.to,className:({isActive:l})=>`block w-full text-left pl-3 py-1 text-[0.7rem] transition-colors ${l?"text-primary opacity-100":"opacity-50 hover:opacity-70"}`,children:o.label},o.to))})]})}function Dn({to:e,label:t,icon:n,sections:s}){const a=Rt().pathname===e;return i.jsxs(i.Fragment,{children:[i.jsxs(lt,{to:e,end:e==="/",className:Gs,children:[n,t]}),a&&s.length>0&&i.jsx(ij,{sections:s})]})}function lj(){const[e,t]=b.useState(!1),[n,s]=b.useState(!1),[r,a]=b.useState(!1),[o,l]=b.useState([]),[c,u]=b.useState(!1),m=b.useRef(null),d=Rt();b.useEffect(()=>{a(!1)},[d.pathname]),b.useEffect(()=>{if(!d.hash)return;const y=d.hash.slice(1),x=document.getElementById(y);x&&x.scrollIntoView({behavior:"smooth",block:"start"})},[d.pathname,d.hash]),b.useEffect(()=>{const y=()=>{B.getStatus().then(w=>{t(w.ok),s(w.extensionConnected)}).catch(()=>{t(!1),s(!1)})};y();const x=setInterval(y,3e4);return()=>clearInterval(x)},[]),b.useEffect(()=>{B.getConnectors().then(y=>{const x=wa(y.connectors).map(([w])=>w);l(x)}).catch(()=>{})},[]);const f=b.useMemo(()=>o.map(y=>({label:y,id:`conn-${y}`})),[o]),v=b.useCallback(()=>{const y=m.current;y&&u(y.scrollHeight-y.scrollTop-y.clientHeight>1)},[]);return b.useEffect(()=>{v();const y=m.current;if(y)return y.addEventListener("scroll",v,{passive:!0}),window.addEventListener("resize",v),()=>{y.removeEventListener("scroll",v),window.removeEventListener("resize",v)}},[v,f,d.pathname,e]),i.jsxs("div",{className:"flex min-h-screen",children:[i.jsx("button",{className:"fixed top-3 left-3 z-50 md:hidden btn btn-sm btn-ghost",onClick:()=>a(!r),"aria-label":r?"Close menu":"Open menu",children:i.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:r?i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"}):i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 6h16M4 12h16M4 18h16"})})}),r&&i.jsx("div",{className:"fixed inset-0 bg-black/30 z-30 md:hidden",onClick:()=>a(!1)}),i.jsxs("aside",{className:`w-56 bg-base-100 border-r border-base-300 flex flex-col fixed top-0 left-0 bottom-0 z-40 transition-transform duration-150 ease-out ${r?"translate-x-0":"-translate-x-full"} md:translate-x-0`,children:[i.jsxs("div",{className:"flex items-start justify-between px-3 py-3 border-b border-base-300",children:[i.jsxs(we,{to:"/",className:"hover:opacity-80 transition-opacity",children:[i.jsxs("h1",{className:"font-display text-lg font-bold tracking-tight",children:[i.jsx("span",{className:"font-normal opacity-50",children:"command"}),"Garden"]}),i.jsx("p",{className:"font-mono text-[0.65rem] opacity-30 mt-1 uppercase tracking-[0.14em]",children:"browser automation"})]}),i.jsx("button",{className:"btn btn-ghost btn-sm btn-square",onClick:()=>{const y=document.documentElement.getAttribute("data-theme")==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",y),localStorage.setItem("theme",y)},"aria-label":"Toggle theme",children:i.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"})})})]}),i.jsxs("div",{className:"relative flex-1 min-h-0",children:[i.jsxs("nav",{ref:m,className:"h-full px-2 py-2 space-y-0.5 overflow-y-auto",children:[i.jsx("div",{className:"px-3 pt-3 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Overview"}),i.jsxs(lt,{to:"/",end:!0,className:Gs,children:[i.jsx(t1,{className:"w-4 h-4 shrink-0"}),"Dashboard"]}),i.jsxs(lt,{to:"/guide",className:Gs,children:[i.jsx(Bh,{className:"w-4 h-4 shrink-0"}),"Setup Guide"]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Apps"}),i.jsx("div",{className:"pl-5 pr-3 pt-3 pb-1 font-mono text-[0.65rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Administrative"}),i.jsxs(lt,{to:"/apps/timetracking",className:qs,children:[i.jsx(_c,{className:"w-4 h-4 shrink-0"}),"Time Tracking"]}),i.jsxs(lt,{to:"/apps/rooms",className:qs,children:[i.jsx(Hh,{className:"w-4 h-4 shrink-0"}),"Room Availability"]}),i.jsx("div",{className:"pl-5 pr-3 pt-3 pb-1 font-mono text-[0.65rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Productivity"}),i.jsx(oj,{to:"/apps/journal",label:"Dev Journal",icon:i.jsx(d1,{className:"w-4 h-4 shrink-0"}),items:aj}),i.jsxs(lt,{to:"/apps/trusted-peer-expiry",className:qs,children:[i.jsx(Yh,{className:"w-4 h-4 shrink-0"}),"Trusted Peer Expiry"]}),i.jsx("div",{className:"pl-5 pr-3 pt-3 pb-1 font-mono text-[0.65rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Security"}),i.jsxs(lt,{to:"/apps/security-news",className:qs,children:[i.jsx(Gh,{className:"w-4 h-4 shrink-0"}),"Security News"]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Platform"}),i.jsx(Dn,{to:"/connectors",label:"Connectors",icon:i.jsx(p1,{className:"w-4 h-4 shrink-0"}),sections:f}),i.jsxs(lt,{to:"/audit",className:Gs,children:[i.jsx(qh,{className:"w-4 h-4 shrink-0"}),"Audit Log"]}),i.jsx(Dn,{to:"/config",label:"Configuration",icon:i.jsx(v1,{className:"w-4 h-4 shrink-0"}),sections:e?Fs["/config"]:[]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Reference"}),i.jsx(Dn,{to:"/why",label:"Why commandGarden",icon:i.jsx(i1,{className:"w-4 h-4 shrink-0"}),sections:Fs["/why"]}),i.jsx(Dn,{to:"/api-reference",label:"API & CLI",icon:i.jsx(Ci,{className:"w-4 h-4 shrink-0"}),sections:Fs["/api-reference"]}),i.jsxs(lt,{to:"/skills",className:Gs,children:[i.jsx(C1,{className:"w-4 h-4 shrink-0"}),"Skills"]}),i.jsx("div",{className:"px-3 pt-6 pb-1.5 font-mono text-[0.6rem] font-medium opacity-70 uppercase tracking-[0.12em]",children:"Deep Dive"}),i.jsx(Dn,{to:"/concepts",label:"Concepts",icon:i.jsx(Zv,{className:"w-4 h-4 shrink-0"}),sections:Fs["/concepts"]}),i.jsx(Dn,{to:"/architecture",label:"Architecture",icon:i.jsx(l1,{className:"w-4 h-4 shrink-0"}),sections:Fs["/architecture"]}),!1]}),c&&i.jsx("div",{className:"pointer-events-none absolute bottom-0 inset-x-0 h-8 bg-gradient-to-t from-base-100 to-transparent","aria-hidden":"true"})]}),i.jsxs("div",{className:"px-3 py-2.5 border-t border-base-300",children:[i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[i.jsx("span",{className:`w-1.5 h-1.5 ${e?"bg-success":"bg-error"}`,"aria-hidden":"true"}),i.jsx("span",{className:"opacity-50 text-[0.65rem]",children:e?"DAEMON OK":"DAEMON OFF"})]}),i.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono mt-1",children:[i.jsx("span",{className:`w-1.5 h-1.5 ${n?"bg-success":"bg-error"}`,"aria-hidden":"true"}),i.jsx("span",{className:"opacity-50 text-[0.65rem]",children:n?"EXTENSION LINKED":"EXTENSION OFF"})]})]})]}),i.jsx("main",{className:"flex-1 p-4 pt-14 md:pt-5 md:p-5 md:ml-56",children:i.jsx(Cy,{})})]})}function cj(){return i.jsx(Dy,{children:i.jsx(Ty,{children:i.jsxs(he,{element:i.jsx(lj,{}),children:[i.jsx(he,{index:!0,element:i.jsx(Vy,{})}),i.jsx(he,{path:"connectors",element:i.jsx(qy,{})}),i.jsx(he,{path:"connectors/:site/:name",element:i.jsx(Yy,{})}),i.jsx(he,{path:"audit",element:i.jsx(Xy,{})}),i.jsx(he,{path:"config",element:i.jsx(mv,{})}),i.jsx(he,{path:"guide",element:i.jsx(jv,{})}),i.jsx(he,{path:"apps/timetracking",element:i.jsx(B1,{})}),i.jsx(he,{path:"apps/rooms",element:i.jsx(tb,{})}),i.jsx(he,{path:"apps/journal",element:i.jsx(Sy,{to:"/apps/journal/daily",replace:!0})}),i.jsx(he,{path:"apps/journal/daily",element:i.jsx(xb,{})}),i.jsx(he,{path:"apps/journal/weekly",element:i.jsx(cb,{})}),i.jsx(he,{path:"apps/security-news",element:i.jsx(Eb,{})}),i.jsx(he,{path:"apps/trusted-peer-expiry",element:i.jsx(Ib,{})}),i.jsx(he,{path:"architecture",element:i.jsx(zb,{})}),i.jsx(he,{path:"api-reference",element:i.jsx(Vb,{})}),i.jsx(he,{path:"skills",element:i.jsx(Yb,{})}),i.jsx(he,{path:"why",element:i.jsx(Zb,{})}),i.jsx(he,{path:"concepts",element:i.jsx(rj,{})}),!1]})})})}Bm(document.getElementById("root")).render(i.jsx(b.StrictMode,{children:i.jsx(cj,{})}));export{Bh as B,Wh as C,md as D,Vh as E,fo as F,oi as G,Kh as L,m1 as P,xl as S,Ci as T,Uh as a,N1 as b,K as c,qv as d,W as e,i as j,b as r,Ym as u};