@nice2dev/ui 1.1.10 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +76 -0
- package/README.md +12 -20
- package/dist/NiceButton-5tWvfXKl.cjs +1 -0
- package/dist/NiceButton-DHSgQT1_.js +112 -0
- package/dist/NiceCodeEditor-B8At55f5.js +1179 -0
- package/dist/NiceCodeEditor-BJSEzhcY.cjs +260 -0
- package/dist/NiceColorPicker-DCgmE-3H.cjs +1 -0
- package/dist/NiceColorPicker-DK30kJgy.js +486 -0
- package/dist/NiceColorPicker-DtPFxDKM.cjs +1 -0
- package/dist/NiceColorPicker-bNJBAU_c.js +598 -0
- package/dist/NiceDataGrid-BOCJr6XF.js +2217 -0
- package/dist/NiceDataGrid-BV5Oh-gy.cjs +10 -0
- package/dist/NiceDataGrid-Dd7SI-M6.cjs +10 -0
- package/dist/NiceDataGrid-DjZchXYG.js +2217 -0
- package/dist/NiceForm-BCEXovJR.cjs +1 -0
- package/dist/NiceForm-D7oyWHXg.js +4820 -0
- package/dist/NiceForm-DUhxXArr.js +4817 -0
- package/dist/NiceForm-uCeVmTrD.cjs +1 -0
- package/dist/NiceHtmlEditor-BYk1roA4.cjs +10 -0
- package/dist/NiceHtmlEditor-C5kLeF9H.cjs +10 -0
- package/dist/NiceHtmlEditor-CFVMIC5L.js +848 -0
- package/dist/NiceHtmlEditor-mWebBmy1.js +849 -0
- package/dist/NiceLoginForm-BHyDY7br.cjs +1 -0
- package/dist/NiceLoginForm-BuxFY2Rk.js +750 -0
- package/dist/NiceLoginForm.css +1 -0
- package/dist/NiceMention-CA7CL5BI.js +11263 -0
- package/dist/NiceMention-CHcKRl-L.cjs +430 -0
- package/dist/NiceMention-DJD0BLcp.js +11269 -0
- package/dist/NiceMention-DcaUEMSg.cjs +430 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-C4p8a82e.cjs +1 -0
- package/dist/NiceModal-TNlkaL_i.js +85 -0
- package/dist/NiceModuleLifecyclePanel-BWbKdVC_.js +7054 -0
- package/dist/NiceModuleLifecyclePanel-CZHIzvkE.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-OC9YK2kG.js +7052 -0
- package/dist/NiceModuleLifecyclePanel-_OcfDmtC.cjs +1 -0
- package/dist/NicePagination-8XsBbMNx.js +165 -0
- package/dist/NicePagination-CkOoXf0f.js +165 -0
- package/dist/NicePagination-D7lek1G7.cjs +1 -0
- package/dist/NicePagination-OjTEfZJE.cjs +1 -0
- package/dist/NicePivotGrid-BJRSciWl.js +1183 -0
- package/dist/NicePivotGrid-CS1dPmNI.cjs +152 -0
- package/dist/NicePivotGrid-D2AxqDzJ.js +1183 -0
- package/dist/NicePivotGrid-DxQ6Py9D.cjs +152 -0
- package/dist/NiceSavedQueryPanel-B5HhqlAI.cjs +586 -0
- package/dist/NiceSavedQueryPanel-CMStDOKe.js +5125 -0
- package/dist/NiceSavedQueryPanel-D2i34e_b.cjs +586 -0
- package/dist/NiceSavedQueryPanel-mPO2THs7.js +5142 -0
- package/dist/NiceSavedQueryPanel.css +1 -1
- package/dist/NiceScheduler-7gP7vcLy.cjs +5 -0
- package/dist/NiceScheduler-Cy7F9tgH.js +1693 -0
- package/dist/NiceScheduler-DquRUZxD.cjs +5 -0
- package/dist/NiceScheduler-l8N4yCWd.js +1716 -0
- package/dist/NiceSelect-DZB1Rs9x.js +435 -0
- package/dist/NiceSelect-tMz9QQUs.cjs +1 -0
- package/dist/NiceStreamDashboard.doc-74KUXya1.cjs +8 -0
- package/dist/NiceStreamDashboard.doc-k8PQfCM0.js +32 -0
- package/dist/NiceWindow-BEov3s9F.js +2094 -0
- package/dist/NiceWindow-CDt6PCEg.cjs +1 -0
- package/dist/NiceWindow.css +1 -1
- package/dist/charts-C047IMVn.cjs +768 -0
- package/dist/charts-CCXSb3xk.js +4752 -0
- package/dist/charts-CqETcUhH.js +4752 -0
- package/dist/charts-DouiiHOT.cjs +768 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-BL-KmGYC.js +795 -0
- package/dist/core-Chg-oYCr.cjs +1 -0
- package/dist/core-CxBnKAhs.cjs +1 -0
- package/dist/core-D_LRh59n.js +795 -0
- package/dist/data-branching-Km4lc8P_.cjs +1 -0
- package/dist/data-branching-YQtJJEtn.js +6273 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +0 -51
- package/dist/data.mjs +3 -3
- package/dist/devops-D5yIDM3e.js +8312 -0
- package/dist/devops-rVpB0ZAX.cjs +17 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +6 -25
- package/dist/editors.mjs +55 -54
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +5 -0
- package/dist/feedback.mjs +2 -2
- package/dist/index.cjs +284 -284
- package/dist/index.css +1 -1
- package/dist/index.d.ts +194 -208
- package/dist/index.mjs +20312 -19511
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +29 -29
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.mjs +3 -3
- package/dist/no-code-6WyYb3hL.cjs +331 -0
- package/dist/no-code-BH5oVFC6.js +8186 -0
- package/dist/no-code-CnHG5_Vn.js +8186 -0
- package/dist/no-code-DMKlg1Zl.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.css +1 -1
- package/dist/no-code.d.ts +25 -18
- package/dist/no-code.mjs +3 -3
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +24 -24
- package/dist/overlays.mjs +24 -490
- package/dist/pickerCommons-0vyK1Knv.js +547 -0
- package/dist/pickerCommons-BFbItm8o.cjs +1 -0
- package/dist/pickerCommons-BHirHJyn.js +548 -0
- package/dist/pickerCommons-Bt8JIaTN.cjs +1 -0
- package/dist/pickerCommons.css +1 -1
- package/dist/style.css +10 -7
- package/package.json +4 -6
- package/css/legacy-bg-text-aliases.css +0 -87
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),a=require("@nice2dev/ui-core"),l=require("react");function pe(p=new Date){const M=new Date().getTime()-p.getTime(),S=Math.floor(M/1e3),z=Math.floor(S/60),N=Math.floor(z/60),P=Math.floor(N/24);let W;return S<60?W="just now":z<60?W=`${z} minute${z>1?"s":""} ago`:N<24?W=`${N} hour${N>1?"s":""} ago`:P<30?W=`${P} day${P>1?"s":""} ago`:W=p.toLocaleDateString(),{date:p,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,relative:W}}function xe(p){return p.substring(0,7)}function ue(p){const f=p||a.createId();return{id:f,shortId:xe(f)}}const Y=["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)"},q={development:"settings",testing:"flask",uat:"users",staging:"rocket",production:"building"};function ee(p){return Y.indexOf(p)}function ie(p,f){return ee(p)<ee(f)}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}}],se=({tenant:p,branches:f,currentUser:M={id:"user-1",name:"Current User"},availableTables:S=ge,readOnly:z=!1,onCreateBranch:N,onDeleteBranch:P,onSwitchBranch:W,onCloneBranch:H,onSyncBranch:G,onProtectBranch:V,onScheduleSync:m,className:b,style:K,"data-testid":C})=>{const[I,g]=l.useState(f??he),[_,v]=l.useState(null),[L,j]=l.useState(null),[D,T]=l.useState("development"),[c,y]=l.useState(""),[x,R]=l.useState([]),[O,d]=l.useState(!0),[w,F]=l.useState({requireApproval:!0,approversCount:1,requireBackup:!0,allowDirectChanges:!1}),[k,r]=l.useState({enabled:!1,frequency:"daily",direction:"pull"}),t=l.useMemo(()=>I.find(i=>i.id===_),[I,_]),n=l.useMemo(()=>{const i={production:[],staging:[],uat:[],testing:[],development:[]};return I.forEach(u=>{i[u.environment].push(u)}),i},[I]),o=i=>i<1024?`${i} B`:i<1024*1024?`${(i/1024).toFixed(1)} KB`:i<1024*1024*1024?`${(i/(1024*1024)).toFixed(1)} MB`:`${(i/(1024*1024*1024)).toFixed(1)} GB`,h=l.useCallback(()=>{const i={...ue(),name:c||`${D}-${Date.now()}`,displayName:c||D,isDefault:!1,isProtected:!1,createdBy:M,createdAt:pe(),status:"active",type:"data",environment:D,tenant:p,sourceSnapshot:t?.id,upstream:t?.id,tables:O?void 0:x,size:{records:0,bytes:0}};g(u=>[...u,i]),N?.(i),H?.(t?.id??"",D,O?void 0:x),j(null),A()},[c,D,t,O,x,M,p,N,H]),A=()=>{y(""),T("development"),R([]),d(!0)},U=l.useCallback(()=>{t&&(g(i=>i.filter(u=>u.id!==t.id)),P?.(t.id),v(null),j(null))},[t,P]),E=i=>{t&&(G?.(t.id,i),j(null))},X=()=>{t&&(g(i=>i.map(u=>u.id===t.id?{...u,isProtected:!0}:u)),V?.(t.id,w),j(null))},s={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-data-branch-manager ${b||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...K},"data-testid":C,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(a.NiceIcon,{name:"database",size:16})," Data Environments"]}),e.jsxs("span",{style:{fontSize:12,color:s.textMuted},children:["Tenant: ",p," • ",I.length," environments"]})]}),!z&&e.jsx("button",{onClick:()=>{v(I.find(i=>i.isDefault)?.id??null),j("clone")},style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"+ New Environment"})]}),e.jsx("div",{style:{padding:16,borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:8,overflowX:"auto"},children:Y.map((i,u)=>{const $=n[i],Q=$.length>0;return e.jsxs(l.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 16px",borderRadius:6,background:Q?B[i]+"20":s.cardBg,border:`2px solid ${Q?B[i]:s.border}`,opacity:Q?1:.5,cursor:Q?"pointer":"default"},onClick:()=>Q&&v($[0].id),children:[e.jsx(a.NiceIcon,{name:q[i],size:18}),e.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase"},children:i}),Q&&e.jsxs("div",{style:{fontSize:10,color:s.textMuted},children:[$.length," branch",$.length>1?"es":""]})]}),u<Y.length-1&&e.jsx("div",{style:{color:s.textMuted,fontSize:20},children:"→"})]},i)})}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{width:300,borderRight:`1px solid ${s.border}`,overflow:"auto"},children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${s.border}`,fontSize:11,color:s.textMuted},children:"All Environments"}),I.map(i=>e.jsxs("div",{onClick:()=>v(i.id),style:{padding:"12px 16px",borderBottom:`1px solid ${s.border}`,background:_===i.id?s.cardBg:"transparent",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:q[i.environment],size:16}),e.jsx("span",{style:{fontWeight:500},children:i.displayName}),i.isProtected&&e.jsx("span",{style:{fontSize:12},children:e.jsx(a.NiceIcon,{name:"lock",size:12})}),i.isDefault&&e.jsx("span",{style:{padding:"2px 6px",background:B[i.environment],borderRadius:4,fontSize:9,fontWeight:600},children:"DEFAULT"})]}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:4},children:[i.size?.records.toLocaleString()," records •"," ",o(i.size?.bytes??0)]}),e.jsx("div",{style:{fontSize:10,color:s.textMuted,marginTop:2},children:i.lastActivity?.relative})]},i.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(a.NiceIcon,{name:q[t.environment],size:32}),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:s.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:o(t.size?.bytes??0)},{label:"Tables",value:t.tables?.length.toString()??"All"},{label:"Status",value:t.status}].map(i=>e.jsxs("div",{style:{padding:12,background:s.cardBg,borderRadius:8,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:600},children:i.value}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:i.label})]},i.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:s.textMuted},children:"Created by"}),e.jsx("span",{children:t.createdBy.name}),e.jsx("span",{style:{color:s.textMuted},children:"Created at"}),e.jsx("span",{children:t.createdAt.date?.toLocaleString()}),e.jsx("span",{style:{color:s.textMuted},children:"Last activity"}),e.jsx("span",{children:t.lastActivity?.relative}),t.upstream&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:s.textMuted},children:"Source"}),e.jsx("span",{children:I.find(i=>i.id===t.upstream)?.displayName??"Unknown"})]}),t.sourceSnapshot&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:s.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(i=>e.jsxs("span",{style:{padding:"4px 10px",background:s.cardBg,borderRadius:4,fontSize:12},children:[e.jsx(a.NiceIcon,{name:"database",size:14})," ",i]},i))})]}),!z&&e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("button",{onClick:()=>W?.(t.id),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"zap",size:14})," Switch to this environment"]}),e.jsxs("button",{onClick:()=>j("clone"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," Clone"]}),e.jsxs("button",{onClick:()=>j("sync"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"refresh",size:14})," Sync"]}),!t.isProtected&&e.jsxs("button",{onClick:()=>j("protect"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"lock",size:14})," Protect"]}),!t.isDefault&&!t.isProtected&&e.jsxs("button",{onClick:()=>j("delete"),style:{padding:"8px 16px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," Delete"]})]})]}):e.jsxs("div",{style:{padding:32,textAlign:"center",color:s.textMuted},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:e.jsx(a.NiceIcon,{name:"database",size:48})}),e.jsx("div",{children:"Select an environment to view details"})]})})]}),L==="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:()=>j(null),children:e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(a.NiceIcon,{name:"clipboard",size:14})," Clone Environment"]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:s.textMuted},children:"Source Environment"}),e.jsxs("div",{style:{padding:12,background:s.bg,borderRadius:6,display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:q[t?.environment??"production"],size:14}),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:s.textMuted},children:"Target Environment"}),e.jsx("select",{value:D,onChange:i=>T(i.target.value),style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:13},children:Y.filter(i=>ie(t?.environment??"production",i)||i==="development"||i==="testing").map(i=>e.jsx("option",{value:i,children:i.charAt(0).toUpperCase()+i.slice(1)},i))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:s.textMuted},children:"Environment Name"}),e.jsx("input",{type:"text",value:c,onChange:i=>y(i.target.value),placeholder:`${D}-${new Date().toISOString().split("T")[0]}`,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${s.border}`,background:s.bg,color:s.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:O,onChange:i=>d(i.target.checked)}),e.jsx("span",{style:{fontSize:13},children:"Include all tables"})]})}),!O&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",marginBottom:6,fontSize:12,color:s.textMuted},children:["Select Tables (",x.length," selected)"]}),e.jsx("div",{style:{maxHeight:200,overflow:"auto",border:`1px solid ${s.border}`,borderRadius:6},children:S.map(i=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:`1px solid ${s.border}`,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.includes(i.name),onChange:u=>{u.target.checked?R($=>[...$,i.name]):R($=>$.filter(Q=>Q!==i.name))}}),e.jsx("span",{style:{flex:1,fontSize:13},children:i.displayName}),e.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[i.recordCount.toLocaleString()," rows"]})]},i.name))})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>j(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:h,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Clone Environment"})]})]})}),L==="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:()=>j(null),children:e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(a.NiceIcon,{name:"refresh",size:14})," Sync Environment"]}),e.jsxs("p",{style:{color:s.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 ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:24,marginBottom:8},children:e.jsx(a.NiceIcon,{name:"arrow-down",size:24})}),e.jsx("div",{style:{fontWeight:500},children:"Pull"}),e.jsx("div",{style:{fontSize:11,color:s.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 ${s.border}`,background:"transparent",color:t.environment==="production"?s.textMuted:s.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(a.NiceIcon,{name:"arrow-up",size:24})}),e.jsx("div",{style:{fontWeight:500},children:"Push"}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Send changes to source"})]})]}),e.jsx("button",{onClick:()=>j(null),style:{width:"100%",padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"})]})}),L==="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:()=>j(null),children:e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0",color:"var(--nice-color-error, #ef4444)"},children:[e.jsx(a.NiceIcon,{name:"trash",size:14})," Delete Environment"]}),e.jsxs("p",{style:{color:s.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.jsxs("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:[e.jsx(a.NiceIcon,{name:"warning",size:14})," This action cannot be undone."]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>j(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:U,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-error, #ef4444)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Delete Environment"})]})]})}),L==="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:()=>j(null),children:e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:450},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(a.NiceIcon,{name:"lock",size:14})," 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:w.requireApproval,onChange:i=>F(u=>({...u,requireApproval:i.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Require approval for changes"})]}),w.requireApproval&&e.jsxs("div",{style:{marginLeft:24},children:[e.jsx("label",{style:{display:"block",marginBottom:4,fontSize:11,color:s.textMuted},children:"Minimum approvers"}),e.jsx("input",{type:"number",min:1,max:5,value:w.approversCount,onChange:i=>F(u=>({...u,approversCount:parseInt(i.target.value)||1})),style:{width:80,padding:6,borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text}})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:w.requireBackup,onChange:i=>F(u=>({...u,requireBackup:i.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:!w.allowDirectChanges,onChange:i=>F(u=>({...u,allowDirectChanges:!i.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:()=>j(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:X,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-warning, #f59e0b)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Apply Protection"})]})]})})]})},ye=Object.freeze(Object.defineProperty({__proto__:null,NiceDataBranchManager:se},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"}]}],oe=({sourceBranch:p,targetBranch:f,branches:M=[],diffItems:S=fe,onCompare:z,onExport:N,onSelectRecord:P,className:W,style:H,"data-testid":G})=>{const[V,m]=l.useState("summary"),[b,K]=l.useState("all"),[C,I]=l.useState(null),[g,_]=l.useState(null),[v,L]=l.useState(""),[j,D]=l.useState(!1),[T,c]=l.useState(p?.id??""),[y,x]=l.useState(f?.id??""),R=l.useMemo(()=>S.reduce((n,o)=>({tables:n.tables+1,added:n.added+o.added,modified:n.modified+o.modified,deleted:n.deleted+o.deleted}),{tables:0,added:0,modified:0,deleted:0}),[S]),O=l.useMemo(()=>S.filter(n=>{if(b==="added"&&n.added===0||b==="modified"&&n.modified===0||b==="deleted"&&n.deleted===0)return!1;if(v){const o=v.toLowerCase();return n.table.toLowerCase().includes(o)||n.displayName.toLowerCase().includes(o)||n.module?.toLowerCase().includes(o)}return!0}).sort((n,o)=>o.added+o.modified+o.deleted-(n.added+n.modified+n.deleted)),[S,b,v]),d=l.useMemo(()=>S.find(n=>n.table===C),[S,C]),w=l.useMemo(()=>d?d.records.filter(n=>b==="all"?!0:n.changeType===b):[],[d,b]),F=l.useCallback(()=>{T&&y&&z?.(T,y)},[T,y,z]),k=n=>{switch(n){case"added":return"var(--nice-color-success, #22c55e)";case"modified":return"var(--nice-color-warning, #f59e0b)";case"deleted":return"var(--nice-color-error, #ef4444)";default:return"var(--nice-text-muted, #888)"}},r=n=>{switch(n){case"added":return"+";case"modified":return"~";case"deleted":return"-";default:return" "}},t={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-data-diff-viewer ${W||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...H},"data-testid":G,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(a.NiceIcon,{name:"bar-chart",size:16})," Data Diff Viewer"]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("select",{value:T,onChange:n=>c(n.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..."}),M.map(n=>e.jsx("option",{value:n.id,children:n.displayName},n.id))]}),e.jsx("span",{style:{color:t.textMuted},children:"→"}),e.jsxs("select",{value:y,onChange:n=>x(n.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..."}),M.map(n=>e.jsx("option",{value:n.id,children:n.displayName},n.id))]}),e.jsx("button",{onClick:F,disabled:!T||!y,style:{padding:"6px 12px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:T&&y?"pointer":"not-allowed",fontSize:12,opacity:T&&y?1:.5},children:"Compare"})]}),e.jsx("div",{style:{flex:1}}),e.jsxs("select",{onChange:n=>{n.target.value&&(N?.(n.target.value),n.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:R.tables})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:k("added")}}),e.jsxs("span",{style:{fontSize:12},children:["+",R.added," added"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:k("modified")}}),e.jsxs("span",{style:{fontSize:12},children:["~",R.modified," modified"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:k("deleted")}}),e.jsxs("span",{style:{fontSize:12},children:["-",R.deleted," deleted"]})]}),e.jsx("div",{style:{flex:1}}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","added","modified","deleted"].map(n=>e.jsx("button",{onClick:()=>K(n),style:{padding:"4px 12px",borderRadius:4,border:"none",background:b===n?"var(--nice-color-primary, #3b82f6)":t.cardBg,color:b===n?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:n},n))}),e.jsx("input",{type:"text",value:v,onChange:n=>L(n.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 (",O.length,")"]}),O.map(n=>e.jsxs("div",{onClick:()=>{I(n.table),_(null),m("table")},style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,background:C===n.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(a.NiceIcon,{name:"database",size:14})}),e.jsx("span",{style:{fontWeight:500,fontSize:13},children:n.displayName})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:11},children:[n.added>0&&e.jsxs("span",{style:{color:k("added")},children:["+",n.added]}),n.modified>0&&e.jsxs("span",{style:{color:k("modified")},children:["~",n.modified]}),n.deleted>0&&e.jsxs("span",{style:{color:k("deleted")},children:["-",n.deleted]})]}),n.module&&e.jsx("div",{style:{fontSize:10,color:t.textMuted,marginTop:4},children:n.module})]},n.table))]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[V==="summary"&&e.jsxs("div",{style:{padding:32,textAlign:"center",color:t.textMuted},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:e.jsx(a.NiceIcon,{name:"bar-chart",size:48})}),e.jsx("div",{children:"Select a table to view changes"})]}),V==="table"&&d&&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:d.displayName}),e.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:[d.table," • ",d.module]})]}),e.jsxs("div",{style:{display:"flex",gap:8,fontSize:12},children:[e.jsxs("span",{style:{color:k("added")},children:["+",d.added]}),e.jsxs("span",{style:{color:k("modified")},children:["~",d.modified]}),e.jsxs("span",{style:{color:k("deleted")},children:["-",d.deleted]})]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:w.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:w.map(n=>e.jsxs("tr",{onClick:()=>{_(n),m("record")},style:{cursor:"pointer",background:g?.id===n.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:k(n.changeType)+"30",color:k(n.changeType),fontWeight:600,fontSize:14},children:r(n.changeType)})}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace"},children:n.id}),e.jsxs("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:[n.fields.length," field",n.fields.length!==1?"s":""]}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:n.changedBy??"-"}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:n.changedAt?.toLocaleString()??"-"})]},n.id))})]})})]}),V==="record"&&g&&d&&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:()=>m("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:[d.displayName," / ",g.id]}),e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",background:k(g.changeType)+"30",color:k(g.changeType),borderRadius:4,fontSize:10,fontWeight:600,marginTop:4,textTransform:"uppercase"},children:g.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(g.primaryKey).map(([n,o])=>e.jsxs("span",{style:{marginRight:16},children:[e.jsxs("span",{style:{color:t.textMuted},children:[n,":"]})," ",String(o)]},n))})]}),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:g.fields.map(n=>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:k(n.changeType)+"30",color:k(n.changeType),fontWeight:600,fontSize:12},children:r(n.changeType)})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontWeight:500},children:n.field}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:n.fieldType}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace",background:n.changeType==="deleted"?"var(--nice-danger-tint-15, #ef444420)":"transparent"},children:n.oldValue!==void 0?String(n.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:n.changeType==="added"?"var(--nice-success-tint-12, #22c55e20)":n.changeType==="modified"?"var(--nice-warning-tint-15, #f59e0b20)":"transparent"},children:n.newValue!==void 0?String(n.newValue):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:"null"})})]},n.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:g.changedBy??"Unknown"}),e.jsx("span",{style:{color:t.textMuted},children:"Changed at"}),e.jsx("span",{children:g.changedAt?.toLocaleString()??"Unknown"})]})]})]})]})]})]})]})},me=Object.freeze(Object.defineProperty({__proto__:null,NiceDataDiffViewer:oe},Symbol.toStringTag,{value:"Module"})),be=[{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"]}],de=({branches:p=[],commits:f=be,selectedCommitId:M,viewMode:S,showLanes:z=!0,onSelectCommit:N,onSelectBranch:P,onCompare:W,onRestore:H,className:G,style:V,"data-testid":m})=>{const[b,K]=l.useState("graph"),[C,I]=l.useState(null),[g,_]=l.useState(null),[v,L]=l.useState(null),j=S??b,D=M??C,T=l.useRef(null),c=l.useMemo(()=>[...f].sort((r,t)=>t.timestamp.getTime()-r.timestamp.getTime()),[f]),y=l.useMemo(()=>{const r={};return Y.forEach((t,n)=>{r[t]=n}),f.reduce((t,n)=>(t[n.id]=r[n.environment]??0,t),{})},[f]),x=l.useMemo(()=>f.find(r=>r.id===D),[f,D]),R=l.useCallback(r=>{g?(W?.(g,r),_(null)):(I(r),N?.(r))},[g,W,N]),O=r=>{const n=new Date().getTime()-r.getTime(),o=Math.floor(n/(1e3*60*60*24));return o===0?"Today":o===1?"Yesterday":o<7?`${o} days ago`:o<30?`${Math.floor(o/7)} weeks ago`:`${Math.floor(o/30)} months ago`},d={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"},w=140,F=12,k=80;return e.jsxs("div",{className:`nice-data-branch-graph ${G||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:d.bg,color:d.text,fontFamily:"system-ui, sans-serif",...V},"data-testid":m,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${d.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(a.NiceIcon,{name:"bar-chart",size:16})," Data History"]}),e.jsx("div",{style:{display:"flex",gap:4},children:["graph","timeline","list"].map(r=>e.jsxs("button",{onClick:()=>K(r),style:{padding:"4px 12px",borderRadius:4,border:"none",background:j===r?"var(--nice-color-primary, #3b82f6)":d.cardBg,color:j===r?"var(--nice-color-white, #fff)":"var(--nice-text-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:[e.jsx(a.NiceIcon,{name:r==="graph"?"box":r==="timeline"?"calendar":"clipboard",size:14})," ",r]},r))}),e.jsx("div",{style:{flex:1}}),g?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{fontSize:12,color:d.textMuted},children:["Select target to compare with ",f.find(r=>r.id===g)?.shortId]}),e.jsx("button",{onClick:()=>_(null),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${d.border}`,background:"transparent",color:d.text,cursor:"pointer",fontSize:11},children:"Cancel"})]}):e.jsxs("span",{style:{fontSize:12,color:d.textMuted},children:[c.length," snapshots"]})]}),z&&j==="graph"&&e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${d.border}`,background:d.cardBg},children:[Y.map(r=>e.jsxs("div",{style:{width:w,padding:"8px 12px",textAlign:"center",borderRight:`1px solid ${d.border}`},children:[e.jsx(a.NiceIcon,{name:q[r],size:16}),e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:B[r]},children:r})]},r)),e.jsx("div",{style:{flex:1,padding:"8px 12px"},children:e.jsx("div",{style:{fontSize:11,color:d.textMuted},children:"Details"})})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[j==="graph"&&e.jsx("div",{ref:T,style:{flex:1,overflow:"auto"},children:e.jsxs("div",{style:{position:"relative",minHeight:c.length*k},children:[e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:w*Y.length,height:c.length*k,pointerEvents:"none"},children:c.map((r,t)=>{const n=t*k+k/2,o=y[r.id]*w+w/2;return r.parents.map(h=>{const A=c.findIndex(i=>i.id===h);if(A===-1)return null;const U=A*k+k/2,E=y[h]*w+w/2,X=r.isMerge&&r.parents.indexOf(h)>0,s=o===E?`M ${o} ${n} L ${E} ${U}`:`M ${o} ${n} C ${o} ${(n+U)/2}, ${E} ${(n+U)/2}, ${E} ${U}`;return e.jsx("path",{d:s,fill:"none",stroke:X?"var(--nice-color-accent, #8b5cf6)":B[r.environment],strokeWidth:2,strokeDasharray:X?"4,4":void 0,opacity:.6},`${r.id}-${h}`)})})}),c.map((r,t)=>{const n=t*k+k/2,o=y[r.id]*w+w/2,h=r.id===D,A=r.id===v,U=r.id===g;return e.jsxs(l.Fragment,{children:[e.jsx("div",{onClick:()=>R(r.id),onMouseEnter:()=>L(r.id),onMouseLeave:()=>L(null),style:{position:"absolute",left:o-F,top:n-F,width:F*2,height:F*2,borderRadius:r.isMerge?4:"50%",background:h||U?"var(--nice-bg-primary, #fff)":B[r.environment],border:`3px solid ${B[r.environment]}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,color:h||U?"var(--nice-text-primary, #000)":"var(--nice-text-primary, #fff)",zIndex:A?10:1,transform:A?"scale(1.2)":"scale(1)",transition:"transform 0.1s",boxShadow:h?"0 0 0 3px rgba(59, 130, 246, 0.5)":"none"},children:r.isSnapshot?e.jsx(a.NiceIcon,{name:"camera",size:12}):r.isMerge?e.jsx(a.NiceIcon,{name:"shuffle",size:12}):null}),e.jsxs("div",{style:{position:"absolute",left:w*Y.length+16,top:n-20,right:16,height:40,display:"flex",alignItems:"center",gap:12,padding:"4px 12px",background:h?d.cardBg:"transparent",borderRadius:6,borderLeft:h?`3px solid ${B[r.environment]}`:"none"},children:[e.jsx("span",{style:{fontFamily:"monospace",fontSize:11,color:B[r.environment]},children:r.shortId}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.message}),r.tags?.map(E=>e.jsxs("span",{style:{padding:"2px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:4,fontSize:9},children:[e.jsx(a.NiceIcon,{name:"tag",size:12})," ",E]},E)),e.jsx("span",{style:{fontSize:10,color:d.textMuted,whiteSpace:"nowrap"},children:O(r.timestamp)})]})]},r.id)})]})}),j==="timeline"&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:c.map((r,t)=>{const n=r.id===D,o=c[t-1],h=!o||r.timestamp.toDateString()!==o.timestamp.toDateString();return e.jsxs(l.Fragment,{children:[h&&e.jsx("div",{style:{padding:"8px 0",fontSize:11,fontWeight:600,color:d.textMuted,borderBottom:`1px solid ${d.border}`,marginBottom:8},children:r.timestamp.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}),e.jsxs("div",{onClick:()=>R(r.id),style:{display:"flex",gap:12,padding:12,marginBottom:8,background:n?d.cardBg:"transparent",borderRadius:8,cursor:"pointer",border:`1px solid ${n?B[r.environment]:"transparent"}`},children:[e.jsx("div",{style:{width:60,textAlign:"right",fontSize:11,color:d.textMuted},children:r.timestamp.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}),e.jsxs("div",{style:{width:80,padding:"4px 8px",background:B[r.environment]+"30",color:B[r.environment],borderRadius:4,fontSize:10,textAlign:"center",fontWeight:600,textTransform:"uppercase"},children:[e.jsx(a.NiceIcon,{name:q[r.environment],size:14})," ",r.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:d.textMuted},children:r.shortId}),r.isSnapshot&&e.jsx("span",{style:{fontSize:12},children:e.jsx(a.NiceIcon,{name:"camera",size:12})}),r.isMerge&&e.jsx("span",{style:{fontSize:12},children:e.jsx(a.NiceIcon,{name:"shuffle",size:12})}),r.tags?.map(A=>e.jsx("span",{style:{padding:"1px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:3,fontSize:9},children:A},A))]}),e.jsx("div",{style:{fontSize:13,marginTop:4},children:r.message}),e.jsxs("div",{style:{fontSize:11,color:d.textMuted,marginTop:4},children:["by ",r.author.name," •"," ",e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",r.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["~",r.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",r.stats.recordsDeleted]})]})]})]})]},r.id)})}),j==="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:d.cardBg},children:[e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"ID"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Environment"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Message"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Author"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Date"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"right",borderBottom:`1px solid ${d.border}`},children:"Changes"})]})}),e.jsx("tbody",{children:c.map(r=>e.jsxs("tr",{onClick:()=>R(r.id),style:{cursor:"pointer",background:r.id===D?d.cardBg:"transparent"},children:[e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,fontFamily:"monospace"},children:[r.shortId,r.isSnapshot&&e.jsxs(e.Fragment,{children:[" ",e.jsx(a.NiceIcon,{name:"camera",size:12})]}),r.isMerge&&e.jsxs(e.Fragment,{children:[" ",e.jsx(a.NiceIcon,{name:"shuffle",size:12})]})]}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`},children:e.jsx("span",{style:{padding:"2px 8px",background:B[r.environment]+"30",color:B[r.environment],borderRadius:4,fontSize:10,fontWeight:600},children:r.environment})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`},children:r.message}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,color:d.textMuted},children:r.author.name}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,color:d.textMuted},children:r.timestamp.toLocaleString()}),e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,textAlign:"right"},children:[e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",r.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["~",r.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",r.stats.recordsDeleted]})]})]},r.id))})]})}),x&&e.jsxs("div",{style:{width:320,borderLeft:`1px solid ${d.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:e.jsx(a.NiceIcon,{name:x.isSnapshot?"camera":x.isMerge?"shuffle":"edit",size:24})}),e.jsx("span",{style:{padding:"4px 10px",background:B[x.environment]+"30",color:B[x.environment],borderRadius:6,fontSize:11,fontWeight:600,textTransform:"uppercase"},children:x.environment})]}),e.jsx("h4",{style:{margin:"0 0 8px 0",fontSize:14},children:x.message}),x.description&&e.jsx("p",{style:{margin:0,fontSize:12,color:d.textMuted},children:x.description})]}),x.tags&&x.tags.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:d.textMuted,marginBottom:4},children:"Tags"}),e.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:x.tags.map(r=>e.jsxs("span",{style:{padding:"2px 8px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:4,fontSize:11},children:[e.jsx(a.NiceIcon,{name:"tag",size:12})," ",r]},r))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:d.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:d.cardBg,borderRadius:6,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:600},children:x.stats.tables}),e.jsx("div",{style:{fontSize:10,color:d.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(--nice-color-success, #22c55e)"},children:["+",x.stats.recordsAdded]}),e.jsx("div",{style:{fontSize:10,color:d.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(--nice-color-warning, #f59e0b)"},children:["~",x.stats.recordsModified]}),e.jsx("div",{style:{fontSize:10,color:d.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(--nice-color-error, #ef4444)"},children:["-",x.stats.recordsDeleted]}),e.jsx("div",{style:{fontSize:10,color:d.textMuted},children:"Deleted"})]})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:d.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:d.textMuted},children:"ID"}),e.jsx("span",{style:{fontFamily:"monospace"},children:x.shortId}),e.jsx("span",{style:{color:d.textMuted},children:"Author"}),e.jsx("span",{children:x.author.name}),e.jsx("span",{style:{color:d.textMuted},children:"Date"}),e.jsx("span",{children:x.timestamp.toLocaleString()}),e.jsx("span",{style:{color:d.textMuted},children:"Type"}),e.jsx("span",{children:x.isSnapshot?"Snapshot":x.isMerge?"Merge":"Change"}),x.parents.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:d.textMuted},children:"Parents"}),e.jsx("span",{style:{fontFamily:"monospace"},children:x.parents.map(r=>f.find(t=>t.id===r)?.shortId??r).join(", ")})]})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("button",{onClick:()=>_(x.id),style:{padding:"8px 12px",borderRadius:6,border:`1px solid ${d.border}`,background:"transparent",color:d.text,cursor:"pointer",fontSize:12},children:[e.jsx(a.NiceIcon,{name:"search",size:14})," Compare with..."]}),x.isSnapshot&&e.jsxs("button",{onClick:()=>H?.(x.id),style:{padding:"8px 12px",borderRadius:6,border:"none",background:"var(--nice-color-warning, #f59e0b)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500},children:[e.jsx(a.NiceIcon,{name:"reply",size:14})," Restore this snapshot"]})]})]})]})]})},ve=Object.freeze(Object.defineProperty({__proto__:null,NiceDataBranchGraph:de},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},ae=({branches:p=Se,sourceBranchId:f,targetBranchId:M,onPreview:S,onMerge:z,onCancel:N,tutorial:P,className:W,style:H,"data-testid":G})=>{const[V,m]=l.useState("select"),[b,K]=l.useState(f??""),[C,I]=l.useState(M??""),[g,_]=l.useState(null),[v,L]=l.useState([]),[j,D]=l.useState("keep-source"),[T,c]=l.useState(!0),[y,x]=l.useState(!1),[R,O]=l.useState(null),[d,w]=l.useState({}),[F,k]=l.useState(!1),r=l.useMemo(()=>p.find(i=>i.id===b),[p,b]),t=l.useMemo(()=>p.find(i=>i.id===C),[p,C]),n=l.useMemo(()=>r?p.filter(i=>i.id!==b&&(ie(r.environment,i.environment)||i.environment==="development"||i.environment==="testing")):p,[p,b,r]),o=l.useMemo(()=>g?g.tables.filter(u=>v.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},[g,v]),h=l.useMemo(()=>g?g.conflicts.filter(i=>!d[i.id]):[],[g,d]),A=l.useCallback(async()=>{k(!0),S?.(b,C),await new Promise(i=>setTimeout(i,1e3)),_(te),L(te.tables.filter(i=>i.selected).map(i=>i.table)),k(!1),m("preview")},[b,C,S]),U=l.useCallback(()=>{const i={sourceId:b,targetId:C,strategy:j,tables:v,createBackup:T,dryRun:y,scheduledAt:R??void 0,conflictResolutions:Object.entries(d).reduce((u,[$,Q])=>({...u,[$]:{conflictId:$,strategy:Q}}),{})};z?.(i)},[b,C,j,v,T,y,R,d,z]),E=(i,u)=>{w($=>({...$,[i]:u}))},X=i=>{if(!g)return;const u={};g.conflicts.forEach($=>{u[$.id]=i}),w(u)},s={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-data-merge-builder ${W||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...H},"data-testid":G,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(a.NiceIcon,{name:"shuffle",size:16})," Data Merge"]}),e.jsx("div",{style:{display:"flex",gap:8,marginLeft:"auto"},children:["select","preview","conflicts","options","confirm"].map((i,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:V===i?"var(--nice-color-primary, #3b82f6)":["select","preview","conflicts","options","confirm"].indexOf(V)>u?"var(--nice-color-success, #22c55e)":s.cardBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:600},children:["select","preview","conflicts","options","confirm"].indexOf(V)>u?e.jsx(a.NiceIcon,{name:"check",size:14}):u+1}),u<4&&e.jsx("div",{style:{width:24,height:2,background:["select","preview","conflicts","options","confirm"].indexOf(V)>u?"var(--nice-color-success, #22c55e)":s.border}})]},i))}),e.jsx(a.NiceTutorialButton,{steps:a.resolveTutorial(P,je)})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[V==="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:s.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:s.textMuted},children:"Source Environment"}),e.jsxs("select",{value:b,onChange:i=>{K(i.target.value),I("")},style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14},children:[e.jsx("option",{value:"",children:"Select source..."}),p.map(i=>e.jsx("option",{value:i.id,children:i.displayName},i.id))]}),r&&e.jsxs("div",{style:{marginTop:12,padding:12,background:B[r.environment]+"20",borderRadius:8,border:`1px solid ${B[r.environment]}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(a.NiceIcon,{name:q[r.environment],size:20}),e.jsx("span",{style:{fontWeight:600},children:r.displayName})]}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:4},children:[r.size?.records.toLocaleString()," records"]})]})]}),e.jsx("div",{style:{fontSize:24,color:s.textMuted},children:"→"}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:s.textMuted},children:"Target Environment"}),e.jsxs("select",{value:C,onChange:i=>I(i.target.value),disabled:!b,style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14,opacity:b?1:.5},children:[e.jsx("option",{value:"",children:"Select target..."}),n.map(i=>e.jsx("option",{value:i.id,children:i.displayName},i.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(a.NiceIcon,{name:q[t.environment],size:20}),e.jsx("span",{style:{fontWeight:600},children:t.displayName}),t.isProtected&&e.jsx("span",{children:e.jsx(a.NiceIcon,{name:"lock",size:16})})]}),e.jsxs("div",{style:{fontSize:11,color:s.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:N,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:A,disabled:!b||!C||F,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:b&&C&&!F?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:b&&C&&!F?1:.5},children:F?e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"clock",size:14})," Loading..."]}):"Preview Changes →"})]})]}),V==="preview"&&g&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>m("select"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.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(--nice-color-success, #22c55e)"},children:["+",o.inserts]}),e.jsx("div",{style:{fontSize:11,color:s.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(--nice-color-warning, #f59e0b)"},children:["~",o.updates]}),e.jsx("div",{style:{fontSize:11,color:s.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(--nice-color-error, #ef4444)"},children:["-",o.deletes]}),e.jsx("div",{style:{fontSize:11,color:s.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(--nice-color-accent, #8b5cf6)"},children:[e.jsx(a.NiceIcon,{name:"warning",size:14})," ",o.conflicts]}),e.jsx("div",{style:{fontSize:11,color:s.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:s.textMuted},children:["Select tables to merge (",v.length," / ",g.tables.length,")"]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>L(g.tables.map(i=>i.table)),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:11},children:"Select All"}),e.jsx("button",{onClick:()=>L([]),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:11},children:"Clear"})]})]}),e.jsx("div",{style:{border:`1px solid ${s.border}`,borderRadius:8,overflow:"hidden"},children:g.tables.map(i=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:`1px solid ${s.border}`,cursor:"pointer",background:v.includes(i.table)?s.cardBg:"transparent"},children:[e.jsx("input",{type:"checkbox",checked:v.includes(i.table),onChange:u=>{u.target.checked?L($=>[...$,i.table]):L($=>$.filter(Q=>Q!==i.table))}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:i.displayName}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:i.module})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:12},children:[i.inserts>0&&e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",i.inserts]}),i.updates>0&&e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["~",i.updates]}),i.deletes>0&&e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",i.deletes]}),i.conflicts>0&&e.jsxs("span",{style:{color:"var(--nice-color-accent, #8b5cf6)"},children:[e.jsx(a.NiceIcon,{name:"warning",size:14})," ",i.conflicts]})]})]},i.table))})]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m("select"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m(o.conflicts>0?"conflicts":"options"),disabled:v.length===0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:v.length>0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:v.length>0?1:.5},children:o.conflicts>0?"Resolve Conflicts →":"Configure Merge →"})]})]}),V==="conflicts"&&g&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>m("preview"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsxs("h4",{style:{margin:0},children:["Resolve Conflicts (",h.length," remaining)"]})]}),e.jsxs("div",{style:{padding:16,background:s.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:()=>X("keep-source"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"Keep Source"}),e.jsx("button",{onClick:()=>X("keep-target"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"Keep Target"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:g.conflicts.map(i=>{const u=!!d[i.id];return e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8,border:`1px solid ${u?"var(--nice-color-success, #22c55e)":"var(--nice-color-accent, #8b5cf6)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("span",{style:{fontSize:16},children:e.jsx(a.NiceIcon,{name:u?"check":"warning",size:16})}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontWeight:500},children:[i.table,".",i.field]}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted},children:["Record: ",i.recordId," • ",i.type.replace("-"," ")]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{style:{padding:12,background:d[i.id]==="keep-source"?"var(--nice-success-tint-12, #22c55e20)":s.bg,borderRadius:6,border:`1px solid ${d[i.id]==="keep-source"?"var(--nice-color-success, #22c55e)":s.border}`,cursor:"pointer"},onClick:()=>E(i.id,"keep-source"),children:[e.jsxs("div",{style:{fontSize:10,color:s.textMuted,marginBottom:4},children:["Source (",r?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(i.sourceValue)})]}),e.jsxs("div",{style:{padding:12,background:d[i.id]==="keep-target"?"var(--nice-success-tint-12, #22c55e20)":s.bg,borderRadius:6,border:`1px solid ${d[i.id]==="keep-target"?"var(--nice-color-success, #22c55e)":s.border}`,cursor:"pointer"},onClick:()=>E(i.id,"keep-target"),children:[e.jsxs("div",{style:{fontSize:10,color:s.textMuted,marginBottom:4},children:["Target (",t?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(i.targetValue)})]})]})]},i.id)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m("preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m("options"),disabled:h.length>0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:h.length===0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:h.length===0?1:.5},children:"Configure Merge →"})]})]}),V==="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:()=>m(o.conflicts>0?"conflicts":"preview"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.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:i=>c(i.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Create backup before merge"}),e.jsx("div",{style:{fontSize:11,color:s.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:y,onChange:i=>x(i.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Dry run (preview only)"}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Simulate merge without applying changes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:s.textMuted},children:"Schedule merge (optional)"}),e.jsx("input",{type:"datetime-local",value:R?.toISOString().slice(0,16)??"",onChange:i=>O(i.target.value?new Date(i.target.value):null),style:{padding:10,borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13}})]})]}),e.jsxs("div",{style:{marginTop:32,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m(o.conflicts>0?"conflicts":"preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m("confirm"),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Review & Confirm →"})]})]}),V==="confirm"&&g&&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:()=>m("options"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Confirm Merge"})]}),e.jsxs("div",{style:{padding:20,background:s.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[r?.environment??"development"]+"30",borderRadius:6},children:[e.jsx(a.NiceIcon,{name:q[r?.environment??"development"],size:14})," ",r?.displayName]}),e.jsx("span",{children:"→"}),e.jsxs("div",{style:{padding:"8px 12px",background:B[t?.environment??"production"]+"30",borderRadius:6},children:[e.jsx(a.NiceIcon,{name:q[t?.environment??"production"],size:14})," ",t?.displayName]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 16px",fontSize:13},children:[e.jsx("span",{style:{color:s.textMuted},children:"Tables"}),e.jsx("span",{children:v.length}),e.jsx("span",{style:{color:s.textMuted},children:"Records affected"}),e.jsx("span",{children:o.inserts+o.updates+o.deletes}),e.jsx("span",{style:{color:s.textMuted},children:"Backup"}),e.jsx("span",{children:T?"Yes":"No"}),e.jsx("span",{style:{color:s.textMuted},children:"Mode"}),e.jsx("span",{children:y?"Dry run":"Apply changes"}),R&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:s.textMuted},children:"Scheduled"}),e.jsx("span",{children:R.toLocaleString()})]})]})]}),t?.isProtected&&e.jsxs("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:[e.jsx(a.NiceIcon,{name:"warning",size:14})," Target environment is protected and may require approval."]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:N,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:U,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:y?e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"search",size:14})," Run Dry Merge"]}):R?e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"calendar",size:14})," Schedule Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"shuffle",size:14})," Execute Merge"]})})]})]})]})]})},ke=Object.freeze(Object.defineProperty({__proto__:null,NiceDataMergeBuilder:ae},Symbol.toStringTag,{value:"Module"})),ze=[{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"}],J={"concurrent-update":{label:"Concurrent Update",icon:"zap",description:"Record was modified in both environments"},"delete-update":{label:"Delete vs Update",icon:"trash",description:"Record deleted in source but updated in target"},"update-delete":{label:"Update vs Delete",icon:"edit",description:"Record updated in source but deleted in target"},"constraint-violation":{label:"Constraint Violation",icon:"slash",description:"Change violates database constraints"},"unique-key-conflict":{label:"Unique Key Conflict",icon:"lock",description:"Duplicate unique key detected"},"foreign-key-missing":{label:"Missing FK Reference",icon:"link",description:"Referenced record does not exist"},"type-mismatch":{label:"Type Mismatch",icon:"warning",description:"Data type incompatibility"},"schema-change":{label:"Schema Change",icon:"clipboard",description:"Schema differs between environments"}},Z={low:"var(--nice-color-success, #22c55e)",medium:"var(--nice-color-warning, #f59e0b)",high:"var(--nice-warning, #f97316)",critical:"var(--nice-color-error, #ef4444)"},le=({conflicts:p=ze,sourceEnvironment:f="development",targetEnvironment:M="uat",showSuggestions:S=!0,allowCustomValues:z=!0,onResolve:N,onSkip:P,onCancel:W,className:H,style:G,"data-testid":V})=>{const[m,b]=l.useState(0),[K,C]=l.useState({}),[I,g]=l.useState({}),[_,v]=l.useState(null),[L,j]=l.useState(""),[D,T]=l.useState("single"),c=p[m],y=l.useMemo(()=>Object.keys(K).length,[K]),x=l.useMemo(()=>{if(!c)return!1;const n=I[c.id]||{};return c.fields.every(o=>n[o.field]?.resolution)},[c,I]),R=l.useCallback(n=>{if(I[n.id])return;const o={};n.fields.forEach(h=>{o[h.field]={resolution:"source",value:h.sourceValue}}),g(h=>({...h,[n.id]:o}))},[I]);l.useEffect(()=>{c&&R(c)},[c,R]);const O=(n,o,h)=>{if(!c)return;const A=c.fields.find(E=>E.field===n);if(!A)return;const U=o==="source"?A.sourceValue:o==="target"?A.targetValue:h;g(E=>({...E,[c.id]:{...E[c.id],[n]:{resolution:o,value:U}}}))},d=n=>{if(!c)return;const o={};c.fields.forEach(h=>{o[h.field]={resolution:n,value:n==="source"?h.sourceValue:h.targetValue}}),g(h=>({...h,[c.id]:o}))},w=()=>{if(!c||!x)return;const n={conflictId:c.id,strategy:"manual",fieldResolutions:I[c.id]};C(o=>({...o,[c.id]:n})),m<p.length-1&&b(m+1)},F=()=>{c&&(P?.(c.id),m<p.length-1&&b(m+1))},k=()=>{const n=Object.values(K);N?.(n)},r=(n,o)=>n===null?"null":n===void 0?"undefined":o==="date"?new Date(n).toLocaleDateString():o==="number"?Number(n).toLocaleString():typeof n=="boolean"?n?"true":"false":String(n),t={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",source:B[f],target:B[M]};return p.length===0?e.jsxs("div",{className:`nice-data-conflict-resolver ${H||""}`,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",padding:40,...G},"data-testid":V,children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:e.jsx(a.NiceIcon,{name:"check",size:48})}),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 ${H||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...G},"data-testid":V,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(a.NiceIcon,{name:"warning",size:16})," 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:y})," /"," ",p.length]}),e.jsx("div",{style:{width:100,height:6,background:t.cardBg,borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${y/p.length*100}%`,height:"100%",background:"var(--nice-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:D==="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:D==="list"?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"List"})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[D==="single"&&c&&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,m-1)),disabled:m===0,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:m>0?"pointer":"not-allowed",opacity:m>0?1:.5,fontSize:12},children:"← Previous"}),e.jsxs("span",{style:{fontSize:13,color:t.textMuted},children:["Conflict ",m+1," of ",p.length]}),e.jsx("button",{onClick:()=>b(Math.min(p.length-1,m+1)),disabled:m===p.length-1,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:m<p.length-1?"pointer":"not-allowed",opacity:m<p.length-1?1:.5,fontSize:12},children:"Next →"}),K[c.id]&&e.jsxs("span",{style:{marginLeft:"auto",padding:"4px 8px",background:"#22c55e30",color:"var(--nice-color-success, #22c55e)",borderRadius:4,fontSize:11},children:[e.jsx(a.NiceIcon,{name:"check",size:14})," 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:e.jsx(a.NiceIcon,{name:J[c.type].icon,size:24})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:600,fontSize:15},children:[c.tableName,":"," ",c.recordLabel??c.recordId]}),e.jsxs("div",{style:{fontSize:12,color:t.textMuted},children:[J[c.type].label," —"," ",J[c.type].description]})]}),e.jsx("div",{style:{padding:"4px 8px",background:Z[c.severity]+"30",color:Z[c.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:c.severity})]}),c.metadata&&e.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`,fontSize:11,color:t.textMuted},children:[c.metadata.sourceModifiedAt&&e.jsxs("span",{children:["Source modified: ",c.metadata.sourceModifiedAt.toLocaleString()," ","by ",c.metadata.sourceModifiedBy]}),c.metadata.targetModifiedAt&&e.jsxs("span",{children:["Target modified: ",c.metadata.targetModifiedAt.toLocaleString()," ","by ",c.metadata.targetModifiedBy]})]}),S&&c.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.jsxs("strong",{children:[e.jsx(a.NiceIcon,{name:"lightbulb",size:14})," Suggestion:"]})," ",c.suggestionReason,e.jsx("button",{onClick:()=>d(c.suggestion==="keep-source"?"source":"target"),style:{marginLeft:12,padding:"4px 8px",borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-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:()=>d("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:[e.jsx(a.NiceIcon,{name:q[f],size:14})," Keep Source"]}),e.jsxs("button",{onClick:()=>d("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:[e.jsx(a.NiceIcon,{name:q[M],size:14})," Keep Target"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:c.fields.map(n=>{const o=I[c.id]?.[n.field],h=_===`${c.id}-${n.field}`;return e.jsxs("div",{style:{background:t.cardBg,borderRadius:8,overflow:"hidden",border:`1px solid ${o?.resolution?"var(--nice-color-success, #22c55e)":t.border}`},children:[e.jsxs("div",{style:{padding:"10px 16px",background:o?.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:o?.resolution?"var(--nice-color-success, #22c55e)":t.textMuted},children:e.jsx(a.NiceIcon,{name:o?.resolution?"check":"circle",size:14})}),e.jsx("span",{style:{fontWeight:500},children:n.fieldLabel}),e.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:["(",n.field,")"]}),e.jsx("span",{style:{marginLeft:"auto",fontSize:10,padding:"2px 6px",background:t.bg,borderRadius:4,color:t.textMuted},children:n.dataType})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1,background:t.border},children:[e.jsxs("div",{onClick:()=>O(n.field,"source"),style:{padding:16,background:o?.resolution==="source"?`${t.source}20`:t.bg,cursor:"pointer",border:o?.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:[e.jsx(a.NiceIcon,{name:q[f],size:14})," Source",o?.resolution==="source"&&e.jsx("span",{style:{marginLeft:4},children:e.jsx(a.NiceIcon,{name:"check",size:14})})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:r(n.sourceValue,n.dataType)})]}),e.jsxs("div",{onClick:()=>O(n.field,"target"),style:{padding:16,background:o?.resolution==="target"?`${t.target}20`:t.bg,cursor:"pointer",border:o?.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:[e.jsx(a.NiceIcon,{name:q[M],size:14})," Target",o?.resolution==="target"&&e.jsx("span",{style:{marginLeft:4},children:e.jsx(a.NiceIcon,{name:"check",size:14})})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:r(n.targetValue,n.dataType)})]})]}),z&&e.jsxs("div",{style:{padding:12,background:o?.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:"}),h?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:L,onChange:A=>j(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:()=>{O(n.field,"custom",L),v(null)},style:{padding:"6px 12px",borderRadius:4,border:"none",background:"var(--nice-color-accent, #8b5cf6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:12},children:"Apply"}),e.jsx("button",{onClick:()=>v(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:()=>{j(o?.resolution==="custom"?String(o.value):String(n.sourceValue)),v(`${c.id}-${n.field}`)},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:o?.resolution==="custom"?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:12},children:o?.resolution==="custom"?`Using: ${r(o.value,n.dataType)}`:"Enter custom..."})]})]},n.field)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:F,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:w,disabled:!x,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-text-on-primary, #fff)",cursor:x?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:x?1:.5},children:m<p.length-1?"Confirm & Next →":"Confirm"})]})]}),D==="list"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.map((n,o)=>{const h=!!K[n.id];return e.jsxs("div",{onClick:()=>{b(o),T("single")},style:{padding:16,background:t.cardBg,borderRadius:8,cursor:"pointer",border:`1px solid ${h?"var(--nice-color-success, #22c55e)":t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:20},children:e.jsx(a.NiceIcon,{name:h?"check":J[n.type].icon,size:14})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[n.tableName,": ",n.recordLabel??n.recordId]}),e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[n.fields.length," fields • ",J[n.type].label]})]}),e.jsx("div",{style:{padding:"4px 8px",background:Z[n.severity]+"30",color:Z[n.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:n.severity})]},n.id)})})]}),e.jsxs("div",{style:{padding:"16px 20px",borderTop:`1px solid ${t.border}`,display:"flex",justifyContent:"space-between"},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:"Cancel"}),e.jsxs("button",{onClick:k,disabled:y===0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:y>0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:y>0?1:.5},children:["Finish (",y," resolved)"]})]})]})},Ce=Object.freeze(Object.defineProperty({__proto__:null,NiceDataConflictResolver:le},Symbol.toStringTag,{value:"Module"})),we=[{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"}],Be=[{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=p=>{if(p===0)return"0 B";const f=1024,M=["B","KB","MB","GB","TB"],S=Math.floor(Math.log(p)/Math.log(f));return parseFloat((p/Math.pow(f,S)).toFixed(1))+" "+M[S]},ne=p=>{const M=new Date().getTime()-p.getTime(),S=Math.floor(M/(1e3*60*60)),z=Math.floor(S/24);return z>0?`${z} day${z>1?"s":""} ago`:S>0?`${S} hour${S>1?"s":""} ago`:"Just now"},Re=p=>{const f=p.split(" ");if(f.length!==5)return p;const[M,S,z,N,P]=f;return z==="*"&&N==="*"&&P==="*"?`Daily at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:z==="*"&&N==="*"?`Weekly on ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][parseInt(P)]} at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:N==="*"?`Monthly on day ${z} at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:p},Ie={creating:{icon:"clock",color:"var(--nice-color-warning, #f59e0b)",label:"Creating"},ready:{icon:"check",color:"var(--nice-color-success, #22c55e)",label:"Ready"},failed:{icon:"close",color:"var(--nice-color-error, #ef4444)",label:"Failed"},expired:{icon:"clock",color:"var(--nice-text-muted, #888)",label:"Expired"},locked:{icon:"lock",color:"var(--nice-color-primary, #3b82f6)",label:"Locked"}},Te={manual:{icon:"user",label:"Manual"},scheduled:{icon:"calendar",label:"Scheduled"},"pre-merge":{icon:"shuffle",label:"Pre-Merge"},"pre-restore":{icon:"reply",label:"Pre-Restore"}},ce=({environment:p="production",snapshots:f=we,retentionPolicy:M=Me,schedules:S=Be,onCreateSnapshot:z,onRestoreSnapshot:N,onDeleteSnapshot:P,onCompareSnapshots:W,onExportSnapshot:H,onUpdateRetentionPolicy:G,onUpdateSchedules:V,className:m,style:b,"data-testid":K})=>{const[C,I]=l.useState("snapshots"),[g,_]=l.useState(!1),[v,L]=l.useState([]),[j,D]=l.useState(""),[T,c]=l.useState(""),[y,x]=l.useState(M),[R,O]=l.useState(S),d=l.useMemo(()=>{const t=f.filter(o=>o.status==="ready").length,n=f.reduce((o,h)=>o+h.size.bytes,0);return{total:f.length,ready:t,totalSize:n}},[f]),w=()=>{z?.({name:j||`Snapshot ${new Date().toISOString()}`,description:T}),_(!1),D(""),c("")},F=()=>{v.length===2&&W?.(v[0],v[1])},k=t=>{const n=R.map(o=>o.id===t?{...o,enabled:!o.enabled}:o);O(n),V?.(n)},r={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",env:B[p]};return e.jsxs("div",{className:`nice-data-snapshot ${m||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:r.bg,color:r.text,fontFamily:"system-ui, sans-serif",...b},"data-testid":K,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${r.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(a.NiceIcon,{name:"camera",size:16})," Snapshots"]}),e.jsxs("div",{style:{padding:"4px 10px",background:r.env+"30",borderRadius:4,fontSize:12,display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:q[p],size:14})," ",p.charAt(0).toUpperCase()+p.slice(1)]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:16,fontSize:12,color:r.textMuted},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:r.text},children:d.total})," snapshots"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:r.text},children:re(d.totalSize)})," total"]})]}),e.jsxs("button",{onClick:()=>_(!0),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(a.NiceIcon,{name:"camera",size:14})," Create Snapshot"]})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${r.border}`,padding:"0 20px"},children:["snapshots","schedules","settings"].map(t=>e.jsxs("button",{onClick:()=>I(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:C===t?r.text:r.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"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"folder",size:14})," Snapshots"]}),t==="schedules"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"calendar",size:14})," Schedules"]}),t==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(a.NiceIcon,{name:"settings",size:14})," Settings"]})]},t))}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[C==="snapshots"&&e.jsxs("div",{children:[v.length>0&&e.jsxs("div",{style:{padding:12,background:r.cardBg,borderRadius:8,marginBottom:16,display:"flex",alignItems:"center",gap:12},children:[e.jsxs("span",{style:{fontSize:13},children:[v.length," selected"]}),v.length===2&&e.jsx("button",{onClick:F,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${r.border}`,background:"transparent",color:r.text,cursor:"pointer",fontSize:12},children:"Compare"}),e.jsx("button",{onClick:()=>L([]),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${r.border}`,background:"transparent",color:r.text,cursor:"pointer",fontSize:12,marginLeft:"auto"},children:"Clear"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:f.map(t=>{const n=v.includes(t.id),o=Ie[t.status],h=Te[t.type];return e.jsx("div",{style:{padding:16,background:r.cardBg,borderRadius:8,border:`1px solid ${n?"var(--nice-color-primary, #3b82f6)":r.border}`},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:A=>{A.target.checked?L(U=>[...U,t.id]):L(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:o.color+"20",color:o.color,borderRadius:4,fontSize:10},children:[e.jsx(a.NiceIcon,{name:o.icon,size:14})," ",o.label]}),e.jsxs("span",{style:{padding:"2px 6px",background:r.bg,color:r.textMuted,borderRadius:4,fontSize:10},children:[e.jsx(a.NiceIcon,{name:h.icon,size:14})," ",h.label]})]}),t.description&&e.jsx("div",{style:{fontSize:12,color:r.textMuted,marginBottom:8},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:11,color:r.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(--nice-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(--nice-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:()=>N?.(t.id),title:"Restore","aria-label":"Restore",style:{padding:8,borderRadius:4,border:`1px solid ${r.border}`,background:"transparent",color:r.text,cursor:"pointer",fontSize:14},children:e.jsx(a.NiceIcon,{name:"reply",size:14})}),e.jsx("button",{onClick:()=>H?.(t.id,"sql"),title:"Export","aria-label":"Export",style:{padding:8,borderRadius:4,border:`1px solid ${r.border}`,background:"transparent",color:r.text,cursor:"pointer",fontSize:14},children:e.jsx(a.NiceIcon,{name:"upload",size:14})})]}),t.status!=="locked"&&e.jsx("button",{onClick:()=>P?.(t.id),title:"Delete","aria-label":"Delete",style:{padding:8,borderRadius:4,border:`1px solid ${r.border}`,background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(a.NiceIcon,{name:"trash",size:14})})]})]})},t.id)})})]}),C==="schedules"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[R.map(t=>e.jsx("div",{style:{padding:16,background:r.cardBg,borderRadius:8,border:`1px solid ${r.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:()=>k(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:r.textMuted},children:[Re(t.cron)," • Keep ",t.retainCount," snapshots"]})]}),e.jsxs("div",{style:{textAlign:"right",fontSize:11,color:r.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 ${r.border}`,background:"transparent",color:r.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:y.enabled,onChange:t=>x({...y,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:r.textMuted},children:"Automatically delete old snapshots based on policy"})]})]}),y.enabled&&e.jsxs("div",{style:{padding:16,background:r.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:r.textMuted},children:"Maximum number of snapshots"}),e.jsx("input",{type:"number",value:y.maxCount??"",onChange:t=>x({...y,maxCount:parseInt(t.target.value)||void 0}),placeholder:"Unlimited",style:{padding:10,borderRadius:6,border:`1px solid ${r.border}`,background:r.bg,color:r.text,fontSize:13,width:150}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:r.textMuted},children:"Maximum age (days)"}),e.jsx("input",{type:"number",value:y.maxAgeDays??"",onChange:t=>x({...y,maxAgeDays:parseInt(t.target.value)||void 0}),placeholder:"Unlimited",style:{padding:10,borderRadius:6,border:`1px solid ${r.border}`,background:r.bg,color:r.text,fontSize:13,width:150}})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:y.keepTagged??!1,onChange:t=>x({...y,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:y.keepLocked??!1,onChange:t=>x({...y,keepLocked:t.target.checked})}),e.jsx("span",{style:{fontSize:13},children:"Keep locked snapshots"})]})]}),e.jsx("button",{onClick:()=>G?.(y),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,alignSelf:"flex-start"},children:"Save Policy"})]})]})]}),g&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>_(!1),children:e.jsxs("div",{style:{background:r.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px"},children:[e.jsx(a.NiceIcon,{name:"camera",size:14})," 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:r.textMuted},children:"Snapshot Name"}),e.jsx("input",{type:"text",value:j,onChange:t=>D(t.target.value),placeholder:`Snapshot ${new Date().toISOString().split("T")[0]}`,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${r.border}`,background:r.bg,color:r.text,fontSize:13,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:r.textMuted},children:"Description (optional)"}),e.jsx("textarea",{value:T,onChange:t=>c(t.target.value),placeholder:"What's this snapshot for?",rows:3,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${r.border}`,background:r.bg,color:r.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:()=>_(!1),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${r.border}`,background:"transparent",color:r.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:w,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-text-on-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Create"})]})]})})]})},$e=Object.freeze(Object.defineProperty({__proto__:null,NiceDataSnapshot:ce},Symbol.toStringTag,{value:"Module"}));exports.NiceDataBranchGraph=de;exports.NiceDataBranchGraph$1=ve;exports.NiceDataBranchManager=se;exports.NiceDataBranchManager$1=ye;exports.NiceDataConflictResolver=le;exports.NiceDataConflictResolver$1=Ce;exports.NiceDataDiffViewer=oe;exports.NiceDataDiffViewer$1=me;exports.NiceDataMergeBuilder=ae;exports.NiceDataMergeBuilder$1=ke;exports.NiceDataSnapshot=ce;exports.NiceDataSnapshot$1=$e;
|