@nice2dev/ui 1.0.21 → 1.0.23

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 (123) hide show
  1. package/CHANGELOG.md +198 -0
  2. package/dist/NiceErrorBoundary-B0262Ffc.js +770 -0
  3. package/dist/NiceErrorBoundary-BNhkOZtq.cjs +1 -0
  4. package/dist/NiceErrorBoundary-BXOLv-zG.cjs +1 -0
  5. package/dist/NiceErrorBoundary-DsreAsON.cjs +1 -0
  6. package/dist/NiceErrorBoundary-DyPWyuki.js +770 -0
  7. package/dist/NiceErrorBoundary-HMfrXIir.js +770 -0
  8. package/dist/NiceForm-B7D1MASh.js +5383 -0
  9. package/dist/NiceForm-BA9zZdm8.cjs +382 -0
  10. package/dist/NiceForm-Ba9rvBoT.cjs +382 -0
  11. package/dist/NiceForm-DAGMJpgx.js +5383 -0
  12. package/dist/NiceForm-D_ifvkIf.js +5386 -0
  13. package/dist/NiceForm-kd4essRP.cjs +382 -0
  14. package/dist/NiceForm.css +1 -1
  15. package/dist/NiceModal-4DLpDmAl.js +95 -0
  16. package/dist/NiceModal-BVT9cZbf.cjs +1 -0
  17. package/dist/NiceModal-CiOYOWJy.cjs +1 -0
  18. package/dist/NiceModal-D2xJTZZf.cjs +1 -0
  19. package/dist/NiceModal-DZbHCdKq.js +95 -0
  20. package/dist/NiceModal-MeC1cNtW.js +95 -0
  21. package/dist/NiceModuleLifecyclePanel-BZMUuDad.js +6807 -0
  22. package/dist/NiceModuleLifecyclePanel-BiX4KxaK.js +6781 -0
  23. package/dist/NiceModuleLifecyclePanel-C54g5eV_.cjs +1 -0
  24. package/dist/NiceModuleLifecyclePanel-CDo0iVfr.js +6781 -0
  25. package/dist/NiceModuleLifecyclePanel-DEJpoz5a.cjs +1 -0
  26. package/dist/NiceModuleLifecyclePanel-DrDTpH6K.cjs +1 -0
  27. package/dist/NiceModuleLifecyclePanel.css +1 -1
  28. package/dist/NicePagination-3be3_sVK.js +171 -0
  29. package/dist/NicePagination-BCRsVzkR.cjs +1 -0
  30. package/dist/NicePagination-C8gx6Bcl.js +171 -0
  31. package/dist/NicePagination-CNxEAb4C.cjs +1 -0
  32. package/dist/NicePagination-Cg_WEf-R.cjs +1 -0
  33. package/dist/NicePagination-DQXdzx7W.js +171 -0
  34. package/dist/NicePinCodeInput-3WugpLHi.js +12240 -0
  35. package/dist/NicePinCodeInput-BD2bMmVF.cjs +696 -0
  36. package/dist/NicePinCodeInput-CSfRHs4v.cjs +419 -0
  37. package/dist/NicePinCodeInput-CjwFvOEQ.js +13092 -0
  38. package/dist/NicePinCodeInput-DCLRLR8a.js +13097 -0
  39. package/dist/NicePinCodeInput-DoBQnMj9.cjs +694 -0
  40. package/dist/NiceSavedQueryPanel-DFDDuKWd.js +6597 -0
  41. package/dist/NiceSavedQueryPanel-DT9v7kUB.cjs +596 -0
  42. package/dist/NiceSavedQueryPanel-DTU4eiIH.cjs +596 -0
  43. package/dist/NiceSavedQueryPanel-RLj3BnDR.js +6866 -0
  44. package/dist/NiceSavedQueryPanel-qtWETcRP.cjs +596 -0
  45. package/dist/NiceSavedQueryPanel-z29D7N_A.js +6584 -0
  46. package/dist/NiceTabs-B4dM77y_.js +1657 -0
  47. package/dist/NiceTabs-BTVTtRZR.cjs +1 -0
  48. package/dist/NiceTabs-BXGmot7J.cjs +1 -0
  49. package/dist/NiceTabs-CFA8DGYR.cjs +1 -0
  50. package/dist/NiceTabs-Cx9DN6QD.js +1657 -0
  51. package/dist/NiceTabs-DJdhKste.js +1657 -0
  52. package/dist/NiceWindow-5VCSBJrc.js +1592 -0
  53. package/dist/NiceWindow-BEFAUTLp.cjs +1 -0
  54. package/dist/NiceWindow-Cs6-Dbci.js +1592 -0
  55. package/dist/NiceWindow-DYw4NCeb.js +1592 -0
  56. package/dist/NiceWindow-O_g8StvA.cjs +1 -0
  57. package/dist/NiceWindow-a4wB_m30.cjs +1 -0
  58. package/dist/NiceWindow.css +1 -0
  59. package/dist/charts-BDr6B81L.js +4657 -0
  60. package/dist/charts-Ci_KrAoU.cjs +761 -0
  61. package/dist/charts-ClxW-i5q.js +4657 -0
  62. package/dist/charts-De7FYS1U.cjs +761 -0
  63. package/dist/charts-DjFvhCdD.js +4657 -0
  64. package/dist/charts-Dr_FIPZT.cjs +761 -0
  65. package/dist/charts.cjs +1 -1
  66. package/dist/charts.mjs +1 -1
  67. package/dist/core-BIz6zQ5u.cjs +122 -0
  68. package/dist/core-BYxnKGOi.js +23141 -0
  69. package/dist/core-CT5vpy5U.js +25248 -0
  70. package/dist/core-CZE5v34h.cjs +122 -0
  71. package/dist/core-Cjw8oBvC.cjs +96 -0
  72. package/dist/core-xcuNJ-DB.js +24948 -0
  73. package/dist/data-branching-B7dCyaWr.cjs +1 -0
  74. package/dist/data-branching-BPAeL45o.js +6133 -0
  75. package/dist/data-branching-Byz79mmA.cjs +1 -0
  76. package/dist/data-branching-DjuerHfS.js +6133 -0
  77. package/dist/data-branching.cjs +1 -1
  78. package/dist/data-branching.d.ts +3 -0
  79. package/dist/data-branching.mjs +1 -1
  80. package/dist/data.cjs +1 -1
  81. package/dist/data.d.ts +45 -7
  82. package/dist/data.mjs +1 -1
  83. package/dist/devops-C3Pmbnxc.js +7684 -0
  84. package/dist/devops-CrXz348W.cjs +17 -0
  85. package/dist/devops-DYFov8j3.js +7684 -0
  86. package/dist/devops-g4qcLXah.cjs +17 -0
  87. package/dist/devops.cjs +1 -1
  88. package/dist/devops.d.ts +5 -0
  89. package/dist/devops.mjs +1 -1
  90. package/dist/editors.cjs +1 -1
  91. package/dist/editors.d.ts +175 -1
  92. package/dist/editors.mjs +44 -41
  93. package/dist/feedback.cjs +1 -1
  94. package/dist/feedback.d.ts +1 -2
  95. package/dist/feedback.mjs +2 -2
  96. package/dist/index-9Gi1mNY7.js +67912 -0
  97. package/dist/index-AEO3cK4T.cjs +5194 -0
  98. package/dist/index-BMQ-F0zE.js +65054 -0
  99. package/dist/index-BNb9q4Ll.cjs +5490 -0
  100. package/dist/index-CjdfogVa.js +66711 -0
  101. package/dist/index-Di3Cgr1P.cjs +5518 -0
  102. package/dist/index.cjs +1 -1
  103. package/dist/index.css +1 -1
  104. package/dist/index.d.ts +752 -62
  105. package/dist/index.mjs +982 -963
  106. package/dist/lazy.cjs +1 -1
  107. package/dist/lazy.d.ts +11 -0
  108. package/dist/lazy.mjs +24 -24
  109. package/dist/navigation.cjs +1 -1
  110. package/dist/navigation.d.ts +30 -4
  111. package/dist/navigation.mjs +34 -34
  112. package/dist/no-code-CHvv1KjZ.cjs +332 -0
  113. package/dist/no-code-CyvddsYt.js +7133 -0
  114. package/dist/no-code-Dl3ima61.cjs +332 -0
  115. package/dist/no-code-ktRzFaET.js +7133 -0
  116. package/dist/no-code.cjs +1 -1
  117. package/dist/no-code.d.ts +11 -0
  118. package/dist/no-code.mjs +1 -1
  119. package/dist/overlays.cjs +1 -1
  120. package/dist/overlays.d.ts +38 -0
  121. package/dist/overlays.mjs +52 -52
  122. package/dist/style.css +7 -4
  123. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),l=require("react"),Z=require("./core-BIz6zQ5u.cjs");function pe(c=new Date){const w=new Date().getTime()-c.getTime(),j=Math.floor(w/1e3),k=Math.floor(j/60),D=Math.floor(k/60),F=Math.floor(D/24);let L;return j<60?L="just now":k<60?L=`${k} minute${k>1?"s":""} ago`:D<24?L=`${D} hour${D>1?"s":""} ago`:F<30?L=`${F} day${F>1?"s":""} ago`:L=c.toLocaleDateString(),{date:c,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,relative:L}}function ue(c){return c.substring(0,7)}function xe(c){const y=c||crypto.randomUUID();return{id:y,shortId:ue(y)}}const Q=["development","testing","uat","staging","production"],B={development:"var(--nice-success, #22c55e)",testing:"var(--nice-primary, #3b82f6)",uat:"var(--nice-warning, #f59e0b)",staging:"var(--nice-accent, #8b5cf6)",production:"var(--nice-danger, #ef4444)"},_={development:"🛠️",testing:"🧪",uat:"👥",staging:"🚀",production:"🏭"};function ee(c){return Q.indexOf(c)}function oe(c,y){return ee(c)<ee(y)}const ge=[{name:"customers",displayName:"Customers",recordCount:15420,sizeBytes:256e5,module:"CRM"},{name:"products",displayName:"Products",recordCount:3200,sizeBytes:85e5,module:"Inventory"},{name:"orders",displayName:"Orders",recordCount:48500,sizeBytes:125e6,module:"Sales"},{name:"order_items",displayName:"Order Items",recordCount:156e3,sizeBytes:45e6,module:"Sales",hasForeignKeys:!0},{name:"invoices",displayName:"Invoices",recordCount:42e3,sizeBytes:85e6,module:"Finance"},{name:"employees",displayName:"Employees",recordCount:450,sizeBytes:25e5,module:"HR"},{name:"config",displayName:"Configuration",recordCount:1200,sizeBytes:5e5,module:"System"}],he=[{id:"prod-1",shortId:"prod-1",name:"production",displayName:"Production",description:"Live production environment",isDefault:!0,isProtected:!0,createdBy:{id:"system",name:"System"},createdAt:{date:new Date("2024-01-01"),relative:"1 year ago"},lastActivity:{date:new Date,relative:"just now"},status:"active",type:"data",environment:"production",tenant:"tenant-1",size:{records:265770,bytes:2921e5}},{id:"uat-1",shortId:"uat-1",name:"uat",displayName:"UAT",description:"User Acceptance Testing",isDefault:!1,isProtected:!0,createdBy:{id:"admin",name:"Admin"},createdAt:{date:new Date("2025-01-15"),relative:"3 months ago"},lastActivity:{date:new Date,relative:"2 days ago"},upstream:"prod-1",status:"active",type:"data",environment:"uat",tenant:"tenant-1",sourceSnapshot:"snapshot-prod-20250115",size:{records:265e3,bytes:29e7}},{id:"dev-1",shortId:"dev-1",name:"development",displayName:"Development",description:"Development environment",isDefault:!1,isProtected:!1,createdBy:{id:"dev-1",name:"Developer"},createdAt:{date:new Date("2025-03-01"),relative:"1 month ago"},lastActivity:{date:new Date,relative:"1 hour ago"},upstream:"uat-1",status:"active",type:"data",environment:"development",tenant:"tenant-1",tables:["customers","products","orders"],size:{records:67120,bytes:1591e5}}],ie=({tenant:c,branches:y,currentUser:w={id:"user-1",name:"Current User"},availableTables:j=ge,readOnly:k=!1,onCreateBranch:D,onDeleteBranch:F,onSwitchBranch:L,onCloneBranch:q,onSyncBranch:H,onProtectBranch:N,onScheduleSync:f,className:b,style:K,"data-testid":C})=>{const[R,x]=l.useState(y??he),[O,m]=l.useState(null),[V,v]=l.useState(null),[I,T]=l.useState("development"),[a,h]=l.useState(""),[p,M]=l.useState([]),[P,s]=l.useState(!0),[z,W]=l.useState({requireApproval:!0,approversCount:1,requireBackup:!0,allowDirectChanges:!1}),[S,o]=l.useState({enabled:!1,frequency:"daily",direction:"pull"}),t=l.useMemo(()=>R.find(n=>n.id===O),[R,O]),r=l.useMemo(()=>{const n={production:[],staging:[],uat:[],testing:[],development:[]};return R.forEach(u=>{n[u.environment].push(u)}),n},[R]),d=n=>n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:n<1024*1024*1024?`${(n/(1024*1024)).toFixed(1)} MB`:`${(n/(1024*1024*1024)).toFixed(1)} GB`,g=l.useCallback(()=>{const n={...xe(),name:a||`${I}-${Date.now()}`,displayName:a||I,isDefault:!1,isProtected:!1,createdBy:w,createdAt:pe(),status:"active",type:"data",environment:I,tenant:c,sourceSnapshot:t?.id,upstream:t?.id,tables:P?void 0:p,size:{records:0,bytes:0}};x(u=>[...u,n]),D?.(n),q?.(t?.id??"",I,P?void 0:p),v(null),A()},[a,I,t,P,p,w,c,D,q]),A=()=>{h(""),T("development"),M([]),s(!0)},U=l.useCallback(()=>{t&&(x(n=>n.filter(u=>u.id!==t.id)),F?.(t.id),m(null),v(null))},[t,F]),E=n=>{t&&(H?.(t.id,n),v(null))},Y=()=>{t&&(x(n=>n.map(u=>u.id===t.id?{...u,isProtected:!0}:u)),N?.(t.id,z),v(null))},i={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"};return e.jsxs("div",{className:`nice-data-branch-manager ${b||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:i.bg,color:i.text,fontFamily:"system-ui, sans-serif",...K},"data-testid":C,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${i.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{margin:0,fontSize:16},children:"🗃️ Data Environments"}),e.jsxs("span",{style:{fontSize:12,color:i.textMuted},children:["Tenant: ",c," • ",R.length," environments"]})]}),!k&&e.jsx("button",{onClick:()=>{m(R.find(n=>n.isDefault)?.id??null),v("clone")},style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"+ New Environment"})]}),e.jsx("div",{style:{padding:16,borderBottom:`1px solid ${i.border}`,display:"flex",alignItems:"center",gap:8,overflowX:"auto"},children:Q.map((n,u)=>{const $=r[n],G=$.length>0;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 16px",borderRadius:6,background:G?B[n]+"20":i.cardBg,border:`2px solid ${G?B[n]:i.border}`,opacity:G?1:.5,cursor:G?"pointer":"default"},onClick:()=>G&&m($[0].id),children:[e.jsx("div",{style:{fontSize:18},children:_[n]}),e.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase"},children:n}),G&&e.jsxs("div",{style:{fontSize:10,color:i.textMuted},children:[$.length," branch",$.length>1?"es":""]})]}),u<Q.length-1&&e.jsx("div",{style:{color:i.textMuted,fontSize:20},children:"→"})]},n)})}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{width:300,borderRight:`1px solid ${i.border}`,overflow:"auto"},children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${i.border}`,fontSize:11,color:i.textMuted},children:"All Environments"}),R.map(n=>e.jsxs("div",{onClick:()=>m(n.id),style:{padding:"12px 16px",borderBottom:`1px solid ${i.border}`,background:O===n.id?i.cardBg:"transparent",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:16},children:_[n.environment]}),e.jsx("span",{style:{fontWeight:500},children:n.displayName}),n.isProtected&&e.jsx("span",{style:{fontSize:12},children:"🔒"}),n.isDefault&&e.jsx("span",{style:{padding:"2px 6px",background:B[n.environment],borderRadius:4,fontSize:9,fontWeight:600},children:"DEFAULT"})]}),e.jsxs("div",{style:{fontSize:11,color:i.textMuted,marginTop:4},children:[n.size?.records.toLocaleString()," records •"," ",d(n.size?.bytes??0)]}),e.jsx("div",{style:{fontSize:10,color:i.textMuted,marginTop:2},children:n.lastActivity?.relative})]},n.id))]}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx("span",{style:{fontSize:32},children:_[t.environment]}),e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:20},children:t.displayName}),e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",background:B[t.environment],borderRadius:4,fontSize:10,fontWeight:600,marginTop:4},children:t.environment.toUpperCase()})]})]}),t.description&&e.jsx("p",{style:{color:i.textMuted,margin:"8px 0"},children:t.description})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:24},children:[{label:"Records",value:t.size?.records.toLocaleString()??"0"},{label:"Size",value:d(t.size?.bytes??0)},{label:"Tables",value:t.tables?.length.toString()??"All"},{label:"Status",value:t.status}].map(n=>e.jsxs("div",{style:{padding:12,background:i.cardBg,borderRadius:8,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:600},children:n.value}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:n.label})]},n.label))}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h4",{style:{margin:"0 0 12px 0",fontSize:14},children:"Details"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr",gap:"8px 16px",fontSize:13},children:[e.jsx("span",{style:{color:i.textMuted},children:"Created by"}),e.jsx("span",{children:t.createdBy.name}),e.jsx("span",{style:{color:i.textMuted},children:"Created at"}),e.jsx("span",{children:t.createdAt.date?.toLocaleString()}),e.jsx("span",{style:{color:i.textMuted},children:"Last activity"}),e.jsx("span",{children:t.lastActivity?.relative}),t.upstream&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:i.textMuted},children:"Source"}),e.jsx("span",{children:R.find(n=>n.id===t.upstream)?.displayName??"Unknown"})]}),t.sourceSnapshot&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:i.textMuted},children:"Snapshot"}),e.jsx("span",{children:t.sourceSnapshot})]})]})]}),t.tables&&e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px 0",fontSize:14},children:["Included Tables (",t.tables.length,")"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:t.tables.map(n=>e.jsxs("span",{style:{padding:"4px 10px",background:i.cardBg,borderRadius:4,fontSize:12},children:["🗃️ ",n]},n))})]}),!k&&e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsx("button",{onClick:()=>L?.(t.id),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"⚡ Switch to this environment"}),e.jsx("button",{onClick:()=>v("clone"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"📋 Clone"}),e.jsx("button",{onClick:()=>v("sync"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"🔄 Sync"}),!t.isProtected&&e.jsx("button",{onClick:()=>v("protect"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"🔒 Protect"}),!t.isDefault&&!t.isProtected&&e.jsx("button",{onClick:()=>v("delete"),style:{padding:"8px 16px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:12},children:"🗑️ Delete"})]})]}):e.jsxs("div",{style:{padding:32,textAlign:"center",color:i.textMuted},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:"🗃️"}),e.jsx("div",{children:"Select an environment to view details"})]})})]}),V==="clone"&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>v(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:i.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},children:[e.jsx("h3",{style:{margin:"0 0 16px 0"},children:"📋 Clone Environment"}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:i.textMuted},children:"Source Environment"}),e.jsxs("div",{style:{padding:12,background:i.bg,borderRadius:6,display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{children:_[t?.environment??"production"]}),e.jsx("span",{children:t?.displayName??"Production"})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:i.textMuted},children:"Target Environment"}),e.jsx("select",{value:I,onChange:n=>T(n.target.value),style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13},children:Q.filter(n=>oe(t?.environment??"production",n)||n==="development"||n==="testing").map(n=>e.jsxs("option",{value:n,children:[_[n]," ",n.charAt(0).toUpperCase()+n.slice(1)]},n))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:i.textMuted},children:"Environment Name"}),e.jsx("input",{type:"text",value:a,onChange:n=>h(n.target.value),placeholder:`${I}-${new Date().toISOString().split("T")[0]}`,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13}})]}),e.jsx("div",{style:{marginBottom:16},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:n=>s(n.target.checked)}),e.jsx("span",{style:{fontSize:13},children:"Include all tables"})]})}),!P&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",marginBottom:6,fontSize:12,color:i.textMuted},children:["Select Tables (",p.length," selected)"]}),e.jsx("div",{style:{maxHeight:200,overflow:"auto",border:`1px solid ${i.border}`,borderRadius:6},children:j.map(n=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:`1px solid ${i.border}`,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:p.includes(n.name),onChange:u=>{u.target.checked?M($=>[...$,n.name]):M($=>$.filter(G=>G!==n.name))}}),e.jsx("span",{style:{flex:1,fontSize:13},children:n.displayName}),e.jsxs("span",{style:{fontSize:11,color:i.textMuted},children:[n.recordCount.toLocaleString()," rows"]})]},n.name))})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>v(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:g,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Clone Environment"})]})]})}),V==="sync"&&t&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>v(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:i.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsx("h3",{style:{margin:"0 0 16px 0"},children:"🔄 Sync Environment"}),e.jsxs("p",{style:{color:i.textMuted,fontSize:13,marginBottom:16},children:["Synchronize data between ",t.displayName," and its source."]}),e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("button",{onClick:()=>E("pull"),style:{flex:1,padding:"16px",borderRadius:8,border:`2px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:24,marginBottom:8},children:"⬇️"}),e.jsx("div",{style:{fontWeight:500},children:"Pull"}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Get changes from source"})]}),e.jsxs("button",{onClick:()=>E("push"),disabled:t.environment==="production",style:{flex:1,padding:"16px",borderRadius:8,border:`2px solid ${i.border}`,background:"transparent",color:t.environment==="production"?i.textMuted:i.text,cursor:t.environment==="production"?"not-allowed":"pointer",textAlign:"center",opacity:t.environment==="production"?.5:1},children:[e.jsx("div",{style:{fontSize:24,marginBottom:8},children:"⬆️"}),e.jsx("div",{style:{fontWeight:500},children:"Push"}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Send changes to source"})]})]}),e.jsx("button",{onClick:()=>v(null),style:{width:"100%",padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"Cancel"})]})}),V==="delete"&&t&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>v(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:i.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsx("h3",{style:{margin:"0 0 16px 0",color:"var(--color-error, #ef4444)"},children:"🗑️ Delete Environment"}),e.jsxs("p",{style:{color:i.textMuted,fontSize:13,marginBottom:16},children:["Are you sure you want to delete ",e.jsx("strong",{children:t.displayName}),"? This will remove all ",t.size?.records.toLocaleString()," records."]}),e.jsx("div",{style:{padding:12,background:"var(--nice-danger-tint-15, #ef444420)",border:"1px solid var(--nice-danger, #ef4444)",borderRadius:6,marginBottom:16,fontSize:12},children:"⚠️ This action cannot be undone."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>v(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:U,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-error, #ef4444)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Delete Environment"})]})]})}),V==="protect"&&t&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>v(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:i.cardBg,borderRadius:12,padding:24,width:450},children:[e.jsx("h3",{style:{margin:"0 0 16px 0"},children:"🔒 Protect Environment"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:z.requireApproval,onChange:n=>W(u=>({...u,requireApproval:n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Require approval for changes"})]}),z.requireApproval&&e.jsxs("div",{style:{marginLeft:24},children:[e.jsx("label",{style:{display:"block",marginBottom:4,fontSize:11,color:i.textMuted},children:"Minimum approvers"}),e.jsx("input",{type:"number",min:1,max:5,value:z.approversCount,onChange:n=>W(u=>({...u,approversCount:parseInt(n.target.value)||1})),style:{width:80,padding:6,borderRadius:4,border:`1px solid ${i.border}`,background:i.bg,color:i.text}})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:z.requireBackup,onChange:n=>W(u=>({...u,requireBackup:n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Require backup before changes"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!z.allowDirectChanges,onChange:n=>W(u=>({...u,allowDirectChanges:!n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Block direct changes (require merge)"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>v(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:Y,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-warning, #f59e0b)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Apply Protection"})]})]})})]})},ye=Object.freeze(Object.defineProperty({__proto__:null,NiceDataBranchManager:ie},Symbol.toStringTag,{value:"Module"})),fe=[{table:"customers",displayName:"Customers",module:"CRM",added:15,modified:42,deleted:3,records:[{id:"CUST-001",changeType:"added",primaryKey:{customer_id:"CUST-001"},fields:[{field:"name",fieldType:"string",oldValue:void 0,newValue:"Acme Corp",changeType:"added"},{field:"email",fieldType:"string",oldValue:void 0,newValue:"info@acme.com",changeType:"added"},{field:"status",fieldType:"string",oldValue:void 0,newValue:"active",changeType:"added"}],changedAt:new Date,changedBy:"admin"},{id:"CUST-042",changeType:"modified",primaryKey:{customer_id:"CUST-042"},fields:[{field:"email",fieldType:"string",oldValue:"old@email.com",newValue:"new@email.com",changeType:"modified"},{field:"phone",fieldType:"string",oldValue:"+1-555-0100",newValue:"+1-555-0199",changeType:"modified"},{field:"updated_at",fieldType:"datetime",oldValue:"2025-01-01",newValue:"2025-04-01",changeType:"modified"}],changedAt:new Date,changedBy:"user1"},{id:"CUST-099",changeType:"deleted",primaryKey:{customer_id:"CUST-099"},fields:[{field:"name",fieldType:"string",oldValue:"Old Customer",newValue:void 0,changeType:"deleted"},{field:"status",fieldType:"string",oldValue:"inactive",newValue:void 0,changeType:"deleted"}],changedAt:new Date,changedBy:"admin"}]},{table:"products",displayName:"Products",module:"Inventory",added:8,modified:25,deleted:0,records:[{id:"PROD-NEW-1",changeType:"added",primaryKey:{product_id:"PROD-NEW-1"},fields:[{field:"name",fieldType:"string",oldValue:void 0,newValue:"New Product",changeType:"added"},{field:"price",fieldType:"decimal",oldValue:void 0,newValue:99.99,changeType:"added"}],changedAt:new Date,changedBy:"inventory_admin"}]},{table:"orders",displayName:"Orders",module:"Sales",added:156,modified:12,deleted:0,records:[]},{table:"config",displayName:"Configuration",module:"System",added:0,modified:3,deleted:0,records:[{id:"CFG-TAX-RATE",changeType:"modified",primaryKey:{config_key:"tax_rate"},fields:[{field:"value",fieldType:"decimal",oldValue:.2,newValue:.21,changeType:"modified"}],changedAt:new Date,changedBy:"admin"}]}],de=({sourceBranch:c,targetBranch:y,branches:w=[],diffItems:j=fe,onCompare:k,onExport:D,onSelectRecord:F,className:L,style:q,"data-testid":H})=>{const[N,f]=l.useState("summary"),[b,K]=l.useState("all"),[C,R]=l.useState(null),[x,O]=l.useState(null),[m,V]=l.useState(""),[v,I]=l.useState(!1),[T,a]=l.useState(c?.id??""),[h,p]=l.useState(y?.id??""),M=l.useMemo(()=>j.reduce((r,d)=>({tables:r.tables+1,added:r.added+d.added,modified:r.modified+d.modified,deleted:r.deleted+d.deleted}),{tables:0,added:0,modified:0,deleted:0}),[j]),P=l.useMemo(()=>j.filter(r=>{if(b==="added"&&r.added===0||b==="modified"&&r.modified===0||b==="deleted"&&r.deleted===0)return!1;if(m){const d=m.toLowerCase();return r.table.toLowerCase().includes(d)||r.displayName.toLowerCase().includes(d)||r.module?.toLowerCase().includes(d)}return!0}).sort((r,d)=>d.added+d.modified+d.deleted-(r.added+r.modified+r.deleted)),[j,b,m]),s=l.useMemo(()=>j.find(r=>r.table===C),[j,C]),z=l.useMemo(()=>s?s.records.filter(r=>b==="all"?!0:r.changeType===b):[],[s,b]),W=l.useCallback(()=>{T&&h&&k?.(T,h)},[T,h,k]),S=r=>{switch(r){case"added":return"var(--color-success, #22c55e)";case"modified":return"var(--color-warning, #f59e0b)";case"deleted":return"var(--color-error, #ef4444)";default:return"var(--text-muted, #888)"}},o=r=>{switch(r){case"added":return"+";case"modified":return"~";case"deleted":return"-";default:return" "}},t={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"};return e.jsxs("div",{className:`nice-data-diff-viewer ${L||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...q},"data-testid":H,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsx("h3",{style:{margin:0,fontSize:16},children:"📊 Data Diff Viewer"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("select",{value:T,onChange:r=>a(r.target.value),style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Select source..."}),w.map(r=>e.jsxs("option",{value:r.id,children:[_[r.environment]," ",r.displayName]},r.id))]}),e.jsx("span",{style:{color:t.textMuted},children:"→"}),e.jsxs("select",{value:h,onChange:r=>p(r.target.value),style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Select target..."}),w.map(r=>e.jsxs("option",{value:r.id,children:[_[r.environment]," ",r.displayName]},r.id))]}),e.jsx("button",{onClick:W,disabled:!T||!h,style:{padding:"6px 12px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:T&&h?"pointer":"not-allowed",fontSize:12,opacity:T&&h?1:.5},children:"Compare"})]}),e.jsx("div",{style:{flex:1}}),e.jsxs("select",{onChange:r=>{r.target.value&&(D?.(r.target.value),r.target.value="")},style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"📥 Export..."}),e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"csv",children:"CSV"}),e.jsx("option",{value:"sql",children:"SQL Script"})]})]}),e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:t.textMuted,fontSize:12},children:"Tables:"}),e.jsx("span",{style:{fontWeight:600},children:M.tables})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:S("added")}}),e.jsxs("span",{style:{fontSize:12},children:["+",M.added," added"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:S("modified")}}),e.jsxs("span",{style:{fontSize:12},children:["~",M.modified," modified"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:S("deleted")}}),e.jsxs("span",{style:{fontSize:12},children:["-",M.deleted," deleted"]})]}),e.jsx("div",{style:{flex:1}}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","added","modified","deleted"].map(r=>e.jsx("button",{onClick:()=>K(r),style:{padding:"4px 12px",borderRadius:4,border:"none",background:b===r?"var(--color-primary, #3b82f6)":t.cardBg,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:r},r))}),e.jsx("input",{type:"text",value:m,onChange:r=>V(r.target.value),placeholder:"Search tables...",style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12,width:180}})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{width:280,borderRight:`1px solid ${t.border}`,overflow:"auto"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,fontSize:11,color:t.textMuted},children:["Tables (",P.length,")"]}),P.map(r=>e.jsxs("div",{onClick:()=>{R(r.table),O(null),f("table")},style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,background:C===r.table?t.cardBg:"transparent",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontSize:14},children:"🗃️"}),e.jsx("span",{style:{fontWeight:500,fontSize:13},children:r.displayName})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:11},children:[r.added>0&&e.jsxs("span",{style:{color:S("added")},children:["+",r.added]}),r.modified>0&&e.jsxs("span",{style:{color:S("modified")},children:["~",r.modified]}),r.deleted>0&&e.jsxs("span",{style:{color:S("deleted")},children:["-",r.deleted]})]}),r.module&&e.jsx("div",{style:{fontSize:10,color:t.textMuted,marginTop:4},children:r.module})]},r.table))]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[N==="summary"&&e.jsxs("div",{style:{padding:32,textAlign:"center",color:t.textMuted},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:"📊"}),e.jsx("div",{children:"Select a table to view changes"})]}),N==="table"&&s&&e.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{margin:0,fontSize:14},children:s.displayName}),e.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:[s.table," • ",s.module]})]}),e.jsxs("div",{style:{display:"flex",gap:8,fontSize:12},children:[e.jsxs("span",{style:{color:S("added")},children:["+",s.added]}),e.jsxs("span",{style:{color:S("modified")},children:["~",s.modified]}),e.jsxs("span",{style:{color:S("deleted")},children:["-",s.deleted]})]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:z.length===0?e.jsx("div",{style:{padding:32,textAlign:"center",color:t.textMuted},children:"No records match the current filter"}):e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:t.cardBg},children:[e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Change"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Record ID"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Fields Changed"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Changed By"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Date"})]})}),e.jsx("tbody",{children:z.map(r=>e.jsxs("tr",{onClick:()=>{O(r),f("record")},style:{cursor:"pointer",background:x?.id===r.id?t.cardBg:"transparent"},children:[e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:4,background:S(r.changeType)+"30",color:S(r.changeType),fontWeight:600,fontSize:14},children:o(r.changeType)})}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace"},children:r.id}),e.jsxs("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:[r.fields.length," field",r.fields.length!==1?"s":""]}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:r.changedBy??"-"}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:r.changedAt?.toLocaleString()??"-"})]},r.id))})]})})]}),N==="record"&&x&&s&&e.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("button",{onClick:()=>f("table"),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsxs("div",{children:[e.jsxs("h4",{style:{margin:0,fontSize:14},children:[s.displayName," / ",x.id]}),e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",background:S(x.changeType)+"30",color:S(x.changeType),borderRadius:4,fontSize:10,fontWeight:600,marginTop:4,textTransform:"uppercase"},children:x.changeType})]})]}),e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,background:t.cardBg},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:4},children:"Primary Key"}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:12},children:Object.entries(x.primaryKey).map(([r,d])=>e.jsxs("span",{style:{marginRight:16},children:[e.jsxs("span",{style:{color:t.textMuted},children:[r,":"]})," ",String(d)]},r))})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:16},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:t.cardBg},children:[e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`,width:30}}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Field"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Type"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Source Value"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Target Value"})]})}),e.jsx("tbody",{children:x.fields.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`},children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:4,background:S(r.changeType)+"30",color:S(r.changeType),fontWeight:600,fontSize:12},children:o(r.changeType)})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontWeight:500},children:r.field}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:r.fieldType}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace",background:r.changeType==="deleted"?"var(--nice-danger-tint-15, #ef444420)":"transparent"},children:r.oldValue!==void 0?String(r.oldValue):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:"null"})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace",background:r.changeType==="added"?"var(--nice-success-tint-12, #22c55e20)":r.changeType==="modified"?"var(--nice-warning-tint-15, #f59e0b20)":"transparent"},children:r.newValue!==void 0?String(r.newValue):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:"null"})})]},r.field))})]}),e.jsxs("div",{style:{marginTop:24,padding:16,background:t.cardBg,borderRadius:8},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:8},children:"Change Metadata"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr",gap:"8px 16px",fontSize:12},children:[e.jsx("span",{style:{color:t.textMuted},children:"Changed by"}),e.jsx("span",{children:x.changedBy??"Unknown"}),e.jsx("span",{style:{color:t.textMuted},children:"Changed at"}),e.jsx("span",{children:x.changedAt?.toLocaleString()??"Unknown"})]})]})]})]})]})]})]})},be=Object.freeze(Object.defineProperty({__proto__:null,NiceDataDiffViewer:de},Symbol.toStringTag,{value:"Module"})),me=[{id:"commit-1",shortId:"c1a2b3c",message:"Initial production snapshot",branch:"production",environment:"production",author:{id:"system",name:"System"},timestamp:new Date("2025-01-01T10:00:00"),parents:[],isMerge:!1,isSnapshot:!0,stats:{tables:25,recordsAdded:265770,recordsModified:0,recordsDeleted:0},tags:["v1.0.0"]},{id:"commit-2",shortId:"d4e5f6g",message:"Clone to UAT for Q1 testing",branch:"uat",environment:"uat",author:{id:"admin",name:"Admin"},timestamp:new Date("2025-01-15T09:00:00"),parents:["commit-1"],isMerge:!1,isSnapshot:!0,stats:{tables:25,recordsAdded:265e3,recordsModified:0,recordsDeleted:0}},{id:"commit-3",shortId:"h7i8j9k",message:"Customer data migration",branch:"uat",environment:"uat",author:{id:"user1",name:"Data Engineer"},timestamp:new Date("2025-02-01T14:30:00"),parents:["commit-2"],isMerge:!1,isSnapshot:!1,stats:{tables:1,recordsAdded:500,recordsModified:1200,recordsDeleted:50}},{id:"commit-4",shortId:"l0m1n2o",message:"Clone to development",branch:"development",environment:"development",author:{id:"dev1",name:"Developer"},timestamp:new Date("2025-03-01T08:00:00"),parents:["commit-3"],isMerge:!1,isSnapshot:!0,stats:{tables:15,recordsAdded:67120,recordsModified:0,recordsDeleted:0}},{id:"commit-5",shortId:"p3q4r5s",message:"New product catalog import",branch:"development",environment:"development",author:{id:"dev1",name:"Developer"},timestamp:new Date("2025-03-10T16:45:00"),parents:["commit-4"],isMerge:!1,isSnapshot:!1,stats:{tables:2,recordsAdded:350,recordsModified:0,recordsDeleted:0}},{id:"commit-6",shortId:"t6u7v8w",message:"Tax rate configuration update",branch:"development",environment:"development",author:{id:"dev2",name:"Config Admin"},timestamp:new Date("2025-03-15T11:20:00"),parents:["commit-5"],isMerge:!1,isSnapshot:!1,stats:{tables:1,recordsAdded:0,recordsModified:3,recordsDeleted:0}},{id:"commit-7",shortId:"x9y0z1a",message:"Merge development changes to UAT",branch:"uat",environment:"uat",author:{id:"admin",name:"Admin"},timestamp:new Date("2025-03-20T09:00:00"),parents:["commit-3","commit-6"],isMerge:!0,isSnapshot:!1,stats:{tables:3,recordsAdded:350,recordsModified:3,recordsDeleted:0},tags:["uat-release-1"]},{id:"commit-8",shortId:"b2c3d4e",message:"Production weekly backup",branch:"production",environment:"production",author:{id:"system",name:"System"},timestamp:new Date("2025-03-25T02:00:00"),parents:["commit-1"],isMerge:!1,isSnapshot:!0,stats:{tables:25,recordsAdded:0,recordsModified:5420,recordsDeleted:120},tags:["backup-2025-03-25"]}],se=({branches:c=[],commits:y=me,selectedCommitId:w,viewMode:j,showLanes:k=!0,onSelectCommit:D,onSelectBranch:F,onCompare:L,onRestore:q,className:H,style:N,"data-testid":f})=>{const[b,K]=l.useState("graph"),[C,R]=l.useState(null),[x,O]=l.useState(null),[m,V]=l.useState(null),v=j??b,I=w??C,T=l.useRef(null),a=l.useMemo(()=>[...y].sort((o,t)=>t.timestamp.getTime()-o.timestamp.getTime()),[y]),h=l.useMemo(()=>{const o={};return Q.forEach((t,r)=>{o[t]=r}),y.reduce((t,r)=>(t[r.id]=o[r.environment]??0,t),{})},[y]),p=l.useMemo(()=>y.find(o=>o.id===I),[y,I]),M=l.useCallback(o=>{x?(L?.(x,o),O(null)):(R(o),D?.(o))},[x,L,D]),P=o=>{const r=new Date().getTime()-o.getTime(),d=Math.floor(r/(1e3*60*60*24));return d===0?"Today":d===1?"Yesterday":d<7?`${d} days ago`:d<30?`${Math.floor(d/7)} weeks ago`:`${Math.floor(d/30)} months ago`},s={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"},z=140,W=12,S=80;return e.jsxs("div",{className:`nice-data-branch-graph ${H||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...N},"data-testid":f,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsx("h3",{style:{margin:0,fontSize:16},children:"📈 Data History"}),e.jsx("div",{style:{display:"flex",gap:4},children:["graph","timeline","list"].map(o=>e.jsxs("button",{onClick:()=>K(o),style:{padding:"4px 12px",borderRadius:4,border:"none",background:v===o?"var(--color-primary, #3b82f6)":s.cardBg,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:[o==="graph"?"🌳":o==="timeline"?"📅":"📋"," ",o]},o))}),e.jsx("div",{style:{flex:1}}),x?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{fontSize:12,color:s.textMuted},children:["Select target to compare with ",y.find(o=>o.id===x)?.shortId]}),e.jsx("button",{onClick:()=>O(null),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:11},children:"Cancel"})]}):e.jsxs("span",{style:{fontSize:12,color:s.textMuted},children:[a.length," snapshots"]})]}),k&&v==="graph"&&e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${s.border}`,background:s.cardBg},children:[Q.map(o=>e.jsxs("div",{style:{width:z,padding:"8px 12px",textAlign:"center",borderRight:`1px solid ${s.border}`},children:[e.jsx("span",{style:{fontSize:16},children:_[o]}),e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:B[o]},children:o})]},o)),e.jsx("div",{style:{flex:1,padding:"8px 12px"},children:e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Details"})})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[v==="graph"&&e.jsx("div",{ref:T,style:{flex:1,overflow:"auto"},children:e.jsxs("div",{style:{position:"relative",minHeight:a.length*S},children:[e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:z*Q.length,height:a.length*S,pointerEvents:"none"},children:a.map((o,t)=>{const r=t*S+S/2,d=h[o.id]*z+z/2;return o.parents.map(g=>{const A=a.findIndex(n=>n.id===g);if(A===-1)return null;const U=A*S+S/2,E=h[g]*z+z/2,Y=o.isMerge&&o.parents.indexOf(g)>0,i=d===E?`M ${d} ${r} L ${E} ${U}`:`M ${d} ${r} C ${d} ${(r+U)/2}, ${E} ${(r+U)/2}, ${E} ${U}`;return e.jsx("path",{d:i,fill:"none",stroke:Y?"var(--color-accent, #8b5cf6)":B[o.environment],strokeWidth:2,strokeDasharray:Y?"4,4":void 0,opacity:.6},`${o.id}-${g}`)})})}),a.map((o,t)=>{const r=t*S+S/2,d=h[o.id]*z+z/2,g=o.id===I,A=o.id===m,U=o.id===x;return e.jsxs(l.Fragment,{children:[e.jsx("div",{onClick:()=>M(o.id),onMouseEnter:()=>V(o.id),onMouseLeave:()=>V(null),style:{position:"absolute",left:d-W,top:r-W,width:W*2,height:W*2,borderRadius:o.isMerge?4:"50%",background:g||U?"var(--bg-primary, #fff)":B[o.environment],border:`3px solid ${B[o.environment]}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,color:g||U?"var(--text-primary, #000)":"var(--bg-primary, #fff)",zIndex:A?10:1,transform:A?"scale(1.2)":"scale(1)",transition:"transform 0.1s",boxShadow:g?"0 0 0 3px rgba(59, 130, 246, 0.5)":"none"},children:o.isSnapshot?"📷":o.isMerge?"🔀":""}),e.jsxs("div",{style:{position:"absolute",left:z*Q.length+16,top:r-20,right:16,height:40,display:"flex",alignItems:"center",gap:12,padding:"4px 12px",background:g?s.cardBg:"transparent",borderRadius:6,borderLeft:g?`3px solid ${B[o.environment]}`:"none"},children:[e.jsx("span",{style:{fontFamily:"monospace",fontSize:11,color:B[o.environment]},children:o.shortId}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.message}),o.tags?.map(E=>e.jsxs("span",{style:{padding:"2px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--color-warning, #f59e0b)",borderRadius:4,fontSize:9},children:["🏷️ ",E]},E)),e.jsx("span",{style:{fontSize:10,color:s.textMuted,whiteSpace:"nowrap"},children:P(o.timestamp)})]})]},o.id)})]})}),v==="timeline"&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:a.map((o,t)=>{const r=o.id===I,d=a[t-1],g=!d||o.timestamp.toDateString()!==d.timestamp.toDateString();return e.jsxs(l.Fragment,{children:[g&&e.jsx("div",{style:{padding:"8px 0",fontSize:11,fontWeight:600,color:s.textMuted,borderBottom:`1px solid ${s.border}`,marginBottom:8},children:o.timestamp.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}),e.jsxs("div",{onClick:()=>M(o.id),style:{display:"flex",gap:12,padding:12,marginBottom:8,background:r?s.cardBg:"transparent",borderRadius:8,cursor:"pointer",border:`1px solid ${r?B[o.environment]:"transparent"}`},children:[e.jsx("div",{style:{width:60,textAlign:"right",fontSize:11,color:s.textMuted},children:o.timestamp.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}),e.jsxs("div",{style:{width:80,padding:"4px 8px",background:B[o.environment]+"30",color:B[o.environment],borderRadius:4,fontSize:10,textAlign:"center",fontWeight:600,textTransform:"uppercase"},children:[_[o.environment]," ",o.environment.substring(0,4)]}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontFamily:"monospace",fontSize:11,color:s.textMuted},children:o.shortId}),o.isSnapshot&&e.jsx("span",{style:{fontSize:12},children:"📷"}),o.isMerge&&e.jsx("span",{style:{fontSize:12},children:"🔀"}),o.tags?.map(A=>e.jsx("span",{style:{padding:"1px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--color-warning, #f59e0b)",borderRadius:3,fontSize:9},children:A},A))]}),e.jsx("div",{style:{fontSize:13,marginTop:4},children:o.message}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:4},children:["by ",o.author.name," •"," ",e.jsxs("span",{style:{color:"var(--color-success, #22c55e)"},children:["+",o.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["~",o.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--color-error, #ef4444)"},children:["-",o.stats.recordsDeleted]})]})]})]})]},o.id)})}),v==="list"&&e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:s.cardBg},children:[e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${s.border}`},children:"ID"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${s.border}`},children:"Environment"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${s.border}`},children:"Message"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${s.border}`},children:"Author"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${s.border}`},children:"Date"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"right",borderBottom:`1px solid ${s.border}`},children:"Changes"})]})}),e.jsx("tbody",{children:a.map(o=>e.jsxs("tr",{onClick:()=>M(o.id),style:{cursor:"pointer",background:o.id===I?s.cardBg:"transparent"},children:[e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${s.border}`,fontFamily:"monospace"},children:[o.shortId,o.isSnapshot&&" 📷",o.isMerge&&" 🔀"]}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${s.border}`},children:e.jsx("span",{style:{padding:"2px 8px",background:B[o.environment]+"30",color:B[o.environment],borderRadius:4,fontSize:10,fontWeight:600},children:o.environment})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${s.border}`},children:o.message}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${s.border}`,color:s.textMuted},children:o.author.name}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${s.border}`,color:s.textMuted},children:o.timestamp.toLocaleString()}),e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${s.border}`,textAlign:"right"},children:[e.jsxs("span",{style:{color:"var(--color-success, #22c55e)"},children:["+",o.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["~",o.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--color-error, #ef4444)"},children:["-",o.stats.recordsDeleted]})]})]},o.id))})]})}),p&&e.jsxs("div",{style:{width:320,borderLeft:`1px solid ${s.border}`,overflow:"auto",padding:16},children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{fontSize:24},children:p.isSnapshot?"📷":p.isMerge?"🔀":"📝"}),e.jsx("span",{style:{padding:"4px 10px",background:B[p.environment]+"30",color:B[p.environment],borderRadius:6,fontSize:11,fontWeight:600,textTransform:"uppercase"},children:p.environment})]}),e.jsx("h4",{style:{margin:"0 0 8px 0",fontSize:14},children:p.message}),p.description&&e.jsx("p",{style:{margin:0,fontSize:12,color:s.textMuted},children:p.description})]}),p.tags&&p.tags.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:4},children:"Tags"}),e.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:p.tags.map(o=>e.jsxs("span",{style:{padding:"2px 8px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--color-warning, #f59e0b)",borderRadius:4,fontSize:11},children:["🏷️ ",o]},o))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:8},children:"Changes"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[e.jsxs("div",{style:{padding:10,background:s.cardBg,borderRadius:6,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:600},children:p.stats.tables}),e.jsx("div",{style:{fontSize:10,color:s.textMuted},children:"Tables"})]}),e.jsxs("div",{style:{padding:10,background:"var(--nice-success-tint-12, #22c55e20)",borderRadius:6,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"var(--color-success, #22c55e)"},children:["+",p.stats.recordsAdded]}),e.jsx("div",{style:{fontSize:10,color:s.textMuted},children:"Added"})]}),e.jsxs("div",{style:{padding:10,background:"var(--nice-warning-tint-15, #f59e0b20)",borderRadius:6,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"var(--color-warning, #f59e0b)"},children:["~",p.stats.recordsModified]}),e.jsx("div",{style:{fontSize:10,color:s.textMuted},children:"Modified"})]}),e.jsxs("div",{style:{padding:10,background:"var(--nice-danger-tint-15, #ef444420)",borderRadius:6,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"var(--color-error, #ef4444)"},children:["-",p.stats.recordsDeleted]}),e.jsx("div",{style:{fontSize:10,color:s.textMuted},children:"Deleted"})]})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:s.textMuted,marginBottom:8},children:"Details"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"80px 1fr",gap:"6px 12px",fontSize:12},children:[e.jsx("span",{style:{color:s.textMuted},children:"ID"}),e.jsx("span",{style:{fontFamily:"monospace"},children:p.shortId}),e.jsx("span",{style:{color:s.textMuted},children:"Author"}),e.jsx("span",{children:p.author.name}),e.jsx("span",{style:{color:s.textMuted},children:"Date"}),e.jsx("span",{children:p.timestamp.toLocaleString()}),e.jsx("span",{style:{color:s.textMuted},children:"Type"}),e.jsx("span",{children:p.isSnapshot?"Snapshot":p.isMerge?"Merge":"Change"}),p.parents.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:s.textMuted},children:"Parents"}),e.jsx("span",{style:{fontFamily:"monospace"},children:p.parents.map(o=>y.find(t=>t.id===o)?.shortId??o).join(", ")})]})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsx("button",{onClick:()=>O(p.id),style:{padding:"8px 12px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"🔍 Compare with..."}),p.isSnapshot&&e.jsx("button",{onClick:()=>q?.(p.id),style:{padding:"8px 12px",borderRadius:6,border:"none",background:"var(--color-warning, #f59e0b)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500},children:"⏪ Restore this snapshot"})]})]})]})]})},ve=Object.freeze(Object.defineProperty({__proto__:null,NiceDataBranchGraph:se},Symbol.toStringTag,{value:"Module"})),je=[{target:".nice-data-merge-builder",titleKey:"tutorial.dataMergeBuilder.intro.title",title:"Data merge",contentKey:"tutorial.dataMergeBuilder.intro.content",content:"Walk through the steps: choose source and target branches, preview changes, resolve conflicts, set options, then confirm the merge.",placement:"auto"}],Se=[{id:"prod-1",shortId:"prod-1",name:"production",displayName:"Production",isDefault:!0,isProtected:!0,createdBy:{id:"system",name:"System"},createdAt:{date:new Date,relative:"1 year ago"},status:"active",type:"data",environment:"production",tenant:"tenant-1",size:{records:265770,bytes:2921e5}},{id:"uat-1",shortId:"uat-1",name:"uat",displayName:"UAT",isDefault:!1,isProtected:!0,createdBy:{id:"admin",name:"Admin"},createdAt:{date:new Date,relative:"3 months ago"},upstream:"prod-1",status:"active",type:"data",environment:"uat",tenant:"tenant-1",size:{records:265e3,bytes:29e7}},{id:"dev-1",shortId:"dev-1",name:"development",displayName:"Development",isDefault:!1,isProtected:!1,createdBy:{id:"dev1",name:"Developer"},createdAt:{date:new Date,relative:"1 month ago"},upstream:"uat-1",status:"active",type:"data",environment:"development",tenant:"tenant-1",size:{records:67120,bytes:1591e5}}],te={sourceId:"dev-1",targetId:"uat-1",tables:[{table:"customers",displayName:"Customers",module:"CRM",inserts:15,updates:42,deletes:3,conflicts:2,selected:!0},{table:"products",displayName:"Products",module:"Inventory",inserts:350,updates:25,deletes:0,conflicts:0,selected:!0},{table:"config",displayName:"Configuration",module:"System",inserts:0,updates:3,deletes:0,conflicts:1,selected:!0},{table:"orders",displayName:"Orders",module:"Sales",inserts:0,updates:0,deletes:0,conflicts:0,selected:!1}],conflicts:[{id:"conflict-1",table:"customers",recordId:"CUST-042",field:"email",sourceValue:"new@email.com",targetValue:"different@email.com",type:"concurrent-update"},{id:"conflict-2",table:"customers",recordId:"CUST-099",field:"status",sourceValue:"deleted",targetValue:"active",type:"delete-update"},{id:"conflict-3",table:"config",recordId:"CFG-TAX-RATE",field:"value",sourceValue:.21,targetValue:.22,type:"concurrent-update"}],estimatedDuration:45,requiresApproval:!0},le=({branches:c=Se,sourceBranchId:y,targetBranchId:w,onPreview:j,onMerge:k,onCancel:D,tutorial:F,className:L,style:q,"data-testid":H})=>{const[N,f]=l.useState("select"),[b,K]=l.useState(y??""),[C,R]=l.useState(w??""),[x,O]=l.useState(null),[m,V]=l.useState([]),[v,I]=l.useState("keep-source"),[T,a]=l.useState(!0),[h,p]=l.useState(!1),[M,P]=l.useState(null),[s,z]=l.useState({}),[W,S]=l.useState(!1),o=l.useMemo(()=>c.find(n=>n.id===b),[c,b]),t=l.useMemo(()=>c.find(n=>n.id===C),[c,C]),r=l.useMemo(()=>o?c.filter(n=>n.id!==b&&(oe(o.environment,n.environment)||n.environment==="development"||n.environment==="testing")):c,[c,b,o]),d=l.useMemo(()=>x?x.tables.filter(u=>m.includes(u.table)).reduce((u,$)=>({inserts:u.inserts+$.inserts,updates:u.updates+$.updates,deletes:u.deletes+$.deletes,conflicts:u.conflicts+$.conflicts}),{inserts:0,updates:0,deletes:0,conflicts:0}):{inserts:0,updates:0,deletes:0,conflicts:0},[x,m]),g=l.useMemo(()=>x?x.conflicts.filter(n=>!s[n.id]):[],[x,s]),A=l.useCallback(async()=>{S(!0),j?.(b,C),await new Promise(n=>setTimeout(n,1e3)),O(te),V(te.tables.filter(n=>n.selected).map(n=>n.table)),S(!1),f("preview")},[b,C,j]),U=l.useCallback(()=>{const n={sourceId:b,targetId:C,strategy:v,tables:m,createBackup:T,dryRun:h,scheduledAt:M??void 0,conflictResolutions:Object.entries(s).reduce((u,[$,G])=>({...u,[$]:{conflictId:$,strategy:G}}),{})};k?.(n)},[b,C,v,m,T,h,M,s,k]),E=(n,u)=>{z($=>({...$,[n]:u}))},Y=n=>{if(!x)return;const u={};x.conflicts.forEach($=>{u[$.id]=n}),z(u)},i={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"};return e.jsxs("div",{className:`nice-data-merge-builder ${L||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:i.bg,color:i.text,fontFamily:"system-ui, sans-serif",...q},"data-testid":H,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${i.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsx("h3",{style:{margin:0,fontSize:18},children:"🔀 Data Merge"}),e.jsx("div",{style:{display:"flex",gap:8,marginLeft:"auto"},children:["select","preview","conflicts","options","confirm"].map((n,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:N===n?"var(--color-primary, #3b82f6)":["select","preview","conflicts","options","confirm"].indexOf(N)>u?"var(--color-success, #22c55e)":i.cardBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:600},children:["select","preview","conflicts","options","confirm"].indexOf(N)>u?"✓":u+1}),u<4&&e.jsx("div",{style:{width:24,height:2,background:["select","preview","conflicts","options","confirm"].indexOf(N)>u?"var(--color-success, #22c55e)":i.border}})]},n))}),e.jsx(Z.bl,{steps:Z.hl(F,je)})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[N==="select"&&e.jsxs("div",{style:{maxWidth:600,margin:"0 auto"},children:[e.jsx("h4",{style:{marginTop:0},children:"Select Environments"}),e.jsx("p",{style:{color:i.textMuted,fontSize:13},children:"Choose the source and target environments for the merge operation."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:16,alignItems:"center",marginTop:24},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:i.textMuted},children:"Source Environment"}),e.jsxs("select",{value:b,onChange:n=>{K(n.target.value),R("")},style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${i.border}`,background:i.cardBg,color:i.text,fontSize:14},children:[e.jsx("option",{value:"",children:"Select source..."}),c.map(n=>e.jsxs("option",{value:n.id,children:[_[n.environment]," ",n.displayName]},n.id))]}),o&&e.jsxs("div",{style:{marginTop:12,padding:12,background:B[o.environment]+"20",borderRadius:8,border:`1px solid ${B[o.environment]}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:20},children:_[o.environment]}),e.jsx("span",{style:{fontWeight:600},children:o.displayName})]}),e.jsxs("div",{style:{fontSize:11,color:i.textMuted,marginTop:4},children:[o.size?.records.toLocaleString()," records"]})]})]}),e.jsx("div",{style:{fontSize:24,color:i.textMuted},children:"→"}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:i.textMuted},children:"Target Environment"}),e.jsxs("select",{value:C,onChange:n=>R(n.target.value),disabled:!b,style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${i.border}`,background:i.cardBg,color:i.text,fontSize:14,opacity:b?1:.5},children:[e.jsx("option",{value:"",children:"Select target..."}),r.map(n=>e.jsxs("option",{value:n.id,children:[_[n.environment]," ",n.displayName]},n.id))]}),t&&e.jsxs("div",{style:{marginTop:12,padding:12,background:B[t.environment]+"20",borderRadius:8,border:`1px solid ${B[t.environment]}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:20},children:_[t.environment]}),e.jsx("span",{style:{fontWeight:600},children:t.displayName}),t.isProtected&&e.jsx("span",{children:"🔒"})]}),e.jsxs("div",{style:{fontSize:11,color:i.textMuted,marginTop:4},children:[t.size?.records.toLocaleString()," records"]})]})]})]}),e.jsxs("div",{style:{marginTop:32,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:D,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:A,disabled:!b||!C||W,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:b&&C&&!W?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:b&&C&&!W?1:.5},children:W?"⏳ Loading...":"Preview Changes →"})]})]}),N==="preview"&&x&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>f("select"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Preview Changes"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:24},children:[e.jsxs("div",{style:{padding:16,background:"var(--nice-success-tint-12, #22c55e20)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-success, #22c55e)"},children:["+",d.inserts]}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Inserts"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-warning-tint-15, #f59e0b20)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-warning, #f59e0b)"},children:["~",d.updates]}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Updates"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-danger-tint-15, #ef444420)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-error, #ef4444)"},children:["-",d.deletes]}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Deletes"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-accent-tint-12, #8b5cf620)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-accent, #8b5cf6)"},children:["⚠️ ",d.conflicts]}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Conflicts"})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("span",{style:{fontSize:12,color:i.textMuted},children:["Select tables to merge (",m.length," / ",x.tables.length,")"]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>V(x.tables.map(n=>n.table)),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:11},children:"Select All"}),e.jsx("button",{onClick:()=>V([]),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:11},children:"Clear"})]})]}),e.jsx("div",{style:{border:`1px solid ${i.border}`,borderRadius:8,overflow:"hidden"},children:x.tables.map(n=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:`1px solid ${i.border}`,cursor:"pointer",background:m.includes(n.table)?i.cardBg:"transparent"},children:[e.jsx("input",{type:"checkbox",checked:m.includes(n.table),onChange:u=>{u.target.checked?V($=>[...$,n.table]):V($=>$.filter(G=>G!==n.table))}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:n.displayName}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:n.module})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:12},children:[n.inserts>0&&e.jsxs("span",{style:{color:"var(--color-success, #22c55e)"},children:["+",n.inserts]}),n.updates>0&&e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["~",n.updates]}),n.deletes>0&&e.jsxs("span",{style:{color:"var(--color-error, #ef4444)"},children:["-",n.deletes]}),n.conflicts>0&&e.jsxs("span",{style:{color:"var(--color-accent, #8b5cf6)"},children:["⚠️ ",n.conflicts]})]})]},n.table))})]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>f("select"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>f(d.conflicts>0?"conflicts":"options"),disabled:m.length===0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:m.length>0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:m.length>0?1:.5},children:d.conflicts>0?"Resolve Conflicts →":"Configure Merge →"})]})]}),N==="conflicts"&&x&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>f("preview"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsxs("h4",{style:{margin:0},children:["Resolve Conflicts (",g.length," remaining)"]})]}),e.jsxs("div",{style:{padding:16,background:i.cardBg,borderRadius:8,marginBottom:24,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:13},children:"Apply to all conflicts:"}),e.jsx("button",{onClick:()=>Y("keep-source"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"Keep Source"}),e.jsx("button",{onClick:()=>Y("keep-target"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"Keep Target"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:x.conflicts.map(n=>{const u=!!s[n.id];return e.jsxs("div",{style:{padding:16,background:i.cardBg,borderRadius:8,border:`1px solid ${u?"var(--color-success, #22c55e)":"var(--color-accent, #8b5cf6)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("span",{style:{fontSize:16},children:u?"✅":"⚠️"}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontWeight:500},children:[n.table,".",n.field]}),e.jsxs("div",{style:{fontSize:11,color:i.textMuted},children:["Record: ",n.recordId," • ",n.type.replace("-"," ")]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{style:{padding:12,background:s[n.id]==="keep-source"?"var(--nice-success-tint-12, #22c55e20)":i.bg,borderRadius:6,border:`1px solid ${s[n.id]==="keep-source"?"var(--color-success, #22c55e)":i.border}`,cursor:"pointer"},onClick:()=>E(n.id,"keep-source"),children:[e.jsxs("div",{style:{fontSize:10,color:i.textMuted,marginBottom:4},children:["Source (",o?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(n.sourceValue)})]}),e.jsxs("div",{style:{padding:12,background:s[n.id]==="keep-target"?"var(--nice-success-tint-12, #22c55e20)":i.bg,borderRadius:6,border:`1px solid ${s[n.id]==="keep-target"?"var(--color-success, #22c55e)":i.border}`,cursor:"pointer"},onClick:()=>E(n.id,"keep-target"),children:[e.jsxs("div",{style:{fontSize:10,color:i.textMuted,marginBottom:4},children:["Target (",t?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(n.targetValue)})]})]})]},n.id)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>f("preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>f("options"),disabled:g.length>0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:g.length===0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:g.length===0?1:.5},children:"Configure Merge →"})]})]}),N==="options"&&e.jsxs("div",{style:{maxWidth:500,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>f(d.conflicts>0?"conflicts":"preview"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Merge Options"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:T,onChange:n=>a(n.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Create backup before merge"}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Recommended for protected environments"})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:h,onChange:n=>p(n.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Dry run (preview only)"}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Simulate merge without applying changes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:i.textMuted},children:"Schedule merge (optional)"}),e.jsx("input",{type:"datetime-local",value:M?.toISOString().slice(0,16)??"",onChange:n=>P(n.target.value?new Date(n.target.value):null),style:{padding:10,borderRadius:6,border:`1px solid ${i.border}`,background:i.cardBg,color:i.text,fontSize:13}})]})]}),e.jsxs("div",{style:{marginTop:32,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>f(d.conflicts>0?"conflicts":"preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>f("confirm"),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Review & Confirm →"})]})]}),N==="confirm"&&x&&e.jsxs("div",{style:{maxWidth:500,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>f("options"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Confirm Merge"})]}),e.jsxs("div",{style:{padding:20,background:i.cardBg,borderRadius:8,marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[e.jsxs("div",{style:{padding:"8px 12px",background:B[o?.environment??"development"]+"30",borderRadius:6},children:[_[o?.environment??"development"]," ",o?.displayName]}),e.jsx("span",{children:"→"}),e.jsxs("div",{style:{padding:"8px 12px",background:B[t?.environment??"production"]+"30",borderRadius:6},children:[_[t?.environment??"production"]," ",t?.displayName]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 16px",fontSize:13},children:[e.jsx("span",{style:{color:i.textMuted},children:"Tables"}),e.jsx("span",{children:m.length}),e.jsx("span",{style:{color:i.textMuted},children:"Records affected"}),e.jsx("span",{children:d.inserts+d.updates+d.deletes}),e.jsx("span",{style:{color:i.textMuted},children:"Backup"}),e.jsx("span",{children:T?"Yes":"No"}),e.jsx("span",{style:{color:i.textMuted},children:"Mode"}),e.jsx("span",{children:h?"Dry run":"Apply changes"}),M&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:i.textMuted},children:"Scheduled"}),e.jsx("span",{children:M.toLocaleString()})]})]})]}),t?.isProtected&&e.jsx("div",{style:{padding:12,background:"var(--nice-warning-tint-15, #f59e0b20)",border:"1px solid var(--nice-warning, #f59e0b)",borderRadius:6,marginBottom:24,fontSize:12},children:"⚠️ Target environment is protected and may require approval."}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:D,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:U,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:h?"🔍 Run Dry Merge":M?"📅 Schedule Merge":"🔀 Execute Merge"})]})]})]})]})},ke=Object.freeze(Object.defineProperty({__proto__:null,NiceDataMergeBuilder:le},Symbol.toStringTag,{value:"Module"})),Ce=[{id:"conflict-1",table:"customers",tableName:"Customers",recordId:"CUST-042",recordLabel:"Acme Corp",type:"concurrent-update",severity:"high",fields:[{field:"email",fieldLabel:"Email Address",dataType:"string",sourceValue:"new.contact@acme.com",targetValue:"old.contact@acme.com",baseValue:"original@acme.com"},{field:"phone",fieldLabel:"Phone Number",dataType:"string",sourceValue:"+1-555-NEW-0000",targetValue:"+1-555-OLD-0000",baseValue:"+1-555-000-0000"},{field:"credit_limit",fieldLabel:"Credit Limit",dataType:"number",sourceValue:75e3,targetValue:5e4,baseValue:25e3}],metadata:{sourceModifiedAt:new Date("2024-01-15T10:30:00"),sourceModifiedBy:"john.dev",targetModifiedAt:new Date("2024-01-15T14:45:00"),targetModifiedBy:"mary.sales"},suggestion:"keep-target",suggestionReason:"Target was modified more recently"},{id:"conflict-2",table:"products",tableName:"Products",recordId:"PRD-1337",recordLabel:"Widget Pro Max",type:"delete-update",severity:"critical",fields:[{field:"_deleted",fieldLabel:"Record Status",dataType:"boolean",sourceValue:!0,targetValue:!1},{field:"name",fieldLabel:"Product Name",dataType:"string",sourceValue:"[DELETED]",targetValue:"Widget Pro Max v2"}],suggestion:"keep-target",suggestionReason:"Record was updated in target, deletion may be accidental"},{id:"conflict-3",table:"config",tableName:"Configuration",recordId:"CFG-TAX-RATE",recordLabel:"Tax Rate Settings",type:"concurrent-update",severity:"medium",fields:[{field:"value",fieldLabel:"Value",dataType:"number",sourceValue:.21,targetValue:.22,baseValue:.2},{field:"effective_date",fieldLabel:"Effective Date",dataType:"date",sourceValue:"2024-02-01",targetValue:"2024-03-01"}],suggestion:"keep-source",suggestionReason:"Source has the newer effective date"}],X={"concurrent-update":{label:"Concurrent Update",icon:"⚡",description:"Record was modified in both environments"},"delete-update":{label:"Delete vs Update",icon:"🗑️",description:"Record deleted in source but updated in target"},"update-delete":{label:"Update vs Delete",icon:"✏️",description:"Record updated in source but deleted in target"},"constraint-violation":{label:"Constraint Violation",icon:"🚫",description:"Change violates database constraints"},"unique-key-conflict":{label:"Unique Key Conflict",icon:"🔑",description:"Duplicate unique key detected"},"foreign-key-missing":{label:"Missing FK Reference",icon:"🔗",description:"Referenced record does not exist"},"type-mismatch":{label:"Type Mismatch",icon:"⚠️",description:"Data type incompatibility"},"schema-change":{label:"Schema Change",icon:"📋",description:"Schema differs between environments"}},J={low:"var(--color-success, #22c55e)",medium:"var(--color-warning, #f59e0b)",high:"var(--nice-warning, #f97316)",critical:"var(--color-error, #ef4444)"},ae=({conflicts:c=Ce,sourceEnvironment:y="development",targetEnvironment:w="uat",showSuggestions:j=!0,allowCustomValues:k=!0,onResolve:D,onSkip:F,onCancel:L,className:q,style:H,"data-testid":N})=>{const[f,b]=l.useState(0),[K,C]=l.useState({}),[R,x]=l.useState({}),[O,m]=l.useState(null),[V,v]=l.useState(""),[I,T]=l.useState("single"),a=c[f],h=l.useMemo(()=>Object.keys(K).length,[K]),p=l.useMemo(()=>{if(!a)return!1;const r=R[a.id]||{};return a.fields.every(d=>r[d.field]?.resolution)},[a,R]),M=l.useCallback(r=>{if(R[r.id])return;const d={};r.fields.forEach(g=>{d[g.field]={resolution:"source",value:g.sourceValue}}),x(g=>({...g,[r.id]:d}))},[R]);l.useEffect(()=>{a&&M(a)},[a,M]);const P=(r,d,g)=>{if(!a)return;const A=a.fields.find(E=>E.field===r);if(!A)return;const U=d==="source"?A.sourceValue:d==="target"?A.targetValue:g;x(E=>({...E,[a.id]:{...E[a.id],[r]:{resolution:d,value:U}}}))},s=r=>{if(!a)return;const d={};a.fields.forEach(g=>{d[g.field]={resolution:r,value:r==="source"?g.sourceValue:g.targetValue}}),x(g=>({...g,[a.id]:d}))},z=()=>{if(!a||!p)return;const r={conflictId:a.id,strategy:"manual",fieldResolutions:R[a.id]};C(d=>({...d,[a.id]:r})),f<c.length-1&&b(f+1)},W=()=>{a&&(F?.(a.id),f<c.length-1&&b(f+1))},S=()=>{const r=Object.values(K);D?.(r)},o=(r,d)=>r===null?"null":r===void 0?"undefined":d==="date"?new Date(r).toLocaleDateString():d==="number"?Number(r).toLocaleString():typeof r=="boolean"?r?"true":"false":String(r),t={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)",source:B[y],target:B[w]};return c.length===0?e.jsxs("div",{className:`nice-data-conflict-resolver ${q||""}`,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",padding:40,...H},"data-testid":N,children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:"✅"}),e.jsx("h3",{style:{margin:0},children:"No Conflicts"}),e.jsx("p",{style:{color:t.textMuted,marginTop:8},children:"All data is compatible for merge."})]}):e.jsxs("div",{className:`nice-data-conflict-resolver ${q||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...H},"data-testid":N,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsx("h3",{style:{margin:0,fontSize:18},children:"⚠️ Resolve Conflicts"}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:12},children:[e.jsxs("div",{style:{fontSize:13,color:t.textMuted},children:["Resolved: ",e.jsx("strong",{style:{color:t.text},children:h})," /"," ",c.length]}),e.jsx("div",{style:{width:100,height:6,background:t.cardBg,borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${h/c.length*100}%`,height:"100%",background:"var(--color-success, #22c55e)",transition:"width 0.2s"}})})]}),e.jsxs("div",{style:{display:"flex",border:`1px solid ${t.border}`,borderRadius:6,overflow:"hidden"},children:[e.jsx("button",{onClick:()=>T("single"),style:{padding:"6px 12px",border:"none",background:I==="single"?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"Single"}),e.jsx("button",{onClick:()=>T("list"),style:{padding:"6px 12px",border:"none",borderLeft:`1px solid ${t.border}`,background:I==="list"?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"List"})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[I==="single"&&a&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsx("button",{onClick:()=>b(Math.max(0,f-1)),disabled:f===0,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:f>0?"pointer":"not-allowed",opacity:f>0?1:.5,fontSize:12},children:"← Previous"}),e.jsxs("span",{style:{fontSize:13,color:t.textMuted},children:["Conflict ",f+1," of ",c.length]}),e.jsx("button",{onClick:()=>b(Math.min(c.length-1,f+1)),disabled:f===c.length-1,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:f<c.length-1?"pointer":"not-allowed",opacity:f<c.length-1?1:.5,fontSize:12},children:"Next →"}),K[a.id]&&e.jsx("span",{style:{marginLeft:"auto",padding:"4px 8px",background:"#22c55e30",color:"var(--color-success, #22c55e)",borderRadius:4,fontSize:11},children:"✓ Resolved"})]}),e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:24},children:X[a.type].icon}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:600,fontSize:15},children:[a.tableName,":"," ",a.recordLabel??a.recordId]}),e.jsxs("div",{style:{fontSize:12,color:t.textMuted},children:[X[a.type].label," —"," ",X[a.type].description]})]}),e.jsx("div",{style:{padding:"4px 8px",background:J[a.severity]+"30",color:J[a.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:a.severity})]}),a.metadata&&e.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`,fontSize:11,color:t.textMuted},children:[a.metadata.sourceModifiedAt&&e.jsxs("span",{children:["Source modified: ",a.metadata.sourceModifiedAt.toLocaleString()," ","by ",a.metadata.sourceModifiedBy]}),a.metadata.targetModifiedAt&&e.jsxs("span",{children:["Target modified: ",a.metadata.targetModifiedAt.toLocaleString()," ","by ",a.metadata.targetModifiedBy]})]}),j&&a.suggestion&&e.jsxs("div",{style:{marginTop:12,padding:12,background:"var(--nice-primary-tint-12, #3b82f620)",border:"1px solid var(--nice-primary, #3b82f6)",borderRadius:6,fontSize:12},children:[e.jsx("strong",{children:"💡 Suggestion:"})," ",a.suggestionReason,e.jsx("button",{onClick:()=>s(a.suggestion==="keep-source"?"source":"target"),style:{marginLeft:12,padding:"4px 8px",borderRadius:4,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11},children:"Apply"})]})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted,lineHeight:"28px"},children:"Apply to all fields:"}),e.jsxs("button",{onClick:()=>s("source"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.source}`,background:`${t.source}20`,color:t.text,cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[_[y]," Keep Source"]}),e.jsxs("button",{onClick:()=>s("target"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.target}`,background:`${t.target}20`,color:t.text,cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[_[w]," Keep Target"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:a.fields.map(r=>{const d=R[a.id]?.[r.field],g=O===`${a.id}-${r.field}`;return e.jsxs("div",{style:{background:t.cardBg,borderRadius:8,overflow:"hidden",border:`1px solid ${d?.resolution?"var(--color-success, #22c55e)":t.border}`},children:[e.jsxs("div",{style:{padding:"10px 16px",background:d?.resolution?"var(--nice-success-tint-10, #22c55e10)":"transparent",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,color:d?.resolution?"var(--color-success, #22c55e)":t.textMuted},children:d?.resolution?"✓":"○"}),e.jsx("span",{style:{fontWeight:500},children:r.fieldLabel}),e.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:["(",r.field,")"]}),e.jsx("span",{style:{marginLeft:"auto",fontSize:10,padding:"2px 6px",background:t.bg,borderRadius:4,color:t.textMuted},children:r.dataType})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1,background:t.border},children:[e.jsxs("div",{onClick:()=>P(r.field,"source"),style:{padding:16,background:d?.resolution==="source"?`${t.source}20`:t.bg,cursor:"pointer",border:d?.resolution==="source"?`2px solid ${t.source}`:"2px solid transparent"},children:[e.jsxs("div",{style:{fontSize:10,color:t.source,marginBottom:8,display:"flex",alignItems:"center",gap:4},children:[_[y]," Source",d?.resolution==="source"&&e.jsx("span",{style:{marginLeft:4},children:"✓"})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:o(r.sourceValue,r.dataType)})]}),e.jsxs("div",{onClick:()=>P(r.field,"target"),style:{padding:16,background:d?.resolution==="target"?`${t.target}20`:t.bg,cursor:"pointer",border:d?.resolution==="target"?`2px solid ${t.target}`:"2px solid transparent"},children:[e.jsxs("div",{style:{fontSize:10,color:t.target,marginBottom:8,display:"flex",alignItems:"center",gap:4},children:[_[w]," Target",d?.resolution==="target"&&e.jsx("span",{style:{marginLeft:4},children:"✓"})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:o(r.targetValue,r.dataType)})]})]}),k&&e.jsxs("div",{style:{padding:12,background:d?.resolution==="custom"?"var(--nice-accent-tint-12, #8b5cf620)":t.bg,borderTop:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted},children:"Custom value:"}),g?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:V,onChange:A=>v(A.target.value),style:{flex:1,padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontFamily:"monospace",fontSize:13},autoFocus:!0}),e.jsx("button",{onClick:()=>{P(r.field,"custom",V),m(null)},style:{padding:"6px 12px",borderRadius:4,border:"none",background:"var(--color-accent, #8b5cf6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"Apply"}),e.jsx("button",{onClick:()=>m(null),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"Cancel"})]}):e.jsx("button",{onClick:()=>{v(d?.resolution==="custom"?String(d.value):String(r.sourceValue)),m(`${a.id}-${r.field}`)},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:d?.resolution==="custom"?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:12},children:d?.resolution==="custom"?`Using: ${o(d.value,r.dataType)}`:"Enter custom..."})]})]},r.field)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:W,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:13},children:"Skip"}),e.jsx("button",{onClick:z,disabled:!p,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:p?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:p?1:.5},children:f<c.length-1?"Confirm & Next →":"Confirm"})]})]}),I==="list"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:c.map((r,d)=>{const g=!!K[r.id];return e.jsxs("div",{onClick:()=>{b(d),T("single")},style:{padding:16,background:t.cardBg,borderRadius:8,cursor:"pointer",border:`1px solid ${g?"var(--color-success, #22c55e)":t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:20},children:g?"✅":X[r.type].icon}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[r.tableName,": ",r.recordLabel??r.recordId]}),e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[r.fields.length," fields • ",X[r.type].label]})]}),e.jsx("div",{style:{padding:"4px 8px",background:J[r.severity]+"30",color:J[r.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:r.severity})]},r.id)})})]}),e.jsxs("div",{style:{padding:"16px 20px",borderTop:`1px solid ${t.border}`,display:"flex",justifyContent:"space-between"},children:[e.jsx("button",{onClick:L,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsxs("button",{onClick:S,disabled:h===0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:h>0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:h>0?1:.5},children:["Finish (",h," resolved)"]})]})]})},ze=Object.freeze(Object.defineProperty({__proto__:null,NiceDataConflictResolver:ae},Symbol.toStringTag,{value:"Module"})),Be=[{id:"snap-001",name:"Q1 Release Backup",description:"Backup before Q1 2024 release deployment",environment:"production",createdAt:new Date("2024-01-15T06:00:00"),createdBy:{id:"admin",name:"Admin"},size:{records:265770,bytes:2921e5},type:"manual",status:"ready",tags:["release","q1-2024"]},{id:"snap-002",name:"Daily Backup 2024-01-20",environment:"production",createdAt:new Date("2024-01-20T02:00:00"),createdBy:{id:"system",name:"System"},size:{records:267e3,bytes:2942e5},type:"scheduled",status:"ready",expiresAt:new Date("2024-02-20T02:00:00")},{id:"snap-003",name:"Pre-Merge: UAT to Prod",description:"Automatic backup before merge operation",environment:"production",createdAt:new Date("2024-01-22T10:30:00"),createdBy:{id:"system",name:"System"},size:{records:267500,bytes:295e6},type:"pre-merge",status:"locked",tags:["merge","automatic"]},{id:"snap-004",name:"Selected Tables Only",description:"Partial snapshot of CRM module",environment:"production",createdAt:new Date("2024-01-23T14:00:00"),createdBy:{id:"dev1",name:"John"},size:{records:15e3,bytes:185e5},type:"manual",status:"ready",tables:["customers","contacts","opportunities"],tags:["crm","partial"]},{id:"snap-005",name:"Failed Backup",environment:"production",createdAt:new Date("2024-01-24T02:00:00"),createdBy:{id:"system",name:"System"},size:{records:0,bytes:0},type:"scheduled",status:"failed"}],we=[{id:"sched-daily",name:"Daily Backup",cron:"0 2 * * *",enabled:!0,nextRun:new Date(Date.now()+480*60*1e3),lastRun:new Date(Date.now()-960*60*1e3),retainCount:7},{id:"sched-weekly",name:"Weekly Full Backup",cron:"0 4 * * 0",enabled:!0,nextRun:new Date(Date.now()+4320*60*1e3),lastRun:new Date(Date.now()-5760*60*1e3),retainCount:4},{id:"sched-monthly",name:"Monthly Archive",cron:"0 6 1 * *",enabled:!1,lastRun:new Date(Date.now()-360*60*60*1e3),retainCount:12}],Me={enabled:!0,maxCount:30,maxAgeDays:90,keepTagged:!0,keepLocked:!0},re=c=>{if(c===0)return"0 B";const y=1024,w=["B","KB","MB","GB","TB"],j=Math.floor(Math.log(c)/Math.log(y));return parseFloat((c/Math.pow(y,j)).toFixed(1))+" "+w[j]},ne=c=>{const w=new Date().getTime()-c.getTime(),j=Math.floor(w/(1e3*60*60)),k=Math.floor(j/24);return k>0?`${k} day${k>1?"s":""} ago`:j>0?`${j} hour${j>1?"s":""} ago`:"Just now"},Re=c=>{const y=c.split(" ");if(y.length!==5)return c;const[w,j,k,D,F]=y;return k==="*"&&D==="*"&&F==="*"?`Daily at ${j.padStart(2,"0")}:${w.padStart(2,"0")}`:k==="*"&&D==="*"?`Weekly on ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][parseInt(F)]} at ${j.padStart(2,"0")}:${w.padStart(2,"0")}`:D==="*"?`Monthly on day ${k} at ${j.padStart(2,"0")}:${w.padStart(2,"0")}`:c},Te={creating:{icon:"⏳",color:"var(--color-warning, #f59e0b)",label:"Creating"},ready:{icon:"✅",color:"var(--color-success, #22c55e)",label:"Ready"},failed:{icon:"❌",color:"var(--color-error, #ef4444)",label:"Failed"},expired:{icon:"⏰",color:"var(--text-muted, #888)",label:"Expired"},locked:{icon:"🔒",color:"var(--color-primary, #3b82f6)",label:"Locked"}},$e={manual:{icon:"👤",label:"Manual"},scheduled:{icon:"📅",label:"Scheduled"},"pre-merge":{icon:"🔀",label:"Pre-Merge"},"pre-restore":{icon:"⏮️",label:"Pre-Restore"}},ce=({environment:c="production",snapshots:y=Be,retentionPolicy:w=Me,schedules:j=we,onCreateSnapshot:k,onRestoreSnapshot:D,onDeleteSnapshot:F,onCompareSnapshots:L,onExportSnapshot:q,onUpdateRetentionPolicy:H,onUpdateSchedules:N,className:f,style:b,"data-testid":K})=>{const[C,R]=l.useState("snapshots"),[x,O]=l.useState(!1),[m,V]=l.useState([]),[v,I]=l.useState(""),[T,a]=l.useState(""),[h,p]=l.useState(w),[M,P]=l.useState(j),s=l.useMemo(()=>{const t=y.filter(d=>d.status==="ready").length,r=y.reduce((d,g)=>d+g.size.bytes,0);return{total:y.length,ready:t,totalSize:r}},[y]),z=()=>{k?.({name:v||`Snapshot ${new Date().toISOString()}`,description:T}),O(!1),I(""),a("")},W=()=>{m.length===2&&L?.(m[0],m[1])},S=t=>{const r=M.map(d=>d.id===t?{...d,enabled:!d.enabled}:d);P(r),N?.(r)},o={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)",env:B[c]};return e.jsxs("div",{className:`nice-data-snapshot ${f||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:o.bg,color:o.text,fontFamily:"system-ui, sans-serif",...b},"data-testid":K,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${o.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsx("h3",{style:{margin:0,fontSize:18},children:"📸 Snapshots"}),e.jsxs("div",{style:{padding:"4px 10px",background:o.env+"30",borderRadius:4,fontSize:12,display:"flex",alignItems:"center",gap:6},children:[_[c]," ",c.charAt(0).toUpperCase()+c.slice(1)]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:16,fontSize:12,color:o.textMuted},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:o.text},children:s.total})," snapshots"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:o.text},children:re(s.totalSize)})," total"]})]}),e.jsx("button",{onClick:()=>O(!0),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,display:"flex",alignItems:"center",gap:6},children:"📸 Create Snapshot"})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${o.border}`,padding:"0 20px"},children:["snapshots","schedules","settings"].map(t=>e.jsxs("button",{onClick:()=>R(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:C===t?o.text:o.textMuted,cursor:"pointer",fontSize:13,fontWeight:C===t?600:400,borderBottom:C===t?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",marginBottom:-1},children:[t==="snapshots"&&"📁 Snapshots",t==="schedules"&&"📅 Schedules",t==="settings"&&"⚙️ Settings"]},t))}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[C==="snapshots"&&e.jsxs("div",{children:[m.length>0&&e.jsxs("div",{style:{padding:12,background:o.cardBg,borderRadius:8,marginBottom:16,display:"flex",alignItems:"center",gap:12},children:[e.jsxs("span",{style:{fontSize:13},children:[m.length," selected"]}),m.length===2&&e.jsx("button",{onClick:W,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:"Compare"}),e.jsx("button",{onClick:()=>V([]),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12,marginLeft:"auto"},children:"Clear"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:y.map(t=>{const r=m.includes(t.id),d=Te[t.status],g=$e[t.type];return e.jsx("div",{style:{padding:16,background:o.cardBg,borderRadius:8,border:`1px solid ${r?"var(--color-primary, #3b82f6)":o.border}`},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("input",{type:"checkbox",checked:r,onChange:A=>{A.target.checked?V(U=>[...U,t.id]):V(U=>U.filter(E=>E!==t.id))},style:{marginTop:4}}),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:600},children:t.name}),e.jsxs("span",{style:{padding:"2px 6px",background:d.color+"20",color:d.color,borderRadius:4,fontSize:10},children:[d.icon," ",d.label]}),e.jsxs("span",{style:{padding:"2px 6px",background:o.bg,color:o.textMuted,borderRadius:4,fontSize:10},children:[g.icon," ",g.label]})]}),t.description&&e.jsx("div",{style:{fontSize:12,color:o.textMuted,marginBottom:8},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:11,color:o.textMuted},children:[e.jsx("span",{children:ne(t.createdAt)}),e.jsxs("span",{children:["by ",t.createdBy.name]}),e.jsxs("span",{children:[t.size.records.toLocaleString()," records"]}),e.jsx("span",{children:re(t.size.bytes)}),t.tables&&e.jsxs("span",{children:[t.tables.length," tables"]}),t.expiresAt&&e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["Expires: ",t.expiresAt.toLocaleDateString()]})]}),t.tags&&t.tags.length>0&&e.jsx("div",{style:{display:"flex",gap:6,marginTop:8},children:t.tags.map(A=>e.jsxs("span",{style:{padding:"2px 8px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:["#",A]},A))})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[t.status==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>D?.(t.id),title:"Restore",style:{padding:8,borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:14},children:"⏮️"}),e.jsx("button",{onClick:()=>q?.(t.id,"sql"),title:"Export",style:{padding:8,borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:14},children:"📤"})]}),t.status!=="locked"&&e.jsx("button",{onClick:()=>F?.(t.id),title:"Delete",style:{padding:8,borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:14},children:"🗑️"})]})]})},t.id)})})]}),C==="schedules"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[M.map(t=>e.jsx("div",{style:{padding:16,background:o.cardBg,borderRadius:8,border:`1px solid ${o.border}`,opacity:t.enabled?1:.6},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("label",{className:"toggle",style:{display:"flex",alignItems:"center",cursor:"pointer"},children:e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:()=>S(t.id),style:{width:16,height:16}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:t.name}),e.jsxs("div",{style:{fontSize:12,color:o.textMuted},children:[Re(t.cron)," • Keep ",t.retainCount," snapshots"]})]}),e.jsxs("div",{style:{textAlign:"right",fontSize:11,color:o.textMuted},children:[t.enabled&&t.nextRun&&e.jsxs("div",{children:["Next: ",t.nextRun.toLocaleString()]}),t.lastRun&&e.jsxs("div",{children:["Last: ",ne(t.lastRun)]})]})]})},t.id)),e.jsx("button",{style:{padding:16,borderRadius:8,border:`1px dashed ${o.border}`,background:"transparent",color:o.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Schedule"})]}),C==="settings"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsx("h4",{style:{marginTop:0},children:"Retention Policy"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:h.enabled,onChange:t=>p({...h,enabled:t.target.checked})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Enable automatic cleanup"}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:"Automatically delete old snapshots based on policy"})]})]}),h.enabled&&e.jsxs("div",{style:{padding:16,background:o.cardBg,borderRadius:8,display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:o.textMuted},children:"Maximum number of snapshots"}),e.jsx("input",{type:"number",value:h.maxCount??"",onChange:t=>p({...h,maxCount:parseInt(t.target.value)||void 0}),placeholder:"Unlimited",style:{padding:10,borderRadius:6,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13,width:150}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:o.textMuted},children:"Maximum age (days)"}),e.jsx("input",{type:"number",value:h.maxAgeDays??"",onChange:t=>p({...h,maxAgeDays:parseInt(t.target.value)||void 0}),placeholder:"Unlimited",style:{padding:10,borderRadius:6,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13,width:150}})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:h.keepTagged??!1,onChange:t=>p({...h,keepTagged:t.target.checked})}),e.jsx("span",{style:{fontSize:13},children:"Keep tagged snapshots"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:h.keepLocked??!1,onChange:t=>p({...h,keepLocked:t.target.checked})}),e.jsx("span",{style:{fontSize:13},children:"Keep locked snapshots"})]})]}),e.jsx("button",{onClick:()=>H?.(h),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,alignSelf:"flex-start"},children:"Save Policy"})]})]})]}),x&&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},onClick:()=>O(!1),children:e.jsxs("div",{style:{background:o.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsx("h4",{style:{margin:"0 0 16px"},children:"📸 Create Snapshot"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:o.textMuted},children:"Snapshot Name"}),e.jsx("input",{type:"text",value:v,onChange:t=>I(t.target.value),placeholder:`Snapshot ${new Date().toISOString().split("T")[0]}`,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:o.textMuted},children:"Description (optional)"}),e.jsx("textarea",{value:T,onChange:t=>a(t.target.value),placeholder:"What's this snapshot for?",rows:3,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13,resize:"vertical",boxSizing:"border-box"}})]})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:24,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>O(!1),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:z,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Create"})]})]})})]})},De=Object.freeze(Object.defineProperty({__proto__:null,NiceDataSnapshot:ce},Symbol.toStringTag,{value:"Module"}));exports.NiceDataBranchGraph=se;exports.NiceDataBranchGraph$1=ve;exports.NiceDataBranchManager=ie;exports.NiceDataBranchManager$1=ye;exports.NiceDataConflictResolver=ae;exports.NiceDataConflictResolver$1=ze;exports.NiceDataDiffViewer=de;exports.NiceDataDiffViewer$1=be;exports.NiceDataMergeBuilder=le;exports.NiceDataMergeBuilder$1=ke;exports.NiceDataSnapshot=ce;exports.NiceDataSnapshot$1=De;