@nice2dev/ui 1.0.29 → 1.0.31
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 +512 -0
- package/README.md +30 -31
- package/dist/NiceBackupStatusBadge.doc-Bx2bFmBQ.cjs +1 -0
- package/dist/NiceBackupStatusBadge.doc-CdDxIQ-M.js +25 -0
- package/dist/NiceCalendarScheduler.doc-BEtQkZjV.cjs +9 -0
- package/dist/NiceCalendarScheduler.doc-D__LRgOx.js +33 -0
- package/dist/NiceConfirmDialog-B57cl_F7.cjs +1 -0
- package/dist/NiceConfirmDialog-BiTJVR4-.js +81 -0
- package/dist/NiceConfirmDialog-Bjw_rN4o.cjs +1 -0
- package/dist/NiceConfirmDialog-N9fBTLYm.js +81 -0
- package/dist/NiceDrawingCanvas.doc-Dv5vB4gY.js +32 -0
- package/dist/NiceDrawingCanvas.doc-Ww9zz17x.cjs +8 -0
- package/dist/NiceErrorBoundary-1H751jK7.cjs +1 -0
- package/dist/NiceErrorBoundary-B-txoU3Y.js +709 -0
- package/dist/NiceErrorBoundary-BD-uqk_q.js +709 -0
- package/dist/NiceErrorBoundary-CIPXaYik.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-CKlnm6cX.cjs +1 -0
- package/dist/NiceFileManagerViews.doc-Cg21DArG.js +25 -0
- package/dist/NiceForm-BNZB31Pg.js +4499 -0
- package/dist/NiceForm-CPyAXxBO.cjs +1 -0
- package/dist/NiceForm-DGUTmaZT.js +5014 -0
- package/dist/NiceForm-DmU-gmyv.cjs +382 -0
- package/dist/NiceMegaMenu.doc-7UyOCd3l.cjs +7 -0
- package/dist/NiceMegaMenu.doc-zeIyVa65.js +31 -0
- package/dist/NiceModal-BClAtR5T.js +95 -0
- package/dist/NiceModal-Bj53SKLI.js +95 -0
- package/dist/NiceModal-DC0UlQhc.cjs +1 -0
- package/dist/NiceModal-iKwtagFB.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BBOg9g0b.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-BO8Hw_W9.js +7619 -0
- package/dist/NiceModuleLifecyclePanel-Ch7HRRoy.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DtuXRiLR.js +6991 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NicePagination-BVo-4KAD.js +172 -0
- package/dist/NicePagination-Bjxy9aEc.js +172 -0
- package/dist/NicePagination-CaohvQsY.cjs +1 -0
- package/dist/NicePagination-CfFfNwrg.cjs +1 -0
- package/dist/NicePinCodeInput-DsyLuc0b.cjs +696 -0
- package/dist/NicePinCodeInput-nuRCN-9R.js +13223 -0
- package/dist/NiceSavedQueryPanel-BBFV4qiF.js +6969 -0
- package/dist/NiceSavedQueryPanel-CH5c3rUG.js +6988 -0
- package/dist/NiceSavedQueryPanel-CsiVNkCT.cjs +596 -0
- package/dist/NiceSavedQueryPanel-aQrEmmcC.cjs +596 -0
- package/dist/NiceScannerControl-Cd5KXJA9.js +12769 -0
- package/dist/NiceScannerControl-DZsERSw_.cjs +698 -0
- package/dist/NiceScannerControl.css +1 -0
- package/dist/NiceWindow-BoDzlGk-.js +1621 -0
- package/dist/NiceWindow-Cm9E6EAi.cjs +1 -0
- package/dist/NiceWindow-DgONWxBm.cjs +1 -0
- package/dist/NiceWindow-FMrVS7zo.js +1603 -0
- package/dist/charts-B90sSFeJ.cjs +761 -0
- package/dist/charts-Bs0aDM0X.js +4671 -0
- package/dist/charts-DaLf19vS.js +4671 -0
- package/dist/charts-DjjKkw0q.cjs +761 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.mjs +1 -1
- package/dist/core-BUTtIHg0.js +27766 -0
- package/dist/core-BUsZ7_vI.js +27914 -0
- package/dist/core-CESNSRyS.cjs +122 -0
- package/dist/core-CLfcCDKc.cjs +122 -0
- package/dist/data-branching-ByQdcjKO.cjs +1 -0
- package/dist/data-branching-D7l_kILW.cjs +1 -0
- package/dist/data-branching-lJ07lDN-.js +6255 -0
- package/dist/data-branching-psTzlcrT.js +6255 -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 +41 -37
- package/dist/data.mjs +18 -19
- package/dist/devops-Bi8MXtko.js +8165 -0
- package/dist/devops-D7bQ3rE4.cjs +17 -0
- package/dist/devops-On_1wRf9.cjs +17 -0
- package/dist/devops-jCmpD6O-.js +8165 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.mjs +3 -3
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +219 -431
- package/dist/editors.mjs +48 -56
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.mjs +3 -3
- package/dist/index-BDH1yDSg.js +69235 -0
- package/dist/index-BpixglWg.js +69337 -0
- package/dist/index-C9njkNOD.cjs +5470 -0
- package/dist/index-DLR-aWZR.cjs +5506 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +798 -1059
- package/dist/index.mjs +741 -756
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.mjs +24 -24
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.d.ts +25 -213
- package/dist/navigation.mjs +143 -151
- package/dist/no-code-8lO7o6xi.js +7425 -0
- package/dist/no-code-BHo5WrXr.js +7425 -0
- package/dist/no-code-DyA_1_Th.cjs +332 -0
- package/dist/no-code-K8tOLNew.cjs +332 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.mjs +1 -1
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +12 -0
- package/dist/overlays.mjs +82 -82
- package/dist/pickerCommons-BEc3pZ_s.js +2044 -0
- package/dist/pickerCommons-CORo9j2a.js +2119 -0
- package/dist/pickerCommons-CrITwM88.cjs +1 -0
- package/dist/pickerCommons-D3WShRrR.cjs +1 -0
- package/dist/style.css +5 -5
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),c=require("./core-CESNSRyS.cjs"),a=require("react");function pe(p=new Date){const M=new Date().getTime()-p.getTime(),S=Math.floor(M/1e3),z=Math.floor(S/60),I=Math.floor(z/60),U=Math.floor(I/24);let W;return S<60?W="just now":z<60?W=`${z} minute${z>1?"s":""} ago`:I<24?W=`${I} hour${I>1?"s":""} ago`:U<30?W=`${U} day${U>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||crypto.randomUUID();return{id:f,shortId:xe(f)}}const Q=["development","testing","uat","staging","production"],B={development:"var(--nice-success, #22c55e)",testing:"var(--nice-primary, #3b82f6)",uat:"var(--nice-warning, #f59e0b)",staging:"var(--nice-accent, #8b5cf6)",production:"var(--nice-danger, #ef4444)"},_={development:"🛠️",testing:"🧪",uat:"👥",staging:"🚀",production:"🏭"};function ee(p){return Q.indexOf(p)}function se(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}}],oe=({tenant:p,branches:f,currentUser:M={id:"user-1",name:"Current User"},availableTables:S=ge,readOnly:z=!1,onCreateBranch:I,onDeleteBranch:U,onSwitchBranch:W,onCloneBranch:H,onSyncBranch:G,onProtectBranch:V,onScheduleSync:m,className:b,style:q,"data-testid":C})=>{const[T,g]=a.useState(f??he),[O,v]=a.useState(null),[L,j]=a.useState(null),[A,$]=a.useState("development"),[l,y]=a.useState(""),[x,R]=a.useState([]),[P,d]=a.useState(!0),[w,F]=a.useState({requireApproval:!0,approversCount:1,requireBackup:!0,allowDirectChanges:!1}),[k,s]=a.useState({enabled:!1,frequency:"daily",direction:"pull"}),t=a.useMemo(()=>T.find(n=>n.id===O),[T,O]),r=a.useMemo(()=>{const n={production:[],staging:[],uat:[],testing:[],development:[]};return T.forEach(u=>{n[u.environment].push(u)}),n},[T]),i=n=>n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:n<1024*1024*1024?`${(n/(1024*1024)).toFixed(1)} MB`:`${(n/(1024*1024*1024)).toFixed(1)} GB`,h=a.useCallback(()=>{const n={...ue(),name:l||`${A}-${Date.now()}`,displayName:l||A,isDefault:!1,isProtected:!1,createdBy:M,createdAt:pe(),status:"active",type:"data",environment:A,tenant:p,sourceSnapshot:t?.id,upstream:t?.id,tables:P?void 0:x,size:{records:0,bytes:0}};g(u=>[...u,n]),I?.(n),H?.(t?.id??"",A,P?void 0:x),j(null),N()},[l,A,t,P,x,M,p,I,H]),N=()=>{y(""),$("development"),R([]),d(!0)},K=a.useCallback(()=>{t&&(g(n=>n.filter(u=>u.id!==t.id)),U?.(t.id),v(null),j(null))},[t,U]),E=n=>{t&&(G?.(t.id,n),j(null))},X=()=>{t&&(g(n=>n.map(u=>u.id===t.id?{...u,isProtected:!0}:u)),V?.(t.id,w),j(null))},o={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"};return e.jsxs("div",{className:`nice-data-branch-manager ${b||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:o.bg,color:o.text,fontFamily:"system-ui, sans-serif",...q},"data-testid":C,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${o.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(c.oa,{name:"database",size:16})," Data Environments"]}),e.jsxs("span",{style:{fontSize:12,color:o.textMuted},children:["Tenant: ",p," • ",T.length," environments"]})]}),!z&&e.jsx("button",{onClick:()=>{v(T.find(n=>n.isDefault)?.id??null),j("clone")},style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"+ New Environment"})]}),e.jsx("div",{style:{padding:16,borderBottom:`1px solid ${o.border}`,display:"flex",alignItems:"center",gap:8,overflowX:"auto"},children:Q.map((n,u)=>{const D=r[n],Y=D.length>0;return e.jsxs(a.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 16px",borderRadius:6,background:Y?B[n]+"20":o.cardBg,border:`2px solid ${Y?B[n]:o.border}`,opacity:Y?1:.5,cursor:Y?"pointer":"default"},onClick:()=>Y&&v(D[0].id),children:[e.jsx("div",{style:{fontSize:18},children:_[n]}),e.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase"},children:n}),Y&&e.jsxs("div",{style:{fontSize:10,color:o.textMuted},children:[D.length," branch",D.length>1?"es":""]})]}),u<Q.length-1&&e.jsx("div",{style:{color:o.textMuted,fontSize:20},children:"→"})]},n)})}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{width:300,borderRight:`1px solid ${o.border}`,overflow:"auto"},children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${o.border}`,fontSize:11,color:o.textMuted},children:"All Environments"}),T.map(n=>e.jsxs("div",{onClick:()=>v(n.id),style:{padding:"12px 16px",borderBottom:`1px solid ${o.border}`,background:O===n.id?o.cardBg:"transparent",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:16},children:_[n.environment]}),e.jsx("span",{style:{fontWeight:500},children:n.displayName}),n.isProtected&&e.jsx("span",{style:{fontSize:12},children:e.jsx(c.oa,{name:"lock",size:12})}),n.isDefault&&e.jsx("span",{style:{padding:"2px 6px",background:B[n.environment],borderRadius:4,fontSize:9,fontWeight:600},children:"DEFAULT"})]}),e.jsxs("div",{style:{fontSize:11,color:o.textMuted,marginTop:4},children:[n.size?.records.toLocaleString()," records •"," ",i(n.size?.bytes??0)]}),e.jsx("div",{style:{fontSize:10,color:o.textMuted,marginTop:2},children:n.lastActivity?.relative})]},n.id))]}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx("span",{style:{fontSize:32},children:_[t.environment]}),e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:20},children:t.displayName}),e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",background:B[t.environment],borderRadius:4,fontSize:10,fontWeight:600,marginTop:4},children:t.environment.toUpperCase()})]})]}),t.description&&e.jsx("p",{style:{color:o.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:i(t.size?.bytes??0)},{label:"Tables",value:t.tables?.length.toString()??"All"},{label:"Status",value:t.status}].map(n=>e.jsxs("div",{style:{padding:12,background:o.cardBg,borderRadius:8,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:600},children:n.value}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:n.label})]},n.label))}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h4",{style:{margin:"0 0 12px 0",fontSize:14},children:"Details"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr",gap:"8px 16px",fontSize:13},children:[e.jsx("span",{style:{color:o.textMuted},children:"Created by"}),e.jsx("span",{children:t.createdBy.name}),e.jsx("span",{style:{color:o.textMuted},children:"Created at"}),e.jsx("span",{children:t.createdAt.date?.toLocaleString()}),e.jsx("span",{style:{color:o.textMuted},children:"Last activity"}),e.jsx("span",{children:t.lastActivity?.relative}),t.upstream&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:o.textMuted},children:"Source"}),e.jsx("span",{children:T.find(n=>n.id===t.upstream)?.displayName??"Unknown"})]}),t.sourceSnapshot&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:o.textMuted},children:"Snapshot"}),e.jsx("span",{children:t.sourceSnapshot})]})]})]}),t.tables&&e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px 0",fontSize:14},children:["Included Tables (",t.tables.length,")"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:t.tables.map(n=>e.jsxs("span",{style:{padding:"4px 10px",background:o.cardBg,borderRadius:4,fontSize:12},children:[e.jsx(c.oa,{name:"database",size:14})," ",n]},n))})]}),!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(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"zap",size:14})," Switch to this environment"]}),e.jsxs("button",{onClick:()=>j("clone"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"clipboard",size:14})," Clone"]}),e.jsxs("button",{onClick:()=>j("sync"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"refresh",size:14})," Sync"]}),!t.isProtected&&e.jsxs("button",{onClick:()=>j("protect"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{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(--color-error, #ef4444)",cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"trash",size:14})," Delete"]})]})]}):e.jsxs("div",{style:{padding:32,textAlign:"center",color:o.textMuted},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:e.jsx(c.oa,{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:n=>n.stopPropagation(),style:{background:o.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(c.oa,{name:"clipboard",size:14})," Clone Environment"]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:o.textMuted},children:"Source Environment"}),e.jsxs("div",{style:{padding:12,background:o.bg,borderRadius:6,display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{children:_[t?.environment??"production"]}),e.jsx("span",{children:t?.displayName??"Production"})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:o.textMuted},children:"Target Environment"}),e.jsx("select",{value:A,onChange:n=>$(n.target.value),style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13},children:Q.filter(n=>se(t?.environment??"production",n)||n==="development"||n==="testing").map(n=>e.jsxs("option",{value:n,children:[_[n]," ",n.charAt(0).toUpperCase()+n.slice(1)]},n))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:o.textMuted},children:"Environment Name"}),e.jsx("input",{type:"text",value:l,onChange:n=>y(n.target.value),placeholder:`${A}-${new Date().toISOString().split("T")[0]}`,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:13}})]}),e.jsx("div",{style:{marginBottom:16},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:n=>d(n.target.checked)}),e.jsx("span",{style:{fontSize:13},children:"Include all tables"})]})}),!P&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",marginBottom:6,fontSize:12,color:o.textMuted},children:["Select Tables (",x.length," selected)"]}),e.jsx("div",{style:{maxHeight:200,overflow:"auto",border:`1px solid ${o.border}`,borderRadius:6},children:S.map(n=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:`1px solid ${o.border}`,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.includes(n.name),onChange:u=>{u.target.checked?R(D=>[...D,n.name]):R(D=>D.filter(Y=>Y!==n.name))}}),e.jsx("span",{style:{flex:1,fontSize:13},children:n.displayName}),e.jsxs("span",{style:{fontSize:11,color:o.textMuted},children:[n.recordCount.toLocaleString()," rows"]})]},n.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 ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:h,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Clone Environment"})]})]})}),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:n=>n.stopPropagation(),style:{background:o.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(c.oa,{name:"refresh",size:14})," Sync Environment"]}),e.jsxs("p",{style:{color:o.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 ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:24,marginBottom:8},children:e.jsx(c.oa,{name:"arrow-down",size:24})}),e.jsx("div",{style:{fontWeight:500},children:"Pull"}),e.jsx("div",{style:{fontSize:11,color:o.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 ${o.border}`,background:"transparent",color:t.environment==="production"?o.textMuted:o.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(c.oa,{name:"arrow-up",size:24})}),e.jsx("div",{style:{fontWeight:500},children:"Push"}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:"Send changes to source"})]})]}),e.jsx("button",{onClick:()=>j(null),style:{width:"100%",padding:"8px 16px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.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:n=>n.stopPropagation(),style:{background:o.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0",color:"var(--color-error, #ef4444)"},children:[e.jsx(c.oa,{name:"trash",size:14})," Delete Environment"]}),e.jsxs("p",{style:{color:o.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(c.oa,{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 ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:K,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-error, #ef4444)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Delete Environment"})]})]})}),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:n=>n.stopPropagation(),style:{background:o.cardBg,borderRadius:12,padding:24,width:450},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(c.oa,{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:n=>F(u=>({...u,requireApproval:n.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:o.textMuted},children:"Minimum approvers"}),e.jsx("input",{type:"number",min:1,max:5,value:w.approversCount,onChange:n=>F(u=>({...u,approversCount:parseInt(n.target.value)||1})),style:{width:80,padding:6,borderRadius:4,border:`1px solid ${o.border}`,background:o.bg,color:o.text}})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:w.requireBackup,onChange:n=>F(u=>({...u,requireBackup:n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Require backup before changes"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!w.allowDirectChanges,onChange:n=>F(u=>({...u,allowDirectChanges:!n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Block direct changes (require merge)"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>j(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:X,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-warning, #f59e0b)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Apply Protection"})]})]})})]})},ye=Object.freeze(Object.defineProperty({__proto__:null,NiceDataBranchManager:oe},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"}]}],ie=({sourceBranch:p,targetBranch:f,branches:M=[],diffItems:S=fe,onCompare:z,onExport:I,onSelectRecord:U,className:W,style:H,"data-testid":G})=>{const[V,m]=a.useState("summary"),[b,q]=a.useState("all"),[C,T]=a.useState(null),[g,O]=a.useState(null),[v,L]=a.useState(""),[j,A]=a.useState(!1),[$,l]=a.useState(p?.id??""),[y,x]=a.useState(f?.id??""),R=a.useMemo(()=>S.reduce((r,i)=>({tables:r.tables+1,added:r.added+i.added,modified:r.modified+i.modified,deleted:r.deleted+i.deleted}),{tables:0,added:0,modified:0,deleted:0}),[S]),P=a.useMemo(()=>S.filter(r=>{if(b==="added"&&r.added===0||b==="modified"&&r.modified===0||b==="deleted"&&r.deleted===0)return!1;if(v){const i=v.toLowerCase();return r.table.toLowerCase().includes(i)||r.displayName.toLowerCase().includes(i)||r.module?.toLowerCase().includes(i)}return!0}).sort((r,i)=>i.added+i.modified+i.deleted-(r.added+r.modified+r.deleted)),[S,b,v]),d=a.useMemo(()=>S.find(r=>r.table===C),[S,C]),w=a.useMemo(()=>d?d.records.filter(r=>b==="all"?!0:r.changeType===b):[],[d,b]),F=a.useCallback(()=>{$&&y&&z?.($,y)},[$,y,z]),k=r=>{switch(r){case"added":return"var(--color-success, #22c55e)";case"modified":return"var(--color-warning, #f59e0b)";case"deleted":return"var(--color-error, #ef4444)";default:return"var(--text-muted, #888)"}},s=r=>{switch(r){case"added":return"+";case"modified":return"~";case"deleted":return"-";default:return" "}},t={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"};return e.jsxs("div",{className:`nice-data-diff-viewer ${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(c.oa,{name:"bar-chart",size:16})," Data Diff Viewer"]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("select",{value:$,onChange:r=>l(r.target.value),style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Select source..."}),M.map(r=>e.jsxs("option",{value:r.id,children:[_[r.environment]," ",r.displayName]},r.id))]}),e.jsx("span",{style:{color:t.textMuted},children:"→"}),e.jsxs("select",{value:y,onChange:r=>x(r.target.value),style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Select target..."}),M.map(r=>e.jsxs("option",{value:r.id,children:[_[r.environment]," ",r.displayName]},r.id))]}),e.jsx("button",{onClick:F,disabled:!$||!y,style:{padding:"6px 12px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:$&&y?"pointer":"not-allowed",fontSize:12,opacity:$&&y?1:.5},children:"Compare"})]}),e.jsx("div",{style:{flex:1}}),e.jsxs("select",{onChange:r=>{r.target.value&&(I?.(r.target.value),r.target.value="")},style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Export..."}),e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"csv",children:"CSV"}),e.jsx("option",{value:"sql",children:"SQL Script"})]})]}),e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:t.textMuted,fontSize:12},children:"Tables:"}),e.jsx("span",{style:{fontWeight:600},children: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(r=>e.jsx("button",{onClick:()=>q(r),style:{padding:"4px 12px",borderRadius:4,border:"none",background:b===r?"var(--color-primary, #3b82f6)":t.cardBg,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:r},r))}),e.jsx("input",{type:"text",value:v,onChange:r=>L(r.target.value),placeholder:"Search tables...",style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12,width:180}})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{width:280,borderRight:`1px solid ${t.border}`,overflow:"auto"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,fontSize:11,color:t.textMuted},children:["Tables (",P.length,")"]}),P.map(r=>e.jsxs("div",{onClick:()=>{T(r.table),O(null),m("table")},style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,background:C===r.table?t.cardBg:"transparent",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontSize:14},children:e.jsx(c.oa,{name:"database",size:14})}),e.jsx("span",{style:{fontWeight:500,fontSize:13},children:r.displayName})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:11},children:[r.added>0&&e.jsxs("span",{style:{color:k("added")},children:["+",r.added]}),r.modified>0&&e.jsxs("span",{style:{color:k("modified")},children:["~",r.modified]}),r.deleted>0&&e.jsxs("span",{style:{color:k("deleted")},children:["-",r.deleted]})]}),r.module&&e.jsx("div",{style:{fontSize:10,color:t.textMuted,marginTop:4},children:r.module})]},r.table))]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[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(c.oa,{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(r=>e.jsxs("tr",{onClick:()=>{O(r),m("record")},style:{cursor:"pointer",background:g?.id===r.id?t.cardBg:"transparent"},children:[e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:4,background:k(r.changeType)+"30",color:k(r.changeType),fontWeight:600,fontSize:14},children:s(r.changeType)})}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace"},children:r.id}),e.jsxs("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:[r.fields.length," field",r.fields.length!==1?"s":""]}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:r.changedBy??"-"}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:r.changedAt?.toLocaleString()??"-"})]},r.id))})]})})]}),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(([r,i])=>e.jsxs("span",{style:{marginRight:16},children:[e.jsxs("span",{style:{color:t.textMuted},children:[r,":"]})," ",String(i)]},r))})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:16},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:t.cardBg},children:[e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`,width:30}}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Field"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Type"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Source Value"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Target Value"})]})}),e.jsx("tbody",{children:g.fields.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`},children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:4,background:k(r.changeType)+"30",color:k(r.changeType),fontWeight:600,fontSize:12},children:s(r.changeType)})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontWeight:500},children:r.field}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:r.fieldType}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace",background:r.changeType==="deleted"?"var(--nice-danger-tint-15, #ef444420)":"transparent"},children:r.oldValue!==void 0?String(r.oldValue):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:"null"})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace",background:r.changeType==="added"?"var(--nice-success-tint-12, #22c55e20)":r.changeType==="modified"?"var(--nice-warning-tint-15, #f59e0b20)":"transparent"},children:r.newValue!==void 0?String(r.newValue):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:"null"})})]},r.field))})]}),e.jsxs("div",{style:{marginTop:24,padding:16,background:t.cardBg,borderRadius:8},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:8},children:"Change Metadata"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr",gap:"8px 16px",fontSize:12},children:[e.jsx("span",{style:{color:t.textMuted},children:"Changed by"}),e.jsx("span",{children: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:ie},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:I,onSelectBranch:U,onCompare:W,onRestore:H,className:G,style:V,"data-testid":m})=>{const[b,q]=a.useState("graph"),[C,T]=a.useState(null),[g,O]=a.useState(null),[v,L]=a.useState(null),j=S??b,A=M??C,$=a.useRef(null),l=a.useMemo(()=>[...f].sort((s,t)=>t.timestamp.getTime()-s.timestamp.getTime()),[f]),y=a.useMemo(()=>{const s={};return Q.forEach((t,r)=>{s[t]=r}),f.reduce((t,r)=>(t[r.id]=s[r.environment]??0,t),{})},[f]),x=a.useMemo(()=>f.find(s=>s.id===A),[f,A]),R=a.useCallback(s=>{g?(W?.(g,s),O(null)):(T(s),I?.(s))},[g,W,I]),P=s=>{const r=new Date().getTime()-s.getTime(),i=Math.floor(r/(1e3*60*60*24));return i===0?"Today":i===1?"Yesterday":i<7?`${i} days ago`:i<30?`${Math.floor(i/7)} weeks ago`:`${Math.floor(i/30)} months ago`},d={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"},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(c.oa,{name:"bar-chart",size:16})," Data History"]}),e.jsx("div",{style:{display:"flex",gap:4},children:["graph","timeline","list"].map(s=>e.jsxs("button",{onClick:()=>q(s),style:{padding:"4px 12px",borderRadius:4,border:"none",background:j===s?"var(--color-primary, #3b82f6)":d.cardBg,color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:[e.jsx(c.oa,{name:s==="graph"?"box":s==="timeline"?"calendar":"clipboard",size:14})," ",s]},s))}),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(s=>s.id===g)?.shortId]}),e.jsx("button",{onClick:()=>O(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:[l.length," snapshots"]})]}),z&&j==="graph"&&e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${d.border}`,background:d.cardBg},children:[Q.map(s=>e.jsxs("div",{style:{width:w,padding:"8px 12px",textAlign:"center",borderRight:`1px solid ${d.border}`},children:[e.jsx("span",{style:{fontSize:16},children:_[s]}),e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:B[s]},children:s})]},s)),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:$,style:{flex:1,overflow:"auto"},children:e.jsxs("div",{style:{position:"relative",minHeight:l.length*k},children:[e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:w*Q.length,height:l.length*k,pointerEvents:"none"},children:l.map((s,t)=>{const r=t*k+k/2,i=y[s.id]*w+w/2;return s.parents.map(h=>{const N=l.findIndex(n=>n.id===h);if(N===-1)return null;const K=N*k+k/2,E=y[h]*w+w/2,X=s.isMerge&&s.parents.indexOf(h)>0,o=i===E?`M ${i} ${r} L ${E} ${K}`:`M ${i} ${r} C ${i} ${(r+K)/2}, ${E} ${(r+K)/2}, ${E} ${K}`;return e.jsx("path",{d:o,fill:"none",stroke:X?"var(--color-accent, #8b5cf6)":B[s.environment],strokeWidth:2,strokeDasharray:X?"4,4":void 0,opacity:.6},`${s.id}-${h}`)})})}),l.map((s,t)=>{const r=t*k+k/2,i=y[s.id]*w+w/2,h=s.id===A,N=s.id===v,K=s.id===g;return e.jsxs(a.Fragment,{children:[e.jsx("div",{onClick:()=>R(s.id),onMouseEnter:()=>L(s.id),onMouseLeave:()=>L(null),style:{position:"absolute",left:i-F,top:r-F,width:F*2,height:F*2,borderRadius:s.isMerge?4:"50%",background:h||K?"var(--bg-primary, #fff)":B[s.environment],border:`3px solid ${B[s.environment]}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,color:h||K?"var(--text-primary, #000)":"var(--bg-primary, #fff)",zIndex:N?10:1,transform:N?"scale(1.2)":"scale(1)",transition:"transform 0.1s",boxShadow:h?"0 0 0 3px rgba(59, 130, 246, 0.5)":"none"},children:s.isSnapshot?e.jsx(c.oa,{name:"camera",size:12}):s.isMerge?e.jsx(c.oa,{name:"shuffle",size:12}):null}),e.jsxs("div",{style:{position:"absolute",left:w*Q.length+16,top:r-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[s.environment]}`:"none"},children:[e.jsx("span",{style:{fontFamily:"monospace",fontSize:11,color:B[s.environment]},children:s.shortId}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s.message}),s.tags?.map(E=>e.jsxs("span",{style:{padding:"2px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--color-warning, #f59e0b)",borderRadius:4,fontSize:9},children:[e.jsx(c.oa,{name:"tag",size:12})," ",E]},E)),e.jsx("span",{style:{fontSize:10,color:d.textMuted,whiteSpace:"nowrap"},children:P(s.timestamp)})]})]},s.id)})]})}),j==="timeline"&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:l.map((s,t)=>{const r=s.id===A,i=l[t-1],h=!i||s.timestamp.toDateString()!==i.timestamp.toDateString();return e.jsxs(a.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:s.timestamp.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}),e.jsxs("div",{onClick:()=>R(s.id),style:{display:"flex",gap:12,padding:12,marginBottom:8,background:r?d.cardBg:"transparent",borderRadius:8,cursor:"pointer",border:`1px solid ${r?B[s.environment]:"transparent"}`},children:[e.jsx("div",{style:{width:60,textAlign:"right",fontSize:11,color:d.textMuted},children:s.timestamp.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}),e.jsxs("div",{style:{width:80,padding:"4px 8px",background:B[s.environment]+"30",color:B[s.environment],borderRadius:4,fontSize:10,textAlign:"center",fontWeight:600,textTransform:"uppercase"},children:[_[s.environment]," ",s.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:s.shortId}),s.isSnapshot&&e.jsx("span",{style:{fontSize:12},children:e.jsx(c.oa,{name:"camera",size:12})}),s.isMerge&&e.jsx("span",{style:{fontSize:12},children:e.jsx(c.oa,{name:"shuffle",size:12})}),s.tags?.map(N=>e.jsx("span",{style:{padding:"1px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--color-warning, #f59e0b)",borderRadius:3,fontSize:9},children:N},N))]}),e.jsx("div",{style:{fontSize:13,marginTop:4},children:s.message}),e.jsxs("div",{style:{fontSize:11,color:d.textMuted,marginTop:4},children:["by ",s.author.name," •"," ",e.jsxs("span",{style:{color:"var(--color-success, #22c55e)"},children:["+",s.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["~",s.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--color-error, #ef4444)"},children:["-",s.stats.recordsDeleted]})]})]})]})]},s.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:l.map(s=>e.jsxs("tr",{onClick:()=>R(s.id),style:{cursor:"pointer",background:s.id===A?d.cardBg:"transparent"},children:[e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,fontFamily:"monospace"},children:[s.shortId,s.isSnapshot&&e.jsxs(e.Fragment,{children:[" ",e.jsx(c.oa,{name:"camera",size:12})]}),s.isMerge&&e.jsxs(e.Fragment,{children:[" ",e.jsx(c.oa,{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[s.environment]+"30",color:B[s.environment],borderRadius:4,fontSize:10,fontWeight:600},children:s.environment})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`},children:s.message}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,color:d.textMuted},children:s.author.name}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,color:d.textMuted},children:s.timestamp.toLocaleString()}),e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,textAlign:"right"},children:[e.jsxs("span",{style:{color:"var(--color-success, #22c55e)"},children:["+",s.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["~",s.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--color-error, #ef4444)"},children:["-",s.stats.recordsDeleted]})]})]},s.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(c.oa,{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(s=>e.jsxs("span",{style:{padding:"2px 8px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--color-warning, #f59e0b)",borderRadius:4,fontSize:11},children:[e.jsx(c.oa,{name:"tag",size:12})," ",s]},s))})]}),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(--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(--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(--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(s=>f.find(t=>t.id===s)?.shortId??s).join(", ")})]})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("button",{onClick:()=>O(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(c.oa,{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(--color-warning, #f59e0b)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500},children:[e.jsx(c.oa,{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:I,tutorial:U,className:W,style:H,"data-testid":G})=>{const[V,m]=a.useState("select"),[b,q]=a.useState(f??""),[C,T]=a.useState(M??""),[g,O]=a.useState(null),[v,L]=a.useState([]),[j,A]=a.useState("keep-source"),[$,l]=a.useState(!0),[y,x]=a.useState(!1),[R,P]=a.useState(null),[d,w]=a.useState({}),[F,k]=a.useState(!1),s=a.useMemo(()=>p.find(n=>n.id===b),[p,b]),t=a.useMemo(()=>p.find(n=>n.id===C),[p,C]),r=a.useMemo(()=>s?p.filter(n=>n.id!==b&&(se(s.environment,n.environment)||n.environment==="development"||n.environment==="testing")):p,[p,b,s]),i=a.useMemo(()=>g?g.tables.filter(u=>v.includes(u.table)).reduce((u,D)=>({inserts:u.inserts+D.inserts,updates:u.updates+D.updates,deletes:u.deletes+D.deletes,conflicts:u.conflicts+D.conflicts}),{inserts:0,updates:0,deletes:0,conflicts:0}):{inserts:0,updates:0,deletes:0,conflicts:0},[g,v]),h=a.useMemo(()=>g?g.conflicts.filter(n=>!d[n.id]):[],[g,d]),N=a.useCallback(async()=>{k(!0),S?.(b,C),await new Promise(n=>setTimeout(n,1e3)),O(te),L(te.tables.filter(n=>n.selected).map(n=>n.table)),k(!1),m("preview")},[b,C,S]),K=a.useCallback(()=>{const n={sourceId:b,targetId:C,strategy:j,tables:v,createBackup:$,dryRun:y,scheduledAt:R??void 0,conflictResolutions:Object.entries(d).reduce((u,[D,Y])=>({...u,[D]:{conflictId:D,strategy:Y}}),{})};z?.(n)},[b,C,j,v,$,y,R,d,z]),E=(n,u)=>{w(D=>({...D,[n]:u}))},X=n=>{if(!g)return;const u={};g.conflicts.forEach(D=>{u[D.id]=n}),w(u)},o={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)"};return e.jsxs("div",{className:`nice-data-merge-builder ${W||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:o.bg,color:o.text,fontFamily:"system-ui, sans-serif",...H},"data-testid":G,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${o.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(c.oa,{name:"shuffle",size:16})," Data Merge"]}),e.jsx("div",{style:{display:"flex",gap:8,marginLeft:"auto"},children:["select","preview","conflicts","options","confirm"].map((n,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:V===n?"var(--color-primary, #3b82f6)":["select","preview","conflicts","options","confirm"].indexOf(V)>u?"var(--color-success, #22c55e)":o.cardBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:600},children:["select","preview","conflicts","options","confirm"].indexOf(V)>u?e.jsx(c.oa,{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(--color-success, #22c55e)":o.border}})]},n))}),e.jsx(c.Yl,{steps:c.Jl(U,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:o.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:o.textMuted},children:"Source Environment"}),e.jsxs("select",{value:b,onChange:n=>{q(n.target.value),T("")},style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${o.border}`,background:o.cardBg,color:o.text,fontSize:14},children:[e.jsx("option",{value:"",children:"Select source..."}),p.map(n=>e.jsxs("option",{value:n.id,children:[_[n.environment]," ",n.displayName]},n.id))]}),s&&e.jsxs("div",{style:{marginTop:12,padding:12,background:B[s.environment]+"20",borderRadius:8,border:`1px solid ${B[s.environment]}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:20},children:_[s.environment]}),e.jsx("span",{style:{fontWeight:600},children:s.displayName})]}),e.jsxs("div",{style:{fontSize:11,color:o.textMuted,marginTop:4},children:[s.size?.records.toLocaleString()," records"]})]})]}),e.jsx("div",{style:{fontSize:24,color:o.textMuted},children:"→"}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:o.textMuted},children:"Target Environment"}),e.jsxs("select",{value:C,onChange:n=>T(n.target.value),disabled:!b,style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${o.border}`,background:o.cardBg,color:o.text,fontSize:14,opacity:b?1:.5},children:[e.jsx("option",{value:"",children:"Select target..."}),r.map(n=>e.jsxs("option",{value:n.id,children:[_[n.environment]," ",n.displayName]},n.id))]}),t&&e.jsxs("div",{style:{marginTop:12,padding:12,background:B[t.environment]+"20",borderRadius:8,border:`1px solid ${B[t.environment]}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:20},children:_[t.environment]}),e.jsx("span",{style:{fontWeight:600},children:t.displayName}),t.isProtected&&e.jsx("span",{children:e.jsx(c.oa,{name:"lock",size:16})})]}),e.jsxs("div",{style:{fontSize:11,color:o.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:I,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:N,disabled:!b||!C||F,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-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(c.oa,{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 ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Preview Changes"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:24},children:[e.jsxs("div",{style:{padding:16,background:"var(--nice-success-tint-12, #22c55e20)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-success, #22c55e)"},children:["+",i.inserts]}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:"Inserts"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-warning-tint-15, #f59e0b20)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-warning, #f59e0b)"},children:["~",i.updates]}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:"Updates"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-danger-tint-15, #ef444420)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-error, #ef4444)"},children:["-",i.deletes]}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:"Deletes"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-accent-tint-12, #8b5cf620)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--color-accent, #8b5cf6)"},children:[e.jsx(c.oa,{name:"warning",size:14})," ",i.conflicts]}),e.jsx("div",{style:{fontSize:11,color:o.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:o.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(n=>n.table)),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:11},children:"Select All"}),e.jsx("button",{onClick:()=>L([]),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:11},children:"Clear"})]})]}),e.jsx("div",{style:{border:`1px solid ${o.border}`,borderRadius:8,overflow:"hidden"},children:g.tables.map(n=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:`1px solid ${o.border}`,cursor:"pointer",background:v.includes(n.table)?o.cardBg:"transparent"},children:[e.jsx("input",{type:"checkbox",checked:v.includes(n.table),onChange:u=>{u.target.checked?L(D=>[...D,n.table]):L(D=>D.filter(Y=>Y!==n.table))}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:n.displayName}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:n.module})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:12},children:[n.inserts>0&&e.jsxs("span",{style:{color:"var(--color-success, #22c55e)"},children:["+",n.inserts]}),n.updates>0&&e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["~",n.updates]}),n.deletes>0&&e.jsxs("span",{style:{color:"var(--color-error, #ef4444)"},children:["-",n.deletes]}),n.conflicts>0&&e.jsxs("span",{style:{color:"var(--color-accent, #8b5cf6)"},children:[e.jsx(c.oa,{name:"warning",size:14})," ",n.conflicts]})]})]},n.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 ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m(i.conflicts>0?"conflicts":"options"),disabled:v.length===0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:v.length>0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:v.length>0?1:.5},children:i.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 ${o.border}`,background:"transparent",color:o.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:o.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 ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:"Keep Source"}),e.jsx("button",{onClick:()=>X("keep-target"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:"Keep Target"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:g.conflicts.map(n=>{const u=!!d[n.id];return e.jsxs("div",{style:{padding:16,background:o.cardBg,borderRadius:8,border:`1px solid ${u?"var(--color-success, #22c55e)":"var(--color-accent, #8b5cf6)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("span",{style:{fontSize:16},children:e.jsx(c.oa,{name:u?"check":"warning",size:16})}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontWeight:500},children:[n.table,".",n.field]}),e.jsxs("div",{style:{fontSize:11,color:o.textMuted},children:["Record: ",n.recordId," • ",n.type.replace("-"," ")]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{style:{padding:12,background:d[n.id]==="keep-source"?"var(--nice-success-tint-12, #22c55e20)":o.bg,borderRadius:6,border:`1px solid ${d[n.id]==="keep-source"?"var(--color-success, #22c55e)":o.border}`,cursor:"pointer"},onClick:()=>E(n.id,"keep-source"),children:[e.jsxs("div",{style:{fontSize:10,color:o.textMuted,marginBottom:4},children:["Source (",s?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(n.sourceValue)})]}),e.jsxs("div",{style:{padding:12,background:d[n.id]==="keep-target"?"var(--nice-success-tint-12, #22c55e20)":o.bg,borderRadius:6,border:`1px solid ${d[n.id]==="keep-target"?"var(--color-success, #22c55e)":o.border}`,cursor:"pointer"},onClick:()=>E(n.id,"keep-target"),children:[e.jsxs("div",{style:{fontSize:10,color:o.textMuted,marginBottom:4},children:["Target (",t?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(n.targetValue)})]})]})]},n.id)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m("preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.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(--color-primary, #3b82f6)",color:"var(--bg-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(i.conflicts>0?"conflicts":"preview"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${o.border}`,background:"transparent",color:o.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:$,onChange:n=>l(n.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Create backup before merge"}),e.jsx("div",{style:{fontSize:11,color:o.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:n=>x(n.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Dry run (preview only)"}),e.jsx("div",{style:{fontSize:11,color:o.textMuted},children:"Simulate merge without applying changes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:o.textMuted},children:"Schedule merge (optional)"}),e.jsx("input",{type:"datetime-local",value:R?.toISOString().slice(0,16)??"",onChange:n=>P(n.target.value?new Date(n.target.value):null),style:{padding:10,borderRadius:6,border:`1px solid ${o.border}`,background:o.cardBg,color:o.text,fontSize:13}})]})]}),e.jsxs("div",{style:{marginTop:32,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m(i.conflicts>0?"conflicts":"preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m("confirm"),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Review & Confirm →"})]})]}),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 ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Confirm Merge"})]}),e.jsxs("div",{style:{padding:20,background:o.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[s?.environment??"development"]+"30",borderRadius:6},children:[_[s?.environment??"development"]," ",s?.displayName]}),e.jsx("span",{children:"→"}),e.jsxs("div",{style:{padding:"8px 12px",background:B[t?.environment??"production"]+"30",borderRadius:6},children:[_[t?.environment??"production"]," ",t?.displayName]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 16px",fontSize:13},children:[e.jsx("span",{style:{color:o.textMuted},children:"Tables"}),e.jsx("span",{children:v.length}),e.jsx("span",{style:{color:o.textMuted},children:"Records affected"}),e.jsx("span",{children:i.inserts+i.updates+i.deletes}),e.jsx("span",{style:{color:o.textMuted},children:"Backup"}),e.jsx("span",{children:$?"Yes":"No"}),e.jsx("span",{style:{color:o.textMuted},children:"Mode"}),e.jsx("span",{children:y?"Dry run":"Apply changes"}),R&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:o.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(c.oa,{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:I,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${o.border}`,background:"transparent",color:o.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:K,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:y?e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"search",size:14})," Run Dry Merge"]}):R?e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"calendar",size:14})," Schedule Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{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(--color-success, #22c55e)",medium:"var(--color-warning, #f59e0b)",high:"var(--nice-warning, #f97316)",critical:"var(--color-error, #ef4444)"},le=({conflicts:p=ze,sourceEnvironment:f="development",targetEnvironment:M="uat",showSuggestions:S=!0,allowCustomValues:z=!0,onResolve:I,onSkip:U,onCancel:W,className:H,style:G,"data-testid":V})=>{const[m,b]=a.useState(0),[q,C]=a.useState({}),[T,g]=a.useState({}),[O,v]=a.useState(null),[L,j]=a.useState(""),[A,$]=a.useState("single"),l=p[m],y=a.useMemo(()=>Object.keys(q).length,[q]),x=a.useMemo(()=>{if(!l)return!1;const r=T[l.id]||{};return l.fields.every(i=>r[i.field]?.resolution)},[l,T]),R=a.useCallback(r=>{if(T[r.id])return;const i={};r.fields.forEach(h=>{i[h.field]={resolution:"source",value:h.sourceValue}}),g(h=>({...h,[r.id]:i}))},[T]);a.useEffect(()=>{l&&R(l)},[l,R]);const P=(r,i,h)=>{if(!l)return;const N=l.fields.find(E=>E.field===r);if(!N)return;const K=i==="source"?N.sourceValue:i==="target"?N.targetValue:h;g(E=>({...E,[l.id]:{...E[l.id],[r]:{resolution:i,value:K}}}))},d=r=>{if(!l)return;const i={};l.fields.forEach(h=>{i[h.field]={resolution:r,value:r==="source"?h.sourceValue:h.targetValue}}),g(h=>({...h,[l.id]:i}))},w=()=>{if(!l||!x)return;const r={conflictId:l.id,strategy:"manual",fieldResolutions:T[l.id]};C(i=>({...i,[l.id]:r})),m<p.length-1&&b(m+1)},F=()=>{l&&(U?.(l.id),m<p.length-1&&b(m+1))},k=()=>{const r=Object.values(q);I?.(r)},s=(r,i)=>r===null?"null":r===void 0?"undefined":i==="date"?new Date(r).toLocaleDateString():i==="number"?Number(r).toLocaleString():typeof r=="boolean"?r?"true":"false":String(r),t={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)",source:B[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(c.oa,{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(c.oa,{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(--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:()=>$("single"),style:{padding:"6px 12px",border:"none",background:A==="single"?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"Single"}),e.jsx("button",{onClick:()=>$("list"),style:{padding:"6px 12px",border:"none",borderLeft:`1px solid ${t.border}`,background:A==="list"?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"List"})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[A==="single"&&l&&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 →"}),q[l.id]&&e.jsxs("span",{style:{marginLeft:"auto",padding:"4px 8px",background:"#22c55e30",color:"var(--color-success, #22c55e)",borderRadius:4,fontSize:11},children:[e.jsx(c.oa,{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(c.oa,{name:J[l.type].icon,size:24})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:600,fontSize:15},children:[l.tableName,":"," ",l.recordLabel??l.recordId]}),e.jsxs("div",{style:{fontSize:12,color:t.textMuted},children:[J[l.type].label," —"," ",J[l.type].description]})]}),e.jsx("div",{style:{padding:"4px 8px",background:Z[l.severity]+"30",color:Z[l.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:l.severity})]}),l.metadata&&e.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`,fontSize:11,color:t.textMuted},children:[l.metadata.sourceModifiedAt&&e.jsxs("span",{children:["Source modified: ",l.metadata.sourceModifiedAt.toLocaleString()," ","by ",l.metadata.sourceModifiedBy]}),l.metadata.targetModifiedAt&&e.jsxs("span",{children:["Target modified: ",l.metadata.targetModifiedAt.toLocaleString()," ","by ",l.metadata.targetModifiedBy]})]}),S&&l.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(c.oa,{name:"lightbulb",size:14})," Suggestion:"]})," ",l.suggestionReason,e.jsx("button",{onClick:()=>d(l.suggestion==="keep-source"?"source":"target"),style:{marginLeft:12,padding:"4px 8px",borderRadius:4,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:11},children:"Apply"})]})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted,lineHeight:"28px"},children:"Apply to all fields:"}),e.jsxs("button",{onClick:()=>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:[_[f]," 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:[_[M]," Keep Target"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:l.fields.map(r=>{const i=T[l.id]?.[r.field],h=O===`${l.id}-${r.field}`;return e.jsxs("div",{style:{background:t.cardBg,borderRadius:8,overflow:"hidden",border:`1px solid ${i?.resolution?"var(--color-success, #22c55e)":t.border}`},children:[e.jsxs("div",{style:{padding:"10px 16px",background:i?.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:i?.resolution?"var(--color-success, #22c55e)":t.textMuted},children:e.jsx(c.oa,{name:i?.resolution?"check":"circle",size:14})}),e.jsx("span",{style:{fontWeight:500},children:r.fieldLabel}),e.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:["(",r.field,")"]}),e.jsx("span",{style:{marginLeft:"auto",fontSize:10,padding:"2px 6px",background:t.bg,borderRadius:4,color:t.textMuted},children:r.dataType})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1,background:t.border},children:[e.jsxs("div",{onClick:()=>P(r.field,"source"),style:{padding:16,background:i?.resolution==="source"?`${t.source}20`:t.bg,cursor:"pointer",border:i?.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:[_[f]," Source",i?.resolution==="source"&&e.jsx("span",{style:{marginLeft:4},children:e.jsx(c.oa,{name:"check",size:14})})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:s(r.sourceValue,r.dataType)})]}),e.jsxs("div",{onClick:()=>P(r.field,"target"),style:{padding:16,background:i?.resolution==="target"?`${t.target}20`:t.bg,cursor:"pointer",border:i?.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:[_[M]," Target",i?.resolution==="target"&&e.jsx("span",{style:{marginLeft:4},children:e.jsx(c.oa,{name:"check",size:14})})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:s(r.targetValue,r.dataType)})]})]}),z&&e.jsxs("div",{style:{padding:12,background:i?.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:N=>j(N.target.value),style:{flex:1,padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontFamily:"monospace",fontSize:13},autoFocus:!0}),e.jsx("button",{onClick:()=>{P(r.field,"custom",L),v(null)},style:{padding:"6px 12px",borderRadius:4,border:"none",background:"var(--color-accent, #8b5cf6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"Apply"}),e.jsx("button",{onClick:()=>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(i?.resolution==="custom"?String(i.value):String(r.sourceValue)),v(`${l.id}-${r.field}`)},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:i?.resolution==="custom"?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:12},children:i?.resolution==="custom"?`Using: ${s(i.value,r.dataType)}`:"Enter custom..."})]})]},r.field)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick: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(--color-success, #22c55e)",color:"var(--bg-primary, #fff)",cursor:x?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:x?1:.5},children:m<p.length-1?"Confirm & Next →":"Confirm"})]})]}),A==="list"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.map((r,i)=>{const h=!!q[r.id];return e.jsxs("div",{onClick:()=>{b(i),$("single")},style:{padding:16,background:t.cardBg,borderRadius:8,cursor:"pointer",border:`1px solid ${h?"var(--color-success, #22c55e)":t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:20},children:e.jsx(c.oa,{name:h?"check":J[r.type].icon,size:14})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[r.tableName,": ",r.recordLabel??r.recordId]}),e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[r.fields.length," fields • ",J[r.type].label]})]}),e.jsx("div",{style:{padding:"4px 8px",background:Z[r.severity]+"30",color:Z[r.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:r.severity})]},r.id)})})]}),e.jsxs("div",{style:{padding:"16px 20px",borderTop:`1px solid ${t.border}`,display:"flex",justifyContent:"space-between"},children:[e.jsx("button",{onClick: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(--color-primary, #3b82f6)",color:"var(--bg-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,I,U]=f;return z==="*"&&I==="*"&&U==="*"?`Daily at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:z==="*"&&I==="*"?`Weekly on ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][parseInt(U)]} at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:I==="*"?`Monthly on day ${z} at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:p},Te={creating:{icon:"clock",color:"var(--color-warning, #f59e0b)",label:"Creating"},ready:{icon:"check",color:"var(--color-success, #22c55e)",label:"Ready"},failed:{icon:"close",color:"var(--color-error, #ef4444)",label:"Failed"},expired:{icon:"clock",color:"var(--text-muted, #888)",label:"Expired"},locked:{icon:"lock",color:"var(--color-primary, #3b82f6)",label:"Locked"}},$e={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:I,onDeleteSnapshot:U,onCompareSnapshots:W,onExportSnapshot:H,onUpdateRetentionPolicy:G,onUpdateSchedules:V,className:m,style:b,"data-testid":q})=>{const[C,T]=a.useState("snapshots"),[g,O]=a.useState(!1),[v,L]=a.useState([]),[j,A]=a.useState(""),[$,l]=a.useState(""),[y,x]=a.useState(M),[R,P]=a.useState(S),d=a.useMemo(()=>{const t=f.filter(i=>i.status==="ready").length,r=f.reduce((i,h)=>i+h.size.bytes,0);return{total:f.length,ready:t,totalSize:r}},[f]),w=()=>{z?.({name:j||`Snapshot ${new Date().toISOString()}`,description:$}),O(!1),A(""),l("")},F=()=>{v.length===2&&W?.(v[0],v[1])},k=t=>{const r=R.map(i=>i.id===t?{...i,enabled:!i.enabled}:i);P(r),V?.(r)},s={bg:"var(--bg-elevated, #1e1e1e)",cardBg:"var(--bg-elevated, #252525)",border:"var(--bg-tertiary, #333)",text:"var(--text-primary, #e0e0e0)",textMuted:"var(--text-muted, #888)",env:B[p]};return e.jsxs("div",{className:`nice-data-snapshot ${m||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...b},"data-testid":q,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(c.oa,{name:"camera",size:16})," Snapshots"]}),e.jsxs("div",{style:{padding:"4px 10px",background:s.env+"30",borderRadius:4,fontSize:12,display:"flex",alignItems:"center",gap:6},children:[_[p]," ",p.charAt(0).toUpperCase()+p.slice(1)]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:16,fontSize:12,color:s.textMuted},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:s.text},children:d.total})," snapshots"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:s.text},children:re(d.totalSize)})," total"]})]}),e.jsxs("button",{onClick:()=>O(!0),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(c.oa,{name:"camera",size:14})," Create Snapshot"]})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${s.border}`,padding:"0 20px"},children:["snapshots","schedules","settings"].map(t=>e.jsxs("button",{onClick:()=>T(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:C===t?s.text:s.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(c.oa,{name:"folder",size:14})," Snapshots"]}),t==="schedules"&&e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"calendar",size:14})," Schedules"]}),t==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{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:s.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 ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"Compare"}),e.jsx("button",{onClick:()=>L([]),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12,marginLeft:"auto"},children:"Clear"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:f.map(t=>{const r=v.includes(t.id),i=Te[t.status],h=$e[t.type];return e.jsx("div",{style:{padding:16,background:s.cardBg,borderRadius:8,border:`1px solid ${r?"var(--color-primary, #3b82f6)":s.border}`},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("input",{type:"checkbox",checked:r,onChange:N=>{N.target.checked?L(K=>[...K,t.id]):L(K=>K.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:i.color+"20",color:i.color,borderRadius:4,fontSize:10},children:[e.jsx(c.oa,{name:i.icon,size:14})," ",i.label]}),e.jsxs("span",{style:{padding:"2px 6px",background:s.bg,color:s.textMuted,borderRadius:4,fontSize:10},children:[e.jsx(c.oa,{name:h.icon,size:14})," ",h.label]})]}),t.description&&e.jsx("div",{style:{fontSize:12,color:s.textMuted,marginBottom:8},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:11,color:s.textMuted},children:[e.jsx("span",{children:ne(t.createdAt)}),e.jsxs("span",{children:["by ",t.createdBy.name]}),e.jsxs("span",{children:[t.size.records.toLocaleString()," records"]}),e.jsx("span",{children:re(t.size.bytes)}),t.tables&&e.jsxs("span",{children:[t.tables.length," tables"]}),t.expiresAt&&e.jsxs("span",{style:{color:"var(--color-warning, #f59e0b)"},children:["Expires: ",t.expiresAt.toLocaleDateString()]})]}),t.tags&&t.tags.length>0&&e.jsx("div",{style:{display:"flex",gap:6,marginTop:8},children:t.tags.map(N=>e.jsxs("span",{style:{padding:"2px 8px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:["#",N]},N))})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[t.status==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>I?.(t.id),title:"Restore","aria-label":"Restore",style:{padding:8,borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:14},children:e.jsx(c.oa,{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 ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:14},children:e.jsx(c.oa,{name:"upload",size:14})})]}),t.status!=="locked"&&e.jsx("button",{onClick:()=>U?.(t.id),title:"Delete","aria-label":"Delete",style:{padding:8,borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:"var(--color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(c.oa,{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:s.cardBg,borderRadius:8,border:`1px solid ${s.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:s.textMuted},children:[Re(t.cron)," • Keep ",t.retainCount," snapshots"]})]}),e.jsxs("div",{style:{textAlign:"right",fontSize:11,color:s.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 ${s.border}`,background:"transparent",color:s.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:s.textMuted},children:"Automatically delete old snapshots based on policy"})]})]}),y.enabled&&e.jsxs("div",{style:{padding:16,background:s.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:s.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 ${s.border}`,background:s.bg,color:s.text,fontSize:13,width:150}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:s.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 ${s.border}`,background:s.bg,color:s.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(--color-primary, #3b82f6)",color:"var(--bg-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:()=>O(!1),children:e.jsxs("div",{style:{background:s.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px"},children:[e.jsx(c.oa,{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:s.textMuted},children:"Snapshot Name"}),e.jsx("input",{type:"text",value:j,onChange:t=>A(t.target.value),placeholder:`Snapshot ${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,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:s.textMuted},children:"Description (optional)"}),e.jsx("textarea",{value:$,onChange:t=>l(t.target.value),placeholder:"What's this snapshot for?",rows:3,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:13,resize:"vertical",boxSizing:"border-box"}})]})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:24,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>O(!1),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:w,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--color-primary, #3b82f6)",color:"var(--bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Create"})]})]})})]})},De=Object.freeze(Object.defineProperty({__proto__:null,NiceDataSnapshot:ce},Symbol.toStringTag,{value:"Module"}));exports.NiceDataBranchGraph=de;exports.NiceDataBranchGraph$1=ve;exports.NiceDataBranchManager=oe;exports.NiceDataBranchManager$1=ye;exports.NiceDataConflictResolver=le;exports.NiceDataConflictResolver$1=Ce;exports.NiceDataDiffViewer=ie;exports.NiceDataDiffViewer$1=me;exports.NiceDataMergeBuilder=ae;exports.NiceDataMergeBuilder$1=ke;exports.NiceDataSnapshot=ce;exports.NiceDataSnapshot$1=De;
|