@nice2dev/ui 1.4.13 → 1.4.15

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 (53) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/dist/{NiceColorPicker-BLwYNSXJ.cjs → NiceColorPicker-79rkvaSk.cjs} +1 -1
  3. package/dist/NiceDataGrid-B1AOjgjm.cjs +10 -0
  4. package/dist/NiceForm-fmePSeA9.cjs +1 -0
  5. package/dist/{NiceHtmlEditor-BzECmDO3.cjs → NiceHtmlEditor-By7R1wRo.cjs} +1 -1
  6. package/dist/{NiceMention-CYRqPKGU.cjs → NiceMention-i7n2BoMw.cjs} +1 -1
  7. package/dist/{NiceModuleLifecyclePanel-CiYbPcHV.cjs → NiceModuleLifecyclePanel-DVHQuhc-.cjs} +1 -1
  8. package/dist/{NicePagination-BAxwqeEd.cjs → NicePagination-D9JguOl0.cjs} +1 -1
  9. package/dist/NicePivotGrid-B_7iQJys.cjs +2 -0
  10. package/dist/NiceSavedQueryPanel-ChY4HwpM.cjs +587 -0
  11. package/dist/{NiceScheduler-BqYiHPvz.cjs → NiceScheduler-B2DamQ_L.cjs} +1 -1
  12. package/dist/backup/NiceBackupScheduler.mjs +171 -119
  13. package/dist/charts/NiceOrganizationChart.mjs +159 -59
  14. package/dist/charts/orgChartExport.mjs +71 -0
  15. package/dist/charts/tidyTree.mjs +43 -0
  16. package/dist/charts-C3Q3r8Yz.cjs +918 -0
  17. package/dist/charts.cjs +1 -1
  18. package/dist/charts.d.ts +9 -0
  19. package/dist/{core-lazy-BQexApr7.cjs → core-lazy-ChKRuEPb.cjs} +1 -1
  20. package/dist/data/NiceDataGrid.mjs +301 -320
  21. package/dist/data/NiceRowEditDialog.mjs +57 -0
  22. package/dist/data/NiceTreeGrid.mjs +670 -551
  23. package/dist/data/NiceTreeView.mjs +222 -180
  24. package/dist/data/treeRowDrop.mjs +130 -0
  25. package/dist/data.cjs +1 -1
  26. package/dist/data.d.ts +68 -5
  27. package/dist/{devops-cgRBnZVX.cjs → devops-o6Zm0VKB.cjs} +3 -3
  28. package/dist/devops.cjs +1 -1
  29. package/dist/editors/forms/NiceForm.mjs +216 -167
  30. package/dist/editors/inputs/NiceUpload.mjs +238 -238
  31. package/dist/editors.cjs +1 -1
  32. package/dist/editors.d.ts +13 -1
  33. package/dist/feedback.cjs +1 -1
  34. package/dist/index.cjs +254 -254
  35. package/dist/index.d.ts +293 -8
  36. package/dist/index.mjs +980 -966
  37. package/dist/lazy.cjs +1 -1
  38. package/dist/lazy.d.ts +11 -1
  39. package/dist/navigation.cjs +1 -1
  40. package/dist/no-code/NiceDataMapper.mjs +398 -361
  41. package/dist/no-code-CN_q6TcB.cjs +331 -0
  42. package/dist/no-code.cjs +1 -1
  43. package/dist/no-code.d.ts +11 -1
  44. package/dist/style.css +1 -1
  45. package/dist/tools/NicePermissionMatrix.mjs +171 -138
  46. package/dist/tools/NiceRoleEditor.mjs +334 -297
  47. package/package.json +4 -4
  48. package/dist/NiceDataGrid-D3qRQSjy.cjs +0 -10
  49. package/dist/NiceForm-BWb4LTQJ.cjs +0 -1
  50. package/dist/NicePivotGrid-Cxu5PECg.cjs +0 -152
  51. package/dist/NiceSavedQueryPanel-BSZhE-_l.cjs +0 -587
  52. package/dist/charts-BzlvCCg9.cjs +0 -768
  53. package/dist/no-code-B1jzfUF5.cjs +0 -331
@@ -1,4 +1,4 @@
1
- "use strict";const e=require("react/jsx-runtime"),n=require("@nice2dev/ui-core"),o=require("react"),qe=require("react-dom");function Se(a){const f=a?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");if(!f)return"";const w=f.getAttribute("data-theme");return w==="dark"||f.classList.contains("nice-dark")||f.classList.contains("dark")?"nice-dark":w==="light"||f.classList.contains("nice-light")?"nice-light":""}const Ge={info:e.jsx(n.NiceIcon,{name:"info",size:28}),warning:e.jsx(n.NiceIcon,{name:"warning",size:28}),error:e.jsx(n.NiceIcon,{name:"error",size:28}),success:e.jsx(n.NiceIcon,{name:"success",size:28})},Ce=({visible:a,message:f,header:w,icon:B,variant:_="warning",acceptLabel:W,rejectLabel:L,onAccept:D,onReject:E,closeOnOverlay:N=!1,closeOnEscape:j=!0,showReject:P=!0,size:z="md",className:k,style:S,testId:v,"data-testid":M})=>{const{t:C}=n.useNiceTranslation(),i=o.useRef(null),I=L??C("confirm.reject","No");if(n.useOverlayFocus(i,{open:a,onClose:E,closeOnEscape:j,closeHint:P?I:void 0}),o.useEffect(()=>(a?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[a]),!a)return null;const O=B??Ge[_],b=W??C("confirm.accept","Yes");return e.jsx("div",{className:"nice-modal-overlay",role:"presentation",onClick:Y=>{Y.stopPropagation(),N&&Y.target===Y.currentTarget&&E()},onKeyDown:Y=>{Y.key!=="Escape"&&Y.stopPropagation()},children:e.jsxs("div",{ref:i,className:`nice-confirm nice-confirm--${_} nice-confirm--${z} ${k||""}`,style:S,role:"alertdialog","aria-modal":"true","aria-label":w,"aria-describedby":"nice-confirm-message","data-testid":M??v,children:[w&&e.jsx("div",{className:"nice-confirm__header",children:e.jsx("h3",{className:"nice-confirm__title",children:w})}),e.jsxs("div",{className:"nice-confirm__body",children:[O&&e.jsx("div",{className:`nice-confirm__icon nice-confirm__icon--${_}`,children:O}),e.jsx("div",{id:"nice-confirm-message",className:"nice-confirm__message",children:f})]}),e.jsxs("div",{className:"nice-confirm__footer",children:[P&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--md",onClick:E,children:I}),e.jsx("button",{type:"button",className:`nice-btn nice-btn--${_==="error"?"error":"primary"} nice-btn--md`,onClick:D,autoFocus:!0,children:b})]})]})})},je=new Set,Ke=(a,f)=>{if(Object.is(a,f))return!0;try{return JSON.stringify(a)===JSON.stringify(f)}catch{return!1}};function we(a,f,w,B,_,W="on its own the prop is only the initial value"){const L=o.useRef(B);if(process.env.NODE_ENV==="production"||_){L.current=B;return}const D=`${a}.${f}`;B!==void 0&&!je.has(D)&&!Ke(B,L.current)&&(je.add(D),console.warn(`[Nice2Dev] <${a}> \`${f}\` changed after mount without \`${w}\`, so the change is ignored: ${W}. Pass \`${w}\` to control it.`)),L.current=B}const me=[],be=["var(--nice-color-success, #22c55e)","var(--nice-color-primary, #3b82f6)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-accent, #8b5cf6)","var(--nice-info, #14b8a6)","var(--nice-warning, #f97316)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #6366f1)","var(--nice-success, #84cc16)"],ve=24,ze=40,Re=28,Ve=6,Ue=4;function Ye(a,f,w,B){const _=[],W=[],L=new Map;a.forEach((z,k)=>L.set(z.hash,k));const D=new Map,E=[],N=new Map;let j=0;const P=new Map;if(f.forEach(z=>{if(!z.lastCommit)return;const k=P.get(z.lastCommit)||[];k.push({type:z.isRemote?"remote":"branch",name:z.name,commit:z.lastCommit,color:z.isHead?"var(--nice-color-success, #22c55e)":z.isRemote?"var(--nice-text-muted, #6b7280)":"var(--nice-color-primary, #3b82f6)"}),P.set(z.lastCommit,k)}),w.forEach(z=>{const k=P.get(z.commit)||[];k.push({type:"tag",name:z.name,commit:z.commit,color:"var(--nice-color-warning, #f59e0b)"}),P.set(z.commit,k)}),B){const z=P.get(B)||[];z.push({type:"head",name:"HEAD",commit:B,color:"var(--nice-color-error, #ef4444)"}),P.set(B,z)}return a.forEach((z,k)=>{let S=E.findIndex(M=>M===z.hash);S===-1&&(S=E.findIndex(M=>M===null),S===-1&&(S=E.length,E.push(null))),N.has(S)||(N.set(S,be[j%be.length]),j++),D.set(z.hash,S);const v=N.get(S)||be[0];_.push({commit:z,x:S,y:k,color:v,refs:P.get(z.hash)||[]}),z.parents.forEach((M,C)=>{const i=L.get(M);if(i!==void 0){let I=D.get(M);I===void 0&&(C===0?(I=S,E[S]=M):(I=E.findIndex(b=>b===null),I===-1?(I=E.length,E.push(M)):E[I]=M),D.set(M,I));const O=N.get(I)||v;W.push({from:z.hash,to:M,fromX:S,fromY:k,toX:I,toY:i,color:C===0?v:O,type:C===0?S===I?"straight":"branch":"merge"})}}),(z.parents.length===0||!a.slice(k+1).some(M=>M.parents.includes(z.hash)))&&(E[S]=null)}),{nodes:_,edges:W}}const Je=({nodes:a,edges:f,selectedHash:w,compact:B,onNodeClick:_,onNodeDoubleClick:W})=>{const L=B?Re:ze,D=B?Ue:Ve,N=(Math.max(...a.map(k=>k.x),0)+2)*ve,j=(a.length+1)*L,P=k=>ve/2+k*ve,z=k=>L/2+k*L;return e.jsxs("svg",{width:N,height:j,style:{minWidth:N,minHeight:j,display:"block"},children:[f.map((k,S)=>{const v=P(k.fromX),M=z(k.fromY),C=P(k.toX),i=z(k.toY);if(k.type==="straight")return e.jsx("line",{x1:v,y1:M,x2:C,y2:i,stroke:k.color,strokeWidth:2},S);const I=(M+i)/2,O=`M ${v} ${M} C ${v} ${I}, ${C} ${I}, ${C} ${i}`;return e.jsx("path",{d:O,fill:"none",stroke:k.color,strokeWidth:2,strokeDasharray:k.type==="merge"?"4,2":void 0},S)}),a.map(k=>{const S=P(k.x),v=z(k.y),M=k.commit.hash===w,C=k.commit.isMerge;return e.jsxs("g",{onClick:()=>_(k.commit.hash),onDoubleClick:()=>W(k.commit.hash),style:{cursor:"pointer"},children:[M&&e.jsx("circle",{cx:S,cy:v,r:D+4,fill:"none",stroke:"var(--nice-bg, #fff)",strokeWidth:2}),e.jsx("circle",{cx:S,cy:v,r:D,fill:C?"var(--nice-bg-elevated, #1e1e1e)":k.color,stroke:k.color,strokeWidth:C?2:0}),k.refs.length>0&&!B&&e.jsx("foreignObject",{x:S+10,y:v-8,width:200,height:16,children:e.jsx("div",{style:{display:"flex",gap:4,whiteSpace:"nowrap"},children:k.refs.map((i,I)=>e.jsxs("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:10,fontWeight:500,background:`${i.color}22`,color:i.color,border:`1px solid ${i.color}44`},children:[i.type==="tag"?e.jsx(n.NiceIcon,{name:"tag",size:10}):i.type==="head"?e.jsx(n.NiceIcon,{name:"cursor",size:10}):null,(i.type==="tag"||i.type==="head")&&" ",i.name]},I))})})]},k.commit.hash)})]})},Ie=({commits:a=me,branches:f=me,tags:w=me,head:B,selectedCommit:_,branchFilter:W,authorFilter:L,dateRange:D,searchQuery:E,maxCommits:N=100,showRemotes:j=!0,showTags:P=!0,compact:z=!1,onCommitSelect:k,onCommitDoubleClick:S,onBranchCheckout:v,onBranchCreate:M,onTagCreate:C,onCherryPick:i,onRevert:I,onReset:O,onCompare:b,onViewDiff:Y,className:F,style:H,"data-testid":c})=>{const{t:l,lang:V}=n.useNiceTranslation(),[A,Z]=o.useState(_),[J,G]=o.useState(null),[U,te]=o.useState(!1),[g,p]=o.useState(null),h=o.useRef(null),T=_??A,d=o.useMemo(()=>{let m=a;if(W&&W.length>0){const Q=new Set;f.filter(y=>W.includes(y.name)).forEach(y=>{y.lastCommit&&Q.add(y.lastCommit)}),m=m.filter(y=>Q.has(y.hash))}if(L&&L.length>0&&(m=m.filter(Q=>L.some(y=>Q.author.name.toLowerCase().includes(y.toLowerCase())||Q.author.email.toLowerCase().includes(y.toLowerCase())))),D&&(D.from&&(m=m.filter(Q=>Q.date>=D.from)),D.to&&(m=m.filter(Q=>Q.date<=D.to))),E&&E.trim()){const Q=E.toLowerCase();m=m.filter(y=>y.hash.toLowerCase().includes(Q)||y.shortHash.toLowerCase().includes(Q)||y.message.toLowerCase().includes(Q)||y.author.name.toLowerCase().includes(Q))}return m.slice(0,N)},[a,W,L,D,E,N,f]),{nodes:$,edges:q}=o.useMemo(()=>Ye(d,j?f:f.filter(m=>!m.isRemote),P?w:[],B),[d,f,w,B,j,P]),s=o.useMemo(()=>d.find(m=>m.hash===T),[d,T]),t=o.useCallback(m=>{if(U&&g)b?.(g,m),te(!1),p(null);else if(U)p(m);else{Z(m);const Q=d.find(y=>y.hash===m);Q&&k?.(Q)}},[U,g,d,k,b]),x=o.useCallback(m=>{const Q=d.find(y=>y.hash===m);Q&&(S?.(Q),Y?.(m))},[d,S,Y]),u=o.useCallback((m,Q)=>{m.preventDefault(),G({x:m.clientX,y:m.clientY,commit:Q})},[]),R=o.useCallback(()=>G(null),[]),ee=m=>{const y=new Date().getTime()-m.getTime(),re=Math.floor(y/(1e3*60*60*24));return re===0?l("gitGraph.today","Today"):re===1?l("gitGraph.yesterday","Yesterday"):re<7?new Intl.RelativeTimeFormat(V).format(-re,"day"):m.toLocaleDateString(V)},X=z?Re:ze;return e.jsxs("div",{role:"presentation",className:`nice-git-graph ${F||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",...H},"data-testid":c,onClick:R,children:[e.jsxs("div",{ref:h,style:{flex:1,overflow:"auto",display:"flex"},children:[e.jsx("div",{style:{flexShrink:0,borderRight:"1px solid var(--nice-border-color, #333)"},children:e.jsx(Je,{nodes:$,edges:q,selectedHash:T,compact:z,onNodeClick:t,onNodeDoubleClick:x})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[$.map(m=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>t(m.commit.hash),onDoubleClick:()=>x(m.commit.hash),onContextMenu:Q=>u(Q,m.commit),style:{height:X,padding:"0 12px",display:"flex",alignItems:"center",gap:12,cursor:"pointer",background:m.commit.hash===T?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderBottom:"1px solid var(--nice-bg-secondary, #2a2a2a)"},children:[m.commit.author.avatar?e.jsx("img",{src:m.commit.author.avatar,alt:"",style:{width:z?20:24,height:z?20:24,borderRadius:"50%",flexShrink:0}}):e.jsx("div",{style:{width:z?20:24,height:z?20:24,borderRadius:"50%",background:m.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:z?10:12,color:"var(--nice-color-white, #fff)",fontWeight:600,flexShrink:0},children:m.commit.author.name.charAt(0).toUpperCase()}),e.jsx("div",{style:{flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:z?12:13},children:m.commit.message}),m.commit.stats&&!z&&e.jsxs("div",{style:{display:"flex",gap:8,fontSize:11,color:"var(--nice-text-muted, #888)",flexShrink:0},children:[e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",m.commit.stats.additions]}),e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",m.commit.stats.deletions]})]}),e.jsx("code",{style:{fontSize:z?10:11,color:"var(--nice-text-muted, #888)",fontFamily:"monospace",flexShrink:0},children:m.commit.shortHash}),!z&&e.jsx("span",{style:{fontSize:11,color:"var(--nice-text-muted, #888)",flexShrink:0,width:100},children:m.commit.author.name}),e.jsx("span",{style:{fontSize:z?10:11,color:"var(--nice-text-muted, #666)",flexShrink:0,width:z?60:80,textAlign:"right"},children:ee(m.commit.date)})]},m.commit.hash)),d.length===0&&e.jsx("div",{style:{padding:24,textAlign:"center",color:"var(--nice-text-muted, #666)",fontSize:13},children:l("gitGraph.noCommitsMatchTheFilters","No commits match the filters")})]})]}),s&&!z&&e.jsxs("div",{style:{width:320,borderLeft:"1px solid var(--nice-border-color, #333)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[s.author.avatar?e.jsx("img",{src:s.author.avatar,alt:"",style:{width:32,height:32,borderRadius:"50%"}}):e.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--nice-color-primary, #3b82f6)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-on-primary, #fff)",fontWeight:600},children:s.author.name.charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:s.author.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:s.author.email})]})]}),e.jsx("code",{style:{fontSize:11,color:"var(--nice-text-muted, #888)",fontFamily:"monospace"},children:s.hash})]}),e.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:s.message}),s.body&&e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #aaa)",whiteSpace:"pre-wrap",maxHeight:120,overflow:"auto"},children:s.body})]}),s.stats&&e.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:20,fontWeight:600},children:s.stats.filesChanged}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:l("gitGraph.filesChanged","files changed")})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:20,fontWeight:600,color:"var(--nice-color-success, #22c55e)"},children:["+",s.stats.additions]}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:l("gitGraph.additions","additions")})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:20,fontWeight:600,color:"var(--nice-color-error, #ef4444)"},children:["-",s.stats.deletions]}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:l("gitGraph.deletions","deletions")})]})]}),e.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:8},children:[e.jsx("button",{onClick:()=>Y?.(s.hash),style:{padding:"8px 12px",borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500},children:l("gitGraph.viewChanges","View Changes")}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>i?.(s.hash),style:{flex:1,padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.cherryPick","Cherry Pick")}),e.jsx("button",{onClick:()=>I?.(s.hash),style:{flex:1,padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.revert","Revert")})]}),e.jsx("button",{onClick:()=>M?.(s.hash),style:{padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.createBranchHere","Create Branch Here")}),e.jsx("button",{onClick:()=>C?.(s.hash),style:{padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.createTagHere","Create Tag Here")}),e.jsx("button",{onClick:()=>{te(!0),p(s.hash)},style:{padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.compareWith","Compare with...")})]})]}),U&&e.jsxs("div",{style:{position:"absolute",top:8,left:"50%",transform:"translateX(-50%)",padding:"8px 16px",background:"var(--nice-color-primary, #3b82f6)",borderRadius:4,fontSize:12,fontWeight:500},children:[g?l("gitGraph.selectCommitToCompareWith","Select commit to compare with {compareBase}").replace("{compareBase}",String(g.slice(0,7))):l("gitGraph.selectFirstCommit","Select first commit"),e.jsx("button",{onClick:()=>{te(!1),p(null)},style:{marginLeft:12,padding:"2px 8px",background:"var(--nice-overlay-light-20, rgba(255, 255, 255, 0.2))",border:"none",borderRadius:4,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.cancel","Cancel")})]}),J&&e.jsx("div",{style:{position:"fixed",left:J.x,top:J.y,background:"var(--nice-bg-elevated, #252525)",border:"1px solid var(--nice-border-color, #444)",borderRadius:6,boxShadow:"0 4px 12px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))",minWidth:160,zIndex:1e3},children:[{label:l("gitGraph.viewChanges","View Changes"),onClick:()=>Y?.(J.commit.hash)},{label:l("gitGraph.cherryPick","Cherry Pick"),onClick:()=>i?.(J.commit.hash)},{label:l("gitGraph.revert","Revert"),onClick:()=>I?.(J.commit.hash)},{divider:!0},{label:l("gitGraph.createBranch","Create Branch"),onClick:()=>M?.(J.commit.hash)},{label:l("gitGraph.createTag","Create Tag"),onClick:()=>C?.(J.commit.hash)},{divider:!0},{label:l("gitGraph.resetSoft","Reset Soft"),onClick:()=>O?.(J.commit.hash,"soft")},{label:l("gitGraph.resetMixed","Reset Mixed"),onClick:()=>O?.(J.commit.hash,"mixed")},{label:l("gitGraph.resetHard","Reset Hard"),onClick:()=>O?.(J.commit.hash,"hard"),danger:!0}].map((m,Q)=>"divider"in m?e.jsx("div",{style:{height:1,background:"var(--nice-bg-tertiary, #444)",margin:"4px 0"}},Q):e.jsx("button",{onClick:()=>{m.onClick?.(),R()},style:{display:"block",width:"100%",padding:"8px 12px",border:"none",background:"transparent",color:"danger"in m&&m.danger?"var(--nice-color-error, #ef4444)":"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},onMouseOver:y=>{y.currentTarget.style.background="var(--nice-bg-tertiary, #333)"},onMouseOut:y=>{y.currentTarget.style.background="transparent"},children:m.label},Q))})]})},Xe=Object.freeze(Object.defineProperty({__proto__:null,NiceGitGraph:Ie},Symbol.toStringTag,{value:"Module"})),ye=({open:a,onSubmit:f,onCancel:w,title:B,message:_,defaultValue:W="",placeholder:L,inputType:D="text",confirmLabel:E,cancelLabel:N,className:j="",style:P,testId:z,"data-testid":k})=>{const{t:S}=n.useNiceTranslation(),[v,M]=o.useState(W),C=o.useRef(null),i=o.useRef(null);return o.useEffect(()=>{a&&M(W)},[a,W]),n.useOverlayFocus(i,{open:a,onClose:w,initialFocus:C,closeHint:typeof N=="string"?N:void 0}),a?e.jsx("div",{className:`nice-prompt-dialog ${j}`,style:P,role:"presentation",onClick:I=>{I.target===I.currentTarget&&w()},onKeyDown:I=>{I.key!=="Escape"&&I.stopPropagation()},children:e.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":"nice-prompt-title",className:"nice-prompt-dialog__panel","data-testid":k??z,children:[e.jsx("h2",{id:"nice-prompt-title",className:"nice-prompt-dialog__title",children:B}),_&&e.jsx("p",{className:"nice-prompt-dialog__message",children:_}),e.jsx("input",{ref:C,type:D,value:v,placeholder:L,className:"nice-prompt-dialog__input",onChange:I=>M(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),f(v))}}),e.jsxs("div",{className:"nice-prompt-dialog__actions",children:[e.jsx("button",{type:"button",className:"nice-prompt-dialog__btn nice-prompt-dialog__btn--cancel",onClick:w,children:N??S("cancel","Cancel")}),e.jsx("button",{type:"button",className:"nice-prompt-dialog__btn nice-prompt-dialog__btn--confirm",onClick:()=>f(v),children:E??S("ok","OK")})]})]})}):null};process.env.NODE_ENV!=="production"&&(ye.displayName="NicePromptDialog");function Ne(){const[a,f]=o.useState(null),w=o.useRef(null),B=o.useCallback(N=>{const j=w.current;j&&(j.kind==="prompt"?j.resolve(null):j.resolve(!1)),w.current=N,f(N)},[]),_=o.useCallback(()=>{w.current=null,f(null)},[]),W=o.useCallback(N=>new Promise(j=>B({kind:"prompt",request:N,resolve:j})),[B]),L=o.useCallback(N=>new Promise(j=>B({kind:"confirm",request:N,resolve:j})),[B]),D=o.useCallback(N=>new Promise(j=>B({kind:"alert",request:N,resolve:()=>j()})),[B]);let E=null;if(a?.kind==="prompt"){const{resolve:N,request:j}=a;E=e.jsx(ye,{open:!0,...j,onSubmit:P=>{_(),N(P)},onCancel:()=>{_(),N(null)}})}else if(a){const{resolve:N,request:j,kind:P}=a;E=e.jsx(Ce,{visible:!0,...j,variant:j.variant??(P==="alert"?"info":"warning"),showReject:P!=="alert",onAccept:()=>{_(),N(!0)},onReject:()=>{_(),N(!1)}})}return{prompt:W,confirm:L,alert:D,element:E}}const Ze=[],Be=({branches:a=Ze,currentBranch:f,defaultBranch:w="main",protectionRules:B=[],showRemotes:_=!0,selectedBranch:W,onBranchSelect:L,onCheckout:D,onCreateBranch:E,onDeleteBranch:N,onRenameBranch:j,onMerge:P,onRebase:z,onSetUpstream:k,onPush:S,onPull:v,onCompare:M,onProtectionChange:C,className:i,style:I,"data-testid":O})=>{const{t:b,lang:Y}=n.useNiceTranslation(),F=Ne(),[H,c]=o.useState(""),[l,V]=o.useState("all"),[A,Z]=o.useState(),[J,G]=o.useState(!1),[U,te]=o.useState(!1),[g,p]=o.useState(!1),[h,T]=o.useState(""),[d,$]=o.useState(f||w),[q,s]=o.useState(""),[t,x]=o.useState(f||w),[u,R]=o.useState(null),ee=W??A,X=o.useMemo(()=>{let r=a;if(l==="local"?r=r.filter(K=>!K.isRemote):l==="remote"?r=r.filter(K=>K.isRemote):_||(r=r.filter(K=>!K.isRemote)),H.trim()){const K=H.toLowerCase();r=r.filter(oe=>oe.name.toLowerCase().includes(K))}return r.sort((K,oe)=>K.isHead?-1:oe.isHead?1:K.name===w?-1:oe.name===w?1:K.isRemote!==oe.isRemote?K.isRemote?1:-1:K.name.localeCompare(oe.name))},[a,l,_,H,w]),m=o.useMemo(()=>{const r=X.filter(oe=>!oe.isRemote),K=X.filter(oe=>oe.isRemote);return{local:r,remote:K}},[X]),Q=o.useCallback(r=>{Z(r),L?.(r)},[L]),y=o.useCallback((r,K)=>{r.preventDefault(),R({x:r.clientX,y:r.clientY,branch:K})},[]),re=o.useCallback(()=>R(null),[]),ie=o.useCallback(()=>{h.trim()&&(E?.(h.trim(),d),T(""),G(!1))},[h,d,E]),de=o.useCallback(()=>{q&&t&&q!==t&&(P?.(q,t),te(!1))},[q,t,P]),ue=r=>{if(!r)return"-";const oe=new Date().getTime()-r.getTime(),ae=Math.floor(oe/(1e3*60*60*24));if(ae===0)return b("branchManager.today","Today");if(ae===1)return b("branchManager.yesterday","Yesterday");const ge=new Intl.RelativeTimeFormat(Y);return ae<7?ge.format(-ae,"day"):ae<30?ge.format(-Math.floor(ae/7),"week"):r.toLocaleDateString(Y)},ne=o.useMemo(()=>a.find(r=>r.name===ee),[a,ee]),pe=o.useCallback(r=>B.some(K=>new RegExp(K.pattern.replace(/\*/g,".*")).test(r)),[B]),le=m.local,se=r=>{const K=r.name===ee,oe=r.isHead,ae=r.name===w,ge=pe(r.name);return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>Q(r.name),onDoubleClick:()=>D?.(r.name),onContextMenu:We=>y(We,r),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",cursor:"pointer",background:K?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":oe?"color-mix(in srgb, var(--nice-color-success, #22c55e) 8%, transparent)":"transparent",borderLeft:oe?"3px solid var(--nice-success, #22c55e)":"3px solid transparent"},children:[e.jsx(n.NiceIcon,{name:r.isRemote?"cloud":oe?"map-pin":"box",size:16}),e.jsx("span",{style:{flex:1,fontSize:13,fontWeight:oe?600:400,color:oe?"var(--nice-color-success, #22c55e)":"var(--nice-text-primary, #e0e0e0)"},children:r.name}),e.jsxs("div",{style:{display:"flex",gap:4},children:[ae&&e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,fontSize:10,background:"var(--nice-primary-tint-15, #3b82f622)",color:"var(--nice-color-primary, #3b82f6)",border:"1px solid color-mix(in srgb, var(--nice-color-primary, #3b82f6) 27%, transparent)"},children:b("branchManager.default","default")}),ge&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",borderRadius:4,fontSize:10,background:"var(--nice-warning-tint-15, #f59e0b22)",color:"var(--nice-color-warning, #f59e0b)",border:"1px solid color-mix(in srgb, var(--nice-color-warning, #f59e0b) 27%, transparent)"},children:[e.jsx(n.NiceIcon,{name:"lock",size:10})," ",b("branchManager.protected","protected")]})]}),r.upstream&&(r.ahead||r.behind)&&e.jsxs("div",{style:{display:"flex",gap:4,fontSize:10,color:"var(--nice-text-muted, #888)"},children:[r.ahead?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--nice-color-success, #22c55e)"},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:10}),r.ahead]}):null,r.behind?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--nice-color-error, #ef4444)"},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:10}),r.behind]}):null]}),r.lastCommit&&e.jsx("span",{style:{fontSize:10,color:"var(--nice-text-muted, #666)",width:80,textAlign:"right"},children:ue(r.lastCommit.date)})]},r.name)};return e.jsxs("div",{role:"presentation",className:`nice-branch-manager ${i||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",...I},"data-testid":O,onClick:re,children:[F.element,e.jsxs("div",{style:{width:350,display:"flex",flexDirection:"column",borderRight:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{padding:12,borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(n.NiceIcon,{name:"box",size:18}),e.jsx("span",{style:{fontWeight:600,fontSize:14},children:b("branchManager.branches","Branches")}),e.jsx("span",{style:{marginLeft:"auto",padding:"2px 8px",background:"var(--nice-bg-tertiary, #333)",borderRadius:10,fontSize:11},children:b("branchManager.local","{branches} local").replace("{branches}",String(a.filter(r=>!r.isRemote).length))})]}),e.jsx("input",{type:"text",placeholder:b("branchManager.searchBranches","Search branches..."),value:H,onChange:r=>c(r.target.value),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",fontSize:12,marginBottom:8}}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","local","remote"].map(r=>e.jsx("button",{onClick:()=>V(r),style:{flex:1,padding:"6px 0",borderRadius:4,border:"none",background:l===r?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:l===r?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:r},r))})]}),e.jsxs("div",{style:{padding:8,borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",gap:8},children:[e.jsxs("button",{onClick:()=>G(!0),style:{flex:1,padding:"8px 12px",borderRadius:4,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"plus",size:14})," ",b("branchManager.newBranch","New Branch")]}),e.jsxs("button",{onClick:()=>te(!0),style:{flex:1,padding:"8px 12px",borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:14})," ",b("branchManager.merge","Merge")]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[m.local.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",fontSize:10,fontWeight:600,color:"var(--nice-text-muted, #888)",textTransform:"uppercase",background:"var(--nice-bg-elevated, #252525)"},children:b("branchManager.local2","Local ({local})").replace("{local}",String(m.local.length))}),m.local.map(se)]}),_&&m.remote.length>0&&l!=="local"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",fontSize:10,fontWeight:600,color:"var(--nice-text-muted, #888)",textTransform:"uppercase",background:"var(--nice-bg-elevated, #252525)",marginTop:8},children:b("branchManager.remote","Remote ({remote})").replace("{remote}",String(m.remote.length))}),m.remote.map(se)]}),X.length===0&&e.jsx("div",{style:{padding:24,textAlign:"center",color:"var(--nice-text-muted, #666)",fontSize:12},children:b("branchManager.noBranchesMatchTheFilter","No branches match the filter")})]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:ne?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:ne.isRemote?"cloud":ne.isHead?"map-pin":"box",size:24}),e.jsxs("div",{style:{flex:1},children:[e.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:600},children:ne.name}),ne.description&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--nice-text-muted, #888)"},children:ne.description})]}),ne.isHead&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 12px",borderRadius:4,background:"var(--nice-success-tint-15, #22c55e22)",color:"var(--nice-color-success, #22c55e)",fontSize:12,fontWeight:500},children:[e.jsx(n.NiceIcon,{name:"check",size:14})," ",b("branchManager.current","Current")]})]})}),e.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.upstream","Upstream")}),e.jsx("div",{style:{fontSize:13},children:ne.upstream||e.jsx("span",{style:{color:"var(--nice-text-muted, #666)"},children:b("branchManager.notSet","Not set")})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.syncStatus","Sync Status")}),e.jsx("div",{style:{display:"flex",gap:8,fontSize:13},children:ne.upstream?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--nice-color-success, #22c55e)"},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:13})," ",b("branchManager.ahead","{ahead} ahead").replace("{ahead}",String(ne.ahead||0))]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--nice-color-error, #ef4444)"},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:13})," ",b("branchManager.behind","{behind} behind").replace("{behind}",String(ne.behind||0))]})]}):e.jsx("span",{style:{color:"var(--nice-text-muted, #666)"},children:"-"})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.lastCommit","Last Commit")}),e.jsx("div",{style:{fontSize:13},children:ne.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{style:{fontSize:11,color:"var(--nice-text-muted, #aaa)"},children:ne.lastCommit.hash.slice(0,7)})," ",ue(ne.lastCommit.date)]}):e.jsx("span",{style:{color:"var(--nice-text-muted, #666)"},children:"-"})})]})]}),ne.lastCommit&&e.jsxs("div",{style:{marginTop:16,padding:12,background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:6,fontSize:12},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:4},children:ne.lastCommit.message}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:b("branchManager.by","by {author}").replace("{author}",String(ne.lastCommit.author))})]})]}),e.jsx("div",{style:{padding:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[!ne.isHead&&e.jsxs("button",{onClick:()=>D?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"map-pin",size:14})," ",b("branchManager.checkout","Checkout")]}),ne.upstream&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>v?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:14})," ",b("branchManager.pull","Pull")]}),e.jsxs("button",{onClick:()=>S?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-accent, #8b5cf6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:14})," ",b("branchManager.push","Push")]})]}),!ne.upstream&&!ne.isRemote&&e.jsx("button",{onClick:()=>k?.(ne.name,`origin/${ne.name}`),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:b("branchManager.setUpstream","Set Upstream")}),e.jsxs("button",{onClick:()=>{s(ne.name),x(f||w),te(!0)},style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:14})," ",b("branchManager.mergeInto","Merge into...")]}),e.jsxs("button",{onClick:()=>M?.(w,ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:14})," ",b("branchManager.compare","Compare")]}),!ne.isHead&&!ne.isRemote&&!pe(ne.name)&&e.jsxs("button",{onClick:()=>N?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-error, #ef4444)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"trash",size:14})," ",b("branchManager.delete","Delete")]})]})})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #666)",fontSize:13},children:b("branchManager.selectABranchToView","Select a branch to view details")})}),J&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>G(!1),children:e.jsxs("div",{role:"presentation",style:{width:400,background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:24},onClick:r=>r.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 16px",fontSize:16},children:b("branchManager.createNewBranch","Create New Branch")}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.branchName","Branch Name")}),e.jsx("input",{type:"text",placeholder:b("branchManager.featureMyFeature","feature/my-feature"),value:h,onChange:r=>T(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.basedOn","Based on")}),e.jsx("select",{value:d,onChange:r=>$(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:le.map(r=>e.jsxs("option",{value:r.name,children:[r.name," ",r.isHead?b("branchManager.current2","(current)"):""]},r.name))})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>G(!1),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:b("branchManager.cancel","Cancel")}),e.jsx("button",{onClick:ie,disabled:!h.trim(),style:{padding:"10px 20px",borderRadius:6,border:"none",background:h.trim()?"var(--nice-color-success, #22c55e)":"var(--nice-bg-tertiary, #333)",color:h.trim()?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:h.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:500},children:b("branchManager.createBranch","Create Branch")})]})]})}),U&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>te(!1),children:e.jsxs("div",{role:"presentation",style:{width:400,background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:24},onClick:r=>r.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 16px",fontSize:16},children:b("branchManager.mergeBranches","Merge Branches")}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.mergeFrom","Merge from")}),e.jsxs("select",{value:q,onChange:r=>s(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:[e.jsx("option",{value:"",children:b("branchManager.selectBranch","Select branch...")}),le.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 0",color:"var(--nice-text-muted, #888)"},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:14})," ",b("branchManager.into","into")," ",e.jsx(n.NiceIcon,{name:"arrow-down",size:14})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.mergeInto2","Merge into")}),e.jsx("select",{value:t,onChange:r=>x(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:le.map(r=>e.jsxs("option",{value:r.name,children:[r.name," ",r.isHead?b("branchManager.current2","(current)"):""]},r.name))})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>te(!1),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:b("branchManager.cancel","Cancel")}),e.jsx("button",{onClick:de,disabled:!q||!t||q===t,style:{padding:"10px 20px",borderRadius:6,border:"none",background:q&&t&&q!==t?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:q&&t&&q!==t?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:q&&t&&q!==t?"pointer":"not-allowed",fontSize:12,fontWeight:500},children:b("branchManager.merge","Merge")})]})]})}),u&&e.jsx("div",{style:{position:"fixed",left:u.x,top:u.y,background:"var(--nice-bg-elevated, #252525)",border:"1px solid var(--nice-border-color, #444)",borderRadius:6,boxShadow:"0 4px 12px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))",minWidth:160,zIndex:1e3},children:[!u.branch.isHead&&{label:b("branchManager.checkout","Checkout"),onClick:()=>D?.(u.branch.name)},{label:b("branchManager.compare","Compare"),onClick:()=>M?.(w,u.branch.name)},{label:b("branchManager.mergeIntoCurrent","Merge into current"),onClick:()=>P?.(u.branch.name,f||w)},{divider:!0},!u.branch.isRemote&&{label:b("branchManager.rename","Rename"),onClick:()=>{const r=u.branch.name;F.prompt({title:b("branchManager.renamePrompt","New branch name"),defaultValue:r}).then(K=>{K&&j?.(r,K)})}},!u.branch.isHead&&!u.branch.isRemote&&!pe(u.branch.name)&&{label:b("branchManager.delete","Delete"),onClick:()=>N?.(u.branch.name),danger:!0}].filter(Boolean).map((r,K)=>r?"divider"in r?e.jsx("div",{style:{height:1,background:"var(--nice-bg-tertiary, #444)",margin:"4px 0"}},K):e.jsx("button",{onClick:()=>{r.onClick?.(),re()},style:{display:"block",width:"100%",padding:"8px 12px",border:"none",background:"transparent",color:"danger"in r&&r.danger?"var(--nice-color-error, #ef4444)":"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},onMouseOver:oe=>oe.currentTarget.style.background="var(--nice-bg-tertiary, #333)",onMouseOut:oe=>oe.currentTarget.style.background="transparent",children:r.label},K):null)})]})},Qe=Object.freeze(Object.defineProperty({__proto__:null,NiceBranchManager:Be},Symbol.toStringTag,{value:"Module"})),et=[],tt=[{target:".nice-merge-request-builder",titleKey:"tutorial.mergeRequestBuilder.intro.title",title:"Merge request builder",contentKey:"tutorial.mergeRequestBuilder.intro.content",content:"Pick source and target branches, write the title and description, add reviewers, labels and linked issues, then preview and submit.",placement:"auto"}],Me=({branches:a=et,users:f=[],labels:w=[],issues:B=[],templates:_=[],diff:W,currentBranch:L,defaultTargetBranch:D="main",initialSourceBranch:E,platform:N="github",onSubmit:j,onCancel:P,onBranchChange:z,onPreview:k,tutorial:S,className:v,style:M,"data-testid":C})=>{const{t:i}=n.useNiceTranslation(),[I,O]=o.useState(""),[b,Y]=o.useState(""),[F,H]=o.useState(E||L||""),[c,l]=o.useState(D),[V,A]=o.useState(!1),[Z,J]=o.useState([]),[G,U]=o.useState([]),[te,g]=o.useState([]),[p,h]=o.useState([]),[T,d]=o.useState(!1),[$,q]=o.useState(!0),[s,t]=o.useState(!1),[x,u]=o.useState(!1),[R,ee]=o.useState(!1),[X,m]=o.useState(!1),Q=o.useMemo(()=>F?F.replace(/^(feature|bugfix|hotfix|release)\//,"").replace(/[-_]/g," ").replace(/\b\w/g,K=>K.toUpperCase()):"",[F]),y=o.useMemo(()=>a.filter(r=>!r.isRemote),[a]),re=o.useCallback((r,K)=>{H(r),l(K),z?.(r,K)},[z]),ie=o.useCallback(()=>{if(!F||!c||!I.trim())return;const r={title:I.trim(),description:b.trim(),sourceBranch:F,targetBranch:c,isDraft:V,labels:Z,reviewers:G,assignees:te,linkedIssues:p,squashCommits:T,deleteSourceBranch:$};j?.(r)},[I,b,F,c,V,Z,G,te,p,T,$,j]),de=r=>{Y(r.content),m(!1)},ue=r=>{J(K=>K.includes(r)?K.filter(oe=>oe!==r):[...K,r])},ne=r=>{U(K=>K.includes(r)?K.filter(oe=>oe!==r):[...K,r])},pe=r=>{h(K=>K.includes(r)?K.filter(oe=>oe!==r):[...K,r])},le={github:{title:i("mergeRequestBuilder.pullRequest","Pull Request"),btn:"Create Pull Request"},gitlab:{title:i("mergeRequestBuilder.mergeRequest","Merge Request"),btn:"Create Merge Request"},bitbucket:{title:i("mergeRequestBuilder.pullRequest","Pull Request"),btn:"Create Pull Request"},azure:{title:i("mergeRequestBuilder.pullRequest","Pull Request"),btn:"Create Pull Request"}},se=F&&c&&F!==c&&I.trim();return e.jsxs("div",{className:`nice-merge-request-builder ${v||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",position:"relative",...M},"data-testid":C,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(n.NiceTutorialButton,{steps:n.resolveTutorial(S,tt)})}),e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:24}),e.jsxs("div",{children:[e.jsxs("h2",{style:{margin:0,fontSize:18,fontWeight:600},children:[V?`${i("mergeRequestBuilder.draft","Draft")} `:"",le[N].title]}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--nice-text-muted, #888)"},children:N==="gitlab"?i("mergeRequestBuilder.createMergeRequest","Create a new merge request"):i("mergeRequestBuilder.createPullRequest","Create a new pull request")})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[e.jsxs("div",{style:{background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:16,marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,justifyContent:"center"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:"var(--nice-text-muted, #888)",marginBottom:4},children:i("mergeRequestBuilder.from","From")}),e.jsxs("select",{value:F,onChange:r=>re(r.target.value,c),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:[e.jsx("option",{value:"",children:i("mergeRequestBuilder.selectSourceBranch","Select source branch...")}),y.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))]})]}),e.jsx("div",{style:{padding:"20px 0 0"},children:e.jsx("span",{style:{fontSize:20,color:"var(--nice-text-muted, #888)"},children:e.jsx(n.NiceIcon,{name:"arrow-right",size:20})})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:"var(--nice-text-muted, #888)",marginBottom:4},children:i("mergeRequestBuilder.into","Into")}),e.jsx("select",{value:c,onChange:r=>re(F,r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:y.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))})]})]}),W&&e.jsxs("div",{style:{marginTop:12,padding:"8px 12px",background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:6,display:"flex",gap:16,fontSize:12},children:[e.jsx("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:i("mergeRequestBuilder.additions","+{additions} additions").replace("{additions}",String(W.additions))}),e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:i("mergeRequestBuilder.deletions","-{deletions} deletions").replace("{deletions}",String(W.deletions))}),e.jsx("span",{style:{color:"var(--nice-text-muted, #888)"},children:i("mergeRequestBuilder.filesChanged","{changedFiles} files changed").replace("{changedFiles}",String(W.changedFiles))})]}),F===c&&F&&e.jsx("div",{style:{marginTop:12,padding:"8px 12px",background:"var(--nice-danger-tint-15, #ef444422)",color:"var(--nice-color-error, #ef4444)",borderRadius:6,fontSize:12},children:i("mergeRequestBuilder.sourceAndTargetBranchesCannot","Source and target branches cannot be the same")})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:6},children:i("mergeRequestBuilder.title","Title")}),e.jsx("input",{type:"text",value:I,onChange:r=>O(r.target.value),placeholder:Q||i("mergeRequestBuilder.enterATitle","Enter a title..."),style:{width:"100%",padding:"12px 16px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",fontSize:14}}),!I&&Q&&e.jsx("button",{onClick:()=>O(Q),style:{marginTop:4,padding:0,background:"none",border:"none",color:"var(--nice-color-primary, #3b82f6)",fontSize:11,cursor:"pointer"},children:i("mergeRequestBuilder.useSuggested",'Use suggested: "{suggestedTitle}"').replace("{suggestedTitle}",String(Q))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:[e.jsx("label",{style:{fontSize:12,color:"var(--nice-text-muted, #888)"},children:i("mergeRequestBuilder.description","Description")}),_.length>0&&e.jsxs("button",{onClick:()=>m(!X),style:{padding:"4px 8px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-muted, #888)",fontSize:11,cursor:"pointer"},children:[e.jsx(n.NiceIcon,{name:"edit",size:14})," ",i("mergeRequestBuilder.templates","Templates")]})]}),e.jsx("textarea",{value:b,onChange:r=>Y(r.target.value),placeholder:i("mergeRequestBuilder.describeYourChanges","Describe your changes..."),rows:8,style:{width:"100%",padding:"12px 16px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",fontSize:13,resize:"vertical",fontFamily:"inherit"}})]}),X&&_.length>0&&e.jsxs("div",{style:{marginBottom:16,padding:12,background:"var(--nice-bg-elevated, #252525)",borderRadius:6,border:"1px solid var(--nice-border-color, #444)"},children:[e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:8},children:i("mergeRequestBuilder.selectTemplate","Select Template")}),_.map(r=>e.jsxs("button",{onClick:()=>de(r),style:{display:"block",width:"100%",padding:"8px 12px",marginBottom:4,borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:[e.jsx("div",{style:{fontWeight:500},children:r.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:r.description})]},r.id))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16,marginBottom:20},children:[e.jsxs("div",{children:[e.jsx("button",{onClick:()=>t(!s),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"tag",size:14})," ",i("mergeRequestBuilder.labels","Labels")]}),Z.length>0&&e.jsxs("span",{style:{color:"var(--nice-color-primary, #3b82f6)"},children:["(",Z.length,")"]})]})}),s&&e.jsx("div",{style:{marginTop:8,padding:8,background:"var(--nice-bg-tertiary, #333)",borderRadius:6,maxHeight:200,overflow:"auto"},children:w.map(r=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:Z.includes(r.id),onChange:()=>ue(r.id)}),e.jsx("span",{style:{width:12,height:12,borderRadius:"50%",background:r.color}}),e.jsx("span",{style:{fontSize:12},children:r.name})]},r.id))})]}),e.jsxs("div",{children:[e.jsx("button",{onClick:()=>u(!x),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"users",size:14})," ",i("mergeRequestBuilder.reviewers","Reviewers")]}),G.length>0&&e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["(",G.length,")"]})]})}),x&&e.jsx("div",{style:{marginTop:8,padding:8,background:"var(--nice-bg-tertiary, #333)",borderRadius:6,maxHeight:200,overflow:"auto"},children:f.map(r=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:G.includes(r.id),onChange:()=>ne(r.id)}),r.avatar?e.jsx("img",{src:r.avatar,alt:"",style:{width:20,height:20,borderRadius:"50%"}}):e.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"var(--nice-bg-tertiary, #666)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10},children:r.name[0]}),e.jsx("span",{style:{fontSize:12},children:r.name})]},r.id))})]}),e.jsxs("div",{children:[e.jsx("button",{onClick:()=>ee(!R),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"link",size:14})," ",i("mergeRequestBuilder.linkedIssues","Linked Issues")]}),p.length>0&&e.jsxs("span",{style:{color:"var(--nice-color-accent, #8b5cf6)"},children:["(",p.length,")"]})]})}),R&&e.jsx("div",{style:{marginTop:8,padding:8,background:"var(--nice-bg-tertiary, #333)",borderRadius:6,maxHeight:200,overflow:"auto"},children:B.filter(r=>r.state==="open").map(r=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p.includes(r.id),onChange:()=>pe(r.id)}),e.jsxs("span",{style:{fontSize:12,color:"var(--nice-text-muted, #888)"},children:["#",r.number]}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title})]},r.id))})]}),e.jsx("div",{children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",cursor:"pointer",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:V,onChange:r=>A(r.target.checked)}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"edit",size:14})," ",i("mergeRequestBuilder.createAsDraft","Create as Draft")]})]})})]}),e.jsxs("div",{style:{background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:16,marginBottom:20},children:[e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:12},children:i("mergeRequestBuilder.mergeOptions","Merge Options")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:T,onChange:r=>d(r.target.checked)}),i("mergeRequestBuilder.squashCommitsOnMerge","Squash commits on merge")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:$,onChange:r=>q(r.target.checked)}),i("mergeRequestBuilder.deleteSourceBranchAfterMerge","Delete source branch after merge")]})]})]}),W&&W.files.length>0&&e.jsxs("div",{style:{background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:16},children:[e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:12},children:i("mergeRequestBuilder.changedFiles","Changed Files ({changedFiles})").replace("{changedFiles}",String(W.changedFiles))}),e.jsx("div",{style:{maxHeight:200,overflow:"auto"},children:W.files.map(r=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,fontSize:12},children:[e.jsx("span",{style:{width:12,height:12,borderRadius:2,background:r.status==="added"?"var(--nice-color-success, #22c55e)":r.status==="deleted"?"var(--nice-color-error, #ef4444)":r.status==="renamed"?"var(--nice-color-primary, #3b82f6)":"var(--nice-color-warning, #f59e0b)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,color:"var(--nice-color-white, #fff)"},children:r.status==="added"?"+":r.status==="deleted"?"-":r.status==="renamed"?"R":"M"}),e.jsx("span",{style:{flex:1,fontFamily:"monospace",fontSize:11},children:r.path}),e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)",fontSize:11},children:["+",r.additions]}),e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)",fontSize:11},children:["-",r.deletions]})]},r.path))})]})]}),e.jsxs("div",{style:{padding:"16px 20px",borderTop:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:12},children:[e.jsx("button",{onClick:P,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:13},children:i("mergeRequestBuilder.cancel","Cancel")}),e.jsx("button",{onClick:()=>k?.({title:I,description:b,sourceBranch:F,targetBranch:c,isDraft:V,labels:Z,reviewers:G,assignees:te,linkedIssues:p,squashCommits:T,deleteSourceBranch:$}),disabled:!se,style:{padding:"10px 20px",borderRadius:6,border:"none",background:se?"var(--nice-bg-tertiary, #333)":"var(--nice-bg-elevated, #222)",color:se?"var(--nice-text-primary, #fff)":"var(--nice-text-muted, #666)",cursor:se?"pointer":"not-allowed",fontSize:13},children:i("mergeRequestBuilder.preview","Preview")}),e.jsx("button",{onClick:ie,disabled:!se,style:{padding:"10px 24px",borderRadius:6,border:"none",background:se?"var(--nice-color-success, #22c55e)":"var(--nice-bg-elevated, #222)",color:se?"var(--nice-color-white, #fff)":"var(--nice-text-muted, #666)",cursor:se?"pointer":"not-allowed",fontSize:13,fontWeight:500},children:V?i("mergeRequestBuilder.createDraft","Create Draft"):le[N].btn})]})]})},nt=Object.freeze(Object.defineProperty({__proto__:null,NiceMergeRequestBuilder:Me},Symbol.toStringTag,{value:"Module"})),rt=[],Ee=({files:a=rt,viewMode:f,showWhitespace:w,comments:B=[],selectedFile:_,showFileTree:W=!0,contextLines:L=3,baseRef:D,headRef:E,onFileSelect:N,onViewModeChange:j,onAddComment:P,onResolveComment:z,onExpandChunk:k,className:S,style:v,"data-testid":M})=>{const{t:C}=n.useNiceTranslation(),[i,I]=o.useState("split"),[O,b]=o.useState(!1),[Y,F]=o.useState(void 0),[H,c]=o.useState(new Set),[l,V]=o.useState(null),A=f??i,Z=w??O,J=_??Y??a[0]?.path,G=o.useMemo(()=>a.find(s=>s.path===J),[a,J]),U=o.useMemo(()=>({additions:a.reduce((s,t)=>s+t.additions,0),deletions:a.reduce((s,t)=>s+t.deletions,0)}),[a]),te=o.useCallback(s=>{F(s),N?.(s)},[N]),g=o.useCallback(s=>{I(s),j?.(s)},[j]),p=o.useCallback((s,t)=>{const x=`${s}:${t}`;c(u=>{const R=new Set(u);return R.has(x)?R.delete(x):R.add(x),R}),k?.(s,t)},[k]),h=o.useMemo(()=>B.filter(s=>s.filePath===J),[B,J]),T=s=>{switch(s){case"added":return{icon:"+",color:"var(--nice-color-success, #22c55e)"};case"deleted":return{icon:"-",color:"var(--nice-color-error, #ef4444)"};case"modified":return{icon:"M",color:"var(--nice-color-warning, #f59e0b)"};case"renamed":return{icon:"R",color:"var(--nice-color-primary, #3b82f6)"};case"copied":return{icon:"C",color:"var(--nice-color-accent, #8b5cf6)"}}},d=(s,t,x)=>{const u=s.type==="addition"?"var(--nice-success-tint-10, rgba(34, 197, 94, 0.1))":s.type==="deletion"?"var(--nice-danger-tint-10, rgba(239, 68, 68, 0.1))":s.type==="header"?"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))":"transparent",R=s.type==="addition"?"var(--nice-success-text, #4ade80)":s.type==="deletion"?"var(--nice-danger-text, #f87171)":s.type==="header"?"var(--nice-info-text, #60a5fa)":"var(--nice-text-primary, #e0e0e0)",ee=x==="old"?s.lineNumberOld:x==="new"?s.lineNumberNew:void 0,X=Z?s.content.replace(/ /g,"·").replace(/\t/g,"→ "):s.content;return e.jsxs("div",{style:{display:"flex",alignItems:"stretch",background:u,minHeight:20,fontSize:12,fontFamily:'"JetBrains Mono", "Fira Code", monospace'},children:[ee!==void 0&&e.jsx("div",{style:{minWidth:50,padding:"0 8px",textAlign:"right",color:"var(--nice-text-muted, #666)",background:"var(--nice-overlay-20, rgba(0, 0, 0, 0.2))",userSelect:"none",borderRight:"1px solid var(--nice-border-color, #333)"},children:ee}),A==="unified"&&e.jsx("div",{style:{width:20,textAlign:"center",color:R,fontWeight:600},children:s.type==="addition"?"+":s.type==="deletion"?"-":" "}),e.jsx("div",{style:{flex:1,padding:"0 8px",color:R,whiteSpace:"pre",overflow:"hidden",textOverflow:"ellipsis"},children:X||" "}),P&&ee&&s.type!=="header"&&e.jsx("button",{type:"button",onClick:()=>V({filePath:J,line:ee,side:x||"new",body:""}),style:{width:24,border:"none",background:"transparent",color:"var(--nice-color-primary, #3b82f6)",cursor:"pointer",opacity:.3,transition:"opacity 0.2s"},onMouseEnter:m=>m.currentTarget.style.opacity="1",onMouseLeave:m=>m.currentTarget.style.opacity="0.3",onFocus:m=>m.currentTarget.style.opacity="1",onBlur:m=>m.currentTarget.style.opacity="0.3","aria-label":C("gitDiffViewer.addComment","Add comment"),children:e.jsx(n.NiceIcon,{name:"message",size:14})})]},`${t}-${x||"unified"}`)},$=s=>e.jsx("div",{style:{borderTop:"1px solid var(--nice-border-color, #333)"},children:s.chunks.map((t,x)=>{const u=`${s.path}:${x}`;return H.has(u),e.jsxs("div",{children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>p(s.path,x),style:{padding:"6px 12px",background:"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))",borderBottom:"1px solid var(--nice-border-color, #333)",fontSize:11,color:"var(--nice-color-primary-light, #60a5fa)",cursor:"pointer",fontFamily:"monospace"},children:["@@ -",t.oldStart,",",t.oldLines," +",t.newStart,",",t.newLines," @@"," ",t.header||""]}),t.lines.map((R,ee)=>d(R,ee))]},x)})}),q=s=>e.jsx("div",{style:{borderTop:"1px solid var(--nice-border-color, #333)"},children:s.chunks.map((t,x)=>{const u=[],R=[];for(const X of t.lines)(X.type==="deletion"||X.type==="context")&&u.push(X),(X.type==="addition"||X.type==="context")&&R.push(X);const ee=Math.max(u.length,R.length);for(;u.length<ee;)u.push({content:"",type:"context"});for(;R.length<ee;)R.push({content:"",type:"context"});return e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"6px 12px",background:"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))",borderBottom:"1px solid var(--nice-border-color, #333)",fontSize:11,color:"var(--nice-color-primary-light, #60a5fa)",fontFamily:"monospace"},children:["@@ -",t.oldStart,",",t.oldLines," +",t.newStart,",",t.newLines," @@"," ",t.header||""]}),e.jsxs("div",{style:{display:"flex"},children:[e.jsx("div",{style:{flex:1,borderRight:"1px solid var(--nice-border-color, #444)"},children:u.map((X,m)=>d(X,m,"old"))}),e.jsx("div",{style:{flex:1},children:R.map((X,m)=>d(X,m,"new"))})]})]},x)})});return e.jsxs("div",{className:`nice-git-diff-viewer ${S||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",...v},"data-testid":M,children:[W&&e.jsxs("div",{style:{width:280,borderRight:"1px solid var(--nice-border-color, #333)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:12,borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(n.NiceIcon,{name:"folder",size:16}),e.jsx("span",{style:{fontWeight:600,fontSize:13},children:C("gitDiffViewer.changedFiles","Changed Files")}),e.jsx("span",{style:{marginLeft:"auto",padding:"2px 8px",background:"var(--nice-bg-tertiary, #333)",borderRadius:10,fontSize:11},children:a.length})]}),(D||E)&&e.jsxs("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:[D&&e.jsx("span",{children:D}),D&&E&&e.jsx("span",{style:{margin:"0 4px"},children:e.jsx(n.NiceIcon,{name:"arrow-right",size:12})}),E&&e.jsx("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:E})]})]}),e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",gap:12,fontSize:12},children:[e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",U.additions]}),e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",U.deletions]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:a.map(s=>{const t=T(s.status),x=s.path===J;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>te(s.path),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",cursor:"pointer",background:x?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderLeft:x?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent"},children:[e.jsx("span",{style:{width:16,height:16,borderRadius:2,background:t.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,color:"var(--nice-color-white, #fff)",fontWeight:600},children:t.icon}),e.jsx("span",{style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.path.split("/").pop()}),e.jsxs("div",{style:{display:"flex",gap:4,fontSize:10},children:[s.additions>0&&e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",s.additions]}),s.deletions>0&&e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",s.deletions]})]})]},s.path)})})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",display:"flex",alignItems:"center",gap:16},children:[G&&e.jsx("div",{style:{flex:1,fontSize:13,fontFamily:"monospace"},children:G.oldPath&&G.oldPath!==G.path?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:G.oldPath}),e.jsx("span",{style:{margin:"0 8px",color:"var(--nice-text-muted, #888)"},children:e.jsx(n.NiceIcon,{name:"arrow-right",size:12})}),e.jsx("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:G.path})]}):G.path}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{onClick:()=>g("unified"),style:{padding:"6px 12px",borderRadius:4,border:"none",background:A==="unified"?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:A==="unified"?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:C("gitDiffViewer.unified","Unified")}),e.jsx("button",{onClick:()=>g("split"),style:{padding:"6px 12px",borderRadius:4,border:"none",background:A==="split"?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:A==="split"?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:C("gitDiffViewer.split","Split")})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--nice-text-muted, #888)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:Z,onChange:s=>b(s.target.checked)}),C("gitDiffViewer.showWhitespace","Show whitespace")]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:G?G.binary?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"var(--nice-text-muted, #888)"},children:[e.jsx(n.NiceIcon,{name:"box",size:48}),e.jsx("p",{children:C("gitDiffViewer.binaryFileCannotBeDisplayed","Binary file cannot be displayed")})]}):A==="split"?q(G):$(G):e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--nice-text-muted, #666)"},children:C("gitDiffViewer.selectAFileToView","Select a file to view changes")})}),h.length>0&&e.jsxs("div",{style:{borderTop:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",maxHeight:200,overflow:"auto"},children:[e.jsx("div",{style:{padding:"8px 16px",fontSize:12,fontWeight:600,borderBottom:"1px solid var(--nice-border-color, #333)"},children:C("gitDiffViewer.comments","Comments ({fileComments})").replace("{fileComments}",String(h.length))}),h.map(s=>e.jsxs("div",{style:{padding:12,borderBottom:"1px solid var(--nice-border-color, #333)",opacity:s.resolved?.5:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[s.author.avatar?e.jsx("img",{src:s.author.avatar,alt:"",style:{width:20,height:20,borderRadius:"50%"}}):e.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"var(--nice-bg-tertiary, #666)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10},children:s.author.name[0]}),e.jsx("span",{style:{fontSize:12,fontWeight:500},children:s.author.name}),e.jsx("span",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:(s.side==="old"?C("gitDiffViewer.lineOld","Line {line} (old)"):C("gitDiffViewer.lineNew","Line {line} (new)")).replace("{line}",String(s.line))}),s.resolved&&e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,fontSize:10,background:"var(--nice-success-tint-15, #22c55e22)",color:"var(--nice-color-success, #22c55e)"},children:C("gitDiffViewer.resolved","Resolved")}),z&&!s.resolved&&e.jsx("button",{onClick:()=>z(s.id),style:{marginLeft:"auto",padding:"4px 8px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-muted, #888)",cursor:"pointer",fontSize:10},children:C("gitDiffViewer.resolve","Resolve")})]}),e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-secondary, #ccc)"},children:s.body})]},s.id))]}),l&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>V(null),children:e.jsxs("div",{role:"presentation",style:{width:400,background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:20},onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px",fontSize:14},children:C("gitDiffViewer.addCommentOnLine","Add comment on line {line}").replace("{line}",String(l.line))}),e.jsx("textarea",{value:l.body,onChange:s=>V({...l,body:s.target.value}),placeholder:C("gitDiffViewer.writeAComment","Write a comment..."),rows:4,style:{width:"100%",padding:12,borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13,resize:"vertical"},autoFocus:!0}),e.jsxs("div",{style:{marginTop:12,display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>V(null),style:{padding:"8px 16px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:C("gitDiffViewer.cancel","Cancel")}),e.jsx("button",{onClick:()=>{l.body.trim()&&(P?.(l.filePath,l.line,l.side,l.body.trim()),V(null))},disabled:!l.body.trim(),style:{padding:"8px 16px",borderRadius:4,border:"none",background:l.body.trim()?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:l.body.trim()?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:l.body.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:500},children:C("gitDiffViewer.addComment2","Add Comment")})]})]})})]})]})},it=Object.freeze(Object.defineProperty({__proto__:null,NiceGitDiffViewer:Ee},Symbol.toStringTag,{value:"Module"})),ot=(a,f)=>{const B=new Date().getTime()-a.getTime(),_=Math.floor(B/(1e3*60*60*24));return _===0?"today":_===1?"yesterday":_<7?`${_} days ago`:_<30?`${Math.floor(_/7)} weeks ago`:_<365?`${Math.floor(_/30)} months ago`:`${Math.floor(_/365)} years ago`},st=a=>{const w=new Date().getTime()-a.getTime(),B=Math.floor(w/(1e3*60*60*24));return B<7?"var(--nice-primary-tint-30, rgba(59, 130, 246, 0.3))":B<30?"var(--nice-success-tint-30, rgba(34, 197, 94, 0.3))":B<90?"var(--nice-warning-tint-30, rgba(234, 179, 8, 0.3))":B<365?"var(--nice-warning-tint-30, rgba(249, 115, 22, 0.3))":"var(--nice-danger-tint-30, rgba(239, 68, 68, 0.3))"},ce=a=>{const f=["var(--nice-color-primary, #3b82f6)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-info, #06b6d4)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-warning, #f97316)","var(--nice-color-accent, #6366f1)"];let w=0;for(let B=0;B<a.length;B++)w=(w<<5)-w+a.charCodeAt(B),w=w&w;return f[Math.abs(w)%f.length]},Te=({file:a,viewMode:f="inline",showAgeHeatmap:w=!0,showAvatars:B=!0,groupHunks:_=!0,highlightOnHover:W=!0,timeZone:L,dateRange:D,authorFilter:E,selectedLine:N,syntaxTheme:j="dark",onLineClick:P,onCommitClick:z,onAuthorClick:k,onBlameParent:S,className:v,style:M,"data-testid":C="nice-git-blame"})=>{const{t:i}=n.useNiceTranslation(),[I,O]=o.useState(null),[b,Y]=o.useState(null),[F,H]=o.useState(null),c=o.useMemo(()=>{const p=[];return a.hunks.forEach(h=>{h.lines.forEach(T=>{p.push(T)})}),p.sort((h,T)=>h.lineNumber-T.lineNumber)},[a.hunks]),l=o.useMemo(()=>c.filter(p=>!(D?.from&&p.commit.timestamp<D.from||D?.to&&p.commit.timestamp>D.to||E&&E.length>0&&!E.includes(p.commit.author.id))),[c,D,E]),V=o.useMemo(()=>{if(!_)return l.map(d=>({startLine:d.lineNumber,endLine:d.lineNumber,commit:d.commit,lines:[d],isFirstOfCommit:!0}));const p=[];let h=null;const T=new Set;return l.forEach(d=>{if(!h||h.commit.id!==d.commit.id){const $=!T.has(d.commit.id);T.add(d.commit.id),h={startLine:d.lineNumber,endLine:d.lineNumber,commit:d.commit,lines:[d],isFirstOfCommit:$},p.push(h)}else h.endLine=d.lineNumber,h.lines.push(d)}),p},[l,_]),A=o.useMemo(()=>{const p=new Map;return c.forEach(h=>{p.has(h.commit.author.id)||p.set(h.commit.author.id,h.commit.author)}),Array.from(p.values())},[c]),Z=o.useMemo(()=>{const p=new Map;return c.forEach(h=>{p.has(h.commit.id)||p.set(h.commit.id,h.commit)}),Array.from(p.values()).sort((h,T)=>T.timestamp.getTime()-h.timestamp.getTime())},[c]),J=o.useCallback(p=>{P?.(p)},[P]),G=o.useCallback((p,h)=>{h.stopPropagation(),b===p.id?Y(null):Y(p.id),z?.(p)},[b,z]),U=(p,h)=>{const T=h===0,d=p.commit,$=W&&I===d.id;return e.jsxs("div",{role:T?"button":void 0,tabIndex:T?0:void 0,onKeyDown:T?n.clickOnActivationKey:void 0,style:{display:"flex",alignItems:"center",gap:8,padding:"0 12px",minWidth:f==="inline"?280:40,background:$?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":w?st(d.timestamp):"transparent",borderRight:`3px solid ${ce(d.author.id)}`,cursor:"pointer",transition:"background 0.15s"},onMouseEnter:()=>O(d.id),onMouseLeave:()=>O(null),onClick:q=>G(d,q),children:[T&&f==="inline"&&e.jsxs(e.Fragment,{children:[B&&e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:ce(d.author.id),display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:"var(--nice-text-primary, #0f172a)",fontWeight:500,flexShrink:0},title:d.author.name,children:d.author.avatar?e.jsx("img",{src:d.author.avatar,alt:d.author.name,style:{width:"100%",height:"100%",borderRadius:"50%"}}):d.author.name[0].toUpperCase()}),e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[e.jsx("div",{style:{fontSize:11,fontFamily:"monospace",color:"var(--nice-text-muted, #6b7280)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d.shortId}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #9ca3af)",whiteSpace:"nowrap"},children:ot(d.timestamp)})]})]}),f==="gutter"&&T&&e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:ce(d.author.id),display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,color:"var(--nice-text-primary, #0f172a)"},title:`${d.author.name} - ${d.shortId}
1
+ "use strict";const e=require("react/jsx-runtime"),n=require("@nice2dev/ui-core"),o=require("react"),qe=require("react-dom"),Ge={info:e.jsx(n.NiceIcon,{name:"info",size:28}),warning:e.jsx(n.NiceIcon,{name:"warning",size:28}),error:e.jsx(n.NiceIcon,{name:"error",size:28}),success:e.jsx(n.NiceIcon,{name:"success",size:28})},Se=({visible:a,message:f,header:w,icon:B,variant:_="warning",acceptLabel:W,rejectLabel:L,onAccept:D,onReject:E,closeOnOverlay:N=!1,closeOnEscape:j=!0,showReject:P=!0,size:z="md",className:k,style:S,testId:v,"data-testid":M})=>{const{t:C}=n.useNiceTranslation(),i=o.useRef(null),I=L??C("confirm.reject","No");if(n.useOverlayFocus(i,{open:a,onClose:E,closeOnEscape:j,closeHint:P?I:void 0}),o.useEffect(()=>(a?document.body.style.overflow="hidden":document.body.style.overflow="",()=>{document.body.style.overflow=""}),[a]),!a)return null;const O=B??Ge[_],b=W??C("confirm.accept","Yes");return e.jsx("div",{className:"nice-modal-overlay",role:"presentation",onClick:Y=>{Y.stopPropagation(),N&&Y.target===Y.currentTarget&&E()},onKeyDown:Y=>{Y.key!=="Escape"&&Y.stopPropagation()},children:e.jsxs("div",{ref:i,className:`nice-confirm nice-confirm--${_} nice-confirm--${z} ${k||""}`,style:S,role:"alertdialog","aria-modal":"true","aria-label":w,"aria-describedby":"nice-confirm-message","data-testid":M??v,children:[w&&e.jsx("div",{className:"nice-confirm__header",children:e.jsx("h3",{className:"nice-confirm__title",children:w})}),e.jsxs("div",{className:"nice-confirm__body",children:[O&&e.jsx("div",{className:`nice-confirm__icon nice-confirm__icon--${_}`,children:O}),e.jsx("div",{id:"nice-confirm-message",className:"nice-confirm__message",children:f})]}),e.jsxs("div",{className:"nice-confirm__footer",children:[P&&e.jsx("button",{type:"button",className:"nice-btn nice-btn--ghost nice-btn--md",onClick:E,children:I}),e.jsx("button",{type:"button",className:`nice-btn nice-btn--${_==="error"?"error":"primary"} nice-btn--md`,onClick:D,autoFocus:!0,children:b})]})]})})};function Ce(a){const f=a?.closest?.("[data-theme], .nice-dark, .nice-light, .dark");if(!f)return"";const w=f.getAttribute("data-theme");return w==="dark"||f.classList.contains("nice-dark")||f.classList.contains("dark")?"nice-dark":w==="light"||f.classList.contains("nice-light")?"nice-light":""}const je=new Set,Ke=(a,f)=>{if(Object.is(a,f))return!0;try{return JSON.stringify(a)===JSON.stringify(f)}catch{return!1}};function we(a,f,w,B,_,W="on its own the prop is only the initial value"){const L=o.useRef(B);if(process.env.NODE_ENV==="production"||_){L.current=B;return}const D=`${a}.${f}`;B!==void 0&&!je.has(D)&&!Ke(B,L.current)&&(je.add(D),console.warn(`[Nice2Dev] <${a}> \`${f}\` changed after mount without \`${w}\`, so the change is ignored: ${W}. Pass \`${w}\` to control it.`)),L.current=B}const me=[],be=["var(--nice-color-success, #22c55e)","var(--nice-color-primary, #3b82f6)","var(--nice-color-warning, #f59e0b)","var(--nice-color-accent-pink, #ec4899)","var(--nice-color-accent, #8b5cf6)","var(--nice-info, #14b8a6)","var(--nice-warning, #f97316)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #6366f1)","var(--nice-success, #84cc16)"],ve=24,ze=40,Re=28,Ve=6,Ue=4;function Ye(a,f,w,B){const _=[],W=[],L=new Map;a.forEach((z,k)=>L.set(z.hash,k));const D=new Map,E=[],N=new Map;let j=0;const P=new Map;if(f.forEach(z=>{if(!z.lastCommit)return;const k=P.get(z.lastCommit)||[];k.push({type:z.isRemote?"remote":"branch",name:z.name,commit:z.lastCommit,color:z.isHead?"var(--nice-color-success, #22c55e)":z.isRemote?"var(--nice-text-muted, #6b7280)":"var(--nice-color-primary, #3b82f6)"}),P.set(z.lastCommit,k)}),w.forEach(z=>{const k=P.get(z.commit)||[];k.push({type:"tag",name:z.name,commit:z.commit,color:"var(--nice-color-warning, #f59e0b)"}),P.set(z.commit,k)}),B){const z=P.get(B)||[];z.push({type:"head",name:"HEAD",commit:B,color:"var(--nice-color-error, #ef4444)"}),P.set(B,z)}return a.forEach((z,k)=>{let S=E.findIndex(M=>M===z.hash);S===-1&&(S=E.findIndex(M=>M===null),S===-1&&(S=E.length,E.push(null))),N.has(S)||(N.set(S,be[j%be.length]),j++),D.set(z.hash,S);const v=N.get(S)||be[0];_.push({commit:z,x:S,y:k,color:v,refs:P.get(z.hash)||[]}),z.parents.forEach((M,C)=>{const i=L.get(M);if(i!==void 0){let I=D.get(M);I===void 0&&(C===0?(I=S,E[S]=M):(I=E.findIndex(b=>b===null),I===-1?(I=E.length,E.push(M)):E[I]=M),D.set(M,I));const O=N.get(I)||v;W.push({from:z.hash,to:M,fromX:S,fromY:k,toX:I,toY:i,color:C===0?v:O,type:C===0?S===I?"straight":"branch":"merge"})}}),(z.parents.length===0||!a.slice(k+1).some(M=>M.parents.includes(z.hash)))&&(E[S]=null)}),{nodes:_,edges:W}}const Je=({nodes:a,edges:f,selectedHash:w,compact:B,onNodeClick:_,onNodeDoubleClick:W})=>{const L=B?Re:ze,D=B?Ue:Ve,N=(Math.max(...a.map(k=>k.x),0)+2)*ve,j=(a.length+1)*L,P=k=>ve/2+k*ve,z=k=>L/2+k*L;return e.jsxs("svg",{width:N,height:j,style:{minWidth:N,minHeight:j,display:"block"},children:[f.map((k,S)=>{const v=P(k.fromX),M=z(k.fromY),C=P(k.toX),i=z(k.toY);if(k.type==="straight")return e.jsx("line",{x1:v,y1:M,x2:C,y2:i,stroke:k.color,strokeWidth:2},S);const I=(M+i)/2,O=`M ${v} ${M} C ${v} ${I}, ${C} ${I}, ${C} ${i}`;return e.jsx("path",{d:O,fill:"none",stroke:k.color,strokeWidth:2,strokeDasharray:k.type==="merge"?"4,2":void 0},S)}),a.map(k=>{const S=P(k.x),v=z(k.y),M=k.commit.hash===w,C=k.commit.isMerge;return e.jsxs("g",{onClick:()=>_(k.commit.hash),onDoubleClick:()=>W(k.commit.hash),style:{cursor:"pointer"},children:[M&&e.jsx("circle",{cx:S,cy:v,r:D+4,fill:"none",stroke:"var(--nice-bg, #fff)",strokeWidth:2}),e.jsx("circle",{cx:S,cy:v,r:D,fill:C?"var(--nice-bg-elevated, #1e1e1e)":k.color,stroke:k.color,strokeWidth:C?2:0}),k.refs.length>0&&!B&&e.jsx("foreignObject",{x:S+10,y:v-8,width:200,height:16,children:e.jsx("div",{style:{display:"flex",gap:4,whiteSpace:"nowrap"},children:k.refs.map((i,I)=>e.jsxs("span",{style:{padding:"1px 6px",borderRadius:4,fontSize:10,fontWeight:500,background:`${i.color}22`,color:i.color,border:`1px solid ${i.color}44`},children:[i.type==="tag"?e.jsx(n.NiceIcon,{name:"tag",size:10}):i.type==="head"?e.jsx(n.NiceIcon,{name:"cursor",size:10}):null,(i.type==="tag"||i.type==="head")&&" ",i.name]},I))})})]},k.commit.hash)})]})},Ie=({commits:a=me,branches:f=me,tags:w=me,head:B,selectedCommit:_,branchFilter:W,authorFilter:L,dateRange:D,searchQuery:E,maxCommits:N=100,showRemotes:j=!0,showTags:P=!0,compact:z=!1,onCommitSelect:k,onCommitDoubleClick:S,onBranchCheckout:v,onBranchCreate:M,onTagCreate:C,onCherryPick:i,onRevert:I,onReset:O,onCompare:b,onViewDiff:Y,className:F,style:H,"data-testid":c})=>{const{t:l,lang:V}=n.useNiceTranslation(),[A,Z]=o.useState(_),[J,G]=o.useState(null),[U,te]=o.useState(!1),[g,p]=o.useState(null),h=o.useRef(null),T=_??A,d=o.useMemo(()=>{let m=a;if(W&&W.length>0){const Q=new Set;f.filter(y=>W.includes(y.name)).forEach(y=>{y.lastCommit&&Q.add(y.lastCommit)}),m=m.filter(y=>Q.has(y.hash))}if(L&&L.length>0&&(m=m.filter(Q=>L.some(y=>Q.author.name.toLowerCase().includes(y.toLowerCase())||Q.author.email.toLowerCase().includes(y.toLowerCase())))),D&&(D.from&&(m=m.filter(Q=>Q.date>=D.from)),D.to&&(m=m.filter(Q=>Q.date<=D.to))),E&&E.trim()){const Q=E.toLowerCase();m=m.filter(y=>y.hash.toLowerCase().includes(Q)||y.shortHash.toLowerCase().includes(Q)||y.message.toLowerCase().includes(Q)||y.author.name.toLowerCase().includes(Q))}return m.slice(0,N)},[a,W,L,D,E,N,f]),{nodes:$,edges:q}=o.useMemo(()=>Ye(d,j?f:f.filter(m=>!m.isRemote),P?w:[],B),[d,f,w,B,j,P]),s=o.useMemo(()=>d.find(m=>m.hash===T),[d,T]),t=o.useCallback(m=>{if(U&&g)b?.(g,m),te(!1),p(null);else if(U)p(m);else{Z(m);const Q=d.find(y=>y.hash===m);Q&&k?.(Q)}},[U,g,d,k,b]),x=o.useCallback(m=>{const Q=d.find(y=>y.hash===m);Q&&(S?.(Q),Y?.(m))},[d,S,Y]),u=o.useCallback((m,Q)=>{m.preventDefault(),G({x:m.clientX,y:m.clientY,commit:Q})},[]),R=o.useCallback(()=>G(null),[]),ee=m=>{const y=new Date().getTime()-m.getTime(),re=Math.floor(y/(1e3*60*60*24));return re===0?l("gitGraph.today","Today"):re===1?l("gitGraph.yesterday","Yesterday"):re<7?new Intl.RelativeTimeFormat(V).format(-re,"day"):m.toLocaleDateString(V)},X=z?Re:ze;return e.jsxs("div",{role:"presentation",className:`nice-git-graph ${F||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",...H},"data-testid":c,onClick:R,children:[e.jsxs("div",{ref:h,style:{flex:1,overflow:"auto",display:"flex"},children:[e.jsx("div",{style:{flexShrink:0,borderRight:"1px solid var(--nice-border-color, #333)"},children:e.jsx(Je,{nodes:$,edges:q,selectedHash:T,compact:z,onNodeClick:t,onNodeDoubleClick:x})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[$.map(m=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>t(m.commit.hash),onDoubleClick:()=>x(m.commit.hash),onContextMenu:Q=>u(Q,m.commit),style:{height:X,padding:"0 12px",display:"flex",alignItems:"center",gap:12,cursor:"pointer",background:m.commit.hash===T?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderBottom:"1px solid var(--nice-bg-secondary, #2a2a2a)"},children:[m.commit.author.avatar?e.jsx("img",{src:m.commit.author.avatar,alt:"",style:{width:z?20:24,height:z?20:24,borderRadius:"50%",flexShrink:0}}):e.jsx("div",{style:{width:z?20:24,height:z?20:24,borderRadius:"50%",background:m.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:z?10:12,color:"var(--nice-color-white, #fff)",fontWeight:600,flexShrink:0},children:m.commit.author.name.charAt(0).toUpperCase()}),e.jsx("div",{style:{flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontSize:z?12:13},children:m.commit.message}),m.commit.stats&&!z&&e.jsxs("div",{style:{display:"flex",gap:8,fontSize:11,color:"var(--nice-text-muted, #888)",flexShrink:0},children:[e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",m.commit.stats.additions]}),e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",m.commit.stats.deletions]})]}),e.jsx("code",{style:{fontSize:z?10:11,color:"var(--nice-text-muted, #888)",fontFamily:"monospace",flexShrink:0},children:m.commit.shortHash}),!z&&e.jsx("span",{style:{fontSize:11,color:"var(--nice-text-muted, #888)",flexShrink:0,width:100},children:m.commit.author.name}),e.jsx("span",{style:{fontSize:z?10:11,color:"var(--nice-text-muted, #666)",flexShrink:0,width:z?60:80,textAlign:"right"},children:ee(m.commit.date)})]},m.commit.hash)),d.length===0&&e.jsx("div",{style:{padding:24,textAlign:"center",color:"var(--nice-text-muted, #666)",fontSize:13},children:l("gitGraph.noCommitsMatchTheFilters","No commits match the filters")})]})]}),s&&!z&&e.jsxs("div",{style:{width:320,borderLeft:"1px solid var(--nice-border-color, #333)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[s.author.avatar?e.jsx("img",{src:s.author.avatar,alt:"",style:{width:32,height:32,borderRadius:"50%"}}):e.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:"var(--nice-color-primary, #3b82f6)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-on-primary, #fff)",fontWeight:600},children:s.author.name.charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:s.author.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:s.author.email})]})]}),e.jsx("code",{style:{fontSize:11,color:"var(--nice-text-muted, #888)",fontFamily:"monospace"},children:s.hash})]}),e.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,marginBottom:8},children:s.message}),s.body&&e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #aaa)",whiteSpace:"pre-wrap",maxHeight:120,overflow:"auto"},children:s.body})]}),s.stats&&e.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:20,fontWeight:600},children:s.stats.filesChanged}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:l("gitGraph.filesChanged","files changed")})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:20,fontWeight:600,color:"var(--nice-color-success, #22c55e)"},children:["+",s.stats.additions]}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:l("gitGraph.additions","additions")})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:20,fontWeight:600,color:"var(--nice-color-error, #ef4444)"},children:["-",s.stats.deletions]}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:l("gitGraph.deletions","deletions")})]})]}),e.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:8},children:[e.jsx("button",{onClick:()=>Y?.(s.hash),style:{padding:"8px 12px",borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500},children:l("gitGraph.viewChanges","View Changes")}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>i?.(s.hash),style:{flex:1,padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.cherryPick","Cherry Pick")}),e.jsx("button",{onClick:()=>I?.(s.hash),style:{flex:1,padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.revert","Revert")})]}),e.jsx("button",{onClick:()=>M?.(s.hash),style:{padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.createBranchHere","Create Branch Here")}),e.jsx("button",{onClick:()=>C?.(s.hash),style:{padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.createTagHere","Create Tag Here")}),e.jsx("button",{onClick:()=>{te(!0),p(s.hash)},style:{padding:"6px 10px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.compareWith","Compare with...")})]})]}),U&&e.jsxs("div",{style:{position:"absolute",top:8,left:"50%",transform:"translateX(-50%)",padding:"8px 16px",background:"var(--nice-color-primary, #3b82f6)",borderRadius:4,fontSize:12,fontWeight:500},children:[g?l("gitGraph.selectCommitToCompareWith","Select commit to compare with {compareBase}").replace("{compareBase}",String(g.slice(0,7))):l("gitGraph.selectFirstCommit","Select first commit"),e.jsx("button",{onClick:()=>{te(!1),p(null)},style:{marginLeft:12,padding:"2px 8px",background:"var(--nice-overlay-light-20, rgba(255, 255, 255, 0.2))",border:"none",borderRadius:4,color:"var(--nice-color-white, #fff)",cursor:"pointer",fontSize:11},children:l("gitGraph.cancel","Cancel")})]}),J&&e.jsx("div",{style:{position:"fixed",left:J.x,top:J.y,background:"var(--nice-bg-elevated, #252525)",border:"1px solid var(--nice-border-color, #444)",borderRadius:6,boxShadow:"0 4px 12px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))",minWidth:160,zIndex:1e3},children:[{label:l("gitGraph.viewChanges","View Changes"),onClick:()=>Y?.(J.commit.hash)},{label:l("gitGraph.cherryPick","Cherry Pick"),onClick:()=>i?.(J.commit.hash)},{label:l("gitGraph.revert","Revert"),onClick:()=>I?.(J.commit.hash)},{divider:!0},{label:l("gitGraph.createBranch","Create Branch"),onClick:()=>M?.(J.commit.hash)},{label:l("gitGraph.createTag","Create Tag"),onClick:()=>C?.(J.commit.hash)},{divider:!0},{label:l("gitGraph.resetSoft","Reset Soft"),onClick:()=>O?.(J.commit.hash,"soft")},{label:l("gitGraph.resetMixed","Reset Mixed"),onClick:()=>O?.(J.commit.hash,"mixed")},{label:l("gitGraph.resetHard","Reset Hard"),onClick:()=>O?.(J.commit.hash,"hard"),danger:!0}].map((m,Q)=>"divider"in m?e.jsx("div",{style:{height:1,background:"var(--nice-bg-tertiary, #444)",margin:"4px 0"}},Q):e.jsx("button",{onClick:()=>{m.onClick?.(),R()},style:{display:"block",width:"100%",padding:"8px 12px",border:"none",background:"transparent",color:"danger"in m&&m.danger?"var(--nice-color-error, #ef4444)":"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},onMouseOver:y=>{y.currentTarget.style.background="var(--nice-bg-tertiary, #333)"},onMouseOut:y=>{y.currentTarget.style.background="transparent"},children:m.label},Q))})]})},Xe=Object.freeze(Object.defineProperty({__proto__:null,NiceGitGraph:Ie},Symbol.toStringTag,{value:"Module"})),ye=({open:a,onSubmit:f,onCancel:w,title:B,message:_,defaultValue:W="",placeholder:L,inputType:D="text",confirmLabel:E,cancelLabel:N,className:j="",style:P,testId:z,"data-testid":k})=>{const{t:S}=n.useNiceTranslation(),[v,M]=o.useState(W),C=o.useRef(null),i=o.useRef(null);return o.useEffect(()=>{a&&M(W)},[a,W]),n.useOverlayFocus(i,{open:a,onClose:w,initialFocus:C,closeHint:typeof N=="string"?N:void 0}),a?e.jsx("div",{className:`nice-prompt-dialog ${j}`,style:P,role:"presentation",onClick:I=>{I.target===I.currentTarget&&w()},onKeyDown:I=>{I.key!=="Escape"&&I.stopPropagation()},children:e.jsxs("div",{ref:i,role:"dialog","aria-modal":"true","aria-labelledby":"nice-prompt-title",className:"nice-prompt-dialog__panel","data-testid":k??z,children:[e.jsx("h2",{id:"nice-prompt-title",className:"nice-prompt-dialog__title",children:B}),_&&e.jsx("p",{className:"nice-prompt-dialog__message",children:_}),e.jsx("input",{ref:C,type:D,value:v,placeholder:L,className:"nice-prompt-dialog__input",onChange:I=>M(I.target.value),onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),f(v))}}),e.jsxs("div",{className:"nice-prompt-dialog__actions",children:[e.jsx("button",{type:"button",className:"nice-prompt-dialog__btn nice-prompt-dialog__btn--cancel",onClick:w,children:N??S("cancel","Cancel")}),e.jsx("button",{type:"button",className:"nice-prompt-dialog__btn nice-prompt-dialog__btn--confirm",onClick:()=>f(v),children:E??S("ok","OK")})]})]})}):null};process.env.NODE_ENV!=="production"&&(ye.displayName="NicePromptDialog");function Ne(){const[a,f]=o.useState(null),w=o.useRef(null),B=o.useCallback(N=>{const j=w.current;j&&(j.kind==="prompt"?j.resolve(null):j.resolve(!1)),w.current=N,f(N)},[]),_=o.useCallback(()=>{w.current=null,f(null)},[]),W=o.useCallback(N=>new Promise(j=>B({kind:"prompt",request:N,resolve:j})),[B]),L=o.useCallback(N=>new Promise(j=>B({kind:"confirm",request:N,resolve:j})),[B]),D=o.useCallback(N=>new Promise(j=>B({kind:"alert",request:N,resolve:()=>j()})),[B]);let E=null;if(a?.kind==="prompt"){const{resolve:N,request:j}=a;E=e.jsx(ye,{open:!0,...j,onSubmit:P=>{_(),N(P)},onCancel:()=>{_(),N(null)}})}else if(a){const{resolve:N,request:j,kind:P}=a;E=e.jsx(Se,{visible:!0,...j,variant:j.variant??(P==="alert"?"info":"warning"),showReject:P!=="alert",onAccept:()=>{_(),N(!0)},onReject:()=>{_(),N(!1)}})}return{prompt:W,confirm:L,alert:D,element:E}}const Ze=[],Be=({branches:a=Ze,currentBranch:f,defaultBranch:w="main",protectionRules:B=[],showRemotes:_=!0,selectedBranch:W,onBranchSelect:L,onCheckout:D,onCreateBranch:E,onDeleteBranch:N,onRenameBranch:j,onMerge:P,onRebase:z,onSetUpstream:k,onPush:S,onPull:v,onCompare:M,onProtectionChange:C,className:i,style:I,"data-testid":O})=>{const{t:b,lang:Y}=n.useNiceTranslation(),F=Ne(),[H,c]=o.useState(""),[l,V]=o.useState("all"),[A,Z]=o.useState(),[J,G]=o.useState(!1),[U,te]=o.useState(!1),[g,p]=o.useState(!1),[h,T]=o.useState(""),[d,$]=o.useState(f||w),[q,s]=o.useState(""),[t,x]=o.useState(f||w),[u,R]=o.useState(null),ee=W??A,X=o.useMemo(()=>{let r=a;if(l==="local"?r=r.filter(K=>!K.isRemote):l==="remote"?r=r.filter(K=>K.isRemote):_||(r=r.filter(K=>!K.isRemote)),H.trim()){const K=H.toLowerCase();r=r.filter(oe=>oe.name.toLowerCase().includes(K))}return r.sort((K,oe)=>K.isHead?-1:oe.isHead?1:K.name===w?-1:oe.name===w?1:K.isRemote!==oe.isRemote?K.isRemote?1:-1:K.name.localeCompare(oe.name))},[a,l,_,H,w]),m=o.useMemo(()=>{const r=X.filter(oe=>!oe.isRemote),K=X.filter(oe=>oe.isRemote);return{local:r,remote:K}},[X]),Q=o.useCallback(r=>{Z(r),L?.(r)},[L]),y=o.useCallback((r,K)=>{r.preventDefault(),R({x:r.clientX,y:r.clientY,branch:K})},[]),re=o.useCallback(()=>R(null),[]),ie=o.useCallback(()=>{h.trim()&&(E?.(h.trim(),d),T(""),G(!1))},[h,d,E]),de=o.useCallback(()=>{q&&t&&q!==t&&(P?.(q,t),te(!1))},[q,t,P]),ue=r=>{if(!r)return"-";const oe=new Date().getTime()-r.getTime(),ae=Math.floor(oe/(1e3*60*60*24));if(ae===0)return b("branchManager.today","Today");if(ae===1)return b("branchManager.yesterday","Yesterday");const ge=new Intl.RelativeTimeFormat(Y);return ae<7?ge.format(-ae,"day"):ae<30?ge.format(-Math.floor(ae/7),"week"):r.toLocaleDateString(Y)},ne=o.useMemo(()=>a.find(r=>r.name===ee),[a,ee]),pe=o.useCallback(r=>B.some(K=>new RegExp(K.pattern.replace(/\*/g,".*")).test(r)),[B]),le=m.local,se=r=>{const K=r.name===ee,oe=r.isHead,ae=r.name===w,ge=pe(r.name);return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>Q(r.name),onDoubleClick:()=>D?.(r.name),onContextMenu:We=>y(We,r),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",cursor:"pointer",background:K?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":oe?"color-mix(in srgb, var(--nice-color-success, #22c55e) 8%, transparent)":"transparent",borderLeft:oe?"3px solid var(--nice-success, #22c55e)":"3px solid transparent"},children:[e.jsx(n.NiceIcon,{name:r.isRemote?"cloud":oe?"map-pin":"box",size:16}),e.jsx("span",{style:{flex:1,fontSize:13,fontWeight:oe?600:400,color:oe?"var(--nice-color-success, #22c55e)":"var(--nice-text-primary, #e0e0e0)"},children:r.name}),e.jsxs("div",{style:{display:"flex",gap:4},children:[ae&&e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,fontSize:10,background:"var(--nice-primary-tint-15, #3b82f622)",color:"var(--nice-color-primary, #3b82f6)",border:"1px solid color-mix(in srgb, var(--nice-color-primary, #3b82f6) 27%, transparent)"},children:b("branchManager.default","default")}),ge&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",borderRadius:4,fontSize:10,background:"var(--nice-warning-tint-15, #f59e0b22)",color:"var(--nice-color-warning, #f59e0b)",border:"1px solid color-mix(in srgb, var(--nice-color-warning, #f59e0b) 27%, transparent)"},children:[e.jsx(n.NiceIcon,{name:"lock",size:10})," ",b("branchManager.protected","protected")]})]}),r.upstream&&(r.ahead||r.behind)&&e.jsxs("div",{style:{display:"flex",gap:4,fontSize:10,color:"var(--nice-text-muted, #888)"},children:[r.ahead?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--nice-color-success, #22c55e)"},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:10}),r.ahead]}):null,r.behind?e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--nice-color-error, #ef4444)"},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:10}),r.behind]}):null]}),r.lastCommit&&e.jsx("span",{style:{fontSize:10,color:"var(--nice-text-muted, #666)",width:80,textAlign:"right"},children:ue(r.lastCommit.date)})]},r.name)};return e.jsxs("div",{role:"presentation",className:`nice-branch-manager ${i||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",...I},"data-testid":O,onClick:re,children:[F.element,e.jsxs("div",{style:{width:350,display:"flex",flexDirection:"column",borderRight:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{padding:12,borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[e.jsx(n.NiceIcon,{name:"box",size:18}),e.jsx("span",{style:{fontWeight:600,fontSize:14},children:b("branchManager.branches","Branches")}),e.jsx("span",{style:{marginLeft:"auto",padding:"2px 8px",background:"var(--nice-bg-tertiary, #333)",borderRadius:10,fontSize:11},children:b("branchManager.local","{branches} local").replace("{branches}",String(a.filter(r=>!r.isRemote).length))})]}),e.jsx("input",{type:"text",placeholder:b("branchManager.searchBranches","Search branches..."),value:H,onChange:r=>c(r.target.value),style:{width:"100%",padding:"8px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",fontSize:12,marginBottom:8}}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","local","remote"].map(r=>e.jsx("button",{onClick:()=>V(r),style:{flex:1,padding:"6px 0",borderRadius:4,border:"none",background:l===r?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:l===r?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:r},r))})]}),e.jsxs("div",{style:{padding:8,borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",gap:8},children:[e.jsxs("button",{onClick:()=>G(!0),style:{flex:1,padding:"8px 12px",borderRadius:4,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"plus",size:14})," ",b("branchManager.newBranch","New Branch")]}),e.jsxs("button",{onClick:()=>te(!0),style:{flex:1,padding:"8px 12px",borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:14})," ",b("branchManager.merge","Merge")]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[m.local.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",fontSize:10,fontWeight:600,color:"var(--nice-text-muted, #888)",textTransform:"uppercase",background:"var(--nice-bg-elevated, #252525)"},children:b("branchManager.local2","Local ({local})").replace("{local}",String(m.local.length))}),m.local.map(se)]}),_&&m.remote.length>0&&l!=="local"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:"8px 12px",fontSize:10,fontWeight:600,color:"var(--nice-text-muted, #888)",textTransform:"uppercase",background:"var(--nice-bg-elevated, #252525)",marginTop:8},children:b("branchManager.remote","Remote ({remote})").replace("{remote}",String(m.remote.length))}),m.remote.map(se)]}),X.length===0&&e.jsx("div",{style:{padding:24,textAlign:"center",color:"var(--nice-text-muted, #666)",fontSize:12},children:b("branchManager.noBranchesMatchTheFilter","No branches match the filter")})]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:ne?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:ne.isRemote?"cloud":ne.isHead?"map-pin":"box",size:24}),e.jsxs("div",{style:{flex:1},children:[e.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:600},children:ne.name}),ne.description&&e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--nice-text-muted, #888)"},children:ne.description})]}),ne.isHead&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"4px 12px",borderRadius:4,background:"var(--nice-success-tint-15, #22c55e22)",color:"var(--nice-color-success, #22c55e)",fontSize:12,fontWeight:500},children:[e.jsx(n.NiceIcon,{name:"check",size:14})," ",b("branchManager.current","Current")]})]})}),e.jsxs("div",{style:{padding:16,borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:16},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.upstream","Upstream")}),e.jsx("div",{style:{fontSize:13},children:ne.upstream||e.jsx("span",{style:{color:"var(--nice-text-muted, #666)"},children:b("branchManager.notSet","Not set")})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.syncStatus","Sync Status")}),e.jsx("div",{style:{display:"flex",gap:8,fontSize:13},children:ne.upstream?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--nice-color-success, #22c55e)"},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:13})," ",b("branchManager.ahead","{ahead} ahead").replace("{ahead}",String(ne.ahead||0))]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--nice-color-error, #ef4444)"},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:13})," ",b("branchManager.behind","{behind} behind").replace("{behind}",String(ne.behind||0))]})]}):e.jsx("span",{style:{color:"var(--nice-text-muted, #666)"},children:"-"})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.lastCommit","Last Commit")}),e.jsx("div",{style:{fontSize:13},children:ne.lastCommit?e.jsxs(e.Fragment,{children:[e.jsx("code",{style:{fontSize:11,color:"var(--nice-text-muted, #aaa)"},children:ne.lastCommit.hash.slice(0,7)})," ",ue(ne.lastCommit.date)]}):e.jsx("span",{style:{color:"var(--nice-text-muted, #666)"},children:"-"})})]})]}),ne.lastCommit&&e.jsxs("div",{style:{marginTop:16,padding:12,background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:6,fontSize:12},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:4},children:ne.lastCommit.message}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:b("branchManager.by","by {author}").replace("{author}",String(ne.lastCommit.author))})]})]}),e.jsx("div",{style:{padding:16},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[!ne.isHead&&e.jsxs("button",{onClick:()=>D?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"map-pin",size:14})," ",b("branchManager.checkout","Checkout")]}),ne.upstream&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>v?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:14})," ",b("branchManager.pull","Pull")]}),e.jsxs("button",{onClick:()=>S?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-accent, #8b5cf6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:14})," ",b("branchManager.push","Push")]})]}),!ne.upstream&&!ne.isRemote&&e.jsx("button",{onClick:()=>k?.(ne.name,`origin/${ne.name}`),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:b("branchManager.setUpstream","Set Upstream")}),e.jsxs("button",{onClick:()=>{s(ne.name),x(f||w),te(!0)},style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:14})," ",b("branchManager.mergeInto","Merge into...")]}),e.jsxs("button",{onClick:()=>M?.(w,ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:14})," ",b("branchManager.compare","Compare")]}),!ne.isHead&&!ne.isRemote&&!pe(ne.name)&&e.jsxs("button",{onClick:()=>N?.(ne.name),style:{padding:"10px 16px",borderRadius:6,border:"none",background:"var(--nice-color-error, #ef4444)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"trash",size:14})," ",b("branchManager.delete","Delete")]})]})})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #666)",fontSize:13},children:b("branchManager.selectABranchToView","Select a branch to view details")})}),J&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>G(!1),children:e.jsxs("div",{role:"presentation",style:{width:400,background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:24},onClick:r=>r.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 16px",fontSize:16},children:b("branchManager.createNewBranch","Create New Branch")}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.branchName","Branch Name")}),e.jsx("input",{type:"text",placeholder:b("branchManager.featureMyFeature","feature/my-feature"),value:h,onChange:r=>T(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.basedOn","Based on")}),e.jsx("select",{value:d,onChange:r=>$(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:le.map(r=>e.jsxs("option",{value:r.name,children:[r.name," ",r.isHead?b("branchManager.current2","(current)"):""]},r.name))})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>G(!1),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:b("branchManager.cancel","Cancel")}),e.jsx("button",{onClick:ie,disabled:!h.trim(),style:{padding:"10px 20px",borderRadius:6,border:"none",background:h.trim()?"var(--nice-color-success, #22c55e)":"var(--nice-bg-tertiary, #333)",color:h.trim()?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:h.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:500},children:b("branchManager.createBranch","Create Branch")})]})]})}),U&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>te(!1),children:e.jsxs("div",{role:"presentation",style:{width:400,background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:24},onClick:r=>r.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 16px",fontSize:16},children:b("branchManager.mergeBranches","Merge Branches")}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.mergeFrom","Merge from")}),e.jsxs("select",{value:q,onChange:r=>s(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:[e.jsx("option",{value:"",children:b("branchManager.selectBranch","Select branch...")}),le.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 0",color:"var(--nice-text-muted, #888)"},children:[e.jsx(n.NiceIcon,{name:"arrow-down",size:14})," ",b("branchManager.into","into")," ",e.jsx(n.NiceIcon,{name:"arrow-down",size:14})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:4},children:b("branchManager.mergeInto2","Merge into")}),e.jsx("select",{value:t,onChange:r=>x(r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:le.map(r=>e.jsxs("option",{value:r.name,children:[r.name," ",r.isHead?b("branchManager.current2","(current)"):""]},r.name))})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>te(!1),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:b("branchManager.cancel","Cancel")}),e.jsx("button",{onClick:de,disabled:!q||!t||q===t,style:{padding:"10px 20px",borderRadius:6,border:"none",background:q&&t&&q!==t?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:q&&t&&q!==t?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:q&&t&&q!==t?"pointer":"not-allowed",fontSize:12,fontWeight:500},children:b("branchManager.merge","Merge")})]})]})}),u&&e.jsx("div",{style:{position:"fixed",left:u.x,top:u.y,background:"var(--nice-bg-elevated, #252525)",border:"1px solid var(--nice-border-color, #444)",borderRadius:6,boxShadow:"0 4px 12px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))",minWidth:160,zIndex:1e3},children:[!u.branch.isHead&&{label:b("branchManager.checkout","Checkout"),onClick:()=>D?.(u.branch.name)},{label:b("branchManager.compare","Compare"),onClick:()=>M?.(w,u.branch.name)},{label:b("branchManager.mergeIntoCurrent","Merge into current"),onClick:()=>P?.(u.branch.name,f||w)},{divider:!0},!u.branch.isRemote&&{label:b("branchManager.rename","Rename"),onClick:()=>{const r=u.branch.name;F.prompt({title:b("branchManager.renamePrompt","New branch name"),defaultValue:r}).then(K=>{K&&j?.(r,K)})}},!u.branch.isHead&&!u.branch.isRemote&&!pe(u.branch.name)&&{label:b("branchManager.delete","Delete"),onClick:()=>N?.(u.branch.name),danger:!0}].filter(Boolean).map((r,K)=>r?"divider"in r?e.jsx("div",{style:{height:1,background:"var(--nice-bg-tertiary, #444)",margin:"4px 0"}},K):e.jsx("button",{onClick:()=>{r.onClick?.(),re()},style:{display:"block",width:"100%",padding:"8px 12px",border:"none",background:"transparent",color:"danger"in r&&r.danger?"var(--nice-color-error, #ef4444)":"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},onMouseOver:oe=>oe.currentTarget.style.background="var(--nice-bg-tertiary, #333)",onMouseOut:oe=>oe.currentTarget.style.background="transparent",children:r.label},K):null)})]})},Qe=Object.freeze(Object.defineProperty({__proto__:null,NiceBranchManager:Be},Symbol.toStringTag,{value:"Module"})),et=[],tt=[{target:".nice-merge-request-builder",titleKey:"tutorial.mergeRequestBuilder.intro.title",title:"Merge request builder",contentKey:"tutorial.mergeRequestBuilder.intro.content",content:"Pick source and target branches, write the title and description, add reviewers, labels and linked issues, then preview and submit.",placement:"auto"}],Me=({branches:a=et,users:f=[],labels:w=[],issues:B=[],templates:_=[],diff:W,currentBranch:L,defaultTargetBranch:D="main",initialSourceBranch:E,platform:N="github",onSubmit:j,onCancel:P,onBranchChange:z,onPreview:k,tutorial:S,className:v,style:M,"data-testid":C})=>{const{t:i}=n.useNiceTranslation(),[I,O]=o.useState(""),[b,Y]=o.useState(""),[F,H]=o.useState(E||L||""),[c,l]=o.useState(D),[V,A]=o.useState(!1),[Z,J]=o.useState([]),[G,U]=o.useState([]),[te,g]=o.useState([]),[p,h]=o.useState([]),[T,d]=o.useState(!1),[$,q]=o.useState(!0),[s,t]=o.useState(!1),[x,u]=o.useState(!1),[R,ee]=o.useState(!1),[X,m]=o.useState(!1),Q=o.useMemo(()=>F?F.replace(/^(feature|bugfix|hotfix|release)\//,"").replace(/[-_]/g," ").replace(/\b\w/g,K=>K.toUpperCase()):"",[F]),y=o.useMemo(()=>a.filter(r=>!r.isRemote),[a]),re=o.useCallback((r,K)=>{H(r),l(K),z?.(r,K)},[z]),ie=o.useCallback(()=>{if(!F||!c||!I.trim())return;const r={title:I.trim(),description:b.trim(),sourceBranch:F,targetBranch:c,isDraft:V,labels:Z,reviewers:G,assignees:te,linkedIssues:p,squashCommits:T,deleteSourceBranch:$};j?.(r)},[I,b,F,c,V,Z,G,te,p,T,$,j]),de=r=>{Y(r.content),m(!1)},ue=r=>{J(K=>K.includes(r)?K.filter(oe=>oe!==r):[...K,r])},ne=r=>{U(K=>K.includes(r)?K.filter(oe=>oe!==r):[...K,r])},pe=r=>{h(K=>K.includes(r)?K.filter(oe=>oe!==r):[...K,r])},le={github:{title:i("mergeRequestBuilder.pullRequest","Pull Request"),btn:"Create Pull Request"},gitlab:{title:i("mergeRequestBuilder.mergeRequest","Merge Request"),btn:"Create Merge Request"},bitbucket:{title:i("mergeRequestBuilder.pullRequest","Pull Request"),btn:"Create Pull Request"},azure:{title:i("mergeRequestBuilder.pullRequest","Pull Request"),btn:"Create Pull Request"}},se=F&&c&&F!==c&&I.trim();return e.jsxs("div",{className:`nice-merge-request-builder ${v||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",position:"relative",...M},"data-testid":C,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(n.NiceTutorialButton,{steps:n.resolveTutorial(S,tt)})}),e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:24}),e.jsxs("div",{children:[e.jsxs("h2",{style:{margin:0,fontSize:18,fontWeight:600},children:[V?`${i("mergeRequestBuilder.draft","Draft")} `:"",le[N].title]}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:12,color:"var(--nice-text-muted, #888)"},children:N==="gitlab"?i("mergeRequestBuilder.createMergeRequest","Create a new merge request"):i("mergeRequestBuilder.createPullRequest","Create a new pull request")})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[e.jsxs("div",{style:{background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:16,marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,justifyContent:"center"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:"var(--nice-text-muted, #888)",marginBottom:4},children:i("mergeRequestBuilder.from","From")}),e.jsxs("select",{value:F,onChange:r=>re(r.target.value,c),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:[e.jsx("option",{value:"",children:i("mergeRequestBuilder.selectSourceBranch","Select source branch...")}),y.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))]})]}),e.jsx("div",{style:{padding:"20px 0 0"},children:e.jsx("span",{style:{fontSize:20,color:"var(--nice-text-muted, #888)"},children:e.jsx(n.NiceIcon,{name:"arrow-right",size:20})})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:{display:"block",fontSize:11,color:"var(--nice-text-muted, #888)",marginBottom:4},children:i("mergeRequestBuilder.into","Into")}),e.jsx("select",{value:c,onChange:r=>re(F,r.target.value),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13},children:y.map(r=>e.jsx("option",{value:r.name,children:r.name},r.name))})]})]}),W&&e.jsxs("div",{style:{marginTop:12,padding:"8px 12px",background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:6,display:"flex",gap:16,fontSize:12},children:[e.jsx("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:i("mergeRequestBuilder.additions","+{additions} additions").replace("{additions}",String(W.additions))}),e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:i("mergeRequestBuilder.deletions","-{deletions} deletions").replace("{deletions}",String(W.deletions))}),e.jsx("span",{style:{color:"var(--nice-text-muted, #888)"},children:i("mergeRequestBuilder.filesChanged","{changedFiles} files changed").replace("{changedFiles}",String(W.changedFiles))})]}),F===c&&F&&e.jsx("div",{style:{marginTop:12,padding:"8px 12px",background:"var(--nice-danger-tint-15, #ef444422)",color:"var(--nice-color-error, #ef4444)",borderRadius:6,fontSize:12},children:i("mergeRequestBuilder.sourceAndTargetBranchesCannot","Source and target branches cannot be the same")})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:6},children:i("mergeRequestBuilder.title","Title")}),e.jsx("input",{type:"text",value:I,onChange:r=>O(r.target.value),placeholder:Q||i("mergeRequestBuilder.enterATitle","Enter a title..."),style:{width:"100%",padding:"12px 16px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",fontSize:14}}),!I&&Q&&e.jsx("button",{onClick:()=>O(Q),style:{marginTop:4,padding:0,background:"none",border:"none",color:"var(--nice-color-primary, #3b82f6)",fontSize:11,cursor:"pointer"},children:i("mergeRequestBuilder.useSuggested",'Use suggested: "{suggestedTitle}"').replace("{suggestedTitle}",String(Q))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6},children:[e.jsx("label",{style:{fontSize:12,color:"var(--nice-text-muted, #888)"},children:i("mergeRequestBuilder.description","Description")}),_.length>0&&e.jsxs("button",{onClick:()=>m(!X),style:{padding:"4px 8px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-muted, #888)",fontSize:11,cursor:"pointer"},children:[e.jsx(n.NiceIcon,{name:"edit",size:14})," ",i("mergeRequestBuilder.templates","Templates")]})]}),e.jsx("textarea",{value:b,onChange:r=>Y(r.target.value),placeholder:i("mergeRequestBuilder.describeYourChanges","Describe your changes..."),rows:8,style:{width:"100%",padding:"12px 16px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",fontSize:13,resize:"vertical",fontFamily:"inherit"}})]}),X&&_.length>0&&e.jsxs("div",{style:{marginBottom:16,padding:12,background:"var(--nice-bg-elevated, #252525)",borderRadius:6,border:"1px solid var(--nice-border-color, #444)"},children:[e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:8},children:i("mergeRequestBuilder.selectTemplate","Select Template")}),_.map(r=>e.jsxs("button",{onClick:()=>de(r),style:{display:"block",width:"100%",padding:"8px 12px",marginBottom:4,borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:[e.jsx("div",{style:{fontWeight:500},children:r.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:r.description})]},r.id))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16,marginBottom:20},children:[e.jsxs("div",{children:[e.jsx("button",{onClick:()=>t(!s),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"tag",size:14})," ",i("mergeRequestBuilder.labels","Labels")]}),Z.length>0&&e.jsxs("span",{style:{color:"var(--nice-color-primary, #3b82f6)"},children:["(",Z.length,")"]})]})}),s&&e.jsx("div",{style:{marginTop:8,padding:8,background:"var(--nice-bg-tertiary, #333)",borderRadius:6,maxHeight:200,overflow:"auto"},children:w.map(r=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:Z.includes(r.id),onChange:()=>ue(r.id)}),e.jsx("span",{style:{width:12,height:12,borderRadius:"50%",background:r.color}}),e.jsx("span",{style:{fontSize:12},children:r.name})]},r.id))})]}),e.jsxs("div",{children:[e.jsx("button",{onClick:()=>u(!x),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"users",size:14})," ",i("mergeRequestBuilder.reviewers","Reviewers")]}),G.length>0&&e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["(",G.length,")"]})]})}),x&&e.jsx("div",{style:{marginTop:8,padding:8,background:"var(--nice-bg-tertiary, #333)",borderRadius:6,maxHeight:200,overflow:"auto"},children:f.map(r=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:G.includes(r.id),onChange:()=>ne(r.id)}),r.avatar?e.jsx("img",{src:r.avatar,alt:"",style:{width:20,height:20,borderRadius:"50%"}}):e.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"var(--nice-bg-tertiary, #666)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10},children:r.name[0]}),e.jsx("span",{style:{fontSize:12},children:r.name})]},r.id))})]}),e.jsxs("div",{children:[e.jsx("button",{onClick:()=>ee(!R),style:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",color:"var(--nice-text-primary, #fff)",textAlign:"left",cursor:"pointer",fontSize:12},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"link",size:14})," ",i("mergeRequestBuilder.linkedIssues","Linked Issues")]}),p.length>0&&e.jsxs("span",{style:{color:"var(--nice-color-accent, #8b5cf6)"},children:["(",p.length,")"]})]})}),R&&e.jsx("div",{style:{marginTop:8,padding:8,background:"var(--nice-bg-tertiary, #333)",borderRadius:6,maxHeight:200,overflow:"auto"},children:B.filter(r=>r.state==="open").map(r=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p.includes(r.id),onChange:()=>pe(r.id)}),e.jsxs("span",{style:{fontSize:12,color:"var(--nice-text-muted, #888)"},children:["#",r.number]}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title})]},r.id))})]}),e.jsx("div",{children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #252525)",cursor:"pointer",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:V,onChange:r=>A(r.target.checked)}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"edit",size:14})," ",i("mergeRequestBuilder.createAsDraft","Create as Draft")]})]})})]}),e.jsxs("div",{style:{background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:16,marginBottom:20},children:[e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:12},children:i("mergeRequestBuilder.mergeOptions","Merge Options")}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:T,onChange:r=>d(r.target.checked)}),i("mergeRequestBuilder.squashCommitsOnMerge","Squash commits on merge")]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,cursor:"pointer",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:$,onChange:r=>q(r.target.checked)}),i("mergeRequestBuilder.deleteSourceBranchAfterMerge","Delete source branch after merge")]})]})]}),W&&W.files.length>0&&e.jsxs("div",{style:{background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:16},children:[e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #888)",marginBottom:12},children:i("mergeRequestBuilder.changedFiles","Changed Files ({changedFiles})").replace("{changedFiles}",String(W.changedFiles))}),e.jsx("div",{style:{maxHeight:200,overflow:"auto"},children:W.files.map(r=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",borderRadius:4,fontSize:12},children:[e.jsx("span",{style:{width:12,height:12,borderRadius:2,background:r.status==="added"?"var(--nice-color-success, #22c55e)":r.status==="deleted"?"var(--nice-color-error, #ef4444)":r.status==="renamed"?"var(--nice-color-primary, #3b82f6)":"var(--nice-color-warning, #f59e0b)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:8,color:"var(--nice-color-white, #fff)"},children:r.status==="added"?"+":r.status==="deleted"?"-":r.status==="renamed"?"R":"M"}),e.jsx("span",{style:{flex:1,fontFamily:"monospace",fontSize:11},children:r.path}),e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)",fontSize:11},children:["+",r.additions]}),e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)",fontSize:11},children:["-",r.deletions]})]},r.path))})]})]}),e.jsxs("div",{style:{padding:"16px 20px",borderTop:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",display:"flex",alignItems:"center",justifyContent:"flex-end",gap:12},children:[e.jsx("button",{onClick:P,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:13},children:i("mergeRequestBuilder.cancel","Cancel")}),e.jsx("button",{onClick:()=>k?.({title:I,description:b,sourceBranch:F,targetBranch:c,isDraft:V,labels:Z,reviewers:G,assignees:te,linkedIssues:p,squashCommits:T,deleteSourceBranch:$}),disabled:!se,style:{padding:"10px 20px",borderRadius:6,border:"none",background:se?"var(--nice-bg-tertiary, #333)":"var(--nice-bg-elevated, #222)",color:se?"var(--nice-text-primary, #fff)":"var(--nice-text-muted, #666)",cursor:se?"pointer":"not-allowed",fontSize:13},children:i("mergeRequestBuilder.preview","Preview")}),e.jsx("button",{onClick:ie,disabled:!se,style:{padding:"10px 24px",borderRadius:6,border:"none",background:se?"var(--nice-color-success, #22c55e)":"var(--nice-bg-elevated, #222)",color:se?"var(--nice-color-white, #fff)":"var(--nice-text-muted, #666)",cursor:se?"pointer":"not-allowed",fontSize:13,fontWeight:500},children:V?i("mergeRequestBuilder.createDraft","Create Draft"):le[N].btn})]})]})},nt=Object.freeze(Object.defineProperty({__proto__:null,NiceMergeRequestBuilder:Me},Symbol.toStringTag,{value:"Module"})),rt=[],Ee=({files:a=rt,viewMode:f,showWhitespace:w,comments:B=[],selectedFile:_,showFileTree:W=!0,contextLines:L=3,baseRef:D,headRef:E,onFileSelect:N,onViewModeChange:j,onAddComment:P,onResolveComment:z,onExpandChunk:k,className:S,style:v,"data-testid":M})=>{const{t:C}=n.useNiceTranslation(),[i,I]=o.useState("split"),[O,b]=o.useState(!1),[Y,F]=o.useState(void 0),[H,c]=o.useState(new Set),[l,V]=o.useState(null),A=f??i,Z=w??O,J=_??Y??a[0]?.path,G=o.useMemo(()=>a.find(s=>s.path===J),[a,J]),U=o.useMemo(()=>({additions:a.reduce((s,t)=>s+t.additions,0),deletions:a.reduce((s,t)=>s+t.deletions,0)}),[a]),te=o.useCallback(s=>{F(s),N?.(s)},[N]),g=o.useCallback(s=>{I(s),j?.(s)},[j]),p=o.useCallback((s,t)=>{const x=`${s}:${t}`;c(u=>{const R=new Set(u);return R.has(x)?R.delete(x):R.add(x),R}),k?.(s,t)},[k]),h=o.useMemo(()=>B.filter(s=>s.filePath===J),[B,J]),T=s=>{switch(s){case"added":return{icon:"+",color:"var(--nice-color-success, #22c55e)"};case"deleted":return{icon:"-",color:"var(--nice-color-error, #ef4444)"};case"modified":return{icon:"M",color:"var(--nice-color-warning, #f59e0b)"};case"renamed":return{icon:"R",color:"var(--nice-color-primary, #3b82f6)"};case"copied":return{icon:"C",color:"var(--nice-color-accent, #8b5cf6)"}}},d=(s,t,x)=>{const u=s.type==="addition"?"var(--nice-success-tint-10, rgba(34, 197, 94, 0.1))":s.type==="deletion"?"var(--nice-danger-tint-10, rgba(239, 68, 68, 0.1))":s.type==="header"?"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))":"transparent",R=s.type==="addition"?"var(--nice-success-text, #4ade80)":s.type==="deletion"?"var(--nice-danger-text, #f87171)":s.type==="header"?"var(--nice-info-text, #60a5fa)":"var(--nice-text-primary, #e0e0e0)",ee=x==="old"?s.lineNumberOld:x==="new"?s.lineNumberNew:void 0,X=Z?s.content.replace(/ /g,"·").replace(/\t/g,"→ "):s.content;return e.jsxs("div",{style:{display:"flex",alignItems:"stretch",background:u,minHeight:20,fontSize:12,fontFamily:'"JetBrains Mono", "Fira Code", monospace'},children:[ee!==void 0&&e.jsx("div",{style:{minWidth:50,padding:"0 8px",textAlign:"right",color:"var(--nice-text-muted, #666)",background:"var(--nice-overlay-20, rgba(0, 0, 0, 0.2))",userSelect:"none",borderRight:"1px solid var(--nice-border-color, #333)"},children:ee}),A==="unified"&&e.jsx("div",{style:{width:20,textAlign:"center",color:R,fontWeight:600},children:s.type==="addition"?"+":s.type==="deletion"?"-":" "}),e.jsx("div",{style:{flex:1,padding:"0 8px",color:R,whiteSpace:"pre",overflow:"hidden",textOverflow:"ellipsis"},children:X||" "}),P&&ee&&s.type!=="header"&&e.jsx("button",{type:"button",onClick:()=>V({filePath:J,line:ee,side:x||"new",body:""}),style:{width:24,border:"none",background:"transparent",color:"var(--nice-color-primary, #3b82f6)",cursor:"pointer",opacity:.3,transition:"opacity 0.2s"},onMouseEnter:m=>m.currentTarget.style.opacity="1",onMouseLeave:m=>m.currentTarget.style.opacity="0.3",onFocus:m=>m.currentTarget.style.opacity="1",onBlur:m=>m.currentTarget.style.opacity="0.3","aria-label":C("gitDiffViewer.addComment","Add comment"),children:e.jsx(n.NiceIcon,{name:"message",size:14})})]},`${t}-${x||"unified"}`)},$=s=>e.jsx("div",{style:{borderTop:"1px solid var(--nice-border-color, #333)"},children:s.chunks.map((t,x)=>{const u=`${s.path}:${x}`;return H.has(u),e.jsxs("div",{children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>p(s.path,x),style:{padding:"6px 12px",background:"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))",borderBottom:"1px solid var(--nice-border-color, #333)",fontSize:11,color:"var(--nice-color-primary-light, #60a5fa)",cursor:"pointer",fontFamily:"monospace"},children:["@@ -",t.oldStart,",",t.oldLines," +",t.newStart,",",t.newLines," @@"," ",t.header||""]}),t.lines.map((R,ee)=>d(R,ee))]},x)})}),q=s=>e.jsx("div",{style:{borderTop:"1px solid var(--nice-border-color, #333)"},children:s.chunks.map((t,x)=>{const u=[],R=[];for(const X of t.lines)(X.type==="deletion"||X.type==="context")&&u.push(X),(X.type==="addition"||X.type==="context")&&R.push(X);const ee=Math.max(u.length,R.length);for(;u.length<ee;)u.push({content:"",type:"context"});for(;R.length<ee;)R.push({content:"",type:"context"});return e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"6px 12px",background:"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))",borderBottom:"1px solid var(--nice-border-color, #333)",fontSize:11,color:"var(--nice-color-primary-light, #60a5fa)",fontFamily:"monospace"},children:["@@ -",t.oldStart,",",t.oldLines," +",t.newStart,",",t.newLines," @@"," ",t.header||""]}),e.jsxs("div",{style:{display:"flex"},children:[e.jsx("div",{style:{flex:1,borderRight:"1px solid var(--nice-border-color, #444)"},children:u.map((X,m)=>d(X,m,"old"))}),e.jsx("div",{style:{flex:1},children:R.map((X,m)=>d(X,m,"new"))})]})]},x)})});return e.jsxs("div",{className:`nice-git-diff-viewer ${S||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",fontFamily:"system-ui, sans-serif",...v},"data-testid":M,children:[W&&e.jsxs("div",{style:{width:280,borderRight:"1px solid var(--nice-border-color, #333)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:12,borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx(n.NiceIcon,{name:"folder",size:16}),e.jsx("span",{style:{fontWeight:600,fontSize:13},children:C("gitDiffViewer.changedFiles","Changed Files")}),e.jsx("span",{style:{marginLeft:"auto",padding:"2px 8px",background:"var(--nice-bg-tertiary, #333)",borderRadius:10,fontSize:11},children:a.length})]}),(D||E)&&e.jsxs("div",{style:{fontSize:11,color:"var(--nice-text-muted, #888)"},children:[D&&e.jsx("span",{children:D}),D&&E&&e.jsx("span",{style:{margin:"0 4px"},children:e.jsx(n.NiceIcon,{name:"arrow-right",size:12})}),E&&e.jsx("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:E})]})]}),e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",gap:12,fontSize:12},children:[e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",U.additions]}),e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",U.deletions]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:a.map(s=>{const t=T(s.status),x=s.path===J;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>te(s.path),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",cursor:"pointer",background:x?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderLeft:x?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent"},children:[e.jsx("span",{style:{width:16,height:16,borderRadius:2,background:t.color,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,color:"var(--nice-color-white, #fff)",fontWeight:600},children:t.icon}),e.jsx("span",{style:{flex:1,fontSize:12,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.path.split("/").pop()}),e.jsxs("div",{style:{display:"flex",gap:4,fontSize:10},children:[s.additions>0&&e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",s.additions]}),s.deletions>0&&e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",s.deletions]})]})]},s.path)})})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",display:"flex",alignItems:"center",gap:16},children:[G&&e.jsx("div",{style:{flex:1,fontSize:13,fontFamily:"monospace"},children:G.oldPath&&G.oldPath!==G.path?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:G.oldPath}),e.jsx("span",{style:{margin:"0 8px",color:"var(--nice-text-muted, #888)"},children:e.jsx(n.NiceIcon,{name:"arrow-right",size:12})}),e.jsx("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:G.path})]}):G.path}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{onClick:()=>g("unified"),style:{padding:"6px 12px",borderRadius:4,border:"none",background:A==="unified"?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:A==="unified"?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:C("gitDiffViewer.unified","Unified")}),e.jsx("button",{onClick:()=>g("split"),style:{padding:"6px 12px",borderRadius:4,border:"none",background:A==="split"?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:A==="split"?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11},children:C("gitDiffViewer.split","Split")})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--nice-text-muted, #888)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:Z,onChange:s=>b(s.target.checked)}),C("gitDiffViewer.showWhitespace","Show whitespace")]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:G?G.binary?e.jsxs("div",{style:{padding:40,textAlign:"center",color:"var(--nice-text-muted, #888)"},children:[e.jsx(n.NiceIcon,{name:"box",size:48}),e.jsx("p",{children:C("gitDiffViewer.binaryFileCannotBeDisplayed","Binary file cannot be displayed")})]}):A==="split"?q(G):$(G):e.jsx("div",{style:{padding:40,textAlign:"center",color:"var(--nice-text-muted, #666)"},children:C("gitDiffViewer.selectAFileToView","Select a file to view changes")})}),h.length>0&&e.jsxs("div",{style:{borderTop:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)",maxHeight:200,overflow:"auto"},children:[e.jsx("div",{style:{padding:"8px 16px",fontSize:12,fontWeight:600,borderBottom:"1px solid var(--nice-border-color, #333)"},children:C("gitDiffViewer.comments","Comments ({fileComments})").replace("{fileComments}",String(h.length))}),h.map(s=>e.jsxs("div",{style:{padding:12,borderBottom:"1px solid var(--nice-border-color, #333)",opacity:s.resolved?.5:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[s.author.avatar?e.jsx("img",{src:s.author.avatar,alt:"",style:{width:20,height:20,borderRadius:"50%"}}):e.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"var(--nice-bg-tertiary, #666)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10},children:s.author.name[0]}),e.jsx("span",{style:{fontSize:12,fontWeight:500},children:s.author.name}),e.jsx("span",{style:{fontSize:10,color:"var(--nice-text-muted, #888)"},children:(s.side==="old"?C("gitDiffViewer.lineOld","Line {line} (old)"):C("gitDiffViewer.lineNew","Line {line} (new)")).replace("{line}",String(s.line))}),s.resolved&&e.jsx("span",{style:{padding:"2px 6px",borderRadius:4,fontSize:10,background:"var(--nice-success-tint-15, #22c55e22)",color:"var(--nice-color-success, #22c55e)"},children:C("gitDiffViewer.resolved","Resolved")}),z&&!s.resolved&&e.jsx("button",{onClick:()=>z(s.id),style:{marginLeft:"auto",padding:"4px 8px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-muted, #888)",cursor:"pointer",fontSize:10},children:C("gitDiffViewer.resolve","Resolve")})]}),e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-secondary, #ccc)"},children:s.body})]},s.id))]}),l&&e.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>V(null),children:e.jsxs("div",{role:"presentation",style:{width:400,background:"var(--nice-bg-elevated, #252525)",borderRadius:8,padding:20},onClick:s=>s.stopPropagation(),children:[e.jsx("h3",{style:{margin:"0 0 12px",fontSize:14},children:C("gitDiffViewer.addCommentOnLine","Add comment on line {line}").replace("{line}",String(l.line))}),e.jsx("textarea",{value:l.body,onChange:s=>V({...l,body:s.target.value}),placeholder:C("gitDiffViewer.writeAComment","Write a comment..."),rows:4,style:{width:"100%",padding:12,borderRadius:6,border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:13,resize:"vertical"},autoFocus:!0}),e.jsxs("div",{style:{marginTop:12,display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>V(null),style:{padding:"8px 16px",borderRadius:4,border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:12},children:C("gitDiffViewer.cancel","Cancel")}),e.jsx("button",{onClick:()=>{l.body.trim()&&(P?.(l.filePath,l.line,l.side,l.body.trim()),V(null))},disabled:!l.body.trim(),style:{padding:"8px 16px",borderRadius:4,border:"none",background:l.body.trim()?"var(--nice-color-primary, #3b82f6)":"var(--nice-bg-tertiary, #333)",color:l.body.trim()?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:l.body.trim()?"pointer":"not-allowed",fontSize:12,fontWeight:500},children:C("gitDiffViewer.addComment2","Add Comment")})]})]})})]})]})},it=Object.freeze(Object.defineProperty({__proto__:null,NiceGitDiffViewer:Ee},Symbol.toStringTag,{value:"Module"})),ot=(a,f)=>{const B=new Date().getTime()-a.getTime(),_=Math.floor(B/(1e3*60*60*24));return _===0?"today":_===1?"yesterday":_<7?`${_} days ago`:_<30?`${Math.floor(_/7)} weeks ago`:_<365?`${Math.floor(_/30)} months ago`:`${Math.floor(_/365)} years ago`},st=a=>{const w=new Date().getTime()-a.getTime(),B=Math.floor(w/(1e3*60*60*24));return B<7?"var(--nice-primary-tint-30, rgba(59, 130, 246, 0.3))":B<30?"var(--nice-success-tint-30, rgba(34, 197, 94, 0.3))":B<90?"var(--nice-warning-tint-30, rgba(234, 179, 8, 0.3))":B<365?"var(--nice-warning-tint-30, rgba(249, 115, 22, 0.3))":"var(--nice-danger-tint-30, rgba(239, 68, 68, 0.3))"},ce=a=>{const f=["var(--nice-color-primary, #3b82f6)","var(--nice-color-success, #22c55e)","var(--nice-color-warning, #f59e0b)","var(--nice-color-error, #ef4444)","var(--nice-color-accent, #8b5cf6)","var(--nice-color-info, #06b6d4)","var(--nice-color-accent-pink, #ec4899)","var(--nice-info, #14b8a6)","var(--nice-warning, #f97316)","var(--nice-color-accent, #6366f1)"];let w=0;for(let B=0;B<a.length;B++)w=(w<<5)-w+a.charCodeAt(B),w=w&w;return f[Math.abs(w)%f.length]},Te=({file:a,viewMode:f="inline",showAgeHeatmap:w=!0,showAvatars:B=!0,groupHunks:_=!0,highlightOnHover:W=!0,timeZone:L,dateRange:D,authorFilter:E,selectedLine:N,syntaxTheme:j="dark",onLineClick:P,onCommitClick:z,onAuthorClick:k,onBlameParent:S,className:v,style:M,"data-testid":C="nice-git-blame"})=>{const{t:i}=n.useNiceTranslation(),[I,O]=o.useState(null),[b,Y]=o.useState(null),[F,H]=o.useState(null),c=o.useMemo(()=>{const p=[];return a.hunks.forEach(h=>{h.lines.forEach(T=>{p.push(T)})}),p.sort((h,T)=>h.lineNumber-T.lineNumber)},[a.hunks]),l=o.useMemo(()=>c.filter(p=>!(D?.from&&p.commit.timestamp<D.from||D?.to&&p.commit.timestamp>D.to||E&&E.length>0&&!E.includes(p.commit.author.id))),[c,D,E]),V=o.useMemo(()=>{if(!_)return l.map(d=>({startLine:d.lineNumber,endLine:d.lineNumber,commit:d.commit,lines:[d],isFirstOfCommit:!0}));const p=[];let h=null;const T=new Set;return l.forEach(d=>{if(!h||h.commit.id!==d.commit.id){const $=!T.has(d.commit.id);T.add(d.commit.id),h={startLine:d.lineNumber,endLine:d.lineNumber,commit:d.commit,lines:[d],isFirstOfCommit:$},p.push(h)}else h.endLine=d.lineNumber,h.lines.push(d)}),p},[l,_]),A=o.useMemo(()=>{const p=new Map;return c.forEach(h=>{p.has(h.commit.author.id)||p.set(h.commit.author.id,h.commit.author)}),Array.from(p.values())},[c]),Z=o.useMemo(()=>{const p=new Map;return c.forEach(h=>{p.has(h.commit.id)||p.set(h.commit.id,h.commit)}),Array.from(p.values()).sort((h,T)=>T.timestamp.getTime()-h.timestamp.getTime())},[c]),J=o.useCallback(p=>{P?.(p)},[P]),G=o.useCallback((p,h)=>{h.stopPropagation(),b===p.id?Y(null):Y(p.id),z?.(p)},[b,z]),U=(p,h)=>{const T=h===0,d=p.commit,$=W&&I===d.id;return e.jsxs("div",{role:T?"button":void 0,tabIndex:T?0:void 0,onKeyDown:T?n.clickOnActivationKey:void 0,style:{display:"flex",alignItems:"center",gap:8,padding:"0 12px",minWidth:f==="inline"?280:40,background:$?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":w?st(d.timestamp):"transparent",borderRight:`3px solid ${ce(d.author.id)}`,cursor:"pointer",transition:"background 0.15s"},onMouseEnter:()=>O(d.id),onMouseLeave:()=>O(null),onClick:q=>G(d,q),children:[T&&f==="inline"&&e.jsxs(e.Fragment,{children:[B&&e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:ce(d.author.id),display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,color:"var(--nice-text-primary, #0f172a)",fontWeight:500,flexShrink:0},title:d.author.name,children:d.author.avatar?e.jsx("img",{src:d.author.avatar,alt:d.author.name,style:{width:"100%",height:"100%",borderRadius:"50%"}}):d.author.name[0].toUpperCase()}),e.jsxs("div",{style:{flex:1,minWidth:0,overflow:"hidden"},children:[e.jsx("div",{style:{fontSize:11,fontFamily:"monospace",color:"var(--nice-text-muted, #6b7280)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d.shortId}),e.jsx("div",{style:{fontSize:10,color:"var(--nice-text-muted, #9ca3af)",whiteSpace:"nowrap"},children:ot(d.timestamp)})]})]}),f==="gutter"&&T&&e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:ce(d.author.id),display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,color:"var(--nice-text-primary, #0f172a)"},title:`${d.author.name} - ${d.shortId}
2
2
  ${d.message}`,children:d.author.name[0].toUpperCase()})]})},te=p=>{if(F!==p.lineNumber||f!=="tooltip")return null;const h=p.commit;return e.jsxs("div",{style:{position:"absolute",left:60,top:-8,zIndex:100,background:"var(--nice-bg-elevated, #ffffff)",border:"1px solid var(--nice-border-color, #e2e8f0)",borderRadius:8,padding:12,boxShadow:"0 4px 12px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))",minWidth:320},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:ce(h.author.id),display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-primary, #0f172a)",fontWeight:500},children:h.author.name[0].toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,color:"var(--nice-text-secondary, #475569)"},children:h.author.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #9ca3af)"},children:h.author.email})]})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:12,color:"var(--nice-color-primary-light, #60a5fa)",marginBottom:4},children:h.shortId}),e.jsx("div",{style:{fontSize:13,color:"var(--nice-text-secondary, #475569)",marginBottom:8},children:h.message}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #6b7280)"},children:h.timestamp.toLocaleString()}),h.parents&&h.parents.length>0&&S&&e.jsxs("button",{onClick:()=>S(h),style:{marginTop:8,padding:"4px 8px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:4,color:"var(--nice-text-secondary, #475569)",fontSize:11,cursor:"pointer"},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:11})," ",i("gitBlame.blameParent","Blame parent")]})]})},g=p=>b!==p.id?null:e.jsx("div",{style:{background:"var(--nice-bg-elevated, #ffffff)",borderBottom:"1px solid var(--nice-border-color, #e2e8f0)",padding:16},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{width:48,height:48,borderRadius:"50%",background:ce(p.author.id),display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-primary, #0f172a)",fontSize:20,fontWeight:500,flexShrink:0},children:p.author.name[0].toUpperCase()}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--nice-text-secondary, #475569)"},children:p.author.name}),e.jsx("span",{style:{fontSize:11,color:"var(--nice-text-muted, #6b7280)"},children:p.author.email})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13,color:"var(--nice-color-primary-light, #60a5fa)",marginBottom:8},children:p.id}),e.jsx("div",{style:{fontSize:14,color:"var(--nice-text-secondary, #475569)",marginBottom:8,lineHeight:1.5},children:p.message}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,fontSize:12,color:"var(--nice-text-muted, #9ca3af)"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(n.NiceIcon,{name:"calendar",size:12})," ",p.timestamp.toLocaleString()]}),p.parents&&p.parents.length>0&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[e.jsx(n.NiceIcon,{name:"cursor",size:12})," ",i("gitBlame.parentS","{parents} parent(s)").replace("{parents}",String(p.parents.length))]})]}),S&&p.parents&&p.parents.length>0&&e.jsxs("button",{onClick:()=>S(p),style:{marginTop:12,padding:"6px 12px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",fontSize:12,cursor:"pointer"},children:[e.jsx(n.NiceIcon,{name:"arrow-up",size:12})," ",i("gitBlame.blameInParentCommit","Blame in parent commit")]})]})]})});return e.jsxs("div",{className:`nice-git-blame ${v||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:j==="dark"?"var(--nice-bg-canvas, #0d1117)":"var(--nice-bg-primary, #ffffff)",color:j==="dark"?"var(--nice-text-primary, #e6edf3)":"var(--nice-text-primary, #ffffff)",fontFamily:"system-ui, sans-serif",...M},"data-testid":C,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:j==="dark"?"var(--nice-bg-elevated, #161b22)":"var(--nice-bg-secondary, #f6f8fa)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:"clipboard",size:16}),e.jsx("span",{style:{fontWeight:500},children:a.path}),e.jsx("span",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:i("gitBlame.at","at {revision}").replace("{revision}",String(a.revision.substring(0,7)))})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:e.jsx("span",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:i("gitBlame.commitsByAuthorS","{commits} commits by {authors} author(s)").replace("{commits}",String(Z.length)).replace("{authors}",String(A.length))})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"8px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:j==="dark"?"var(--nice-bg-elevated, #161b22)":"var(--nice-bg-secondary, #f6f8fa)",flexWrap:"wrap"},children:[A.slice(0,10).map(p=>e.jsxs("div",{role:k?"button":void 0,tabIndex:k?0:void 0,onKeyDown:k?n.clickOnActivationKey:void 0,onClick:()=>k?.(p),style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[e.jsx("div",{style:{width:12,height:12,borderRadius:"50%",background:ce(p.id)}}),e.jsx("span",{style:{fontSize:12},children:p.name})]},p.id)),A.length>10&&e.jsx("span",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:i("gitBlame.more","+{authors} more").replace("{authors}",String(A.length-10))})]}),e.jsx("div",{style:{flex:1,overflow:"auto",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",fontSize:13,lineHeight:"20px"},children:V.map((p,h)=>e.jsxs(o.Fragment,{children:[p.isFirstOfCommit&&b===p.commit.id&&g(p.commit),p.lines.map((T,d)=>e.jsxs("div",{role:"presentation",onClick:()=>J(T),onMouseEnter:()=>H(T.lineNumber),onMouseLeave:()=>H(null),style:{display:"flex",alignItems:"stretch",background:N===T.lineNumber?"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))":W&&I===p.commit.id?"var(--nice-primary-tint-8, rgba(59, 130, 246, 0.08))":"transparent",borderLeft:N===T.lineNumber?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",position:"relative"},children:[U(p,d),e.jsx("div",{style:{padding:"0 12px",color:"var(--nice-text-muted, #6e7681)",textAlign:"right",minWidth:50,userSelect:"none",background:j==="dark"?"var(--nice-bg-canvas, #0d1117)":"var(--nice-bg-secondary, #f6f8fa)",borderRight:"1px solid var(--nice-border, #30363d)"},children:T.lineNumber}),e.jsx("div",{style:{flex:1,padding:"0 16px",whiteSpace:"pre",overflow:"hidden",textOverflow:"ellipsis"},children:T.content}),f==="tooltip"&&te(T)]},T.lineNumber))]},`${p.commit.id}-${p.startLine}`))}),w&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:16,padding:"8px 16px",borderTop:"1px solid var(--nice-border, #30363d)",background:j==="dark"?"var(--nice-bg-elevated, #161b22)":"var(--nice-bg-secondary, #f6f8fa)",fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:[e.jsx("span",{children:i("gitBlame.age","Age:")}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:16,background:"var(--nice-primary-tint-30, rgba(59, 130, 246, 0.3))",borderRadius:2}}),e.jsx("span",{children:i("gitBlame.n1Week","<1 week")})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:16,background:"var(--nice-success-tint-30, rgba(34, 197, 94, 0.3))",borderRadius:2}}),e.jsx("span",{children:i("gitBlame.n1Month","<1 month")})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:16,background:"var(--nice-warning-tint-30, rgba(234, 179, 8, 0.3))",borderRadius:2}}),e.jsx("span",{children:i("gitBlame.n3Months","<3 months")})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:16,background:"var(--nice-warning-tint-30, rgba(249, 115, 22, 0.3))",borderRadius:2}}),e.jsx("span",{children:i("gitBlame.n1Year","<1 year")})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("div",{style:{width:16,height:16,background:"var(--nice-danger-tint-30, rgba(239, 68, 68, 0.3))",borderRadius:2}}),e.jsx("span",{children:i("gitBlame.n1Year2",">1 year")})]})]})]})},at=Object.freeze(Object.defineProperty({__proto__:null,NiceGitBlame:Te},Symbol.toStringTag,{value:"Module"})),lt=a=>{if(!a.resolved)return[];switch(a.resolution){case"ours":return a.oursContent;case"theirs":return a.theirsContent;case"both":return[...a.oursContent,...a.theirsContent];case"custom":return a.customContent||[];default:return[]}},_e=({file:a,context:f,viewMode:w="split",showLineNumbers:B=!0,showBase:_=!1,currentConflictIndex:W,syntaxTheme:L="dark",onResolve:D,onResolveAll:E,onNavigateConflict:N,onSave:j,onCancel:P,className:z,style:k,"data-testid":S="nice-git-conflict-resolver"})=>{const{t:v}=n.useNiceTranslation(),[M,C]=o.useState(a.conflicts),[i,I]=o.useState(W??0),[O,b]=o.useState(null),[Y,F]=o.useState(""),H=o.useMemo(()=>M.filter(d=>!d.resolved).length,[M]),c=o.useMemo(()=>M.filter(d=>d.resolved).length,[M]),l=M[i],V=o.useCallback((d,$,q)=>{C(t=>t.map(x=>x.id===d?{...x,resolved:!0,resolution:$,customContent:q}:x)),b(null),D?.(d,$,q);const s=M.findIndex((t,x)=>x>i&&!t.resolved);s!==-1&&(I(s),N?.(s))},[M,i,D,N]),A=o.useCallback(d=>{C($=>$.map(q=>q.resolved?q:{...q,resolved:!0,resolution:d})),E?.(d)},[E]),Z=o.useCallback(d=>{const $=d==="prev"?Math.max(0,i-1):Math.min(M.length-1,i+1);I($),N?.($)},[i,M.length,N]),J=o.useCallback(()=>{l&&(b(l.id),F(l.oursContent.join(`
3
3
  `)))},[l]),G=o.useCallback(()=>{O&&V(O,"custom",Y.split(`
4
4
  `))},[O,Y,V]),U=o.useCallback(()=>{const d=a.content.split(`
@@ -7,7 +7,7 @@ ${d.message}`,children:d.author.name[0].toUpperCase()})]})},te=p=>{if(F!==p.line
7
7
  `)})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 12px",background:"var(--nice-bg-elevated, #ffffff)"},children:[e.jsx("div",{style:{flex:1,height:1,background:"var(--nice-border-color, #e2e8f0)"}}),e.jsx("span",{style:{color:"var(--nice-text-muted, #9ca3af)",fontSize:11},children:v("gitConflictResolver.vs","VS")}),e.jsx("div",{style:{flex:1,height:1,background:"var(--nice-border-color, #e2e8f0)"}})]}),e.jsxs("div",{style:{background:"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))",borderLeft:"3px solid var(--nice-primary, #3b82f6)"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:"1px solid var(--nice-border, #30363d)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontSize:12,color:"var(--nice-color-primary, #3b82f6)",fontWeight:500},children:[e.jsx(n.NiceIcon,{name:"arrow-right",size:14})," ",v("gitConflictResolver.theirsBranch","Theirs ({branch})").replace("{branch}",f?.theirsCommit.branch||"incoming")]}),e.jsx("button",{onClick:()=>V(l.id,"theirs"),style:{padding:"4px 10px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:4,color:"var(--nice-text-on-primary, #fff)",fontSize:11,cursor:"pointer"},children:v("gitConflictResolver.acceptTheirs","Accept Theirs")})]}),e.jsx("pre",{style:{margin:0,padding:12,fontFamily:"monospace",fontSize:13},children:l.theirsContent.join(`
8
8
  `)})]})]}):null,p=()=>l?e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[te(e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"arrow-left",size:14})," ",v("gitConflictResolver.oursBranch","Ours ({branch})").replace("{branch}",f?.oursCommit.branch||"HEAD")]}),l.oursContent,"var(--nice-color-success, #22c55e)",()=>V(l.id,"ours")),_&&te(v("gitConflictResolver.baseAncestor","Base (ancestor)"),l.baseContent,"var(--nice-text-muted, #6b7280)"),te(e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"arrow-right",size:14})," ",v("gitConflictResolver.theirsBranch","Theirs ({branch})").replace("{branch}",f?.theirsCommit.branch||"incoming")]}),l.theirsContent,"var(--nice-color-primary, #3b82f6)",()=>V(l.id,"theirs"))]}):null,h=()=>l?e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[te(e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"arrow-left",size:14})," ",v("gitConflictResolver.oursBranch","Ours ({branch})").replace("{branch}",f?.oursCommit.branch||"HEAD")]}),l.oursContent,"var(--nice-color-success, #22c55e)",()=>V(l.id,"ours")),te(v("gitConflictResolver.base","Base"),l.baseContent,"var(--nice-text-muted, #6b7280)"),te(e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"arrow-right",size:14})," ",v("gitConflictResolver.theirsBranch","Theirs ({branch})").replace("{branch}",f?.theirsCommit.branch||"incoming")]}),l.theirsContent,"var(--nice-color-primary, #3b82f6)",()=>V(l.id,"theirs"))]}):null,T=()=>O!==l?.id?null:e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,background:"var(--nice-overlay-80, rgba(0, 0, 0, 0.8))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:e.jsxs("div",{style:{width:"80%",maxWidth:800,background:"var(--nice-bg-elevated, #ffffff)",borderRadius:8,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border-color, #e2e8f0)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,fontWeight:500},children:[e.jsx(n.NiceIcon,{name:"edit",size:14})," ",v("gitConflictResolver.editResolution","Edit Resolution")]}),e.jsx("button",{onClick:()=>b(null),"aria-label":v("gitConflictResolver.closeEditor","Close editor"),style:{background:"transparent",border:"none",color:"var(--nice-text-muted, #9ca3af)",cursor:"pointer",fontSize:18},children:e.jsx(n.NiceIcon,{name:"close",size:18})})]}),e.jsx("textarea",{value:Y,onChange:d=>F(d.target.value),style:{width:"100%",height:300,padding:16,fontFamily:"monospace",fontSize:13,background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",border:"none",resize:"none"}}),e.jsxs("div",{style:{padding:16,borderTop:"1px solid var(--nice-border-color, #e2e8f0)",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:()=>b(null),style:{padding:"8px 16px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},children:v("gitConflictResolver.cancel","Cancel")}),e.jsx("button",{onClick:G,style:{padding:"8px 16px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer"},children:v("gitConflictResolver.saveChanges","Save Changes")})]})]})});return e.jsxs("div",{className:`nice-git-conflict-resolver ${z||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:L==="dark"?"var(--nice-bg-canvas, #0d1117)":"var(--nice-bg-primary, #ffffff)",color:L==="dark"?"var(--nice-text-primary, #e6edf3)":"var(--nice-text-primary, #ffffff)",fontFamily:"system-ui, sans-serif",position:"relative",...k},"data-testid":S,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:L==="dark"?"var(--nice-bg-elevated, #161b22)":"var(--nice-bg-secondary, #f6f8fa)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:"warning",size:18}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:a.path}),e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:v("gitConflictResolver.conflictSResolvedRemaining","{conflicts} conflict(s) • {resolvedCount} resolved • {unresolvedCount} remaining").replace("{conflicts}",String(M.length)).replace("{resolvedCount}",String(c)).replace("{unresolvedCount}",String(H))})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("button",{onClick:P,style:{padding:"6px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},children:v("gitConflictResolver.cancel","Cancel")}),e.jsxs("button",{onClick:U,disabled:H>0,style:{padding:"6px 12px",background:H>0?"var(--nice-bg-tertiary, #e2e8f0)":"var(--nice-color-success, #22c55e)",border:"none",borderRadius:6,color:H>0?"var(--nice-text-muted, #94a3b8)":"var(--nice-color-white, #fff)",cursor:H>0?"not-allowed":"pointer",opacity:H>0?.5:1,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"check",size:14})," ",v("gitConflictResolver.saveResolved","Save Resolved")]})]})]}),f&&e.jsxs("div",{style:{display:"flex",gap:24,padding:"8px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:L==="dark"?"var(--nice-bg-elevated, #161b22)":"var(--nice-bg-secondary, #f6f8fa)",fontSize:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:[e.jsx(n.NiceIcon,{name:"arrow-left",size:14})," ",v("gitConflictResolver.oursLabel","Ours:")]}),e.jsx("span",{children:f.oursCommit.branch}),e.jsxs("span",{style:{color:"var(--nice-text-muted, #8b949e)",fontFamily:"monospace"},children:["(",f.oursCommit.shortId,")"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{color:"var(--nice-color-primary, #3b82f6)"},children:[e.jsx(n.NiceIcon,{name:"arrow-right",size:14})," ",v("gitConflictResolver.theirsLabel","Theirs:")]}),e.jsx("span",{children:f.theirsCommit.branch}),e.jsxs("span",{style:{color:"var(--nice-text-muted, #8b949e)",fontFamily:"monospace"},children:["(",f.theirsCommit.shortId,")"]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",background:L==="dark"?"var(--nice-bg-elevated, #ffffff)":"var(--nice-bg-secondary, #f0f0f0)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("button",{onClick:()=>Z("prev"),disabled:i===0,style:{padding:"4px 8px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:4,color:"var(--nice-text-primary, #0f172a)",cursor:i===0?"not-allowed":"pointer",opacity:i===0?.5:1},children:[e.jsx(n.NiceIcon,{name:"arrow-left",size:14})," ",v("gitConflictResolver.prev","Prev")]}),e.jsxs("span",{style:{padding:"0 8px"},children:[v("gitConflictResolver.conflictOf","Conflict {current} of {total}").replace("{current}",String(i+1)).replace("{total}",String(M.length)),l?.resolved&&e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,marginLeft:8,color:"var(--nice-color-success, #22c55e)"},children:[e.jsx(n.NiceIcon,{name:"check",size:14})," ",v("gitConflictResolver.resolved","Resolved")]})]}),e.jsxs("button",{onClick:()=>Z("next"),disabled:i===M.length-1,style:{padding:"4px 8px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:4,color:"var(--nice-text-primary, #0f172a)",cursor:i===M.length-1?"not-allowed":"pointer",opacity:i===M.length-1?.5:1},children:[v("gitConflictResolver.next","Next")," ",e.jsx(n.NiceIcon,{name:"arrow-right",size:14})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("button",{onClick:()=>A("ours"),disabled:H===0,style:{padding:"4px 10px",background:"var(--nice-color-success, #22c55e)",border:"none",borderRadius:4,color:"var(--nice-text-on-primary, #fff)",fontSize:11,cursor:H===0?"not-allowed":"pointer",opacity:H===0?.5:1},children:v("gitConflictResolver.acceptAllOurs","Accept All Ours")}),e.jsx("button",{onClick:()=>A("theirs"),disabled:H===0,style:{padding:"4px 10px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:4,color:"var(--nice-text-on-primary, #fff)",fontSize:11,cursor:H===0?"not-allowed":"pointer",opacity:H===0?.5:1},children:v("gitConflictResolver.acceptAllTheirs","Accept All Theirs")})]})]}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:[l&&!l.resolved&&e.jsxs(e.Fragment,{children:[w==="inline"&&g(),w==="split"&&p(),w==="three-way"&&h()]}),l?.resolved&&e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,color:"var(--nice-color-success, #22c55e)"},children:[e.jsx(n.NiceIcon,{name:"check",size:48}),e.jsx("span",{style:{fontSize:18},children:v("gitConflictResolver.conflictResolved","Conflict Resolved")}),e.jsx("span",{style:{color:"var(--nice-text-muted, #8b949e)",fontSize:13},children:v("gitConflictResolver.resolution","Resolution: {resolution}").replace("{resolution}",String(l.resolution??""))}),e.jsxs("button",{onClick:()=>C(d=>d.map($=>$.id===l.id?{...$,resolved:!1,resolution:void 0}:$)),style:{padding:"8px 16px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"reply",size:14})," ",v("gitConflictResolver.reResolve","Re-resolve")]})]})]}),l&&!l.resolved&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:12,padding:"12px 16px",borderTop:"1px solid var(--nice-border, #30363d)",background:L==="dark"?"var(--nice-bg-elevated, #161b22)":"var(--nice-bg-secondary, #f6f8fa)"},children:[e.jsxs("button",{onClick:()=>V(l.id,"ours"),style:{padding:"8px 20px",background:"var(--nice-color-success, #22c55e)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"check",size:14})," ",v("gitConflictResolver.acceptOurs","Accept Ours")]}),e.jsxs("button",{onClick:()=>V(l.id,"theirs"),style:{padding:"8px 20px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"check",size:14})," ",v("gitConflictResolver.acceptTheirs","Accept Theirs")]}),e.jsxs("button",{onClick:()=>V(l.id,"both"),style:{padding:"8px 20px",background:"var(--nice-color-accent, #8b5cf6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:14})," ",v("gitConflictResolver.acceptBoth","Accept Both")]}),e.jsxs("button",{onClick:J,style:{padding:"8px 20px",background:"var(--nice-color-warning, #f59e0b)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"edit",size:14})," ",v("gitConflictResolver.editManually","Edit Manually")]})]}),T()]})},ct=Object.freeze(Object.defineProperty({__proto__:null,NiceGitConflictResolver:_e},Symbol.toStringTag,{value:"Module"})),fe={"pre-commit":{title:"Pre-commit",description:"Runs before commit is created. Good for linting and formatting.",icon:"check"},"prepare-commit-msg":{title:"Prepare Commit Message",description:"Runs before commit message editor opens. Can modify default message.",icon:"edit"},"commit-msg":{title:"Commit Message",description:"Validates commit message format (e.g., conventional commits).",icon:"message"},"post-commit":{title:"Post-commit",description:"Runs after commit is created. Good for notifications.",icon:"upload"},"pre-push":{title:"Pre-push",description:"Runs before push. Good for running tests.",icon:"rocket"},"pre-rebase":{title:"Pre-rebase",description:"Runs before rebase starts.",icon:"shuffle"},"post-merge":{title:"Post-merge",description:"Runs after merge completes. Good for dependency updates.",icon:"link"},"post-checkout":{title:"Post-checkout",description:"Runs after checkout completes.",icon:"download"},"pre-auto-gc":{title:"Pre-auto GC",description:"Runs before automatic garbage collection.",icon:"trash"}},dt=[{id:"eslint-staged",name:"ESLint (staged files)",description:"Run ESLint on staged JavaScript/TypeScript files",icon:"search",category:"lint",hook:"pre-commit",actions:[{type:"lint",name:"ESLint",command:"npx eslint --fix",runOn:"staged",filePatterns:["*.js","*.jsx","*.ts","*.tsx"],enabled:!0,failOnError:!0}]},{id:"prettier-staged",name:"Prettier (staged files)",description:"Format staged files with Prettier",icon:"edit",category:"lint",hook:"pre-commit",actions:[{type:"format",name:"Prettier",command:"npx prettier --write",runOn:"staged",filePatterns:["*.js","*.jsx","*.ts","*.tsx","*.css","*.json","*.md"],enabled:!0,failOnError:!1}]},{id:"jest-tests",name:"Jest Tests",description:"Run Jest tests before push",icon:"flask",category:"test",hook:"pre-push",actions:[{type:"test",name:"Jest",command:"npm test",runOn:"all",enabled:!0,failOnError:!0}]},{id:"typecheck",name:"TypeScript Check",description:"Run TypeScript compiler check",icon:"book",category:"quality",hook:"pre-commit",actions:[{type:"typecheck",name:"tsc",command:"npx tsc --noEmit",runOn:"all",enabled:!0,failOnError:!0}]},{id:"conventional-commits",name:"Conventional Commits",description:"Validate commit message format",icon:"clipboard",category:"quality",hook:"commit-msg",actions:[{type:"custom",name:"Commitlint",command:"npx commitlint --edit $1",enabled:!0,failOnError:!0}]},{id:"secrets-scan",name:"Secret Detection",description:"Scan for accidentally committed secrets",icon:"lock",category:"security",hook:"pre-commit",actions:[{type:"custom",name:"Detect Secrets",command:"npx secretlint",runOn:"staged",enabled:!0,failOnError:!0}]}],Ae=({hooks:a,defaultHooks:f,templates:w=dt,manager:B="husky",repoPath:_,selectedHook:W,onHookChange:L,onHooksChange:D,onHookToggle:E,onActionAdd:N,onActionRemove:j,onActionUpdate:P,onInstall:z,onUninstall:k,onExport:S,className:v,style:M,"data-testid":C="nice-git-hooks"})=>{const{t:i}=n.useNiceTranslation(),I=a!==void 0&&D!==void 0,O=o.useRef([]),b=o.useCallback(t=>{const x=O.current;O.current=t,L&&t.filter(u=>!x.includes(u)).forEach(u=>L(u)),D?.(t)},[L,D]),[Y,F]=n.useControllableState({value:I?a:void 0,defaultValue:I?f:f??a,fallbackValue:[],onChange:b,componentName:"NiceGitHooks"});O.current=Y,we("NiceGitHooks","hooks","onHooksChange",a,I);const[H,c]=o.useState(W||null),[l,V]=o.useState(!1),[A,Z]=o.useState(null),[J,G]=o.useState(!1),U=o.useMemo(()=>Y.find(t=>t.type===H),[Y,H]),te=o.useCallback((t,x)=>{F(u=>u.map(R=>R.type===t?{...R,enabled:x}:R)),E?.(t,x)},[E,F]),g=o.useCallback(t=>{if(!H)return;const x=t?t.actions.map((u,R)=>({...u,id:n.createId(),order:(U?.actions.length||0)+R})):[{id:n.createId(),type:"custom",name:"New Action",command:'echo "Hello"',order:U?.actions.length||0,enabled:!0,failOnError:!0}];F(u=>u.map(R=>R.type===H?{...R,actions:[...R.actions,...x]}:R)),x.forEach(u=>N?.(H,u)),V(!1)},[H,U,N,F]),p=o.useCallback(t=>{H&&(F(x=>x.map(u=>u.type===H?{...u,actions:u.actions.filter(R=>R.id!==t)}:u)),j?.(H,t))},[H,j,F]),h=o.useCallback(t=>{H&&(F(x=>x.map(u=>u.type===H?{...u,actions:u.actions.map(R=>R.id===t.id?t:R)}:u)),Z(null),P?.(H,t))},[H,P,F]),T=o.useCallback((t,x)=>{if(!U)return;const u=[...U.actions],R=u.findIndex(X=>X.id===t);if(R===-1)return;const ee=x==="up"?R-1:R+1;ee<0||ee>=u.length||([u[R],u[ee]]=[u[ee],u[R]],u.forEach((X,m)=>X.order=m),F(X=>X.map(m=>m.type===H?{...m,actions:u}:m)))},[U,H,F]),d=o.useCallback(t=>{const x=["#!/bin/sh",""];return t.verbose&&x.push("set -x"),x.push("# Generated by NiceGitHooks",`# Hook: ${t.type}`,""),t.actions.forEach(u=>{if(!u.enabled){x.push(`# [DISABLED] ${u.name}`);return}if(x.push(`# ${u.name}`),u.condition){const{type:ee,operator:X,value:m}=u.condition;ee==="branch"?(x.push("BRANCH=$(git rev-parse --abbrev-ref HEAD)"),X==="equals"?x.push(`if [ "$BRANCH" != "${m}" ]; then exit 0; fi`):X==="matches"&&x.push(`if ! echo "$BRANCH" | grep -q "${m}"; then exit 0; fi`)):ee==="env"&&x.push(`if [ -z "$${m}" ]; then exit 0; fi`)}let R=u.command;u.runOn==="staged"&&u.filePatterns?.length&&(u.filePatterns.map(ee=>`'${ee}'`).join(" "),R=`git diff --cached --name-only --diff-filter=ACM | grep -E "${u.filePatterns.join("|")}" | xargs ${R}`),x.push(R),u.failOnError&&(x.push("if [ $? -ne 0 ]; then"),x.push(` echo "❌ ${u.name} failed""`),x.push(" exit 1"),x.push("fi")),x.push("")}),x.push("exit 0"),x.join(`
9
9
  `)},[]),$=t=>({lint:"search",test:"flask",format:"edit",typecheck:"book",build:"settings",custom:"settings"})[t],q=()=>A?e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"var(--nice-overlay-80, rgba(0, 0, 0, 0.8))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:e.jsxs("div",{style:{width:"90%",maxWidth:600,background:"var(--nice-bg-elevated, #ffffff)",borderRadius:12,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--nice-border-color, #e2e8f0)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontWeight:500,fontSize:16,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"edit",size:16})," ",i("gitHooks.editAction","Edit Action")]}),e.jsx("button",{onClick:()=>Z(null),"aria-label":i("gitHooks.close","Close"),style:{background:"none",border:"none",color:"var(--nice-text-muted, #9ca3af)",cursor:"pointer",fontSize:20},children:e.jsx(n.NiceIcon,{name:"close",size:18})})]}),e.jsxs("div",{style:{padding:20,display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #9ca3af)",marginBottom:4},children:i("gitHooks.name","Name")}),e.jsx("input",{type:"text",value:A.name,onChange:t=>Z({...A,name:t.target.value}),style:{width:"100%",padding:"8px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"1px solid var(--nice-border-color, #cbd5e1)",borderRadius:6,color:"var(--nice-text-primary, #0f172a)"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #9ca3af)",marginBottom:4},children:i("gitHooks.type","Type")}),e.jsxs("select",{value:A.type,onChange:t=>Z({...A,type:t.target.value}),style:{width:"100%",padding:"8px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"1px solid var(--nice-border-color, #cbd5e1)",borderRadius:6,color:"var(--nice-text-primary, #0f172a)"},children:[e.jsx("option",{value:"lint",children:i("gitHooks.lint","Lint")}),e.jsx("option",{value:"test",children:i("gitHooks.test","Test")}),e.jsx("option",{value:"format",children:i("gitHooks.format","Format")}),e.jsx("option",{value:"typecheck",children:i("gitHooks.typecheck","Typecheck")}),e.jsx("option",{value:"build",children:i("gitHooks.build","Build")}),e.jsx("option",{value:"custom",children:i("gitHooks.custom","Custom")})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #9ca3af)",marginBottom:4},children:i("gitHooks.command","Command")}),e.jsx("textarea",{value:A.command,onChange:t=>Z({...A,command:t.target.value}),style:{width:"100%",padding:"8px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"1px solid var(--nice-border-color, #cbd5e1)",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",fontFamily:"monospace",minHeight:80,resize:"vertical"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #9ca3af)",marginBottom:4},children:i("gitHooks.runOn","Run On")}),e.jsxs("select",{value:A.runOn||"all",onChange:t=>Z({...A,runOn:t.target.value}),style:{width:"100%",padding:"8px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"1px solid var(--nice-border-color, #cbd5e1)",borderRadius:6,color:"var(--nice-text-primary, #0f172a)"},children:[e.jsx("option",{value:"all",children:i("gitHooks.allFiles","All files")}),e.jsx("option",{value:"staged",children:i("gitHooks.stagedFilesOnly","Staged files only")}),e.jsx("option",{value:"changed",children:i("gitHooks.changedFiles","Changed files")})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:12,color:"var(--nice-text-muted, #9ca3af)",marginBottom:4},children:i("gitHooks.filePatternsCommaSeparated","File Patterns (comma-separated)")}),e.jsx("input",{type:"text",value:A.filePatterns?.join(", ")||"",onChange:t=>Z({...A,filePatterns:t.target.value.split(",").map(x=>x.trim()).filter(Boolean)}),placeholder:i("gitHooks.tsTsxJs","*.ts, *.tsx, *.js"),style:{width:"100%",padding:"8px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"1px solid var(--nice-border-color, #cbd5e1)",borderRadius:6,color:"var(--nice-text-primary, #0f172a)"}})]}),e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:A.enabled,onChange:t=>Z({...A,enabled:t.target.checked})}),e.jsx("span",{style:{fontSize:13},children:i("gitHooks.enabled","Enabled")})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:A.failOnError,onChange:t=>Z({...A,failOnError:t.target.checked})}),e.jsx("span",{style:{fontSize:13},children:i("gitHooks.failOnError","Fail on error")})]})]})]}),e.jsxs("div",{style:{padding:16,borderTop:"1px solid var(--nice-border-color, #e2e8f0)",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsx("button",{onClick:()=>Z(null),style:{padding:"8px 16px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},children:i("gitHooks.cancel","Cancel")}),e.jsx("button",{onClick:()=>h(A),style:{padding:"8px 16px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer"},children:i("gitHooks.save","Save")})]})]})}):null,s=()=>{if(!J||!U)return null;const t=d(U);return e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"var(--nice-overlay-80, rgba(0, 0, 0, 0.8))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:e.jsxs("div",{style:{width:"90%",maxWidth:700,maxHeight:"80vh",background:"var(--nice-bg-elevated, #ffffff)",borderRadius:12,overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--nice-border-color, #e2e8f0)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("span",{style:{fontWeight:500,fontSize:16,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"file",size:16})," ",i("gitHooks.scriptPreview","Script Preview: {type}").replace("{type}",String(U.type))]}),e.jsx("button",{onClick:()=>G(!1),"aria-label":i("gitHooks.close","Close"),style:{background:"none",border:"none",color:"var(--nice-text-muted, #9ca3af)",cursor:"pointer",fontSize:20},children:e.jsx(n.NiceIcon,{name:"close",size:18})})]}),e.jsx("pre",{style:{flex:1,margin:0,padding:20,background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",fontFamily:"monospace",fontSize:13,overflow:"auto"},children:t}),e.jsxs("div",{style:{padding:16,borderTop:"1px solid var(--nice-border-color, #e2e8f0)",display:"flex",justifyContent:"flex-end",gap:8},children:[e.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(t)},style:{padding:"8px 16px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"clipboard",size:14})," ",i("gitHooks.copy","Copy")]}),e.jsx("button",{onClick:()=>G(!1),style:{padding:"8px 16px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer"},children:i("gitHooks.close","Close")})]})]})})};return e.jsxs("div",{className:`nice-git-hooks ${v||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-canvas, #0d1117)",color:"var(--nice-text-primary, #e6edf3)",fontFamily:"system-ui, sans-serif",...M},"data-testid":C,children:[e.jsxs("div",{style:{width:280,borderRight:"1px solid var(--nice-border, #30363d)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border, #30363d)",fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"link",size:16})," ",i("gitHooks.gitHooks","Git Hooks")]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:Object.entries(fe).map(([t,x])=>{const u=Y.find(X=>X.type===t),R=H===t,ee=u?.actions.length||0;return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>c(t),style:{padding:"12px 16px",cursor:"pointer",background:R?"var(--nice-primary-tint-15, rgba(59, 130, 246, 0.15))":"transparent",borderLeft:R?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:x.icon,size:18}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:13,fontWeight:500},children:x.title}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:ee!==1?i("gitHooks.actionsMany","{actionCount} actions").replace("{actionCount}",String(ee)):i("gitHooks.actionsOne","{actionCount} action").replace("{actionCount}",String(ee))})]}),e.jsx("button",{onClick:X=>{X.stopPropagation(),te(t,!u?.enabled)},style:{width:36,height:20,borderRadius:10,background:u?.enabled?"var(--nice-color-success, #22c55e)":"var(--nice-bg-tertiary, #cbd5e1)",border:"none",cursor:"pointer",position:"relative",transition:"background 0.2s"},children:e.jsx("div",{style:{position:"absolute",top:2,left:u?.enabled?18:2,width:16,height:16,borderRadius:"50%",background:"var(--nice-bg-primary, #fff)",transition:"left 0.2s"}})})]},t)})}),e.jsx("div",{style:{padding:12,borderTop:"1px solid var(--nice-border, #30363d)",display:"flex",gap:8},children:e.jsx("button",{onClick:()=>S?.(Y,"husky"),style:{flex:1,padding:"8px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",fontSize:12,cursor:"pointer"},children:i("gitHooks.export","Export")})})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:U?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--nice-border, #30363d)",background:"var(--nice-bg-elevated, #161b22)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx(n.NiceIcon,{name:fe[U.type].icon,size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:18,fontWeight:500},children:fe[U.type].title}),e.jsx("div",{style:{fontSize:12,color:"var(--nice-text-muted, #8b949e)"},children:fe[U.type].description})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:12},children:[e.jsxs("button",{onClick:()=>G(!0),style:{padding:"6px 12px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",fontSize:12,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"file",size:14})," ",i("gitHooks.previewScript","Preview Script")]}),e.jsxs("button",{onClick:()=>z?.(U.type),style:{padding:"6px 12px",background:"var(--nice-color-success, #22c55e)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",fontSize:12,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"download",size:14})," ",i("gitHooks.install","Install")]}),e.jsxs("button",{onClick:()=>k?.(U.type),style:{padding:"6px 12px",background:"var(--nice-color-error, #ef4444)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",fontSize:12,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"close",size:14})," ",i("gitHooks.uninstall","Uninstall")]})]})]}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:U.actions.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:40,color:"var(--nice-text-muted, #8b949e)"},children:[e.jsx(n.NiceIcon,{name:"box",size:48}),e.jsx("span",{style:{marginTop:16},children:i("gitHooks.noActionsConfigured","No actions configured")}),e.jsx("span",{style:{fontSize:12,marginTop:4},children:i("gitHooks.addAnActionFromTemplates","Add an action from templates or create a custom one")})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:U.actions.sort((t,x)=>t.order-x.order).map((t,x)=>e.jsxs("div",{style:{padding:16,background:"var(--nice-bg-elevated, #161b22)",borderRadius:8,border:"1px solid var(--nice-border, #30363d)",opacity:t.enabled?1:.5},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:$(t.type),size:20}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:t.name}),e.jsx("code",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)",background:"var(--nice-bg-canvas, #0d1117)",padding:"2px 6px",borderRadius:4},children:t.command})]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{onClick:()=>T(t.id,"up"),disabled:x===0,"aria-label":i("gitHooks.moveUp","Move up"),style:{padding:"4px 8px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:4,color:"var(--nice-text-primary, #0f172a)",cursor:x===0?"not-allowed":"pointer",opacity:x===0?.5:1},children:e.jsx(n.NiceIcon,{name:"arrow-up",size:14})}),e.jsx("button",{onClick:()=>T(t.id,"down"),disabled:x===U.actions.length-1,"aria-label":i("gitHooks.moveDown","Move down"),style:{padding:"4px 8px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:4,color:"var(--nice-text-primary, #0f172a)",cursor:x===U.actions.length-1?"not-allowed":"pointer",opacity:x===U.actions.length-1?.5:1},children:e.jsx(n.NiceIcon,{name:"arrow-down",size:14})}),e.jsx("button",{onClick:()=>Z(t),"aria-label":i("gitHooks.editAction2","Edit action"),style:{padding:"4px 8px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:4,color:"var(--nice-text-primary, #0f172a)",cursor:"pointer"},children:e.jsx(n.NiceIcon,{name:"edit",size:14})}),e.jsx("button",{onClick:()=>p(t.id),"aria-label":i("gitHooks.removeAction","Remove action"),style:{padding:"4px 8px",background:"var(--nice-color-error, #ef4444)",border:"none",borderRadius:4,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer"},children:e.jsx(n.NiceIcon,{name:"trash",size:14})})]})]}),t.filePatterns&&t.filePatterns.length>0&&e.jsx("div",{style:{marginTop:8,fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:i("gitHooks.files","Files: {filePatterns}").replace("{filePatterns}",String(t.filePatterns.join(", ")))}),e.jsxs("div",{style:{marginTop:8,display:"flex",gap:8},children:[t.runOn&&e.jsx("span",{style:{fontSize:10,padding:"2px 6px",background:"var(--nice-color-primary-active, #1d4ed8)",borderRadius:4},children:t.runOn}),t.failOnError&&e.jsx("span",{style:{fontSize:10,padding:"2px 6px",background:"var(--nice-color-error, #b91c1c)",borderRadius:4},children:i("gitHooks.failOnError2","fail on error")})]})]},t.id))})}),e.jsxs("div",{style:{padding:16,borderTop:"1px solid var(--nice-border, #30363d)",display:"flex",gap:8},children:[e.jsxs("button",{onClick:()=>V(!l),style:{padding:"10px 16px",background:"var(--nice-color-primary, #3b82f6)",border:"none",borderRadius:6,color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontWeight:500,display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"plus",size:14})," ",i("gitHooks.addFromTemplate","Add from Template")]}),e.jsxs("button",{onClick:()=>g(),style:{padding:"10px 16px",background:"var(--nice-bg-secondary, #f8fafc)",border:"none",borderRadius:6,color:"var(--nice-text-primary, #0f172a)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"settings",size:14})," ",i("gitHooks.customAction","Custom Action")]})]}),l&&e.jsxs("div",{style:{position:"absolute",bottom:70,left:300,width:400,maxHeight:300,overflow:"auto",background:"var(--nice-bg-elevated, #ffffff)",border:"1px solid var(--nice-border-color, #e2e8f0)",borderRadius:8,boxShadow:"0 4px 12px var(--nice-overlay-30, rgba(0, 0, 0, 0.3))",zIndex:50},children:[w.filter(t=>t.hook===H).map(t=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>g(t),style:{padding:12,cursor:"pointer",borderBottom:"1px solid var(--nice-border-color, #e2e8f0)",display:"flex",alignItems:"center",gap:12},children:[e.jsx(n.NiceIcon,{name:t.icon,size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500},children:t.name}),e.jsx("div",{style:{fontSize:11,color:"var(--nice-text-muted, #8b949e)"},children:t.description})]})]},t.id)),w.filter(t=>t.hook===H).length===0&&e.jsx("div",{style:{padding:20,textAlign:"center",color:"var(--nice-text-muted, #8b949e)"},children:i("gitHooks.noTemplatesForThisHook","No templates for this hook type")})]})]}):e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #8b949e)"},children:[e.jsx(n.NiceIcon,{name:"link",size:64}),e.jsx("span",{style:{fontSize:18,marginTop:16},children:i("gitHooks.selectAHookToConfigure","Select a hook to configure")}),e.jsx("span",{style:{fontSize:12,marginTop:4},children:i("gitHooks.clickOnAHookFrom","Click on a hook from the list to start editing")})]})}),q(),s()]})},pt=Object.freeze(Object.defineProperty({__proto__:null,NiceGitHooks:Ae},Symbol.toStringTag,{value:"Module"})),xt=[...n.NICE_KEYBOARD_NUMERIC,[{value:"-"},{value:","},{...n.NICE_KEY_ENTER,width:1}]];function ut(a){const f=(a??"en").slice(0,2).toLowerCase();return f in n.NICE_KEYBOARD_LAYOUTS?f:"en"}function gt(a){const f=n.NICE_KEYBOARD_LAYOUTS[a]?.accents;if(!f)return null;const w=[...new Set(Object.values(f).flat())];return w.length?w.map(B=>({value:B})):null}const Oe=Object.assign(function({value:f,defaultValue:w,caret:B,onChange:_,onSubmit:W,onClose:L,language:D,languages:E,layout:N="text",multiline:j=!1,masked:P=!1,maxLength:z,enterLabel:k,showPreview:S=!0,fieldLabel:v,modal:M=!0,className:C,"data-testid":i,style:I}){const{t:O,lang:b}=n.useNiceTranslation(),Y=o.useRef(null),[F,H]=n.useControllableState({value:f,defaultValue:w,fallbackValue:"",componentName:"NiceOnScreenKeyboard"}),[c,l]=o.useState(null),V=Math.max(0,Math.min(F.length,B??c??F.length)),A=o.useMemo(()=>({text:F,caret:V}),[F,V]),Z=D??ut(b),J=o.useMemo(()=>E&&E.length>0?E:[Z],[E,Z]),G=o.useMemo(()=>[{kind:"letters",lang:J[0]},{kind:"symbols"},...J.slice(1).map(y=>({kind:"letters",lang:y}))],[J]),[U,te]=o.useState(0),g=G[Math.min(U,G.length-1)],[p,h]=o.useState(!1),T=o.useMemo(()=>{if(N==="number")return xt;const y=g.kind==="letters"?g.lang:J[0],re=n.buildKeyboardRows(y,"compact",g.kind==="symbols",J.length>1,k),ie=g.kind==="letters"?gt(y):null;return ie?[...re.slice(0,-1),ie,re[re.length-1]]:re},[N,g,J,k]),d=o.useCallback(y=>{y.text===A.text&&y.caret===A.caret||(H(y.text),l(y.caret),_?.(y.text,y.caret))},[A,_,H]),$=o.useCallback(y=>d(n.insertAtCaret(A,y,z)),[d,A,z]),q=o.useCallback(()=>d(n.deleteBeforeCaret(A)),[d,A]),s=o.useCallback(y=>d(n.moveTextCaret(A,y)),[d,A]),t=o.useCallback(y=>te(re=>(re+y+G.length)%G.length),[G.length]),x=y=>{switch(y.type){case"backspace":q();return;case"enter":j?$(`
10
- `):W?.(F);return;case"shift":case"caps":h(re=>!re);return;case"space":$(" ");return;case"tab":$(" ");return;case"lang":t(1);return;case"fn":y.value==="123"||y.value==="ABC"||y.value==="#+="?te(g.kind==="symbols"?0:G.findIndex(re=>re.kind==="symbols")):(y.value==="Clear"||y.value==="C")&&d({text:"",caret:0});return;default:{const re=p&&y.value.length===1?y.value.toUpperCase():y.value;$(re),p&&h(!1)}}};n.useOverlayFocus(Y,{open:M,modal:!0,onClose:()=>L?.()}),n.useIntent(["secondary","tertiary","pagePrev","pageNext","sectionPrev","sectionNext","menu"],y=>{const re={secondary:q,tertiary:()=>$(" "),pagePrev:()=>s(-1),pageNext:()=>s(1),sectionPrev:()=>t(-1),sectionNext:()=>t(1),menu:()=>W?.(F)};if(y.source==="keyboard"&&y.intent!=="secondary")return!1;re[y.intent]?.()},{ref:Y}),n.useInputHints(Y,[{intent:"activate",label:O("osk.type","Type")},{intent:"secondary",label:O("osk.delete","Delete")},{intent:"tertiary",label:O("touchKeyboard.space","Space")},{intent:"pageNext",label:O("osk.cursor","Cursor")},{intent:"sectionNext",label:O("osk.layout","Layout")},{intent:"menu",label:O("osk.done","Done")},{intent:"back",label:O("osk.close","Close")}]);const u=o.useRef({backspace:q,typeChars:$});u.current={backspace:q,typeChars:$},o.useEffect(()=>{const y=Y.current;if(!y)return;const re=ie=>{ie.ctrlKey||ie.metaKey||ie.altKey||ie.defaultPrevented||(ie.key==="Backspace"?(ie.preventDefault(),u.current.backspace()):ie.key.length===1&&ie.key!==" "&&(ie.preventDefault(),u.current.typeChars(ie.key)))};return y.addEventListener("keydown",re),()=>y.removeEventListener("keydown",re)},[]);const R=y=>{switch(y.type){case"backspace":return O("touchKeyboard.backspace","Backspace");case"enter":return j?O("osk.newLine","New line"):k??O("touchKeyboard.enter","Enter");case"space":return O("touchKeyboard.space","Space");case"shift":case"caps":return O("osk.shift","Shift");case"tab":return O("input.key.tab","Tab");case"lang":return O("touchKeyboard.language","Lang");case"fn":return y.value==="ABC"?O("osk.letters","Letters"):y.value==="123"||y.value==="#+="?O("osk.symbols","Symbols"):y.label??y.value;default:return p&&y.value.length===1?y.value.toUpperCase():y.value}},ee=y=>{switch(y.type){case"backspace":return e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"key-backspace",size:18}),e.jsx(n.NiceControlHint,{intent:"secondary",always:!0})]});case"enter":return e.jsxs(e.Fragment,{children:[k&&!j?e.jsx("span",{className:"nice-osk__key-text",children:k}):e.jsx(n.NiceIcon,{name:"key-enter",size:18}),!j&&e.jsx(n.NiceControlHint,{intent:"menu",always:!0})]});case"space":return e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"key-space",size:18}),e.jsx(n.NiceControlHint,{intent:"tertiary",always:!0})]});case"shift":case"caps":return e.jsx(n.NiceIcon,{name:"key-shift",size:18});case"tab":return e.jsx(n.NiceIcon,{name:"key-tab",size:18});case"lang":return e.jsx(n.NiceIcon,{name:"globe",size:18});default:return e.jsx("span",{className:"nice-osk__key-text",children:R(y)})}},X=T.length>1?T[Math.min(1,T.length-1)][0]:T[0]?.[0],m=P?"•".repeat(F.length):F,Q=N==="text"&&g.kind==="letters"&&n.isRtlKeyboardLanguage(g.lang);return e.jsxs("div",{ref:Y,className:`nice-osk${C?` ${C}`:""}`,style:I,"data-testid":i,role:M?"dialog":"group","aria-modal":M||void 0,"aria-label":O("osk.label","On-screen keyboard"),children:[S&&e.jsxs("div",{className:"nice-osk__preview",children:[v&&e.jsx("span",{className:"nice-osk__preview-label",children:v}),e.jsxs("span",{className:"nice-osk__preview-text",dir:Q?"rtl":void 0,children:[m.slice(0,V),e.jsx("span",{className:"nice-osk__caret","aria-hidden":"true"}),m.slice(V)]})]}),e.jsx("div",{className:"nice-osk__keys",dir:Q?"rtl":void 0,children:T.map((y,re)=>e.jsx("div",{className:"nice-osk__row",children:y.map((ie,de)=>e.jsx("button",{type:"button",className:`nice-osk__key nice-osk__key--${ie.type??"char"}${(ie.type==="shift"||ie.type==="caps")&&p?" nice-osk__key--active":""}`,style:{flexGrow:ie.width??1},onClick:()=>x(ie),"aria-label":R(ie),"aria-pressed":ie.type==="shift"||ie.type==="caps"?p:void 0,"data-autofocus":ie===X?"":void 0,children:ee(ie)},`${re}-${de}-${ie.value}`))},re))}),e.jsxs("div",{className:"nice-osk__bar",children:[e.jsxs("button",{type:"button",className:"nice-osk__bar-btn",onClick:()=>s(-1),"aria-label":O("osk.cursorLeft","Cursor left"),children:[e.jsx(n.NiceIcon,{name:"chevron-left",size:16}),e.jsx(n.NiceControlHint,{intent:"pagePrev",always:!0})]}),e.jsxs("button",{type:"button",className:"nice-osk__bar-btn",onClick:()=>s(1),"aria-label":O("osk.cursorRight","Cursor right"),children:[e.jsx(n.NiceControlHint,{intent:"pageNext",always:!0}),e.jsx(n.NiceIcon,{name:"chevron-right",size:16})]}),e.jsx("span",{className:"nice-osk__bar-spacer"}),e.jsxs("button",{type:"button",className:"nice-osk__bar-btn",onClick:()=>L?.(),"aria-label":O("osk.close","Close"),children:[e.jsx(n.NiceControlHint,{intent:"back",always:!0}),e.jsx(n.NiceIcon,{name:"close",size:16})]})]})]})},{displayName:"NiceOnScreenKeyboard"});function ke(a){return(a instanceof HTMLTextAreaElement||a instanceof Element&&n.isTextInput(a))&&!a.readOnly&&!a.disabled}function ft(a){return a.labels?.[0]?.textContent?.trim()||a.getAttribute("aria-label")||a.placeholder||void 0}const xe=[];function De(){const{t:a}=n.useNiceTranslation(),[f]=n.useInputPreferences(),w=n.useInputMethod();n.useInputEngine();const B=o.useRef({}),[_,W]=o.useState(null),[L,D]=o.useState({text:"",caret:0}),E=o.useRef(w);E.current=w,o.useEffect(()=>{const C=B.current;return xe.push(C),()=>{xe.splice(xe.indexOf(C),1)}},[]);const N=o.useCallback(C=>{let i=C.value.length;try{i=C.selectionEnd??i}catch{}D({text:C.value,caret:i}),W({el:C,before:C.value})},[]);if(o.useEffect(()=>{if(f.onScreenKeyboard==="never")return;const C=I=>{const O=I.detail;xe[0]===B.current&&O.engaged&&(O.source==="gamepad"||O.source==="remote")&&ke(I.target)&&N(I.target)},i=I=>{f.onScreenKeyboard==="always"&&E.current==="touch"&&xe[0]===B.current&&ke(I.target)&&N(I.target)};return document.addEventListener(n.NICE_ENGAGE_EVENT,C),document.addEventListener("focusin",i),()=>{document.removeEventListener(n.NICE_ENGAGE_EVENT,C),document.removeEventListener("focusin",i)}},[f.onScreenKeyboard,N]),!_||typeof document>"u")return null;const{el:j}=_,P=()=>{j.value!==_.before&&j.dispatchEvent(new Event("change",{bubbles:!0})),W(null)},z=()=>{P(),window.setTimeout(()=>{const C=new KeyboardEvent("keydown",{key:"Enter",bubbles:!0,cancelable:!0});if(j.dispatchEvent(C),!C.defaultPrevented&&j instanceof HTMLInputElement&&j.form)try{j.form.requestSubmit()}catch{}},0)},k=j.getAttribute("inputmode"),S=k==="numeric"||k==="decimal"||k==="tel"||j.type==="tel",v=j.getAttribute("enterkeyhint"),M=j.type==="search"||v==="search"?a("osk.search","Search"):v==="send"?a("osk.send","Send"):v==="go"?a("osk.go","Go"):v==="next"?a("osk.next","Next"):void 0;return qe.createPortal(e.jsx("div",{className:`nice-osk-host ${Se(j)}`,children:e.jsx(Oe,{value:L.text,caret:L.caret,onChange:(C,i)=>{D({text:C,caret:i}),n.setFieldText(j,C,i)},onSubmit:j instanceof HTMLTextAreaElement?()=>P():()=>z(),onClose:P,layout:S?"number":"text",multiline:j instanceof HTMLTextAreaElement,masked:j.type==="password",maxLength:j.maxLength>0?j.maxLength:void 0,enterLabel:M,fieldLabel:ft(j)})}),document.body)}const ht={"data-nice-focus-scope":"spatial","data-nice-arrows":"spatial"};function Pe(){return n.useInputEngine(),ht}function $e({position:a,block:f}){return e.jsxs(e.Fragment,{children:[a!=="none"&&e.jsx(n.NiceInputHintBar,{visibility:"pad",position:a,className:`${f}__hint-bar`}),e.jsx(De,{})]})}const He=Object.assign(o.forwardRef(({menubar:a,toolbar:f,sidebar:w,sidebarWidth:B=220,rightSidebar:_,rightSidebarWidth:W=280,children:L,bottomPanel:D,bottomPanelHeight:E,statusBar:N,height:j="100%",flush:P=!1,hintBar:z="bottom",className:k,style:S,id:v,"data-testid":M},C)=>{const{t:i}=n.useNiceTranslation(),I=Pe(),O=`nice-app-shell__sidebar${P?" nice-app-shell__sidebar--flush":""}`;return e.jsxs("div",{ref:C,id:v,"data-testid":M,className:`nice-app-shell${k?` ${k}`:""}`,style:{height:j,...S},...I,children:[a!=null&&e.jsx("div",{className:`nice-app-shell__menubar${P?" nice-app-shell__chrome--flush":""}`,"data-nice-region":i("appShell.region.menubar","Menu bar"),children:a}),f!=null&&e.jsx("div",{className:`nice-app-shell__toolbar${P?" nice-app-shell__chrome--flush":""}`,"data-nice-region":i("appShell.region.toolbar","Toolbar"),children:f}),e.jsxs("div",{className:"nice-app-shell__body",children:[w!=null&&e.jsx("aside",{className:O,style:P?void 0:{width:B},children:w}),e.jsx("main",{className:"nice-app-shell__content",children:L}),_!=null&&e.jsx("aside",{className:`${O} nice-app-shell__sidebar--right`,style:P?void 0:{width:W},children:_})]}),D!=null&&e.jsx("div",{className:`nice-app-shell__bottom${P?" nice-app-shell__bottom--flush":""}`,style:E!=null?{height:E}:void 0,"data-nice-region":i("appShell.region.bottom","Bottom panel"),children:D}),N!=null&&e.jsx("div",{className:"nice-app-shell__status","data-nice-region":i("appShell.region.status","Status bar"),children:N}),e.jsx($e,{position:z,block:"nice-app-shell"})]})}),{displayName:"NiceAppShell"}),mt=[],bt=[],vt={id:"",name:"",repository:"",triggers:[],stages:[],variables:[],secrets:[],isEnabled:!0,createdAt:new Date(0),updatedAt:new Date(0)},yt=[],jt=[{target:".nice-pipeline-editor",titleKey:"tutorial.pipelineEditor.intro.title",title:"Pipeline editor",contentKey:"tutorial.pipelineEditor.intro.content",content:"Build a CI/CD pipeline from stages, jobs and steps; set triggers, variables and secrets; then validate, save and run it.",placement:"auto"}],kt={push:"upload",pull_request:"shuffle",schedule:"clock",manual:"cursor",tag:"tag",workflow_dispatch:"zap"},St={script:"file",action:"settings",checkout:"download",upload_artifact:"upload",download_artifact:"download",docker:"box",deploy:"rocket"},Le=({pipeline:a,defaultPipeline:f,templates:w=mt,runners:B=yt,environments:_=bt,onPipelineChange:W,onStageAdd:L,onStageRemove:D,onStageMove:E,onJobAdd:N,onJobRemove:j,onStepAdd:P,onStepRemove:z,onVariableAdd:k,onVariableRemove:S,onSecretAdd:v,onSecretRemove:M,onTemplateApply:C,onSave:i,onRun:I,onValidate:O,tutorial:b,className:Y,style:F,"data-testid":H})=>{const{t:c}=n.useNiceTranslation(),[l,V]=n.useControllableState({value:a,defaultValue:f,fallbackValue:vt,onChange:W,componentName:"NicePipelineEditor"}),[A,Z]=o.useState("visual"),[J,G]=o.useState(null),[U,te]=o.useState(null),[g,p]=o.useState(!1),h=l.stages.find(t=>t.id===J),T=h?.jobs.find(t=>t.id===U),d=o.useMemo(()=>{const t=[];return t.push(`name: ${l.name}`),t.push(""),t.push("on:"),l.triggers.forEach(x=>{t.push(` ${x}:`),(x==="push"||x==="pull_request")&&(t.push(" branches:"),t.push(` - ${l.branch||"main"}`))}),t.push(""),l.variables.length>0&&(t.push("env:"),l.variables.filter(x=>!x.isSecret).forEach(x=>{t.push(` ${x.name}: ${x.value}`)}),t.push("")),t.push("jobs:"),l.stages.forEach(x=>{x.jobs.forEach(u=>{t.push(` ${x.name.toLowerCase().replace(/\s+/g,"-")}-${u.name.toLowerCase().replace(/\s+/g,"-")}:`),t.push(` name: ${u.name}`),u.runner&&t.push(` runs-on: ${u.runner}`),x.dependsOn?.length&&t.push(` needs: [${x.dependsOn.join(", ")}]`),t.push(" steps:"),u.steps.forEach(R=>{R.type==="checkout"?t.push(" - uses: actions/checkout@v4"):R.type==="action"&&R.action?(t.push(` - uses: ${R.action}${R.actionVersion?`@${R.actionVersion}`:""}`),R.with&&Object.keys(R.with).length>0&&(t.push(" with:"),Object.entries(R.with).forEach(([ee,X])=>{t.push(` ${ee}: ${X}`)}))):R.type==="script"&&R.script&&(t.push(` - name: ${R.name}`),t.push(" run: |"),R.script.split(`
10
+ `):W?.(F);return;case"shift":case"caps":h(re=>!re);return;case"space":$(" ");return;case"tab":$(" ");return;case"lang":t(1);return;case"fn":y.value==="123"||y.value==="ABC"||y.value==="#+="?te(g.kind==="symbols"?0:G.findIndex(re=>re.kind==="symbols")):(y.value==="Clear"||y.value==="C")&&d({text:"",caret:0});return;default:{const re=p&&y.value.length===1?y.value.toUpperCase():y.value;$(re),p&&h(!1)}}};n.useOverlayFocus(Y,{open:M,modal:!0,onClose:()=>L?.()}),n.useIntent(["secondary","tertiary","pagePrev","pageNext","sectionPrev","sectionNext","menu"],y=>{const re={secondary:q,tertiary:()=>$(" "),pagePrev:()=>s(-1),pageNext:()=>s(1),sectionPrev:()=>t(-1),sectionNext:()=>t(1),menu:()=>W?.(F)};if(y.source==="keyboard"&&y.intent!=="secondary")return!1;re[y.intent]?.()},{ref:Y}),n.useInputHints(Y,[{intent:"activate",label:O("osk.type","Type")},{intent:"secondary",label:O("osk.delete","Delete")},{intent:"tertiary",label:O("touchKeyboard.space","Space")},{intent:"pageNext",label:O("osk.cursor","Cursor")},{intent:"sectionNext",label:O("osk.layout","Layout")},{intent:"menu",label:O("osk.done","Done")},{intent:"back",label:O("osk.close","Close")}]);const u=o.useRef({backspace:q,typeChars:$});u.current={backspace:q,typeChars:$},o.useEffect(()=>{const y=Y.current;if(!y)return;const re=ie=>{ie.ctrlKey||ie.metaKey||ie.altKey||ie.defaultPrevented||(ie.key==="Backspace"?(ie.preventDefault(),u.current.backspace()):ie.key.length===1&&ie.key!==" "&&(ie.preventDefault(),u.current.typeChars(ie.key)))};return y.addEventListener("keydown",re),()=>y.removeEventListener("keydown",re)},[]);const R=y=>{switch(y.type){case"backspace":return O("touchKeyboard.backspace","Backspace");case"enter":return j?O("osk.newLine","New line"):k??O("touchKeyboard.enter","Enter");case"space":return O("touchKeyboard.space","Space");case"shift":case"caps":return O("osk.shift","Shift");case"tab":return O("input.key.tab","Tab");case"lang":return O("touchKeyboard.language","Lang");case"fn":return y.value==="ABC"?O("osk.letters","Letters"):y.value==="123"||y.value==="#+="?O("osk.symbols","Symbols"):y.label??y.value;default:return p&&y.value.length===1?y.value.toUpperCase():y.value}},ee=y=>{switch(y.type){case"backspace":return e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"key-backspace",size:18}),e.jsx(n.NiceControlHint,{intent:"secondary",always:!0})]});case"enter":return e.jsxs(e.Fragment,{children:[k&&!j?e.jsx("span",{className:"nice-osk__key-text",children:k}):e.jsx(n.NiceIcon,{name:"key-enter",size:18}),!j&&e.jsx(n.NiceControlHint,{intent:"menu",always:!0})]});case"space":return e.jsxs(e.Fragment,{children:[e.jsx(n.NiceIcon,{name:"key-space",size:18}),e.jsx(n.NiceControlHint,{intent:"tertiary",always:!0})]});case"shift":case"caps":return e.jsx(n.NiceIcon,{name:"key-shift",size:18});case"tab":return e.jsx(n.NiceIcon,{name:"key-tab",size:18});case"lang":return e.jsx(n.NiceIcon,{name:"globe",size:18});default:return e.jsx("span",{className:"nice-osk__key-text",children:R(y)})}},X=T.length>1?T[Math.min(1,T.length-1)][0]:T[0]?.[0],m=P?"•".repeat(F.length):F,Q=N==="text"&&g.kind==="letters"&&n.isRtlKeyboardLanguage(g.lang);return e.jsxs("div",{ref:Y,className:`nice-osk${C?` ${C}`:""}`,style:I,"data-testid":i,role:M?"dialog":"group","aria-modal":M||void 0,"aria-label":O("osk.label","On-screen keyboard"),children:[S&&e.jsxs("div",{className:"nice-osk__preview",children:[v&&e.jsx("span",{className:"nice-osk__preview-label",children:v}),e.jsxs("span",{className:"nice-osk__preview-text",dir:Q?"rtl":void 0,children:[m.slice(0,V),e.jsx("span",{className:"nice-osk__caret","aria-hidden":"true"}),m.slice(V)]})]}),e.jsx("div",{className:"nice-osk__keys",dir:Q?"rtl":void 0,children:T.map((y,re)=>e.jsx("div",{className:"nice-osk__row",children:y.map((ie,de)=>e.jsx("button",{type:"button",className:`nice-osk__key nice-osk__key--${ie.type??"char"}${(ie.type==="shift"||ie.type==="caps")&&p?" nice-osk__key--active":""}`,style:{flexGrow:ie.width??1},onClick:()=>x(ie),"aria-label":R(ie),"aria-pressed":ie.type==="shift"||ie.type==="caps"?p:void 0,"data-autofocus":ie===X?"":void 0,children:ee(ie)},`${re}-${de}-${ie.value}`))},re))}),e.jsxs("div",{className:"nice-osk__bar",children:[e.jsxs("button",{type:"button",className:"nice-osk__bar-btn",onClick:()=>s(-1),"aria-label":O("osk.cursorLeft","Cursor left"),children:[e.jsx(n.NiceIcon,{name:"chevron-left",size:16}),e.jsx(n.NiceControlHint,{intent:"pagePrev",always:!0})]}),e.jsxs("button",{type:"button",className:"nice-osk__bar-btn",onClick:()=>s(1),"aria-label":O("osk.cursorRight","Cursor right"),children:[e.jsx(n.NiceControlHint,{intent:"pageNext",always:!0}),e.jsx(n.NiceIcon,{name:"chevron-right",size:16})]}),e.jsx("span",{className:"nice-osk__bar-spacer"}),e.jsxs("button",{type:"button",className:"nice-osk__bar-btn",onClick:()=>L?.(),"aria-label":O("osk.close","Close"),children:[e.jsx(n.NiceControlHint,{intent:"back",always:!0}),e.jsx(n.NiceIcon,{name:"close",size:16})]})]})]})},{displayName:"NiceOnScreenKeyboard"});function ke(a){return(a instanceof HTMLTextAreaElement||a instanceof Element&&n.isTextInput(a))&&!a.readOnly&&!a.disabled}function ft(a){return a.labels?.[0]?.textContent?.trim()||a.getAttribute("aria-label")||a.placeholder||void 0}const xe=[];function De(){const{t:a}=n.useNiceTranslation(),[f]=n.useInputPreferences(),w=n.useInputMethod();n.useInputEngine();const B=o.useRef({}),[_,W]=o.useState(null),[L,D]=o.useState({text:"",caret:0}),E=o.useRef(w);E.current=w,o.useEffect(()=>{const C=B.current;return xe.push(C),()=>{xe.splice(xe.indexOf(C),1)}},[]);const N=o.useCallback(C=>{let i=C.value.length;try{i=C.selectionEnd??i}catch{}D({text:C.value,caret:i}),W({el:C,before:C.value})},[]);if(o.useEffect(()=>{if(f.onScreenKeyboard==="never")return;const C=I=>{const O=I.detail;xe[0]===B.current&&O.engaged&&(O.source==="gamepad"||O.source==="remote")&&ke(I.target)&&N(I.target)},i=I=>{f.onScreenKeyboard==="always"&&E.current==="touch"&&xe[0]===B.current&&ke(I.target)&&N(I.target)};return document.addEventListener(n.NICE_ENGAGE_EVENT,C),document.addEventListener("focusin",i),()=>{document.removeEventListener(n.NICE_ENGAGE_EVENT,C),document.removeEventListener("focusin",i)}},[f.onScreenKeyboard,N]),!_||typeof document>"u")return null;const{el:j}=_,P=()=>{j.value!==_.before&&j.dispatchEvent(new Event("change",{bubbles:!0})),W(null)},z=()=>{P(),window.setTimeout(()=>{const C=new KeyboardEvent("keydown",{key:"Enter",bubbles:!0,cancelable:!0});if(j.dispatchEvent(C),!C.defaultPrevented&&j instanceof HTMLInputElement&&j.form)try{j.form.requestSubmit()}catch{}},0)},k=j.getAttribute("inputmode"),S=k==="numeric"||k==="decimal"||k==="tel"||j.type==="tel",v=j.getAttribute("enterkeyhint"),M=j.type==="search"||v==="search"?a("osk.search","Search"):v==="send"?a("osk.send","Send"):v==="go"?a("osk.go","Go"):v==="next"?a("osk.next","Next"):void 0;return qe.createPortal(e.jsx("div",{className:`nice-osk-host ${Ce(j)}`,children:e.jsx(Oe,{value:L.text,caret:L.caret,onChange:(C,i)=>{D({text:C,caret:i}),n.setFieldText(j,C,i)},onSubmit:j instanceof HTMLTextAreaElement?()=>P():()=>z(),onClose:P,layout:S?"number":"text",multiline:j instanceof HTMLTextAreaElement,masked:j.type==="password",maxLength:j.maxLength>0?j.maxLength:void 0,enterLabel:M,fieldLabel:ft(j)})}),document.body)}const ht={"data-nice-focus-scope":"spatial","data-nice-arrows":"spatial"};function Pe(){return n.useInputEngine(),ht}function $e({position:a,block:f}){return e.jsxs(e.Fragment,{children:[a!=="none"&&e.jsx(n.NiceInputHintBar,{visibility:"pad",position:a,className:`${f}__hint-bar`}),e.jsx(De,{})]})}const He=Object.assign(o.forwardRef(({menubar:a,toolbar:f,sidebar:w,sidebarWidth:B=220,rightSidebar:_,rightSidebarWidth:W=280,children:L,bottomPanel:D,bottomPanelHeight:E,statusBar:N,height:j="100%",flush:P=!1,hintBar:z="bottom",className:k,style:S,id:v,"data-testid":M},C)=>{const{t:i}=n.useNiceTranslation(),I=Pe(),O=`nice-app-shell__sidebar${P?" nice-app-shell__sidebar--flush":""}`;return e.jsxs("div",{ref:C,id:v,"data-testid":M,className:`nice-app-shell${k?` ${k}`:""}`,style:{height:j,...S},...I,children:[a!=null&&e.jsx("div",{className:`nice-app-shell__menubar${P?" nice-app-shell__chrome--flush":""}`,"data-nice-region":i("appShell.region.menubar","Menu bar"),children:a}),f!=null&&e.jsx("div",{className:`nice-app-shell__toolbar${P?" nice-app-shell__chrome--flush":""}`,"data-nice-region":i("appShell.region.toolbar","Toolbar"),children:f}),e.jsxs("div",{className:"nice-app-shell__body",children:[w!=null&&e.jsx("aside",{className:O,style:P?void 0:{width:B},children:w}),e.jsx("main",{className:"nice-app-shell__content",children:L}),_!=null&&e.jsx("aside",{className:`${O} nice-app-shell__sidebar--right`,style:P?void 0:{width:W},children:_})]}),D!=null&&e.jsx("div",{className:`nice-app-shell__bottom${P?" nice-app-shell__bottom--flush":""}`,style:E!=null?{height:E}:void 0,"data-nice-region":i("appShell.region.bottom","Bottom panel"),children:D}),N!=null&&e.jsx("div",{className:"nice-app-shell__status","data-nice-region":i("appShell.region.status","Status bar"),children:N}),e.jsx($e,{position:z,block:"nice-app-shell"})]})}),{displayName:"NiceAppShell"}),mt=[],bt=[],vt={id:"",name:"",repository:"",triggers:[],stages:[],variables:[],secrets:[],isEnabled:!0,createdAt:new Date(0),updatedAt:new Date(0)},yt=[],jt=[{target:".nice-pipeline-editor",titleKey:"tutorial.pipelineEditor.intro.title",title:"Pipeline editor",contentKey:"tutorial.pipelineEditor.intro.content",content:"Build a CI/CD pipeline from stages, jobs and steps; set triggers, variables and secrets; then validate, save and run it.",placement:"auto"}],kt={push:"upload",pull_request:"shuffle",schedule:"clock",manual:"cursor",tag:"tag",workflow_dispatch:"zap"},St={script:"file",action:"settings",checkout:"download",upload_artifact:"upload",download_artifact:"download",docker:"box",deploy:"rocket"},Le=({pipeline:a,defaultPipeline:f,templates:w=mt,runners:B=yt,environments:_=bt,onPipelineChange:W,onStageAdd:L,onStageRemove:D,onStageMove:E,onJobAdd:N,onJobRemove:j,onStepAdd:P,onStepRemove:z,onVariableAdd:k,onVariableRemove:S,onSecretAdd:v,onSecretRemove:M,onTemplateApply:C,onSave:i,onRun:I,onValidate:O,tutorial:b,className:Y,style:F,"data-testid":H})=>{const{t:c}=n.useNiceTranslation(),[l,V]=n.useControllableState({value:a,defaultValue:f,fallbackValue:vt,onChange:W,componentName:"NicePipelineEditor"}),[A,Z]=o.useState("visual"),[J,G]=o.useState(null),[U,te]=o.useState(null),[g,p]=o.useState(!1),h=l.stages.find(t=>t.id===J),T=h?.jobs.find(t=>t.id===U),d=o.useMemo(()=>{const t=[];return t.push(`name: ${l.name}`),t.push(""),t.push("on:"),l.triggers.forEach(x=>{t.push(` ${x}:`),(x==="push"||x==="pull_request")&&(t.push(" branches:"),t.push(` - ${l.branch||"main"}`))}),t.push(""),l.variables.length>0&&(t.push("env:"),l.variables.filter(x=>!x.isSecret).forEach(x=>{t.push(` ${x.name}: ${x.value}`)}),t.push("")),t.push("jobs:"),l.stages.forEach(x=>{x.jobs.forEach(u=>{t.push(` ${x.name.toLowerCase().replace(/\s+/g,"-")}-${u.name.toLowerCase().replace(/\s+/g,"-")}:`),t.push(` name: ${u.name}`),u.runner&&t.push(` runs-on: ${u.runner}`),x.dependsOn?.length&&t.push(` needs: [${x.dependsOn.join(", ")}]`),t.push(" steps:"),u.steps.forEach(R=>{R.type==="checkout"?t.push(" - uses: actions/checkout@v4"):R.type==="action"&&R.action?(t.push(` - uses: ${R.action}${R.actionVersion?`@${R.actionVersion}`:""}`),R.with&&Object.keys(R.with).length>0&&(t.push(" with:"),Object.entries(R.with).forEach(([ee,X])=>{t.push(` ${ee}: ${X}`)}))):R.type==="script"&&R.script&&(t.push(` - name: ${R.name}`),t.push(" run: |"),R.script.split(`
11
11
  `).forEach(ee=>{t.push(` ${ee}`)}))})})}),t.join(`
12
12
  `)},[l]),$=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(n.NiceIcon,{name:"settings",size:20}),e.jsx("input",{type:"text",value:l.name,onChange:t=>V({...l,name:t.target.value}),style:{padding:"6px 12px",borderRadius:"4px",border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:"14px",fontWeight:500,width:"250px"}})]}),e.jsx("div",{style:{flex:1}}),e.jsx(n.NiceTutorialButton,{steps:n.resolveTutorial(b,jt)}),e.jsx("button",{onClick:()=>p(!0),style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:"12px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"clipboard",size:14})," ",c("pipelineEditor.templates","Templates")]})}),e.jsx("button",{onClick:O,style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:"12px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"check",size:14})," ",c("pipelineEditor.validate","Validate")]})}),e.jsx("button",{onClick:i,style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"12px",fontWeight:500},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"save",size:14})," ",c("pipelineEditor.save","Save")]})}),e.jsx("button",{onClick:I,style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"12px",fontWeight:500},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"play",size:14})," ",c("pipelineEditor.runPipeline","Run Pipeline")]})})]}),q=e.jsx("div",{style:{display:"flex",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #1e1e1e)"},children:[{id:"visual",icon:"palette",label:c("pipelineEditor.visualEditor","Visual Editor")},{id:"yaml",icon:"edit",label:"YAML"},{id:"triggers",icon:"zap",label:c("pipelineEditor.triggers","Triggers")},{id:"variables",icon:"settings",label:c("pipelineEditor.variables","Variables")}].map(t=>e.jsx("button",{onClick:()=>Z(t.id),style:{padding:"10px 20px",border:"none",background:A===t.id?"var(--nice-bg-elevated, #1e1e1e)":"transparent",color:A===t.id?"var(--nice-text-primary, #fff)":"var(--nice-text-muted, #888)",cursor:"pointer",fontSize:"12px",borderBottom:A===t.id?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:t.icon,size:14})," ",t.label]})},t.id))}),s=e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",height:"100%"},children:[A==="visual"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{width:"300px",borderRight:"1px solid var(--nice-border-color, #333)",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px",borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px"},children:c("pipelineEditor.stages","Stages")}),e.jsx("button",{onClick:L,style:{padding:"4px 8px",borderRadius:"4px",border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"11px"},children:c("pipelineEditor.addStage","+ Add Stage")})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:"8px"},children:[l.stages.map((t,x)=>e.jsxs("div",{children:[x>0&&e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"4px",color:"var(--nice-text-primary, #444)"},children:e.jsx(n.NiceIcon,{name:"arrow-down",size:14})}),e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>{G(t.id),te(null)},style:{padding:"12px",background:J===t.id?"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))":"var(--nice-bg-elevated, #252525)",borderRadius:"8px",cursor:"pointer",border:J===t.id?"1px solid var(--nice-primary, #3b82f6)":"1px solid var(--nice-border-color, #333)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"8px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px"},children:t.name}),e.jsxs("div",{style:{display:"flex",gap:"4px"},children:[x>0&&e.jsx("button",{"aria-label":c("pipelineEditor.moveStageUp","Move stage up"),onClick:u=>{u.stopPropagation(),E(t.id,"up")},style:{padding:"2px 4px",background:"var(--nice-bg-tertiary, #333)",border:"none",borderRadius:"2px",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:e.jsx(n.NiceIcon,{name:"arrow-up",size:12})}),x<l.stages.length-1&&e.jsx("button",{"aria-label":c("pipelineEditor.moveStageDown","Move stage down"),onClick:u=>{u.stopPropagation(),E(t.id,"down")},style:{padding:"2px 4px",background:"var(--nice-bg-tertiary, #333)",border:"none",borderRadius:"2px",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:e.jsx(n.NiceIcon,{name:"arrow-down",size:12})}),e.jsx("button",{"aria-label":c("pipelineEditor.removeStage","Remove stage"),onClick:u=>{u.stopPropagation(),D(t.id)},style:{padding:"2px 4px",background:"var(--nice-color-error, #ef4444)",border:"none",borderRadius:"2px",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:e.jsx(n.NiceIcon,{name:"close",size:12})})]})]}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--nice-text-muted, #888)"},children:[t.jobs.length!==1?c("pipelineEditor.jobsMany","{count} jobs").replace("{count}",String(t.jobs.length)):c("pipelineEditor.jobsOne","{count} job").replace("{count}",String(t.jobs.length))," ","•"," ",t.parallel?c("pipelineEditor.parallel","Parallel"):c("pipelineEditor.sequential","Sequential")]})]})]},t.id)),l.stages.length===0&&e.jsx("div",{style:{textAlign:"center",color:"var(--nice-text-muted, #666)",padding:"24px",fontSize:"12px"},children:c("pipelineEditor.noStagesYetAddA","No stages yet. Add a stage to get started.")})]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",justifyContent:"space-between",alignItems:"center",background:"var(--nice-bg-elevated, #252525)"},children:[e.jsx("span",{style:{fontWeight:500},children:c("pipelineEditor.stage","Stage: {name}").replace("{name}",String(h.name))}),e.jsx("button",{onClick:()=>N(h.id),style:{padding:"4px 8px",borderRadius:"4px",border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"11px"},children:c("pipelineEditor.addJob","+ Add Job")})]}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[e.jsx("div",{style:{width:"200px",borderRight:"1px solid var(--nice-border-color, #333)",overflow:"auto",padding:"8px"},children:h.jobs.map(t=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>te(t.id),style:{padding:"10px",marginBottom:"4px",background:U===t.id?"var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2))":"var(--nice-bg-elevated, #252525)",borderRadius:"6px",cursor:"pointer",border:U===t.id?"1px solid var(--nice-primary, #3b82f6)":"1px solid transparent"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:t.name}),e.jsx("button",{"aria-label":c("pipelineEditor.removeJob","Remove job"),onClick:x=>{x.stopPropagation(),j(h.id,t.id)},style:{padding:"2px 4px",background:"var(--nice-color-error, #ef4444)",border:"none",borderRadius:"2px",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"9px"},children:e.jsx(n.NiceIcon,{name:"close",size:11})})]}),e.jsx("div",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)",marginTop:"4px"},children:c("pipelineEditor.steps","{steps} steps").replace("{steps}",String(t.steps.length))})]},t.id))}),T?e.jsxs("div",{style:{flex:1,overflow:"auto",padding:"16px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e.jsx("h3",{style:{margin:0,fontSize:"14px"},children:c("pipelineEditor.job","Job: {name}").replace("{name}",String(T.name))}),e.jsx("button",{onClick:()=>P(h.id,T.id),style:{padding:"4px 8px",borderRadius:"4px",border:"none",background:"var(--nice-color-accent, #8b5cf6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"11px"},children:c("pipelineEditor.addStep","+ Add Step")})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px",marginBottom:"16px",padding:"12px",background:"var(--nice-bg-elevated, #252525)",borderRadius:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"11px",color:"var(--nice-text-muted, #888)",display:"block",marginBottom:"4px"},children:c("pipelineEditor.runner","Runner")}),e.jsxs("select",{style:{width:"100%",padding:"6px",borderRadius:"4px",border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:"11px"},children:[e.jsx("option",{value:"",children:c("pipelineEditor.selectRunner","Select runner...")}),B.map(t=>e.jsxs("option",{value:t.id,children:[t.name," (",t.os,")"]},t.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{fontSize:"11px",color:"var(--nice-text-muted, #888)",display:"block",marginBottom:"4px"},children:c("pipelineEditor.environment","Environment")}),e.jsxs("select",{style:{width:"100%",padding:"6px",borderRadius:"4px",border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:"11px"},children:[e.jsx("option",{value:"",children:c("pipelineEditor.noEnvironment","No environment")}),_.map(t=>e.jsxs("option",{value:t.id,children:[t.name,t.protection?c("pipelineEditor.protected"," (protected)"):""]},t.id))]})]})]}),T.steps.map((t,x)=>e.jsxs("div",{style:{marginBottom:"8px",padding:"12px",background:"var(--nice-bg-elevated, #252525)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[e.jsx(n.NiceIcon,{name:St[t.type],size:16}),e.jsx("span",{style:{fontSize:"12px",fontWeight:500,flex:1},children:t.name}),e.jsx("span",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)",padding:"2px 6px",background:"var(--nice-bg-tertiary, #333)",borderRadius:"4px"},children:t.type}),e.jsx("button",{"aria-label":c("pipelineEditor.removeStep","Remove step"),onClick:()=>z(h.id,T.id,t.id),style:{padding:"2px 6px",background:"var(--nice-color-error, #ef4444)",border:"none",borderRadius:"4px",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:e.jsx(n.NiceIcon,{name:"close",size:12})})]}),t.type==="script"&&t.script&&e.jsx("pre",{style:{margin:0,padding:"8px",background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:"4px",fontSize:"10px",fontFamily:"monospace",overflow:"auto"},children:t.script}),t.type==="action"&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--nice-text-muted, #888)"},children:["uses: ",t.action,t.actionVersion&&`@${t.actionVersion}`]})]},t.id)),T.steps.length===0&&e.jsx("div",{style:{textAlign:"center",color:"var(--nice-text-muted, #666)",padding:"24px",fontSize:"12px"},children:c("pipelineEditor.noStepsYetAddA","No steps yet. Add a step to define what this job does.")})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #666)"},children:c("pipelineEditor.selectAJobToEdit","Select a job to edit its steps")})]})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #666)"},children:c("pipelineEditor.selectAStageToView","Select a stage to view its jobs")})})]}),A==="yaml"&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px"},children:e.jsx("pre",{style:{margin:0,padding:"16px",background:"var(--nice-bg-elevated, #252525)",borderRadius:"8px",fontFamily:"monospace",fontSize:"12px",lineHeight:"1.6",whiteSpace:"pre-wrap"},children:d})}),A==="triggers"&&e.jsxs("div",{style:{flex:1,overflow:"auto",padding:"24px"},children:[e.jsx("h3",{style:{margin:"0 0 16px 0",fontSize:"14px"},children:c("pipelineEditor.pipelineTriggers","Pipeline Triggers")}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"16px"},children:["push","pull_request","schedule","manual","tag","workflow_dispatch"].map(t=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"16px",background:"var(--nice-bg-elevated, #252525)",borderRadius:"8px",cursor:"pointer",border:l.triggers.includes(t)?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent"},children:[e.jsx("input",{type:"checkbox",checked:l.triggers.includes(t),onChange:x=>{const u=x.target.checked?[...l.triggers,t]:l.triggers.filter(R=>R!==t);V({...l,triggers:u})}}),e.jsx(n.NiceIcon,{name:kt[t],size:24}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:t.replace("_"," ")}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--nice-text-muted, #888)"},children:[t==="push"&&c("pipelineEditor.runOnPushToBranch","Run on push to branch"),t==="pull_request"&&c("pipelineEditor.runOnPrMr","Run on PR/MR"),t==="schedule"&&c("pipelineEditor.runOnScheduleCron","Run on schedule (cron)"),t==="manual"&&c("pipelineEditor.manualTriggerOnly","Manual trigger only"),t==="tag"&&c("pipelineEditor.runOnTagPush","Run on tag push"),t==="workflow_dispatch"&&c("pipelineEditor.apiUiTrigger","API/UI trigger")]})]})]},t))})]}),A==="variables"&&e.jsxs("div",{style:{flex:1,overflow:"auto",padding:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e.jsx("h3",{style:{margin:0,fontSize:"14px"},children:c("pipelineEditor.variablesSecrets","Variables & Secrets")}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:k,style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"11px"},children:c("pipelineEditor.addVariable","+ Add Variable")}),e.jsx("button",{onClick:v,style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-color-warning, #f59e0b)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"11px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[e.jsx(n.NiceIcon,{name:"lock",size:12})," ",c("pipelineEditor.addSecret","Add Secret")]})})]})]}),e.jsxs("div",{style:{background:"var(--nice-bg-elevated, #252525)",borderRadius:"8px",overflow:"hidden"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"var(--nice-bg-elevated, #1e1e1e)"},children:[e.jsx("th",{style:{padding:"10px 16px",textAlign:"left",fontWeight:500},children:c("pipelineEditor.name","Name")}),e.jsx("th",{style:{padding:"10px 16px",textAlign:"left",fontWeight:500},children:c("pipelineEditor.value","Value")}),e.jsx("th",{style:{padding:"10px 16px",textAlign:"center",fontWeight:500},children:c("pipelineEditor.type","Type")}),e.jsx("th",{style:{padding:"10px 16px",textAlign:"right",fontWeight:500},children:c("pipelineEditor.actions","Actions")})]})}),e.jsx("tbody",{children:l.variables.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"10px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",fontFamily:"monospace"},children:t.name}),e.jsx("td",{style:{padding:"10px 16px",borderBottom:"1px solid var(--nice-border-color, #333)"},children:t.isSecret?"••••••••":t.value}),e.jsx("td",{style:{padding:"10px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",textAlign:"center"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",borderRadius:"4px",background:t.isSecret?"var(--nice-warning-tint-15, #f59e0b22)":"var(--nice-primary-tint-15, #3b82f622)",color:t.isSecret?"var(--nice-color-warning, #f59e0b)":"var(--nice-color-primary, #3b82f6)",fontSize:"10px"},children:[t.isSecret&&e.jsx(n.NiceIcon,{name:"lock",size:10}),t.isSecret?c("pipelineEditor.secret","Secret"):c("pipelineEditor.variable","Variable")]})}),e.jsx("td",{style:{padding:"10px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",textAlign:"right"},children:e.jsx("button",{onClick:()=>S(t.name),style:{padding:"4px 8px",borderRadius:"4px",border:"none",background:"var(--nice-color-error, #ef4444)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:c("pipelineEditor.remove","Remove")})})]},t.name))})]}),l.variables.length===0&&e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--nice-text-muted, #666)",fontSize:"12px"},children:c("pipelineEditor.noVariablesDefined","No variables defined")})]})]})]});return e.jsxs(e.Fragment,{children:[e.jsx(He,{className:`nice-pipeline-editor ${Y||""}`,style:{background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",...F},flush:!0,menubar:$,toolbar:q,"data-testid":H,children:s}),g&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:e.jsxs("div",{style:{width:"600px",maxHeight:"80vh",background:"var(--nice-bg-elevated, #252525)",borderRadius:"12px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"16px",borderBottom:"1px solid var(--nice-border-color, #333)"},children:[e.jsx("span",{style:{fontWeight:600},children:c("pipelineEditor.pipelineTemplates","Pipeline Templates")}),e.jsx("button",{"aria-label":c("pipelineEditor.closeTemplates","Close templates"),onClick:()=>p(!1),style:{background:"none",border:"none",color:"var(--nice-text-muted, #888)",cursor:"pointer",fontSize:"18px"},children:e.jsx(n.NiceIcon,{name:"close",size:18})})]}),e.jsx("div",{style:{maxHeight:"60vh",overflow:"auto",padding:"16px"},children:w.map(t=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>{C(t),p(!1)},style:{display:"flex",alignItems:"center",gap:"16px",padding:"16px",marginBottom:"8px",background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:"8px",cursor:"pointer"},children:[e.jsx(n.NiceIcon,{name:t.icon,size:32}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",marginBottom:"4px"},children:t.name}),e.jsx("div",{style:{fontSize:"12px",color:"var(--nice-text-muted, #888)"},children:t.description}),e.jsx("div",{style:{fontSize:"10px",color:"var(--nice-text-muted, #666)",marginTop:"4px"},children:t.category})]})]},t.id))})]})})]})},Ct=Object.freeze(Object.defineProperty({__proto__:null,NicePipelineEditor:Le},Symbol.toStringTag,{value:"Module"})),wt=[],he={queued:{color:"var(--nice-text-muted, #6b7280)",icon:"clock",label:"Queued"},pending:{color:"var(--nice-text-muted, #6b7280)",icon:"clock",label:"Pending"},waiting:{color:"var(--nice-color-warning, #f59e0b)",icon:"pause",label:"Waiting"},in_progress:{color:"var(--nice-color-primary, #3b82f6)",icon:"refresh",label:"In Progress"},running:{color:"var(--nice-color-primary, #3b82f6)",icon:"refresh",label:"Running"},completed:{color:"var(--nice-color-success, #22c55e)",icon:"check",label:"Completed"},success:{color:"var(--nice-color-success, #22c55e)",icon:"check",label:"Success"},failed:{color:"var(--nice-color-error, #ef4444)",icon:"close",label:"Failed"},failure:{color:"var(--nice-color-error, #ef4444)",icon:"close",label:"Failed"},cancelled:{color:"var(--nice-text-muted, #6b7280)",icon:"close",label:"Cancelled"},skipped:{color:"var(--nice-text-muted, #6b7280)",icon:"skip-forward",label:"Skipped"}},Fe=({runs:a=wt,stats:f,selectedRunId:w,onRunSelect:B,onCancel:_,onRerun:W,onRerunFromStage:L,onDownloadArtifact:D,onDownloadLogs:E,onApprove:N,onReject:j,className:P,style:z,"data-testid":k})=>{const{t:S}=n.useNiceTranslation(),[v,M]=o.useState("all"),[C,i]=o.useState("all"),[I,O]=o.useState(new Set),[b,Y]=o.useState(new Set),[F,H]=o.useState(null),c=a.find(g=>g.id===w),l=o.useMemo(()=>a.filter(g=>!(v!=="all"&&g.status!==v||C!=="all"&&g.branch!==C)),[a,v,C]),V=o.useMemo(()=>[...new Set(a.map(g=>g.branch))],[a]),A=g=>{if(!g)return"-";const p=Math.floor(g/1e3);if(p<60)return`${p}s`;const h=Math.floor(p/60),T=p%60;if(h<60)return`${h}m ${T}s`;const d=Math.floor(h/60),$=h%60;return`${d}h ${$}m`},Z=g=>g?new Date(g).toLocaleString():"-",J=g=>g<1024?`${g} B`:g<1024*1024?`${(g/1024).toFixed(1)} KB`:`${(g/(1024*1024)).toFixed(1)} MB`,G=g=>{O(p=>{const h=new Set(p);return h.has(g)?h.delete(g):h.add(g),h})},U=g=>{Y(p=>{const h=new Set(p);return h.has(g)?h.delete(g):h.add(g),h})},te=()=>{if(!F||!c)return[];for(const g of c.stages)for(const p of g.jobs)if(p.id===F.jobId)return p.steps.find(T=>T.id===F.stepId)?.logs||[];return[]};return e.jsxs("div",{className:`nice-pipeline-monitor ${P||""}`,style:{display:"flex",height:"100%",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #e0e0e0)",...z},"data-testid":k,children:[e.jsxs("div",{style:{width:"400px",borderRight:"1px solid var(--nice-border-color, #333)",display:"flex",flexDirection:"column"},children:[f&&e.jsx("div",{style:{padding:"16px",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px",textAlign:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"20px",fontWeight:600,color:"var(--nice-color-primary, #3b82f6)"},children:f.totalRuns}),e.jsx("div",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)"},children:S("pipelineMonitor.totalRuns","Total Runs")})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"20px",fontWeight:600,color:"var(--nice-color-success, #22c55e)"},children:[f.successRate.toFixed(0),"%"]}),e.jsx("div",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)"},children:S("pipelineMonitor.successRate","Success Rate")})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"20px",fontWeight:600,color:"var(--nice-color-warning, #f59e0b)"},children:A(f.avgDuration)}),e.jsx("div",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)"},children:S("pipelineMonitor.avgDuration","Avg Duration")})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"20px",fontWeight:600,color:"var(--nice-color-error, #ef4444)"},children:f.failedRuns}),e.jsx("div",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)"},children:S("pipelineMonitor.failed","Failed")})]})]})}),e.jsxs("div",{style:{padding:"12px",borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",gap:"8px"},children:[e.jsxs("select",{value:v,onChange:g=>M(g.target.value),style:{flex:1,padding:"6px",borderRadius:"4px",border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:"11px"},children:[e.jsx("option",{value:"all",children:S("pipelineMonitor.allStatus","All Status")}),e.jsx("option",{value:"in_progress",children:S("pipelineMonitor.inProgress","In Progress")}),e.jsx("option",{value:"completed",children:S("pipelineMonitor.completed","Completed")}),e.jsx("option",{value:"failed",children:S("pipelineMonitor.failed","Failed")}),e.jsx("option",{value:"cancelled",children:S("pipelineMonitor.cancelled","Cancelled")})]}),e.jsxs("select",{value:C,onChange:g=>i(g.target.value),style:{flex:1,padding:"6px",borderRadius:"4px",border:"1px solid var(--nice-border-color, #444)",background:"var(--nice-bg-elevated, #1e1e1e)",color:"var(--nice-text-primary, #fff)",fontSize:"11px"},children:[e.jsx("option",{value:"all",children:S("pipelineMonitor.allBranches","All Branches")}),V.map(g=>e.jsx("option",{value:g,children:g},g))]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[l.map(g=>{const p=he[g.status];return e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>B(g.id),style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",cursor:"pointer",background:w===g.id?"var(--nice-primary-tint-10, rgba(59, 130, 246, 0.1))":"transparent"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"},children:[e.jsx("span",{style:{display:"inline-flex",color:p.color,animation:g.status==="in_progress"?"spin 1s linear infinite":"none"},children:e.jsx(n.NiceIcon,{name:p.icon,size:16})}),e.jsxs("span",{style:{flex:1,fontWeight:500,fontSize:"13px"},children:[g.pipelineName," #",g.runNumber]}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:"4px",background:`${p.color}22`,color:p.color,fontSize:"10px"},children:p.label})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontSize:"11px",color:"var(--nice-text-muted, #888)"},children:[e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:12})," ",g.branch]}),e.jsx("span",{children:"•"}),e.jsx("span",{children:g.commit.sha.slice(0,7)}),e.jsx("span",{children:"•"}),e.jsx("span",{children:A(g.duration)})]}),e.jsx("div",{style:{marginTop:"6px",fontSize:"11px",color:"var(--nice-text-muted, #666)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.commit.message})]},g.id)}),l.length===0&&e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--nice-text-muted, #666)",fontSize:"12px"},children:S("pipelineMonitor.noPipelineRunsMatchThe","No pipeline runs match the filters")})]})]}),e.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden"},children:c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"16px",borderBottom:"1px solid var(--nice-border-color, #333)",background:"var(--nice-bg-elevated, #252525)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"12px"},children:[e.jsxs("div",{children:[e.jsxs("h2",{style:{margin:"0 0 4px 0",fontSize:"16px",fontWeight:500},children:[c.pipelineName," #",c.runNumber]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",fontSize:"12px",color:"var(--nice-text-muted, #888)"},children:[e.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[c.commit.authorAvatar&&e.jsx("img",{src:c.commit.authorAvatar,alt:"",style:{width:"16px",height:"16px",borderRadius:"50%"}}),c.commit.author]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx(n.NiceIcon,{name:"shuffle",size:12})," ",c.branch]}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx(n.NiceIcon,{name:"edit",size:12})," ",c.commit.sha.slice(0,7)]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[(c.status==="in_progress"||c.status==="queued"||c.status==="waiting")&&e.jsx("button",{onClick:()=>_(c.id),style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-color-error, #ef4444)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"11px"},children:S("pipelineMonitor.cancel","Cancel")}),e.jsx("button",{onClick:()=>W(c.id),style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"11px"},children:S("pipelineMonitor.reRun","Re-run")}),e.jsxs("button",{onClick:()=>E(c.id),style:{padding:"6px 12px",borderRadius:"4px",border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:"11px",display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx(n.NiceIcon,{name:"download",size:14})," ",S("pipelineMonitor.logs","Logs")]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"12px"},children:[e.jsx("span",{children:S("pipelineMonitor.started","Started: {time}").replace("{time}",String(Z(c.startedAt)))}),c.completedAt&&e.jsx("span",{children:S("pipelineMonitor.completed2","Completed: {time}").replace("{time}",String(Z(c.completedAt)))}),e.jsx("span",{children:S("pipelineMonitor.duration","Duration: {duration}").replace("{duration}",String(A(c.duration)))})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:"16px"},children:[e.jsx("div",{style:{marginBottom:"24px"},children:c.stages.map((g,p)=>{const h=he[g.status],T=I.has(g.id);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>G(g.id),style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--nice-bg-elevated, #252525)",borderRadius:"8px",cursor:"pointer",border:`2px solid ${h.color}44`},children:[e.jsx("span",{style:{color:"var(--nice-text-muted, #666)",display:"inline-flex"},children:e.jsx(n.NiceIcon,{name:T?"chevron-down":"chevron-right",size:14})}),e.jsx("span",{style:{display:"inline-flex",color:h.color},children:e.jsx(n.NiceIcon,{name:h.icon,size:16})}),e.jsx("span",{style:{flex:1,fontWeight:500},children:g.name}),e.jsx("span",{style:{fontSize:"11px",color:"var(--nice-text-muted, #888)"},children:A(g.duration)}),g.status==="waiting"&&N&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:d=>{d.stopPropagation(),N(c.id,g.id)},style:{padding:"4px 8px",borderRadius:"4px",border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:S("pipelineMonitor.approve","Approve")}),e.jsx("button",{onClick:d=>{d.stopPropagation(),j?.(c.id,g.id)},style:{padding:"4px 8px",borderRadius:"4px",border:"none",background:"var(--nice-color-error, #ef4444)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:S("pipelineMonitor.reject","Reject")})]}),e.jsx("button",{onClick:d=>{d.stopPropagation(),L(c.id,g.id)},style:{padding:"4px 8px",borderRadius:"4px",border:"none",background:"var(--nice-bg-tertiary, #333)",color:"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:"10px"},children:S("pipelineMonitor.reRunFromHere","Re-run from here")})]}),T&&e.jsx("div",{style:{marginLeft:"32px",marginTop:"8px"},children:g.jobs.map(d=>{const $=he[d.status],q=b.has(d.id);return e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>U(d.id),style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 12px",background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:"6px",cursor:"pointer",borderLeft:`3px solid ${$.color}`},children:[e.jsx("span",{style:{color:"var(--nice-text-muted, #666)",display:"inline-flex"},children:e.jsx(n.NiceIcon,{name:q?"chevron-down":"chevron-right",size:12})}),e.jsx("span",{style:{display:"inline-flex",color:$.color},children:e.jsx(n.NiceIcon,{name:$.icon,size:14})}),e.jsx("span",{style:{flex:1,fontSize:"12px"},children:d.name}),d.runner&&e.jsxs("span",{style:{fontSize:"10px",color:"var(--nice-text-muted, #666)",display:"inline-flex",alignItems:"center",gap:"4px"},children:[e.jsx(n.NiceIcon,{name:"monitor",size:12})," ",d.runner]}),e.jsx("span",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)"},children:A(d.duration)})]}),q&&e.jsx("div",{style:{marginLeft:"24px",marginTop:"4px"},children:d.steps.map(s=>{const t=he[s.status];return e.jsxs("div",{role:s.logs?.length?"button":void 0,tabIndex:s.logs?.length?0:void 0,onKeyDown:s.logs?.length?n.clickOnActivationKey:void 0,onClick:()=>H({jobId:d.id,stepId:s.id}),style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 10px",marginBottom:"2px",background:"transparent",borderRadius:"4px",cursor:s.logs?.length?"pointer":"default"},children:[e.jsx("span",{style:{display:"inline-flex",color:t.color},children:e.jsx(n.NiceIcon,{name:t.icon,size:12})}),e.jsx("span",{style:{flex:1,fontSize:"11px"},children:s.name}),e.jsx("span",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)"},children:A(s.duration)}),s.logs?.length?e.jsx("span",{style:{display:"inline-flex",color:"var(--nice-text-muted, #666)"},children:e.jsx(n.NiceIcon,{name:"file",size:10})}):null]},s.id)})})]},d.id)})}),p<c.stages.length-1&&e.jsx("div",{style:{marginLeft:"24px",padding:"4px 0",color:"var(--nice-text-primary, #444)",display:"flex"},children:e.jsx(n.NiceIcon,{name:"arrow-down",size:14})})]},g.id)})}),c.artifacts.length>0&&e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsx("h3",{style:{margin:"0 0 12px 0",fontSize:"13px",color:"var(--nice-text-muted, #888)"},children:S("pipelineMonitor.artifacts","Artifacts")}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"8px"},children:c.artifacts.map(g=>e.jsxs("div",{role:"button",tabIndex:0,onKeyDown:n.clickOnActivationKey,onClick:()=>D(g),style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--nice-bg-elevated, #252525)",borderRadius:"8px",cursor:"pointer"},children:[e.jsx("span",{style:{display:"inline-flex"},children:e.jsx(n.NiceIcon,{name:"box",size:24})}),e.jsxs("div",{style:{flex:1,overflow:"hidden"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:g.name}),e.jsx("div",{style:{fontSize:"10px",color:"var(--nice-text-muted, #888)"},children:J(g.size)})]}),e.jsx("span",{style:{display:"inline-flex"},children:e.jsx(n.NiceIcon,{name:"download",size:16})})]},g.id))})]})]})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--nice-text-muted, #666)"},children:S("pipelineMonitor.selectAPipelineRunTo","Select a pipeline run to view details")})}),F&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-80, rgba(0, 0, 0, 0.8))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:e.jsxs("div",{style:{width:"80%",height:"80%",background:"var(--nice-bg-elevated, #1e1e1e)",borderRadius:"12px",overflow:"hidden",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--nice-border-color, #333)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{fontWeight:500},children:S("pipelineMonitor.stepLogs","Step Logs")}),e.jsx("button",{onClick:()=>H(null),"aria-label":S("pipelineMonitor.closeLogs","Close logs"),style:{background:"none",border:"none",color:"var(--nice-text-muted, #888)",cursor:"pointer",display:"inline-flex",alignItems:"center"},children:e.jsx(n.NiceIcon,{name:"close",size:18})})]}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:"12px"},children:e.jsx("pre",{style:{margin:0,fontFamily:"monospace",fontSize:"11px",lineHeight:"1.5",whiteSpace:"pre-wrap",color:"var(--nice-text-secondary, #d4d4d4)"},children:te().join(`
13
13
  `)||"No logs available"})})]})}),e.jsx("style",{children:`
@@ -15,4 +15,4 @@ ${d.message}`,children:d.author.name[0].toUpperCase()})]})},te=p=>{if(F!==p.line
15
15
  from { transform: rotate(0deg); }
16
16
  to { transform: rotate(360deg); }
17
17
  }
18
- `})]})},zt=Object.freeze(Object.defineProperty({__proto__:null,NicePipelineMonitor:Fe},Symbol.toStringTag,{value:"Module"}));exports.NiceAppShell=He;exports.NiceBranchManager=Be;exports.NiceBranchManager$1=Qe;exports.NiceConfirmDialog=Ce;exports.NiceGitBlame=Te;exports.NiceGitBlame$1=at;exports.NiceGitConflictResolver=_e;exports.NiceGitConflictResolver$1=ct;exports.NiceGitDiffViewer=Ee;exports.NiceGitDiffViewer$1=it;exports.NiceGitGraph=Ie;exports.NiceGitGraph$1=Xe;exports.NiceGitHooks=Ae;exports.NiceGitHooks$1=pt;exports.NiceMergeRequestBuilder=Me;exports.NiceMergeRequestBuilder$1=nt;exports.NiceOnScreenKeyboard=Oe;exports.NiceOnScreenKeyboardHost=De;exports.NicePipelineEditor=Le;exports.NicePipelineEditor$1=Ct;exports.NicePipelineMonitor=Fe;exports.NicePipelineMonitor$1=zt;exports.NicePromptDialog=ye;exports.ShellHintBar=$e;exports.scopeThemeClass=Se;exports.useIgnoredPropChangeWarning=we;exports.useNiceDialogs=Ne;exports.useShellInput=Pe;
18
+ `})]})},zt=Object.freeze(Object.defineProperty({__proto__:null,NicePipelineMonitor:Fe},Symbol.toStringTag,{value:"Module"}));exports.NiceAppShell=He;exports.NiceBranchManager=Be;exports.NiceBranchManager$1=Qe;exports.NiceConfirmDialog=Se;exports.NiceGitBlame=Te;exports.NiceGitBlame$1=at;exports.NiceGitConflictResolver=_e;exports.NiceGitConflictResolver$1=ct;exports.NiceGitDiffViewer=Ee;exports.NiceGitDiffViewer$1=it;exports.NiceGitGraph=Ie;exports.NiceGitGraph$1=Xe;exports.NiceGitHooks=Ae;exports.NiceGitHooks$1=pt;exports.NiceMergeRequestBuilder=Me;exports.NiceMergeRequestBuilder$1=nt;exports.NiceOnScreenKeyboard=Oe;exports.NiceOnScreenKeyboardHost=De;exports.NicePipelineEditor=Le;exports.NicePipelineEditor$1=Ct;exports.NicePipelineMonitor=Fe;exports.NicePipelineMonitor$1=zt;exports.NicePromptDialog=ye;exports.ShellHintBar=$e;exports.scopeThemeClass=Ce;exports.useIgnoredPropChangeWarning=we;exports.useNiceDialogs=Ne;exports.useShellInput=Pe;