diff --git a/dist/assets/index.js b/dist/assets/index.js index b2cce91..6430a03 100644 --- a/dist/assets/index.js +++ b/dist/assets/index.js @@ -1,3 +1,3 @@ -import{r as t,u as cs,l as ds,R as Ne,j as e,W as Me,d as Pe,L as qe,I as hs,H as X,T as v,e as H,f as J,M as us,g as fs,h as ms,i as gs,A as _e,k as be,m as Ge,n as pe,o as Ce,p as Se,B as E,D as xs,C as De,F as M,q as Be,s as bs,t as Qe,v as ps,w as Cs,x as ve,S as ws,V as js,y as ze,z as Ss,E as Ye,G as Ke,J as Bs,K as ys,N as ks,O as Ds,P as vs,Q as Oe,U as C,X as Fs,Y as Is,Z as ye,_ as P,$ as Fe,a0 as ae,a1 as oe,a2 as re,a3 as se,a4 as Rs,a5 as Je,a6 as te,a7 as Ts,a8 as Ns,a9 as Ms,aa as Ue,ab as we,ac as As,ad as je,ae as ie,af as Ie,ag as Re,ah as Ls,ai as Vs,aj as Xe,ak as Es,al as Ps,am as zs,an as Os,ao as Ze,ap as es,aq as ge,ar as ss,as as xe,at as Us,au as Te,av as Ws,aw as Hs,ax as $s,ay as qs,az as _s,aA as Gs,aB as Qs,aC as Ys,aD as Ks,aE as Js,aF as Xs,aG as Zs,aH as et}from"./vendor.js";import{_ as G}from"./lodash.js";import{A as de}from"./ag-grid-react.js";import"./ag-grid-community.js";(function(){const o=document.createElement("link").relList;if(o&&o.supports&&o.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))n(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&n(l)}).observe(document,{childList:!0,subtree:!0});function a(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(r){if(r.ep)return;r.ep=!0;const i=a(r);fetch(r.href,i)}})();const st="/assets/Titan.png";function ce(s=[]){return(Array.isArray(s)?s:[s]).map(a=>(delete a["Branch Info"],a))}function ke(s,o,a){return`${s==""?"Uncategorised":s} ${o==""?"Unversioned":o} ${String(a).split("\\").at(-1)}`}function tt(s){return String(s).split("\\").at(-1)}const nt="http://localhost:4000",lt="40px";function me(s,o="info",a=3e3,n=!1){return{position:"top",variant:"solid",title:n?"Server Notification":"Client Notification",description:s,status:o,duration:a,isClosable:!0}}const ts=t.createContext({socket:null,toast:null,config:null,updateConfig:s=>{},isDebug:!1,setIsDebug:s=>{},configurableRowData:[],setConfigurableRowData:s=>{},branchInfos:{},setBranchInfos:s=>{},branchTableGridRef:null,selectedBranches:[],setSelectedBranches:s=>{},showSelectedBranchesLog:!1,setShowSelectedBranchesLog:s=>{},isCommitMode:!1,setIsCommitMode:s=>{},selectedBranchStatuses:[],setSelectedBranchStatuses:s=>{},localChangesGridRef:null,untrackedChangesGridRef:null,showCommitView:!1,setShowCommitView:s=>{},sourceBranch:null,setSourceBranch:s=>{},branchOptions:[],issueNumber:{},setIssueNumber:s=>{},commitMessage:"",setCommitMessage:s=>{},selectedLocalChanges:[],setSelectedLocalChanges:s=>{},selectedUntrackedChanges:[],setSelectedUntrackedChanges:s=>{},socketPayload:null,setSocketPayload:s=>{},postCommitData:{},setPostCommitData:s=>{},logData:[],setLogData:s=>{}}),L=()=>t.useContext(ts),at=({children:s})=>{const[o,a]=t.useState(null),[n,r]=t.useState(null),i=cs(),[l,d]=t.useState(()=>localStorage.getItem("isDebug")==="true");t.useEffect(()=>{const x=ds(nt);return r(x),x.on("connect",()=>{x.emit("titan-config-get","fetch"),x.once("titan-config-get",V=>{a(V),i(me("Configurations Loaded","success",2e3))})}),x.on("notification",V=>{i(me(V.description,V.status,V.duration,!0))}),x.on("disconnect",()=>{i(me("Server Has Been Disconnected","warning",0,!0))}),x.on("reconnect",()=>{i(me("Server Has Been Reconnected","success",2e3,!0))}),()=>{x.disconnect()}},[]),t.useEffect(()=>{localStorage.setItem("isDebug",String(l))},[l]);const u=t.useCallback(x=>{x!=null&&(console.debug("Saving config:",x),n==null||n.emit("titan-config-set",x))},[n]),c=t.useCallback(x=>{a(V=>{const _=x(V);return G.isEqual(V,_)?V:(u(_),_)})},[a,u]),[h,g]=t.useState([]),[w,F]=t.useState({}),k=t.useRef(null),[b,p]=t.useState([]),[y,j]=t.useState(!1),[m,S]=t.useState(!1),[D,A]=t.useState([]),z=t.useRef(null),T=t.useRef(null),[N,U]=t.useState(!1),[$,I]=t.useState(null),O=t.useMemo(()=>h.filter(x=>x["Branch Folder"]&&x["Branch Version"]&&x["SVN Branch"]&&x["Branch Folder"]!==""&&x["Branch Version"]!==""&&x["SVN Branch"]!=="").map(x=>({value:x.id,label:ke(x["Branch Folder"],x["Branch Version"],x["SVN Branch"])})),[o,b,h]),[W,Y]=t.useState({}),[K,Z]=t.useState(""),[ee,ue]=t.useState([]),[B,f]=t.useState([]),[R,Q]=t.useState(null),[fe,Ve]=t.useState({}),[le,q]=Ne.useState([]);return t.useEffect(()=>{A([]),U(!1)},[h]),t.useEffect(()=>{if(!m||!N)return;const x=setTimeout(()=>{var V;(V=document.getElementById("sectionCommit"))==null||V.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},100);return()=>clearTimeout(x)},[m,N]),t.useEffect(()=>{if(b.length<1||N){b.length<1&&S(!1);return}A([]),Q(null),ce(b).forEach(x=>{console.debug("Emitting svn-status-single for branch:",x),n==null||n.emit("svn-status-single",{selectedBranch:x})})},[n,b,N]),t.useEffect(()=>{const x=()=>{U(!1)};return n==null||n.on("branch-refresh-unseen",x),()=>n==null?void 0:n.off("branch-refresh-unseen",x)},[n]),t.useEffect(()=>{const x=V=>{l&&console.debug("Received branch status data:",V),A(_=>[..._,V])};return n==null||n.on("branch-status-single",x),()=>n==null?void 0:n.off("branch-status-single",x)},[n]),t.useEffect(()=>{q([])},[b]),t.useEffect(()=>{le.length===0&&n&&p(x=>(x.length>0&&n.emit("svn-log-selected",{selectedBranches:b}),x))},[le,n]),t.useEffect(()=>{const x=V=>{console.debug("Received svn-log-result from socket in SectionBranchLog component in background"),q(_=>_.some(is=>is.id===V.id)?_:[..._,V])};return n==null||n.on("svn-log-result",x),()=>n==null?void 0:n.off("svn-log-result",x)},[n]),e.jsx(ts.Provider,{value:{socket:n,toast:i,config:o,updateConfig:c,isDebug:l,setIsDebug:d,configurableRowData:h,setConfigurableRowData:g,branchInfos:w,setBranchInfos:F,branchTableGridRef:k,selectedBranches:b,setSelectedBranches:p,showSelectedBranchesLog:y,setShowSelectedBranchesLog:j,isCommitMode:m,setIsCommitMode:S,selectedBranchStatuses:D,setSelectedBranchStatuses:A,localChangesGridRef:z,untrackedChangesGridRef:T,showCommitView:N,setShowCommitView:U,sourceBranch:$,setSourceBranch:I,branchOptions:O,issueNumber:W,setIssueNumber:Y,commitMessage:K,setCommitMessage:Z,selectedLocalChanges:ee,setSelectedLocalChanges:ue,selectedUntrackedChanges:B,setSelectedUntrackedChanges:f,socketPayload:R,setSocketPayload:Q,postCommitData:fe,setPostCommitData:Ve,logData:le,setLogData:q},children:s})};function he(){const{socket:s}=L(),o=t.useCallback(()=>{s==null||s.emit("titan-config-open",{})},[s]),a=t.useCallback((c,h,g,w)=>{s==null||s.emit("svn-update-single",{id:c,branch:h,version:g,folder:w})},[s]),n=t.useCallback((c,h,g,w)=>{s==null||s.emit("svn-info-single",{id:c,branch:h,version:g,folder:w})},[s]),r=t.useCallback(c=>{s==null||s.emit("svn-commit",c)},[s]),i=t.useCallback(c=>{s==null||s.emit("svn-files-revert",{filesToProcess:c})},[s]),l=t.useCallback(c=>{s==null||s.emit("svn-files-add-remove",{filesToProcess:c})},[s]),d=t.useCallback((c,h,g,w=null)=>{s==null||s.emit("trello-search-names-card",{key:c,token:h,query:g,limit:w})},[s]),u=t.useCallback((c,h,g,w)=>{s==null||s.emit("trello-update-card",{key:c,token:h,trelloData:g,commitResponses:w})},[s]);return{emitOpenConfig:o,emitUpdateSingle:a,emitInfoSingle:n,emitCommitPayload:r,emitFilesRevert:i,emitFilesAddRemove:l,emitTrelloCardNamesSearch:d,emitTrelloCardUpdate:u}}function ne(){const{toast:s}=L(),o=t.useCallback((a="",n="info",r=3e3,i=null)=>{const l=me(a,n,r);if(s)return s(l);if(i)return i(l)},[s]);return{toast:s,RaiseClientNotificaiton:o}}function ot(){const{config:s,isDebug:o,setIsDebug:a}=L(),{emitOpenConfig:n}=he(),{RaiseClientNotificaiton:r}=ne(),i=t.useCallback(()=>{window.electron.checkForUpdates().then(d=>{console.debug("Check for updates result: ",d)}),window.electron.on("update-not-available",()=>{r("Titan is up to date","info",3e3),window.electron.removeAllListeners("update-not-available")})},[r]),l=t.useCallback(()=>{window.electron&&window.electron.getAppVersion().then(d=>{r(`Application Version: v${d}`,"info",2e3)})},[r]);return e.jsxs(Me,{my:5,spacingY:5,justify:"space-between",children:[e.jsxs(Pe,{alignItems:"center",children:[e.jsx(qe,{onClick:l,children:e.jsx(hs,{src:st,alt:"Titan Logo",boxSize:"100px",mr:5,borderRadius:"full"})}),e.jsx(X,{as:"h2",size:"2xl",noOfLines:1,className:"animation-fadein-forward",children:"Welcome back"}),e.jsx(X,{as:"h2",size:"2xl",noOfLines:1,p:2,className:"animation-handwave",children:"👋"})]}),e.jsxs(Pe,{alignItems:"center",columnGap:2,children:[e.jsx(v,{label:`Current Debug Mode: ${o?"on":"off"}`,hasArrow:!0,placement:"left",children:e.jsx(H,{"aria-label":"Toggle Debug Mode",colorScheme:"yellow",icon:o?e.jsx(J,{as:fs}):e.jsx(J,{as:us}),onClick:()=>a(d=>!d)})}),e.jsx(v,{label:"Open configuration file",hasArrow:!0,placement:"bottom-start",children:e.jsx(H,{"aria-label":"Open configuration file",colorScheme:"yellow",icon:e.jsx(J,{as:ms}),onClick:()=>n()})}),e.jsx(v,{label:"Check for updates",hasArrow:!0,placement:"bottom-start",isDisabled:!window.electron,children:e.jsx(H,{"aria-label":"Check for updates",colorScheme:"yellow",icon:e.jsx(J,{as:gs}),onClick:i,isDisabled:!window.electron})})]})]})}function rt({isAlertOpen:s,onCloseAlert:o,cancelRef:a,removeSelectedRows:n}){return e.jsx(_e,{isOpen:s,leastDestructiveRef:a,onClose:o,children:e.jsx(be,{children:e.jsxs(Ge,{children:[e.jsx(pe,{fontSize:"lg",fontWeight:"bold",children:"Delete Selected Rows"}),e.jsx(Ce,{children:"Are you sure you want to delete the selected rows? This action cannot be undone."}),e.jsxs(Se,{children:[e.jsx(E,{ref:a,onClick:o,children:"Cancel"}),e.jsx(E,{colorScheme:"red",onClick:n,ml:3,children:"Delete"})]})]})})})}function We(){const{innerWidth:s,innerHeight:o}=window;return{width:s,height:o}}function it(){const[s,o]=t.useState(We());return t.useEffect(()=>{function a(){o(We())}return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),s}function ct({rowData:s,onRowValueChanged:o}){const{config:a,branchTableGridRef:n,updateConfig:r,isDebug:i,selectedBranches:l,setSelectedBranches:d,setSelectedBranchStatuses:u,setShowCommitView:c}=L(),h=it(),[g,w]=t.useState(h.height>768),F=t.useCallback(m=>{const S={...m,id:String(Date.now()),"Branch Info":"Hasn't been refreshed"};r(D=>({...D,branches:ce([...D.branches,S])}))},[r]),k=t.useCallback(m=>{var D,A,z,T;const S=(A=(D=n==null?void 0:n.current)==null?void 0:D.api)==null?void 0:A.getSelectedNodes().map(N=>N.data);if(i&&console.log("SectionBranches.jsx: onSelectionChanged - event",m),i&&console.log("SectionBranches.jsx: onSelectionChanged - selectedBranches",l),(m==null?void 0:m.source)=="rowDataChanged"){const N=l.map(U=>U.id);(T=(z=n==null?void 0:n.current)==null?void 0:z.api)==null||T.forEachNode(U=>{N.includes(U.data.id)&&U.setSelected(!0)});return}else["api"].includes(m==null?void 0:m.source)||(d(S),u([]),c(!1))},[i,n,l,d,c]),b=t.useCallback(m=>{const S=[];m.api.forEachNode(D=>S.push(D.data)),i&&console.debug("SectionBranches.jsx: onRowDragEnd - movedRowData",S),r(D=>({...D,branches:ce(S)}))},[r,i]),p=t.useCallback(m=>{const S=a==null?void 0:a.branchFolderColours[m.data["Branch Folder"]];return{backgroundColor:S?`${S}20`:"transparent"}},[a==null?void 0:a.branchFolderColours]),y=t.useMemo(()=>({resizable:!0,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!0,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),j=t.useMemo(()=>{const m=[{headerCheckboxSelection:!0,checkboxSelection:!0,headerCheckboxSelectionFilteredOnly:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{headerName:"",width:60,resizable:!1,sortable:!1,filter:!1,editable:!1,cellRenderer:S=>e.jsx(v,{label:"Copy Row",hasArrow:!0,children:e.jsx(H,{colorScheme:"yellow","aria-label":"Copy Row",size:"sm",onClick:()=>F(S.data),icon:e.jsx(De,{})})})},{field:"Branch Folder",resizable:!1,width:130,valueFormatter:S=>S.value.toUpperCase()},{field:"Branch Version",resizable:!1,width:130},{field:"SVN Branch",flex:1},{field:"Branch Info",editable:!1,resizable:!1,width:200}];return g?[{field:"",rowDrag:!0,resizable:!1,filter:!1,suppressMovable:!1,editable:!1,width:20,cellRenderer:xs,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},...m]:m},[a,g,F]);return t.useEffect(()=>{w(h.height>768)},[h]),e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:g?"auto":"428px",width:"100%"},children:e.jsx(de,{ref:n,rowData:s,defaultColDef:y,columnDefs:j,stopEditingWhenCellsLoseFocus:!0,getRowStyle:p,onRowDragEnd:b,domLayout:g?"autoHeight":"normal",suppressRowClickSelection:!0,rowSelection:"multiple",rowMultiSelectWithClick:!0,animateRows:!0,rowDragManaged:!0,onSelectionChanged:k,onRowValueChanged:o,columnMenu:"new",editType:"fullRow",deltaRowDataMode:!0,getRowNodeId:m=>m.id,immutableData:!0,suppressFlash:!0,enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!g,paginationAutoPageSize:!1,paginationPageSizeSelector:!1,paginationPageSize:10})})}function dt(){const{updateConfig:s,isDebug:o,socket:a,configurableRowData:n,setConfigurableRowData:r,branchInfos:i,config:l,setBranchInfos:d,setSelectedBranches:u,setSelectedBranchStatuses:c,showCommitView:h,setShowCommitView:g}=L(),[w,F]=t.useState([]),k=t.useCallback(b=>{o&&console.log("AG Grid: onRowValueChanged - event",b),o&&console.log("AG Grid: onRowValueChanged - rowDataBranches",w),s(p=>({...p,branches:ce(w)}))},[w,s,o]);return t.useEffect(()=>{const b=G.debounce(()=>{const p=n.map(y=>({...y,"Branch Info":i[y.id]||"Hasn't been refreshed"}));F(y=>G.isEqual(p,y)?y:p)},300);return b(),()=>b.cancel()},[n,i]),t.useEffect(()=>{r(b=>l&&l.branches&&!G.isEqual(l.branches,b)?l.branches:b)},[l]),t.useEffect(()=>{const b=p=>{d(y=>{const j={...y,[p.id]:p.info};return console.debug("branch-info-single data received:",p),console.debug("branch-info-single newBranchInfos",j),u(m=>(m.find(D=>D.id===p.id)&&h&&(c([]),g(!1)),m)),j})};return a==null||a.on("branch-info-single",b),()=>a==null?void 0:a.off("branch-info-single")},[a,h]),{rowDataBranches:w,setRowDataBranches:F,onRowValueChanged:k}}function ht(){const{socket:s,updateConfig:o,isDebug:a,setShowSelectedBranchesLog:n,configurableRowData:r,branchTableGridRef:i,selectedBranches:l,setSelectedBranches:d,isCommitMode:u,setIsCommitMode:c,setSelectedBranchStatuses:h,setShowCommitView:g}=L(),{emitUpdateSingle:w,emitInfoSingle:F}=he(),{RaiseClientNotificaiton:k}=ne(),[b,p]=t.useState(!1),y=t.useRef(),j=()=>p(!1),{rowDataBranches:m,setRowDataBranches:S,onRowValueChanged:D}=dt(),[A,z]=t.useState(0),[T,N]=t.useState([]),U=t.useCallback(()=>{var B,f;a&&console.log("SectionBranches.jsx: clearSelection: START"),(f=(B=i==null?void 0:i.current)==null?void 0:B.api)==null||f.deselectAll(),d([]),c(!1)},[a,i,d]),$=t.useCallback(()=>{var f,R;const B=(R=(f=i==null?void 0:i.current)==null?void 0:f.api)==null?void 0:R.getSelectedNodes().map(Q=>Q.data);d(B),p(!0)},[i,d]),I=t.useCallback(()=>{const B={id:String(Date.now()),"Branch Folder":"","Branch Version":"","SVN Branch":"","Branch Info":""};o(f=>({...f,branches:ce([...f.branches,B])}))},[o]),O=t.useCallback(()=>{l.forEach(B=>{w(B.id,B["SVN Branch"],B["Branch Version"],B["Branch Folder"])})},[l,w]),W=t.useCallback(()=>{T.forEach(B=>{w(B.id,B["SVN Branch"],B["Branch Version"],B["Branch Folder"])})},[T,w]),Y=t.useCallback(()=>{const B=l.map(R=>R.id),f=m.filter(R=>!B.includes(R.id));console.log("SectionBranches.jsx: removeSelectedRows - updatedData",f),o(R=>({...R,branches:ce(f)})),U(),j()},[l,m,o]),K=t.useCallback(()=>{n(!0)},[]),Z=t.useCallback(()=>{S(B=>{const f=[...B];return l.forEach(R=>{const Q=f.findIndex(fe=>fe.id===R.id);f[Q]["Branch Info"]="Refreshing..."}),f}),l.forEach(B=>{F(B.id,B["SVN Branch"],B["Branch Version"],B["Branch Folder"])})},[l,F]),ee=t.useCallback(()=>{if(u){k("Unable to refresh branches while in commit mode","warning",0);return}k("Refreshing all branches. Please wait until this is done!","info",3e3);const B=Date.now();r.forEach(f=>{F(f.id,f["SVN Branch"],f["Branch Version"],f["Branch Folder"])}),z(B)},[r,F,k,u]),ue=t.useCallback(()=>{c(B=>!B),g(!1)},[c]);return t.useEffect(()=>{const B=m.filter(f=>String(f["Branch Info"]).toLowerCase().includes("behind"));N(B)},[m]),t.useEffect(()=>{const f=Date.now();if(r.length>0){f-A>3e5&&ee();const R=setInterval(()=>{ee()},3e5);return()=>clearInterval(R)}},[r,A,ee]),t.useEffect(()=>{const B=f=>{a&&console.debug("branch-success-single data received:",f),F(f.id,f.branch,f.version,f.folder)};return s==null||s.on("branch-success-single",B),()=>s==null?void 0:s.off("branch-success-single",B)},[a,s,F]),e.jsxs("div",{children:[e.jsxs(Me,{mb:4,justify:"space-between",children:[e.jsxs(M,{columnGap:2,children:[e.jsx(v,{label:"Requires at least 1 branch",isDisabled:l.length>0,hasArrow:!0,children:e.jsxs(E,{onClick:Z,leftIcon:e.jsx(Be,{}),colorScheme:"yellow",isDisabled:l.length<1,children:["Refresh ",l.length>0?`${l.length} Branch`:"",l.length>1?"es":""]})}),e.jsx(v,{label:"Requires at least 1 branch",isDisabled:l.length>0,hasArrow:!0,children:e.jsxs(E,{onClick:O,leftIcon:e.jsx(J,{as:bs}),colorScheme:"yellow",isDisabled:l.length<1,children:["Update ",l.length>0?`${l.length} Branch`:"",l.length>1?"es":""]})}),e.jsx(v,{label:"Requires at least 1 branch",isDisabled:l.length>0,hasArrow:!0,children:e.jsx(E,{onClick:ue,leftIcon:e.jsx(J,{as:Qe}),colorScheme:"yellow",isDisabled:l.length<1,children:u?"Undo Commit":"Commit"})}),e.jsx(v,{label:"Requires at least 1 branch",isDisabled:l.length>0,hasArrow:!0,children:e.jsx(E,{onClick:K,leftIcon:e.jsx(ps,{}),colorScheme:"yellow",isDisabled:l.length<1,children:"View Logs"})})]}),e.jsx(M,{columnGap:2,children:e.jsx(v,{label:"No outdated branches to update",isDisabled:T.length>0,hasArrow:!0,children:e.jsx(E,{onClick:W,leftIcon:e.jsx(Cs,{}),colorScheme:"yellow",isDisabled:T.length<1,children:"Update Outdated"})})})]}),e.jsx(ct,{rowData:m,onRowValueChanged:D}),e.jsxs(M,{columnGap:2,mt:4,children:[e.jsx(v,{label:"Please select at least 1 branch",isDisabled:l.length>0,hasArrow:!0,children:e.jsxs(E,{onClick:U,leftIcon:e.jsx(ve,{}),colorScheme:"red",isDisabled:l.length<1,children:["Deselect ",l.length>0?`${l.length} Branch`:"",l.length>1?"es":""]})}),e.jsx(v,{label:"Please select at least 1 branch",isDisabled:l.length>0,hasArrow:!0,children:e.jsxs(E,{onClick:$,leftIcon:e.jsx(ve,{}),colorScheme:"red",isDisabled:l.length<1,children:["Delete ",l.length>0?`${l.length} Branch`:"",l.length>1?"es":""]})}),e.jsx(E,{onClick:I,leftIcon:e.jsx(ws,{boxSize:8}),colorScheme:"green",children:"New Row"})]}),e.jsx(rt,{isAlertOpen:b,onCloseAlert:j,cancelRef:y,removeSelectedRows:Y})]})}function ns(s){const{data:o,onDiffResult:a}=s,n=async()=>{try{const r=await window.electron.openTortoiseSVNDiff({fullPath:o["Full Path"],branchFolder:o["Branch Folder"],branchVersion:o["Branch Version"]});a(r)}catch(r){a({success:!1,error:r.message})}};return e.jsx(H,{"aria-label":"Diff",size:"sm",icon:e.jsx(js,{}),onClick:n,colorScheme:"yellow"})}function ls(){const{config:s}=L(),{emitTrelloCardNamesSearch:o,emitTrelloCardUpdate:a}=he(),n=s==null?void 0:s.trelloIntegration,r=(n==null?void 0:n.key)||null,i=(n==null?void 0:n.token)||null,l=r&&i&&r.trim()!==""&&i.trim()!==""&&r.toUpperCase()!=="TRELLO_API_KEY"&&i.toUpperCase!=="TRELLO_TOKEN";return{key:r,token:i,isTrelloIntegrationEnabled:l,emitTrelloCardNamesSearch:o,emitTrelloCardUpdate:a}}function ut({isModalOpen:s,closeModal:o}){const{socket:a,setIsCommitMode:n,setSelectedBranchStatuses:r,setShowCommitView:i,socketPayload:l,postCommitData:d,setPostCommitData:u}=L(),{emitUpdateSingle:c,emitCommitPayload:h}=he(),{key:g,token:w,isTrelloIntegrationEnabled:F,emitTrelloCardUpdate:k}=ls(),{RaiseClientNotificaiton:b}=ne(),[p,y]=t.useState([]),{onCopy:j,value:m,setValue:S,hasCopied:D}=ze(""),{onCopy:A,value:z,setValue:T,hasCopied:N}=ze(""),U=t.useCallback(f=>{f.success?b("TortoiseSVN diff opened successfully","success",3e3):b(`Error opening TortoiseSVN diff: ${JSON.stringify(f.error,null,4)}`,"error",0)},[b]),$=[{title:"Review",description:"Confirm SVN changes"},{title:"Commit",description:"Commit changes"},{title:"Complete",description:"Process Completed"}],{activeStep:I,setActiveStep:O}=Ss({index:1,count:$.length}),W=t.useMemo(()=>({resizable:!1,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),Y=t.useMemo(()=>[{field:"Branch Folder"},{field:"Branch Version",sort:"asc"},{field:"File Path",flex:1},{field:"Local Status",headerTooltip:"Working Copy"},{headerName:"Diff",filter:!1,sortable:!1,cellRenderer:ns,cellRendererParams:{onDiffResult:U},width:90}],[]),K=t.useCallback((f,R=!0)=>{const Q="​".repeat(7),fe=f.includes("MarkupSupport")?`\r +import{r as t,u as cs,l as ds,R as Ae,j as e,W as Le,d as Oe,L as _e,I as hs,H as Z,T as v,e as $,f as X,M as us,g as fs,h as ms,i as gs,A as Ge,k as pe,m as Qe,n as Ce,o as we,p as Be,B as P,D as xs,C as Fe,F as A,q as ye,s as bs,t as Ye,v as ps,w as Cs,x as Ie,S as ws,V as js,y as ze,z as Ss,E as Ke,G as Je,J as Bs,K as ys,N as ks,O as Ds,P as vs,Q as Ue,U as p,X as Fs,Y as Is,Z as ke,_ as O,$ as Re,a0 as ae,a1 as oe,a2 as re,a3 as te,a4 as Rs,a5 as Xe,a6 as J,a7 as Ns,a8 as Ts,a9 as Ms,aa as We,ab as je,ac as As,ad as Se,ae as ie,af as Ne,ag as Te,ah as Ls,ai as Vs,aj as Ze,ak as Es,al as Ps,am as Os,an as zs,ao as es,ap as ss,aq as xe,ar as ts,as as be,at as Us,au as Me,av as Ws,aw as Hs,ax as $s,ay as qs,az as _s,aA as Gs,aB as Qs,aC as Ys,aD as Ks,aE as Js,aF as Xs,aG as Zs,aH as et}from"./vendor.js";import{_ as G}from"./lodash.js";import{A as de}from"./ag-grid-react.js";import"./ag-grid-community.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))l(r);new MutationObserver(r=>{for(const i of r)if(i.type==="childList")for(const n of i.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&l(n)}).observe(document,{childList:!0,subtree:!0});function o(r){const i={};return r.integrity&&(i.integrity=r.integrity),r.referrerPolicy&&(i.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?i.credentials="include":r.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function l(r){if(r.ep)return;r.ep=!0;const i=o(r);fetch(r.href,i)}})();const st="/assets/Titan.png";function ce(s=[]){return(Array.isArray(s)?s:[s]).map(o=>(delete o["Branch Info"],o))}function De(s,a,o){return`${s==""?"Uncategorised":s} ${a==""?"Unversioned":a} ${String(o).split("\\").at(-1)}`}function tt(s){return String(s).split("\\").at(-1)}const nt="http://localhost:4000",lt="40px";function ge(s,a="info",o=3e3,l=!1){return{position:"top",variant:"solid",title:l?"Server Notification":"Client Notification",description:s,status:a,duration:o,isClosable:!0}}const ns=t.createContext({socket:null,toast:null,config:null,updateConfig:s=>{},isDebug:!1,setIsDebug:s=>{},configurableRowData:[],setConfigurableRowData:s=>{},branchInfos:{},setBranchInfos:s=>{},branchTableGridRef:null,selectedBranches:[],setSelectedBranches:s=>{},showSelectedBranchesLog:!1,setShowSelectedBranchesLog:s=>{},isCommitMode:!1,setIsCommitMode:s=>{},selectedBranchStatuses:[],setSelectedBranchStatuses:s=>{},localChangesGridRef:null,untrackedChangesGridRef:null,showCommitView:!1,setShowCommitView:s=>{},sourceBranch:null,setSourceBranch:s=>{},branchOptions:[],issueNumber:{},setIssueNumber:s=>{},commitMessage:"",setCommitMessage:s=>{},selectedLocalChanges:[],setSelectedLocalChanges:s=>{},selectedUntrackedChanges:[],setSelectedUntrackedChanges:s=>{},socketPayload:null,setSocketPayload:s=>{},postCommitData:{},setPostCommitData:s=>{},logData:[],setLogData:s=>{}}),E=()=>t.useContext(ns),at=({children:s})=>{const[a,o]=t.useState(null),[l,r]=t.useState(null),i=cs(),[n,d]=t.useState(()=>localStorage.getItem("isDebug")==="true");t.useEffect(()=>{const S=ds(nt);return r(S),S.on("connect",()=>{S.emit("titan-config-get","fetch"),S.once("titan-config-get",L=>{o(L),i(ge("Configurations Loaded","success",2e3))})}),S.on("notification",L=>{i(ge(L.description,L.status,L.duration,!0))}),S.on("disconnect",()=>{i(ge("Server Has Been Disconnected","warning",0,!0))}),S.on("reconnect",()=>{i(ge("Server Has Been Reconnected","success",2e3,!0))}),()=>{S.disconnect()}},[]),t.useEffect(()=>{localStorage.setItem("isDebug",String(n))},[n]);const u=t.useCallback(S=>{S!=null&&(console.debug("Saving config:",S),l==null||l.emit("titan-config-set",S))},[l]),c=t.useCallback(S=>{o(L=>{const M=S(L);return G.isEqual(L,M)?L:(u(M),M)})},[o,u]),[h,g]=t.useState([]),[C,F]=t.useState({}),k=t.useRef(null),[x,b]=t.useState([]),[y,w]=t.useState(!1),[m,j]=t.useState(!1),[D,V]=t.useState([]),z=t.useRef(null),N=t.useRef(null),[T,W]=t.useState(!1),[q,I]=t.useState(null),U=t.useMemo(()=>{let S=a&&a.commitOptions&&a.commitOptions.useFolderOnlySource,L=h.filter(M=>M["Branch Folder"]&&M["Branch Version"]&&M["SVN Branch"]&&M["Branch Folder"]!==""&&M["Branch Version"]!==""&&M["SVN Branch"]!=="");return S&&(L=L.reduce((M,me)=>(M.some(ve=>ve["Branch Folder"]===me["Branch Folder"])||M.push(me),M),[])),L.map(M=>({value:M.id,label:S?M["Branch Folder"]:De(M["Branch Folder"],M["Branch Version"],M["SVN Branch"])}))},[a,x,h]),[H,Y]=t.useState({}),[K,ee]=t.useState(""),[se,ue]=t.useState([]),[B,f]=t.useState([]),[R,Q]=t.useState(null),[fe,Pe]=t.useState({}),[le,_]=Ae.useState([]);return t.useEffect(()=>{V([]),W(!1)},[h]),t.useEffect(()=>{if(!m||!T)return;const S=setTimeout(()=>{var L;(L=document.getElementById("sectionCommit"))==null||L.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},100);return()=>clearTimeout(S)},[m,T]),t.useEffect(()=>{if(x.length<1||T){x.length<1&&j(!1);return}V([]),Q(null),ce(x).forEach(S=>{console.debug("Emitting svn-status-single for branch:",S),l==null||l.emit("svn-status-single",{selectedBranch:S})})},[l,x,T]),t.useEffect(()=>{const S=()=>{W(!1)};return l==null||l.on("branch-refresh-unseen",S),()=>l==null?void 0:l.off("branch-refresh-unseen",S)},[l]),t.useEffect(()=>{const S=L=>{n&&console.debug("Received branch status data:",L),V(M=>[...M,L])};return l==null||l.on("branch-status-single",S),()=>l==null?void 0:l.off("branch-status-single",S)},[l]),t.useEffect(()=>{_([])},[x]),t.useEffect(()=>{le.length===0&&l&&b(S=>(S.length>0&&l.emit("svn-log-selected",{selectedBranches:x}),S))},[le,l]),t.useEffect(()=>{const S=L=>{console.debug("Received svn-log-result from socket in SectionBranchLog component in background"),_(M=>M.some(ve=>ve.id===L.id)?M:[...M,L])};return l==null||l.on("svn-log-result",S),()=>l==null?void 0:l.off("svn-log-result",S)},[l]),e.jsx(ns.Provider,{value:{socket:l,toast:i,config:a,updateConfig:c,isDebug:n,setIsDebug:d,configurableRowData:h,setConfigurableRowData:g,branchInfos:C,setBranchInfos:F,branchTableGridRef:k,selectedBranches:x,setSelectedBranches:b,showSelectedBranchesLog:y,setShowSelectedBranchesLog:w,isCommitMode:m,setIsCommitMode:j,selectedBranchStatuses:D,setSelectedBranchStatuses:V,localChangesGridRef:z,untrackedChangesGridRef:N,showCommitView:T,setShowCommitView:W,sourceBranch:q,setSourceBranch:I,branchOptions:U,issueNumber:H,setIssueNumber:Y,commitMessage:K,setCommitMessage:ee,selectedLocalChanges:se,setSelectedLocalChanges:ue,selectedUntrackedChanges:B,setSelectedUntrackedChanges:f,socketPayload:R,setSocketPayload:Q,postCommitData:fe,setPostCommitData:Pe,logData:le,setLogData:_},children:s})};function he(){const{socket:s}=E(),a=t.useCallback(()=>{s==null||s.emit("titan-config-open",{})},[s]),o=t.useCallback((c,h,g,C)=>{s==null||s.emit("svn-update-single",{id:c,branch:h,version:g,folder:C})},[s]),l=t.useCallback((c,h,g,C)=>{s==null||s.emit("svn-info-single",{id:c,branch:h,version:g,folder:C})},[s]),r=t.useCallback(c=>{s==null||s.emit("svn-commit",c)},[s]),i=t.useCallback(c=>{s==null||s.emit("svn-files-revert",{filesToProcess:c})},[s]),n=t.useCallback(c=>{s==null||s.emit("svn-files-add-remove",{filesToProcess:c})},[s]),d=t.useCallback((c,h,g,C=null)=>{s==null||s.emit("trello-search-names-card",{key:c,token:h,query:g,limit:C})},[s]),u=t.useCallback((c,h,g,C)=>{s==null||s.emit("trello-update-card",{key:c,token:h,trelloData:g,commitResponses:C})},[s]);return{emitOpenConfig:a,emitUpdateSingle:o,emitInfoSingle:l,emitCommitPayload:r,emitFilesRevert:i,emitFilesAddRemove:n,emitTrelloCardNamesSearch:d,emitTrelloCardUpdate:u}}function ne(){const{toast:s}=E(),a=t.useCallback((o="",l="info",r=3e3,i=null)=>{const n=ge(o,l,r);if(s)return s(n);if(i)return i(n)},[s]);return{toast:s,RaiseClientNotificaiton:a}}function ot(){const{config:s,isDebug:a,setIsDebug:o}=E(),{emitOpenConfig:l}=he(),{RaiseClientNotificaiton:r}=ne(),i=t.useCallback(()=>{window.electron.checkForUpdates().then(d=>{console.debug("Check for updates result: ",d)}),window.electron.on("update-not-available",()=>{r("Titan is up to date","info",3e3),window.electron.removeAllListeners("update-not-available")})},[r]),n=t.useCallback(()=>{window.electron&&window.electron.getAppVersion().then(d=>{r(`Application Version: v${d}`,"info",2e3)})},[r]);return e.jsxs(Le,{my:5,spacingY:5,justify:"space-between",children:[e.jsxs(Oe,{alignItems:"center",children:[e.jsx(_e,{onClick:n,children:e.jsx(hs,{src:st,alt:"Titan Logo",boxSize:"100px",mr:5,borderRadius:"full"})}),e.jsx(Z,{as:"h2",size:"2xl",noOfLines:1,className:"animation-fadein-forward",children:"Welcome back"}),e.jsx(Z,{as:"h2",size:"2xl",noOfLines:1,p:2,className:"animation-handwave",children:"👋"})]}),e.jsxs(Oe,{alignItems:"center",columnGap:2,children:[e.jsx(v,{label:`Current Debug Mode: ${a?"on":"off"}`,hasArrow:!0,placement:"left",children:e.jsx($,{"aria-label":"Toggle Debug Mode",colorScheme:"yellow",icon:a?e.jsx(X,{as:fs}):e.jsx(X,{as:us}),onClick:()=>o(d=>!d)})}),e.jsx(v,{label:"Open configuration file",hasArrow:!0,placement:"bottom-start",children:e.jsx($,{"aria-label":"Open configuration file",colorScheme:"yellow",icon:e.jsx(X,{as:ms}),onClick:()=>l()})}),e.jsx(v,{label:"Check for updates",hasArrow:!0,placement:"bottom-start",isDisabled:!window.electron,children:e.jsx($,{"aria-label":"Check for updates",colorScheme:"yellow",icon:e.jsx(X,{as:gs}),onClick:i,isDisabled:!window.electron})})]})]})}function rt({isAlertOpen:s,onCloseAlert:a,cancelRef:o,removeSelectedRows:l}){return e.jsx(Ge,{isOpen:s,leastDestructiveRef:o,onClose:a,children:e.jsx(pe,{children:e.jsxs(Qe,{children:[e.jsx(Ce,{fontSize:"lg",fontWeight:"bold",children:"Delete Selected Rows"}),e.jsx(we,{children:"Are you sure you want to delete the selected rows? This action cannot be undone."}),e.jsxs(Be,{children:[e.jsx(P,{ref:o,onClick:a,children:"Cancel"}),e.jsx(P,{colorScheme:"red",onClick:l,ml:3,children:"Delete"})]})]})})})}function He(){const{innerWidth:s,innerHeight:a}=window;return{width:s,height:a}}function it(){const[s,a]=t.useState(He());return t.useEffect(()=>{function o(){a(He())}return window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)},[]),s}function ct({rowData:s,onRowValueChanged:a}){const{config:o,branchTableGridRef:l,updateConfig:r,isDebug:i,selectedBranches:n,setSelectedBranches:d,setSelectedBranchStatuses:u,setShowCommitView:c}=E(),h=it(),[g,C]=t.useState(h.height>768),F=t.useCallback(m=>{const j={...m,id:String(Date.now()),"Branch Info":"Hasn't been refreshed"};r(D=>({...D,branches:ce([...D.branches,j])}))},[r]),k=t.useCallback(m=>{var D,V,z,N;const j=(V=(D=l==null?void 0:l.current)==null?void 0:D.api)==null?void 0:V.getSelectedNodes().map(T=>T.data);if(i&&console.log("SectionBranches.jsx: onSelectionChanged - event",m),i&&console.log("SectionBranches.jsx: onSelectionChanged - selectedBranches",n),(m==null?void 0:m.source)=="rowDataChanged"){const T=n.map(W=>W.id);(N=(z=l==null?void 0:l.current)==null?void 0:z.api)==null||N.forEachNode(W=>{T.includes(W.data.id)&&W.setSelected(!0)});return}else["api"].includes(m==null?void 0:m.source)||(d(j),u([]),c(!1))},[i,l,n,d,c]),x=t.useCallback(m=>{const j=[];m.api.forEachNode(D=>j.push(D.data)),i&&console.debug("SectionBranches.jsx: onRowDragEnd - movedRowData",j),r(D=>({...D,branches:ce(j)}))},[r,i]),b=t.useCallback(m=>{const j=o==null?void 0:o.branchFolderColours[m.data["Branch Folder"]];return{backgroundColor:j?`${j}20`:"transparent"}},[o==null?void 0:o.branchFolderColours]),y=t.useMemo(()=>({resizable:!0,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!0,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),w=t.useMemo(()=>{const m=[{headerCheckboxSelection:!0,checkboxSelection:!0,headerCheckboxSelectionFilteredOnly:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{headerName:"",width:60,resizable:!1,sortable:!1,filter:!1,editable:!1,cellRenderer:j=>e.jsx(v,{label:"Copy Row",hasArrow:!0,children:e.jsx($,{colorScheme:"yellow","aria-label":"Copy Row",size:"sm",onClick:()=>F(j.data),icon:e.jsx(Fe,{})})})},{field:"Branch Folder",resizable:!1,width:130,valueFormatter:j=>j.value.toUpperCase()},{field:"Branch Version",resizable:!1,width:130},{field:"SVN Branch",flex:1},{field:"Branch Info",editable:!1,resizable:!1,width:200}];return g?[{field:"",rowDrag:!0,resizable:!1,filter:!1,suppressMovable:!1,editable:!1,width:20,cellRenderer:xs,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},...m]:m},[o,g,F]);return t.useEffect(()=>{C(h.height>768)},[h]),e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:g?"auto":"428px",width:"100%"},children:e.jsx(de,{ref:l,rowData:s,defaultColDef:y,columnDefs:w,stopEditingWhenCellsLoseFocus:!0,getRowStyle:b,onRowDragEnd:x,domLayout:g?"autoHeight":"normal",suppressRowClickSelection:!0,rowSelection:"multiple",rowMultiSelectWithClick:!0,animateRows:!0,rowDragManaged:!0,onSelectionChanged:k,onRowValueChanged:a,columnMenu:"new",editType:"fullRow",deltaRowDataMode:!0,getRowNodeId:m=>m.id,immutableData:!0,suppressFlash:!0,enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!g,paginationAutoPageSize:!1,paginationPageSizeSelector:!1,paginationPageSize:10})})}function dt(){const{updateConfig:s,isDebug:a,socket:o,configurableRowData:l,setConfigurableRowData:r,branchInfos:i,config:n,setBranchInfos:d,setSelectedBranches:u,setSelectedBranchStatuses:c,showCommitView:h,setShowCommitView:g}=E(),[C,F]=t.useState([]),k=t.useCallback(x=>{a&&console.log("AG Grid: onRowValueChanged - event",x),a&&console.log("AG Grid: onRowValueChanged - rowDataBranches",C),s(b=>({...b,branches:ce(C)}))},[C,s,a]);return t.useEffect(()=>{const x=G.debounce(()=>{const b=l.map(y=>({...y,"Branch Info":i[y.id]||"Hasn't been refreshed"}));F(y=>G.isEqual(b,y)?y:b)},300);return x(),()=>x.cancel()},[l,i]),t.useEffect(()=>{r(x=>n&&n.branches&&!G.isEqual(n.branches,x)?n.branches:x)},[n]),t.useEffect(()=>{const x=b=>{d(y=>{const w={...y,[b.id]:b.info};return console.debug("branch-info-single data received:",b),console.debug("branch-info-single newBranchInfos",w),u(m=>(m.find(D=>D.id===b.id)&&h&&(c([]),g(!1)),m)),w})};return o==null||o.on("branch-info-single",x),()=>o==null?void 0:o.off("branch-info-single")},[o,h]),{rowDataBranches:C,setRowDataBranches:F,onRowValueChanged:k}}function ht(){const{socket:s,updateConfig:a,isDebug:o,setShowSelectedBranchesLog:l,configurableRowData:r,branchTableGridRef:i,selectedBranches:n,setSelectedBranches:d,isCommitMode:u,setIsCommitMode:c,setSelectedBranchStatuses:h,setShowCommitView:g}=E(),{emitUpdateSingle:C,emitInfoSingle:F}=he(),{RaiseClientNotificaiton:k}=ne(),[x,b]=t.useState(!1),y=t.useRef(),w=()=>b(!1),{rowDataBranches:m,setRowDataBranches:j,onRowValueChanged:D}=dt(),[V,z]=t.useState(0),[N,T]=t.useState([]),W=t.useCallback(()=>{var B,f;o&&console.log("SectionBranches.jsx: clearSelection: START"),(f=(B=i==null?void 0:i.current)==null?void 0:B.api)==null||f.deselectAll(),d([]),c(!1)},[o,i,d]),q=t.useCallback(()=>{var f,R;const B=(R=(f=i==null?void 0:i.current)==null?void 0:f.api)==null?void 0:R.getSelectedNodes().map(Q=>Q.data);d(B),b(!0)},[i,d]),I=t.useCallback(()=>{const B={id:String(Date.now()),"Branch Folder":"","Branch Version":"","SVN Branch":"","Branch Info":""};a(f=>({...f,branches:ce([...f.branches,B])}))},[a]),U=t.useCallback(()=>{n.forEach(B=>{C(B.id,B["SVN Branch"],B["Branch Version"],B["Branch Folder"])})},[n,C]),H=t.useCallback(()=>{N.forEach(B=>{C(B.id,B["SVN Branch"],B["Branch Version"],B["Branch Folder"])})},[N,C]),Y=t.useCallback(()=>{const B=n.map(R=>R.id),f=m.filter(R=>!B.includes(R.id));console.log("SectionBranches.jsx: removeSelectedRows - updatedData",f),a(R=>({...R,branches:ce(f)})),W(),w()},[n,m,a]),K=t.useCallback(()=>{l(!0)},[]),ee=t.useCallback(()=>{j(B=>{const f=[...B];return n.forEach(R=>{const Q=f.findIndex(fe=>fe.id===R.id);f[Q]["Branch Info"]="Refreshing..."}),f}),n.forEach(B=>{F(B.id,B["SVN Branch"],B["Branch Version"],B["Branch Folder"])})},[n,F]),se=t.useCallback(()=>{if(u){k("Unable to refresh branches while in commit mode","warning",0);return}k("Refreshing all branches. Please wait until this is done!","info",3e3);const B=Date.now();r.forEach(f=>{F(f.id,f["SVN Branch"],f["Branch Version"],f["Branch Folder"])}),z(B)},[r,F,k,u]),ue=t.useCallback(()=>{c(B=>!B),g(!1)},[c]);return t.useEffect(()=>{const B=m.filter(f=>String(f["Branch Info"]).toLowerCase().includes("behind"));T(B)},[m]),t.useEffect(()=>{const f=Date.now();if(r.length>0){f-V>3e5&&se();const R=setInterval(()=>{se()},3e5);return()=>clearInterval(R)}},[r,V,se]),t.useEffect(()=>{const B=f=>{o&&console.debug("branch-success-single data received:",f),F(f.id,f.branch,f.version,f.folder)};return s==null||s.on("branch-success-single",B),()=>s==null?void 0:s.off("branch-success-single",B)},[o,s,F]),e.jsxs("div",{children:[e.jsxs(Le,{mb:4,justify:"space-between",children:[e.jsxs(A,{columnGap:2,children:[e.jsx(v,{label:"Requires at least 1 branch",isDisabled:n.length>0,hasArrow:!0,children:e.jsxs(P,{onClick:ee,leftIcon:e.jsx(ye,{}),colorScheme:"yellow",isDisabled:n.length<1,children:["Refresh ",n.length>0?`${n.length} Branch`:"",n.length>1?"es":""]})}),e.jsx(v,{label:"Requires at least 1 branch",isDisabled:n.length>0,hasArrow:!0,children:e.jsxs(P,{onClick:U,leftIcon:e.jsx(X,{as:bs}),colorScheme:"yellow",isDisabled:n.length<1,children:["Update ",n.length>0?`${n.length} Branch`:"",n.length>1?"es":""]})}),e.jsx(v,{label:"Requires at least 1 branch",isDisabled:n.length>0,hasArrow:!0,children:e.jsx(P,{onClick:ue,leftIcon:e.jsx(X,{as:Ye}),colorScheme:"yellow",isDisabled:n.length<1,children:u?"Undo Commit":"Commit"})}),e.jsx(v,{label:"Requires at least 1 branch",isDisabled:n.length>0,hasArrow:!0,children:e.jsx(P,{onClick:K,leftIcon:e.jsx(ps,{}),colorScheme:"yellow",isDisabled:n.length<1,children:"View Logs"})})]}),e.jsx(A,{columnGap:2,children:e.jsx(v,{label:"No outdated branches to update",isDisabled:N.length>0,hasArrow:!0,children:e.jsx(P,{onClick:H,leftIcon:e.jsx(Cs,{}),colorScheme:"yellow",isDisabled:N.length<1,children:"Update Outdated"})})})]}),e.jsx(ct,{rowData:m,onRowValueChanged:D}),e.jsxs(A,{columnGap:2,mt:4,children:[e.jsx(v,{label:"Please select at least 1 branch",isDisabled:n.length>0,hasArrow:!0,children:e.jsxs(P,{onClick:W,leftIcon:e.jsx(Ie,{}),colorScheme:"red",isDisabled:n.length<1,children:["Deselect ",n.length>0?`${n.length} Branch`:"",n.length>1?"es":""]})}),e.jsx(v,{label:"Please select at least 1 branch",isDisabled:n.length>0,hasArrow:!0,children:e.jsxs(P,{onClick:q,leftIcon:e.jsx(Ie,{}),colorScheme:"red",isDisabled:n.length<1,children:["Delete ",n.length>0?`${n.length} Branch`:"",n.length>1?"es":""]})}),e.jsx(P,{onClick:I,leftIcon:e.jsx(ws,{boxSize:8}),colorScheme:"green",children:"New Row"})]}),e.jsx(rt,{isAlertOpen:x,onCloseAlert:w,cancelRef:y,removeSelectedRows:Y})]})}function ls(s){const{data:a,onDiffResult:o}=s,l=async()=>{try{const r=await window.electron.openTortoiseSVNDiff({fullPath:a["Full Path"],branchFolder:a["Branch Folder"],branchVersion:a["Branch Version"]});o(r)}catch(r){o({success:!1,error:r.message})}};return e.jsx($,{"aria-label":"Diff",size:"sm",icon:e.jsx(js,{}),onClick:l,colorScheme:"yellow"})}function as(){const{config:s}=E(),{emitTrelloCardNamesSearch:a,emitTrelloCardUpdate:o}=he(),l=s==null?void 0:s.trelloIntegration,r=(l==null?void 0:l.key)||null,i=(l==null?void 0:l.token)||null,n=r&&i&&r.trim()!==""&&i.trim()!==""&&r.toUpperCase()!=="TRELLO_API_KEY"&&i.toUpperCase!=="TRELLO_TOKEN";return{key:r,token:i,isTrelloIntegrationEnabled:n,emitTrelloCardNamesSearch:a,emitTrelloCardUpdate:o}}function ut({isModalOpen:s,closeModal:a}){const{socket:o,setIsCommitMode:l,setSelectedBranchStatuses:r,setShowCommitView:i,socketPayload:n,postCommitData:d,setPostCommitData:u}=E(),{emitUpdateSingle:c,emitCommitPayload:h}=he(),{key:g,token:C,isTrelloIntegrationEnabled:F,emitTrelloCardUpdate:k}=as(),{RaiseClientNotificaiton:x}=ne(),[b,y]=t.useState([]),{onCopy:w,value:m,setValue:j,hasCopied:D}=ze(""),{onCopy:V,value:z,setValue:N,hasCopied:T}=ze(""),W=t.useCallback(f=>{f.success?x("TortoiseSVN diff opened successfully","success",3e3):x(`Error opening TortoiseSVN diff: ${JSON.stringify(f.error,null,4)}`,"error",0)},[x]),q=[{title:"Review",description:"Confirm SVN changes"},{title:"Commit",description:"Commit changes"},{title:"Complete",description:"Process Completed"}],{activeStep:I,setActiveStep:U}=Ss({index:1,count:q.length}),H=t.useMemo(()=>({resizable:!1,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),Y=t.useMemo(()=>[{field:"Branch Folder"},{field:"Branch Version",sort:"asc"},{field:"File Path",flex:1},{field:"Local Status",headerTooltip:"Working Copy"},{headerName:"Diff",filter:!1,sortable:!1,cellRenderer:ls,cellRendererParams:{onDiffResult:W},width:90}],[]),K=t.useCallback((f,R=!0)=>{const Q="​".repeat(7),fe=f.includes("MarkupSupport")?`\r ${Q}`:`\r -`,le=p.sort((q,x)=>q["Branch Version"].localeCompare(x["Branch Version"])).map(q=>{const x=[];f.includes("BranchFolder")&&x.push(q["Branch Folder"]),f.includes("BranchVersion")&&x.push(q["Branch Version"]),f.includes("SVNBranch")&&x.push(q.branchPathFolder);let V=x.join(" ").trim();if(f.includes("IssueNumber")){const Ee=q.branchIssueNumber;V+=` Issue [${Ee}]`}const _=q.revision?q.revision:q.errorMessage||"Error";return V+=` Revision [${_}]`,V});return R?le.join(fe):le},[p,l]),Z=t.useCallback(f=>{const R=K(f);S(R)},[K,S]),ee=t.useCallback(()=>{O(f=>f-1)},[O]),ue=t.useCallback(()=>{if(d.type!=="trello"){b("Trello Autofill is not enabled for this commit","error");return}const f=d.data,R=K(["BranchFolder","BranchVersion","IssueNumber"],!1);k(g,w,f,R),b("Updating Trello card with commit information","info"),u(null)},[d,b,K]),B=t.useCallback(()=>{O(f=>{switch(f){case 1:h(l);case 2:S(""),T("");break;case 3:return j(),b("Updating selected branches! Please wait","info",1500),p.forEach(R=>{c(R.branchId,R["SVN Branch"],R["Branch Version"],R["Branch Folder"])}),n(!1),r([]),i(!1),o(),1}return f+1})},[O,h,l,S,T,j,b,p,c,n,r,i,o]);return t.useEffect(()=>{O(1),y([]),S(""),T("")},[s,y]),t.useEffect(()=>{!s||I!=0||(o(),O(1),y([]),S(""),T(""))},[I,s]),t.useEffect(()=>{!s||I!=3||(b("The commit process has been completed successfully","success",5e3),Z(["BranchFolder","BranchVersion","SVNBranch"]),T(l.commitMessage||""))},[b,I,s,Z]),t.useEffect(()=>{const f=R=>{y(Q=>[...Q,R])};return a==null||a.on("svn-commit-status-live",f),()=>a==null?void 0:a.off("svn-commit-status-live",f)},[a]),t.useEffect(()=>{if(I!=2)return;const f=setTimeout(()=>{p.length>0&&p[0].bulkCommitLength==p.length&&O(3)},3e3);return()=>clearTimeout(f)},[I,p]),t.useEffect(()=>{(D||N)&&b("Copied to Clipboard","success",1500)},[D,N,b]),!s||!l?e.jsx(e.Fragment,{}):e.jsxs(Ye,{isOpen:s,onClose:o,isCentered:!0,motionPreset:"slideInBottom",scrollBehavior:"inside",size:"xl",closeOnOverlayClick:I==1,children:[e.jsx(be,{}),e.jsxs(Ke,{maxH:"85%",maxW:"95%",children:[e.jsxs(pe,{display:"flex",justifyContent:"space-between",maxWidth:I==1?"94%":"100%",children:[e.jsx(X,{as:"h2",size:"lg",children:"Commit Selected Files"}),e.jsx(Bs,{index:I-1,mb:0,size:"sm",colorScheme:"yellow",children:$.map((f,R)=>e.jsxs(ys,{children:[e.jsx(ks,{children:e.jsx(Ds,{complete:e.jsx(vs,{}),incomplete:e.jsx(Oe,{}),active:e.jsx(Oe,{})})}),e.jsx(C,{flexShrink:"0",children:e.jsx(Fs,{children:f.title})}),e.jsx(Is,{})]},R))})]}),I==1?e.jsx(ye,{size:"lg",py:6}):e.jsx(e.Fragment,{}),e.jsx(Ce,{children:e.jsxs(C,{children:[I!=1?e.jsx(e.Fragment,{}):e.jsxs(C,{children:[e.jsxs(C,{mb:4,children:[e.jsx(P,{fontWeight:600,children:"Please confirm that the following information is correct before proceeding to commit your files:"}),e.jsxs(Fe,{spacing:3,children:[e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Source Branch: ",e.jsx(se,{children:ke(l.sourceBranch["Branch Folder"],l.sourceBranch["Branch Version"],l.sourceBranch["SVN Branch"])})]}),e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Issue Numbers: ",e.jsx(se,{children:Object.entries(l.issueNumber).map(f=>`${f[1]} (${f[0]})`).join(", ")})]}),e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Commit Message: ",e.jsx(se,{children:l.commitMessage})]}),e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Example:"," ",e.jsxs(se,{children:["Issue ",l.issueNumber[l.sourceBranch["Branch Folder"]]," (",l.sourceBranch["Branch Folder"]," ",l.sourceBranch["Branch Version"],"): ",l.commitMessage]})]})]})]}),e.jsx(C,{children:e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"350px",width:"100%"},children:e.jsx(de,{rowData:l.filesToProcess,defaultColDef:W,columnDefs:Y,domLayout:"normal",columnMenu:"new",pagination:!0,paginationAutoPageSize:!0})})})]}),I!=2?e.jsx(e.Fragment,{}):e.jsxs(C,{children:[e.jsxs(P,{fontWeight:600,children:["Please wait while the files are being committed to the SVN repository.",e.jsx("br",{}),"Current live status of the commit process:"]}),e.jsx(C,{children:e.jsx(Fe,{spacing:3,children:p.map((f,R)=>e.jsxs(ae,{children:[e.jsx(oe,{as:f.errorMessage?Rs:re,color:f.errorMessage?"red.500":"yellow.500"}),f.branchString,": ",e.jsx(se,{children:f.errorMessage||f.revision})]},R))})})]}),I!=3?e.jsx(e.Fragment,{}):e.jsxs(C,{children:[e.jsx(C,{mb:4,children:e.jsxs(P,{fontWeight:600,children:["The commit process has been completed successfully.",e.jsx("br",{}),"Please find your revisions here for view and copy:"]})}),e.jsxs(M,{columnGap:10,alignItems:"center",children:[e.jsxs(C,{children:[e.jsx(X,{as:"h3",size:"md",children:"SVN Revisions"}),e.jsx(C,{children:e.jsx("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:m})})]}),e.jsx(C,{children:e.jsx(v,{hasArrow:!0,label:"Copy to clipboard",children:e.jsx(H,{"aria-label":"Copy To Clipboard",onClick:j,icon:e.jsx(De,{}),colorScheme:"yellow"})})})]}),e.jsxs(C,{my:4,children:[e.jsx(P,{fontWeight:600,children:"Modify the clipboard text to include..."}),e.jsx(Je,{colorScheme:"yellow",defaultValue:["BranchFolder","BranchVersion"],onChange:Z,children:e.jsxs(Me,{children:[e.jsx(te,{value:"BranchFolder",children:"Branch Folder"}),e.jsx(te,{value:"BranchVersion",children:"Branch Version"}),e.jsx(te,{value:"SVNBranch",children:"SVN Branch"}),e.jsx(te,{value:"IssueNumber",children:"Issue Number"}),e.jsx(te,{value:"MarkupSupport",children:"Markup Support"})]})})]}),e.jsxs(M,{columnGap:10,alignItems:"center",children:[e.jsxs(C,{children:[e.jsx(P,{fontWeight:600,children:"Here is your SVN commit message for the source branch:"}),l.sourceBranch&&l.sourceBranch["Branch Folder"]&&l.sourceBranch["Branch Version"]?e.jsx(se,{children:`Issue ${l.issueNumber[l.sourceBranch["Branch Folder"]]} (${l.sourceBranch["Branch Folder"]} ${l.sourceBranch["Branch Version"]}): ${z}`}):e.jsx(se,{children:"Source information is undefined. Please check that you have entered the correct details otherwise contact the developer!"})]}),e.jsx(v,{hasArrow:!0,label:"Copy to clipboard",children:e.jsx(H,{"aria-label":"Copy To Clipboard",onClick:A,icon:e.jsx(De,{}),colorScheme:"yellow"})})]})]})]})}),e.jsx(Se,{children:e.jsxs(M,{flex:1,justifyContent:"space-between",children:[e.jsx(M,{columnGap:2,children:e.jsx(v,{hasArrow:!0,label:"Cannot undo the commit currently",isDisabled:I<2,children:e.jsx(E,{onClick:ee,mr:3,isDisabled:I>=2,children:I==1?"Cancel":"Previous"})})}),e.jsxs(M,{columnGap:2,children:[e.jsx(v,{hasArrow:!0,label:"Requires Trello Autofill",isDisabled:(d==null?void 0:d.type)==="trello"&&F,children:e.jsx(E,{colorScheme:"yellow",leftIcon:e.jsx(J,{as:Ts}),onClick:ue,isDisabled:I<3||(d==null?void 0:d.type)!="trello"||!F,children:"Update Card"})}),e.jsx(v,{hasArrow:!0,label:"Cannot undo the commit currently",isDisabled:I!=2,children:e.jsx(E,{colorScheme:"yellow",onClick:B,isDisabled:I==2,children:I==$.length?"Complete":"Next"})})]})]})})]})]})}function ft({fileUpdates:s}){return e.jsx(C,{children:Object.keys(s).length>0?e.jsxs(C,{children:[e.jsx(P,{mb:4,children:"Below are the list of files which have been changed on your machine but there exists a newer version of them in the repository:"}),e.jsx(C,{maxHeight:"200px",overflowY:"auto",children:e.jsxs(Ns,{children:[e.jsx(Ms,{children:e.jsxs(Ue,{children:[e.jsx(we,{children:"Branch"}),e.jsx(we,{children:"Path"}),e.jsx(we,{children:e.jsx(v,{label:"Working Copy",hasArrow:!0,children:"Local Status"})}),e.jsx(we,{children:e.jsx(v,{label:"Repository",hasArrow:!0,children:"Remote Status"})})]})}),e.jsx(As,{children:Object.keys(s).map(o=>e.jsx(Ne.Fragment,{children:s[o].map((a,n)=>e.jsxs(Ue,{children:[e.jsx(je,{children:o}),e.jsx(je,{children:a.pathDisplay}),e.jsx(je,{children:a.wcStatus}),e.jsx(je,{children:a.reposStatus})]},n))},o))})]})}),e.jsx(P,{mt:4,children:"If you wish to commit these files, please update the associated branches!"})]}):e.jsx(C,{children:e.jsx(P,{children:"Your selected branches do not contain any changed files for which a newer version exists in the repository."})})})}function mt({rowDataLocalChanges:s,setRowDataLocalChanges:o,defaultColDefsCommit:a}){const{localChangesGridRef:n,isDebug:r,selectedBranches:i,showCommitView:l,setSelectedLocalChanges:d,selectedLocalChanges:u}=L(),{emitFilesRevert:c}=he(),{RaiseClientNotificaiton:h}=ne(),[g,w]=t.useState(""),F=t.useCallback(()=>{c(u)},[c,u]),k=t.useCallback(j=>{w(j.target.value)},[w]),b=t.useCallback(j=>{var D,A,z,T;if(console.debug("PanelLocalChanges.jsx: onFileViewSelectionChanged - event",j),String(j==null?void 0:j.source).toLowerCase().includes("api"))return;let m=(A=(D=n==null?void 0:n.current)==null?void 0:D.api)==null?void 0:A.getSelectedNodes().map(N=>N.data);r&&console.debug("PanelLocalChanges.jsx: onFileViewSelectionChanged - selectedBranches",m);const S=m.filter(N=>N["Local Status"].toLowerCase()==="added");(T=(z=n==null?void 0:n.current)==null?void 0:z.api)==null||T.forEachNode(N=>{S.some($=>$["File Path"].includes(N.data["File Path"])&&$["File Path"]!==N.data["File Path"])&&N.data["Local Status"].toLowerCase()==="added"&&!N.isSelected()&&(N.setSelected(!0),m.push(N.data),console.debug("PanelLocalChanges.jsx (onFileViewSelectionChanged): Adding ancestor node: ",N))}),d(m)},[n,r,d]),p=t.useCallback(j=>{j.success?h("TortoiseSVN diff opened successfully","success",3e3):h(`Error opening TortoiseSVN diff: ${JSON.stringify(j.error,null,4)}`,"error",0)},[h]),y=t.useMemo(()=>[{headerCheckboxSelection:!0,checkboxSelection:!0,headerCheckboxSelectionFilteredOnly:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{field:"Branch Folder"},{field:"Branch Version",sort:"asc",sortIndex:0},{field:"File Path",flex:1,sort:"asc",sortIndex:2},{field:"Local Status",headerTooltip:"Working Copy",sort:"asc",sortIndex:1},{headerName:"Diff",filter:!1,sortable:!1,resizable:!1,cellRenderer:ns,cellRendererParams:{onDiffResult:p},width:90}],[]);return t.useEffect(()=>{i.length<1||l||(w(""),o([]),d([]))},[i,l]),e.jsx(C,{children:s.length>0?e.jsxs(C,{children:[e.jsxs(M,{mb:4,alignItems:"center",children:[e.jsx(P,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:k,width:"100%"})]}),e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"480px",width:"100%"},children:e.jsx(de,{ref:n,rowData:s,defaultColDef:a,columnDefs:y,onSelectionChanged:b,quickFilterText:g,domLayout:"normal",rowSelection:"multiple",suppressRowClickSelection:!0,rowMultiSelectWithClick:!0,animateRows:!0,columnMenu:"new",enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!0,paginationAutoPageSize:!0})}),e.jsx(M,{mt:4,columnGap:2,justifyContent:"flex-end",children:e.jsx(v,{label:"Requires you to select at least 1 file",hasArrow:!0,isDisabled:u.length>0,children:e.jsx(E,{onClick:F,colorScheme:"red",isDisabled:u.length<1,children:"Revert Selected"})})})]}):e.jsx(C,{children:e.jsx(P,{children:"Your selected branches do not contain any files to commit."})})})}function gt({rowDataUntrackedChanges:s,setRowDataUntrackedChanges:o,defaultColDefsCommit:a}){const{untrackedChangesGridRef:n,selectedUntrackedChanges:r,setSelectedUntrackedChanges:i,isDebug:l,selectedBranches:d,showCommitView:u}=L(),{emitFilesAddRemove:c,emitFilesRevert:h}=he(),[g,w]=t.useState(""),F=t.useCallback(j=>{w(j.target.value)},[w]),k=t.useCallback(()=>{var m,S;const j=(S=(m=n==null?void 0:n.current)==null?void 0:m.api)==null?void 0:S.getSelectedNodes().map(D=>D.data);l&&console.debug("PanelUntrackedChanges.jsx (onUnseenFilesSelectionChanged): selectedBranches",j),i(j)},[n,l]),b=t.useCallback(()=>{c(r)},[c,r]),p=t.useCallback(()=>{h(r)},[h,r]),y=t.useMemo(()=>[{headerCheckboxSelection:!0,checkboxSelection:!0,headerCheckboxSelectionFilteredOnly:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{field:"Branch Folder"},{field:"Branch Version",sort:"asc",sortIndex:0},{field:"File Path",flex:1,sort:"asc",sortIndex:1},{field:"Local Status",headerTooltip:"Working Copy"}],[]);return t.useEffect(()=>{d.length<1||u||(w(""),o([]),i([]))},[d,u]),e.jsx(C,{children:s.length>0?e.jsxs(C,{children:[e.jsx(P,{mb:4,children:"Below are the list of files which are either unversioned or missing in the repository:"}),e.jsxs(M,{mb:4,alignItems:"center",children:[e.jsx(P,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:F,width:"100%"})]}),e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"390px",width:"100%"},children:e.jsx(de,{ref:n,rowData:s,defaultColDef:a,columnDefs:y,onSelectionChanged:k,quickFilterText:g,domLayout:"normal",rowSelection:"multiple",rowMultiSelectWithClick:!0,animateRows:!0,columnMenu:"new",enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!0,paginationAutoPageSize:!0})}),e.jsxs(M,{mt:4,columnGap:2,justifyContent:"flex-end",children:[e.jsx(v,{label:"Requires you to select at least 1 file",hasArrow:!0,isDisabled:r.length>0,children:e.jsxs(E,{onClick:b,colorScheme:"green",isDisabled:r.length<1,children:["Add/Remove ",r.length," File",r.length>1?"s":""]})}),e.jsx(v,{label:"Requires you to select at least 1 file",hasArrow:!0,isDisabled:r.length>0,children:e.jsxs(E,{onClick:p,colorScheme:"red",isDisabled:r.length<1,children:["Revert ",r.length," File",r.length>1?"s":""]})})]})]}):e.jsx(C,{children:e.jsx(P,{children:"Your selected branches do not contain any unversioned or missing files."})})})}function Ae(){const{config:s}=L();return s&&s.commitOptions?s.commitOptions:null}function He({branchFolder:s}){const{issueNumber:o,setIssueNumber:a,selectedBranches:n}=L(),r=Ae(),i=t.useCallback(u=>{const c=String(u.target.value||"").trim();c==""&&a(h=>G.omit(h,[s])),/^\d*$/.test(c)&&a(h=>({...h,[s]:c}))},[s,a]);t.useEffect(()=>{a({})},[r==null?void 0:r.useIssuePerFolder,a]);const l=!s,d=!s||!(r!=null&&r.useIssuePerFolder)?!0:n==null?void 0:n.map(u=>u["Branch Folder"]).includes(s);return e.jsx(v,{label:"Please select source branch first!",isDisabled:!l,hasArrow:!0,children:e.jsxs(Ie,{isDisabled:l,isRequired:d,children:[e.jsx(Re,{children:s?`Issue Number For ${s}`:"Issue Number"}),e.jsx(ie,{value:o[s]||"",onInput:i,placeholder:"Enter number"})]},s)})}function Le(){const{configurableRowData:s,sourceBranch:o,selectedBranches:a}=L(),n=t.useCallback(d=>s&&s.length>0?s.find(u=>u.id==d)["Branch Folder"]:"",[s]),r=t.useMemo(()=>{if(!(o!=null&&o.value))return[];const d=n(o.value);return[...new Set(a.filter(u=>u["Branch Folder"]!==d).map(u=>u["Branch Folder"]))]},[o,a,n]),i=t.useCallback(d=>s&&s.length>0?s.find(u=>u.id==d)["Branch Version"]:"",[s]),l=t.useCallback(d=>s&&s.length>0?s.find(u=>u.id==d)["SVN Branch"]:"",[s]);return{getBranchFolderById:n,selectedBranchFolders:r,getBranchVersionById:i,getSvnBranchById:l}}function xt({openMessageAutoFillModal:s}){const{sourceBranch:o,setSourceBranch:a,branchOptions:n,setIssueNumber:r,commitMessage:i,setCommitMessage:l,isCommitMode:d,selectedBranches:u}=L(),c=Ae(),{getBranchFolderById:h,selectedBranchFolders:g}=Le(),w=t.useCallback(k=>{a(k)},[a]),F=t.useCallback(k=>{l(String(k.target.value).replace(/["`]/g,"'"))},[l]);return t.useEffect(()=>{d&&(a(null),r({}))},[d]),t.useEffect(()=>{c!=null&&c.reusePreviousCommitMessage||l("")},[c==null?void 0:c.reusePreviousCommitMessage,l,d]),t.useEffect(()=>{r(k=>Object.fromEntries(Object.entries(k).filter(([b])=>u.some(p=>p["Branch Folder"]===b))))},[u]),e.jsx(C,{children:e.jsxs(M,{columnGap:3,children:[e.jsxs(C,{flexGrow:1,children:[e.jsxs(M,{columnGap:2,mb:2,children:[e.jsx(C,{width:"50%",children:e.jsxs(Ie,{isRequired:!0,children:[e.jsx(Re,{children:"Source Branch"}),e.jsx(Ls,{value:o,onChange:w,options:n,placeholder:"SVN Branch you're commiting from",selectedOptionStyle:"check",selectedOptionColorScheme:"yellow",isClearable:!0,classNamePrefix:"chakra-react-select"})]})}),e.jsx(M,{width:"50%",alignItems:"flex-end",columnGap:2,children:e.jsx(He,{branchFolder:o&&o.value?h(o.value):null})})]}),e.jsxs(M,{columnGap:2,height:"auto",children:[e.jsxs(Ie,{width:c!=null&&c.useIssuePerFolder?"50%":"100%",isRequired:!0,children:[e.jsx(Re,{children:"Commit Message"}),e.jsx(Vs,{placeholder:"Enter Commit Message",height:"76%",resize:"none",onInput:F,value:i})]}),c!=null&&c.useIssuePerFolder?o!=null&&o.value?e.jsx(M,{width:"50%",flexDir:"column",rowGap:2,children:g.map(k=>e.jsx(He,{branchFolder:k},k))}):e.jsx(C,{width:"50%",textAlign:"center",m:"auto",children:e.jsx(P,{fontSize:"lg",fontWeight:"600",color:"yellow.500",children:"Please select source branch first!"})}):null]})]}),e.jsx(C,{pt:8,children:e.jsx(v,{label:"Auto Fill Message",hasArrow:!0,children:e.jsx(H,{colorScheme:"yellow","aria-label":"Auto Fill Message",size:"md",onClick:()=>s(),icon:e.jsx(Xe,{})})})})]})})}function bt({openCommitModal:s}){const{setShowCommitView:o,selectedLocalChanges:a,sourceBranch:n,issueNumber:r,commitMessage:i,setSocketPayload:l,configurableRowData:d,selectedBranches:u}=L(),{RaiseClientNotificaiton:c}=ne(),h=Ae(),{selectedBranchFolders:g}=Le(),w=t.useCallback(()=>{o(!1)},[o]),F=t.useCallback(()=>{if(!n||n.value===""){c("Please select the source branch to proceed!","error");return}const k=d.find(y=>y.id==n.value),b=h!=null&&h.useIssuePerFolder?g.every(y=>r[y]&&r[y]!==""):!0,p=h!=null&&h.useIssuePerFolder&&!u.some(y=>y["Branch Folder"]===k["Branch Folder"])||r[k["Branch Folder"]];if(!r||G.isEmpty(r)||!b||!p){c("Please provide the issue number to proceed!","error");return}if(!i||i.trim()===""){c("Please provide the commit message to proceed!","error");return}l({sourceBranch:k,issueNumber:r,commitMessage:i,filesToProcess:a}),s()},[c,n,d,h,g,r,u,i,a]);return e.jsx(C,{children:e.jsxs(M,{columnGap:2,justifyContent:"center",children:[e.jsx(E,{onClick:w,leftIcon:e.jsx(Be,{}),colorScheme:"yellow",children:"Refresh Process"}),e.jsx(v,{label:"Select at least 1 file",hasArrow:!0,isDisabled:a.length>0,children:e.jsxs(E,{onClick:F,leftIcon:e.jsx(J,{as:Qe}),colorScheme:"yellow",isDisabled:a.length<1,children:["Commit ",a.length>0?`${a.length} File`:"",a.length>1?"s":""]})})]})})}function pt(){const{selectedBranches:s,logData:o,setLogData:a}=L(),[n,r]=t.useState([]),[i,l]=t.useState(""),d=t.useCallback(h=>{l(h.target.value)},[l]),u=t.useCallback(()=>{a([])},[a]),c=o.length===s.length;return t.useEffect(()=>{if(o.length===0)return;const h=o.map(g=>g.logs).flat();r(g=>G.isEqual(g,h)?g:h)},[o]),{rowDataLogs:n,quickFilterLogsText:i,setQuickFilterLogsText:l,onQuickFilterLogsInputChanged:d,refreshLogs:u,areLogsFetched:c}}function Ct({rowDataLogs:s,quickFilterLogsText:o,setAutoFillSelection:a=null,isAutofill:n=!1}){const r=t.useMemo(()=>({sortable:!0,resizable:!1,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),i=t.useMemo(()=>{const u=[{field:"revision",headerName:"Revision",sort:"desc",width:130},{field:"date",headerName:"Date",sortable:!1},{field:"branchFolder",headerName:"Branch Folder",width:135},{field:"branchVersion",headerName:"Branch Version",width:125},{field:"author",headerName:"Author"},{field:"message",headerName:"Message",flex:1}];return n?[{checkboxSelection:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},...u]:u},[n]),l=t.useRef(null),d=t.useCallback(()=>{var u,c;if(a){const h=(c=(u=l==null?void 0:l.current)==null?void 0:u.api)==null?void 0:c.getSelectedNodes().map(g=>g.data);a(h[0]||null)}},[a]);return e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:n?"90%":"85%",width:"100%"},children:e.jsx(de,{ref:l,rowData:s,defaultColDef:r,columnDefs:i,onSelectionChanged:d,quickFilterText:o,domLayout:"normal",columnMenu:"new",rowSelection:"single",suppressRowClickSelection:!n,animateRows:!1,immutableData:!0,suppressFlash:!0,enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!0,paginationAutoPageSize:!0})})}function as({setAutoFillSelection:s=!1,isAutofill:o=!1}){const{selectedBranches:a,logData:n}=L(),{rowDataLogs:r,quickFilterLogsText:i,onQuickFilterLogsInputChanged:l,refreshLogs:d,areLogsFetched:u}=pt();return u?e.jsxs(C,{h:"100%",children:[e.jsxs(M,{mb:4,width:"100%",alignItems:"center",columnGap:4,children:[e.jsxs(M,{alignItems:"center",width:"100%",children:[e.jsx(P,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:l,width:"100%"})]}),e.jsx(C,{children:e.jsx(v,{label:"Refresh",hasArrow:!0,children:e.jsx(H,{onClick:d,icon:e.jsx(Be,{}),colorScheme:"yellow","aria-label":"Refresh"})})})]}),e.jsx(Ct,{rowDataLogs:r,quickFilterLogsText:i,setAutoFillSelection:s,isAutofill:o})]}):e.jsxs(C,{children:[e.jsxs(C,{mb:4,children:[e.jsx(P,{fontWeight:600,children:"Showing SVN Log for the following branches:"}),e.jsx(Fe,{spacing:3,children:a.map(c=>{const h=n.find(g=>g.id===c.id);return e.jsxs(ae,{display:"flex",alignItems:"center",children:[e.jsx(oe,{w:30,h:30,as:h?re:Es,color:"yellow.500"}),ke(c["Branch Folder"],c["Branch Version"],c["SVN Branch"])]},c.branchId)})})]}),e.jsx(M,{justifyContent:"center",children:e.jsx(Ps,{value:n.length/a.length*360,color:"yellow.300",size:"100px",children:e.jsxs(zs,{children:[n.length," / ",a.length]})})})]})}function wt(s){const{data:o}=s,a=async()=>{window.open(o.url,"_blank")};return e.jsx(H,{"aria-label":"Diff",size:"sm",icon:e.jsx(Os,{}),onClick:a,colorScheme:"yellow"})}function jt({rowDataTrello:s,quickFilterTrelloText:o,setAutoFillSelection:a}){const n=t.useMemo(()=>({sortable:!0,resizable:!1,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),r=t.useMemo(()=>[{checkboxSelection:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{field:"name",headerName:"Name",flex:1},{field:"lastActivityDate",headerName:"Last Activity Date"},{field:"url",headerName:"Goto Trello",filter:!1,sortable:!1,resizable:!1,cellRenderer:wt,width:120}],[]),i=t.useRef(null),l=t.useCallback(()=>{var u,c;const d=(c=(u=i==null?void 0:i.current)==null?void 0:u.api)==null?void 0:c.getSelectedNodes().map(h=>h.data);a(d[0]||null)},[a]);return e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"80%",width:"100%"},children:e.jsx(de,{ref:i,rowData:s,defaultColDef:n,columnDefs:r,onSelectionChanged:l,quickFilterText:o,domLayout:"normal",columnMenu:"new",rowSelection:"single",suppressRowClickSelection:!1,animateRows:!1,enableCellTextSelection:!0,pagination:!0,paginationAutoPageSize:!0})})}function St({setAutoFillSelection:s}){const{socket:o}=L(),{key:a,token:n,isTrelloIntegrationEnabled:r,emitTrelloCardNamesSearch:i}=ls(),[l,d]=t.useState(""),[u,c]=t.useState(""),[h,g]=t.useState([]),w=t.useCallback(G.debounce(p=>{p.trim()!==""&&i(a,n,p)},400),[a,n,i]),F=t.useCallback(p=>{d(String(p.target.value).trim())},[d]),k=t.useCallback(()=>{l.trim()!==""&&i(a,n,l)},[l,a,n,i]),b=t.useCallback(p=>{c(p.target.value)},[]);return t.useEffect(()=>(w(l),()=>w.cancel()),[l,w]),t.useEffect(()=>{const p=y=>{g(y&&y.length>0?y:[])};return o==null||o.on("trello-result-search-names-card",p),()=>o==null?void 0:o.off("trello-result-search-names-card",p)},[o]),r?e.jsxs(C,{h:"100%",children:[e.jsxs(M,{mb:4,width:"100%",alignItems:"center",columnGap:4,children:[e.jsxs(M,{alignItems:"center",width:"100%",children:[e.jsx(P,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Trello Query:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:F,width:"100%"})]}),e.jsx(C,{children:e.jsx(v,{label:"Resubmit Query",hasArrow:!0,children:e.jsx(H,{onClick:k,icon:e.jsx(Be,{}),colorScheme:"yellow","aria-label":"Resubmit"})})})]}),e.jsx(M,{mb:4,width:"100%",alignItems:"center",columnGap:4,children:e.jsxs(M,{alignItems:"center",width:"100%",children:[e.jsx(P,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:b,width:"100%"})]})}),e.jsx(jt,{rowDataTrello:h,quickFilterTrelloText:u,setAutoFillSelection:s})]}):e.jsx(C,{h:"100%",p:4,children:e.jsxs(P,{fontSize:"lg",fontWeight:"600",color:"red.500",children:["You need to"," ",e.jsxs(qe,{href:"https://help.merge.dev/en/articles/8757597-trello-how-do-i-link-my-account",isExternal:!0,color:"yellow.500",children:["set up Trello Integration ",e.jsx(Xe,{mx:"2px"})]})," ","in the configuration file to use this feature."]})})}function Bt({isModalOpen:s,closeModal:o}){const{setSourceBranch:a,branchOptions:n,setIssueNumber:r,setCommitMessage:i,setPostCommitData:l}=L(),{getBranchFolderById:d}=Le(),[u,c]=t.useState(0),[h,g]=t.useState([null,null]),[w,F]=t.useState(!0),k=t.useCallback(j=>{c(j),g(j===0?m=>[m[0],null]:m=>[null,m[1]])},[c]),b=t.useCallback(j=>{g(m=>[j,...m.slice(1)])},[g]),p=t.useCallback(j=>{g(m=>[m[0],j])},[g]),y=t.useCallback(()=>{console.debug("Selected tab index:",u),console.debug("Selected autofill selection:",JSON.stringify(h,null,4));let j=h[u];if(u===0){const m=j.message,S=j.branchId,D=m.match(/\s*(Issue)*\s*(\d+)\s*/),A=D?D[2]:null,z=m.replace(/\s*(Issue)*\s*(\d+)?\s*(\([^\)]+\))*\s?:?\s*/,"");S&&a(n.find(T=>T.value===S)),A&&r(T=>({...T,[d(j.branchId)]:A})),z.trim()!==""&&i(z)}else{const m=j.name,S=m.match(/\s*(Issue)*\s*(\d+)\s*/),D=S?S[2]:null,A=m.replace(/\s*(Issue)*\s*(\d+)/,"");D&&r(z=>Object.fromEntries(Object.keys(z).map(T=>[T,D]))),A.trim()!==""&&i(A),l({type:"trello",data:j})}o()},[u,h,o]);return t.useEffect(()=>{F(!(h.length==2&&(h[0]||h[1])))},[h]),t.useEffect(()=>{g([null,null]),c(0)},[s]),e.jsxs(Ye,{isOpen:s,onClose:o,isCentered:!0,motionPreset:"slideInBottom",scrollBehavior:"inside",size:"xl",closeOnOverlayClick:!0,children:[e.jsx(be,{}),e.jsxs(Ke,{maxH:"95%",maxW:"95%",children:[e.jsx(pe,{children:e.jsx(X,{as:"h2",size:"lg",children:"Autofill Commit Message"})}),e.jsx(ye,{size:"lg"}),e.jsx(Ce,{children:e.jsx(C,{height:"70vh",children:e.jsxs(Ze,{variant:"solid-rounded",colorScheme:"yellow",defaultIndex:0,isLazy:!0,h:"100%",onChange:j=>k(j),children:[e.jsxs(es,{children:[e.jsx(ge,{children:"SVN Logs"}),e.jsx(ge,{children:"Trello"})]}),e.jsxs(ss,{h:"90%",children:[e.jsx(xe,{px:0,pb:0,h:"100%",children:e.jsx(as,{setAutoFillSelection:b,isAutofill:!0})}),e.jsx(xe,{px:0,pb:0,h:"100%",children:e.jsx(St,{setAutoFillSelection:p})})]})]})})}),e.jsxs(Se,{children:[e.jsx(E,{mr:3,onClick:()=>o(),children:"Cancel"}),e.jsx(v,{hasArrow:!0,label:"Please select exactly one row!",placement:"top-start",isDisabled:!w,children:e.jsx(E,{colorScheme:"yellow",onClick:y,isDisabled:w,children:"Select"})})]})]})]})}function yt(){const{config:s,updateConfig:o}=L(),[a,n]=t.useState({}),r=t.useCallback((i,l)=>{n(d=>({...d,[i]:l}))},[n]);return t.useEffect(()=>{!s||G.isEmpty(s)||(s.commitOptions?n(s.commitOptions):o(i=>({...i,commitOptions:{useIssuePerFolder:!1,reusePreviousCommitMessage:!1}})))},[s]),t.useEffect(()=>{G.isEmpty(a)||o(i=>G.isEqual(i.commitOptions,a)?i:{...i,commitOptions:a})},[a]),e.jsxs(C,{mb:4,children:[e.jsx(X,{as:"h6",size:"sm",children:"Commit Options"}),e.jsx(Je,{colorScheme:"yellow",children:e.jsxs(Us,{direction:"row",spacing:4,mt:2,children:[e.jsx(te,{isChecked:a.useIssuePerFolder,onChange:i=>r("useIssuePerFolder",i.target.checked),children:e.jsx(v,{label:"This option is for users who would like to apply different issue numbers for different branch folders. Toggling this option will clear the issue number!",hasArrow:!0,placement:"bottom-end",children:"Use 1 Issue Per Folder?"})}),e.jsx(te,{isChecked:a.reusePreviousCommitMessage,onChange:i=>r("reusePreviousCommitMessage",i.target.checked),children:e.jsx(v,{label:"Toggling this option will clear the commit message!",hasArrow:!0,children:"Reuse Previous Commit Message?"})})]})})]})}function kt(){const{isDebug:s,setIsCommitMode:o,selectedBranchStatuses:a,showCommitView:n,setShowCommitView:r,selectedBranches:i,configurableRowData:l}=L(),[d,u]=t.useState({}),[c,h]=t.useState([]),[g,w]=t.useState([]),{isOpen:F,onOpen:k,onClose:b}=Te(),{isOpen:p,onOpen:y,onClose:j}=Te(),m=t.useMemo(()=>({resizable:!0,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]);t.useEffect(()=>{if(i.length<1||n){i.length<1&&o(!1);return}u({})},[i,n]),t.useEffect(()=>{s&&(console.debug("Branch Status Rows:",a),console.debug("Selected Rows:",i))},[s,a,i]),t.useEffect(()=>{a.length===i.length&&(a.forEach(T=>{let N=T.id,U=T.status.filesToCommit,$=T.status.filesToUpdate;const I=l.find(O=>O.id===N);if($.length>0){const O=ke(I["Branch Folder"],I["Branch Version"],I["SVN Branch"]);u(W=>({...W,[O]:[...W[O]||[],...$]}))}if(U.length>0){const O=U.map(W=>({branchId:N,"Branch Folder":I["Branch Folder"],"Branch Version":I["Branch Version"],"SVN Branch":I["SVN Branch"],"Full Path":W.path,"File Path":`${tt(T.status.branch)}\\${W.pathDisplay}`,"Local Status":W.wcStatus}));h(W=>[...W,...O.filter(Y=>!["unversioned","missing"].includes(Y["Local Status"]))]),w(W=>[...W,...O.filter(Y=>["unversioned","missing"].includes(Y["Local Status"]))])}}),r(!0))},[a,i,l]);const S=Object.keys(d).length>0,D=c.length>0,A=g.length>0,z=S||D||A;return e.jsxs(C,{children:[e.jsx(yt,{}),e.jsx(C,{mb:6,children:e.jsx(xt,{openMessageAutoFillModal:y})}),e.jsx(Ws,{isLoaded:n&&z,startColor:"yelow.500",endColor:"yellow.500",children:e.jsxs(Ze,{variant:"solid-rounded",colorScheme:"yellow",defaultIndex:S?0:D?1:2,isLazy:!1,children:[e.jsxs(es,{children:[e.jsx(ge,{isDisabled:!S,children:e.jsx(v,{label:"No files to update!",hasArrow:!0,isDisabled:S,children:"Files to Update"})}),e.jsx(ge,{isDisabled:!D,children:e.jsx(v,{label:"No files to commit!",hasArrow:!0,isDisabled:D,children:"Local Changes"})}),e.jsx(ge,{isDisabled:!A,children:e.jsx(v,{label:"No unversioned/missing files!",hasArrow:!0,isDisabled:A,children:"Untracked Changes"})})]}),e.jsxs(ss,{children:[e.jsx(xe,{px:0,children:e.jsx(ft,{fileUpdates:d})}),e.jsx(xe,{px:0,children:e.jsx(mt,{rowDataLocalChanges:c,setRowDataLocalChanges:h,defaultColDefsCommit:m})}),e.jsx(xe,{px:0,children:e.jsx(gt,{rowDataUntrackedChanges:g,setRowDataUntrackedChanges:w,defaultColDefsCommit:m})})]})]})}),n&&!z?e.jsxs(P,{mt:4,className:"animation-pulse",fontWeight:600,textAlign:"center",children:["No changes have been spotted!",e.jsx("br",{}),"Please use the refresh button 👇 if you have recently made a change"]}):e.jsx(e.Fragment,{}),e.jsx(C,{mt:6,children:e.jsx(bt,{openCommitModal:k})}),e.jsx(ut,{isModalOpen:F,closeModal:b}),e.jsx(Bt,{isModalOpen:p,closeModal:j})]})}function Dt(){const{showSelectedBranchesLog:s,setShowSelectedBranchesLog:o}=L();return e.jsxs(Hs,{isOpen:s,onClose:()=>o(!1),placement:"left",size:"full",children:[e.jsx(be,{}),e.jsxs($s,{children:[e.jsx(ye,{size:"lg"}),e.jsx(pe,{children:"Selected Branches: SVN Log"}),e.jsx(Ce,{children:e.jsx(C,{height:"100%",children:e.jsx(as,{})})})]})]})}function vt(){const{toast:s,RaiseClientNotificaiton:o}=ne(),{isOpen:a,onOpen:n,onClose:r}=Te(),i=t.useRef(),[l,d]=t.useState(!1);t.useEffect(()=>{if(!window.electron){o("Electron context is not available. Updates cannot be checked.","warning",5e3);return}return window.electron.on("update-available",()=>{s.closeAll(),n()}),window.electron.on("update-error",h=>{o(`An error occurred while checking for updates: ${h}`,"error",5e3),d(!1)}),()=>{window.electron.removeAllListeners("update-available"),window.electron.removeAllListeners("update-error")}},[s,n]);const u=t.useCallback(()=>{r(),o("You may update the application later by manually triggering an update check or wait until Titan does this","info",5e3)},[r,o]),c=t.useCallback(()=>{if(l){o("Update is already in progress. Please wait.","info",5e3);return}window.electron?(d(!0),window.electron.downloadUpdate().catch(h=>{d(!1),o(`An error occurred while downloading the update: ${h}`,"error",5e3)}),window.electron.on("update-downloaded",()=>{o("Update has been downloaded successfully. Titan will now restart to apply the update.","info",5e3),window.electron.removeAllListeners("update-downloaded"),r()}),window.electron.on("update-not-available",()=>{o("Titan is up to date","info",3e3),window.electron.removeAllListeners("update-not-available"),d(!1),r()})):o("Cannot update Titan in a non-desktop application environment","error",5e3)},[l,o,d,r]);return e.jsx(_e,{isOpen:a,leastDestructiveRef:i,onClose:r,motionPreset:"slideInBottom",closeOnOverlayClick:!l,children:e.jsx(be,{children:e.jsxs(Ge,{children:[e.jsx(pe,{fontSize:"lg",fontWeight:"bold",children:"Update Available"}),l?e.jsx(e.Fragment,{}):e.jsx(ye,{}),e.jsx(Ce,{children:"A new version of Titan is available. Would you like to download and install the update?"}),e.jsxs(Se,{children:[e.jsx(E,{colorScheme:"red",ref:i,onClick:u,isDisabled:l,children:"Cancel"}),e.jsx(E,{colorScheme:"yellow",onClick:c,ml:3,isDisabled:l,children:"Confirm"})]})]})})})}function Ft(){if(!window.electron)return e.jsx(e.Fragment,{});const s=t.useCallback(()=>{window.electron.minimizeWindow()},[]),o=t.useCallback(()=>{window.electron.maximizeWindow()},[]),a=t.useCallback(()=>{window.electron.closeWindow()},[]);return e.jsx(qs.header,{w:"100%",position:"fixed",bgColor:"#121212",className:"titanHead",zIndex:9999999,top:0,children:e.jsxs(M,{justifyContent:"space-between",alignItems:"center",p:2,position:"static",children:[e.jsx(X,{as:"h6",size:"sm",noOfLines:1,className:"animation-fadein-left-forward",children:"Titan"}),e.jsxs(M,{alignItems:"center",columnGap:2,flexWrap:"nowrap",wrap:"nowrap",children:[e.jsx(H,{"aria-label":"Minimize",size:"xs",icon:e.jsx(_s,{}),onClick:s,colorScheme:"gray",_hover:{bg:"#FAF089",color:"#1A202C"}}),e.jsx(H,{"aria-label":"Maximize",size:"xs",icon:e.jsx(Gs,{}),onClick:o,colorScheme:"gray",_hover:{bg:"#FAF089",color:"#1A202C"}}),e.jsx(H,{"aria-label":"Close",size:"xs",icon:e.jsx(ve,{}),onClick:a,colorScheme:"gray",_hover:{bg:"#FEB2B2",color:"#1A202C"}})]})]})})}function It(){const{isCommitMode:s,selectedBranches:o,configurableRowData:a}=L(),{RaiseClientNotificaiton:n}=ne();return t.useEffect(()=>{if(window.electron)return window.electron.onAppClosing(()=>{n("App is closing, performing cleanup...","info",0),window.electron.closeWindow()}),()=>{window.electron.removeAppClosingListener()};console.warn("Electron specific logic is not available in browser mode.")},[]),e.jsxs(C,{className:"titanBody",children:[e.jsx(Ft,{}),e.jsxs(C,{p:10,children:[e.jsx(ot,{}),e.jsx(vt,{}),e.jsxs(M,{rowGap:4,flexDirection:"column",children:[e.jsx(C,{children:e.jsx(ht,{})}),e.jsx(Qs,{in:s,animateOpacity:!0,children:e.jsxs(C,{id:"sectionCommit",children:[e.jsxs(X,{as:"h2",size:"lg",noOfLines:1,mb:4,className:"animation-pulse",children:["Committing ",o.length==a.length?"All":`${o.length}/${a.length}`," Branch",o.length==1?"":"es"]}),e.jsx(kt,{})]})})]}),e.jsx(Dt,{})]})]})}const{definePartsStyle:os,defineMultiStyleConfig:rs}=Zs(et.keys),Rt=os({overlay:{bg:"blackAlpha.900"},dialog:{bg:"gray.900",color:"white",boxShadow:"rgba(255, 255, 255, 0.07) 0px -20px 20px 20px"},header:{bg:"gray.900",color:"white",borderRadius:"20px",p:4},body:{p:4,color:"white"},footer:{bg:"gray.900",p:4,color:"white",borderRadius:"20px"}}),Tt=rs({baseStyle:Rt}),Nt=os({overlay:{bg:"blackAlpha.900"},dialog:{mt:lt,bg:"gray.900",color:"white",boxShadow:"rgba(255, 255, 255, 0.07) 0px -20px 20px 20px"},header:{bg:"gray.900",color:"white",borderRadius:"20px",p:4},body:{p:4,color:"white"},footer:{bg:"gray.900",p:2,color:"white",borderRadius:"20px"}}),Mt=rs({baseStyle:Nt}),At={initialColorMode:"dark",useSystemColorMode:!1},$e=Ys({config:At,components:{Modal:Tt,Drawer:Mt}});Ks.createRoot(document.getElementById("root")).render(e.jsx(Ne.StrictMode,{children:e.jsxs(Js,{theme:$e,children:[e.jsx(Xs,{initialColorMode:$e.config.initialColorMode}),e.jsx(at,{children:e.jsx(It,{})})]})})); +`,le=b.sort((_,S)=>_["Branch Version"].localeCompare(S["Branch Version"])).map(_=>{const S=[];f.includes("BranchFolder")&&S.push(_["Branch Folder"]),f.includes("BranchVersion")&&S.push(_["Branch Version"]),f.includes("SVNBranch")&&S.push(_.branchPathFolder);let L=S.join(" ").trim();if(f.includes("IssueNumber")){const me=_.branchIssueNumber;L+=` Issue [${me}]`}const M=_.revision?_.revision:_.errorMessage||"Error";return L+=` Revision [${M}]`,L});return R?le.join(fe):le},[b,n]),ee=t.useCallback(f=>{const R=K(f);j(R)},[K,j]),se=t.useCallback(()=>{U(f=>f-1)},[U]),ue=t.useCallback(()=>{if(d.type!=="trello"){x("Trello Autofill is not enabled for this commit","error");return}const f=d.data,R=K(["BranchFolder","BranchVersion","IssueNumber"],!1);k(g,C,f,R),x("Updating Trello card with commit information","info"),u(null)},[d,x,K]),B=t.useCallback(()=>{U(f=>{switch(f){case 1:h(n);case 2:j(""),N("");break;case 3:return w(),x("Updating selected branches! Please wait","info",1500),b.forEach(R=>{c(R.branchId,R["SVN Branch"],R["Branch Version"],R["Branch Folder"])}),l(!1),r([]),i(!1),a(),1}return f+1})},[U,h,n,j,N,w,x,b,c,l,r,i,a]);return t.useEffect(()=>{U(1),y([]),j(""),N("")},[s,y]),t.useEffect(()=>{!s||I!=0||(a(),U(1),y([]),j(""),N(""))},[I,s]),t.useEffect(()=>{!s||I!=3||(x("The commit process has been completed successfully","success",5e3),ee(["BranchFolder","BranchVersion","SVNBranch"]),N(n.commitMessage||""))},[x,I,s,ee]),t.useEffect(()=>{const f=R=>{y(Q=>[...Q,R])};return o==null||o.on("svn-commit-status-live",f),()=>o==null?void 0:o.off("svn-commit-status-live",f)},[o]),t.useEffect(()=>{if(I!=2)return;const f=setTimeout(()=>{b.length>0&&b[0].bulkCommitLength==b.length&&U(3)},3e3);return()=>clearTimeout(f)},[I,b]),t.useEffect(()=>{(D||T)&&x("Copied to Clipboard","success",1500)},[D,T,x]),!s||!n?e.jsx(e.Fragment,{}):e.jsxs(Ke,{isOpen:s,onClose:a,isCentered:!0,motionPreset:"slideInBottom",scrollBehavior:"inside",size:"xl",closeOnOverlayClick:I==1,children:[e.jsx(pe,{}),e.jsxs(Je,{maxH:"85%",maxW:"95%",children:[e.jsxs(Ce,{display:"flex",justifyContent:"space-between",maxWidth:I==1?"94%":"100%",children:[e.jsx(Z,{as:"h2",size:"lg",children:"Commit Selected Files"}),e.jsx(Bs,{index:I-1,mb:0,size:"sm",colorScheme:"yellow",children:q.map((f,R)=>e.jsxs(ys,{children:[e.jsx(ks,{children:e.jsx(Ds,{complete:e.jsx(vs,{}),incomplete:e.jsx(Ue,{}),active:e.jsx(Ue,{})})}),e.jsx(p,{flexShrink:"0",children:e.jsx(Fs,{children:f.title})}),e.jsx(Is,{})]},R))})]}),I==1?e.jsx(ke,{size:"lg",py:6}):e.jsx(e.Fragment,{}),e.jsx(we,{children:e.jsxs(p,{children:[I!=1?e.jsx(e.Fragment,{}):e.jsxs(p,{children:[e.jsxs(p,{mb:4,children:[e.jsx(O,{fontWeight:600,children:"Please confirm that the following information is correct before proceeding to commit your files:"}),e.jsxs(Re,{spacing:3,children:[e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Source Branch: ",e.jsx(te,{children:De(n.sourceBranch["Branch Folder"],n.sourceBranch["Branch Version"],n.sourceBranch["SVN Branch"])})]}),e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Issue Numbers: ",e.jsx(te,{children:Object.entries(n.issueNumber).map(f=>`${f[1]} (${f[0]})`).join(", ")})]}),e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Commit Message: ",e.jsx(te,{children:n.commitMessage})]}),e.jsxs(ae,{children:[e.jsx(oe,{as:re,color:"yellow.500"}),"Example:"," ",e.jsxs(te,{children:["Issue ",n.issueNumber[n.sourceBranch["Branch Folder"]]," (",n.sourceBranch["Branch Folder"]," ",n.sourceBranch["Branch Version"],"): ",n.commitMessage]})]})]})]}),e.jsx(p,{children:e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"350px",width:"100%"},children:e.jsx(de,{rowData:n.filesToProcess,defaultColDef:H,columnDefs:Y,domLayout:"normal",columnMenu:"new",pagination:!0,paginationAutoPageSize:!0})})})]}),I!=2?e.jsx(e.Fragment,{}):e.jsxs(p,{children:[e.jsxs(O,{fontWeight:600,children:["Please wait while the files are being committed to the SVN repository.",e.jsx("br",{}),"Current live status of the commit process:"]}),e.jsx(p,{children:e.jsx(Re,{spacing:3,children:b.map((f,R)=>e.jsxs(ae,{children:[e.jsx(oe,{as:f.errorMessage?Rs:re,color:f.errorMessage?"red.500":"yellow.500"}),f.branchString,": ",e.jsx(te,{children:f.errorMessage||f.revision})]},R))})})]}),I!=3?e.jsx(e.Fragment,{}):e.jsxs(p,{children:[e.jsx(p,{mb:4,children:e.jsxs(O,{fontWeight:600,children:["The commit process has been completed successfully.",e.jsx("br",{}),"Please find your revisions here for view and copy:"]})}),e.jsxs(A,{columnGap:10,alignItems:"center",children:[e.jsxs(p,{children:[e.jsx(Z,{as:"h3",size:"md",children:"SVN Revisions"}),e.jsx(p,{children:e.jsx("pre",{style:{whiteSpace:"pre-wrap",wordWrap:"break-word"},children:m})})]}),e.jsx(p,{children:e.jsx(v,{hasArrow:!0,label:"Copy to clipboard",children:e.jsx($,{"aria-label":"Copy To Clipboard",onClick:w,icon:e.jsx(Fe,{}),colorScheme:"yellow"})})})]}),e.jsxs(p,{my:4,children:[e.jsx(O,{fontWeight:600,children:"Modify the clipboard text to include..."}),e.jsx(Xe,{colorScheme:"yellow",defaultValue:["BranchFolder","BranchVersion"],onChange:ee,children:e.jsxs(Le,{children:[e.jsx(J,{value:"BranchFolder",children:"Branch Folder"}),e.jsx(J,{value:"BranchVersion",children:"Branch Version"}),e.jsx(J,{value:"SVNBranch",children:"SVN Branch"}),e.jsx(J,{value:"IssueNumber",children:"Issue Number"}),e.jsx(J,{value:"MarkupSupport",children:"Markup Support"})]})})]}),e.jsxs(A,{columnGap:10,alignItems:"center",children:[e.jsxs(p,{children:[e.jsx(O,{fontWeight:600,children:"Here is your SVN commit message for the source branch:"}),n.sourceBranch&&n.sourceBranch["Branch Folder"]&&n.sourceBranch["Branch Version"]?e.jsx(te,{children:`Issue ${n.issueNumber[n.sourceBranch["Branch Folder"]]} (${n.sourceBranch["Branch Folder"]} ${n.sourceBranch["Branch Version"]}): ${z}`}):e.jsx(te,{children:"Source information is undefined. Please check that you have entered the correct details otherwise contact the developer!"})]}),e.jsx(v,{hasArrow:!0,label:"Copy to clipboard",children:e.jsx($,{"aria-label":"Copy To Clipboard",onClick:V,icon:e.jsx(Fe,{}),colorScheme:"yellow"})})]})]})]})}),e.jsx(Be,{children:e.jsxs(A,{flex:1,justifyContent:"space-between",children:[e.jsx(A,{columnGap:2,children:e.jsx(v,{hasArrow:!0,label:"Cannot undo the commit currently",isDisabled:I<2,children:e.jsx(P,{onClick:se,mr:3,isDisabled:I>=2,children:I==1?"Cancel":"Previous"})})}),e.jsxs(A,{columnGap:2,children:[e.jsx(v,{hasArrow:!0,label:"Requires Trello Autofill",isDisabled:(d==null?void 0:d.type)==="trello"&&F,children:e.jsx(P,{colorScheme:"yellow",leftIcon:e.jsx(X,{as:Ns}),onClick:ue,isDisabled:I<3||(d==null?void 0:d.type)!="trello"||!F,children:"Update Card"})}),e.jsx(v,{hasArrow:!0,label:"Cannot undo the commit currently",isDisabled:I!=2,children:e.jsx(P,{colorScheme:"yellow",onClick:B,isDisabled:I==2,children:I==q.length?"Complete":"Next"})})]})]})})]})]})}function ft({fileUpdates:s}){return e.jsx(p,{children:Object.keys(s).length>0?e.jsxs(p,{children:[e.jsx(O,{mb:4,children:"Below are the list of files which have been changed on your machine but there exists a newer version of them in the repository:"}),e.jsx(p,{maxHeight:"200px",overflowY:"auto",children:e.jsxs(Ts,{children:[e.jsx(Ms,{children:e.jsxs(We,{children:[e.jsx(je,{children:"Branch"}),e.jsx(je,{children:"Path"}),e.jsx(je,{children:e.jsx(v,{label:"Working Copy",hasArrow:!0,children:"Local Status"})}),e.jsx(je,{children:e.jsx(v,{label:"Repository",hasArrow:!0,children:"Remote Status"})})]})}),e.jsx(As,{children:Object.keys(s).map(a=>e.jsx(Ae.Fragment,{children:s[a].map((o,l)=>e.jsxs(We,{children:[e.jsx(Se,{children:a}),e.jsx(Se,{children:o.pathDisplay}),e.jsx(Se,{children:o.wcStatus}),e.jsx(Se,{children:o.reposStatus})]},l))},a))})]})}),e.jsx(O,{mt:4,children:"If you wish to commit these files, please update the associated branches!"})]}):e.jsx(p,{children:e.jsx(O,{children:"Your selected branches do not contain any changed files for which a newer version exists in the repository."})})})}function mt({rowDataLocalChanges:s,setRowDataLocalChanges:a,defaultColDefsCommit:o}){const{localChangesGridRef:l,isDebug:r,selectedBranches:i,showCommitView:n,setSelectedLocalChanges:d,selectedLocalChanges:u}=E(),{emitFilesRevert:c}=he(),{RaiseClientNotificaiton:h}=ne(),[g,C]=t.useState(""),F=t.useCallback(()=>{c(u)},[c,u]),k=t.useCallback(w=>{C(w.target.value)},[C]),x=t.useCallback(w=>{var D,V,z,N;if(console.debug("PanelLocalChanges.jsx: onFileViewSelectionChanged - event",w),String(w==null?void 0:w.source).toLowerCase().includes("api"))return;let m=(V=(D=l==null?void 0:l.current)==null?void 0:D.api)==null?void 0:V.getSelectedNodes().map(T=>T.data);r&&console.debug("PanelLocalChanges.jsx: onFileViewSelectionChanged - selectedBranches",m);const j=m.filter(T=>T["Local Status"].toLowerCase()==="added");(N=(z=l==null?void 0:l.current)==null?void 0:z.api)==null||N.forEachNode(T=>{j.some(q=>q["File Path"].includes(T.data["File Path"])&&q["File Path"]!==T.data["File Path"])&&T.data["Local Status"].toLowerCase()==="added"&&!T.isSelected()&&(T.setSelected(!0),m.push(T.data),console.debug("PanelLocalChanges.jsx (onFileViewSelectionChanged): Adding ancestor node: ",T))}),d(m)},[l,r,d]),b=t.useCallback(w=>{w.success?h("TortoiseSVN diff opened successfully","success",3e3):h(`Error opening TortoiseSVN diff: ${JSON.stringify(w.error,null,4)}`,"error",0)},[h]),y=t.useMemo(()=>[{headerCheckboxSelection:!0,checkboxSelection:!0,headerCheckboxSelectionFilteredOnly:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{field:"Branch Folder"},{field:"Branch Version",sort:"asc",sortIndex:0},{field:"File Path",flex:1,sort:"asc",sortIndex:2},{field:"Local Status",headerTooltip:"Working Copy",sort:"asc",sortIndex:1},{headerName:"Diff",filter:!1,sortable:!1,resizable:!1,cellRenderer:ls,cellRendererParams:{onDiffResult:b},width:90}],[]);return t.useEffect(()=>{i.length<1||n||(C(""),a([]),d([]))},[i,n]),e.jsx(p,{children:s.length>0?e.jsxs(p,{children:[e.jsxs(A,{mb:4,alignItems:"center",children:[e.jsx(O,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:k,width:"100%"})]}),e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"480px",width:"100%"},children:e.jsx(de,{ref:l,rowData:s,defaultColDef:o,columnDefs:y,onSelectionChanged:x,quickFilterText:g,domLayout:"normal",rowSelection:"multiple",suppressRowClickSelection:!0,rowMultiSelectWithClick:!0,animateRows:!0,columnMenu:"new",enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!0,paginationAutoPageSize:!0})}),e.jsx(A,{mt:4,columnGap:2,justifyContent:"flex-end",children:e.jsx(v,{label:"Requires you to select at least 1 file",hasArrow:!0,isDisabled:u.length>0,children:e.jsx(P,{onClick:F,colorScheme:"red",isDisabled:u.length<1,children:"Revert Selected"})})})]}):e.jsx(p,{children:e.jsx(O,{children:"Your selected branches do not contain any files to commit."})})})}function gt({rowDataUntrackedChanges:s,setRowDataUntrackedChanges:a,defaultColDefsCommit:o}){const{untrackedChangesGridRef:l,selectedUntrackedChanges:r,setSelectedUntrackedChanges:i,isDebug:n,selectedBranches:d,showCommitView:u}=E(),{emitFilesAddRemove:c,emitFilesRevert:h}=he(),[g,C]=t.useState(""),F=t.useCallback(w=>{C(w.target.value)},[C]),k=t.useCallback(()=>{var m,j;const w=(j=(m=l==null?void 0:l.current)==null?void 0:m.api)==null?void 0:j.getSelectedNodes().map(D=>D.data);n&&console.debug("PanelUntrackedChanges.jsx (onUnseenFilesSelectionChanged): selectedBranches",w),i(w)},[l,n]),x=t.useCallback(()=>{c(r)},[c,r]),b=t.useCallback(()=>{h(r)},[h,r]),y=t.useMemo(()=>[{headerCheckboxSelection:!0,checkboxSelection:!0,headerCheckboxSelectionFilteredOnly:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{field:"Branch Folder"},{field:"Branch Version",sort:"asc",sortIndex:0},{field:"File Path",flex:1,sort:"asc",sortIndex:1},{field:"Local Status",headerTooltip:"Working Copy"}],[]);return t.useEffect(()=>{d.length<1||u||(C(""),a([]),i([]))},[d,u]),e.jsx(p,{children:s.length>0?e.jsxs(p,{children:[e.jsx(O,{mb:4,children:"Below are the list of files which are either unversioned or missing in the repository:"}),e.jsxs(A,{mb:4,alignItems:"center",children:[e.jsx(O,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:F,width:"100%"})]}),e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"390px",width:"100%"},children:e.jsx(de,{ref:l,rowData:s,defaultColDef:o,columnDefs:y,onSelectionChanged:k,quickFilterText:g,domLayout:"normal",rowSelection:"multiple",rowMultiSelectWithClick:!0,animateRows:!0,columnMenu:"new",enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!0,paginationAutoPageSize:!0})}),e.jsxs(A,{mt:4,columnGap:2,justifyContent:"flex-end",children:[e.jsx(v,{label:"Requires you to select at least 1 file",hasArrow:!0,isDisabled:r.length>0,children:e.jsxs(P,{onClick:x,colorScheme:"green",isDisabled:r.length<1,children:["Add/Remove ",r.length," File",r.length>1?"s":""]})}),e.jsx(v,{label:"Requires you to select at least 1 file",hasArrow:!0,isDisabled:r.length>0,children:e.jsxs(P,{onClick:b,colorScheme:"red",isDisabled:r.length<1,children:["Revert ",r.length," File",r.length>1?"s":""]})})]})]}):e.jsx(p,{children:e.jsx(O,{children:"Your selected branches do not contain any unversioned or missing files."})})})}function Ve(){const{config:s}=E();return s&&s.commitOptions?s.commitOptions:null}function $e({branchFolder:s}){const{issueNumber:a,setIssueNumber:o,selectedBranches:l}=E(),r=Ve(),i=t.useCallback(u=>{const c=String(u.target.value||"").trim();c==""&&o(h=>G.omit(h,[s])),/^\d*$/.test(c)&&o(h=>({...h,[s]:c}))},[s,o]);t.useEffect(()=>{o({})},[r==null?void 0:r.useIssuePerFolder,o]);const n=!s,d=!s||!(r!=null&&r.useIssuePerFolder)?!0:l==null?void 0:l.map(u=>u["Branch Folder"]).includes(s);return e.jsx(v,{label:"Please select source branch first!",isDisabled:!n,hasArrow:!0,children:e.jsxs(Ne,{isDisabled:n,isRequired:d,children:[e.jsx(Te,{children:s?`Issue Number For ${s}`:"Issue Number"}),e.jsx(ie,{value:a[s]||"",onInput:i,placeholder:"Enter number"})]},s)})}function Ee(){const{configurableRowData:s,sourceBranch:a,selectedBranches:o}=E(),l=t.useCallback(d=>s&&s.length>0?s.find(u=>u.id==d)["Branch Folder"]:"",[s]),r=t.useMemo(()=>{if(!(a!=null&&a.value))return[];const d=l(a.value);return[...new Set(o.filter(u=>u["Branch Folder"]!==d).map(u=>u["Branch Folder"]))]},[a,o,l]),i=t.useCallback(d=>s&&s.length>0?s.find(u=>u.id==d)["Branch Version"]:"",[s]),n=t.useCallback(d=>s&&s.length>0?s.find(u=>u.id==d)["SVN Branch"]:"",[s]);return{getBranchFolderById:l,selectedBranchFolders:r,getBranchVersionById:i,getSvnBranchById:n}}function xt({openMessageAutoFillModal:s}){const{sourceBranch:a,setSourceBranch:o,branchOptions:l,setIssueNumber:r,commitMessage:i,setCommitMessage:n,isCommitMode:d,selectedBranches:u}=E(),c=Ve(),{getBranchFolderById:h,selectedBranchFolders:g}=Ee(),C=t.useCallback(k=>{o(k)},[o]),F=t.useCallback(k=>{n(String(k.target.value).replace(/["`]/g,"'"))},[n]);return t.useEffect(()=>{d&&(o(null),r({}))},[d]),t.useEffect(()=>{c!=null&&c.reusePreviousCommitMessage||n("")},[c==null?void 0:c.reusePreviousCommitMessage,n,d]),t.useEffect(()=>{r(k=>Object.fromEntries(Object.entries(k).filter(([x])=>u.some(b=>b["Branch Folder"]===x))))},[u]),e.jsx(p,{children:e.jsxs(A,{columnGap:3,children:[e.jsxs(p,{flexGrow:1,children:[e.jsxs(A,{columnGap:2,mb:2,children:[e.jsx(p,{width:"50%",children:e.jsxs(Ne,{isRequired:!0,children:[e.jsx(Te,{children:"Source Branch"}),e.jsx(Ls,{value:a,onChange:C,options:l,placeholder:"SVN Branch you're commiting from",selectedOptionStyle:"check",selectedOptionColorScheme:"yellow",isClearable:!0,classNamePrefix:"chakra-react-select"})]})}),e.jsx(A,{width:"50%",alignItems:"flex-end",columnGap:2,children:e.jsx($e,{branchFolder:a&&a.value?h(a.value):null})})]}),e.jsxs(A,{columnGap:2,height:"auto",children:[e.jsxs(Ne,{width:c!=null&&c.useIssuePerFolder?"50%":"100%",isRequired:!0,children:[e.jsx(Te,{children:"Commit Message"}),e.jsx(Vs,{placeholder:"Enter Commit Message",height:"76%",resize:"none",onInput:F,value:i})]}),c!=null&&c.useIssuePerFolder?a!=null&&a.value?e.jsx(A,{width:"50%",flexDir:"column",rowGap:2,children:g.map(k=>e.jsx($e,{branchFolder:k},k))}):e.jsx(p,{width:"50%",textAlign:"center",m:"auto",children:e.jsx(O,{fontSize:"lg",fontWeight:"600",color:"yellow.500",children:"Please select source branch first!"})}):null]})]}),e.jsx(p,{pt:8,children:e.jsx(v,{label:"Auto Fill Message",hasArrow:!0,children:e.jsx($,{colorScheme:"yellow","aria-label":"Auto Fill Message",size:"md",onClick:()=>s(),icon:e.jsx(Ze,{})})})})]})})}function bt({openCommitModal:s}){const{setShowCommitView:a,selectedLocalChanges:o,sourceBranch:l,issueNumber:r,commitMessage:i,setSocketPayload:n,configurableRowData:d,selectedBranches:u}=E(),{RaiseClientNotificaiton:c}=ne(),h=Ve(),{selectedBranchFolders:g}=Ee(),C=t.useCallback(()=>{a(!1)},[a]),F=t.useCallback(()=>{if(!l||l.value===""){c("Please select the source branch to proceed!","error");return}const k=d.find(y=>y.id==l.value),x=h!=null&&h.useIssuePerFolder?g.every(y=>r[y]&&r[y]!==""):!0,b=h!=null&&h.useIssuePerFolder&&!u.some(y=>y["Branch Folder"]===k["Branch Folder"])||r[k["Branch Folder"]];if(!r||G.isEmpty(r)||!x||!b){c("Please provide the issue number to proceed!","error");return}if(!i||i.trim()===""){c("Please provide the commit message to proceed!","error");return}n({sourceBranch:k,issueNumber:r,commitMessage:i,filesToProcess:o,commitOptions:h}),s()},[c,l,d,h,g,r,u,i,o]);return e.jsx(p,{children:e.jsxs(A,{columnGap:2,justifyContent:"center",children:[e.jsx(P,{onClick:C,leftIcon:e.jsx(ye,{}),colorScheme:"yellow",children:"Refresh Process"}),e.jsx(v,{label:"Select at least 1 file",hasArrow:!0,isDisabled:o.length>0,children:e.jsxs(P,{onClick:F,leftIcon:e.jsx(X,{as:Ye}),colorScheme:"yellow",isDisabled:o.length<1,children:["Commit ",o.length>0?`${o.length} File`:"",o.length>1?"s":""]})})]})})}function pt(){const{selectedBranches:s,logData:a,setLogData:o}=E(),[l,r]=t.useState([]),[i,n]=t.useState(""),d=t.useCallback(h=>{n(h.target.value)},[n]),u=t.useCallback(()=>{o([])},[o]),c=a.length===s.length;return t.useEffect(()=>{if(a.length===0)return;const h=a.map(g=>g.logs).flat();r(g=>G.isEqual(g,h)?g:h)},[a]),{rowDataLogs:l,quickFilterLogsText:i,setQuickFilterLogsText:n,onQuickFilterLogsInputChanged:d,refreshLogs:u,areLogsFetched:c}}function Ct({rowDataLogs:s,quickFilterLogsText:a,setAutoFillSelection:o=null,isAutofill:l=!1}){const r=t.useMemo(()=>({sortable:!0,resizable:!1,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),i=t.useMemo(()=>{const u=[{field:"revision",headerName:"Revision",sort:"desc",width:130},{field:"date",headerName:"Date",sortable:!1},{field:"branchFolder",headerName:"Branch Folder",width:135},{field:"branchVersion",headerName:"Branch Version",width:125},{field:"author",headerName:"Author"},{field:"message",headerName:"Message",flex:1}];return l?[{checkboxSelection:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},...u]:u},[l]),n=t.useRef(null),d=t.useCallback(()=>{var u,c;if(o){const h=(c=(u=n==null?void 0:n.current)==null?void 0:u.api)==null?void 0:c.getSelectedNodes().map(g=>g.data);o(h[0]||null)}},[o]);return e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:l?"90%":"85%",width:"100%"},children:e.jsx(de,{ref:n,rowData:s,defaultColDef:r,columnDefs:i,onSelectionChanged:d,quickFilterText:a,domLayout:"normal",columnMenu:"new",rowSelection:"single",suppressRowClickSelection:!l,animateRows:!1,immutableData:!0,suppressFlash:!0,enableCellTextSelection:!0,ensureDomOrder:!0,pagination:!0,paginationAutoPageSize:!0})})}function os({setAutoFillSelection:s=!1,isAutofill:a=!1}){const{selectedBranches:o,logData:l}=E(),{rowDataLogs:r,quickFilterLogsText:i,onQuickFilterLogsInputChanged:n,refreshLogs:d,areLogsFetched:u}=pt();return u?e.jsxs(p,{h:"100%",children:[e.jsxs(A,{mb:4,width:"100%",alignItems:"center",columnGap:4,children:[e.jsxs(A,{alignItems:"center",width:"100%",children:[e.jsx(O,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:n,width:"100%"})]}),e.jsx(p,{children:e.jsx(v,{label:"Refresh",hasArrow:!0,children:e.jsx($,{onClick:d,icon:e.jsx(ye,{}),colorScheme:"yellow","aria-label":"Refresh"})})})]}),e.jsx(Ct,{rowDataLogs:r,quickFilterLogsText:i,setAutoFillSelection:s,isAutofill:a})]}):e.jsxs(p,{children:[e.jsxs(p,{mb:4,children:[e.jsx(O,{fontWeight:600,children:"Showing SVN Log for the following branches:"}),e.jsx(Re,{spacing:3,children:o.map(c=>{const h=l.find(g=>g.id===c.id);return e.jsxs(ae,{display:"flex",alignItems:"center",children:[e.jsx(oe,{w:30,h:30,as:h?re:Es,color:"yellow.500"}),De(c["Branch Folder"],c["Branch Version"],c["SVN Branch"])]},c.branchId)})})]}),e.jsx(A,{justifyContent:"center",children:e.jsx(Ps,{value:l.length/o.length*360,color:"yellow.300",size:"100px",children:e.jsxs(Os,{children:[l.length," / ",o.length]})})})]})}function wt(s){const{data:a}=s,o=async()=>{window.open(a.url,"_blank")};return e.jsx($,{"aria-label":"Diff",size:"sm",icon:e.jsx(zs,{}),onClick:o,colorScheme:"yellow"})}function jt({rowDataTrello:s,quickFilterTrelloText:a,setAutoFillSelection:o}){const l=t.useMemo(()=>({sortable:!0,resizable:!1,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]),r=t.useMemo(()=>[{checkboxSelection:!0,width:20,resizable:!1,suppressMovable:!1,filter:!1,editable:!1,headerClass:"branch-table-header-cell",cellClass:"branch-table-body-cell"},{field:"name",headerName:"Name",flex:1},{field:"lastActivityDate",headerName:"Last Activity Date"},{field:"url",headerName:"Goto Trello",filter:!1,sortable:!1,resizable:!1,cellRenderer:wt,width:120}],[]),i=t.useRef(null),n=t.useCallback(()=>{var u,c;const d=(c=(u=i==null?void 0:i.current)==null?void 0:u.api)==null?void 0:c.getSelectedNodes().map(h=>h.data);o(d[0]||null)},[o]);return e.jsx("div",{className:"ag-theme-balham-dark compact",style:{height:"80%",width:"100%"},children:e.jsx(de,{ref:i,rowData:s,defaultColDef:l,columnDefs:r,onSelectionChanged:n,quickFilterText:a,domLayout:"normal",columnMenu:"new",rowSelection:"single",suppressRowClickSelection:!1,animateRows:!1,enableCellTextSelection:!0,pagination:!0,paginationAutoPageSize:!0})})}function St({setAutoFillSelection:s}){const{socket:a}=E(),{key:o,token:l,isTrelloIntegrationEnabled:r,emitTrelloCardNamesSearch:i}=as(),[n,d]=t.useState(""),[u,c]=t.useState(""),[h,g]=t.useState([]),C=t.useCallback(G.debounce(b=>{b.trim()!==""&&i(o,l,b)},400),[o,l,i]),F=t.useCallback(b=>{d(String(b.target.value).trim())},[d]),k=t.useCallback(()=>{n.trim()!==""&&i(o,l,n)},[n,o,l,i]),x=t.useCallback(b=>{c(b.target.value)},[]);return t.useEffect(()=>(C(n),()=>C.cancel()),[n,C]),t.useEffect(()=>{const b=y=>{g(y&&y.length>0?y:[])};return a==null||a.on("trello-result-search-names-card",b),()=>a==null?void 0:a.off("trello-result-search-names-card",b)},[a]),r?e.jsxs(p,{h:"100%",children:[e.jsxs(A,{mb:4,width:"100%",alignItems:"center",columnGap:4,children:[e.jsxs(A,{alignItems:"center",width:"100%",children:[e.jsx(O,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Trello Query:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:F,width:"100%"})]}),e.jsx(p,{children:e.jsx(v,{label:"Resubmit Query",hasArrow:!0,children:e.jsx($,{onClick:k,icon:e.jsx(ye,{}),colorScheme:"yellow","aria-label":"Resubmit"})})})]}),e.jsx(A,{mb:4,width:"100%",alignItems:"center",columnGap:4,children:e.jsxs(A,{alignItems:"center",width:"100%",children:[e.jsx(O,{mr:2,fontWeight:"600",whiteSpace:"nowrap",children:"Quick Filter:"}),e.jsx(ie,{placeholder:"Type to search...",onInput:x,width:"100%"})]})}),e.jsx(jt,{rowDataTrello:h,quickFilterTrelloText:u,setAutoFillSelection:s})]}):e.jsx(p,{h:"100%",p:4,children:e.jsxs(O,{fontSize:"lg",fontWeight:"600",color:"red.500",children:["You need to"," ",e.jsxs(_e,{href:"https://help.merge.dev/en/articles/8757597-trello-how-do-i-link-my-account",isExternal:!0,color:"yellow.500",children:["set up Trello Integration ",e.jsx(Ze,{mx:"2px"})]})," ","in the configuration file to use this feature."]})})}function Bt({isModalOpen:s,closeModal:a}){const{setSourceBranch:o,branchOptions:l,setIssueNumber:r,setCommitMessage:i,setPostCommitData:n}=E(),{getBranchFolderById:d}=Ee(),[u,c]=t.useState(0),[h,g]=t.useState([null,null]),[C,F]=t.useState(!0),k=t.useCallback(w=>{c(w),g(w===0?m=>[m[0],null]:m=>[null,m[1]])},[c]),x=t.useCallback(w=>{g(m=>[w,...m.slice(1)])},[g]),b=t.useCallback(w=>{g(m=>[m[0],w])},[g]),y=t.useCallback(()=>{console.debug("Selected tab index:",u),console.debug("Selected autofill selection:",JSON.stringify(h,null,4));let w=h[u];if(u===0){const m=w.message,j=w.branchId,D=m.match(/\s*(Issue)*\s*(\d+)\s*/),V=D?D[2]:null,z=m.replace(/\s*(Issue)*\s*(\d+)?\s*(\([^\)]+\))*\s?:?\s*/,"");j&&o(l.find(N=>N.value===j)),V&&r(N=>({...N,[d(w.branchId)]:V})),z.trim()!==""&&i(z)}else{const m=w.name,j=m.match(/\s*(Issue)*\s*(\d+)\s*/),D=j?j[2]:null,V=m.replace(/\s*(Issue)*\s*(\d+)/,"");D&&r(z=>Object.fromEntries(Object.keys(z).map(N=>[N,D]))),V.trim()!==""&&i(V),n({type:"trello",data:w})}a()},[u,h,a]);return t.useEffect(()=>{F(!(h.length==2&&(h[0]||h[1])))},[h]),t.useEffect(()=>{g([null,null]),c(0)},[s]),e.jsxs(Ke,{isOpen:s,onClose:a,isCentered:!0,motionPreset:"slideInBottom",scrollBehavior:"inside",size:"xl",closeOnOverlayClick:!0,children:[e.jsx(pe,{}),e.jsxs(Je,{maxH:"95%",maxW:"95%",children:[e.jsx(Ce,{children:e.jsx(Z,{as:"h2",size:"lg",children:"Autofill Commit Message"})}),e.jsx(ke,{size:"lg"}),e.jsx(we,{children:e.jsx(p,{height:"70vh",children:e.jsxs(es,{variant:"solid-rounded",colorScheme:"yellow",defaultIndex:0,isLazy:!0,h:"100%",onChange:w=>k(w),children:[e.jsxs(ss,{children:[e.jsx(xe,{children:"SVN Logs"}),e.jsx(xe,{children:"Trello"})]}),e.jsxs(ts,{h:"90%",children:[e.jsx(be,{px:0,pb:0,h:"100%",children:e.jsx(os,{setAutoFillSelection:x,isAutofill:!0})}),e.jsx(be,{px:0,pb:0,h:"100%",children:e.jsx(St,{setAutoFillSelection:b})})]})]})})}),e.jsxs(Be,{children:[e.jsx(P,{mr:3,onClick:()=>a(),children:"Cancel"}),e.jsx(v,{hasArrow:!0,label:"Please select exactly one row!",placement:"top-start",isDisabled:!C,children:e.jsx(P,{colorScheme:"yellow",onClick:y,isDisabled:C,children:"Select"})})]})]})]})}function yt(){const{config:s,updateConfig:a,setSourceBranch:o}=E(),[l,r]=t.useState({}),i=t.useCallback((n,d)=>{r(u=>({...u,[n]:d}))},[r]);return t.useEffect(()=>{!s||G.isEmpty(s)||(s.commitOptions?r(s.commitOptions):a(n=>({...n,commitOptions:{useFolderOnlySource:!1,useIssuePerFolder:!1,reusePreviousCommitMessage:!1}})))},[s]),t.useEffect(()=>{G.isEmpty(l)||a(n=>G.isEqual(n.commitOptions,l)?n:{...n,commitOptions:l})},[l]),t.useEffect(()=>{o(null)},[l==null?void 0:l.useFolderOnlySource,o]),e.jsxs(p,{mb:4,children:[e.jsx(Z,{as:"h6",size:"sm",children:"Commit Options"}),e.jsx(Xe,{colorScheme:"yellow",children:e.jsxs(Us,{direction:"row",spacing:4,mt:2,children:[e.jsx(J,{isChecked:l.useFolderOnlySource,onChange:n=>i("useFolderOnlySource",n.target.checked),children:e.jsx(v,{label:"Removes extra branch details from source branch.",hasArrow:!0,placement:"bottom-start",children:"Use Folder Only Source Branch?"})}),e.jsx(J,{isChecked:l.useIssuePerFolder,onChange:n=>i("useIssuePerFolder",n.target.checked),children:e.jsx(v,{label:"Allows users to input issue number for each branch folder.",hasArrow:!0,placement:"bottom-start",children:"Use 1 Issue Per Folder?"})}),e.jsx(J,{isChecked:l.reusePreviousCommitMessage,onChange:n=>i("reusePreviousCommitMessage",n.target.checked),children:e.jsx(v,{label:"Reuses the commit message from the previous commit made in Titan.",hasArrow:!0,children:"Reuse Previous Commit Message?"})})]})})]})}function kt(){const{isDebug:s,setIsCommitMode:a,selectedBranchStatuses:o,showCommitView:l,setShowCommitView:r,selectedBranches:i,configurableRowData:n}=E(),[d,u]=t.useState({}),[c,h]=t.useState([]),[g,C]=t.useState([]),{isOpen:F,onOpen:k,onClose:x}=Me(),{isOpen:b,onOpen:y,onClose:w}=Me(),m=t.useMemo(()=>({resizable:!0,wrapText:!0,autoHeight:!0,filter:!0,suppressMovable:!0,editable:!1,wrapHeaderText:!0,autoHeaderHeight:!0}),[]);t.useEffect(()=>{if(i.length<1||l){i.length<1&&a(!1);return}u({})},[i,l]),t.useEffect(()=>{s&&(console.debug("Branch Status Rows:",o),console.debug("Selected Rows:",i))},[s,o,i]),t.useEffect(()=>{o.length===i.length&&(o.forEach(N=>{let T=N.id,W=N.status.filesToCommit,q=N.status.filesToUpdate;const I=n.find(U=>U.id===T);if(q.length>0){const U=De(I["Branch Folder"],I["Branch Version"],I["SVN Branch"]);u(H=>({...H,[U]:[...H[U]||[],...q]}))}if(W.length>0){const U=W.map(H=>({branchId:T,"Branch Folder":I["Branch Folder"],"Branch Version":I["Branch Version"],"SVN Branch":I["SVN Branch"],"Full Path":H.path,"File Path":`${tt(N.status.branch)}\\${H.pathDisplay}`,"Local Status":H.wcStatus}));h(H=>[...H,...U.filter(Y=>!["unversioned","missing"].includes(Y["Local Status"]))]),C(H=>[...H,...U.filter(Y=>["unversioned","missing"].includes(Y["Local Status"]))])}}),r(!0))},[o,i,n]);const j=Object.keys(d).length>0,D=c.length>0,V=g.length>0,z=j||D||V;return e.jsxs(p,{children:[e.jsx(yt,{}),e.jsx(p,{mb:6,children:e.jsx(xt,{openMessageAutoFillModal:y})}),e.jsx(Ws,{isLoaded:l&&z,startColor:"yelow.500",endColor:"yellow.500",children:e.jsxs(es,{variant:"solid-rounded",colorScheme:"yellow",defaultIndex:j?0:D?1:2,isLazy:!1,children:[e.jsxs(ss,{children:[e.jsx(xe,{isDisabled:!j,children:e.jsx(v,{label:"No files to update!",hasArrow:!0,isDisabled:j,children:"Files to Update"})}),e.jsx(xe,{isDisabled:!D,children:e.jsx(v,{label:"No files to commit!",hasArrow:!0,isDisabled:D,children:"Local Changes"})}),e.jsx(xe,{isDisabled:!V,children:e.jsx(v,{label:"No unversioned/missing files!",hasArrow:!0,isDisabled:V,children:"Untracked Changes"})})]}),e.jsxs(ts,{children:[e.jsx(be,{px:0,children:e.jsx(ft,{fileUpdates:d})}),e.jsx(be,{px:0,children:e.jsx(mt,{rowDataLocalChanges:c,setRowDataLocalChanges:h,defaultColDefsCommit:m})}),e.jsx(be,{px:0,children:e.jsx(gt,{rowDataUntrackedChanges:g,setRowDataUntrackedChanges:C,defaultColDefsCommit:m})})]})]})}),l&&!z?e.jsxs(O,{mt:4,className:"animation-pulse",fontWeight:600,textAlign:"center",children:["No changes have been spotted!",e.jsx("br",{}),"Please use the refresh button 👇 if you have recently made a change"]}):e.jsx(e.Fragment,{}),e.jsx(p,{mt:6,children:e.jsx(bt,{openCommitModal:k})}),e.jsx(ut,{isModalOpen:F,closeModal:x}),e.jsx(Bt,{isModalOpen:b,closeModal:w})]})}function Dt(){const{showSelectedBranchesLog:s,setShowSelectedBranchesLog:a}=E();return e.jsxs(Hs,{isOpen:s,onClose:()=>a(!1),placement:"left",size:"full",children:[e.jsx(pe,{}),e.jsxs($s,{children:[e.jsx(ke,{size:"lg"}),e.jsx(Ce,{children:"Selected Branches: SVN Log"}),e.jsx(we,{children:e.jsx(p,{height:"100%",children:e.jsx(os,{})})})]})]})}function vt(){const{toast:s,RaiseClientNotificaiton:a}=ne(),{isOpen:o,onOpen:l,onClose:r}=Me(),i=t.useRef(),[n,d]=t.useState(!1);t.useEffect(()=>{if(!window.electron){a("Electron context is not available. Updates cannot be checked.","warning",5e3);return}return window.electron.on("update-available",()=>{s.closeAll(),l()}),window.electron.on("update-error",h=>{a(`An error occurred while checking for updates: ${h}`,"error",5e3),d(!1)}),()=>{window.electron.removeAllListeners("update-available"),window.electron.removeAllListeners("update-error")}},[s,l]);const u=t.useCallback(()=>{r(),a("You may update the application later by manually triggering an update check or wait until Titan does this","info",5e3)},[r,a]),c=t.useCallback(()=>{if(n){a("Update is already in progress. Please wait.","info",5e3);return}window.electron?(d(!0),window.electron.downloadUpdate().catch(h=>{d(!1),a(`An error occurred while downloading the update: ${h}`,"error",5e3)}),window.electron.on("update-downloaded",()=>{a("Update has been downloaded successfully. Titan will now restart to apply the update.","info",5e3),window.electron.removeAllListeners("update-downloaded"),r()}),window.electron.on("update-not-available",()=>{a("Titan is up to date","info",3e3),window.electron.removeAllListeners("update-not-available"),d(!1),r()})):a("Cannot update Titan in a non-desktop application environment","error",5e3)},[n,a,d,r]);return e.jsx(Ge,{isOpen:o,leastDestructiveRef:i,onClose:r,motionPreset:"slideInBottom",closeOnOverlayClick:!n,children:e.jsx(pe,{children:e.jsxs(Qe,{children:[e.jsx(Ce,{fontSize:"lg",fontWeight:"bold",children:"Update Available"}),n?e.jsx(e.Fragment,{}):e.jsx(ke,{}),e.jsx(we,{children:"A new version of Titan is available. Would you like to download and install the update?"}),e.jsxs(Be,{children:[e.jsx(P,{colorScheme:"red",ref:i,onClick:u,isDisabled:n,children:"Cancel"}),e.jsx(P,{colorScheme:"yellow",onClick:c,ml:3,isDisabled:n,children:"Confirm"})]})]})})})}function Ft(){if(!window.electron)return e.jsx(e.Fragment,{});const s=t.useCallback(()=>{window.electron.minimizeWindow()},[]),a=t.useCallback(()=>{window.electron.maximizeWindow()},[]),o=t.useCallback(()=>{window.electron.closeWindow()},[]);return e.jsx(qs.header,{w:"100%",position:"fixed",bgColor:"#121212",className:"titanHead",zIndex:9999999,top:0,children:e.jsxs(A,{justifyContent:"space-between",alignItems:"center",p:2,position:"static",children:[e.jsx(Z,{as:"h6",size:"sm",noOfLines:1,className:"animation-fadein-left-forward",children:"Titan"}),e.jsxs(A,{alignItems:"center",columnGap:2,flexWrap:"nowrap",wrap:"nowrap",children:[e.jsx($,{"aria-label":"Minimize",size:"xs",icon:e.jsx(_s,{}),onClick:s,colorScheme:"gray",_hover:{bg:"#FAF089",color:"#1A202C"}}),e.jsx($,{"aria-label":"Maximize",size:"xs",icon:e.jsx(Gs,{}),onClick:a,colorScheme:"gray",_hover:{bg:"#FAF089",color:"#1A202C"}}),e.jsx($,{"aria-label":"Close",size:"xs",icon:e.jsx(Ie,{}),onClick:o,colorScheme:"gray",_hover:{bg:"#FEB2B2",color:"#1A202C"}})]})]})})}function It(){const{isCommitMode:s,selectedBranches:a,configurableRowData:o}=E(),{RaiseClientNotificaiton:l}=ne();return t.useEffect(()=>{if(window.electron)return window.electron.onAppClosing(()=>{l("App is closing, performing cleanup...","info",0),window.electron.closeWindow()}),()=>{window.electron.removeAppClosingListener()};console.warn("Electron specific logic is not available in browser mode.")},[]),e.jsxs(p,{className:"titanBody",children:[e.jsx(Ft,{}),e.jsxs(p,{p:10,children:[e.jsx(ot,{}),e.jsx(vt,{}),e.jsxs(A,{rowGap:4,flexDirection:"column",children:[e.jsx(p,{children:e.jsx(ht,{})}),e.jsx(Qs,{in:s,animateOpacity:!0,children:e.jsxs(p,{id:"sectionCommit",children:[e.jsxs(Z,{as:"h2",size:"lg",noOfLines:1,mb:4,className:"animation-pulse",children:["Committing ",a.length==o.length?"All":`${a.length}/${o.length}`," Branch",a.length==1?"":"es"]}),e.jsx(kt,{})]})})]}),e.jsx(Dt,{})]})]})}const{definePartsStyle:rs,defineMultiStyleConfig:is}=Zs(et.keys),Rt=rs({overlay:{bg:"blackAlpha.900"},dialog:{bg:"gray.900",color:"white",boxShadow:"rgba(255, 255, 255, 0.07) 0px -20px 20px 20px"},header:{bg:"gray.900",color:"white",borderRadius:"20px",p:4},body:{p:4,color:"white"},footer:{bg:"gray.900",p:4,color:"white",borderRadius:"20px"}}),Nt=is({baseStyle:Rt}),Tt=rs({overlay:{bg:"blackAlpha.900"},dialog:{mt:lt,bg:"gray.900",color:"white",boxShadow:"rgba(255, 255, 255, 0.07) 0px -20px 20px 20px"},header:{bg:"gray.900",color:"white",borderRadius:"20px",p:4},body:{p:4,color:"white"},footer:{bg:"gray.900",p:2,color:"white",borderRadius:"20px"}}),Mt=is({baseStyle:Tt}),At={initialColorMode:"dark",useSystemColorMode:!1},qe=Ys({config:At,components:{Modal:Nt,Drawer:Mt}});Ks.createRoot(document.getElementById("root")).render(e.jsx(Ae.StrictMode,{children:e.jsxs(Js,{theme:qe,children:[e.jsx(Xs,{initialColorMode:qe.config.initialColorMode}),e.jsx(at,{children:e.jsx(It,{})})]})})); diff --git a/package.json b/package.json index ec34ebc..605c2b7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "titan", "private": true, "proxy": "http://localhost:5173", - "version": "1.3.1", + "version": "1.3.2", "type": "module", "main": "main.js", "description": "A desktop application for streamlining your workflow in Revision Control Systems (RCS) like Subversion (SVN).", diff --git a/server/server.js b/server/server.js index 367e7aa..437ee32 100644 --- a/server/server.js +++ b/server/server.js @@ -434,6 +434,7 @@ async function sendConfig(socket) { branches: [], branchFolderColours: {}, commitOptions: { + useFolderOnlySource: false, useIssuePerFolder: false, reusePreviousCommitMessage: false, }, @@ -796,7 +797,7 @@ io.on("connection", (socket) => { return; } - const { sourceBranch, issueNumber, commitMessage, filesToProcess } = data; + const { sourceBranch, issueNumber, commitMessage, filesToProcess, commitOptions } = data; // Group files by SVN Branch const filesByBranch = filesToProcess.reduce((acc, file) => { @@ -820,7 +821,7 @@ io.on("connection", (socket) => { let originalMessage = `(${sourceBranch["Branch Folder"]}${originalIssueNumber !== "" ? ` #${originalIssueNumber}` : ""})`; if (branchFolder === sourceBranch["Branch Folder"]) { - originalMessage = `(${branchFolder} ${sourceBranch["Branch Version"]})`; + originalMessage = `(${branchFolder}${commitOptions.useFolderOnlySource ? "" : ` ${sourceBranch["Branch Version"]}`})`; } let branchIssueNumber = issueNumber[branchFolder] || originalIssueNumber; diff --git a/src/AppContext.jsx b/src/AppContext.jsx index a845a12..aefff19 100644 --- a/src/AppContext.jsx +++ b/src/AppContext.jsx @@ -127,6 +127,7 @@ export const AppProvider = ({ children }) => { const [showCommitView, setShowCommitView] = useState(false); const [sourceBranch, setSourceBranch] = useState(null); const branchOptions = useMemo(() => { + // Old Implementation for source branch: // if (config && config.commitOptions && config.commitOptions.useIssuePerFolder) { // return selectedBranches.filter((row) => row["Branch Folder"] && row["Branch Version"] && row["SVN Branch"] && row["Branch Folder"] !== "" && row["Branch Version"] !== "" && row["SVN Branch"] !== "").map((row) => ({ // value: row.id, @@ -134,11 +135,22 @@ export const AppProvider = ({ children }) => { // })); // } - return configurableRowData - .filter((row) => row["Branch Folder"] && row["Branch Version"] && row["SVN Branch"] && row["Branch Folder"] !== "" && row["Branch Version"] !== "" && row["SVN Branch"] !== "") + let isFolderOnlySource = config && config.commitOptions && config.commitOptions.useFolderOnlySource; + let filteredBranches = configurableRowData.filter((row) => row["Branch Folder"] && row["Branch Version"] && row["SVN Branch"] && row["Branch Folder"] !== "" && row["Branch Version"] !== "" && row["SVN Branch"] !== ""); + + if (isFolderOnlySource) { + filteredBranches = filteredBranches.reduce((acc, row) => { + if (!acc.some((item) => item["Branch Folder"] === row["Branch Folder"])) { + acc.push(row); + } + return acc; + }, []); + } + + return filteredBranches .map((row) => ({ value: row.id, - label: branchString(row["Branch Folder"], row["Branch Version"], row["SVN Branch"]), + label: isFolderOnlySource ? row["Branch Folder"] : branchString(row["Branch Folder"], row["Branch Version"], row["SVN Branch"]), })); }, [config, selectedBranches, configurableRowData]); const [issueNumber, setIssueNumber] = useState({}); diff --git a/src/components/FooterSectionCommit.jsx b/src/components/FooterSectionCommit.jsx index aa0bc0e..34ea66d 100644 --- a/src/components/FooterSectionCommit.jsx +++ b/src/components/FooterSectionCommit.jsx @@ -47,7 +47,7 @@ export default function FooterSectionCommit({ openCommitModal }) { // return; // } - setSocketPayload({ sourceBranch: sourceBranchRow, issueNumber: issueNumber, commitMessage, filesToProcess: selectedLocalChanges }); + setSocketPayload({ sourceBranch: sourceBranchRow, issueNumber: issueNumber, commitMessage, filesToProcess: selectedLocalChanges, commitOptions: commitOptions }); openCommitModal(); }, [RaiseClientNotificaiton, sourceBranch, configurableRowData, commitOptions, selectedBranchFolders, issueNumber, selectedBranches, commitMessage, selectedLocalChanges]); diff --git a/src/components/OptionsCommit.jsx b/src/components/OptionsCommit.jsx index 9c5b808..da5fa4a 100644 --- a/src/components/OptionsCommit.jsx +++ b/src/components/OptionsCommit.jsx @@ -4,8 +4,7 @@ import { useApp } from "../AppContext"; import _ from "lodash"; export default function OptionsCommit() { - const { config, updateConfig } = useApp(); - + const { config, updateConfig, setSourceBranch } = useApp(); const [commitOptions, setCommitOptions] = useState({}); const handleOptionChange = useCallback( @@ -25,6 +24,7 @@ export default function OptionsCommit() { updateConfig((currentConfig) => ({ ...currentConfig, commitOptions: { + useFolderOnlySource: false, useIssuePerFolder: false, reusePreviousCommitMessage: false, }, @@ -48,6 +48,11 @@ export default function OptionsCommit() { }); }, [commitOptions]); + // Clear source branch option if folder only source is toggled + useEffect(() => { + setSourceBranch(null); + }, [commitOptions?.useFolderOnlySource, setSourceBranch]); + return ( @@ -55,13 +60,18 @@ export default function OptionsCommit() { + handleOptionChange("useFolderOnlySource", e.target.checked)}> + + Use Folder Only Source Branch? + + handleOptionChange("useIssuePerFolder", e.target.checked)}> - + Use 1 Issue Per Folder? handleOptionChange("reusePreviousCommitMessage", e.target.checked)}> - + Reuse Previous Commit Message?