specrails-desktop 2.63.0 → 2.63.1
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.
- package/client/dist/assets/{ActivityFeedPage-Bn2MpG5M.js → ActivityFeedPage-B1bpTy7O.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-CHlXWdXq.js → AgentBrowserCapture-BussBbN3.js} +1 -1
- package/client/dist/assets/{AgentModeAnalyticsPane-yj-YCgrK.js → AgentModeAnalyticsPane-BiT1n3BU.js} +2 -2
- package/client/dist/assets/{AgentModeCodePane-Xczcyghb.js → AgentModeCodePane-CUjNfeKa.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-DtOW01ln.js → AgentModeJobsPane-RVEwyS59.js} +1 -1
- package/client/dist/assets/{AgentsPage-BMfJ4mzU.js → AgentsPage-DKE-eMC5.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-CGn5cgtc.js → AnalyticsPage-Bser2Ly3.js} +1 -1
- package/client/dist/assets/{CodePage-C8NIginr.js → CodePage-BK0grm6e.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-C87r4y26.js → DesktopAnalyticsPage-DEBidZbs.js} +1 -1
- package/client/dist/assets/{DocsDialog-Z50a_KPv.js → DocsDialog-Dhyo57n9.js} +1 -1
- package/client/dist/assets/{DocsPage-DIArbEPl.js → DocsPage-BcEkPXd6.js} +1 -1
- package/client/dist/assets/{ExportDropdown-CJdCqYd7.js → ExportDropdown-mRmqdkjr.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-BxLh4me-.js → InteractiveJobComposer-BlCe3vrU.js} +1 -1
- package/client/dist/assets/{JobDetailModal-C7dWoRu6.js → JobDetailModal-CkAejD1F.js} +1 -1
- package/client/dist/assets/{JobDetailPage-Ilu294WS.js → JobDetailPage-P-FS_lKz.js} +1 -1
- package/client/dist/assets/{JobsPage-fPq1hefb.js → JobsPage-CoUXgYse.js} +1 -1
- package/client/dist/assets/LoopBuilderPage-iFylNk68.js +1 -0
- package/client/dist/assets/{LoopPreviewModal-ChI3NQC7.js → LoopPreviewModal-4obS_Ptg.js} +1 -1
- package/client/dist/assets/{LoopWindowSurface-D1WB9i-9.js → LoopWindowSurface-CLr5OPqj.js} +1 -1
- package/client/dist/assets/{LoopsPage-CCwc0Biu.js → LoopsPage-eKpWFtCp.js} +1 -1
- package/client/dist/assets/{MinimizedChatsContext-eH_KaAZ1.js → MinimizedChatsContext-BHIUPVmC.js} +1 -1
- package/client/dist/assets/{PluginsPage-DfDfEfbW.js → PluginsPage-BgTC2CQx.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-9NHnG8JQ.js → ProjectSettingsDialog-B4chTfU8.js} +1 -1
- package/client/dist/assets/{RepositoryDeliveries-DgzNnJmn.js → RepositoryDeliveries-DAIxIYsl.js} +1 -1
- package/client/dist/assets/{RepositoryScopeSelector-BSgUqk_u.js → RepositoryScopeSelector-DeCoUsRN.js} +1 -1
- package/client/dist/assets/{ReviewPacketPage-D34bGpSA.js → ReviewPacketPage-Cktv0-9b.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-CcfSxWQ7.js → TemplatePreviewModal-BZTV1TM1.js} +1 -1
- package/client/dist/assets/{TicketDetailModalContext-BoafEcm4.js → TicketDetailModalContext-DiPngt2g.js} +1 -1
- package/client/dist/assets/{Trans-CVSryAL1.js → Trans-ZiXIfj50.js} +1 -1
- package/client/dist/assets/{agentRuntime-TKQyg137.js → agentRuntime-BDvbJMmS.js} +1 -1
- package/client/dist/assets/{agentRuntime-DvhEe1um.js → agentRuntime-BKJfv5YD.js} +1 -1
- package/client/dist/assets/{agentRuntime-DxC6-9rN.js → agentRuntime-BxF81z52.js} +1 -1
- package/client/dist/assets/{agentRuntime-C_yLPKDy.js → agentRuntime-BxYS5V7u.js} +1 -1
- package/client/dist/assets/{agentRuntime-WSv8G0pW.js → agentRuntime-BzuwQQgn.js} +1 -1
- package/client/dist/assets/{agentRuntime-D2kYQqNO.js → agentRuntime-Dc9HG3BA.js} +1 -1
- package/client/dist/assets/{agentRuntime-Bjt7Ij6_.js → agentRuntime-DiCldqGG.js} +1 -1
- package/client/dist/assets/{agentRuntime-B-myNBUP.js → agentRuntime-es2ymSl-.js} +1 -1
- package/client/dist/assets/{formatDistanceToNow-NVM6rK3i.js → formatDistanceToNow-CdN5lTyD.js} +1 -1
- package/client/dist/assets/{getTimezoneOffsetInMilliseconds-ZHg7WpdH.js → getTimezoneOffsetInMilliseconds-62h40I4t.js} +1 -1
- package/client/dist/assets/index-BgbCbIua.css +2 -0
- package/client/dist/assets/{index-Culan6y7.js → index-CECj3joE.js} +7 -7
- package/client/dist/assets/{jira-api-Bl8xEIpk.js → jira-api-C_D_RDhl.js} +1 -1
- package/client/dist/assets/{project-repositories-CvJf1a6H.js → project-repositories-Be0CWklo.js} +1 -1
- package/client/dist/assets/{spending-BfjSJjBd.js → spending-eWiZGhC_.js} +1 -1
- package/client/dist/assets/{useDesktop-C5JVBeur.js → useDesktop-C0mRIlHT.js} +1 -1
- package/client/dist/assets/{useRuntimeRuns-DohBmeg8.js → useRuntimeRuns-B1a6GChu.js} +1 -1
- package/client/dist/assets/{useSharedWebSocket-CNOvmgTr.js → useSharedWebSocket-CcsE5986.js} +2 -2
- package/client/dist/index.html +16 -16
- package/docs/internals/core-runtime-updates.md +3 -3
- package/docs/internals/desktop-owned-workflows.md +10 -0
- package/docs/internals/programmatic-agent-runtime.md +16 -0
- package/docs/internals/source-map.md +4 -1
- package/package.json +1 -1
- package/server/dist/mcp/tools/loops.js +1 -1
- package/server/dist/modules/agent-runtime/runtime/agent-runtime-bridge.js +13 -3
- package/server/dist/modules/delivery/runtime/rail-isolated-launch.js +1 -1
- package/server/dist/modules/loops/runtime/loop-implement-recipe.js +13 -6
- package/server/dist/modules/loops/runtime/loop-turn-limits.js +64 -0
- package/server/dist/modules/loops/runtime/loops-router.js +3 -1
- package/server/dist/modules/missions/runtime/agent-operator-prompt.js +8 -0
- package/server/dist/schemas/agent-runtime.schema.json +1 -1
- package/client/dist/assets/LoopBuilderPage-5M7IypEP.js +0 -1
- package/client/dist/assets/index-D1v33giW.css +0 -2
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-DxrmGfoq.js","assets/rolldown-runtime-CNC7AqOf.js","assets/preload-helper-Czpn1I53.js","assets/editor.api2-4ndOupAA.js","assets/editor-Br_kD0ds.css","assets/monaco.contribution-Bt92R3Vw.js","assets/workers-uOo7WLaa.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{t as r}from"./react-dom-DDD8FYaU.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{f as a,u as o}from"./chunk-OB3PAWPO-B1EMk45A.js";import{r as s}from"./useSharedWebSocket-CNOvmgTr.js";import{n as c,t as l}from"./createLucideIcon-DtODIU64.js";import{a as u,i as d,r as f,s as p}from"./useDesktop-C5JVBeur.js";import{J as m,V as h,Y as g,et as _,n as v,q as y}from"./TicketDetailModalContext-BoafEcm4.js";import{p as b}from"./provider-capabilities-lePfeT_Y.js";import{n as x}from"./save-LmPSfsvZ.js";import{t as S}from"./chevron-up-6EFqEHBj.js";import{n as C,t as w}from"./file-text-C0blZHLh.js";import{t as T}from"./external-link-CZ6Q-v1-.js";import{t as E}from"./loader-circle-BqV9xYGf.js";import{t as D}from"./search-BDVp3fkH.js";import{t as O}from"./sparkles-CCfUdFGY.js";import{t as k}from"./x-Bu7X_eR2.js";import{F as A,P as j}from"./dialog-DtdR05v1.js";import{t as M}from"./utils-BC4DHlz2.js";import{n as N,t as P}from"./lib-DWJfei6y.js";import{n as ee,t as F}from"./project-repositories-CvJf1a6H.js";import{Bt as I,Dt as te,Tt as L,Ut as R,Vt as ne,Xt as re,an as z}from"./index-Culan6y7.js";var B={name:`file-search`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]};B.node;var ie=l(B),V={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};V.node;var ae=l(V),H={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};H.node;var oe=l(H),U={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};U.node;var W=l(U),G={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};G.node;var K=l(G),se={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};se.node;var ce=l(se),q=e(t(),1),le=e(r(),1);function ue(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function J(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function de(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var fe=(e,t)=>Math.abs(e-t)<1.01,pe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},me,Y=()=>{if(me!==void 0)return me;if(typeof navigator>`u`)return me=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return me=!0;let e=navigator.maxTouchPoints;return me=navigator.platform===`MacIntel`&&e!==void 0&&e>0},he=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ge=e=>e,X=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},_e=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(he(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(he(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},ve={passive:!0},ye=typeof window>`u`||`onscrollend`in window,be=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&ye,o=0,s=a?null:pe(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,ve),a&&r.addEventListener(`scrollend`,u,ve),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},xe=(e,t)=>be(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Se=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Ce=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},we=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ge,rangeExtractor:X,onChange:()=>{},measureElement:Se,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=J(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Y()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,ve),e.addEventListener(`touchend`,n,ve),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=J(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=J(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=ue(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=J(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Ee({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=J(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(Y()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=J(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return de(t[Te(0,t.length-1,r?e=>n[e*2]:e=>de(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&fe(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Te=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Ee({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Te(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var De=typeof document<`u`?q.useLayoutEffect:q.useEffect;function Oe({useFlushSync:e=!0,...t}){let n=q.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,le.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=q.useState(()=>new we(r));return i.setOptions(r),De(()=>i._didMount(),[]),De(()=>i._willUpdate()),i}function ke(e){return Oe({observeElementRect:_e,observeElementOffset:xe,scrollToFn:Ce,...e})}var Ae=(0,q.createContext)(null);function Z(){return(0,q.useContext)(Ae)??{apiBase:u()}}function je(e,t){return e?e===t.repositoryId:!t.repositoryId||t.isPrimary===!0}var Q=n(),Me=e=>`specrails-desktop:code-tree-filter:${e}`,Ne=e=>`specrails-desktop:code-tree-collapsed:${e}`;function Pe(e){return e.split(`/`).length-1}function Fe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function Ie(e){return e?e.length>10?e.slice(0,10):e:null}function Le(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function Re(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function ze({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:r}){let{t:i}=c(`code`),a=(0,q.useId)(),o=Z(),{apiBase:l,repositoryId:u,repositoryPath:p}=o,{activeProjectId:m}=f(),{openTicketDetail:h}=v(),{registerHandler:g,unregisterHandler:_}=s(),[b,x]=(0,q.useState)(()=>{if(!m)return`all`;try{let e=localStorage.getItem(Me(`${m}:${u??`primary`}`));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`all`});(0,q.useEffect)(()=>{if(m)try{localStorage.setItem(Me(`${m}:${u??`primary`}`),b)}catch{}},[b,m,u]),(0,q.useEffect)(()=>{(n||r)&&x(`touched-by-ai`)},[n,r]);let[S,w]=(0,q.useState)(()=>{if(!m)return new Set;try{let e=localStorage.getItem(Ne(`${m}:${u??`primary`}`));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,q.useEffect)(()=>{if(m)try{localStorage.setItem(Ne(`${m}:${u??`primary`}`),JSON.stringify([...S]))}catch{}},[S,m,u]);let T=(0,q.useCallback)(e=>{w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),E=(0,q.useCallback)(()=>{w(new Set)},[]),D=b===`touched-by-ai`?`${n??`all-jobs`}:${r??`all-specs`}`:`all`,{data:O,refresh:k,isFirstLoad:A,isLoading:j,error:N}=d({namespace:`code-tree-v2:${JSON.stringify([u,p,b,D])}`,projectId:m,initialValue:{entries:[],partial:!1},fetcher:(0,q.useCallback)(async({signal:e})=>{let t=new Map,i=new Set,a=null,o=!1;for(let s=0;s<20;s+=1){e.throwIfAborted();let s=new URLSearchParams({withProvenance:`1`,filter:b});b===`touched-by-ai`&&n&&s.set(`jobId`,n),b===`touched-by-ai`&&typeof r==`number`&&s.set(`ticketId`,String(r)),a&&s.set(`cursor`,a);let c=await fetch(`${l}/code/tree?${s}`,{signal:e});if(!c.ok)throw Error(`tree_request_failed`);let u=await c.json();if(e.throwIfAborted(),!Array.isArray(u.entries))throw Error(`invalid_tree_response`);for(let e of u.entries)t.set(e.path,e);if(o||=u.truncated===!0,a=u.nextCursor??null,!a)break;if(i.has(a)||t.size>=2e4){o=!0;break}i.add(a)}return{entries:[...t.values()].slice(0,2e4),partial:o||!!a}},[b,n,r,l])}),P=O.entries,ee=(0,q.useRef)(m);(0,q.useEffect)(()=>{ee.current=m},[m]),(0,q.useEffect)(()=>{if(!m)return;let e=`code-tree-${a}-${m}-${u??`primary`}`,t;return g(e,e=>{let n=e;n.projectId!==ee.current||!je(n.repositoryId,o)||n.type===`file.provenance_updated`&&(clearTimeout(t),t=setTimeout(()=>{k()},150))}),()=>{clearTimeout(t),_(e)}},[l,u,m,g,_,k,a]);let F=(0,q.useRef)(null),L=(0,q.useMemo)(()=>(P??[]).filter(e=>!Re(e.path,S)),[P,S]),z=(0,q.useCallback)(()=>{w(new Set((P??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[P]),B=ke({count:L.length,getScrollElement:()=>F.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),ie=(0,q.useId)(),[V,ae]=(0,q.useState)(t),H=Math.max(0,L.findIndex(e=>e.path===V));(0,q.useEffect)(()=>{t&&(ae(t),w(e=>{let n=new Set(e),r=t.split(`/`);for(let e=1;e<r.length;e++)n.delete(r.slice(0,e).join(`/`));return n}))},[t]);let oe=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t||oe.current===t)return;let e=L.findIndex(e=>e.path===t);e>=0&&(B.scrollToIndex(e,{align:`auto`}),oe.current=t)},[t,L,B]);let U=(t,n)=>{let r=L[n];if(!r)return;let i=n;switch(t.key){case`ArrowDown`:i=Math.min(L.length-1,n+1);break;case`ArrowUp`:i=Math.max(0,n-1);break;case`Home`:i=0;break;case`End`:i=L.length-1;break;case`ArrowRight`:r.kind===`dir`&&S.has(r.path)?T(r.path):r.kind===`dir`&&(i=Math.min(L.length-1,n+1));break;case`ArrowLeft`:if(r.kind===`dir`&&!S.has(r.path))T(r.path);else{let e=r.path.split(`/`).slice(0,-1).join(`/`),t=L.findIndex(t=>t.path===e);t>=0&&(i=t)}break;case`Enter`:case` `:r.kind===`dir`?T(r.path):e(r.path);break;default:return}t.preventDefault(),t.stopPropagation(),ae(L[i].path),i!==n&&B.scrollToIndex(i,{align:`auto`})},W=L.length===0,G=(0,q.useMemo)(()=>(P??[]).filter(e=>e.kind===`file`).length,[P]);return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,Q.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>x(`touched-by-ai`),className:M(`px-2 py-1 rounded-md transition-colors`,b===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":b===`touched-by-ai`,children:i(n?`tree.jobFiles`:r?`tree.specFiles`:`tree.touchedByAi`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>x(`all`),className:M(`px-2 py-1 rounded-md transition-colors`,b===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":b===`all`,children:i(`tree.allFiles`)}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{k()},disabled:j,"aria-label":i(`explore.refresh`),title:i(`explore.refresh`),className:`rounded p-1 text-muted-foreground hover:bg-muted disabled:opacity-40`,children:(0,Q.jsx)(te,{className:`h-3.5 w-3.5 ${j?`animate-spin`:``}`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:z,title:i(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.collapseAll`),children:(0,Q.jsx)(C,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:E,title:i(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.expandAll`),children:(0,Q.jsx)(re,{className:`w-3.5 h-3.5`})})]}),b===`touched-by-ai`&&G>0&&(0,Q.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,Q.jsx)(`span`,{children:i(`tree.touchedCount`,{count:G})})})]}),N&&(0,Q.jsxs)(`div`,{role:`alert`,className:`space-y-1 border-b border-border p-3 text-xs`,children:[(0,Q.jsx)(`p`,{children:i(`tree.loadFailed`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{k()},className:`text-accent-primary underline`,children:i(`explore.retry`)})]}),O.partial&&(0,Q.jsx)(`p`,{role:`status`,className:`border-b border-border p-3 text-xs text-amber-600 dark:text-amber-400`,children:i(`tree.partial`)}),W&&N?null:W&&A?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:i(`tree.loadingFiles`)})}):W&&b===`touched-by-ai`?(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`tree.emptyTouched`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>x(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:i(`tree.showAllFiles`)})]}):W?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:i(`tree.noFiles`)}):(0,Q.jsx)(`div`,{ref:F,className:`min-h-0 flex-1 overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent-primary/50`,"data-testid":`file-tree-scroller`,role:`tree`,tabIndex:0,"aria-label":i(`explore.files`),"aria-activedescendant":L[H]?`${ie}-${H}`:void 0,onKeyDown:e=>{e.target===e.currentTarget&&U(e,H)},children:(0,Q.jsx)(`div`,{style:{height:B.getTotalSize(),position:`relative`,width:`100%`},children:B.getVirtualItems().map(n=>{let r=L[n.index],a=Pe(r.path)*12,o=r.kind===`file`&&r.path===t,s=r.provenance?.createdByTicketId,c=r.provenance?.modifiedByTicketIds??[],l=r.provenance?.latest??null,u=Ie(l?.jobId),d=Le(l?.kind),f=r.kind===`dir`,p=f&&S.has(r.path),m=r.provenance?.touchedFileCount??0;return(0,Q.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:M(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,o&&`bg-accent-primary/10 text-foreground`,r.path===V&&`ring-1 ring-inset ring-accent-primary/30`),onClick:()=>{ae(r.path),F.current?.focus({preventScroll:!0}),f?T(r.path):e(r.path)},onKeyDown:e=>{e.target===e.currentTarget&&U(e,n.index)},role:`treeitem`,id:`${ie}-${n.index}`,tabIndex:-1,"aria-level":Pe(r.path)+1,"aria-selected":o,title:r.path,"aria-expanded":f?!p:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,Q.jsxs)(`span`,{style:{paddingLeft:a},className:`flex items-center gap-1 min-w-0 flex-1`,children:[f?(0,Q.jsxs)(Q.Fragment,{children:[p?(0,Q.jsx)(C,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,Q.jsx)(re,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),p?(0,Q.jsx)(I,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,Q.jsx)(ne,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,Q.jsx)(R,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,Q.jsx)(`span`,{className:`truncate ml-0.5`,children:Fe(r.path)})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[f&&m>0&&(0,Q.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:i(`tree.folderTouched`,{count:m}),children:m}),!f&&d&&(0,Q.jsx)(`span`,{className:M(`h-1.5 w-1.5 rounded-full`,l?.kind===`created`&&`bg-accent-success`,l?.kind===`modified`&&`bg-accent-info`,l?.kind===`deleted`&&`bg-destructive`),title:l?.kind===`created`?i(`tree.latestTitleCreated`):l?.kind===`deleted`?i(`tree.latestTitleDeleted`):i(`tree.latestTitleModified`),children:(0,Q.jsx)(`span`,{className:`sr-only`,children:i(`action.${d}`)})}),!f&&u&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center px-0.5 text-muted-foreground`,title:i(`tree.jobTitle`,{jobId:l?.jobId??``}),children:[(0,Q.jsx)(y,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:u})]}),!f&&typeof s==`number`&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h(s)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${s}`,title:i(`tree.createdBySpec`,{id:s}),children:[`#`,s]}),!f&&c.slice(0,2).map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),h(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:i(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},r.path)})})})]})}function Be(e){return new Worker(`/assets/editor.worker-tytyn86m.js`,{name:e?.name})}function Ve(e){return new Worker(`/assets/json.worker-Oa9UrkKE.js`,{name:e?.name})}function He(e){return new Worker(`/assets/css.worker-yKcq13f2.js`,{name:e?.name})}function Ue(e){return new Worker(`/assets/html.worker-DSJ9zmd7.js`,{name:e?.name})}function We(e){return new Worker(`/assets/ts.worker-BtjBFNHX.js`,{name:e?.name})}var Ge=!1;function Ke(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function $(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=Ke(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function qe(e){return`specrails-${e}`}function Je(e,t){let n=qe(t.id),r=t.xterm,i=$(r.background),a=$(r.foreground),o=$(r.brightBlack),s=$(r.magenta),c=$(r.yellow),l=$(r.cyan),u=$(r.blue),d=$(r.green),f=$(r.brightBlack),p=$(r.brightCyan),m=$(r.red),h=$(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":$(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":$(r.black),"editor.lineHighlightBorder":$(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":$(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function Ye(){Ge||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new Ve;case`css`:case`scss`:case`less`:return new He;case`html`:case`handlebars`:case`razor`:return new Ue;case`typescript`:case`javascript`:return new We;default:return new Be}}},!0)}function Xe({content:e,language:t,initialLine:n}){let{t:r}=c(`code`),a=z(),o=(0,q.useRef)(null),s=(0,q.useRef)(null),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(0),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(``),b=(0,q.useRef)({content:e,language:t,theme:a,initialLine:n,wrap:g});b.current={content:e,language:t,theme:a,initialLine:n,wrap:g};let x=(e,t=!1)=>{let n=s.current,r=n?.getModel();if(!n||!r||!Number.isFinite(e)||e<1)return;let i=Math.min(r.getLineCount(),Math.max(1,Math.floor(e)));n.setSelection({startLineNumber:i,startColumn:1,endLineNumber:i,endColumn:r.getLineMaxColumn(i)}),n.revealLineInCenter(i),t&&n.focus()};return(0,q.useEffect)(()=>{let e=!1;return d(!1),p(!1),Ye(),i(()=>import(`./editor.main-DxrmGfoq.js`).then(t=>{if(e||!o.current)return;l.current=t;let n=b.current,r=t.editor.create(o.current,{value:n.content,language:n.language,readOnly:!0,domReadOnly:!0,theme:Je(t,n.theme),minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,renderValidationDecorations:`off`,wordWrap:n.wrap?`on`:`off`,fontSize:13});s.current=r,x(n.initialLine),d(!0)}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||p(!0)}),()=>{e=!0;let t=s.current?.getModel();s.current?.dispose(),t?.dispose(),s.current=null,l.current=null}},[m]),(0,q.useEffect)(()=>{let t=s.current;t&&t.getValue()!==e&&t.setValue(e)},[e]),(0,q.useEffect)(()=>{let e=s.current?.getModel();e&&l.current&&l.current.editor.setModelLanguage(e,t)},[t]),(0,q.useEffect)(()=>{let e=l.current;e&&e.editor.setTheme(Je(e,a))},[a]),(0,q.useEffect)(()=>{x(n)},[n,u]),(0,q.useEffect)(()=>{s.current?.updateOptions({wordWrap:g?`on`:`off`})},[g]),(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/20 px-3 py-1 text-xs`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:!u,className:`rounded px-2 py-1 hover:bg-muted disabled:opacity-50`,onClick:()=>{s.current?.getAction(`actions.find`)?.run()},children:r(`reader.find`,{defaultValue:`Find in file`})}),(0,Q.jsx)(`button`,{type:`button`,disabled:!u,"aria-pressed":g,className:`rounded px-2 py-1 hover:bg-muted disabled:opacity-50`,onClick:()=>_(e=>!e),children:r(`reader.wrap`,{defaultValue:`Wrap lines`})}),(0,Q.jsxs)(`form`,{className:`ml-auto flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),x(Number(v),!0)},children:[(0,Q.jsx)(`input`,{type:`number`,min:1,step:1,"aria-label":r(`reader.line`,{defaultValue:`Line number`}),placeholder:`#`,title:r(`reader.line`,{defaultValue:`Line number`}),value:v,onChange:e=>y(e.target.value),className:`w-28 rounded border border-border bg-background px-2 py-1`}),(0,Q.jsx)(`button`,{type:`submit`,disabled:!u||!Number.isInteger(Number(v))||Number(v)<1,className:`rounded px-2 py-1 hover:bg-muted disabled:opacity-50`,children:r(`reader.go`,{defaultValue:`Go`})})]})]}),f?(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,Q.jsx)(`span`,{children:r(`monaco.loadFailed`)}),(0,Q.jsx)(`button`,{onClick:()=>h(e=>e+1),className:`rounded border px-3 py-1`,children:r(`reader.retry`,{defaultValue:`Retry`})})]}):(0,Q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[!u&&(0,Q.jsx)(`div`,{role:`status`,className:`absolute inset-0 flex items-center justify-center text-sm text-muted-foreground`,children:r(`reader.loading`,{defaultValue:`Loading source viewer…`})}),(0,Q.jsx)(`div`,{ref:o,className:`h-full w-full`,"data-testid":`monaco-host`})]})]})}function Ze(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Qe({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:s}=c(`code`),{openTicketDetail:l}=v();if(!t)return(0,Q.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Q.jsx)(S,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let u=Ze(t.generatedAt,s.language),d=t.generatedBy?.model??t.model,f=t.generatedAt&&Number.isFinite(Date.parse(t.generatedAt))?new Date(t.generatedAt).toLocaleString(s.language):void 0,p=t.triggeredBy?.ticketId,m=t.triggeredBy?.modifiedTicketIds??[];return(0,Q.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,Q.jsx)(`span`,{className:M(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:o(`summary.stale`)}),r&&(0,Q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,Q.jsx)(`p`,{className:`text-sm text-foreground mt-1 whitespace-pre-wrap break-words`,children:t.summary}),t.generatedBy?.truncated&&(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-accent-warning`,children:o(`reader.summaryPartial`,{defaultValue:`Generated from a partial source snapshot. This summary may not cover the entire file.`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[d&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:o(`story.explainedBy`,{model:d})}),typeof p==`number`&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>l(p),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,p]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),u&&(0,Q.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:t.generatedAt,title:f,children:u})]})]}),a&&(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Q.jsx)(S,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function $e({content:e}){return(0,Q.jsx)(N,{remarkPlugins:[P],children:e})}var et=2e3,tt=256e3;function nt({path:e,jobId:t}){let{activeProjectId:n}=f(),r=Z(),i=JSON.stringify([n,r.apiBase,r.repositoryPath,e,t]);return(0,Q.jsx)(rt,{path:e,jobId:t},i)}function rt({path:e,jobId:t}){let{t:n}=c(`code`),{apiBase:r}=Z(),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(`loading`),[l,u]=(0,q.useState)(0);(0,q.useEffect)(()=>{let n=new AbortController;s(`loading`);let i=new URLSearchParams({path:e,jobId:t});return fetch(`${r}/code/diff?${i}`,{signal:n.signal}).then(async e=>{if(e.status===404){n.signal.aborted||s(`missing`);return}if(!e.ok)throw Error(`Diff request failed`);let t=await e.json();if(typeof t.patch!=`string`)throw Error(`Invalid patch response`);n.signal.aborted||(a({patch:t.patch,truncated:t.truncated===!0}),s(t.patch?`ready`:`missing`))}).catch(()=>{n.signal.aborted||s(`failed`)}),()=>n.abort()},[r,e,t,l]);let d=(i?.patch??``).slice(0,tt).split(`
|
|
2
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{t as r}from"./react-dom-DDD8FYaU.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{f as a,u as o}from"./chunk-OB3PAWPO-B1EMk45A.js";import{r as s}from"./useSharedWebSocket-CcsE5986.js";import{n as c,t as l}from"./createLucideIcon-DtODIU64.js";import{a as u,i as d,r as f,s as p}from"./useDesktop-C0mRIlHT.js";import{J as m,V as h,Y as g,et as _,n as v,q as y}from"./TicketDetailModalContext-DiPngt2g.js";import{p as b}from"./provider-capabilities-lePfeT_Y.js";import{n as x}from"./save-LmPSfsvZ.js";import{t as S}from"./chevron-up-6EFqEHBj.js";import{n as C,t as w}from"./file-text-C0blZHLh.js";import{t as T}from"./external-link-CZ6Q-v1-.js";import{t as E}from"./loader-circle-BqV9xYGf.js";import{t as D}from"./search-BDVp3fkH.js";import{t as O}from"./sparkles-CCfUdFGY.js";import{t as k}from"./x-Bu7X_eR2.js";import{F as A,P as j}from"./dialog-DtdR05v1.js";import{t as M}from"./utils-BC4DHlz2.js";import{n as N,t as P}from"./lib-DWJfei6y.js";import{n as ee,t as F}from"./project-repositories-Be0CWklo.js";import{Bt as I,Dt as te,Tt as L,Ut as R,Vt as ne,Xt as re,an as z}from"./index-CECj3joE.js";var B={name:`file-search`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`circle`,{cx:`11.5`,cy:`14.5`,r:`2.5`,key:`1bq0ko`}],[`path`,{d:`M13.3 16.3 15 18`,key:`2quom7`}]]};B.node;var ie=l(B),V={name:`files`,size:24,node:[[`path`,{d:`M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8`,key:`14sh0y`}],[`path`,{d:`M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z`,key:`1970lx`}],[`path`,{d:`M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1`,key:`l4dndm`}]]};V.node;var ae=l(V),H={name:`folder-search`,size:24,node:[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]};H.node;var oe=l(H),U={name:`funnel`,size:24,node:[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]],aliases:[`filter`]};U.node;var W=l(U),G={name:`panel-left-close`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]],aliases:[`sidebar-close`]};G.node;var K=l(G),se={name:`panel-left-open`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]],aliases:[`sidebar-open`]};se.node;var ce=l(se),q=e(t(),1),le=e(r(),1);function ue(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function J(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function de(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var fe=(e,t)=>Math.abs(e-t)<1.01,pe=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},me,Y=()=>{if(me!==void 0)return me;if(typeof navigator>`u`)return me=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return me=!0;let e=navigator.maxTouchPoints;return me=navigator.platform===`MacIntel`&&e!==void 0&&e>0},he=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ge=e=>e,X=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},_e=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(he(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(he(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},ve={passive:!0},ye=typeof window>`u`||`onscrollend`in window,be=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&ye,o=0,s=a?null:pe(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,ve),a&&r.addEventListener(`scrollend`,u,ve),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},xe=(e,t)=>be(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Se=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Ce=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},we=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:ge,rangeExtractor:X,onChange:()=>{},measureElement:Se,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=J(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Y()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,ve),e.addEventListener(`touchend`,n,ve),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=J(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=J(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=ue(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=J(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?Ee({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=J(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(Y()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=J(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return de(t[Te(0,t.length-1,r?e=>n[e*2]:e=>de(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&fe(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Te=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Ee({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Te(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var De=typeof document<`u`?q.useLayoutEffect:q.useEffect;function Oe({useFlushSync:e=!0,...t}){let n=q.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,le.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=q.useState(()=>new we(r));return i.setOptions(r),De(()=>i._didMount(),[]),De(()=>i._willUpdate()),i}function ke(e){return Oe({observeElementRect:_e,observeElementOffset:xe,scrollToFn:Ce,...e})}var Ae=(0,q.createContext)(null);function Z(){return(0,q.useContext)(Ae)??{apiBase:u()}}function je(e,t){return e?e===t.repositoryId:!t.repositoryId||t.isPrimary===!0}var Q=n(),Me=e=>`specrails-desktop:code-tree-filter:${e}`,Ne=e=>`specrails-desktop:code-tree-collapsed:${e}`;function Pe(e){return e.split(`/`).length-1}function Fe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function Ie(e){return e?e.length>10?e.slice(0,10):e:null}function Le(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function Re(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function ze({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:r}){let{t:i}=c(`code`),a=(0,q.useId)(),o=Z(),{apiBase:l,repositoryId:u,repositoryPath:p}=o,{activeProjectId:m}=f(),{openTicketDetail:h}=v(),{registerHandler:g,unregisterHandler:_}=s(),[b,x]=(0,q.useState)(()=>{if(!m)return`all`;try{let e=localStorage.getItem(Me(`${m}:${u??`primary`}`));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`all`});(0,q.useEffect)(()=>{if(m)try{localStorage.setItem(Me(`${m}:${u??`primary`}`),b)}catch{}},[b,m,u]),(0,q.useEffect)(()=>{(n||r)&&x(`touched-by-ai`)},[n,r]);let[S,w]=(0,q.useState)(()=>{if(!m)return new Set;try{let e=localStorage.getItem(Ne(`${m}:${u??`primary`}`));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,q.useEffect)(()=>{if(m)try{localStorage.setItem(Ne(`${m}:${u??`primary`}`),JSON.stringify([...S]))}catch{}},[S,m,u]);let T=(0,q.useCallback)(e=>{w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),E=(0,q.useCallback)(()=>{w(new Set)},[]),D=b===`touched-by-ai`?`${n??`all-jobs`}:${r??`all-specs`}`:`all`,{data:O,refresh:k,isFirstLoad:A,isLoading:j,error:N}=d({namespace:`code-tree-v2:${JSON.stringify([u,p,b,D])}`,projectId:m,initialValue:{entries:[],partial:!1},fetcher:(0,q.useCallback)(async({signal:e})=>{let t=new Map,i=new Set,a=null,o=!1;for(let s=0;s<20;s+=1){e.throwIfAborted();let s=new URLSearchParams({withProvenance:`1`,filter:b});b===`touched-by-ai`&&n&&s.set(`jobId`,n),b===`touched-by-ai`&&typeof r==`number`&&s.set(`ticketId`,String(r)),a&&s.set(`cursor`,a);let c=await fetch(`${l}/code/tree?${s}`,{signal:e});if(!c.ok)throw Error(`tree_request_failed`);let u=await c.json();if(e.throwIfAborted(),!Array.isArray(u.entries))throw Error(`invalid_tree_response`);for(let e of u.entries)t.set(e.path,e);if(o||=u.truncated===!0,a=u.nextCursor??null,!a)break;if(i.has(a)||t.size>=2e4){o=!0;break}i.add(a)}return{entries:[...t.values()].slice(0,2e4),partial:o||!!a}},[b,n,r,l])}),P=O.entries,ee=(0,q.useRef)(m);(0,q.useEffect)(()=>{ee.current=m},[m]),(0,q.useEffect)(()=>{if(!m)return;let e=`code-tree-${a}-${m}-${u??`primary`}`,t;return g(e,e=>{let n=e;n.projectId!==ee.current||!je(n.repositoryId,o)||n.type===`file.provenance_updated`&&(clearTimeout(t),t=setTimeout(()=>{k()},150))}),()=>{clearTimeout(t),_(e)}},[l,u,m,g,_,k,a]);let F=(0,q.useRef)(null),L=(0,q.useMemo)(()=>(P??[]).filter(e=>!Re(e.path,S)),[P,S]),z=(0,q.useCallback)(()=>{w(new Set((P??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[P]),B=ke({count:L.length,getScrollElement:()=>F.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),ie=(0,q.useId)(),[V,ae]=(0,q.useState)(t),H=Math.max(0,L.findIndex(e=>e.path===V));(0,q.useEffect)(()=>{t&&(ae(t),w(e=>{let n=new Set(e),r=t.split(`/`);for(let e=1;e<r.length;e++)n.delete(r.slice(0,e).join(`/`));return n}))},[t]);let oe=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t||oe.current===t)return;let e=L.findIndex(e=>e.path===t);e>=0&&(B.scrollToIndex(e,{align:`auto`}),oe.current=t)},[t,L,B]);let U=(t,n)=>{let r=L[n];if(!r)return;let i=n;switch(t.key){case`ArrowDown`:i=Math.min(L.length-1,n+1);break;case`ArrowUp`:i=Math.max(0,n-1);break;case`Home`:i=0;break;case`End`:i=L.length-1;break;case`ArrowRight`:r.kind===`dir`&&S.has(r.path)?T(r.path):r.kind===`dir`&&(i=Math.min(L.length-1,n+1));break;case`ArrowLeft`:if(r.kind===`dir`&&!S.has(r.path))T(r.path);else{let e=r.path.split(`/`).slice(0,-1).join(`/`),t=L.findIndex(t=>t.path===e);t>=0&&(i=t)}break;case`Enter`:case` `:r.kind===`dir`?T(r.path):e(r.path);break;default:return}t.preventDefault(),t.stopPropagation(),ae(L[i].path),i!==n&&B.scrollToIndex(i,{align:`auto`})},W=L.length===0,G=(0,q.useMemo)(()=>(P??[]).filter(e=>e.kind===`file`).length,[P]);return(0,Q.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,Q.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>x(`touched-by-ai`),className:M(`px-2 py-1 rounded-md transition-colors`,b===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":b===`touched-by-ai`,children:i(n?`tree.jobFiles`:r?`tree.specFiles`:`tree.touchedByAi`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>x(`all`),className:M(`px-2 py-1 rounded-md transition-colors`,b===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":b===`all`,children:i(`tree.allFiles`)}),(0,Q.jsx)(`div`,{className:`flex-1`}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{k()},disabled:j,"aria-label":i(`explore.refresh`),title:i(`explore.refresh`),className:`rounded p-1 text-muted-foreground hover:bg-muted disabled:opacity-40`,children:(0,Q.jsx)(te,{className:`h-3.5 w-3.5 ${j?`animate-spin`:``}`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:z,title:i(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.collapseAll`),children:(0,Q.jsx)(C,{className:`w-3.5 h-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:E,title:i(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":i(`tree.expandAll`),children:(0,Q.jsx)(re,{className:`w-3.5 h-3.5`})})]}),b===`touched-by-ai`&&G>0&&(0,Q.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,Q.jsx)(`span`,{children:i(`tree.touchedCount`,{count:G})})})]}),N&&(0,Q.jsxs)(`div`,{role:`alert`,className:`space-y-1 border-b border-border p-3 text-xs`,children:[(0,Q.jsx)(`p`,{children:i(`tree.loadFailed`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{k()},className:`text-accent-primary underline`,children:i(`explore.retry`)})]}),O.partial&&(0,Q.jsx)(`p`,{role:`status`,className:`border-b border-border p-3 text-xs text-amber-600 dark:text-amber-400`,children:i(`tree.partial`)}),W&&N?null:W&&A?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:i(`tree.loadingFiles`)})}):W&&b===`touched-by-ai`?(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`tree.emptyTouched`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>x(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:i(`tree.showAllFiles`)})]}):W?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:i(`tree.noFiles`)}):(0,Q.jsx)(`div`,{ref:F,className:`min-h-0 flex-1 overflow-auto outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent-primary/50`,"data-testid":`file-tree-scroller`,role:`tree`,tabIndex:0,"aria-label":i(`explore.files`),"aria-activedescendant":L[H]?`${ie}-${H}`:void 0,onKeyDown:e=>{e.target===e.currentTarget&&U(e,H)},children:(0,Q.jsx)(`div`,{style:{height:B.getTotalSize(),position:`relative`,width:`100%`},children:B.getVirtualItems().map(n=>{let r=L[n.index],a=Pe(r.path)*12,o=r.kind===`file`&&r.path===t,s=r.provenance?.createdByTicketId,c=r.provenance?.modifiedByTicketIds??[],l=r.provenance?.latest??null,u=Ie(l?.jobId),d=Le(l?.kind),f=r.kind===`dir`,p=f&&S.has(r.path),m=r.provenance?.touchedFileCount??0;return(0,Q.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:M(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,o&&`bg-accent-primary/10 text-foreground`,r.path===V&&`ring-1 ring-inset ring-accent-primary/30`),onClick:()=>{ae(r.path),F.current?.focus({preventScroll:!0}),f?T(r.path):e(r.path)},onKeyDown:e=>{e.target===e.currentTarget&&U(e,n.index)},role:`treeitem`,id:`${ie}-${n.index}`,tabIndex:-1,"aria-level":Pe(r.path)+1,"aria-selected":o,title:r.path,"aria-expanded":f?!p:void 0,"data-testid":`file-tree-row-${r.path}`,children:[(0,Q.jsxs)(`span`,{style:{paddingLeft:a},className:`flex items-center gap-1 min-w-0 flex-1`,children:[f?(0,Q.jsxs)(Q.Fragment,{children:[p?(0,Q.jsx)(C,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,Q.jsx)(re,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),p?(0,Q.jsx)(I,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,Q.jsx)(ne,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,Q.jsx)(R,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,Q.jsx)(`span`,{className:`truncate ml-0.5`,children:Fe(r.path)})]}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[f&&m>0&&(0,Q.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:i(`tree.folderTouched`,{count:m}),children:m}),!f&&d&&(0,Q.jsx)(`span`,{className:M(`h-1.5 w-1.5 rounded-full`,l?.kind===`created`&&`bg-accent-success`,l?.kind===`modified`&&`bg-accent-info`,l?.kind===`deleted`&&`bg-destructive`),title:l?.kind===`created`?i(`tree.latestTitleCreated`):l?.kind===`deleted`?i(`tree.latestTitleDeleted`):i(`tree.latestTitleModified`),children:(0,Q.jsx)(`span`,{className:`sr-only`,children:i(`action.${d}`)})}),!f&&u&&(0,Q.jsxs)(`span`,{className:`inline-flex items-center px-0.5 text-muted-foreground`,title:i(`tree.jobTitle`,{jobId:l?.jobId??``}),children:[(0,Q.jsx)(y,{className:`h-3 w-3`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:u})]}),!f&&typeof s==`number`&&(0,Q.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),h(s)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${s}`,title:i(`tree.createdBySpec`,{id:s}),children:[`#`,s]}),!f&&c.slice(0,2).map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),h(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:i(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},r.path)})})})]})}function Be(e){return new Worker(`/assets/editor.worker-tytyn86m.js`,{name:e?.name})}function Ve(e){return new Worker(`/assets/json.worker-Oa9UrkKE.js`,{name:e?.name})}function He(e){return new Worker(`/assets/css.worker-yKcq13f2.js`,{name:e?.name})}function Ue(e){return new Worker(`/assets/html.worker-DSJ9zmd7.js`,{name:e?.name})}function We(e){return new Worker(`/assets/ts.worker-BtjBFNHX.js`,{name:e?.name})}var Ge=!1;function Ke(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function $(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=Ke(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function qe(e){return`specrails-${e}`}function Je(e,t){let n=qe(t.id),r=t.xterm,i=$(r.background),a=$(r.foreground),o=$(r.brightBlack),s=$(r.magenta),c=$(r.yellow),l=$(r.cyan),u=$(r.blue),d=$(r.green),f=$(r.brightBlack),p=$(r.brightCyan),m=$(r.red),h=$(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":$(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":$(r.black),"editor.lineHighlightBorder":$(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":$(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function Ye(){Ge||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new Ve;case`css`:case`scss`:case`less`:return new He;case`html`:case`handlebars`:case`razor`:return new Ue;case`typescript`:case`javascript`:return new We;default:return new Be}}},!0)}function Xe({content:e,language:t,initialLine:n}){let{t:r}=c(`code`),a=z(),o=(0,q.useRef)(null),s=(0,q.useRef)(null),l=(0,q.useRef)(null),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(0),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(``),b=(0,q.useRef)({content:e,language:t,theme:a,initialLine:n,wrap:g});b.current={content:e,language:t,theme:a,initialLine:n,wrap:g};let x=(e,t=!1)=>{let n=s.current,r=n?.getModel();if(!n||!r||!Number.isFinite(e)||e<1)return;let i=Math.min(r.getLineCount(),Math.max(1,Math.floor(e)));n.setSelection({startLineNumber:i,startColumn:1,endLineNumber:i,endColumn:r.getLineMaxColumn(i)}),n.revealLineInCenter(i),t&&n.focus()};return(0,q.useEffect)(()=>{let e=!1;return d(!1),p(!1),Ye(),i(()=>import(`./editor.main-DxrmGfoq.js`).then(t=>{if(e||!o.current)return;l.current=t;let n=b.current,r=t.editor.create(o.current,{value:n.content,language:n.language,readOnly:!0,domReadOnly:!0,theme:Je(t,n.theme),minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,renderValidationDecorations:`off`,wordWrap:n.wrap?`on`:`off`,fontSize:13});s.current=r,x(n.initialLine),d(!0)}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||p(!0)}),()=>{e=!0;let t=s.current?.getModel();s.current?.dispose(),t?.dispose(),s.current=null,l.current=null}},[m]),(0,q.useEffect)(()=>{let t=s.current;t&&t.getValue()!==e&&t.setValue(e)},[e]),(0,q.useEffect)(()=>{let e=s.current?.getModel();e&&l.current&&l.current.editor.setModelLanguage(e,t)},[t]),(0,q.useEffect)(()=>{let e=l.current;e&&e.editor.setTheme(Je(e,a))},[a]),(0,q.useEffect)(()=>{x(n)},[n,u]),(0,q.useEffect)(()=>{s.current?.updateOptions({wordWrap:g?`on`:`off`})},[g]),(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-muted/20 px-3 py-1 text-xs`,children:[(0,Q.jsx)(`button`,{type:`button`,disabled:!u,className:`rounded px-2 py-1 hover:bg-muted disabled:opacity-50`,onClick:()=>{s.current?.getAction(`actions.find`)?.run()},children:r(`reader.find`,{defaultValue:`Find in file`})}),(0,Q.jsx)(`button`,{type:`button`,disabled:!u,"aria-pressed":g,className:`rounded px-2 py-1 hover:bg-muted disabled:opacity-50`,onClick:()=>_(e=>!e),children:r(`reader.wrap`,{defaultValue:`Wrap lines`})}),(0,Q.jsxs)(`form`,{className:`ml-auto flex items-center gap-1`,onSubmit:e=>{e.preventDefault(),x(Number(v),!0)},children:[(0,Q.jsx)(`input`,{type:`number`,min:1,step:1,"aria-label":r(`reader.line`,{defaultValue:`Line number`}),placeholder:`#`,title:r(`reader.line`,{defaultValue:`Line number`}),value:v,onChange:e=>y(e.target.value),className:`w-28 rounded border border-border bg-background px-2 py-1`}),(0,Q.jsx)(`button`,{type:`submit`,disabled:!u||!Number.isInteger(Number(v))||Number(v)<1,className:`rounded px-2 py-1 hover:bg-muted disabled:opacity-50`,children:r(`reader.go`,{defaultValue:`Go`})})]})]}),f?(0,Q.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,Q.jsx)(`span`,{children:r(`monaco.loadFailed`)}),(0,Q.jsx)(`button`,{onClick:()=>h(e=>e+1),className:`rounded border px-3 py-1`,children:r(`reader.retry`,{defaultValue:`Retry`})})]}):(0,Q.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[!u&&(0,Q.jsx)(`div`,{role:`status`,className:`absolute inset-0 flex items-center justify-center text-sm text-muted-foreground`,children:r(`reader.loading`,{defaultValue:`Loading source viewer…`})}),(0,Q.jsx)(`div`,{ref:o,className:`h-full w-full`,"data-testid":`monaco-host`})]})]})}function Ze(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Qe({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:i,onCollapse:a}){let{t:o,i18n:s}=c(`code`),{openTicketDetail:l}=v();if(!t)return(0,Q.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i?o(`summary.unavailable`,{reason:i}):o(`summary.empty`)})]}),a&&(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Q.jsx)(S,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})});let u=Ze(t.generatedAt,s.language),d=t.generatedBy?.model??t.model,f=t.generatedAt&&Number.isFinite(Date.parse(t.generatedAt))?new Date(t.generatedAt).toLocaleString(s.language):void 0,p=t.triggeredBy?.ticketId,m=t.triggeredBy?.modifiedTicketIds??[];return(0,Q.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,Q.jsx)(`span`,{className:M(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:o(`summary.stale`)}),r&&(0,Q.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,Q.jsx)(`p`,{className:`text-sm text-foreground mt-1 whitespace-pre-wrap break-words`,children:t.summary}),t.generatedBy?.truncated&&(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-accent-warning`,children:o(`reader.summaryPartial`,{defaultValue:`Generated from a partial source snapshot. This summary may not cover the entire file.`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[d&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:o(`story.explainedBy`,{model:d})}),typeof p==`number`&&(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>l(p),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,p]}),m.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),u&&(0,Q.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:t.generatedAt,title:f,children:u})]})]}),a&&(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Q.jsx)(S,{className:`h-3.5 w-3.5`}),o(`summary.hide`)]})]})})}function $e({content:e}){return(0,Q.jsx)(N,{remarkPlugins:[P],children:e})}var et=2e3,tt=256e3;function nt({path:e,jobId:t}){let{activeProjectId:n}=f(),r=Z(),i=JSON.stringify([n,r.apiBase,r.repositoryPath,e,t]);return(0,Q.jsx)(rt,{path:e,jobId:t},i)}function rt({path:e,jobId:t}){let{t:n}=c(`code`),{apiBase:r}=Z(),[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(`loading`),[l,u]=(0,q.useState)(0);(0,q.useEffect)(()=>{let n=new AbortController;s(`loading`);let i=new URLSearchParams({path:e,jobId:t});return fetch(`${r}/code/diff?${i}`,{signal:n.signal}).then(async e=>{if(e.status===404){n.signal.aborted||s(`missing`);return}if(!e.ok)throw Error(`Diff request failed`);let t=await e.json();if(typeof t.patch!=`string`)throw Error(`Invalid patch response`);n.signal.aborted||(a({patch:t.patch,truncated:t.truncated===!0}),s(t.patch?`ready`:`missing`))}).catch(()=>{n.signal.aborted||s(`failed`)}),()=>n.abort()},[r,e,t,l]);let d=(i?.patch??``).slice(0,tt).split(`
|
|
3
3
|
`),f=d.length>et||(i?.patch.length??0)>tt,p=null,m=null;return(0,Q.jsxs)(`section`,{className:`flex min-h-0 flex-col gap-2 text-xs`,"data-testid":`recorded-diff`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border border-border bg-muted/30 px-3 py-2`,children:[(0,Q.jsxs)(`p`,{className:`font-medium`,children:[n(`reader.recordedChange`,{defaultValue:`Recorded change`}),` · `,(0,Q.jsx)(`span`,{className:`font-mono`,title:t,children:t.slice(0,12)})]}),(0,Q.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n(`reader.recordedNotice`,{defaultValue:`This patch records a past run. It may differ from the current registered checkout.`})})]}),o===`loading`&&(0,Q.jsx)(`p`,{role:`status`,children:n(`history.loadingDiff`)}),o===`missing`&&(0,Q.jsx)(`p`,{children:n(`history.diffUnavailable`)}),o===`failed`&&(0,Q.jsxs)(`div`,{role:`alert`,children:[(0,Q.jsx)(`p`,{children:n(`reader.diffFailed`,{defaultValue:`Could not load the recorded change.`})}),(0,Q.jsx)(`button`,{className:`mt-2 rounded border px-2 py-1`,onClick:()=>u(e=>e+1),children:n(`reader.retry`,{defaultValue:`Retry`})})]}),o===`ready`&&i&&(0,Q.jsxs)(Q.Fragment,{children:[i.truncated&&(0,Q.jsx)(`p`,{className:`text-accent-warning`,children:n(`reader.patchIncomplete`,{defaultValue:`The stored patch is incomplete. Missing content cannot be reconstructed from this record.`})}),f&&(0,Q.jsx)(`p`,{className:`text-accent-warning`,children:n(`reader.displayLimited`,{defaultValue:`Preview limited to {{count}} lines or {{chars}} characters. The remaining patch is not shown.`,count:et,chars:tt})}),(0,Q.jsx)(`div`,{className:`max-h-[32rem] overflow-auto rounded-md border border-border bg-background font-mono text-[11px] leading-5`,tabIndex:0,"aria-label":n(`reader.patch`,{defaultValue:`Recorded patch`}),children:d.slice(0,et).map((e,t)=>{let n=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/.exec(e),r=null,i=null,a=`meta`;return n?(p=Number(n[1]),m=Number(n[2])):p!==null&&m!==null&&(e.startsWith(`+`)?(a=`added`,i=m++):e.startsWith(`-`)?(a=`removed`,r=p++):e.startsWith(` `)&&(a=`context`,r=p++,i=m++)),(0,Q.jsxs)(`div`,{"data-kind":a,className:`flex min-w-max ${a===`added`?`bg-accent-success/10`:a===`removed`?`bg-destructive/10`:a===`meta`?`text-muted-foreground`:``}`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`w-12 shrink-0 select-none border-r border-border/40 px-2 text-right text-muted-foreground`,children:r}),(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`w-12 shrink-0 select-none border-r border-border/40 px-2 text-right text-muted-foreground`,children:i}),(0,Q.jsx)(`code`,{className:`whitespace-pre px-3`,children:e||` `})]},t)})})]})]})}var it={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function at(e){return e===`created`?m:e===`deleted`?g:w}function ot(e){let t=Z(),{activeProjectId:n}=f(),r=JSON.stringify([n,t.apiBase,t.repositoryPath,e.relPath]);return(0,Q.jsx)(st,{...e},r)}function st({relPath:e,height:t,onOpenTicket:n,onFilterJob:r,onViewDiff:i}){let{t:a}=c(`code`),o=Z(),{apiBase:l,repositoryId:u}=o,{activeProjectId:d,projects:m}=f(),h=m.find(e=>e.id===d)?.provider,g=b(h),{registerHandler:_,unregisterHandler:v}=s(),y=(0,q.useId)(),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(!1),T=(0,q.useRef)(!0),E=(0,q.useRef)(null),D=(0,q.useRef)(new Map);(0,q.useEffect)(()=>(T.current=!0,()=>{T.current=!1,E.current?.abort();for(let e of D.current.values())e.abort();D.current.clear()}),[]);let[O,k]=(0,q.useState)({}),A=(0,q.useRef)(d);(0,q.useEffect)(()=>{A.current=d},[d]);let j=(0,q.useRef)(e);(0,q.useEffect)(()=>{j.current=e},[e]);let M=(0,q.useRef)(0),N=(0,q.useCallback)(async()=>{if(!T.current)return;let t=++M.current;E.current?.abort();let n=new AbortController;E.current=n;try{let r=await fetch(`${l}/code/file/story?path=${encodeURIComponent(e)}`,{signal:n.signal});if(!T.current||n.signal.aborted||t!==M.current)return;if(!r.ok){S([]),w(!0);return}let i=await r.json();if(!T.current||n.signal.aborted||t!==M.current)return;S(Array.isArray(i.story)?i.story:[]),w(!1)}catch{T.current&&!n.signal.aborted&&t===M.current&&(S([]),w(!0))}},[e,d,l]);(0,q.useEffect)(()=>{S(null),k({}),N()},[N]),(0,q.useEffect)(()=>{if(!d)return;let e=`code-story-${d}-${u??`primary`}-${y}`;return _(e,e=>{let t=e;t.projectId!==A.current||!je(t.repositoryId,o)||t.path===j.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&N()}),()=>v(e)},[y,l,u,d,_,v,N]);let P=(0,q.useCallback)(async(t,n)=>{if(!g||!T.current||!t.hasPatch||t.evidence?.kind===`missing`||D.current.has(t.provenanceId))return;let r=new AbortController;D.current.set(t.provenanceId,r),k(e=>({...e,[t.provenanceId]:`busy`}));try{let i=await fetch(`${l}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,signal:r.signal,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n,...t.summaryStale?{force:!0}:{}})}),o=await i.json().catch(()=>({}));if(!T.current||r.signal.aborted)return;if(o.skipped===`budget`){k(e=>({...e,[t.provenanceId]:`budget`}));return}if(!i.ok||!o.ok){p.error(a(`story.explainFailed`)),k(e=>{let n={...e};return delete n[t.provenanceId],n});return}if(await N(),!T.current||r.signal.aborted)return;k(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{if(!T.current||r.signal.aborted)return;p.error(a(`story.explainFailed`)),k(e=>{let n={...e};return delete n[t.provenanceId],n})}finally{D.current.delete(t.provenanceId)}},[g,N,e,a]);return(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:x===null?(0,Q.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:a(`story.loading`)}):C?(0,Q.jsxs)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,role:`alert`,children:[a(`story.loadFailed`),` `,(0,Q.jsx)(`button`,{className:`ml-2 underline`,onClick:()=>{N()},children:a(`reader.retry`,{defaultValue:`Retry`})})]}):x.length===0?(0,Q.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:a(`story.empty`)}):(0,Q.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:x.map(t=>(0,Q.jsx)(ct,{entry:t,state:O[t.provenanceId],canExplain:g&&t.hasPatch&&t.evidence?.kind!==`missing`,path:e,onViewDiff:i,onOpenTicket:n,onFilterJob:r,onExplain:e=>{P(t,e)}},t.provenanceId))})})})}function ct({entry:e,state:t,canExplain:n,path:r,onViewDiff:i,onOpenTicket:a,onFilterJob:o,onExplain:s}){let{t:l}=c(`code`),[u,d]=(0,q.useState)(!1),f=at(e.kind),p=e.ticket?.status??null,m=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:l(`story.spec`,{ticketId:e.ticketId}),h=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,Q.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,Q.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,Q.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(f,{className:`h-3.5 w-3.5 shrink-0`}),l(`story.kindLabel.${e.kind}`)]}),m!=null&&e.ticketId!=null&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>a(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:l(`story.openSpec`,{ticketId:e.ticketId}),children:m}),m==null&&(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:l(`story.unknownSpec`)}),p&&(0,Q.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${it[p]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:p}),(0,Q.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,Q.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:l(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,Q.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:l(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,Q.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,Q.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,Q.jsxs)(Q.Fragment,{children:[e.summaryStale&&(0,Q.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:l(`summary.stale`)}),(0,Q.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryGeneratedAt&&(0,Q.jsx)(`time`,{className:`mt-1 block text-[10px] text-muted-foreground`,dateTime:e.summaryGeneratedAt,children:new Date(e.summaryGeneratedAt).toLocaleString()}),e.summaryStale&&n&&(t===`budget`?(0,Q.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-2 text-[11px] text-accent-warning`,children:[(0,Q.jsx)(`span`,{children:l(`story.budgetReached`)}),(0,Q.jsx)(`button`,{className:`rounded border px-2 py-1`,onClick:()=>s(!0),children:l(`story.generateAnyway`)})]}):(0,Q.jsx)(`button`,{disabled:t===`busy`,className:`mt-1 rounded border px-2 py-1 text-[11px]`,onClick:()=>s(!1),children:t===`busy`?l(`story.explaining`):l(`reader.regenerateExplanation`,{defaultValue:`Refresh explanation`})})),e.summaryModel&&(0,Q.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:l(`story.explainedBy`,{model:e.summaryModel})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:l(`story.fallback.${h}`)}),n?t===`budget`?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:l(`story.budgetReached`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:l(`story.generateAnyway`)})]}):(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>s(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,Q.jsx)(O,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),l(t===`busy`?`story.explaining`:`story.explain`)]}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,"data-testid":`story-explain-unavailable`,children:!e.hasPatch||e.evidence?.kind===`missing`?l(`reader.noEvidence`,{defaultValue:`No patch evidence was stored for this change.`}):l(`story.explainUnavailable`)})]})}),e.summary&&(!e.hasPatch||e.evidence?.kind===`missing`)&&(0,Q.jsx)(`p`,{className:`mt-2 text-[10px] text-accent-warning`,children:l(`reader.noEvidence`,{defaultValue:`No patch evidence was stored for this change.`})}),(e.summaryEvidence?.truncated??e.evidence?.truncated)&&(0,Q.jsx)(`p`,{className:`mt-2 text-[10px] text-accent-warning`,children:l(`reader.excerptEvidence`,{defaultValue:`This explanation uses incomplete patch evidence.`})}),e.jobId&&(0,Q.jsxs)(`div`,{className:`mt-2`,children:[(0,Q.jsx)(`button`,{className:`rounded border px-2 py-1 text-[11px]`,onClick:()=>{i?i(e.jobId):d(e=>!e)},children:l(`reader.viewPatch`,{defaultValue:`View recorded change`})}),u&&(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(nt,{path:r,jobId:e.jobId})})]}),e.jobId&&o&&(0,Q.jsx)(`footer`,{className:`mt-1.5`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>o(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:l(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function lt(e,t){return t===`markdown`||t===`md`||/\.(md|mdx|markdown)$/i.test(e)}var ut=180,dt=120,ft=240;function pt(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function mt(e){return e?`specrails-desktop:code-history-height:${e}`:null}function ht(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function gt(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function _t(e){let t=gt(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function vt(e,t){let n=gt(e);if(n)try{localStorage.setItem(n,t)}catch{}}function yt(e){let t=mt(e);if(!t)return ut;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:ut}catch{return ut}}function bt(e,t){let n=mt(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function xt(e){let t=pt(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function St(e,t){let n=pt(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Ct(e,t=!1){let n=ht(e);if(!n)return t;let r=t?n+`:compact`:n;try{let e=localStorage.getItem(r);return e===null?t:e===`true`}catch{return t}}function wt(e,t,n=!1){let r=ht(e),i=r&&n?r+`:compact`:r;if(i)try{localStorage.setItem(i,t?`true`:`false`)}catch{}}function Tt(e,t){let n=Math.max(dt,t-ft);return Math.min(Math.max(e,dt),n)}function Et(e){let{activeProjectId:t}=f(),n=Z(),r=JSON.stringify([t,n.apiBase,n.repositoryId,n.repositoryPath,e.relPath,e.initialJobId]);return(0,Q.jsx)(Dt,{...e},r)}function Dt({relPath:e,initialLine:t,initialJobId:n,compact:r=!1,onFilterJob:i,onSummaryActionChange:a,onCopyPathActionChange:o}){let{t:l}=c(`code`),u=Z(),{apiBase:d,repositoryId:m}=u,{activeProjectId:h,projects:g}=f(),_=g.find(e=>e.id===h)?.provider,y=b(_),{openTicketDetail:x}=v(),{registerHandler:C,unregisterHandler:w}=s(),T=(0,q.useId)(),E=A({allowMove:!1}),D=(0,q.useRef)(null),[O,k]=(0,q.useState)(null),[M,N]=(0,q.useState)(!1),P=(0,q.useRef)(!0),ee=(0,q.useRef)(null),F=(0,q.useRef)(new Set);(0,q.useEffect)(()=>(P.current=!0,()=>{P.current=!1,ee.current?.abort();for(let e of F.current)e.abort();F.current.clear()}),[]);let[I,te]=(0,q.useState)(n??null),[L,R]=(0,q.useState)(n?`recorded`:`source`);(0,q.useEffect)(()=>{te(n??null),R(n?`recorded`:`source`)},[n]),(0,q.useEffect)(()=>{t&&!n&&R(`source`)},[t,n]);let ne=(0,q.useCallback)(e=>{te(e),R(`recorded`)},[]),[z,B]=(0,q.useState)(!0),[ie,V]=(0,q.useState)(!1),[ae,H]=(0,q.useState)(!1),[oe,U]=(0,q.useState)(()=>xt(h)),[W,G]=(0,q.useState)(()=>yt(h)),[K,se]=(0,q.useState)(()=>Ct(h,r)),[ce,ue]=(0,q.useState)(()=>_t(h)),J=(0,q.useRef)(h);(0,q.useEffect)(()=>{J.current=h},[h]);let de=(0,q.useRef)(e);(0,q.useEffect)(()=>{de.current=e},[e]),(0,q.useEffect)(()=>{let e=D.current?.clientHeight||window.innerHeight;U(xt(h)),G(Tt(yt(h),e)),se(Ct(h,r)),ue(_t(h))},[h,r]);let fe=(0,q.useCallback)(e=>{let t=e.clientY,n=W,r=D.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){G(Tt(n+(t-e.clientY),r))}function o(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),G(e=>{let t=Tt(e,r);return bt(h,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},[h,W]),pe=(0,q.useCallback)(()=>{let e=Tt(ut,D.current?.clientHeight||window.innerHeight);G(e),bt(h,e)},[h]),me=(0,q.useCallback)(()=>{U(e=>{let t=!e;return St(h,t),t})},[h]),Y=(0,q.useCallback)(()=>{se(e=>{let t=!e;return wt(h,t,r),t})},[h,r]),he=(0,q.useCallback)(e=>{ue(e),vt(h,e)},[h]);(0,q.useEffect)(()=>{xe(t?`raw`:`preview`)},[e,t]);let ge=(0,q.useRef)(0),X=(0,q.useCallback)(async()=>{if(!P.current)return;let t=++ge.current;ee.current?.abort();let n=new AbortController;ee.current=n,B(!0),N(!1);try{let r=await fetch(`${d}/code/file?path=${encodeURIComponent(e)}`,{signal:n.signal});if(!P.current||n.signal.aborted||t!==ge.current)return;if(!r.ok){N(!0);return}let i=await r.json();if(!P.current||n.signal.aborted||t!==ge.current)return;k(i)}catch{P.current&&!n.signal.aborted&&t===ge.current&&N(!0)}finally{P.current&&!n.signal.aborted&&t===ge.current&&B(!1)}},[e,h,d]);(0,q.useEffect)(()=>{X()},[X]),(0,q.useEffect)(()=>{let e=()=>{X()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[X]),(0,q.useEffect)(()=>{if(!h)return;let e=`code-file-${h}-${m??`primary`}-${T}`;return C(e,e=>{let t=e;t.projectId!==J.current||!je(t.repositoryId,u)||((t.type===`file.summary_updated`||t.type===`file.provenance_updated`||t.type===`file.content_updated`)&&t.path===de.current?(t.type===`file.summary_updated`&&V(!1),X()):t.type===`file.summary_failed`&&t.path===de.current?(p.error(t.reason??l(`summary.generationFailed`)),V(!1)):t.type===`file.summary_skipped`&&t.path===de.current&&(t.reason&&p(l(`summary.skipped`,{reason:t.reason})),V(!1)))}),()=>w(e)},[T,d,m,h,C,w,X,l]);let _e=(0,q.useCallback)(async t=>{if(!y||!P.current||F.current.size>0)return;let n=new AbortController;F.current.add(n),V(!0);try{let r=await fetch(`${d}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,signal:n.signal,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),i=await r.json().catch(()=>({}));if(!P.current||n.signal.aborted)return;if(!r.ok){V(!1);let e=typeof i.skipped==`string`?i.skipped:null;p.error(e?l(`summary.skipped`,{reason:e}):l(`summary.generationFailed`));return}if(i.skipped===`budget`){V(!1),H(!0);return}if(i.skipped){V(!1),p(l(`summary.skipped`,{reason:i.skipped}));return}await X(),P.current&&!n.signal.aborted&&V(!1)}catch{P.current&&!n.signal.aborted&&(V(!1),p.error(l(`summary.generationFailed`)))}finally{F.current.delete(n)}},[y,X,e,l]),ve=(0,q.useCallback)(async()=>{let t=O?.absolutePath??e;try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t),p.success(l(`viewer.pathCopied`))}catch{p.error(l(`viewer.copyPathFailed`))}},[O,e,l]),ye=(0,q.useMemo)(()=>lt(e,O?.language),[e,O?.language]),[be,xe]=(0,q.useState)(t?`raw`:`preview`),Se=O?.summary??null,Ce=!!O?.summaryStale,we=O?.provenance??[],Te=O?.reason===`not-found`,Ee=O?y?Te?l(`summary.reason.missing`):O?.binary?l(`summary.reason.binary`):O?.tooLarge?l(`summary.reason.tooLarge`):null:l(`summary.reason.providerNoPureOutput`):l(`reader.sourceUnavailable`,{defaultValue:`source unavailable`});return(0,q.useEffect)(()=>{if(a){if(L===`recorded`||z&&!O){a(null);return}return a({hasSummary:!!Se,regenerating:ie,disabledReason:Ee,onClick:()=>_e(!1)}),()=>a(null)}},[O,_e,z,a,ie,Se,Ee,L]),(0,q.useEffect)(()=>{if(o){if(z&&!O){o(null);return}return o({onClick:ve}),()=>o(null)}},[ve,O,z,o]),L===`source`&&z&&!O?(0,Q.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:l(`viewer.loadingFile`)}):(0,Q.jsxs)(`div`,{ref:D,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[L===`source`&&(oe?(0,Q.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,Q.jsxs)(`button`,{type:`button`,onClick:me,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Q.jsx)(re,{className:`h-3.5 w-3.5`}),l(`viewer.showSummary`)]})]}):(0,Q.jsx)(Qe,{path:e,summary:Se,stale:Ce,regenerating:ie,generateDisabledReason:Ee,onCollapse:me})),(0,Q.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[(0,Q.jsx)(`button`,{"aria-pressed":L===`source`,onClick:()=>R(`source`),className:`rounded px-2 py-1 text-xs hover:bg-muted`,children:l(`reader.currentFile`,{defaultValue:`Current file`})}),I&&(0,Q.jsx)(`button`,{"aria-pressed":L===`recorded`,onClick:()=>R(`recorded`),className:`rounded px-2 py-1 text-xs hover:bg-muted`,children:l(`reader.recordedChange`,{defaultValue:`Recorded change`})}),L===`source`&&ye&&O?.content!==void 0&&!O.binary&&!O.tooLarge&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":l(`viewer.markdownViewMode`),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>xe(`preview`),"aria-pressed":be===`preview`,className:be===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:l(`viewer.preview`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>xe(`raw`),"aria-pressed":be===`raw`,className:be===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:l(`viewer.raw`)})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted-foreground`,children:[O?.language&&(0,Q.jsx)(`span`,{children:O.language}),typeof O?.sizeBytes==`number`&&(0,Q.jsxs)(`span`,{children:[(O.sizeBytes/1024).toFixed(1),` KB`]}),(0,Q.jsx)(`button`,{disabled:z,onClick:()=>{X()},className:`rounded px-2 py-1 hover:bg-muted disabled:opacity-50`,children:l(`reader.refresh`,{defaultValue:`Refresh source`})})]})]}),M&&(0,Q.jsxs)(`div`,{role:`alert`,className:`border-b border-border px-4 py-2 text-xs`,children:[l(`reader.sourceFailed`,{defaultValue:`Could not refresh the current file. Any displayed source is the last successful read.`}),(0,Q.jsx)(`button`,{className:`ml-2 underline`,onClick:()=>{X()},children:l(`reader.retry`,{defaultValue:`Retry`})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:L===`recorded`&&I?(0,Q.jsx)(`div`,{className:`h-full overflow-auto p-3`,children:(0,Q.jsx)(nt,{path:e,jobId:I})}):Te?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:l(`viewer.missingFile`)}):O?.binary?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:l(`viewer.binaryFile`)}):O?.tooLarge?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:l(`viewer.tooLarge`,{size:Math.round((O.sizeBytes??0)/1024/1024)})}):O?.content===void 0?(0,Q.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:l(`viewer.noContent`)}):ye&&be===`preview`?(0,Q.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,Q.jsx)($e,{content:O.content})}):(0,Q.jsx)(Xe,{content:O.content,language:O.language??`plaintext`,initialLine:t})}),we.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":l(`history.resize`),onPointerDown:K?void 0:fe,onDoubleClick:K?void 0:pe,className:K?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:K?void 0:l(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:l(ce===`story`?`story.title`:`history.title`,{count:we.length})}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!K&&(0,Q.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":l(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>he(`story`),"aria-pressed":ce===`story`,className:ce===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:l(`story.modeStory`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>he(`log`),"aria-pressed":ce===`log`,className:ce===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:l(`story.modeLog`)})]}),(0,Q.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:Y,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[K?(0,Q.jsx)(S,{className:`h-3.5 w-3.5`}):(0,Q.jsx)(re,{className:`h-3.5 w-3.5`}),l(K?`history.show`:`history.hide`)]})]})]}),!K&&(ce===`story`?(0,Q.jsx)(ot,{relPath:e,height:W,onOpenTicket:x,onFilterJob:i,onViewDiff:ne}):(0,Q.jsx)(Ot,{rows:we,onOpenTicket:x,onFilterJob:i,height:W}))]}),ae&&(0,le.createPortal)((0,Q.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:E.guardBackdrop(()=>H(!1)),children:[(0,Q.jsxs)(`div`,{ref:E.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:E.panelStyle,children:[(0,Q.jsx)(`p`,{className:`text-sm text-foreground`,children:l(`viewer.budgetPrompt`)}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>H(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:l(`common:actions.cancel`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{H(!1),_e(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:l(`common:actions.confirm`)})]})]}),(0,Q.jsx)(j,{handles:E.resizeHandles})]}),document.body)]})}function Ot({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=c(`code`),[a,o]=(0,q.useState)(null);if(e.length===0)return null;function s(e,t){o(e=>e===t?null:t)}return(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:r},"data-testid":`file-provenance-timeline`,children:(0,Q.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let o=e.kind===`created`?m:e.kind===`deleted`?g:w,c=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:i(`history.unknownJob`),l=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`;return(0,Q.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,Q.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,Q.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Q.jsx)(`span`,{className:`capitalize`,children:i(`kind.${e.kind}`)})]}),(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,Q.jsx)(y,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,Q.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:i(`history.filterByJob`,{jobId:e.jobId}),children:c}):(0,Q.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:c}),e.jobId&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>s(e,l),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:i(`history.diff`)}),typeof e.ticketId==`number`&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:i(`history.openSpec`,{ticketId:e.ticketId}),children:i(`history.specChip`,{ticketId:e.ticketId})})]}),(0,Q.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),a===l&&(0,Q.jsx)(`div`,{className:`px-2 pb-2`,children:e.jobId&&(0,Q.jsx)(nt,{path:e.path,jobId:e.jobId})})]},l)})})})}function kt({projectId:e,repositoryName:t,multipleRepositories:n,active:r=!0,onOpen:i}){let{t:a}=c(`code`),{apiBase:o,repositoryId:s,repositoryPath:l}=Z(),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(`find`),[m,h]=(0,q.useState)(n),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(!1),[w,T]=(0,q.useState)(!1),[O,k]=(0,q.useState)(0),A=n&&m,j=A?ee(e):o,M=A?void 0:s,N=A?void 0:t,P=A?void 0:l,F=(0,q.useRef)(0),I=(0,q.useRef)(null);return(0,q.useEffect)(()=>{r&&I.current?.focus()},[r]),(0,q.useEffect)(()=>{let e=++F.current,t=new AbortController;x(null),T(!1);let n=u.trim();if(!n)return C(!1),()=>t.abort();C(!0);let r=setTimeout(async()=>{try{let r=new URLSearchParams({q:n,limit:f===`find`?`50`:`100`});f===`search`&&r.set(`caseSensitive`,String(g)),f===`search`&&v.trim()&&r.set(`path`,v.trim()),A&&r.set(`kind`,f);let i=await fetch(`${j}/code/${A?`discover`:f}?${r}`,{signal:t.signal});if(!i.ok)throw Error(`search_failed`);let a=await i.json();if(!Array.isArray(a.matches))throw Error(`invalid_search_response`);!t.signal.aborted&&e===F.current&&x({...a,matches:a.matches.map(e=>({...e,repositoryId:e.repositoryId??M,repositoryName:e.repositoryName??N}))})}catch{!t.signal.aborted&&e===F.current&&T(!0)}finally{!t.signal.aborted&&e===F.current&&C(!1)}},250);return()=>{clearTimeout(r),t.abort()}},[u,f,g,v,O,A,j,M,N,P]),(0,Q.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":a(`explore.search`),children:[(0,Q.jsxs)(`div`,{className:`space-y-2 border-b border-border p-3`,children:[(0,Q.jsx)(`div`,{className:`flex gap-1 rounded-lg bg-muted/40 p-1`,children:[`find`,`search`].map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":f===e,onClick:()=>p(e),className:`flex-1 rounded-md px-2 py-1.5 text-xs ${f===e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground`}`,children:a(`search.${e}`)},e))}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(D,{className:`pointer-events-none absolute left-2.5 top-2.5 h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(`input`,{ref:I,value:u,onChange:e=>d(e.target.value),maxLength:256,"aria-label":a(`search.query`),placeholder:a(f===`find`?`search.filePlaceholder`:`search.contentPlaceholder`),className:`h-9 w-full rounded-md border border-border bg-background pl-8 pr-2 text-xs outline-none focus:border-accent-primary`})]}),n&&(0,Q.jsxs)(`select`,{"aria-label":a(`search.scope`),value:m?`all`:`current`,onChange:e=>h(e.target.value===`all`),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`option`,{value:`all`,children:a(`search.allRepositories`)}),(0,Q.jsx)(`option`,{value:`current`,children:t??a(`search.currentRepository`)})]}),f===`search`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{value:v,onChange:e=>y(e.target.value),placeholder:a(`search.pathPlaceholder`),"aria-label":a(`search.withinPath`),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs outline-none focus:border-accent-primary`}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:g,onChange:e=>_(e.target.checked)}),a(`search.caseSensitive`)]})]})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,"aria-busy":S,children:[!u.trim()&&(0,Q.jsxs)(`div`,{className:`space-y-2 px-5 py-8 text-center text-xs text-muted-foreground`,children:[(0,Q.jsx)(ie,{className:`mx-auto h-7 w-7 opacity-50`}),(0,Q.jsx)(`p`,{children:a(`search.hint`)})]}),S&&(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,Q.jsx)(E,{className:`h-3.5 w-3.5 animate-spin`}),a(`search.loading`)]}),w&&(0,Q.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-4 text-xs`,children:[(0,Q.jsx)(`p`,{children:a(`search.failed`)}),(0,Q.jsx)(`button`,{type:`button`,className:`text-accent-primary underline`,onClick:()=>k(e=>e+1),children:a(`explore.retry`)})]}),b&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{role:`status`,className:`space-y-1 border-b border-border/50 px-3 py-2 text-[11px] text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:a(`search.results`,{count:b.matches.length})}),b.truncated&&(0,Q.jsx)(`p`,{className:`text-amber-600 dark:text-amber-400`,children:a(`search.partial`)}),b.repositories?.filter(e=>![`ok`,`partial`].includes(e.status)).map(e=>(0,Q.jsx)(`p`,{children:a(`search.repositoryIncomplete`,{name:e.repositoryName})},e.repositoryId))]}),b.matches.length===0&&(0,Q.jsx)(`p`,{className:`p-4 text-xs text-muted-foreground`,children:a(b.truncated?`search.noMatchesPartial`:`search.noMatches`)}),(0,Q.jsx)(`ul`,{className:`divide-y divide-border/40`,children:b.matches.map((e,t)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>i({repositoryId:e.repositoryId,path:e.path,line:e.lineNumber}),className:`w-full space-y-1 px-3 py-3 text-left hover:bg-muted/50 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-accent-primary`,title:`${e.repositoryName??``} / ${e.path}`,children:[n&&(0,Q.jsx)(`span`,{className:`block text-[10px] font-medium text-accent-primary`,children:e.repositoryName}),(0,Q.jsxs)(`span`,{className:`block break-all font-mono text-xs text-foreground`,children:[e.path,e.lineNumber?(0,Q.jsxs)(`span`,{className:`text-accent-primary`,children:[`:`,e.lineNumber]}):null]}),e.snippet!==void 0&&(0,Q.jsxs)(`span`,{className:`block overflow-hidden text-ellipsis whitespace-pre font-mono text-[11px] text-muted-foreground`,children:[e.snippetTruncated?`… `:``,e.snippet]})]})},`${e.repositoryId}:${e.path}:${e.lineNumber??0}:${t}`))})]})]})]})}function At({projectId:e,repositoryName:t,multipleRepositories:n,jobId:r,ticketId:i,onOpen:a}){let{t:o,i18n:l}=c(`code`),{repositoryId:u,repositoryPath:d}=Z(),{registerHandler:f,unregisterHandler:p}=s(),[h,_]=(0,q.useState)(n),[v,b]=(0,q.useState)(null),[x,S]=(0,q.useState)(!1),[C,T]=(0,q.useState)(!1),D=(0,q.useRef)(0),O=(0,q.useRef)(null),k=(0,q.useId)(),A=JSON.stringify([e,u,d,h,r,i]),j=(0,q.useRef)(A);j.current=A;let M=v?.scope===A?v:null,N=(0,q.useCallback)(async t=>{let n=++D.current;O.current?.abort();let a=new AbortController;O.current=a,S(!0),T(!1),t||b(null);try{let o=new URLSearchParams({limit:`50`});!h&&u&&o.set(`repositoryId`,u),r&&o.set(`jobId`,r),i&&o.set(`ticketId`,String(i)),t&&o.set(`cursor`,t);let s=await fetch(`${ee(e)}/code/activity?${o}`,{signal:a.signal});if(!s.ok)throw Error(`activity_failed`);let c=await s.json();if(!Array.isArray(c.entries)||t&&c.nextCursor===t)throw Error(`invalid_activity_page`);if(a.signal.aborted||n!==D.current||j.current!==A)return;b(e=>{let n=t&&e?.scope===A?[...e.entries,...c.entries]:c.entries,r=[...new Map(n.map(e=>[e.id,e])).values()],i=r.length>1e3||r.length===1e3&&c.nextCursor!==null;return{...c,scope:A,entries:r.slice(0,1e3),nextCursor:i?null:c.nextCursor,truncated:c.truncated||i||!!t&&e?.scope===A&&e.truncated}})}catch{!a.signal.aborted&&n===D.current&&j.current===A&&T(!0)}finally{!a.signal.aborted&&n===D.current&&j.current===A&&S(!1)}},[e,u,d,h,r,i,A]);return(0,q.useEffect)(()=>(N(),()=>{D.current++,O.current?.abort()}),[N]),(0,q.useEffect)(()=>{let t=`code-activity-${e}-${k}`,n;return f(t,t=>{let r=t;r.type!==`file.provenance_updated`||r.projectId!==e||(clearTimeout(n),n=setTimeout(()=>{N()},250))}),()=>{clearTimeout(n),p(t)}},[N,e,k,f,p]),(0,Q.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col`,"aria-label":o(`explore.activity`),children:[(0,Q.jsxs)(`div`,{className:`space-y-2 border-b border-border p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:o(`activity.description`)}),(0,Q.jsx)(`button`,{type:`button`,disabled:x,onClick:()=>{N()},"aria-label":o(`explore.refresh`),title:o(`explore.refresh`),className:`rounded p-1 text-muted-foreground hover:bg-muted disabled:opacity-40`,children:(0,Q.jsx)(te,{className:`h-3.5 w-3.5 ${x?`animate-spin`:``}`})})]}),n&&(0,Q.jsxs)(`select`,{"aria-label":o(`activity.scope`),value:h?`all`:`current`,onChange:e=>_(e.target.value===`all`),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs`,children:[(0,Q.jsx)(`option`,{value:`all`,children:o(`search.allRepositories`)}),(0,Q.jsx)(`option`,{value:`current`,children:t??o(`search.currentRepository`)})]}),(i||r)&&(0,Q.jsx)(`p`,{className:`break-all text-[11px] text-accent-primary`,children:i?o(`provenancePanel.specTitle`,{ticketId:i}):o(`provenancePanel.jobTitle`,{jobId:r})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,"aria-busy":x,children:[C&&(0,Q.jsxs)(`div`,{role:`alert`,className:`space-y-2 p-3 text-xs`,children:[(0,Q.jsx)(`p`,{children:o(`activity.failed`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{N(M?.nextCursor??void 0)},className:`text-accent-primary underline`,children:o(`explore.retry`)})]}),M?.truncated&&(0,Q.jsx)(`p`,{role:`status`,className:`border-b border-border p-3 text-xs text-amber-600 dark:text-amber-400`,children:o(`activity.partial`)}),M&&M.entries.length===0&&!M.truncated&&!M.nextCursor&&!x&&(0,Q.jsxs)(`div`,{className:`space-y-2 p-6 text-center text-xs text-muted-foreground`,children:[(0,Q.jsx)(L,{className:`mx-auto h-6 w-6 opacity-50`}),(0,Q.jsx)(`p`,{children:o(`activity.empty`)})]}),(0,Q.jsx)(`ol`,{children:M?.entries.map((e,t)=>{let n=M.entries[t-1],r=!n||n.repositoryId!==e.repositoryId||n.jobId!==e.jobId||n.ticketId!==e.ticketId,i=e.kind===`created`?m:e.kind===`deleted`?g:w;return(0,Q.jsxs)(`li`,{children:[r&&(0,Q.jsxs)(`div`,{className:`sticky top-0 z-[1] space-y-1 border-y border-border bg-background/95 px-3 py-2 backdrop-blur`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.repositoryName}),e.ticketId!=null&&(0,Q.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-0.5 text-accent-primary`,children:o(`story.spec`,{ticketId:e.ticketId})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[10px] text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,title:e.jobId??void 0,children:[(0,Q.jsx)(y,{className:`h-3 w-3`}),e.jobId?.slice(0,10)??o(`history.unknownJob`)]}),(0,Q.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),title:new Date(e.at).toLocaleString(l.language),children:new Date(e.at).toLocaleDateString(l.language,{month:`short`,day:`numeric`})})]})]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>a({repositoryId:e.repositoryId,path:e.path,changeJobId:e.jobId}),className:`flex w-full items-start gap-2 border-b border-border/30 px-3 py-3 text-left hover:bg-muted/50`,title:e.path,children:[(0,Q.jsx)(i,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 ${e.kind===`created`?`text-accent-success`:e.kind===`deleted`?`text-destructive`:`text-accent-info`}`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 space-y-1`,children:[(0,Q.jsx)(`span`,{className:`block break-all font-mono text-xs`,children:e.path}),(0,Q.jsxs)(`span`,{className:`block text-[10px] text-muted-foreground`,children:[o(`story.kindLabel.${e.kind}`),` · `,o(e.hasPatch?e.patchTruncated?`activity.partialPatch`:`activity.patch`:`activity.noPatch`)]})]})]})]},e.id)})}),x&&(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,Q.jsx)(E,{className:`h-3.5 w-3.5 animate-spin`}),o(`activity.loading`)]}),M?.nextCursor&&!x&&!C&&(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{N(M.nextCursor)},className:`m-3 rounded-md border border-border px-3 py-1.5 text-xs hover:bg-muted/50`,children:o(`activity.loadMore`)})]})]})}function jt(e){if(!e||!/^\d+$/.test(e))return;let t=Number(e);return Number.isSafeInteger(t)&&t>0?t:void 0}var Mt=320,Nt=240,Pt=420,Ft=760,It=e=>`specrails-desktop:code-tree-width:${e}`;function Lt(e){try{let t=Number(localStorage.getItem(It(e)));return t>0&&Number.isFinite(t)?t:Mt}catch{return Mt}}function Rt(e,t){if(e)try{localStorage.setItem(It(e),String(Math.round(t)))}catch{}}function zt(e,t){return Math.min(Math.max(e,Nt),Math.max(Nt,t-Pt))}function Bt(e={}){let{activeProjectId:t}=f();return(0,Q.jsx)(Vt,{...e},t??`no-project`)}function Vt({embedded:e=!1,initialPath:t=null,initialRepositoryId:n,onRepositoryChange:r,onSelectedPathChange:i}){let{t:s}=c(`code`),{t:l}=c(`common`),{activeProjectId:d,projects:p}=f(),[m,h]=a(),g=o(),v=p?.find(e=>e.id===d),y=(0,q.useMemo)(()=>F(v),[v]),[b,S]=(0,q.useState)(()=>({entries:[{repositoryId:n??void 0,path:t}],index:0})),T=e?b.entries[b.index]:{repositoryId:m.get(`repositoryId`)??void 0,path:m.get(`path`),line:jt(m.get(`line`)),changeJobId:m.get(`changeJobId`)},E=T.repositoryId?y.find(e=>e.id===T.repositoryId):y.find(e=>e.isPrimary),O=!!T.repositoryId&&!!v&&!E,k=(0,q.useMemo)(()=>({apiBase:d?ee(d,E?.id):u(),repositoryId:E?.id,repositoryPath:E?.path,isPrimary:E?.isPrimary}),[d,E?.id,E?.path,E?.isPrimary]),A=JSON.stringify([d,E?.id,E?.path]),[j,M]=(0,q.useState)(`files`),[N,P]=(0,q.useState)(!0),[I,te]=(0,q.useState)(e),[R,ne]=(0,q.useState)(()=>Lt(d)),[re,z]=(0,q.useState)(null),[B,ie]=(0,q.useState)(null),[V,H]=(0,q.useState)({}),U=e?V.jobId??null:m.get(`jobId`),W=e?V.ticketId??null:jt(m.get(`ticketId`))??null,[G,se]=(0,q.useState)(W?String(W):``),le=(0,q.useRef)(null),ue=(0,q.useRef)(null);(0,q.useEffect)(()=>{se(W?String(W):``)},[W]),(0,q.useEffect)(()=>{let e=le.current;if(!e)return;let t=e=>{e&&(te(e<Ft),ne(t=>zt(t,e)))};if(t(e.clientWidth),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(e=>t(e[0]?.contentRect.width??0));return n.observe(e),()=>n.disconnect()},[]),(0,q.useEffect)(()=>()=>ue.current?.(),[]),(0,q.useEffect)(()=>{I&&T.path&&P(!1)},[I,T.path]);let J=(0,q.useCallback)(t=>{let n={...t,repositoryId:t.repositoryId??E?.id},a=n.repositoryId!==E?.id;if(e)S(e=>({entries:[...e.entries.slice(0,e.index+1),n],index:e.index+1})),a&&H({});else{let e=new URLSearchParams(m);for(let t of[`path`,`line`,`changeJobId`])e.delete(t);n.repositoryId&&e.set(`repositoryId`,n.repositoryId),n.path&&e.set(`path`,n.path),n.line&&e.set(`line`,String(n.line)),n.changeJobId&&e.set(`changeJobId`,n.changeJobId),a&&(e.delete(`jobId`),e.delete(`ticketId`)),h(e)}i?.(n.path),n.repositoryId&&r?.(n.repositoryId),I&&n.path&&P(!1)},[e,E?.id,m,h,i,r,I]),de=t=>{if(!e){g(t);return}let n=b.index+t,a=b.entries[n];if(!a)return;let o=a.repositoryId??y.find(e=>e.isPrimary)?.id;o!==E?.id&&H({}),S({...b,index:n}),i?.(a.path),o&&r?.(o)},fe=(0,q.useCallback)(t=>{if(e)H(t);else{let e=new URLSearchParams(m);e.delete(`jobId`),e.delete(`ticketId`),t.jobId&&e.set(`jobId`,t.jobId),t.ticketId&&e.set(`ticketId`,String(t.ticketId)),h(e)}},[e,m,h]),pe=(0,q.useCallback)(e=>{fe({jobId:e}),M(`activity`),P(!0)},[fe]),me=e=>{ue.current?.();let t=e.clientX,n=R,r=R,i=e=>{r=zt(n+e.clientX-t,le.current?.clientWidth||window.innerWidth),ne(r)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a),Rt(d,r),ue.current=null};ue.current=a,window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},Y=N||!T.path,he=!I||!Y,ge=T.path?.split(`/`)??[];return(0,Q.jsx)(Ae.Provider,{value:k,children:(0,Q.jsxs)(`div`,{ref:le,className:`flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden`,"data-testid":`code-page`,"data-compact":I,children:[(0,Q.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-card/30 px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":s(`explore.back`),title:s(`explore.back`),onClick:()=>de(-1),disabled:e&&b.index===0,className:`rounded p-1.5 text-muted-foreground hover:bg-muted disabled:opacity-30`,children:(0,Q.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":s(`explore.forward`),title:s(`explore.forward`),onClick:()=>de(1),disabled:e&&b.index===b.entries.length-1,className:`rounded p-1.5 text-muted-foreground hover:bg-muted disabled:opacity-30`,children:(0,Q.jsx)(_,{className:`h-3.5 w-3.5`})}),T.path&&(0,Q.jsx)(`button`,{type:`button`,"aria-label":s(Y?`explore.hideNavigation`:`explore.showNavigation`),title:s(Y?`explore.hideNavigation`:`explore.showNavigation`),onClick:()=>P(!Y),className:`rounded p-1.5 text-muted-foreground hover:bg-muted`,children:Y?(0,Q.jsx)(K,{className:`h-4 w-4`}):(0,Q.jsx)(ce,{className:`h-4 w-4`})})]}),y.length>0&&(0,Q.jsxs)(`select`,{"aria-label":l(`repositories.select`),className:`max-w-full min-w-0 rounded-md border border-border bg-background px-2 py-1 text-xs`,value:E?.id??T.repositoryId??``,onChange:e=>J({repositoryId:e.target.value,path:null}),children:[O&&(0,Q.jsx)(`option`,{value:T.repositoryId,children:l(`repositories.unavailable`)}),y.map(e=>(0,Q.jsxs)(`option`,{value:e.id,children:[e.name,e.isPrimary?` · ${l(`repositories.primary`)}`:``]},e.id))]}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-muted-foreground`,title:E?.path,children:E?.path})]}),O?(0,Q.jsx)(`p`,{role:`alert`,className:`p-4 text-sm text-destructive`,children:l(`repositories.invalidSelection`)}):(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,Q.jsxs)(`aside`,{hidden:!Y,className:`${Y?`flex`:`hidden`} min-h-0 min-w-0 shrink-0 flex-col overflow-hidden bg-card/15`,style:{width:I?`100%`:R},"aria-label":s(`explore.navigation`),children:[(0,Q.jsx)(`nav`,{className:`flex shrink-0 gap-0.5 border-b border-border px-2 pt-2`,"aria-label":s(`explore.views`),children:[{mode:`files`,Icon:ae},{mode:`search`,Icon:D},{mode:`activity`,Icon:L}].map(({mode:e,Icon:t})=>(0,Q.jsxs)(`button`,{type:`button`,"aria-pressed":j===e,onClick:()=>M(e),className:`flex min-w-0 flex-1 items-center justify-center gap-1.5 border-b-2 px-1 py-2 text-xs ${j===e?`border-accent-primary text-accent-primary`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[(0,Q.jsx)(t,{className:`h-3.5 w-3.5 shrink-0`}),s(`explore.${e}`)]},e))}),(0,Q.jsx)(`div`,{className:j===`files`?`min-h-0 flex-1`:`hidden`,children:(0,Q.jsx)(ze,{selectedPath:T.path,onOpenFile:e=>J({path:e}),filterJobId:U,filterTicketId:W},A)}),d&&(0,Q.jsx)(`div`,{className:j===`search`?`flex min-h-0 flex-1 flex-col`:`hidden`,children:(0,Q.jsx)(kt,{active:j===`search`&&Y,projectId:d,repositoryName:E?.name,multipleRepositories:y.length>1,onOpen:J})}),j===`activity`&&d&&(0,Q.jsx)(At,{projectId:d,repositoryName:E?.name,multipleRepositories:y.length>1,jobId:U,ticketId:W,onOpen:J})]}),Y&&!I&&(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":s(`page.resizeFileTree`),onPointerDown:me,onDoubleClick:()=>{let e=zt(Mt,le.current?.clientWidth||window.innerWidth);ne(e),Rt(d,e)},className:`w-1.5 shrink-0 cursor-col-resize touch-none select-none border-x border-border/40 hover:bg-accent-primary/20`,title:s(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,Q.jsxs)(`main`,{hidden:!he,className:`${he?`flex`:`hidden`} min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[T.path&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 overflow-x-auto border-b border-border/60 px-3 py-2 text-[11px]`,"aria-label":s(`explore.breadcrumb`),children:[(0,Q.jsx)(w,{className:`mr-1 h-3.5 w-3.5 shrink-0 text-muted-foreground`}),ge.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 ${t===ge.length-1?`font-medium text-foreground`:`text-muted-foreground`}`,children:[t>0&&(0,Q.jsx)(C,{className:`h-3 w-3`}),e]},t)),T.line&&(0,Q.jsxs)(`span`,{className:`ml-1 shrink-0 text-accent-primary`,children:[`:`,T.line]})]}),(0,Q.jsx)(Ht,{jobId:U,ticketId:W,ticketInput:G,onTicketInputChange:se,onApplyTicket:e=>fe({ticketId:jt(e.trim())}),onClear:()=>fe({}),summaryAction:T.path?re:null,copyPathAction:T.path?B:null}),(U||W)&&(0,Q.jsx)(Ut,{jobId:U,ticketId:W,onOpenFile:e=>J({path:e,changeJobId:U})},`${A}:${U}:${W}`),T.path?(0,Q.jsx)(Et,{compact:I,relPath:T.path,initialLine:T.line,initialJobId:T.changeJobId,onFilterJob:pe,onSummaryActionChange:z,onCopyPathActionChange:ie},`${A}:${T.path}`):(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-6`,children:(0,Q.jsxs)(`div`,{className:`max-w-sm space-y-4 text-center`,children:[(0,Q.jsx)(`div`,{className:`mx-auto flex h-14 w-14 items-center justify-center rounded-2xl border border-accent-primary/20 bg-accent-primary/10 text-accent-primary`,children:(0,Q.jsx)(oe,{className:`h-7 w-7`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h1`,{className:`text-lg font-semibold`,children:s(`explore.welcome`)}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-muted-foreground`,children:s(`explore.description`)})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{M(`search`),P(!0)},className:`rounded-lg bg-accent-primary/15 px-3 py-2 text-xs text-accent-primary`,children:s(`explore.findCode`)}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{M(`activity`),P(!0)},className:`rounded-lg border border-border px-3 py-2 text-xs text-muted-foreground hover:text-foreground`,children:s(`explore.viewActivity`)})]}),(0,Q.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground/80`,children:s(`explore.sourceHint`)})]})})]})]})]})})}function Ht({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:o,copyPathAction:s}){let{t:l}=c(`code`),u=t?`spec`:e?`job-context`:`all`;return(0,Q.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,Q.jsx)(W,{className:`h-3.5 w-3.5`}),l(`toolbar.scope`)]}),(0,Q.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":u===`all`,className:u===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.allAi`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":u===`spec`,className:u===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.spec`)}),(0,Q.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:l(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,Q.jsx)(`div`,{className:`flex-1`}),s&&(0,Q.jsx)(`button`,{type:`button`,onClick:s.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:l(`toolbar.copyFilePath`)}),o&&(0,Q.jsxs)(`button`,{type:`button`,onClick:o.onClick,disabled:o.regenerating||!!o.disabledReason,"aria-label":o.hasSummary?l(`toolbar.regenerateSummary`):l(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:o.disabledReason?l(`toolbar.summaryUnavailable`,{reason:o.disabledReason}):void 0,children:[(0,Q.jsx)(h,{className:o.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),o.hasSummary?o.regenerating?l(`toolbar.regenerating`):l(`toolbar.regenerateSummary`):o.regenerating?l(`toolbar.generating`):l(`toolbar.generateSummary`)]}),u===`job-context`&&(0,Q.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:l(`toolbar.jobContext`)}),(e||t)&&(0,Q.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Q.jsx)(k,{className:`h-3.5 w-3.5`}),l(`toolbar.clear`)]})]})})}function Ut({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=c(`code`),{apiBase:i}=Z(),[a,o]=(0,q.useState)(null),[s,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(0);(0,q.useEffect)(()=>{let n=new AbortController;o(null),l(!1),d(!1);let r=new URLSearchParams({limit:`100`});return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${i}/code/activity?${r}`,{signal:n.signal}).then(async e=>{if(!e.ok)throw Error(`activity_failed`);return e.json()}).then(e=>{if(n.signal.aborted)return;if(!Array.isArray(e.entries))throw Error(`invalid_activity_response`);let t=new Map;for(let n of e.entries)t.has(n.path)||t.set(n.path,n);o([...t.values()]),d(!!e.nextCursor||e.truncated===!0)}).catch(()=>{n.signal.aborted||l(!0)}),()=>n.abort()},[e,t,i,f]);let m=(0,q.useMemo)(()=>{let e=a??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[a]),h=a?.length??0,g=e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t});return(0,Q.jsxs)(`section`,{className:`max-h-52 shrink-0 overflow-auto border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:[s&&(0,Q.jsxs)(`p`,{role:`alert`,className:`mb-2 text-xs`,children:[r(`activity.failed`),` `,(0,Q.jsx)(`button`,{type:`button`,className:`text-accent-primary underline`,onClick:()=>p(e=>e+1),children:r(`explore.retry`)})]}),!a&&!s&&(0,Q.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-muted-foreground`,children:r(`activity.loading`)}),u&&(0,Q.jsx)(`p`,{role:`status`,className:`mb-2 text-xs text-amber-600 dark:text-amber-400`,children:r(`activity.partial`)}),(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:g}),(0,Q.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:a?r(`provenancePanel.touchedFiles`,{count:h}):`—`})]}),(0,Q.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Q.jsx)(Wt,{label:r(`action.added`),rows:m.created,icon:`created`,onOpenFile:n}),(0,Q.jsx)(Wt,{label:r(`action.changed`),rows:m.modified,icon:`modified`,onOpenFile:n}),(0,Q.jsx)(Wt,{label:r(`action.deleted`),rows:m.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,Q.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,Q.jsx)(T,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})]})}function Wt({label:e,rows:t,icon:n,onOpenFile:r}){return(0,Q.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,Q.jsx)(n===`created`?m:n===`deleted`?g:w,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{children:e}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,Q.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{Bt as default};
|
package/client/dist/assets/{DesktopAnalyticsPage-C87r4y26.js → DesktopAnalyticsPage-DEBidZbs.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{m as r,r as i}from"./useSharedWebSocket-CNOvmgTr.js";import{n as a,t as o}from"./createLucideIcon-DtODIU64.js";import{t as s}from"./clsx-CjueKrWZ.js";import{t as c}from"./utils-BC4DHlz2.js";import{Dt as l,an as u,lt as d}from"./index-Culan6y7.js";import{$ as f,A as p,Ct as m,E as h,F as g,G as _,H as v,L as y,M as b,N as x,O as S,P as C,Q as w,R as T,S as ee,St as te,U as ne,V as E,W as re,X as D,Y as O,_ as ie,a as ae,at as oe,b as se,bt as ce,c as le,d as ue,et as de,g as fe,gt as pe,h as me,ht as k,i as A,k as he,l as j,mt as M,n as ge,nt as _e,o as ve,ot as N,pt as P,q as ye,r as F,rt as I,s as be,st as L,t as xe,tt as R,u as Se,v as Ce,vt as we,x as Te,xt as Ee,yt as z,z as De}from"./BarChart-BDMqVFJy.js";var B={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};B.node;var Oe=o(B),V=e(t());function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},H.apply(null,arguments)}var U=e=>{var t=e.cx,n=e.cy,r=e.r,i=e.className,a=s(`recharts-dot`,i);return k(t)&&k(n)&&k(r)?V.createElement(`circle`,H({},te(e),L(e),{className:a,cx:t,cy:n,r})):null},ke=[`points`];function W(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?W(Object(n),!0).forEach(function(t){Ae(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ae(e,t,n){return(t=je(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function je(e){var t=Me(e,`string`);return typeof t==`symbol`?t:t+``}function Me(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function Ne(e,t){if(e==null)return{};var n,r,i=Pe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Pe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Fe(e){var t=e.option,n=e.dotProps,r=e.className;if((0,V.isValidElement)(t))return(0,V.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=s(r,typeof t==`boolean`?``:t.className),a=n??{};a.points;var o=Ne(a,ke);return V.createElement(U,K({},o,{className:i}))}function Ie(e,t){return e==null?!1:t?!0:e.length===1}function Le(e){var t=e.points,n=e.dot,r=e.className,i=e.dotClassName,a=e.dataKey,o=e.baseProps,s=e.needClip,c=e.clipPathId,l=e.zIndex,u=l===void 0?E.scatter:l;if(!Ie(t,n))return null;var d=S(n),f=Ee(n),p=t.map((e,r)=>{var s=G(G(G({r:3},o),f),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return V.createElement(Fe,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${d?``:`dots-`}${c})`),V.createElement(C,{zIndex:u},V.createElement(z,K({className:r},m),p))}function Re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Re(Object(n),!0).forEach(function(t){ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Re(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ze(e,t,n){return(t=Be(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Be(e){var t=Ve(e,`string`);return typeof t==`symbol`?t:t+``}function Ve(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var He=e=>{var t=e.point,n=e.childIndex,r=e.mainColor,i=e.activeDot,a=e.dataKey,o=e.clipPath;if(i===!1||t.x==null||t.y==null)return null;var s=q(q(q({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),m(i)),L(i)),c=(0,V.isValidElement)(i)?(0,V.cloneElement)(i,s):typeof i==`function`?i(s):V.createElement(U,s);return V.createElement(z,{className:`recharts-active-dot`,clipPath:o},c)};function Ue(e){var t=e.points,n=e.mainColor,r=e.activeDot,i=e.itemDataKey,a=e.clipPath,o=e.zIndex,s=o===void 0?E.activeDot:o,c=oe(g),l=Se();if(t==null||l==null)return null;var u=t.find(e=>l.includes(e.payload));return M(u)?null:V.createElement(C,{zIndex:s},V.createElement(He,{point:u,childIndex:Number(c),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var We=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function Ge(e,t){if(e==null)return{};var n,r,i=Ke(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ke(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function qe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function Je(e,t){return`${t}px ${e}px`}function Ye(e){return e.length%2==0?e:[...e,...e]}function Xe(e,t){for(var n=[],r=0;r<t;++r)n.push(...e);return n}function Ze(e,t,n){var r=Ye(n),i=r.reduce((e,t)=>e+t,0);if(!i)return Je(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;c<r.length;l+=(u=r[c])??0,++c){var u,d=r[c];if(d!=null&&l+d>o){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...Xe(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function Qe(e,t,n){return e?Ze(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Je(t,n)}function $e(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=Ge(e,We),a=r??!1,o;if(t!=null){var s=i.pathRef;o=Qe(n,qe(s?.current??null),t)}else n!=null&&(o=String(n));return V.createElement(ne,J({},i,{connectNulls:a,strokeDasharray:o}))}function et(e){var t=(0,V.useRef)(0),n=(0,V.useRef)(0),r=(0,V.useRef)(!1),i=(0,V.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,V.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(we(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}var tt=(e,t,n,r)=>y(e,`xAxis`,t,r),nt=(e,t,n,r)=>T(e,`xAxis`,t,r),rt=(e,t,n,r)=>y(e,`yAxis`,n,r),it=(e,t,n,r)=>T(e,`yAxis`,n,r),at=I([_,tt,rt,nt,it],(e,t,n,r,i)=>_e(e,`xAxis`)?w(t,r,!1):w(n,i,!1)),ot=(e,t,n,r,i)=>i;function st(e){return e.type===`line`}var ct=I([_,tt,rt,nt,it,I([De,ot],(e,t)=>e.filter(st).find(e=>e.id===t)),at,v],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return At({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function lt(e){var t=m(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var ut=[`id`],dt=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],ft=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(null,arguments)}function X(e,t){if(e==null)return{};var n,r,i=pt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function mt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?mt(Object(n),!0).forEach(function(t){ht(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ht(e,t,n){return(t=gt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gt(e){var t=_t(e,`string`);return typeof t==`symbol`?t:t+``}function _t(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function vt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function yt(e){var t=0,n=0;for(var r of e)r.status===`matched`&&r.prev.x!=null&&r.next.x!=null&&(t+=r.next.x-r.prev.x,n++);return n>0?t/n:0}var Q={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=yt(e),r=[];for(var i of e)if(i.status===`matched`)r.push(Z(Z({},i.next),{},{x:P(i.prev.x,i.next.x,t),y:P(i.prev.y,i.next.y,t)}));else if(i.status===`added`)if(i.next.x!=null){var a=i.next.x-n;r.push(Z(Z({},i.next),{},{x:P(a,i.next.x,t),y:i.next.y}))}else r.push(i.next);else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(Z(Z({},i.prev),{},{x:P(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:se,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:$e,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:E.line,type:`linear`},bt=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:de(n,t),payload:e}]},xt=V.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:pe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:de(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return V.createElement(ee,{tooltipEntrySettings:f})});function St(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=te(X(r,ut));return V.createElement(Le,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:s,needClip:o,clipPathId:t})}function Ct(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,V.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return V.createElement(he,{value:t?i:void 0},n)}function wt(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,g=Z(Z({},ce(X(i,dt))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return V.createElement(V.Fragment,null,r?.length>1&&V.createElement(h,{option:p,DefaultShape:Q.shape,shapeProps:g}),V.createElement(St,{points:r,clipPathId:t,props:i}))}function Tt(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,m=vt(r.current),h=Ce(n.onAnimationStart,n.onAnimationEnd),g=h.isAnimating,_=h.handleAnimationStart,v=h.handleAnimationEnd,y=!g,b=et(a),x=(0,V.useCallback)(e=>e>0&&m>0,[m]);return V.createElement(Ct,{points:a,showLabels:y},n.children,V.createElement(ie,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:_,onAnimationEnd:v,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:x,layout:f},(e,i,a)=>{var o=g||i<1,s=o?b(i,m):null;return V.createElement(wt,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),V.createElement(p,{label:n.label}))}function Et(e){var t=e.clipPathId,n=e.props,r=(0,V.useRef)(null),i=(0,V.useRef)(null);return V.createElement(Tt,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var Dt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:R(e.payload,t)}),Ot=class extends V.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.xAxisId,o=e.yAxisId,c=e.top,l=e.left,u=e.width,d=e.height,f=e.id,p=e.needClip,m=e.zIndex;if(t)return null;var h=s(`recharts-line`,i),g=f,_=lt(n),v=_.r,y=_.strokeWidth,b=S(n),x=v*2+y,w=p?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return V.createElement(C,{zIndex:m},V.createElement(z,{className:h},p&&V.createElement(`defs`,null,V.createElement(ve,{clipPathId:g,xAxisId:a,yAxisId:o}),!b&&V.createElement(`clipPath`,{id:`clipPath-dots-${g}`},V.createElement(`rect`,{x:l-x/2,y:c-x/2,width:u+x,height:d+x}))),V.createElement(le,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:Dt,errorBarOffset:0},V.createElement(Et,{props:this.props,clipPathId:g}))),V.createElement(Ue,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:w}))}};function kt(e){var t=N(e,Q),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,p=t.xAxisId,m=t.yAxisId,h=t.id,g=X(t,ft),_=be(p,m).needClip,v=ue(),y=ye(),b=D(),x=oe(e=>ct(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var S=v.height,C=v.width,w=v.x,T=v.y;return V.createElement(Ot,Y({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function At(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=R(e,o);if(t===`horizontal`)return{x:f({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(M(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=M(l)?null:n.scale.map(l),d=f({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function jt(e){var t=N(e,Q),n=D();return V.createElement(fe,{id:t.id,type:`line`},e=>V.createElement(V.Fragment,null,V.createElement(Te,{legendPayload:bt(t)}),V.createElement(xt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),V.createElement(me,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),V.createElement(kt,Y({},t,{id:e}))))}var Mt=V.memo(jt,re);Mt.displayName=`Line`;var Nt=[`axis`],Pt=(0,V.forwardRef)((e,t)=>V.createElement(ge,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Nt,tooltipPayloadSearcher:x,categoricalChartProps:e,ref:t})),$=n(),Ft=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function It({period:e,from:t,to:n,onChange:r}){let{t:i}=a(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function l(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:Ft.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:c(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:i(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":i(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>l(e.target.value),"aria-label":i(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Lt({kpi:e,windowLabel:t}){let{t:n}=a(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=i>0,l=typeof e.pricedRuns==`number`||typeof e.unpricedRuns==`number`,u=e.unpricedRuns??0,d=e.pricedRuns??(l?Math.max(0,e.totalJobs-u):e.totalJobs),f=l&&e.totalCostUsd===0&&u>0&&d===0,p=u>0&&(d>0||e.totalCostUsd>0),m=e.unpricedTodayRuns??0,h=e.pricedTodayRuns??(l?Math.max(0,e.jobsToday-m):e.jobsToday),g=l&&e.costToday===0&&m>0&&h===0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:f?`—`:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:g?n(`desktop.costTodayUnavailable`):n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0&&u===0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(u>0?`desktop.averageUnavailable`:`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})}),(f||p)&&(0,$.jsx)(`p`,{"data-testid":`kpi-cost-coverage-note`,className:`text-[10px] text-muted-foreground/70 italic`,children:f?n(`desktop.costUnavailable`):n(`desktop.costPartiallyUnavailable`,{count:u})})]})}function Rt({data:e}){let{t}=a(`analytics`),n=u(),i=e.length>0&&e.some(e=>e.costUsd>0),o=e.reduce((e,t)=>e+(t.unpricedCount??0),0),s=!i&&o>0,c=i&&o>0,l=Math.max(1,Math.floor(e.length/7)),f=e.filter((e,t)=>t%l===0).map(e=>e.date),p=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),m=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),m&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)}),c&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,children:t(`desktop.costPartiallyUnavailable`,{count:o})})]}),s?(0,$.jsx)(`div`,{"data-testid":`desktop-timeline-cost-unavailable`,className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):i?(0,$.jsx)(O,{width:`100%`,height:200,children:(0,$.jsxs)(Pt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(j,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(A,{dataKey:`date`,ticks:f,tickFormatter:e=>{try{return d(new Date(e),`MMM d`,{locale:r()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(F,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(b,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(p.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(Mt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function zt({projects:e}){let{t}=a(`analytics`),n=u();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0,s=e.unpricedRuns??0,c=e.pricedRuns??Math.max(0,e.totalJobs-s),l=s>0&&c===0,u=s>0&&c>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,title:u?t(`desktop.costPartiallyUnavailable`,{count:s}):void 0,children:l?t(`desktop.costUnavailableShort`):`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Bt({projects:e}){let{t}=a(`analytics`),n=u();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd})),i=e.some(e=>e.totalCostUsd>0),o=e.some(e=>(e.unpricedRuns??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),!i&&o?(0,$.jsx)(`div`,{"data-testid":`desktop-project-cost-unavailable`,className:`h-[180px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):(0,$.jsx)(O,{width:`100%`,height:180,children:(0,$.jsxs)(xe,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(j,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(A,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(F,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(b,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(ae,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Vt(){let{t:e}=a(`analytics`),[t,n]=(0,V.useState)(`7d`),[r,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(``),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(null),{registerHandler:g,unregisterHandler:_}=i(),v=(0,V.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,r,s)},[t,r,s]);(0,V.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();d(a)}catch(e){h(e.message)}finally{p(!1)}}(0,V.useEffect)(()=>{y(t,r,s)},[t,r,s]);function b(e,t,r){n(e),t!==void 0&&o(t),r!==void 0&&c(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Oe,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(It,{period:t,from:r,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(l,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Lt,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(Rt,{data:u.costTimeline}),(0,$.jsx)(Bt,{projects:u.projectBreakdown})]}),(0,$.jsx)(zt,{projects:u.projectBreakdown})]})]})})}export{Vt as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{m as r,r as i}from"./useSharedWebSocket-CcsE5986.js";import{n as a,t as o}from"./createLucideIcon-DtODIU64.js";import{t as s}from"./clsx-CjueKrWZ.js";import{t as c}from"./utils-BC4DHlz2.js";import{Dt as l,an as u,lt as d}from"./index-CECj3joE.js";import{$ as f,A as p,Ct as m,E as h,F as g,G as _,H as v,L as y,M as b,N as x,O as S,P as C,Q as w,R as T,S as ee,St as te,U as ne,V as E,W as re,X as D,Y as O,_ as ie,a as ae,at as oe,b as se,bt as ce,c as le,d as ue,et as de,g as fe,gt as pe,h as me,ht as k,i as A,k as he,l as j,mt as M,n as ge,nt as _e,o as ve,ot as N,pt as P,q as ye,r as F,rt as I,s as be,st as L,t as xe,tt as R,u as Se,v as Ce,vt as we,x as Te,xt as Ee,yt as z,z as De}from"./BarChart-BDMqVFJy.js";var B={name:`trending-up`,size:24,node:[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]};B.node;var Oe=o(B),V=e(t());function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},H.apply(null,arguments)}var U=e=>{var t=e.cx,n=e.cy,r=e.r,i=e.className,a=s(`recharts-dot`,i);return k(t)&&k(n)&&k(r)?V.createElement(`circle`,H({},te(e),L(e),{className:a,cx:t,cy:n,r})):null},ke=[`points`];function W(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function G(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?W(Object(n),!0).forEach(function(t){Ae(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):W(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ae(e,t,n){return(t=je(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function je(e){var t=Me(e,`string`);return typeof t==`symbol`?t:t+``}function Me(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function Ne(e,t){if(e==null)return{};var n,r,i=Pe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Pe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Fe(e){var t=e.option,n=e.dotProps,r=e.className;if((0,V.isValidElement)(t))return(0,V.cloneElement)(t,n);if(typeof t==`function`)return t(n);var i=s(r,typeof t==`boolean`?``:t.className),a=n??{};a.points;var o=Ne(a,ke);return V.createElement(U,K({},o,{className:i}))}function Ie(e,t){return e==null?!1:t?!0:e.length===1}function Le(e){var t=e.points,n=e.dot,r=e.className,i=e.dotClassName,a=e.dataKey,o=e.baseProps,s=e.needClip,c=e.clipPathId,l=e.zIndex,u=l===void 0?E.scatter:l;if(!Ie(t,n))return null;var d=S(n),f=Ee(n),p=t.map((e,r)=>{var s=G(G(G({r:3},o),f),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return V.createElement(Fe,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${d?``:`dots-`}${c})`),V.createElement(C,{zIndex:u},V.createElement(z,K({className:r},m),p))}function Re(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Re(Object(n),!0).forEach(function(t){ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Re(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ze(e,t,n){return(t=Be(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Be(e){var t=Ve(e,`string`);return typeof t==`symbol`?t:t+``}function Ve(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var He=e=>{var t=e.point,n=e.childIndex,r=e.mainColor,i=e.activeDot,a=e.dataKey,o=e.clipPath;if(i===!1||t.x==null||t.y==null)return null;var s=q(q(q({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),m(i)),L(i)),c=(0,V.isValidElement)(i)?(0,V.cloneElement)(i,s):typeof i==`function`?i(s):V.createElement(U,s);return V.createElement(z,{className:`recharts-active-dot`,clipPath:o},c)};function Ue(e){var t=e.points,n=e.mainColor,r=e.activeDot,i=e.itemDataKey,a=e.clipPath,o=e.zIndex,s=o===void 0?E.activeDot:o,c=oe(g),l=Se();if(t==null||l==null)return null;var u=t.find(e=>l.includes(e.payload));return M(u)?null:V.createElement(C,{zIndex:s},V.createElement(He,{point:u,childIndex:Number(c),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var We=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function Ge(e,t){if(e==null)return{};var n,r,i=Ke(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ke(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function qe(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function Je(e,t){return`${t}px ${e}px`}function Ye(e){return e.length%2==0?e:[...e,...e]}function Xe(e,t){for(var n=[],r=0;r<t;++r)n.push(...e);return n}function Ze(e,t,n){var r=Ye(n),i=r.reduce((e,t)=>e+t,0);if(!i)return Je(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;c<r.length;l+=(u=r[c])??0,++c){var u,d=r[c];if(d!=null&&l+d>o){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...Xe(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function Qe(e,t,n){return e?Ze(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Je(t,n)}function $e(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=Ge(e,We),a=r??!1,o;if(t!=null){var s=i.pathRef;o=Qe(n,qe(s?.current??null),t)}else n!=null&&(o=String(n));return V.createElement(ne,J({},i,{connectNulls:a,strokeDasharray:o}))}function et(e){var t=(0,V.useRef)(0),n=(0,V.useRef)(0),r=(0,V.useRef)(!1),i=(0,V.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,V.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(we(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}var tt=(e,t,n,r)=>y(e,`xAxis`,t,r),nt=(e,t,n,r)=>T(e,`xAxis`,t,r),rt=(e,t,n,r)=>y(e,`yAxis`,n,r),it=(e,t,n,r)=>T(e,`yAxis`,n,r),at=I([_,tt,rt,nt,it],(e,t,n,r,i)=>_e(e,`xAxis`)?w(t,r,!1):w(n,i,!1)),ot=(e,t,n,r,i)=>i;function st(e){return e.type===`line`}var ct=I([_,tt,rt,nt,it,I([De,ot],(e,t)=>e.filter(st).find(e=>e.id===t)),at,v],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return At({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function lt(e){var t=m(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var ut=[`id`],dt=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],ft=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Y(){return Y=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Y.apply(null,arguments)}function X(e,t){if(e==null)return{};var n,r,i=pt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function mt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?mt(Object(n),!0).forEach(function(t){ht(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ht(e,t,n){return(t=gt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gt(e){var t=_t(e,`string`);return typeof t==`symbol`?t:t+``}function _t(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function vt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function yt(e){var t=0,n=0;for(var r of e)r.status===`matched`&&r.prev.x!=null&&r.next.x!=null&&(t+=r.next.x-r.prev.x,n++);return n>0?t/n:0}var Q={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=yt(e),r=[];for(var i of e)if(i.status===`matched`)r.push(Z(Z({},i.next),{},{x:P(i.prev.x,i.next.x,t),y:P(i.prev.y,i.next.y,t)}));else if(i.status===`added`)if(i.next.x!=null){var a=i.next.x-n;r.push(Z(Z({},i.next),{},{x:P(a,i.next.x,t),y:i.next.y}))}else r.push(i.next);else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(Z(Z({},i.prev),{},{x:P(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:se,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:$e,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:E.line,type:`linear`},bt=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:de(n,t),payload:e}]},xt=V.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:pe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:de(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return V.createElement(ee,{tooltipEntrySettings:f})});function St(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=te(X(r,ut));return V.createElement(Le,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:s,needClip:o,clipPathId:t})}function Ct(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,V.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return V.createElement(he,{value:t?i:void 0},n)}function wt(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,g=Z(Z({},ce(X(i,dt))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return V.createElement(V.Fragment,null,r?.length>1&&V.createElement(h,{option:p,DefaultShape:Q.shape,shapeProps:g}),V.createElement(St,{points:r,clipPathId:t,props:i}))}function Tt(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,m=vt(r.current),h=Ce(n.onAnimationStart,n.onAnimationEnd),g=h.isAnimating,_=h.handleAnimationStart,v=h.handleAnimationEnd,y=!g,b=et(a),x=(0,V.useCallback)(e=>e>0&&m>0,[m]);return V.createElement(Ct,{points:a,showLabels:y},n.children,V.createElement(ie,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:_,onAnimationEnd:v,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:x,layout:f},(e,i,a)=>{var o=g||i<1,s=o?b(i,m):null;return V.createElement(wt,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),V.createElement(p,{label:n.label}))}function Et(e){var t=e.clipPathId,n=e.props,r=(0,V.useRef)(null),i=(0,V.useRef)(null);return V.createElement(Tt,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var Dt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:R(e.payload,t)}),Ot=class extends V.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.xAxisId,o=e.yAxisId,c=e.top,l=e.left,u=e.width,d=e.height,f=e.id,p=e.needClip,m=e.zIndex;if(t)return null;var h=s(`recharts-line`,i),g=f,_=lt(n),v=_.r,y=_.strokeWidth,b=S(n),x=v*2+y,w=p?`url(#clipPath-${b?``:`dots-`}${g})`:void 0;return V.createElement(C,{zIndex:m},V.createElement(z,{className:h},p&&V.createElement(`defs`,null,V.createElement(ve,{clipPathId:g,xAxisId:a,yAxisId:o}),!b&&V.createElement(`clipPath`,{id:`clipPath-dots-${g}`},V.createElement(`rect`,{x:l-x/2,y:c-x/2,width:u+x,height:d+x}))),V.createElement(le,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:Dt,errorBarOffset:0},V.createElement(Et,{props:this.props,clipPathId:g}))),V.createElement(Ue,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:w}))}};function kt(e){var t=N(e,Q),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,p=t.xAxisId,m=t.yAxisId,h=t.id,g=X(t,ft),_=be(p,m).needClip,v=ue(),y=ye(),b=D(),x=oe(e=>ct(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var S=v.height,C=v.width,w=v.x,T=v.y;return V.createElement(Ot,Y({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function At(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=R(e,o);if(t===`horizontal`)return{x:f({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(M(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=M(l)?null:n.scale.map(l),d=f({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function jt(e){var t=N(e,Q),n=D();return V.createElement(fe,{id:t.id,type:`line`},e=>V.createElement(V.Fragment,null,V.createElement(Te,{legendPayload:bt(t)}),V.createElement(xt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),V.createElement(me,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),V.createElement(kt,Y({},t,{id:e}))))}var Mt=V.memo(jt,re);Mt.displayName=`Line`;var Nt=[`axis`],Pt=(0,V.forwardRef)((e,t)=>V.createElement(ge,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Nt,tooltipPayloadSearcher:x,categoricalChartProps:e,ref:t})),$=n(),Ft=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function It({period:e,from:t,to:n,onChange:r}){let{t:i}=a(`analytics`);function o(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function l(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:Ft.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:c(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:i(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":i(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>l(e.target.value),"aria-label":i(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Lt({kpi:e,windowLabel:t}){let{t:n}=a(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,o=e.includesEstimated??r>0,s=r>0,c=i>0,l=typeof e.pricedRuns==`number`||typeof e.unpricedRuns==`number`,u=e.unpricedRuns??0,d=e.pricedRuns??(l?Math.max(0,e.totalJobs-u):e.totalJobs),f=l&&e.totalCostUsd===0&&u>0&&d===0,p=u>0&&(d>0||e.totalCostUsd>0),m=e.unpricedTodayRuns??0,h=e.pricedTodayRuns??(l?Math.max(0,e.jobsToday-m):e.jobsToday),g=l&&e.costToday===0&&m>0&&h===0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:f?`—`:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:g?n(`desktop.costTodayUnavailable`):n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0&&u===0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(u>0?`desktop.averageUnavailable`:`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})}),(f||p)&&(0,$.jsx)(`p`,{"data-testid":`kpi-cost-coverage-note`,className:`text-[10px] text-muted-foreground/70 italic`,children:f?n(`desktop.costUnavailable`):n(`desktop.costPartiallyUnavailable`,{count:u})})]})}function Rt({data:e}){let{t}=a(`analytics`),n=u(),i=e.length>0&&e.some(e=>e.costUsd>0),o=e.reduce((e,t)=>e+(t.unpricedCount??0),0),s=!i&&o>0,c=i&&o>0,l=Math.max(1,Math.floor(e.length/7)),f=e.filter((e,t)=>t%l===0).map(e=>e.date),p=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),m=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),m&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)}),c&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,children:t(`desktop.costPartiallyUnavailable`,{count:o})})]}),s?(0,$.jsx)(`div`,{"data-testid":`desktop-timeline-cost-unavailable`,className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):i?(0,$.jsx)(O,{width:`100%`,height:200,children:(0,$.jsxs)(Pt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(j,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(A,{dataKey:`date`,ticks:f,tickFormatter:e=>{try{return d(new Date(e),`MMM d`,{locale:r()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(F,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(b,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(p.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(Mt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function zt({projects:e}){let{t}=a(`analytics`),n=u();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0,s=e.unpricedRuns??0,c=e.pricedRuns??Math.max(0,e.totalJobs-s),l=s>0&&c===0,u=s>0&&c>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,title:u?t(`desktop.costPartiallyUnavailable`,{count:s}):void 0,children:l?t(`desktop.costUnavailableShort`):`${o?`~`:``}$${e.totalCostUsd.toFixed(4)}`})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Bt({projects:e}){let{t}=a(`analytics`),n=u();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd})),i=e.some(e=>e.totalCostUsd>0),o=e.some(e=>(e.unpricedRuns??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),!i&&o?(0,$.jsx)(`div`,{"data-testid":`desktop-project-cost-unavailable`,className:`h-[180px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.costUnavailable`)}):(0,$.jsx)(O,{width:`100%`,height:180,children:(0,$.jsxs)(xe,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(j,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(A,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(F,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(b,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(ae,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Vt(){let{t:e}=a(`analytics`),[t,n]=(0,V.useState)(`7d`),[r,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(``),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!0),[m,h]=(0,V.useState)(null),{registerHandler:g,unregisterHandler:_}=i(),v=(0,V.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,r,s)},[t,r,s]);(0,V.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();d(a)}catch(e){h(e.message)}finally{p(!1)}}(0,V.useEffect)(()=>{y(t,r,s)},[t,r,s]);function b(e,t,r){n(e),t!==void 0&&o(t),r!==void 0&&c(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Oe,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(It,{period:t,from:r,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(l,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Lt,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(Rt,{data:u.costTimeline}),(0,$.jsx)(Bt,{projects:u.projectBreakdown})]}),(0,$.jsx)(zt,{projects:u.projectBreakdown})]})]})})}export{Vt as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{n as r}from"./createLucideIcon-DtODIU64.js";import{n as i,t as a}from"./file-text-C0blZHLh.js";import{t as o}from"./loader-circle-BqV9xYGf.js";import{i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./utils-BC4DHlz2.js";import{n as p,t as m}from"./lib-DWJfei6y.js";import{tn as h}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{n as r}from"./createLucideIcon-DtODIU64.js";import{n as i,t as a}from"./file-text-C0blZHLh.js";import{t as o}from"./loader-circle-BqV9xYGf.js";import{i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./utils-BC4DHlz2.js";import{n as p,t as m}from"./lib-DWJfei6y.js";import{tn as h}from"./index-CECj3joE.js";import{t as g}from"./lib-CQJT8S6Q.js";import{t as _}from"./atom-one-dark-qiGhVQxg.js";var v=e(t(),1),y=n();function b({categories:e,activeCategory:t,activeSlug:n,onSelect:i,onHome:o}){let{t:s}=r(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:o,className:f(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(h,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:s(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:s(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(r=>{let o=t===e.slug&&n===r.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>i(e.slug,r.slug),title:r.title,className:f(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,o?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:r.title})]})},r.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=r(`integrations`),o=e.reduce((e,t)=>e+t.docs.length,0),s=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:o}),categories:n(`docs.categoryCount`,{count:s})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(n=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n.title}),(0,y.jsx)(i,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(p,{remarkPlugins:[m],rehypePlugins:[g],components:{a({href:e,children:r,...i}){return(0,y.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=_(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function C({category:e,slug:t,lang:n,onNotFound:i,onNavigate:a,scrollContainerRef:s}){let{t:c}=r(`integrations`),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let r=++p.current;f(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){i();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r===p.current&&e&&(u(e),s.current&&(s.current.scrollTop=0))}).catch(e=>{r===p.current&&f(e instanceof Error?e.message:c(`docs.loadError`))})},[e,t,n,i,s]),!l&&!d?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(o,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!l?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):l?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.jsx)(`div`,{className:`prose prose-sm max-w-none
|
|
2
2
|
prose-headings:text-foreground prose-headings:font-bold
|
|
3
3
|
prose-p:text-foreground/90
|
|
4
4
|
prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{d as r,n as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as o}from"./createLucideIcon-DtODIU64.js";import{n as s,t as c}from"./file-text-C0blZHLh.js";import{t as l}from"./loader-circle-BqV9xYGf.js";import{t as u}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-DWJfei6y.js";import{tn as p}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{d as r,n as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as o}from"./createLucideIcon-DtODIU64.js";import{n as s,t as c}from"./file-text-C0blZHLh.js";import{t as l}from"./loader-circle-BqV9xYGf.js";import{t as u}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-DWJfei6y.js";import{tn as p}from"./index-CECj3joE.js";import{t as m}from"./lib-CQJT8S6Q.js";import{t as h}from"./atom-one-dark-qiGhVQxg.js";var g=e(t(),1),_=n();function v({categories:e,activeCategory:t,activeSlug:n}){let{t:r}=o(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3 space-y-4`,children:[(0,_.jsxs)(i,{to:`/docs`,className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r(`docs.title`)})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,_.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,_.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,_.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:r(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(r=>{let a=t===e.slug&&n===r.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(i,{to:`/docs/${e.slug}/${r.slug}`,title:r.title,className:u(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(c,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r.title})]})},r.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=o(`integrations`),n=e.reduce((e,t)=>e+t.docs.length,0),r=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,_.jsx)(p,{className:`w-4 h-4`}),t(`docs.title`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:n}),categories:t(`docs.categoryCount`,{count:r})})})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:t(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(i,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-3 p-2.5 rounded-md border border-border transition-colors hover:bg-muted/40 group`,children:[(0,_.jsx)(c,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,_.jsx)(s,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))]})}var b=(0,g.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,_.jsx)(d,{remarkPlugins:[f],rehypePlugins:[m],components:{a({href:e,children:r,...i}){return(0,_.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=h(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function x({category:e,slug:t,lang:n,scrollContainerRef:r}){let{t:i}=o(`integrations`),[s,c]=(0,g.useState)(null),[u,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=a();return(0,g.useEffect)(()=>{let a=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){p(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{a===f.current&&e&&(c(e),r.current&&(r.current.scrollTop=0))}).catch(e=>{a===f.current&&d(e instanceof Error?e.message:i(`docs.loadError`))})},[e,t,n,p,r]),!s&&!u?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(l,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!s?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):s?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
|
|
2
2
|
prose-headings:text-foreground prose-headings:font-bold
|
|
3
3
|
prose-p:text-foreground/90
|
|
4
4
|
prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{n as r}from"./createLucideIcon-DtODIU64.js";import{s as i}from"./useDesktop-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{n as r}from"./createLucideIcon-DtODIU64.js";import{s as i}from"./useDesktop-C0mRIlHT.js";import{t as a}from"./download-C9wP_42h.js";var o=e(t(),1),s=n(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:t,label:n,disabled:u}){let{t:d}=r(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(n=>`${e}?${new URLSearchParams({format:n.format,mode:n.mode,...t}).toString()}`,[e,t]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),i.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(a,{className:`w-3 h-3`}),m?d(`export.downloading`):n??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(a,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
|