specrails-desktop 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/client/dist/assets/{ActivityFeedPage-D0-P3PsD.js → ActivityFeedPage-BBGvhMX5.js} +1 -1
  2. package/client/dist/assets/AgentsPage-CSrs9kuV.js +86 -0
  3. package/client/dist/assets/{AnalyticsPage-CgaEg-lx.js → AnalyticsPage-B011XilA.js} +1 -1
  4. package/client/dist/assets/{BarChart-D9vfeilz.js → BarChart-zCFHhnbZ.js} +2 -2
  5. package/client/dist/assets/CodePage-MB0JiLis.js +2 -0
  6. package/client/dist/assets/{DesktopAnalyticsPage-C6Qccm5E.js → DesktopAnalyticsPage-DlrcBWPo.js} +1 -1
  7. package/client/dist/assets/{DocsDialog-BAmtk9Jc.js → DocsDialog-B8mSbQhA.js} +2 -2
  8. package/client/dist/assets/DocsPage-D7t2Bc-K.js +11 -0
  9. package/client/dist/assets/{ExportDropdown-DMJ__Yui.js → ExportDropdown-ClTut9WA.js} +1 -1
  10. package/client/dist/assets/{IntegrationsPage-CP2VcOpr.js → IntegrationsPage-CgJf4uLW.js} +3 -3
  11. package/client/dist/assets/JobDetailPage-DlyLLI4l.js +16 -0
  12. package/client/dist/assets/JobsPage-mbez97dP.js +1 -0
  13. package/client/dist/assets/LoopBuilderPage-CScd8wyY.js +7 -0
  14. package/client/dist/assets/LoopsPage-mBDRcEzq.js +1 -0
  15. package/client/dist/assets/{dist-js-_oLAsZQ4.js → dist-js-BHJ5LpTw.js} +1 -1
  16. package/client/dist/assets/{dist-js-o4iwbCuN.js → dist-js-Ca7dsMhN.js} +1 -1
  17. package/client/dist/assets/{index-DrFJinsI.css → index-ByhYcYLV.css} +1 -1
  18. package/client/dist/assets/{index-QEeqwz4v.js → index-CEunZ8kJ.js} +12 -11
  19. package/client/dist/assets/{lib-CVrpo1ac.js → lib-3_pPhUqA.js} +1 -1
  20. package/client/dist/assets/loops-BYNUJVyD.js +1 -0
  21. package/client/dist/assets/loops-B_gS4Pqu.js +1 -0
  22. package/client/dist/assets/loops-B_w7STrw.js +1 -0
  23. package/client/dist/assets/loops-DE-2cmLw.js +1 -0
  24. package/client/dist/assets/loops-D_ZxkD4l.js +1 -0
  25. package/client/dist/assets/loops-DfGadne0.js +1 -0
  26. package/client/dist/assets/loops-Fv4Bs-9A.js +1 -0
  27. package/client/dist/assets/loops-mcoeFMat.js +1 -0
  28. package/client/dist/assets/{upload-Dn9N1ESQ.js → upload-DsygVwLQ.js} +1 -1
  29. package/client/dist/assets/{value-Bd3Cf9Sr.js → value-B5mYukkD.js} +1 -1
  30. package/client/dist/index.html +3 -3
  31. package/package.json +1 -1
  32. package/server/dist/loop-command-catalog.js +87 -0
  33. package/server/dist/loop-constants.js +15 -1
  34. package/server/dist/loop-graph.js +21 -0
  35. package/server/dist/loop-templates-ported.js +671 -0
  36. package/server/dist/loop-templates.js +36 -1
  37. package/server/dist/loops-router.js +1 -0
  38. package/server/dist/project-router-loop-runs.js +15 -2
  39. package/server/dist/rails-router.js +9 -0
  40. package/client/dist/assets/AgentsPage-BZa3lhQM.js +0 -86
  41. package/client/dist/assets/CodePage-2GUsF_JS.js +0 -2
  42. package/client/dist/assets/DocsPage-CJwnpB57.js +0 -11
  43. package/client/dist/assets/JobDetailPage-Bk6tQTew.js +0 -16
  44. package/client/dist/assets/JobsPage-BvbeqWjS.js +0 -1
  45. package/client/dist/assets/LoopBuilderPage-BS3enu9N.js +0 -7
  46. package/client/dist/assets/LoopsPage-B0pgvoky.js +0 -2
  47. package/client/dist/assets/loops-B1ZQCKEk.js +0 -1
  48. package/client/dist/assets/loops-Bp5yTSic.js +0 -1
  49. package/client/dist/assets/loops-BvoL_LAc.js +0 -1
  50. package/client/dist/assets/loops-BwgehdXY.js +0 -1
  51. package/client/dist/assets/loops-CMLUqUpc.js +0 -1
  52. package/client/dist/assets/loops-CW69VvTI.js +0 -1
  53. package/client/dist/assets/loops-DkV2RhEb.js +0 -1
  54. package/client/dist/assets/loops-arQ602Zm.js +0 -1
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-Cd8qBRAT.js","assets/chunk-CilyBKbf.js","assets/preload-helper-DSXbuxSR.js","assets/editor.api2-Cwla1nvV.js","assets/editor-Br_kD0ds.css","assets/workers-yr2u4c3C.js","assets/monaco.contribution-CIvCAJs4.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./preload-helper-DSXbuxSR.js";import{$ as n,Dt as r,Et as i,It as a,Ot as o,Qt as s,Rt as c,V as l,Xt as u,Zt as d,_ as f,_t as p,a as m,bn as h,dn as g,dt as _,fn as v,g as y,gn as b,gt as x,ht as S,l as C,pt as w,vn as T,vt as E,yn as D,z as O,zt as k}from"./index-CEunZ8kJ.js";var A=a(`file`,[[`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`}]]),ee=a(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),j=a(`funnel`,[[`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`}]]),M=e(h(),1),N=e(D(),1);function te(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 P(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 F(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var I=(e,t)=>Math.abs(e-t)<1.01,L=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},R,z=()=>{if(R!==void 0)return R;if(typeof navigator>`u`)return R=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return R=!0;let e=navigator.maxTouchPoints;return R=navigator.platform===`MacIntel`&&e!==void 0&&e>0},B=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},ne=e=>e,V=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},H=(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(B(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(B(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},U={passive:!0},W=typeof window>`u`?!0:`onscrollend`in window,G=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&W,o=0,s=a?null:L(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,U),a&&r.addEventListener(`scrollend`,u,U),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},re=(e,t)=>G(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),K=(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`]},ie=(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})},ae=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:ne,rangeExtractor:V,onChange:()=>{},measureElement:K,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=P(()=>(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,!(!z()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,U),e.addEventListener(`touchend`,n,U),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=P(()=>[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=P(()=>[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=te(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=P(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?se({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=P(()=>{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))&&(z()&&(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=P(()=>[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 F(t[oe(0,t.length-1,r?e=>n[e*2]:e=>F(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&&I(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()}},oe=(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 se({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=oe(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 q=typeof document<`u`?M.useLayoutEffect:M.useEffect;function ce({useFlushSync:e=!0,...t}){let n=M.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,N.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=M.useState(()=>new ae(r));return i.setOptions(r),q(()=>i._didMount(),[]),q(()=>i._willUpdate()),i}function J(e){return ce({observeElementRect:H,observeElementOffset:re,scrollToFn:ie,...e})}var Y=d(),X=e=>`specrails-desktop:code-tree-filter:${e}`,Z=e=>`specrails-desktop:code-tree-collapsed:${e}`;function le(e){return e.split(`/`).length-1}function ue(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function de(e){return e?e.length>10?e.slice(0,10):e:null}function fe(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function pe(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 me({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:i}){let{t:a}=v(`code`),{activeProjectId:l}=c(),{openTicketDetail:d}=C(),{registerHandler:f,unregisterHandler:p}=u(),[m,h]=(0,M.useState)(()=>{if(!l)return`touched-by-ai`;try{let e=localStorage.getItem(X(l));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,M.useEffect)(()=>{if(l)try{localStorage.setItem(X(l),m)}catch{}},[m,l]);let[g,y]=(0,M.useState)(()=>{if(!l)return new Set;try{let e=localStorage.getItem(Z(l));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,M.useEffect)(()=>{if(l)try{localStorage.setItem(Z(l),JSON.stringify([...g]))}catch{}},[g,l]);let b=(0,M.useCallback)(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),x=(0,M.useCallback)(()=>{y(new Set)},[]),{data:S,refresh:T,isFirstLoad:E}=k({namespace:`code-tree:${m}:${m===`touched-by-ai`?`${n??`all-jobs`}:${i??`all-specs`}`:`all`}`,projectId:l,initialValue:[],fetcher:(0,M.useCallback)(async()=>{let e=[],t=null;for(let r=0;r<100;r+=1){let r=new URLSearchParams({withProvenance:`1`,filter:m});m===`touched-by-ai`&&n&&r.set(`jobId`,n),m===`touched-by-ai`&&typeof i==`number`&&r.set(`ticketId`,String(i)),t&&r.set(`cursor`,t);let a=await fetch(`${s()}/code/tree?${r.toString()}`);if(!a.ok)break;let o=await a.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[m,n,i])}),D=(0,M.useRef)(l);(0,M.useEffect)(()=>{D.current=l},[l]),(0,M.useEffect)(()=>{if(!l)return;let e=`code-tree-${l}`;return f(e,e=>{let t=e;t.projectId===D.current&&t.type===`file.provenance_updated`&&T()}),()=>p(e)},[l,f,p,T]);let j=(0,M.useRef)(null),N=(0,M.useMemo)(()=>(S??[]).filter(e=>!pe(e.path,g)),[S,g]),te=(0,M.useCallback)(()=>{y(new Set((S??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[S]),P=J({count:N.length,getScrollElement:()=>j.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()=>{}}}),F=N.length===0,I=(0,M.useMemo)(()=>(S??[]).filter(e=>e.kind===`file`).length,[S]);return(0,Y.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,Y.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(`touched-by-ai`),className:O(`px-2 py-1 rounded-md transition-colors`,m===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":m===`touched-by-ai`,children:a(n?`tree.jobFiles`:i?`tree.specFiles`:`tree.touchedByAi`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(`all`),className:O(`px-2 py-1 rounded-md transition-colors`,m===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":m===`all`,children:a(`tree.allFiles`)}),(0,Y.jsx)(`div`,{className:`flex-1`}),(0,Y.jsx)(`button`,{type:`button`,onClick:te,title:a(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.collapseAll`),children:(0,Y.jsx)(r,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:x,title:a(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":a(`tree.expandAll`),children:(0,Y.jsx)(o,{className:`w-3.5 h-3.5`})})]}),m===`touched-by-ai`&&I>0&&(0,Y.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,Y.jsx)(`span`,{children:a(`tree.touchedCount`,{count:I})})})]}),F&&E?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:a(`tree.loadingFiles`)})}):F&&m===`touched-by-ai`?(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`tree.emptyTouched`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>h(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:a(`tree.showAllFiles`)})]}):F?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:a(`tree.noFiles`)}):(0,Y.jsx)(`div`,{ref:j,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,Y.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`,width:`100%`},children:P.getVirtualItems().map(n=>{let i=N[n.index],s=le(i.path)*12,c=i.kind===`file`&&i.path===t,l=i.provenance?.createdByTicketId,u=i.provenance?.modifiedByTicketIds??[],f=i.provenance?.latest??null,p=de(f?.jobId),m=fe(f?.kind),h=i.kind===`dir`,v=h&&g.has(i.path),y=i.provenance?.touchedFileCount??0;return(0,Y.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:O(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,c&&`bg-muted text-foreground`),onClick:()=>{h?b(i.path):e(i.path)},role:`button`,tabIndex:0,"aria-expanded":h?!v:void 0,"data-testid":`file-tree-row-${i.path}`,children:[(0,Y.jsxs)(`span`,{style:{paddingLeft:s},className:`flex items-center gap-1 min-w-0 flex-1`,children:[h?(0,Y.jsxs)(Y.Fragment,{children:[v?(0,Y.jsx)(r,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,Y.jsx)(o,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),v?(0,Y.jsx)(ee,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,Y.jsx)(w,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,Y.jsx)(A,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,Y.jsx)(`span`,{className:`truncate ml-0.5`,children:ue(i.path)})]}),(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[h&&y>0&&(0,Y.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:a(`tree.folderTouched`,{count:y}),children:y}),!h&&m&&(0,Y.jsx)(`span`,{className:O(`text-[10px] px-1.5 py-0.5 rounded`,f?.kind===`created`&&`bg-accent-success/15 text-accent-success`,f?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,f?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:f?.kind===`created`?a(`tree.latestTitleCreated`):f?.kind===`deleted`?a(`tree.latestTitleDeleted`):a(`tree.latestTitleModified`),children:a(`action.${m}`)}),!h&&p&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:a(`tree.jobTitle`,{jobId:f?.jobId??``}),children:[(0,Y.jsx)(_,{className:`h-3 w-3`}),p]}),!h&&typeof l==`number`&&(0,Y.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),d(l)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${l}`,title:a(`tree.createdBySpec`,{id:l}),children:[`#`,l]}),!h&&u.slice(0,2).map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d(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:a(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},i.path)})})})]})}function he(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function ge(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function _e(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function ve(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var be=!1;function xe(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 Q(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=xe(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 Se(e){return`specrails-${e}`}function Ce(e,t){let n=Se(t.id),r=t.xterm,i=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(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":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function we(){be||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ge;case`css`:case`scss`:case`less`:return new _e;case`html`:case`handlebars`:case`razor`:return new ve;case`typescript`:case`javascript`:return new ye;default:return new he}}},!0)}function Te({content:e,language:n,readOnly:r,onChange:i}){let{t:a}=v(`code`),o=m(),s=(0,M.useRef)(null),c=(0,M.useRef)(null),l=(0,M.useRef)(null),[u,d]=(0,M.useState)(!1),f=(0,M.useRef)(e),p=(0,M.useRef)(n),h=(0,M.useRef)(o),g=(0,M.useRef)(r),_=(0,M.useRef)(i);return(0,M.useEffect)(()=>{f.current=e},[e]),(0,M.useEffect)(()=>{p.current=n},[n]),(0,M.useEffect)(()=>{h.current=o},[o]),(0,M.useEffect)(()=>{g.current=r},[r]),(0,M.useEffect)(()=>{_.current=i},[i]),(0,M.useEffect)(()=>{let e=!1;return we(),t(()=>import(`./editor.main-Cd8qBRAT.js`).then(t=>{if(e||!s.current)return;l.current=t;let n=Ce(t,h.current),r=t.editor.create(s.current,{value:f.current,language:p.current,readOnly:g.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{_.current?.(r.getValue())}),c.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||d(!0)}),()=>{e=!0,c.current?.dispose?.(),c.current=null}},[]),(0,M.useEffect)(()=>{let t=c.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,M.useEffect)(()=>{c.current?.updateOptions?.({readOnly:r})},[r]),(0,M.useEffect)(()=>{let e=l.current,t=c.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,M.useEffect)(()=>{let e=l.current;if(!e)return;let t=Ce(e,o);e.editor.setTheme(t)},[o]),u?(0,Y.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,Y.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:a(`monaco.reload`)})]}):(0,Y.jsx)(`div`,{ref:s,className:`w-full h-full`,"data-testid":`monaco-host`})}var Ee=(0,M.lazy)(async()=>({default:Te}));function De({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=v(`code`);return(0,Y.jsx)(M.Suspense,{fallback:(0,Y.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`monaco.loadingEditor`)}),children:(0,Y.jsx)(Ee,{content:e,language:t,readOnly:n,onChange:r})})}function Oe(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 ke({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:a,onCollapse:o}){let{t:s,i18n:c}=v(`code`),{openTicketDetail:l}=C();if(!t)return(0,Y.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a?s(`summary.unavailable`,{reason:a}):s(`summary.empty`)})]}),o&&(0,Y.jsxs)(`button`,{type:`button`,onClick:o,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,Y.jsx)(i,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})});let u=Oe(t.generatedAt,c.language),d=t.triggeredBy?.ticketId,f=t.triggeredBy?.modifiedTicketIds??[];return(0,Y.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,Y.jsx)(`span`,{className:O(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:s(`summary.stale`)}),r&&(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof d==`number`&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>l(d),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,d]}),f.map(e=>(0,Y.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,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u})]})]}),o&&(0,Y.jsxs)(`button`,{type:`button`,onClick:o,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,Y.jsx)(i,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})})}function Ae({content:e}){return(0,Y.jsx)(f,{remarkPlugins:[y],children:e})}function je(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var Me=180,Ne=120,Pe=240;function Fe(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Ie(e){return e?`specrails-desktop:code-history-height:${e}`:null}function Le(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Re(e){let t=Ie(e);if(!t)return Me;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:Me}catch{return Me}}function ze(e,t){let n=Ie(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Be(e){let t=Fe(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ve(e,t){let n=Fe(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function He(e){let t=Le(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ue(e,t){let n=Le(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function We(e,t){let n=Math.max(Ne,t-Pe);return Math.min(Math.max(e,Ne),n)}function Ge({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:r}){let{t:a}=v(`code`),{activeProjectId:l}=c(),{openTicketDetail:d}=C(),{registerHandler:f,unregisterHandler:p}=u(),m=(0,M.useRef)(null),[h,_]=(0,M.useState)(null),[y,b]=(0,M.useState)(!0),[x,S]=(0,M.useState)(!1),[w,T]=(0,M.useState)(!1),[E,D]=(0,M.useState)(()=>Be(l)),[O,k]=(0,M.useState)(()=>Re(l)),[A,ee]=(0,M.useState)(()=>He(l)),j=(0,M.useRef)(l);(0,M.useEffect)(()=>{j.current=l},[l]);let N=(0,M.useRef)(e);(0,M.useEffect)(()=>{N.current=e},[e]),(0,M.useEffect)(()=>{let e=m.current?.clientHeight||window.innerHeight;D(Be(l)),k(We(Re(l),e)),ee(He(l))},[l]);let te=(0,M.useCallback)(e=>{let t=e.clientY,n=O,r=m.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){k(We(n+(t-e.clientY),r))}function o(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),k(e=>{let t=We(e,r);return ze(l,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`pointercancel`,o)},[l,O]),P=(0,M.useCallback)(()=>{let e=We(Me,m.current?.clientHeight||window.innerHeight);k(e),ze(l,e)},[l]),F=(0,M.useCallback)(()=>{D(e=>{let t=!e;return Ve(l,t),t})},[l]),I=(0,M.useCallback)(()=>{ee(e=>{let t=!e;return Ue(l,t),t})},[l]);(0,M.useEffect)(()=>{S(!1),T(!1),H(`preview`),W(!1)},[e]);let L=(0,M.useRef)(0),R=(0,M.useCallback)(async()=>{let t=++L.current;b(!0);try{let n=await fetch(`${s()}/code/file?path=${encodeURIComponent(e)}`);if(t!==L.current)return;if(!n.ok){_(null);return}let r=await n.json();if(t!==L.current)return;_(r)}catch{t===L.current&&_(null)}finally{t===L.current&&b(!1)}},[e,l]);(0,M.useEffect)(()=>{R()},[R]),(0,M.useEffect)(()=>{if(!l)return;let e=`code-file-${l}`;return f(e,e=>{let t=e;t.projectId===j.current&&(t.type===`file.summary_updated`&&t.path===N.current?(S(!1),R()):t.type===`file.summary_failed`&&t.path===N.current?(g.error(t.reason??a(`summary.generationFailed`)),S(!1)):t.type===`file.summary_skipped`&&t.path===N.current&&(t.reason&&g(a(`summary.skipped`,{reason:t.reason})),S(!1)))}),()=>p(e)},[l,f,p,R,a]);let z=(0,M.useCallback)(async t=>{S(!0);try{let n=await fetch(`${s()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){S(!1);let e=typeof r.skipped==`string`?r.skipped:null;g.error(e?a(`summary.skipped`,{reason:e}):a(`summary.generationFailed`));return}if(r.skipped===`budget`){S(!1),T(!0);return}if(r.skipped){S(!1),g(a(`summary.skipped`,{reason:r.skipped}));return}await R(),S(!1)}catch{S(!1),g.error(a(`summary.generationFailed`))}},[R,e,a]),B=(0,M.useCallback)(async()=>{let t=h?.absolutePath??e;try{await navigator.clipboard?.writeText(t),g.success(a(`viewer.pathCopied`))}catch{g.error(a(`viewer.copyPathFailed`))}},[h,e,a]),ne=(0,M.useMemo)(()=>je(e,h?.language),[e,h?.language]),[V,H]=(0,M.useState)(`preview`),[U,W]=(0,M.useState)(!1),[G,re]=(0,M.useState)(``),[K,ie]=(0,M.useState)(!1),ae=h?.content!==void 0&&!h.binary&&!h.tooLarge&&h.reason!==`not-found`,oe=(0,M.useCallback)(()=>{re(h?.content??``),H(`raw`),W(!0)},[h]),se=(0,M.useCallback)(async()=>{ie(!0);try{let t=await fetch(`${s()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:G})});if(!t.ok){let e=await t.json().catch(()=>({}));g.error(e.error??a(`viewer.saveFailed`));return}g.success(a(`viewer.saved`)),W(!1),R()}catch{g.error(a(`viewer.saveFailed`))}finally{ie(!1)}},[e,G,a,R]),q=h?.summary??null,ce=!!h?.summaryStale,J=h?.provenance??[],X=h?.reason===`not-found`,Z=X?a(`summary.reason.missing`):h?.binary?a(`summary.reason.binary`):h?.tooLarge?a(`summary.reason.tooLarge`):null;return(0,M.useEffect)(()=>{if(n){if(y&&!h){n(null);return}return n({hasSummary:!!q,regenerating:x,disabledReason:Z,onClick:()=>z(!1)}),()=>n(null)}},[h,z,y,n,x,q,Z]),(0,M.useEffect)(()=>{if(r){if(y&&!h){r(null);return}return r({onClick:B}),()=>r(null)}},[B,h,y,r]),y&&!h?(0,Y.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:a(`viewer.loadingFile`)}):(0,Y.jsxs)(`div`,{ref:m,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[E?(0,Y.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,Y.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,Y.jsxs)(`button`,{type:`button`,onClick:F,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,Y.jsx)(o,{className:`h-3.5 w-3.5`}),a(`viewer.showSummary`)]})]}):(0,Y.jsx)(ke,{path:e,summary:q,stale:ce,regenerating:x,generateDisabledReason:Z,onCollapse:F}),(0,Y.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:ne&&h?.content!==void 0&&!h.binary&&!h.tooLarge&&(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":a(`viewer.markdownViewMode`),children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>H(`preview`),"aria-pressed":V===`preview`,className:V===`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:a(`viewer.preview`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>H(`raw`),"aria-pressed":V===`raw`,className:V===`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:a(`viewer.raw`)})]})}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ae&&!U&&(0,Y.jsx)(`button`,{type:`button`,onClick:oe,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:a(`viewer.edit`)}),U&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>W(!1),disabled:K,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:a(`actions.cancel`,{ns:`common`})}),(0,Y.jsx)(`button`,{type:`button`,onClick:se,disabled:K,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:a(K?`viewer.saving`:`viewer.save`)})]})]})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:X?(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:a(`viewer.missingFile`)}):h?.binary?(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:a(`viewer.binaryFile`)}):h?.tooLarge?(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:a(`viewer.tooLarge`,{size:Math.round((h.sizeBytes??0)/1024/1024)})}):h?.content===void 0?(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:a(`viewer.noContent`)}):U?(0,Y.jsx)(De,{content:G,language:h.language??`plaintext`,readOnly:!1,onChange:re}):ne&&V===`preview`?(0,Y.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,Y.jsx)(Ae,{content:h.content})}):(0,Y.jsx)(De,{content:h.content,language:h.language??`plaintext`})}),J.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`history.resize`),onPointerDown:A?void 0:te,onDoubleClick:A?void 0:P,className:A?`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:A?void 0:a(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,Y.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:a(`history.title`,{count:J.length})}),(0,Y.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:I,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:[A?(0,Y.jsx)(i,{className:`h-3.5 w-3.5`}):(0,Y.jsx)(o,{className:`h-3.5 w-3.5`}),a(A?`history.show`:`history.hide`)]})]}),!A&&(0,Y.jsx)(Ke,{rows:J,onOpenTicket:d,onFilterJob:t,height:O})]}),w&&(0,Y.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,children:(0,Y.jsxs)(`div`,{className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`viewer.budgetPrompt`)}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>T(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:a(`common:actions.cancel`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{T(!1),z(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:a(`common:actions.confirm`)})]})]})})]})}function Ke({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=v(`code`),[a,o]=(0,M.useState)(null),[c,l]=(0,M.useState)({});if(e.length===0)return null;async function u(e,t){if(a===t){o(null);return}if(o(t),!(!e.jobId||c[t])){l(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${s()}/code/diff?${n.toString()}`);if(r.status===404){l(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();l(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{l(e=>({...e,[t]:`missing`}))}}}return(0,Y.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,Y.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let o=e.kind===`created`?x:e.kind===`deleted`?p:S,s=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}`,d=c[l];return(0,Y.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,Y.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,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,Y.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`capitalize`,children:i(`kind.${e.kind}`)})]}),(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,Y.jsx)(_,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:i(`history.filterByJob`,{jobId:e.jobId}),children:s}):(0,Y.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:s}),e.jobId&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(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,Y.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,Y.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),a===l&&(0,Y.jsx)(`div`,{className:`px-2 pb-2`,children:d===`loading`?(0,Y.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.loadingDiff`)}):d===`missing`||!d?(0,Y.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.diffUnavailable`)}):(0,Y.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[d.patch,d.truncated?`\n${i(`history.diffTruncated`)}`:``]})})]},l)})})})}var qe=320,Je=240,Ye=520;function Xe(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function Ze(e){let t=Xe(e);if(!t)return qe;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:qe}catch{return qe}}function Qe(e,t){let n=Xe(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(Je,t-Ye);return Math.min(Math.max(e,Je),n)}function $e(){let{t:e}=v(`code`),{activeProjectId:t}=c(),[n]=T(),r=b(),i=(0,M.useRef)(null),[a,o]=(0,M.useState)(n.get(`path`)),[s,l]=(0,M.useState)(null),[u,d]=(0,M.useState)(null),[f,p]=(0,M.useState)(()=>Ze(t)),m=n.get(`jobId`),h=(0,M.useMemo)(()=>{let e=n.get(`ticketId`);if(!e)return null;let t=Number(e);return Number.isInteger(t)&&t>0?t:null},[n]),[g,_]=(0,M.useState)(h==null?``:String(h));(0,M.useEffect)(()=>{let e=n.get(`path`);e!==a&&o(e)},[n]),(0,M.useEffect)(()=>{_(h==null?``:String(h))},[h]),(0,M.useEffect)(()=>{let e=i.current?.clientWidth||window.innerWidth;p($(Ze(t),e))},[t]),(0,M.useEffect)(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&p(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let y=(0,M.useCallback)(e=>{let n=e.clientX,r=f,a=i.current?.clientWidth||window.innerWidth,o=e.currentTarget;try{o.setPointerCapture(e.pointerId)}catch{}function s(e){p($(r+(e.clientX-n),a))}function c(){window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),p(e=>{let n=$(e,a);return Qe(t,n),n})}window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[t,f]),x=(0,M.useCallback)(()=>{let e=$(qe,i.current?.clientWidth||window.innerWidth);p(e),Qe(t,e)},[t]),S=(0,M.useCallback)(e=>{o(e);let t=new URLSearchParams(n);t.set(`path`,e),r({pathname:`/code`,search:`?${t.toString()}`},{replace:!0})},[r,n]),C=(0,M.useCallback)(e=>{let t=new URLSearchParams(n);t.set(`jobId`,e),t.delete(`ticketId`),r({pathname:`/code`,search:`?${t.toString()}`},{replace:!0})},[r,n]),w=(0,M.useCallback)(()=>{let e=new URLSearchParams(n);e.delete(`jobId`),e.delete(`ticketId`),r({pathname:`/code`,search:e.toString()?`?${e.toString()}`:``},{replace:!0})},[r,n]),E=(0,M.useCallback)(e=>{let t=Number(e.trim());if(!Number.isInteger(t)||t<=0){w();return}let i=new URLSearchParams(n);i.set(`ticketId`,String(t)),i.delete(`jobId`),r({pathname:`/code`,search:`?${i.toString()}`},{replace:!0})},[w,r,n]);return(0,Y.jsxs)(`div`,{ref:i,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,Y.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:f},children:(0,Y.jsx)(me,{onOpenFile:S,selectedPath:a,filterJobId:m,filterTicketId:h},t??`no-project`)}),(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":e(`page.resizeFileTree`),onPointerDown:y,onDoubleClick:x,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:e(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,Y.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,Y.jsx)(et,{jobId:m,ticketId:h,ticketInput:g,onTicketInputChange:_,onApplyTicket:E,onClear:w,summaryAction:s,copyPathAction:u}),(m||h)&&(0,Y.jsx)(tt,{jobId:m,ticketId:h,onOpenFile:S}),a?(0,Y.jsx)(Ge,{relPath:a,onFilterJob:C,onSummaryActionChange:l,onCopyPathActionChange:d}):(0,Y.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:e(`page.selectFile`)})]})]})}function et({jobId:e,ticketId:t,ticketInput:r,onTicketInputChange:i,onApplyTicket:a,onClear:o,summaryAction:s,copyPathAction:c}){let{t:u}=v(`code`),d=t?`spec`:e?`job-context`:`all`;return(0,Y.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,Y.jsx)(j,{className:`h-3.5 w-3.5`}),u(`toolbar.scope`)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:o,"aria-pressed":d===`all`,className:d===`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:u(`toolbar.allAi`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(r),"aria-pressed":d===`spec`,className:d===`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:u(`toolbar.spec`)}),(0,Y.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a(r)},placeholder:u(`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,Y.jsx)(`div`,{className:`flex-1`}),c&&(0,Y.jsx)(`button`,{type:`button`,onClick:c.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:u(`toolbar.copyFilePath`)}),s&&(0,Y.jsxs)(`button`,{type:`button`,onClick:s.onClick,disabled:s.regenerating||!!s.disabledReason,"aria-label":s.hasSummary?u(`toolbar.regenerateSummary`):u(`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:s.disabledReason?u(`toolbar.summaryUnavailable`,{reason:s.disabledReason}):void 0,children:[(0,Y.jsx)(n,{className:s.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),s.hasSummary?s.regenerating?u(`toolbar.regenerating`):u(`toolbar.regenerateSummary`):s.regenerating?u(`toolbar.generating`):u(`toolbar.generateSummary`)]}),d===`job-context`&&(0,Y.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:u(`toolbar.jobContext`)}),(e||t)&&(0,Y.jsxs)(`button`,{type:`button`,onClick:o,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,Y.jsx)(l,{className:`h-3.5 w-3.5`}),u(`toolbar.clear`)]})]})})}function tt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=v(`code`),[i,a]=(0,M.useState)(null);(0,M.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${s()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||a(Array.isArray(e)?e:[])}).catch(()=>{n||a([])}),()=>{n=!0}},[e,t]);let o=(0,M.useMemo)(()=>{let e=i??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[i]),c=i?.length??0;return(0,Y.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,Y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:c})})]}),(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Y.jsx)(nt,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,Y.jsx)(nt,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,Y.jsx)(nt,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,Y.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,Y.jsx)(E,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function nt({label:e,rows:t,icon:n,onOpenFile:r}){return(0,Y.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,Y.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,Y.jsx)(n===`created`?x:n===`deleted`?p:S,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{children:e}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,Y.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,Y.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{$e as default};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./clsx-CjLeUJfG.js";import{Ft as n,Gt as r,Ht as i,Jt as a,Kt as o,R as s,Ut as c,Vt as l,Wt as u,Xt as d,Yt as f,a as p,d as m,dn as h,et as g,qt as _,yn as v,zt as y}from"./index-QEeqwz4v.js";import{$ as b,A as x,B as S,E as ee,F as C,H as w,K as T,L as E,N as D,O,P as te,Q as ne,R as re,S as ie,T as ae,U as oe,W as se,X as ce,Y as le,Z as ue,_ as de,_t as fe,a as pe,c as me,d as he,dt as k,et as A,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as j,it as xe,j as Se,k as Ce,l as we,lt as M,mt as Te,n as Ee,nt as De,o as Oe,pt as N,q as ke,r as Ae,rt as je,s as Me,t as Ne,u as Pe,ut as P,v as Fe,w as F,z as Ie}from"./BarChart-D9vfeilz.js";var Le=n(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]);function I(e,t){return i(e,{...t,weekStartsOn:1})}function L(e,t){let n=c(e,t?.in),r=n.getFullYear(),i=o(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=I(i),s=o(n,0);s.setFullYear(r,0,4),s.setHours(0,0,0,0);let l=I(s);return n.getTime()>=a.getTime()?r+1:n.getTime()>=l.getTime()?r:r-1}function R(e,t){let n=c(e,t?.in);return n.setHours(0,0,0,0),n}function Re(e,t,n){let[i,a]=r(n?.in,e,t),o=R(i),s=R(a),c=+o-m(o),l=+s-m(s);return Math.round((c-l)/_)}function ze(e,t){let n=L(e,t),r=o(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),I(r)}function Be(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Ve(e){return!(!Be(e)&&typeof e!=`number`||isNaN(+c(e)))}function He(e,t){let n=c(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ue(e,t){let n=c(e,t?.in);return Re(n,He(n))+1}function We(e,t){let n=c(e,t?.in),r=I(n)-+ze(n);return Math.round(r/a)+1}function z(e,t){let n=c(e,t?.in),r=n.getFullYear(),a=u(),s=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,l=o(t?.in||e,0);l.setFullYear(r+1,0,s),l.setHours(0,0,0,0);let d=i(l,t),f=o(t?.in||e,0);f.setFullYear(r,0,s),f.setHours(0,0,0,0);let p=i(f,t);return+n>=+d?r+1:+n>=+p?r:r-1}function Ge(e,t){let n=u(),r=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=z(e,t),s=o(t?.in||e,0);return s.setFullYear(a,0,r),s.setHours(0,0,0,0),i(s,t)}function Ke(e,t){let n=c(e,t?.in),r=i(n,t)-+Ge(n,t);return Math.round(r/a)+1}function B(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var V={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return B(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):B(n+1,2)},d(e,t){return B(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return B(e.getHours()%12||12,t.length)},H(e,t){return B(e.getHours(),t.length)},m(e,t){return B(e.getMinutes(),t.length)},s(e,t){return B(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return B(Math.trunc(r*10**(n-3)),t.length)}},H={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},qe={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return V.y(e,t)},Y:function(e,t,n,r){let i=z(e,r),a=i>0?i:1-i;return t===`YY`?B(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):B(a,t.length)},R:function(e,t){return B(L(e),t.length)},u:function(e,t){return B(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return B(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return B(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return V.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return B(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=Ke(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):B(i,t.length)},I:function(e,t,n){let r=We(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):B(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):V.d(e,t)},D:function(e,t,n){let r=Ue(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):B(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return B(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return B(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return B(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?H.noon:r===0?H.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?H.evening:r>=12?H.afternoon:r>=4?H.morning:H.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return V.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):V.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):V.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):V.s(e,t)},S:function(e,t){return V.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return Ye(r);case`XXXX`:case`XX`:return U(r);default:return U(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return Ye(r);case`xxxx`:case`xx`:return U(r);default:return U(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},t:function(e,t,n){return B(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return B(+e,t.length)}};function Je(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+B(a,2)}function Ye(e,t){return e%60==0?(e>0?`-`:`+`)+B(Math.abs(e)/60,2):U(e,t)}function U(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=B(Math.trunc(r/60),2),a=B(r%60,2);return n+i+t+a}var Xe=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},Ze=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},Qe={p:Ze,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Xe(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Xe(r,t)).replace(`{{time}}`,Ze(i,t))}},$e=/^D+$/,et=/^Y+$/,tt=[`D`,`DD`,`YY`,`YYYY`];function nt(e){return $e.test(e)}function rt(e){return et.test(e)}function it(e,t,n){let r=at(e,t,n);if(console.warn(r),tt.includes(e))throw RangeError(r)}function at(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var ot=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,st=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ct=/^'([^]*?)'?$/,lt=/''/g,ut=/[a-zA-Z]/;function dt(e,t,n){let r=u(),i=n?.locale??r.locale??l,a=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??r.firstWeekContainsDate??r.locale?.options?.firstWeekContainsDate??1,o=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??r.weekStartsOn??r.locale?.options?.weekStartsOn??0,s=c(e,n?.in);if(!Ve(s))throw RangeError(`Invalid time value`);let d=t.match(st).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=Qe[t];return n(e,i.formatLong)}return e}).join(``).match(ot).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ft(e)};if(qe[t])return{isToken:!0,value:e};if(t.match(ut))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});i.localize.preprocessor&&(d=i.localize.preprocessor(s,d));let f={firstWeekContainsDate:a,weekStartsOn:o,locale:i};return d.map(r=>{if(!r.isToken)return r.value;let a=r.value;(!n?.useAdditionalWeekYearTokens&&rt(a)||!n?.useAdditionalDayOfYearTokens&&nt(a))&&it(a,t,String(e));let o=qe[a[0]];return o(s,a,i.localize,f)}).join(``)}function ft(e){let t=e.match(ct);return t?t[1].replace(lt,`'`):e}var W=e(v());function G(){return G=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},G.apply(null,arguments)}var pt=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return k(n)&&k(r)&&k(i)?W.createElement(`circle`,G({},ve(e),xe(e),{className:o,cx:n,cy:r,r:i})):null},mt=[`points`];function ht(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 K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ht(Object(n),!0).forEach(function(t){gt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gt(e,t,n){return(t=_t(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _t(e){var t=vt(e,`string`);return typeof t==`symbol`?t:t+``}function vt(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 q(){return q=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},q.apply(null,arguments)}function yt(e,t){if(e==null)return{};var n,r,i=bt(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 bt(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 xt(e){var{option:n,dotProps:r,className:i}=e;if((0,W.isValidElement)(n))return(0,W.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=yt(o,mt);return W.createElement(pt,q({},c,{className:a}))}function St(e,t){return e==null?!1:t?!0:e.length===1}function Ct(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=E.scatter}=e;if(!St(t,n))return null;var u=F(n),d=be(n),f=t.map((e,r)=>{var s=K(K(K({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return W.createElement(xt,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),W.createElement(x,{zIndex:l},W.createElement(N,q({className:r},p),f))}function wt(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wt(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(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 Ot=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=J(J(J({},{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}),fe(i)),xe(i)),c=(0,W.isValidElement)(i)?(0,W.cloneElement)(i,s):typeof i==`function`?i(s):W.createElement(pt,s);return W.createElement(N,{className:`recharts-active-dot`,clipPath:o},c)};function kt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=E.activeDot}=e,s=De(Se),c=Pe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return P(l)?null:W.createElement(x,{zIndex:o},W.createElement(Ot,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var At=(e,t,n,r)=>D(e,`xAxis`,t,r),jt=(e,t,n,r)=>te(e,`xAxis`,t,r),Mt=(e,t,n,r)=>D(e,`yAxis`,n,r),Nt=(e,t,n,r)=>te(e,`yAxis`,n,r),Pt=A([oe,At,Mt,jt,Nt],(e,t,n,r,i)=>b(e,`xAxis`)?le(t,r,!1):le(n,i,!1)),Ft=(e,t,n,r,i)=>i;function It(e){return e.type===`line`}var Lt=A([oe,At,Mt,jt,Nt,A([C,Ft],(e,t)=>e.filter(It).find(e=>e.id===t)),Pt,re],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return cn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Rt(e){var t=fe(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,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 zt=[`id`],Bt=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Vt=[`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 Ht(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 X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ht(Object(n),!0).forEach(function(t){Ut(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ut(e,t,n){return(t=Wt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wt(e){var t=Gt(e,`string`);return typeof t==`symbol`?t:t+``}function Gt(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 Z(e,t){if(e==null)return{};var n,r,i=Kt(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 Kt(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}var qt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:ue(n,t),payload:e}]},Jt=W.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:ge,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:ue(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return W.createElement(Fe,{tooltipEntrySettings:d})}),Q=(e,t)=>`${t}px ${e}px`;function Yt(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var Xt=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return Q(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...Yt(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function Zt(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ve(Z(r,zt));return W.createElement(Ct,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Qt(e){var{showLabels:t,children:n,points:r}=e,i=(0,W.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return W.createElement(ae,{value:t?i:void 0},n)}function $t(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=X(X({},Te(Z(a,Bt))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return W.createElement(W.Fragment,null,r?.length>1&&W.createElement(ie,Y({shapeType:`curve`,option:u},d,{pathRef:n})),W.createElement(Zt,{points:r,clipPathId:t,props:a}))}function en(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function tn(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Ie(o,`recharts-line-`),y=(0,W.useRef)(v),[b,x]=(0,W.useState)(!1),C=!b,w=(0,W.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),T=(0,W.useCallback)(()=>{typeof g==`function`&&g(),x(!0)},[g]),E=en(r.current),D=(0,W.useRef)(0);y.current!==v&&(D.current=a.current,y.current=v);var O=D.current;return W.createElement(Qt,{points:o,showLabels:C},n.children,W.createElement(S,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:v},e=>{var l=M(O,E+O,e),u=Math.min(l,E),d=c?s?Xt(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Q(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return X(X({},t),{},{x:M(i.x,t.x,e),y:M(i.y,t.y,e)})}return f?X(X({},t),{},{x:M(p*2,t.x,e),y:M(m/2,t.y,e)}):X(X({},t),{},{x:t.x,y:t.y})});return i.current=g,W.createElement($t,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return W.createElement($t,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),W.createElement(ee,{label:n.label}))}function nn(e){var{clipPathId:t,props:n}=e,r=(0,W.useRef)(null),i=(0,W.useRef)(0),a=(0,W.useRef)(null);return W.createElement(tn,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var rn=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:ne(e.payload,t)}),an=class extends W.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:p}=this.props;if(e)return null;var m=t(`recharts-line`,i),h=d,{r:g,strokeWidth:_}=Rt(n),v=F(n),y=g*2+_,b=f?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return W.createElement(x,{zIndex:p},W.createElement(N,{className:m},f&&W.createElement(`defs`,null,W.createElement(Oe,{clipPathId:h,xAxisId:a,yAxisId:o}),!v&&W.createElement(`clipPath`,{id:`clipPath-dots-${h}`},W.createElement(`rect`,{x:c-y/2,y:s-y/2,width:l+y,height:u+y}))),W.createElement(me,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:rn,errorBarOffset:0},W.createElement(nn,{props:this.props,clipPathId:h}))),W.createElement(kt,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:b}))}},on={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:E.line,type:`linear`};function sn(e){var t=je(e,on),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Z(t,Vt),{needClip:_}=Me(p,m),v=he(),y=se(),b=ke(),x=De(e=>Lt(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:ee,x:C,y:w}=v;return W.createElement(an,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:ee,left:C,top:w,needClip:_}))}function cn(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=ne(e,o);if(t===`horizontal`)return{x:ce({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(P(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=P(l)?null:n.scale.map(l),d=ce({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 ln(e){var t=je(e,on),n=ke();return W.createElement(_e,{id:t.id,type:`line`},e=>W.createElement(W.Fragment,null,W.createElement(de,{legendPayload:qt(t)}),W.createElement(Jt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),W.createElement(ye,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),W.createElement(sn,Y({},t,{id:e}))))}var un=W.memo(ln,w);un.displayName=`Line`;var dn=[`axis`],fn=(0,W.forwardRef)((e,t)=>W.createElement(Ee,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:dn,tooltipPayloadSearcher:Ce,categoricalChartProps:e,ref:t})),$=d(),pn=[{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 mn({period:e,from:t,to:n,onChange:r}){let{t:i}=h(`analytics`);function a(e){e===`custom`?r(`custom`,t,n):r(e)}function o(e){r(`custom`,e,n)}function c(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:pn.map(t=>(0,$.jsx)(`button`,{onClick:()=>a(t.value),className:s(`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=>o(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=>c(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 hn({kpi:e}){let{t}=h(`analytics`);return(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{label:t(`desktop.totalCost`),value:`$${e.totalCostUsd.toFixed(4)}`,sub:t(`desktop.costToday`,{value:`$${e.costToday.toFixed(4)}`})},{label:t(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:t(`desktop.jobsToday`,{n:e.jobsToday})},{label:t(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:t(`desktop.acrossAllProjects`)},{label:t(`desktop.avgCostPerJob`),value:e.totalJobs>0?`$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:t(`desktop.periodAverage`)}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e.label}),(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.label))})}function gn({data:e}){let{t}=h(`analytics`),n=p(),r=e.length>0&&e.some(e=>e.costUsd>0),i=Math.max(1,Math.floor(e.length/7)),a=e.filter((e,t)=>t%i===0).map(e=>e.date);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.costOverTime`)}),r?(0,$.jsx)(T,{width:`100%`,height:200,children:(0,$.jsxs)(fn,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`date`,ticks:a,tickFormatter:e=>{try{return dt(new Date(e),`MMM d`,{locale:y()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{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)(un,{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 _n({projects:e}){let{t}=h(`analytics`),n=p();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)=>(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`font-medium truncate max-w-[160px]`,title:e.projectName,children:e.projectName}),(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,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[`$`,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 vn({projects:e}){let{t}=h(`analytics`),n=p();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));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`)}),(0,$.jsx)(T,{width:`100%`,height:180,children:(0,$.jsxs)(Ne,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{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)(pe,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function yn(){let{t:e}=h(`analytics`),[t,n]=(0,W.useState)(`7d`),[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(null),[l,u]=(0,W.useState)(!0),[d,p]=(0,W.useState)(null),{registerHandler:m,unregisterHandler:_}=f(),v=(0,W.useCallback)(e=>{let n=e;n.type===`log`&&n.event_type===`job_done`&&y(t,r,a)},[t,r,a]);(0,W.useEffect)(()=>(m(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,m,_]);async function y(e,t,n){u(!0),p(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}`);c(await i.json())}catch(e){p(e.message)}finally{u(!1)}}(0,W.useEffect)(()=>{y(t,r,a)},[t,r,a]);function b(e,t,r){n(e),t!==void 0&&i(t),r!==void 0&&o(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)(Le,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),s&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(mn,{period:t,from:r,to:a,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,a),disabled:l,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)(g,{className:`w-3 h-3 ${l?`animate-spin`:``}`})})]})]}),d&&(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:d})}),l&&!s&&(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))})]}),s&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(hn,{kpi:s.kpi}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(gn,{data:s.costTimeline}),(0,$.jsx)(vn,{projects:s.projectBreakdown})]}),(0,$.jsx)(_n,{projects:s.projectBreakdown})]})]})})}export{yn as default};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./clsx-CjLeUJfG.js";import{Bt as n,Gt as r,Ht as i,It as a,Jt as o,Kt as s,Ut as c,Wt as l,Xt as u,Yt as d,Zt as f,a as p,bn as m,d as h,fn as g,qt as _,tt as v,z as y}from"./index-CEunZ8kJ.js";import{$ as b,A as x,B as S,E as ee,F as C,H as w,K as T,L as E,N as D,O,P as te,Q as ne,R as re,S as ie,T as ae,U as oe,W as se,X as ce,Y as le,Z as ue,_ as de,_t as fe,a as pe,c as me,d as he,dt as k,et as A,ft as ge,g as _e,gt as ve,h as ye,ht as be,i as j,it as xe,j as Se,k as Ce,l as we,lt as M,mt as Te,n as Ee,nt as De,o as Oe,pt as N,q as ke,r as Ae,rt as je,s as Me,t as Ne,u as Pe,ut as P,v as Fe,w as F,z as Ie}from"./BarChart-zCFHhnbZ.js";var Le=a(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]);function I(e,t){return c(e,{...t,weekStartsOn:1})}function L(e,t){let n=l(e,t?.in),r=n.getFullYear(),i=_(n,0);i.setFullYear(r+1,0,4),i.setHours(0,0,0,0);let a=I(i),o=_(n,0);o.setFullYear(r,0,4),o.setHours(0,0,0,0);let s=I(o);return n.getTime()>=a.getTime()?r+1:n.getTime()>=s.getTime()?r:r-1}function R(e,t){let n=l(e,t?.in);return n.setHours(0,0,0,0),n}function Re(e,t,n){let[r,i]=s(n?.in,e,t),a=R(r),c=R(i),l=+a-h(a),u=+c-h(c);return Math.round((l-u)/o)}function ze(e,t){let n=L(e,t),r=_(t?.in||e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),I(r)}function Be(e){return e instanceof Date||typeof e==`object`&&Object.prototype.toString.call(e)===`[object Date]`}function Ve(e){return!(!Be(e)&&typeof e!=`number`||isNaN(+l(e)))}function He(e,t){let n=l(e,t?.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function Ue(e,t){let n=l(e,t?.in);return Re(n,He(n))+1}function We(e,t){let n=l(e,t?.in),r=I(n)-+ze(n);return Math.round(r/d)+1}function z(e,t){let n=l(e,t?.in),i=n.getFullYear(),a=r(),o=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,s=_(t?.in||e,0);s.setFullYear(i+1,0,o),s.setHours(0,0,0,0);let u=c(s,t),d=_(t?.in||e,0);d.setFullYear(i,0,o),d.setHours(0,0,0,0);let f=c(d,t);return+n>=+u?i+1:+n>=+f?i:i-1}function Ge(e,t){let n=r(),i=t?.firstWeekContainsDate??t?.locale?.options?.firstWeekContainsDate??n.firstWeekContainsDate??n.locale?.options?.firstWeekContainsDate??1,a=z(e,t),o=_(t?.in||e,0);return o.setFullYear(a,0,i),o.setHours(0,0,0,0),c(o,t)}function Ke(e,t){let n=l(e,t?.in),r=c(n,t)-+Ge(n,t);return Math.round(r/d)+1}function B(e,t){return(e<0?`-`:``)+Math.abs(e).toString().padStart(t,`0`)}var V={y(e,t){let n=e.getFullYear(),r=n>0?n:1-n;return B(t===`yy`?r%100:r,t.length)},M(e,t){let n=e.getMonth();return t===`M`?String(n+1):B(n+1,2)},d(e,t){return B(e.getDate(),t.length)},a(e,t){let n=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.toUpperCase();case`aaa`:return n;case`aaaaa`:return n[0];default:return n===`am`?`a.m.`:`p.m.`}},h(e,t){return B(e.getHours()%12||12,t.length)},H(e,t){return B(e.getHours(),t.length)},m(e,t){return B(e.getMinutes(),t.length)},s(e,t){return B(e.getSeconds(),t.length)},S(e,t){let n=t.length,r=e.getMilliseconds();return B(Math.trunc(r*10**(n-3)),t.length)}},H={am:`am`,pm:`pm`,midnight:`midnight`,noon:`noon`,morning:`morning`,afternoon:`afternoon`,evening:`evening`,night:`night`},qe={G:function(e,t,n){let r=+(e.getFullYear()>0);switch(t){case`G`:case`GG`:case`GGG`:return n.era(r,{width:`abbreviated`});case`GGGGG`:return n.era(r,{width:`narrow`});default:return n.era(r,{width:`wide`})}},y:function(e,t,n){if(t===`yo`){let t=e.getFullYear(),r=t>0?t:1-t;return n.ordinalNumber(r,{unit:`year`})}return V.y(e,t)},Y:function(e,t,n,r){let i=z(e,r),a=i>0?i:1-i;return t===`YY`?B(a%100,2):t===`Yo`?n.ordinalNumber(a,{unit:`year`}):B(a,t.length)},R:function(e,t){return B(L(e),t.length)},u:function(e,t){return B(e.getFullYear(),t.length)},Q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`Q`:return String(r);case`QQ`:return B(r,2);case`Qo`:return n.ordinalNumber(r,{unit:`quarter`});case`QQQ`:return n.quarter(r,{width:`abbreviated`,context:`formatting`});case`QQQQQ`:return n.quarter(r,{width:`narrow`,context:`formatting`});default:return n.quarter(r,{width:`wide`,context:`formatting`})}},q:function(e,t,n){let r=Math.ceil((e.getMonth()+1)/3);switch(t){case`q`:return String(r);case`qq`:return B(r,2);case`qo`:return n.ordinalNumber(r,{unit:`quarter`});case`qqq`:return n.quarter(r,{width:`abbreviated`,context:`standalone`});case`qqqqq`:return n.quarter(r,{width:`narrow`,context:`standalone`});default:return n.quarter(r,{width:`wide`,context:`standalone`})}},M:function(e,t,n){let r=e.getMonth();switch(t){case`M`:case`MM`:return V.M(e,t);case`Mo`:return n.ordinalNumber(r+1,{unit:`month`});case`MMM`:return n.month(r,{width:`abbreviated`,context:`formatting`});case`MMMMM`:return n.month(r,{width:`narrow`,context:`formatting`});default:return n.month(r,{width:`wide`,context:`formatting`})}},L:function(e,t,n){let r=e.getMonth();switch(t){case`L`:return String(r+1);case`LL`:return B(r+1,2);case`Lo`:return n.ordinalNumber(r+1,{unit:`month`});case`LLL`:return n.month(r,{width:`abbreviated`,context:`standalone`});case`LLLLL`:return n.month(r,{width:`narrow`,context:`standalone`});default:return n.month(r,{width:`wide`,context:`standalone`})}},w:function(e,t,n,r){let i=Ke(e,r);return t===`wo`?n.ordinalNumber(i,{unit:`week`}):B(i,t.length)},I:function(e,t,n){let r=We(e);return t===`Io`?n.ordinalNumber(r,{unit:`week`}):B(r,t.length)},d:function(e,t,n){return t===`do`?n.ordinalNumber(e.getDate(),{unit:`date`}):V.d(e,t)},D:function(e,t,n){let r=Ue(e);return t===`Do`?n.ordinalNumber(r,{unit:`dayOfYear`}):B(r,t.length)},E:function(e,t,n){let r=e.getDay();switch(t){case`E`:case`EE`:case`EEE`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`EEEEE`:return n.day(r,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},e:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`e`:return String(a);case`ee`:return B(a,2);case`eo`:return n.ordinalNumber(a,{unit:`day`});case`eee`:return n.day(i,{width:`abbreviated`,context:`formatting`});case`eeeee`:return n.day(i,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(i,{width:`short`,context:`formatting`});default:return n.day(i,{width:`wide`,context:`formatting`})}},c:function(e,t,n,r){let i=e.getDay(),a=(i-r.weekStartsOn+8)%7||7;switch(t){case`c`:return String(a);case`cc`:return B(a,t.length);case`co`:return n.ordinalNumber(a,{unit:`day`});case`ccc`:return n.day(i,{width:`abbreviated`,context:`standalone`});case`ccccc`:return n.day(i,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(i,{width:`short`,context:`standalone`});default:return n.day(i,{width:`wide`,context:`standalone`})}},i:function(e,t,n){let r=e.getDay(),i=r===0?7:r;switch(t){case`i`:return String(i);case`ii`:return B(i,t.length);case`io`:return n.ordinalNumber(i,{unit:`day`});case`iii`:return n.day(r,{width:`abbreviated`,context:`formatting`});case`iiiii`:return n.day(r,{width:`narrow`,context:`formatting`});case`iiiiii`:return n.day(r,{width:`short`,context:`formatting`});default:return n.day(r,{width:`wide`,context:`formatting`})}},a:function(e,t,n){let r=e.getHours()/12>=1?`pm`:`am`;switch(t){case`a`:case`aa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`});case`aaa`:return n.dayPeriod(r,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`aaaaa`:return n.dayPeriod(r,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(r,{width:`wide`,context:`formatting`})}},b:function(e,t,n){let r=e.getHours(),i;switch(i=r===12?H.noon:r===0?H.midnight:r/12>=1?`pm`:`am`,t){case`b`:case`bb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`bbb`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`}).toLowerCase();case`bbbbb`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},B:function(e,t,n){let r=e.getHours(),i;switch(i=r>=17?H.evening:r>=12?H.afternoon:r>=4?H.morning:H.night,t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(i,{width:`abbreviated`,context:`formatting`});case`BBBBB`:return n.dayPeriod(i,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(i,{width:`wide`,context:`formatting`})}},h:function(e,t,n){if(t===`ho`){let t=e.getHours()%12;return t===0&&(t=12),n.ordinalNumber(t,{unit:`hour`})}return V.h(e,t)},H:function(e,t,n){return t===`Ho`?n.ordinalNumber(e.getHours(),{unit:`hour`}):V.H(e,t)},K:function(e,t,n){let r=e.getHours()%12;return t===`Ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t===`ko`?n.ordinalNumber(r,{unit:`hour`}):B(r,t.length)},m:function(e,t,n){return t===`mo`?n.ordinalNumber(e.getMinutes(),{unit:`minute`}):V.m(e,t)},s:function(e,t,n){return t===`so`?n.ordinalNumber(e.getSeconds(),{unit:`second`}):V.s(e,t)},S:function(e,t){return V.S(e,t)},X:function(e,t,n){let r=e.getTimezoneOffset();if(r===0)return`Z`;switch(t){case`X`:return Ye(r);case`XXXX`:case`XX`:return U(r);default:return U(r,`:`)}},x:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`x`:return Ye(r);case`xxxx`:case`xx`:return U(r);default:return U(r,`:`)}},O:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`O`:case`OO`:case`OOO`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},z:function(e,t,n){let r=e.getTimezoneOffset();switch(t){case`z`:case`zz`:case`zzz`:return`GMT`+Je(r,`:`);default:return`GMT`+U(r,`:`)}},t:function(e,t,n){return B(Math.trunc(e/1e3),t.length)},T:function(e,t,n){return B(+e,t.length)}};function Je(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=Math.trunc(r/60),a=r%60;return a===0?n+String(i):n+String(i)+t+B(a,2)}function Ye(e,t){return e%60==0?(e>0?`-`:`+`)+B(Math.abs(e)/60,2):U(e,t)}function U(e,t=``){let n=e>0?`-`:`+`,r=Math.abs(e),i=B(Math.trunc(r/60),2),a=B(r%60,2);return n+i+t+a}var Xe=(e,t)=>{switch(e){case`P`:return t.date({width:`short`});case`PP`:return t.date({width:`medium`});case`PPP`:return t.date({width:`long`});default:return t.date({width:`full`})}},Ze=(e,t)=>{switch(e){case`p`:return t.time({width:`short`});case`pp`:return t.time({width:`medium`});case`ppp`:return t.time({width:`long`});default:return t.time({width:`full`})}},Qe={p:Ze,P:(e,t)=>{let n=e.match(/(P+)(p+)?/)||[],r=n[1],i=n[2];if(!i)return Xe(e,t);let a;switch(r){case`P`:a=t.dateTime({width:`short`});break;case`PP`:a=t.dateTime({width:`medium`});break;case`PPP`:a=t.dateTime({width:`long`});break;default:a=t.dateTime({width:`full`});break}return a.replace(`{{date}}`,Xe(r,t)).replace(`{{time}}`,Ze(i,t))}},$e=/^D+$/,et=/^Y+$/,tt=[`D`,`DD`,`YY`,`YYYY`];function nt(e){return $e.test(e)}function rt(e){return et.test(e)}function it(e,t,n){let r=at(e,t,n);if(console.warn(r),tt.includes(e))throw RangeError(r)}function at(e,t,n){let r=e[0]===`Y`?`years`:`days of the month`;return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}var ot=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,st=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,ct=/^'([^]*?)'?$/,lt=/''/g,ut=/[a-zA-Z]/;function dt(e,t,n){let a=r(),o=n?.locale??a.locale??i,s=n?.firstWeekContainsDate??n?.locale?.options?.firstWeekContainsDate??a.firstWeekContainsDate??a.locale?.options?.firstWeekContainsDate??1,c=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??a.weekStartsOn??a.locale?.options?.weekStartsOn??0,u=l(e,n?.in);if(!Ve(u))throw RangeError(`Invalid time value`);let d=t.match(st).map(e=>{let t=e[0];if(t===`p`||t===`P`){let n=Qe[t];return n(e,o.formatLong)}return e}).join(``).match(ot).map(e=>{if(e===`''`)return{isToken:!1,value:`'`};let t=e[0];if(t===`'`)return{isToken:!1,value:ft(e)};if(qe[t])return{isToken:!0,value:e};if(t.match(ut))throw RangeError("Format string contains an unescaped latin alphabet character `"+t+"`");return{isToken:!1,value:e}});o.localize.preprocessor&&(d=o.localize.preprocessor(u,d));let f={firstWeekContainsDate:s,weekStartsOn:c,locale:o};return d.map(r=>{if(!r.isToken)return r.value;let i=r.value;(!n?.useAdditionalWeekYearTokens&&rt(i)||!n?.useAdditionalDayOfYearTokens&&nt(i))&&it(i,t,String(e));let a=qe[i[0]];return a(u,i,o.localize,f)}).join(``)}function ft(e){let t=e.match(ct);return t?t[1].replace(lt,`'`):e}var W=e(m());function G(){return G=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},G.apply(null,arguments)}var pt=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return k(n)&&k(r)&&k(i)?W.createElement(`circle`,G({},ve(e),xe(e),{className:o,cx:n,cy:r,r:i})):null},mt=[`points`];function ht(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 K(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ht(Object(n),!0).forEach(function(t){gt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function gt(e,t,n){return(t=_t(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _t(e){var t=vt(e,`string`);return typeof t==`symbol`?t:t+``}function vt(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 q(){return q=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},q.apply(null,arguments)}function yt(e,t){if(e==null)return{};var n,r,i=bt(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 bt(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 xt(e){var{option:n,dotProps:r,className:i}=e;if((0,W.isValidElement)(n))return(0,W.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=yt(o,mt);return W.createElement(pt,q({},c,{className:a}))}function St(e,t){return e==null?!1:t?!0:e.length===1}function Ct(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=E.scatter}=e;if(!St(t,n))return null;var u=F(n),d=be(n),f=t.map((e,r)=>{var s=K(K(K({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return W.createElement(xt,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),p={};return s&&c!=null&&(p.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),W.createElement(x,{zIndex:l},W.createElement(N,q({className:r},p),f))}function wt(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 J(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?wt(Object(n),!0).forEach(function(t){Tt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):wt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Tt(e,t,n){return(t=Et(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Et(e){var t=Dt(e,`string`);return typeof t==`symbol`?t:t+``}function Dt(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 Ot=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=J(J(J({},{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}),fe(i)),xe(i)),c=(0,W.isValidElement)(i)?(0,W.cloneElement)(i,s):typeof i==`function`?i(s):W.createElement(pt,s);return W.createElement(N,{className:`recharts-active-dot`,clipPath:o},c)};function kt(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=E.activeDot}=e,s=De(Se),c=Pe();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return P(l)?null:W.createElement(x,{zIndex:o},W.createElement(Ot,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var At=(e,t,n,r)=>D(e,`xAxis`,t,r),jt=(e,t,n,r)=>te(e,`xAxis`,t,r),Mt=(e,t,n,r)=>D(e,`yAxis`,n,r),Nt=(e,t,n,r)=>te(e,`yAxis`,n,r),Pt=A([oe,At,Mt,jt,Nt],(e,t,n,r,i)=>b(e,`xAxis`)?le(t,r,!1):le(n,i,!1)),Ft=(e,t,n,r,i)=>i;function It(e){return e.type===`line`}var Lt=A([oe,At,Mt,jt,Nt,A([C,Ft],(e,t)=>e.filter(It).find(e=>e.id===t)),Pt,re],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return cn({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Rt(e){var t=fe(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,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 zt=[`id`],Bt=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Vt=[`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 Ht(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 X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ht(Object(n),!0).forEach(function(t){Ut(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ht(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ut(e,t,n){return(t=Wt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wt(e){var t=Gt(e,`string`);return typeof t==`symbol`?t:t+``}function Gt(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 Z(e,t){if(e==null)return{};var n,r,i=Kt(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 Kt(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}var qt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:ue(n,t),payload:e}]},Jt=W.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:ge,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:ue(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return W.createElement(Fe,{tooltipEntrySettings:d})}),Q=(e,t)=>`${t}px ${e}px`;function Yt(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var Xt=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return Q(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...Yt(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function Zt(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ve(Z(r,zt));return W.createElement(Ct,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Qt(e){var{showLabels:t,children:n,points:r}=e,i=(0,W.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return W.createElement(ae,{value:t?i:void 0},n)}function $t(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=X(X({},Te(Z(a,Bt))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return W.createElement(W.Fragment,null,r?.length>1&&W.createElement(ie,Y({shapeType:`curve`,option:u},d,{pathRef:n})),W.createElement(Zt,{points:r,clipPathId:t,props:a}))}function en(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function tn(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Ie(o,`recharts-line-`),y=(0,W.useRef)(v),[b,x]=(0,W.useState)(!1),C=!b,w=(0,W.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),T=(0,W.useCallback)(()=>{typeof g==`function`&&g(),x(!0)},[g]),E=en(r.current),D=(0,W.useRef)(0);y.current!==v&&(D.current=a.current,y.current=v);var O=D.current;return W.createElement(Qt,{points:o,showLabels:C},n.children,W.createElement(S,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:w,onAnimationStart:T,key:v},e=>{var l=M(O,E+O,e),u=Math.min(l,E),d=c?s?Xt(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):Q(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return X(X({},t),{},{x:M(i.x,t.x,e),y:M(i.y,t.y,e)})}return f?X(X({},t),{},{x:M(p*2,t.x,e),y:M(m/2,t.y,e)}):X(X({},t),{},{x:t.x,y:t.y})});return i.current=g,W.createElement($t,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return W.createElement($t,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),W.createElement(ee,{label:n.label}))}function nn(e){var{clipPathId:t,props:n}=e,r=(0,W.useRef)(null),i=(0,W.useRef)(0),a=(0,W.useRef)(null);return W.createElement(tn,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var rn=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:ne(e.payload,t)}),an=class extends W.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:p}=this.props;if(e)return null;var m=t(`recharts-line`,i),h=d,{r:g,strokeWidth:_}=Rt(n),v=F(n),y=g*2+_,b=f?`url(#clipPath-${v?``:`dots-`}${h})`:void 0;return W.createElement(x,{zIndex:p},W.createElement(N,{className:m},f&&W.createElement(`defs`,null,W.createElement(Oe,{clipPathId:h,xAxisId:a,yAxisId:o}),!v&&W.createElement(`clipPath`,{id:`clipPath-dots-${h}`},W.createElement(`rect`,{x:c-y/2,y:s-y/2,width:l+y,height:u+y}))),W.createElement(me,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:rn,errorBarOffset:0},W.createElement(nn,{props:this.props,clipPathId:h}))),W.createElement(kt,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:b}))}},on={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:E.line,type:`linear`};function sn(e){var t=je(e,on),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Z(t,Vt),{needClip:_}=Me(p,m),v=he(),y=se(),b=ke(),x=De(e=>Lt(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:ee,x:C,y:w}=v;return W.createElement(an,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:ee,left:C,top:w,needClip:_}))}function cn(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=ne(e,o);if(t===`horizontal`)return{x:ce({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(P(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=P(l)?null:n.scale.map(l),d=ce({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 ln(e){var t=je(e,on),n=ke();return W.createElement(_e,{id:t.id,type:`line`},e=>W.createElement(W.Fragment,null,W.createElement(de,{legendPayload:qt(t)}),W.createElement(Jt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),W.createElement(ye,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),W.createElement(sn,Y({},t,{id:e}))))}var un=W.memo(ln,w);un.displayName=`Line`;var dn=[`axis`],fn=(0,W.forwardRef)((e,t)=>W.createElement(Ee,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:dn,tooltipPayloadSearcher:Ce,categoricalChartProps:e,ref:t})),$=f(),pn=[{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 mn({period:e,from:t,to:n,onChange:r}){let{t:i}=g(`analytics`);function a(e){e===`custom`?r(`custom`,t,n):r(e)}function o(e){r(`custom`,e,n)}function s(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:pn.map(t=>(0,$.jsx)(`button`,{onClick:()=>a(t.value),className:y(`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=>o(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=>s(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 hn({kpi:e}){let{t}=g(`analytics`);return(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{label:t(`desktop.totalCost`),value:`$${e.totalCostUsd.toFixed(4)}`,sub:t(`desktop.costToday`,{value:`$${e.costToday.toFixed(4)}`})},{label:t(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:t(`desktop.jobsToday`,{n:e.jobsToday})},{label:t(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:t(`desktop.acrossAllProjects`)},{label:t(`desktop.avgCostPerJob`),value:e.totalJobs>0?`$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:t(`desktop.periodAverage`)}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e.label}),(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.label))})}function gn({data:e}){let{t}=g(`analytics`),r=p(),i=e.length>0&&e.some(e=>e.costUsd>0),a=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%a===0).map(e=>e.date);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.costOverTime`)}),i?(0,$.jsx)(T,{width:`100%`,height:200,children:(0,$.jsxs)(fn,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`date`,ticks:o,tickFormatter:e=>{try{return dt(new Date(e),`MMM d`,{locale:n()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{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)(un,{type:`monotone`,dataKey:`costUsd`,stroke:r.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:r.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function _n({projects:e}){let{t}=g(`analytics`),n=p();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)=>(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsx)(`span`,{className:`font-medium truncate max-w-[160px]`,title:e.projectName,children:e.projectName}),(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,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[`$`,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 vn({projects:e}){let{t}=g(`analytics`),n=p();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));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`)}),(0,$.jsx)(T,{width:`100%`,height:180,children:(0,$.jsxs)(Ne,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(we,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(j,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(Ae,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(O,{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)(pe,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function yn(){let{t:e}=g(`analytics`),[t,n]=(0,W.useState)(`7d`),[r,i]=(0,W.useState)(``),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(null),[l,d]=(0,W.useState)(!0),[f,p]=(0,W.useState)(null),{registerHandler:m,unregisterHandler:h}=u(),_=(0,W.useCallback)(e=>{let n=e;n.type===`log`&&n.event_type===`job_done`&&y(t,r,a)},[t,r,a]);(0,W.useEffect)(()=>(m(`desktop-analytics`,_),()=>h(`desktop-analytics`)),[_,m,h]);async function y(e,t,n){d(!0),p(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}`);c(await i.json())}catch(e){p(e.message)}finally{d(!1)}}(0,W.useEffect)(()=>{y(t,r,a)},[t,r,a]);function b(e,t,r){n(e),t!==void 0&&i(t),r!==void 0&&o(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)(Le,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),s&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(mn,{period:t,from:r,to:a,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,a),disabled:l,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)(v,{className:`w-3 h-3 ${l?`animate-spin`:``}`})})]})]}),f&&(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:f})}),l&&!s&&(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))})]}),s&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(hn,{kpi:s.kpi}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(gn,{data:s.costTimeline}),(0,$.jsx)(vn,{projects:s.projectBreakdown})]}),(0,$.jsx)(_n,{projects:s.projectBreakdown})]})]})})}export{yn as default};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{A as t,Et as n,N as r,O as i,R as a,Xt as o,dn as s,g as c,h as l,k as u,kt as d,mt as f,st as p,yn as m}from"./index-QEeqwz4v.js";import{t as h}from"./lib-CVrpo1ac.js";import{t as g}from"./atom-one-dark-DrWoEEbZ.js";var _=e(m(),1),v=o();function y({categories:e,activeCategory:t,activeSlug:n,onSelect:r,onHome:i}){let{t:o}=s(`integrations`);return(0,v.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,v.jsxs)(`button`,{onClick:i,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,v.jsx)(d,{className:`w-3.5 h-3.5`}),o(`docs.title`)]}),(0,v.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,v.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,v.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,v.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(i=>(0,v.jsx)(`li`,{children:(0,v.jsxs)(`button`,{onClick:()=>r(e.slug,i.slug),className:a(`w-full flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors text-left`,t===e.slug&&n===i.slug?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,v.jsx)(f,{className:`w-3 h-3 flex-shrink-0`}),i.title]})},i.slug))})]},e.slug))})]})}function b({categories:e,onSelect:t}){let{t:r}=s(`integrations`),i=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,v.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,v.jsxs)(`div`,{className:`mb-8`,children:[(0,v.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:r(`docs.title`)}),(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===0?r(`docs.indexEmpty`):r(`docs.summary`,{documents:r(`docs.documentCount`,{count:i}),categories:r(`docs.categoryCount`,{count:a})})})]}),(0,v.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:r(`docs.categoryEmpty`)}):(0,v.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(r=>(0,v.jsx)(`li`,{children:(0,v.jsxs)(`button`,{onClick:()=>t(e.slug,r.slug),className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group text-left`,children:[(0,v.jsx)(f,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,v.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:r.title}),(0,v.jsx)(n,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},r.slug))})]},e.slug))})]})}var x=(0,_.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,v.jsx)(c,{remarkPlugins:[l],rehypePlugins:[h],components:{a({href:e,children:r,...i}){return(0,v.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=g(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function S({category:e,slug:t,lang:n,onNotFound:r,onNavigate:i,scrollContainerRef:a}){let{t:o}=s(`integrations`),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(0);return(0,_.useEffect)(()=>{let i=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){r();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===f.current&&e&&(l(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{i===f.current&&d(e instanceof Error?e.message:o(`docs.loadError`))})},[e,t,n,r,a]),!c&&!u?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(p,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!c?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):c?(0,v.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,v.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{A as t,At as n,Dt as r,P as i,Zt as a,_ as o,bn as s,ct as c,fn as l,g as u,ht as d,j as f,k as p,z as m}from"./index-CEunZ8kJ.js";import{t as h}from"./lib-3_pPhUqA.js";import{t as g}from"./atom-one-dark-DrWoEEbZ.js";var _=e(s(),1),v=a();function y({categories:e,activeCategory:t,activeSlug:r,onSelect:i,onHome:a}){let{t:o}=l(`integrations`);return(0,v.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,v.jsxs)(`button`,{onClick:a,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,v.jsx)(n,{className:`w-3.5 h-3.5`}),o(`docs.title`)]}),(0,v.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,v.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,v.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,v.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,v.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(n=>(0,v.jsx)(`li`,{children:(0,v.jsxs)(`button`,{onClick:()=>i(e.slug,n.slug),className:m(`w-full flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors text-left`,t===e.slug&&r===n.slug?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,v.jsx)(d,{className:`w-3 h-3 flex-shrink-0`}),n.title]})},n.slug))})]},e.slug))})]})}function b({categories:e,onSelect:t}){let{t:n}=l(`integrations`),i=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,v.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,v.jsxs)(`div`,{className:`mb-8`,children:[(0,v.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:n(`docs.title`)}),(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:i}),categories:n(`docs.categoryCount`,{count:a})})})]}),(0,v.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,v.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,v.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(n=>(0,v.jsx)(`li`,{children:(0,v.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group text-left`,children:[(0,v.jsx)(d,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,v.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:n.title}),(0,v.jsx)(r,{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 x=(0,_.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,v.jsx)(o,{remarkPlugins:[u],rehypePlugins:[h],components:{a({href:e,children:r,...i}){return(0,v.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=g(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function S({category:e,slug:t,lang:n,onNotFound:r,onNavigate:i,scrollContainerRef:a}){let{t:o}=l(`integrations`),[s,u]=(0,_.useState)(null),[d,f]=(0,_.useState)(null),p=(0,_.useRef)(0);return(0,_.useEffect)(()=>{let i=++p.current;f(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){r();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===p.current&&e&&(u(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{i===p.current&&f(e instanceof Error?e.message:o(`docs.loadError`))})},[e,t,n,r,a]),!s&&!d?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(c,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!s?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,v.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):s?(0,v.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,v.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
@@ -8,4 +8,4 @@ import{r as e}from"./chunk-CilyBKbf.js";import{A as t,Et as n,N as r,O as i,R as
8
8
  prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
9
9
  prose-hr:border-border
10
10
  prose-th:text-foreground prose-td:text-foreground/90
11
- prose-li:text-foreground/90`,children:(0,v.jsx)(x,{content:c.content,currentCategory:c.category,onNavigateDoc:i})})}):null}function C({open:e,onClose:n}){let{t:a,i18n:o}=s(`integrations`),c=o.language||`en`,[l,d]=(0,_.useState)(null),[f,m]=(0,_.useState)(!0),[h,g]=(0,_.useState)(),[x,C]=(0,_.useState)(),w=(0,_.useRef)(null);(0,_.useEffect)(()=>{e&&(m(!0),fetch(`/api/docs?lang=${encodeURIComponent(c)}`).then(e=>e.json()).then(e=>d(e)).catch(()=>d({categories:[]})).finally(()=>m(!1)))},[e,c]);let T=(0,_.useCallback)((e,t)=>{g(e),C(t)},[]),E=(0,_.useCallback)(()=>{g(void 0),C(void 0)},[]),D=!!(h&&x);return(0,v.jsx)(i,{open:e,onOpenChange:e=>{e||n()},children:(0,v.jsxs)(u,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:[(0,v.jsx)(r,{className:`sr-only`,children:a(`docs.title`)}),(0,v.jsx)(t,{className:`sr-only`,children:a(`docs.dialogDescription`)}),(0,v.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[f?(0,v.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,v.jsx)(p,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,v.jsx)(y,{categories:l?.categories??[],activeCategory:h,activeSlug:x,onSelect:T,onHome:E}),(0,v.jsx)(`main`,{ref:w,className:`flex-1 overflow-y-auto`,children:D&&h&&x?(0,v.jsx)(S,{category:h,slug:x,lang:c,onNotFound:E,onNavigate:T,scrollContainerRef:w}):l&&(0,v.jsx)(b,{categories:l.categories,onSelect:T})})]})]})})}var w=(0,_.memo)(C);export{w as default};
11
+ prose-li:text-foreground/90`,children:(0,v.jsx)(x,{content:s.content,currentCategory:s.category,onNavigateDoc:i})})}):null}function C({open:e,onClose:n}){let{t:r,i18n:a}=l(`integrations`),o=a.language||`en`,[s,u]=(0,_.useState)(null),[d,m]=(0,_.useState)(!0),[h,g]=(0,_.useState)(),[x,C]=(0,_.useState)(),w=(0,_.useRef)(null);(0,_.useEffect)(()=>{e&&(m(!0),fetch(`/api/docs?lang=${encodeURIComponent(o)}`).then(e=>e.json()).then(e=>u(e)).catch(()=>u({categories:[]})).finally(()=>m(!1)))},[e,o]);let T=(0,_.useCallback)((e,t)=>{g(e),C(t)},[]),E=(0,_.useCallback)(()=>{g(void 0),C(void 0)},[]),D=!!(h&&x);return(0,v.jsx)(p,{open:e,onOpenChange:e=>{e||n()},children:(0,v.jsxs)(t,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:[(0,v.jsx)(i,{className:`sr-only`,children:r(`docs.title`)}),(0,v.jsx)(f,{className:`sr-only`,children:r(`docs.dialogDescription`)}),(0,v.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[d?(0,v.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,v.jsx)(c,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,v.jsx)(y,{categories:s?.categories??[],activeCategory:h,activeSlug:x,onSelect:T,onHome:E}),(0,v.jsx)(`main`,{ref:w,className:`flex-1 overflow-y-auto`,children:D&&h&&x?(0,v.jsx)(S,{category:h,slug:x,lang:o,onNotFound:E,onNavigate:T,scrollContainerRef:w}):s&&(0,v.jsx)(b,{categories:s.categories,onSelect:T})})]})]})})}var w=(0,_.memo)(C);export{w as default};
@@ -0,0 +1,11 @@
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{At as t,Dt as n,Zt as r,_ as i,_n as a,bn as o,ct as s,fn as c,g as l,gn as u,hn as d,ht as f,z as p}from"./index-CEunZ8kJ.js";import{t as m}from"./lib-3_pPhUqA.js";import{t as h}from"./atom-one-dark-DrWoEEbZ.js";var g=e(o(),1),_=r();function v({categories:e,activeCategory:n,activeSlug:r}){let{t:i}=c(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,_.jsxs)(d,{to:`/docs`,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,_.jsx)(t,{className:`w-3.5 h-3.5`}),i(`docs.title`)]}),(0,_.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`div`,{className:`px-2 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 text-xs text-muted-foreground italic`,children:i(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(t=>{let i=n===e.slug&&r===t.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(d,{to:`/docs/${e.slug}/${t.slug}`,className:p(`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors`,i?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,_.jsx)(f,{className:`w-3 h-3 flex-shrink-0`}),t.title]})},t.slug)})})]},e.slug))})]})}function y({categories:e}){let{t}=c(`integrations`),r=e.reduce((e,t)=>e+t.docs.length,0),i=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,_.jsxs)(`div`,{className:`mb-8`,children:[(0,_.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:t(`docs.title`)}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:r}),categories:t(`docs.categoryCount`,{count:i})})})]}),(0,_.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,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-1`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(d,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group`,children:[(0,_.jsx)(f,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:t.title}),(0,_.jsx)(n,{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)(i,{remarkPlugins:[l],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}=c(`integrations`),[a,o]=(0,g.useState)(null),[l,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=u();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&&(o(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]),!a&&!l?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l&&!a?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):a?(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
+ prose-headings:text-foreground prose-headings:font-bold
3
+ prose-p:text-foreground/90
4
+ prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
5
+ prose-strong:text-foreground
6
+ prose-code:text-accent-info prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
7
+ prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
8
+ prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
9
+ prose-hr:border-border
10
+ prose-th:text-foreground prose-td:text-foreground/90
11
+ prose-li:text-foreground/90`,children:(0,_.jsx)(b,{content:a.content,currentCategory:a.category,onNavigateDoc:(e,t)=>p(`/docs/${e}/${t}`)})})}):null}function S(){let{category:e,slug:t}=a(),{i18n:n}=c(`integrations`),r=n.language||`en`,[i,o]=(0,g.useState)(null),[l,u]=(0,g.useState)(!0),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{fetch(`/api/docs?lang=${encodeURIComponent(r)}`).then(e=>e.json()).then(e=>o(e)).catch(()=>o({categories:[]})).finally(()=>u(!1))},[r]);let f=!!(e&&t);return(0,_.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[l?(0,_.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,_.jsx)(s,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,_.jsx)(v,{categories:i?.categories??[],activeCategory:e,activeSlug:t}),(0,_.jsx)(`main`,{ref:d,className:`flex-1 overflow-y-auto`,children:f&&e&&t?(0,_.jsx)(x,{category:e,slug:t,lang:r,scrollContainerRef:d}):i&&(0,_.jsx)(y,{categories:i.categories})})]})}export{S as default};
@@ -1 +1 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{Xt as t,dn as n,un as r,vt as i,yn as a}from"./index-QEeqwz4v.js";var o=e(a(),1),s=t(),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:a,disabled:u}){let{t:d}=n(`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),r.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)(i,{className:`w-3 h-3`}),m?d(`export.downloading`):a??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)(i,{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};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{Zt as t,bn as n,dn as r,fn as i,yt as a}from"./index-CEunZ8kJ.js";var o=e(n(),1),s=t(),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}=i(`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),r.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};
@@ -1,3 +1,3 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{Ct as t,D as n,E as r,H as i,It as a,L as o,Lt as s,M as c,N as l,O as u,Rt as d,St as f,U as p,Xt as m,Yt as h,Zt as g,dn as _,k as v,pn as y,rt as b,st as x,t as S,tt as C,un as w,vt as T,yn as E}from"./index-QEeqwz4v.js";var D=e(E(),1),O=m(),k=[`todo`,`in_progress`,`done`,`cancelled`],A={todo:`todo`,in_progress:`inProgress`,done:`done`,cancelled:`cancelled`};function j({state:e,onChanged:t}){let{t:n}=_(`jira`),i=e.connection,[a,s]=(0,D.useState)(i.enabled),[c,l]=(0,D.useState)(!1),[u,d]=(0,D.useState)(!1),[f,p]=(0,D.useState)([]),[m,h]=(0,D.useState)([]),[g,v]=(0,D.useState)(i.discardStatus??``),[y,b]=(0,D.useState)(i.statusMap??{}),x=e.outbox??{pending:0,inflight:0,done:0,dead:0},S=(0,D.useCallback)(async()=>{try{let{ops:e}=await r.listOutbox(`dead`);p(e)}catch{p([])}},[]);(0,D.useEffect)(()=>{S()},[S]),(0,D.useEffect)(()=>{let e=!1;return r.listStatuses().then(({statuses:t})=>{e||h(t)}).catch(()=>{e||h([])}),()=>{e=!0}},[]);async function C(e){let i=g;v(e);try{await r.patchConnection({discardStatus:e||null}),t()}catch(e){v(i),w.error(N(e,n))}}async function T(e,i){let a=y,o={...y,[e]:i||void 0};b(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{await r.patchConnection({statusMap:Object.keys(s).length?s:null}),t()}catch(e){b(a),w.error(N(e,n))}}async function E(){let e=!a;s(e),d(!0);try{await r.setEnabled(e)}catch(t){s(!e),w.error(N(t,n))}finally{d(!1)}}async function j(){l(!0);try{let e=await r.syncNow();w.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){w.error(N(e,n))}finally{l(!1)}}async function P(){if(window.confirm(n(`status.disconnectConfirm`))){d(!0);try{await r.disconnect(),w.success(n(`status.disconnectedToast`)),t()}catch(e){w.error(N(e,n))}finally{d(!1)}}}async function F(e){try{await r.retryOutbox(e),await S()}catch(e){w.error(N(e,n))}}let I=x.pending+x.inflight;return(0,O.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:i.jiraProjectKey})}),(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,O.jsx)(`a`,{href:`${i.baseUrl}/browse/${i.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(a?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":n(`status.enabledLabel`),disabled:u,onClick:E,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${a?`bg-accent-success`:`bg-input`}`,children:(0,O.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${a?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,O.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,O.jsx)(`div`,{className:`space-y-2`,children:k.map(e=>(0,O.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${A[e]}`)}),(0,O.jsxs)(`select`,{value:y[e]??``,onChange:t=>void T(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,O.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),m.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.name},e.id)),y[e]&&!m.some(t=>t.name===y[e])&&(0,O.jsx)(`option`,{value:y[e],children:y[e]})]})]},e))})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,O.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,O.jsxs)(`select`,{value:g,onChange:e=>void C(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,O.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),m.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.name},e.id)),g&&!m.some(e=>e.name===g)&&(0,O.jsx)(`option`,{value:g,children:g})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(o,{variant:`outline`,size:`sm`,onClick:j,disabled:c,children:n(c?`status.syncing`:`status.syncNow`)}),(0,O.jsx)(o,{variant:`ghost`,size:`sm`,onClick:P,disabled:u,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),x.dead>0?(0,O.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:x.dead})}):I>0?(0,O.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,O.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),f.length>0&&(0,O.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),f.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,O.jsxs)(`span`,{className:`truncate text-xs`,children:[M(e,n),` · `,e.deadReason??e.lastError??``]}),(0,O.jsx)(o,{variant:`outline`,size:`sm`,onClick:()=>F(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function M(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function N(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function P({activeProjectId:e}){let{t:i}=_(`integrations`),[a,o]=(0,D.useState)(null),[s,d]=(0,D.useState)(!0),[f,p]=(0,D.useState)(!1),[m,h]=(0,D.useState)(!1),g=(0,D.useCallback)(async()=>{try{o(await r.getConnection())}catch{o({connected:!1})}finally{d(!1)}},[]);if((0,D.useEffect)(()=>{!n||!e||(d(!0),g())},[e,g]),!n)return null;let y=!!(a?.connected&&a.connection);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,O.jsx)(b,{className:`w-4 h-4`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:i(`jiraCard.title`)}),y&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,O.jsx)(t,{className:`w-3 h-3`}),` `,i(`jiraCard.connected`)]})]}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:i(`jiraCard.category`)})]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:y&&a?.connection?i(`jiraCard.connectedDescription`,{key:a.connection.jiraProjectKey}):i(`jiraCard.description`)}),(0,O.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,O.jsx)(`li`,{children:i(`jiraCard.bullet1`)}),(0,O.jsx)(`li`,{children:i(`jiraCard.bullet2`)}),(0,O.jsx)(`li`,{children:i(`jiraCard.bullet3`)})]}),(0,O.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:i(`jiraCard.requires`)}),(0,O.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:s?(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):y?(0,O.jsx)(`button`,{type:`button`,onClick:()=>h(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:i(`jiraCard.manage`)}):(0,O.jsxs)(`button`,{type:`button`,onClick:()=>p(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,O.jsx)(b,{className:`w-3.5 h-3.5`}),i(`jiraCard.connect`)]})}),(0,O.jsx)(u,{open:f,onOpenChange:p,children:(0,O.jsxs)(v,{className:`max-w-lg`,children:[(0,O.jsx)(c,{children:(0,O.jsx)(l,{children:i(`jiraCard.modalTitle`)})}),(0,O.jsx)(S,{onConnected:()=>{p(!1),g()},onSkip:()=>p(!1)})]})}),(0,O.jsx)(u,{open:m,onOpenChange:h,children:(0,O.jsxs)(v,{className:`max-w-lg`,children:[(0,O.jsx)(c,{children:(0,O.jsx)(l,{children:i(`jiraCard.manageTitle`)})}),a?.connected&&a.connection&&(0,O.jsx)(j,{state:a,onChanged:()=>{g().then(()=>h(!1))}})]})})]})}function F(){let{t:e}=_(`integrations`),{activeProjectId:t,projects:r}=s(),o=r.find(e=>e.id===t),c=o?a(o).includes(`claude`):!0,{registerHandler:l,unregisterHandler:u}=h(),f=(0,D.useRef)(t);(0,D.useEffect)(()=>{f.current=t},[t]);let[p,m]=(0,D.useState)(null),[v,y]=(0,D.useState)(null),{data:b,isLoading:x,isFirstLoad:S,refresh:w}=d({namespace:`plugins`,projectId:t,initialValue:[],fetcher:(0,D.useCallback)(async()=>{let e=await fetch(`${g()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,D.useEffect)(()=>(l(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==f.current||t.type.startsWith(`plugin.`)&&w())}),()=>u(`integrations-page`)),[l,u,w]),(0,D.useEffect)(()=>{m(!x&&!b?`Failed to load plugins`:null)},[x,b]);let T=(0,D.useMemo)(()=>(b??[]).filter(e=>e.status!==`orphan`),[b]),E=(0,D.useMemo)(()=>(b??[]).filter(e=>e.status===`orphan`),[b]);return t?(0,O.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,O.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,O.jsx)(C,{className:`w-4 h-4 text-accent-primary`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:S&&x?(0,O.jsx)(G,{}):p&&c?(0,O.jsx)(K,{onRetry:w}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,O.jsx)(P,{activeProjectId:t}),c&&T.map(e=>(0,O.jsx)(I,{plugin:e,isInstalling:v===e.name,onInstall:()=>y(e.name),onCloseInstall:()=>{y(null),w()}},e.name))]}),c&&E.length>0&&(0,O.jsxs)(`div`,{className:`mt-10`,children:[(0,O.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,O.jsx)(i,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:E.map(e=>(0,O.jsx)(V,{plugin:e,onRemoved:w},e.name))})]}),!n&&(!c||T.length===0)&&(0,O.jsx)(q,{})]})})]}):(0,O.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function I({plugin:e,isInstalling:n,onInstall:r,onCloseInstall:a}){let{t:o}=_(`integrations`),[s,c]=(0,D.useState)(!1);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,O.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,O.jsx)(t,{className:`w-3 h-3`}),` `,o(`card.statusActive`)]}),e.status===`deactivated`&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,O.jsx)(f,{className:`w-3 h-3`}),` `,o(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,O.jsx)(i,{className:`w-3 h-3`}),` `,o(`card.statusDegraded`)]}),e.updateAvailable&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,O.jsx)(T,{className:`w-3 h-3`}),` `,o(`card.updateAvailable`)]})]}),e.category&&(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,O.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,O.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:o(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,O.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,O.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,O.jsx)(y,{t:o,i18nKey:`card.deactivatedHint`,components:{strong:(0,O.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,O.jsx)(B,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,O.jsx)(R,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,O.jsx)(z,{pluginName:e.name}),(0,O.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,O.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:o(`card.install`)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(L,{pluginName:e.name,active:e.status===`installed`}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>c(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,O.jsx)(p,{className:`w-3 h-3`}),` `,o(`card.uninstall`)]})]})}),n&&(0,O.jsx)(H,{pluginName:e.name,onClose:a}),s&&(0,O.jsx)(U,{pluginName:e.name,onClose:()=>c(!1),onUninstalled:()=>{c(!1)}})]})}function L({pluginName:e,active:t}){let{t:n}=_(`integrations`),[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(null);return(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),o(null);try{let n=`${g()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){o(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,O.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,O.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),a&&(0,O.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a})]})}function R({keys:e}){let{t}=_(`integrations`);return(0,O.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,O.jsx)(i,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:(0,O.jsx)(y,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,O.jsx)(`strong`,{}),code:(0,O.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,O.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,O.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,O.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function z({pluginName:e}){let{t}=_(`integrations`),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null);return(0,O.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,O.jsx)(T,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:(0,O.jsx)(y,{t,i18nKey:`update.body`,components:{code:(0,O.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,O.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{r(!0),a(null);try{let t=await fetch(`${g()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){a(e.message)}finally{r(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[n&&(0,O.jsx)(x,{className:`w-2.5 h-2.5 animate-spin`}),(0,O.jsx)(y,{t,i18nKey:`update.button`,components:{code:(0,O.jsx)(`code`,{})}})]}),i&&(0,O.jsx)(`div`,{className:`text-destructive text-[10px]`,children:i})]})}function B({pluginName:e,conflicts:t}){let{t:n}=_(`integrations`),[r,a]=(0,D.useState)(null),[o,s]=(0,D.useState)(null),c=async e=>{a(e),s(null);try{let t=await fetch(`${g()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){s(e.message)}finally{a(null)}};return(0,O.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,O.jsx)(i,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:(0,O.jsx)(y,{t:n,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,O.jsx)(`strong`,{})}})})]}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,O.jsxs)(`button`,{type:`button`,disabled:r===e,onClick:()=>c(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[r===e&&(0,O.jsx)(x,{className:`w-2.5 h-2.5 animate-spin`}),(0,O.jsx)(y,{t:n,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,O.jsx)(`code`,{})}})]},e))}),o&&(0,O.jsx)(`div`,{className:`text-destructive`,children:o})]})}function V({plugin:e,onRemoved:t}){let{t:n}=_(`integrations`),[r,i]=(0,D.useState)(!1);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,O.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,O.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,O.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${g()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,O.jsx)(p,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function H({pluginName:e,onClose:n}){let{t:r}=_(`integrations`),[a,o]=(0,D.useState)(null),[s,c]=(0,D.useState)(null),[l,u]=(0,D.useState)(!1),[d,p]=(0,D.useState)(null),[m,v]=(0,D.useState)([]),[y,b]=(0,D.useState)(null),[S,C]=(0,D.useState)([]),{registerHandler:w,unregisterHandler:E}=h(),k=(0,D.useCallback)(()=>{o(null),c(null),fetch(`${g()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>o(e)).catch(e=>c(e.message))},[e]);(0,D.useEffect)(()=>{k()},[k]),(0,D.useEffect)(()=>(w(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&v(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&C(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){b(null);let e=n.reason;e&&C(t=>[...t,`► ${e}`]),n.ok&&k()}}),()=>E(`install-${e}`)),[e,w,E,k]);let A=async e=>{b(e),C([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${g()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){C(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),b(null)}},j=(a?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,O.jsxs)(W,{onClose:n,title:r(`installDialog.title`,{name:e}),children:[s&&(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:s}),!a&&!s&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,O.jsx)(x,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),a&&(0,O.jsxs)(O.Fragment,{children:[a.platformNote&&(0,O.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,O.jsx)(i,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:a.platformNote})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,O.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:a.files.map((e,t)=>(0,O.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),a.requirements.length>0&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,O.jsx)(`ul`,{className:`text-xs space-y-1`,children:a.requirements.map(e=>{let n=e.installed&&e.executable&&e.meetsMinimum,i=e.name===`uv`;return(0,O.jsxs)(`li`,{className:`flex items-center gap-2`,children:[n?(0,O.jsx)(t,{className:`w-3 h-3 text-accent-success`}):(0,O.jsx)(f,{className:`w-3 h-3 text-accent-warning`}),(0,O.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!n&&i&&(0,O.jsxs)(`button`,{type:`button`,disabled:y===e.name,onClick:()=>A(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[y===e.name&&(0,O.jsx)(x,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),S.length>0&&(0,O.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:S.join(`
2
- `)})]}),m.length>0&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.progress`)}),(0,O.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:m.join(`
3
- `)})]}),d&&(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:d})]}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:n,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,O.jsxs)(`button`,{type:`button`,disabled:!a||!j||l,onClick:async()=>{u(!0),p(null);try{let t=await fetch(`${g()}/plugins/${e}/install`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);setTimeout(n,1500)}catch(e){p(e.message)}finally{u(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[l?(0,O.jsx)(x,{className:`w-3 h-3 animate-spin`}):(0,O.jsx)(T,{className:`w-3 h-3`}),r(`card.install`)]})]})]})}function U({pluginName:e,onClose:t,onUninstalled:n}){let{t:r}=_(`integrations`),[i,a]=(0,D.useState)(!1),[o,s]=(0,D.useState)(null);return(0,O.jsxs)(W,{onClose:t,title:r(`uninstallDialog.title`,{name:e}),children:[(0,O.jsx)(`p`,{className:`text-xs`,children:(0,O.jsx)(y,{t:r,i18nKey:`uninstallDialog.body`,components:{code:(0,O.jsx)(`code`,{})}})}),o&&(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:o}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,O.jsxs)(`button`,{type:`button`,disabled:i,onClick:async()=>{a(!0);try{let t=await fetch(`${g()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);n()}catch(e){s(e.message)}finally{a(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[i&&(0,O.jsx)(x,{className:`w-3 h-3 animate-spin`}),r(`card.uninstall`)]})]})]})}function W({title:e,onClose:t,children:n}){return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:t,children:(0,O.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),n]})})}function G(){return(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,O.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function K({onRetry:e}){let{t}=_(`integrations`);return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,O.jsx)(i,{className:`w-5 h-5 text-destructive`}),(0,O.jsx)(`p`,{children:t(`page.loadError`)}),(0,O.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function q(){let{t:e}=_(`integrations`);return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(C,{className:`w-6 h-6`}),(0,O.jsx)(`p`,{children:e(`page.empty`)})]})}export{F as default};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{A as t,Ct as n,D as r,Lt as i,N as a,O as o,P as s,Qt as c,R as l,Rt as u,U as d,W as f,Xt as p,Zt as m,bn as h,ct as g,dn as _,fn as v,it as y,k as b,mn as x,nt as S,t as C,wt as w,yt as T,zt as E}from"./index-CEunZ8kJ.js";var D=e(h(),1),O=m(),k=[`todo`,`in_progress`,`done`,`cancelled`],A={todo:`todo`,in_progress:`inProgress`,done:`done`,cancelled:`cancelled`};function j({state:e,onChanged:t}){let{t:n}=v(`jira`),i=e.connection,[a,o]=(0,D.useState)(i.enabled),[s,c]=(0,D.useState)(!1),[u,d]=(0,D.useState)(!1),[f,p]=(0,D.useState)([]),[m,h]=(0,D.useState)([]),[g,y]=(0,D.useState)(i.discardStatus??``),[b,x]=(0,D.useState)(i.statusMap??{}),S=e.outbox??{pending:0,inflight:0,done:0,dead:0},C=(0,D.useCallback)(async()=>{try{let{ops:e}=await r.listOutbox(`dead`);p(e)}catch{p([])}},[]);(0,D.useEffect)(()=>{C()},[C]),(0,D.useEffect)(()=>{let e=!1;return r.listStatuses().then(({statuses:t})=>{e||h(t)}).catch(()=>{e||h([])}),()=>{e=!0}},[]);async function w(e){let i=g;y(e);try{await r.patchConnection({discardStatus:e||null}),t()}catch(e){y(i),_.error(N(e,n))}}async function T(e,i){let a=b,o={...b,[e]:i||void 0};x(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{await r.patchConnection({statusMap:Object.keys(s).length?s:null}),t()}catch(e){x(a),_.error(N(e,n))}}async function E(){let e=!a;o(e),d(!0);try{await r.setEnabled(e)}catch(t){o(!e),_.error(N(t,n))}finally{d(!1)}}async function j(){c(!0);try{let e=await r.syncNow();_.success(n(`status.syncedToast`,{count:e.upserted}))}catch(e){_.error(N(e,n))}finally{c(!1)}}async function P(){if(window.confirm(n(`status.disconnectConfirm`))){d(!0);try{await r.disconnect(),_.success(n(`status.disconnectedToast`)),t()}catch(e){_.error(N(e,n))}finally{d(!1)}}}async function F(e){try{await r.retryOutbox(e),await C()}catch(e){_.error(N(e,n))}}let I=S.pending+S.inflight;return(0,O.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:n(`status.connected`,{key:i.jiraProjectKey})}),(0,O.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?n(`review.cloud`):n(`review.dc`)]})]}),(0,O.jsx)(`a`,{href:`${i.baseUrl}/browse/${i.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:n(`badge.openInJira`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`status.enabledLabel`)}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(a?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,O.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":a,"aria-label":n(`status.enabledLabel`),disabled:u,onClick:E,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${a?`bg-accent-success`:`bg-input`}`,children:(0,O.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${a?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`wizard.step3Title`)}),(0,O.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`mapping.intro`)}),(0,O.jsx)(`div`,{className:`space-y-2`,children:k.map(e=>(0,O.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n(`mapping.${A[e]}`)}),(0,O.jsxs)(`select`,{value:b[e]??``,onChange:t=>void T(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,O.jsx)(`option`,{value:``,children:n(`mapping.auto`)}),m.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!m.some(t=>t.name===b[e])&&(0,O.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`discard.configLabel`)}),(0,O.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:n(`discard.configHelp`)}),(0,O.jsxs)(`select`,{value:g,onChange:e=>void w(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,O.jsx)(`option`,{value:``,children:n(`discard.configNone`)}),m.map(e=>(0,O.jsx)(`option`,{value:e.name,children:e.name},e.id)),g&&!m.some(e=>e.name===g)&&(0,O.jsx)(`option`,{value:g,children:g})]})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(l,{variant:`outline`,size:`sm`,onClick:j,disabled:s,children:n(s?`status.syncing`:`status.syncNow`)}),(0,O.jsx)(l,{variant:`ghost`,size:`sm`,onClick:P,disabled:u,className:`text-destructive`,children:n(`status.disconnect`)})]}),(0,O.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,O.jsx)(`p`,{className:`text-sm font-medium`,children:n(`outbox.title`)}),S.dead>0?(0,O.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:n(`outbox.dead`,{count:S.dead})}):I>0?(0,O.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.pending`,{count:I})}):(0,O.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`outbox.allSynced`)}),f.length>0&&(0,O.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`outbox.deadHelp`)}),f.map(e=>(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,O.jsxs)(`span`,{className:`truncate text-xs`,children:[M(e,n),` · `,e.deadReason??e.lastError??``]}),(0,O.jsx)(l,{variant:`outline`,size:`sm`,onClick:()=>F(e.id),children:n(`outbox.retry`)})]},e.id))]})]})]})}function M(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function N(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function P({activeProjectId:e}){let{t:n}=v(`integrations`),[i,c]=(0,D.useState)(null),[l,u]=(0,D.useState)(!0),[d,f]=(0,D.useState)(!1),[p,m]=(0,D.useState)(!1),h=(0,D.useCallback)(async()=>{try{c(await r.getConnection())}catch{c({connected:!1})}finally{u(!1)}},[]);if((0,D.useEffect)(()=>{!o||!e||(u(!0),h())},[e,h]),!o)return null;let g=!!(i?.connected&&i.connection);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,"data-testid":`jira-integration-card`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,O.jsx)(`div`,{className:`grid place-items-center w-9 h-9 rounded-md bg-accent-info/15 text-accent-info shrink-0`,children:(0,O.jsx)(y,{className:`w-4 h-4`})}),(0,O.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`jiraCard.title`)}),g&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,"data-testid":`jira-connected-badge`,children:[(0,O.jsx)(w,{className:`w-3 h-3`}),` `,n(`jiraCard.connected`)]})]}),(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:n(`jiraCard.category`)})]})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:g&&i?.connection?n(`jiraCard.connectedDescription`,{key:i.connection.jiraProjectKey}):n(`jiraCard.description`)}),(0,O.jsxs)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:[(0,O.jsx)(`li`,{children:n(`jiraCard.bullet1`)}),(0,O.jsx)(`li`,{children:n(`jiraCard.bullet2`)}),(0,O.jsx)(`li`,{children:n(`jiraCard.bullet3`)})]}),(0,O.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:n(`jiraCard.requires`)}),(0,O.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:l?(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`…`}):g?(0,O.jsx)(`button`,{type:`button`,onClick:()=>m(!0),"data-testid":`jira-manage-btn`,className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-muted/30 inline-flex items-center gap-1.5`,children:n(`jiraCard.manage`)}):(0,O.jsxs)(`button`,{type:`button`,onClick:()=>f(!0),"data-testid":`jira-connect-btn`,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90 inline-flex items-center gap-1.5`,children:[(0,O.jsx)(y,{className:`w-3.5 h-3.5`}),n(`jiraCard.connect`)]})}),(0,O.jsx)(b,{open:d,onOpenChange:f,children:(0,O.jsxs)(t,{className:`max-w-lg`,children:[(0,O.jsx)(a,{children:(0,O.jsx)(s,{children:n(`jiraCard.modalTitle`)})}),(0,O.jsx)(C,{onConnected:()=>{f(!1),h()},onSkip:()=>f(!1)})]})}),(0,O.jsx)(b,{open:p,onOpenChange:m,children:(0,O.jsxs)(t,{className:`max-w-lg`,children:[(0,O.jsx)(a,{children:(0,O.jsx)(s,{children:n(`jiraCard.manageTitle`)})}),i?.connected&&i.connection&&(0,O.jsx)(j,{state:i,onChanged:()=>{h().then(()=>m(!1))}})]})})]})}function F(){let{t:e}=v(`integrations`),{activeProjectId:t,projects:n}=u(),r=n.find(e=>e.id===t),a=r?i(r).includes(`claude`):!0,{registerHandler:s,unregisterHandler:l}=p(),f=(0,D.useRef)(t);(0,D.useEffect)(()=>{f.current=t},[t]);let[m,h]=(0,D.useState)(null),[g,_]=(0,D.useState)(null),{data:y,isLoading:b,isFirstLoad:x,refresh:C}=E({namespace:`plugins`,projectId:t,initialValue:[],fetcher:(0,D.useCallback)(async()=>{let e=await fetch(`${c()}/plugins`);if(!e.ok)throw Error(`HTTP ${e.status}`);return(await e.json()).plugins??[]},[])});(0,D.useEffect)(()=>(s(`integrations-page`,e=>{let t=e;t.type&&(t.projectId&&t.projectId!==f.current||t.type.startsWith(`plugin.`)&&C())}),()=>l(`integrations-page`)),[s,l,C]),(0,D.useEffect)(()=>{h(!b&&!y?`Failed to load plugins`:null)},[b,y]);let w=(0,D.useMemo)(()=>(y??[]).filter(e=>e.status!==`orphan`),[y]),T=(0,D.useMemo)(()=>(y??[]).filter(e=>e.status===`orphan`),[y]);return t?(0,O.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,O.jsxs)(`div`,{className:`flex-shrink-0 border-b border-border px-6 pt-4 pb-3 flex items-center gap-2`,children:[(0,O.jsx)(S,{className:`w-4 h-4 text-accent-primary`}),(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsx)(`h1`,{className:`text-lg font-semibold`,children:e(`page.title`)}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:e(`page.subtitle`)})]})]}),(0,O.jsx)(`div`,{className:`flex-1 overflow-auto p-6`,children:x&&b?(0,O.jsx)(G,{}):m&&a?(0,O.jsx)(K,{onRetry:C}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:[(0,O.jsx)(P,{activeProjectId:t}),a&&w.map(e=>(0,O.jsx)(I,{plugin:e,isInstalling:g===e.name,onInstall:()=>_(e.name),onCloseInstall:()=>{_(null),C()}},e.name))]}),a&&T.length>0&&(0,O.jsxs)(`div`,{className:`mt-10`,children:[(0,O.jsxs)(`h2`,{className:`text-sm font-semibold text-muted-foreground mb-3 flex items-center gap-2`,children:[(0,O.jsx)(d,{className:`w-3.5 h-3.5`}),` `,e(`page.deprecated`)]}),(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:T.map(e=>(0,O.jsx)(V,{plugin:e,onRemoved:C},e.name))})]}),!o&&(!a||w.length===0)&&(0,O.jsx)(q,{})]})})]}):(0,O.jsx)(`div`,{className:`flex flex-col items-center justify-center h-full text-muted-foreground text-sm`,children:e(`page.selectProject`)})}function I({plugin:e,isInstalling:t,onInstall:r,onCloseInstall:i}){let{t:a}=v(`integrations`),[o,s]=(0,D.useState)(!1);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-4 flex flex-col gap-3 h-full`,children:[(0,O.jsx)(`div`,{className:`flex items-start gap-2`,children:(0,O.jsxs)(`div`,{className:`flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:[`v`,e.version]}),e.status===`installed`&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success flex items-center gap-1`,children:[(0,O.jsx)(w,{className:`w-3 h-3`}),` `,a(`card.statusActive`)]}),e.status===`deactivated`&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground flex items-center gap-1`,children:[(0,O.jsx)(n,{className:`w-3 h-3`}),` `,a(`card.statusDeactivated`)]}),e.status===`degraded`&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning flex items-center gap-1`,children:[(0,O.jsx)(d,{className:`w-3 h-3`}),` `,a(`card.statusDegraded`)]}),e.updateAvailable&&(0,O.jsxs)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/20 text-accent-info flex items-center gap-1`,children:[(0,O.jsx)(T,{className:`w-3 h-3`}),` `,a(`card.updateAvailable`)]})]}),e.category&&(0,O.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:e.category})]})}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground leading-relaxed`,children:e.description}),e.whatItDoes.length>0&&(0,O.jsx)(`ul`,{className:`text-xs space-y-1 list-disc pl-4 text-foreground/80`,children:e.whatItDoes.map((e,t)=>(0,O.jsx)(`li`,{children:e},t))}),e.requirements.length>0&&(0,O.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:a(`card.requires`,{list:e.requirements.map(e=>`${e.name}${e.minVersion?` ≥ ${e.minVersion}`:``}`).join(`, `)})}),e.healthReason&&e.status===`degraded`&&(0,O.jsx)(`div`,{className:`text-[11px] text-accent-warning`,children:e.healthReason}),e.status===`deactivated`&&(0,O.jsx)(`div`,{className:`text-[11px] text-muted-foreground leading-relaxed`,children:(0,O.jsx)(x,{t:a,i18nKey:`card.deactivatedHint`,components:{strong:(0,O.jsx)(`strong`,{})}})}),e.marketplaceConflicts&&e.marketplaceConflicts.length>0&&(0,O.jsx)(B,{pluginName:e.name,conflicts:e.marketplaceConflicts}),e.marketplaceCachedButDisabled&&e.marketplaceCachedButDisabled.length>0&&(0,O.jsx)(R,{keys:e.marketplaceCachedButDisabled}),e.updateAvailable&&(0,O.jsx)(z,{pluginName:e.name}),(0,O.jsx)(`div`,{className:`mt-auto pt-2 flex items-center justify-end gap-2`,children:e.status===`not-installed`?(0,O.jsx)(`button`,{type:`button`,onClick:r,className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white hover:opacity-90`,children:a(`card.install`)}):(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(L,{pluginName:e.name,active:e.status===`installed`}),(0,O.jsxs)(`button`,{type:`button`,onClick:()=>s(!0),className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,O.jsx)(f,{className:`w-3 h-3`}),` `,a(`card.uninstall`)]})]})}),t&&(0,O.jsx)(H,{pluginName:e.name,onClose:i}),o&&(0,O.jsx)(U,{pluginName:e.name,onClose:()=>s(!1),onUninstalled:()=>{s(!1)}})]})}function L({pluginName:e,active:t}){let{t:n}=v(`integrations`),[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(null);return(0,O.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,O.jsx)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0),o(null);try{let n=`${c()}/plugins/${e}/${t?`deactivate`:`activate`}`,r=await fetch(n,{method:`POST`});if(!r.ok)throw Error((await r.json()).error??`HTTP ${r.status}`)}catch(e){o(e.message)}finally{i(!1)}},role:`switch`,"aria-checked":t,className:`relative inline-flex items-center h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${t?`bg-accent-success`:`bg-muted`}`,title:n(t?`toggle.titleActive`:`toggle.titleDeactivated`),children:(0,O.jsx)(`span`,{className:`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform ${t?`translate-x-4`:`translate-x-0.5`}`})}),(0,O.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:n(t?`card.statusActive`:`common:states.off`)}),a&&(0,O.jsx)(`span`,{className:`text-[10px] text-destructive`,children:a})]})}function R({keys:e}){let{t}=v(`integrations`);return(0,O.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,O.jsx)(d,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:(0,O.jsx)(x,{t,i18nKey:`cachedNotice.body`,components:{strong:(0,O.jsx)(`strong`,{}),code:(0,O.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,O.jsx)(`div`,{className:`pl-5 space-y-0.5`,children:e.map(e=>(0,O.jsxs)(`pre`,{className:`text-[10px] bg-muted/40 rounded px-1.5 py-0.5 inline-block font-mono`,children:[`/plugin uninstall `,e]},e))}),(0,O.jsx)(`div`,{className:`pl-5 text-[10px] text-muted-foreground`,children:t(`cachedNotice.runInstruction`)})]})}function z({pluginName:e}){let{t}=v(`integrations`),[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(null);return(0,O.jsxs)(`div`,{className:`text-[11px] rounded-md border border-accent-info/30 bg-accent-info/5 p-2 leading-relaxed space-y-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,O.jsx)(T,{className:`w-3 h-3 text-accent-info mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:(0,O.jsx)(x,{t,i18nKey:`update.body`,components:{code:(0,O.jsx)(`code`,{className:`bg-muted px-1 rounded`})}})})]}),(0,O.jsxs)(`button`,{type:`button`,disabled:n,onClick:async()=>{r(!0),a(null);try{let t=await fetch(`${c()}/plugins/${e}/update`,{method:`POST`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){a(e.message)}finally{r(!1)}},className:`text-[10px] px-2 py-0.5 rounded border border-accent-info/40 hover:bg-accent-info/10 disabled:opacity-50 flex items-center gap-1`,children:[n&&(0,O.jsx)(g,{className:`w-2.5 h-2.5 animate-spin`}),(0,O.jsx)(x,{t,i18nKey:`update.button`,components:{code:(0,O.jsx)(`code`,{})}})]}),i&&(0,O.jsx)(`div`,{className:`text-destructive text-[10px]`,children:i})]})}function B({pluginName:e,conflicts:t}){let{t:n}=v(`integrations`),[r,i]=(0,D.useState)(null),[a,o]=(0,D.useState)(null),s=async e=>{i(e),o(null);try{let t=await fetch(`${c()}/plugins/_marketplace/disable`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({key:e})});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`)}catch(e){o(e.message)}finally{i(null)}};return(0,O.jsxs)(`div`,{className:`text-[11px] rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-2 leading-relaxed space-y-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,O.jsx)(d,{className:`w-3 h-3 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:(0,O.jsx)(x,{t:n,i18nKey:`conflict.body`,values:{name:e},components:{strong:(0,O.jsx)(`strong`,{})}})})]}),(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,children:t.map(e=>(0,O.jsxs)(`button`,{type:`button`,disabled:r===e,onClick:()=>s(e),className:`text-[10px] px-2 py-0.5 rounded border border-yellow-500/40 aurora-light:border-accent-warning/40 hover:bg-yellow-500/10 aurora-light:hover:bg-accent-warning/10 disabled:opacity-50 flex items-center gap-1`,children:[r===e&&(0,O.jsx)(g,{className:`w-2.5 h-2.5 animate-spin`}),(0,O.jsx)(x,{t:n,i18nKey:`conflict.disableButton`,values:{key:e},components:{code:(0,O.jsx)(`code`,{})}})]},e))}),a&&(0,O.jsx)(`div`,{className:`text-destructive`,children:a})]})}function V({plugin:e,onRemoved:t}){let{t:n}=v(`integrations`),[r,i]=(0,D.useState)(!1);return(0,O.jsxs)(`div`,{className:`rounded-lg border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 p-4 flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.name}),(0,O.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-yellow-500/20 aurora-light:bg-accent-warning/15 text-yellow-500 aurora-light:text-accent-warning`,children:n(`orphan.badge`)})]}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}),(0,O.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,O.jsxs)(`button`,{type:`button`,disabled:r,onClick:async()=>{i(!0);try{await fetch(`${c()}/plugins/${e.name}`,{method:`DELETE`}),t()}finally{i(!1)}},className:`text-xs px-3 py-1.5 rounded-md border border-border hover:bg-destructive/10 hover:text-destructive flex items-center gap-1.5`,children:[(0,O.jsx)(f,{className:`w-3 h-3`}),` `,n(`orphan.removeButton`)]})})]})}function H({pluginName:e,onClose:t}){let{t:r}=v(`integrations`),[i,a]=(0,D.useState)(null),[o,s]=(0,D.useState)(null),[l,u]=(0,D.useState)(!1),[f,m]=(0,D.useState)(null),[h,_]=(0,D.useState)([]),[y,b]=(0,D.useState)(null),[x,S]=(0,D.useState)([]),{registerHandler:C,unregisterHandler:E}=p(),k=(0,D.useCallback)(()=>{a(null),s(null),fetch(`${c()}/plugins/${e}/preview-install`).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>a(e)).catch(e=>s(e.message))},[e]);(0,D.useEffect)(()=>{k()},[k]),(0,D.useEffect)(()=>(C(`install-${e}`,t=>{let n=t;if(n.type===`plugin.install_progress`&&n.name===e&&n.line&&_(e=>[...e,n.line]),n.type===`plugin.prereq_install_progress`&&n.line&&S(e=>[...e,n.line]),n.type===`plugin.prereq_installed`){b(null);let e=n.reason;e&&S(t=>[...t,`► ${e}`]),n.ok&&k()}}),()=>E(`install-${e}`)),[e,C,E,k]);let A=async e=>{b(e),S([r(`installDialog.installingPrereq`,{name:e})]);try{await fetch(`${c()}/plugins/_prerequisites/${e}/install`,{method:`POST`})}catch(e){S(t=>[...t,r(`installDialog.prereqStartFailed`,{message:e.message})]),b(null)}},j=(i?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum);return(0,O.jsxs)(W,{onClose:t,title:r(`installDialog.title`,{name:e}),children:[o&&(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:o}),!i&&!o&&(0,O.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,O.jsx)(g,{className:`w-3 h-3 animate-spin`}),` `,r(`installDialog.computingChanges`)]}),i&&(0,O.jsxs)(O.Fragment,{children:[i.platformNote&&(0,O.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/5 aurora-light:bg-accent-warning/10 text-[11px] leading-relaxed`,children:[(0,O.jsx)(d,{className:`w-3.5 h-3.5 text-yellow-500 aurora-light:text-accent-warning mt-0.5 flex-shrink-0`}),(0,O.jsx)(`span`,{children:i.platformNote})]}),(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.filesHeading`)}),(0,O.jsx)(`ul`,{className:`text-xs space-y-0.5 font-mono`,children:i.files.map((e,t)=>(0,O.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path,e.summary&&(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,e.summary]})]},t))})]}),i.requirements.length>0&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.prerequisites`)}),(0,O.jsx)(`ul`,{className:`text-xs space-y-1`,children:i.requirements.map(e=>{let t=e.installed&&e.executable&&e.meetsMinimum,i=e.name===`uv`;return(0,O.jsxs)(`li`,{className:`flex items-center gap-2`,children:[t?(0,O.jsx)(w,{className:`w-3 h-3 text-accent-success`}):(0,O.jsx)(n,{className:`w-3 h-3 text-accent-warning`}),(0,O.jsxs)(`span`,{children:[e.name,e.minVersion?` ≥ ${e.minVersion}`:``]}),e.version&&(0,O.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]}),!t&&i&&(0,O.jsxs)(`button`,{type:`button`,disabled:y===e.name,onClick:()=>A(e.name),className:`ml-auto text-[10px] px-2 py-0.5 rounded border border-border hover:bg-muted disabled:opacity-50 flex items-center gap-1`,children:[y===e.name&&(0,O.jsx)(g,{className:`w-2.5 h-2.5 animate-spin`}),r(`installDialog.autoInstall`)]})]},e.name)})}),x.length>0&&(0,O.jsx)(`pre`,{className:`mt-2 text-[11px] bg-muted/40 rounded p-2 max-h-24 overflow-auto font-mono`,children:x.join(`
2
+ `)})]}),h.length>0&&(0,O.jsxs)(`section`,{children:[(0,O.jsx)(`h4`,{className:`text-xs font-semibold mb-1.5`,children:r(`installDialog.progress`)}),(0,O.jsx)(`pre`,{className:`text-[11px] bg-muted/40 rounded p-2 max-h-32 overflow-auto font-mono`,children:h.join(`
3
+ `)})]}),f&&(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:f})]}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,O.jsxs)(`button`,{type:`button`,disabled:!i||!j||l,onClick:async()=>{u(!0),m(null);try{let n=await fetch(`${c()}/plugins/${e}/install`,{method:`POST`});if(!n.ok)throw Error((await n.json()).error??`HTTP ${n.status}`);setTimeout(t,1500)}catch(e){m(e.message)}finally{u(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white disabled:opacity-50 flex items-center gap-1.5`,children:[l?(0,O.jsx)(g,{className:`w-3 h-3 animate-spin`}):(0,O.jsx)(T,{className:`w-3 h-3`}),r(`card.install`)]})]})]})}function U({pluginName:e,onClose:t,onUninstalled:n}){let{t:r}=v(`integrations`),[i,a]=(0,D.useState)(!1),[o,s]=(0,D.useState)(null);return(0,O.jsxs)(W,{onClose:t,title:r(`uninstallDialog.title`,{name:e}),children:[(0,O.jsx)(`p`,{className:`text-xs`,children:(0,O.jsx)(x,{t:r,i18nKey:`uninstallDialog.body`,components:{code:(0,O.jsx)(`code`,{})}})}),o&&(0,O.jsx)(`div`,{className:`text-xs text-destructive`,children:o}),(0,O.jsxs)(`div`,{className:`flex justify-end gap-2 pt-2`,children:[(0,O.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:r(`common:actions.cancel`)}),(0,O.jsxs)(`button`,{type:`button`,disabled:i,onClick:async()=>{a(!0);try{let t=await fetch(`${c()}/plugins/${e}`,{method:`DELETE`});if(!t.ok)throw Error((await t.json()).error??`HTTP ${t.status}`);n()}catch(e){s(e.message)}finally{a(!1)}},className:`text-xs px-3 py-1.5 rounded-md bg-destructive text-white disabled:opacity-50 flex items-center gap-1.5`,children:[i&&(0,O.jsx)(g,{className:`w-3 h-3 animate-spin`}),r(`card.uninstall`)]})]})]})}function W({title:e,onClose:t,children:n}){return(0,O.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/40`,role:`dialog`,tabIndex:-1,onClick:t,children:(0,O.jsxs)(`div`,{className:`bg-card border border-border rounded-lg shadow-xl w-full max-w-md p-5 flex flex-col gap-3`,onClick:e=>e.stopPropagation(),children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),n]})})}function G(){return(0,O.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:3},(e,t)=>(0,O.jsx)(`div`,{className:`rounded-lg border border-border bg-card p-4 h-40 animate-pulse`},t))})}function K({onRetry:e}){let{t}=v(`integrations`);return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-3 text-sm text-muted-foreground`,children:[(0,O.jsx)(d,{className:`w-5 h-5 text-destructive`}),(0,O.jsx)(`p`,{children:t(`page.loadError`)}),(0,O.jsx)(`button`,{type:`button`,onClick:e,className:`text-xs px-3 py-1.5 rounded-md border border-border`,children:t(`common:actions.retry`)})]})}function q(){let{t:e}=v(`integrations`);return(0,O.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 gap-2 text-sm text-muted-foreground`,children:[(0,O.jsx)(S,{className:`w-6 h-6`}),(0,O.jsx)(`p`,{children:e(`page.empty`)})]})}export{F as default};