@actual-app/web 23.9.0 → 23.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +7 -2
  2. package/build/apple-touch-icon.png +0 -0
  3. package/build/asset-manifest.json +25 -21
  4. package/build/index.html +1 -1
  5. package/build/kcab/kcab.worker.b835d2cdcf8004c363da.js +250 -0
  6. package/build/kcab/kcab.worker.b835d2cdcf8004c363da.js.map +1 -0
  7. package/build/kcab/xfo.xfo.kcab.worker.2ee5d7175d50b7896f28.js +1 -0
  8. package/build/static/css/main.476f35a5.css +359 -0
  9. package/build/static/css/main.476f35a5.css.map +1 -0
  10. package/build/static/js/231.370f17f8.chunk.js +2 -0
  11. package/build/static/js/231.370f17f8.chunk.js.map +1 -0
  12. package/build/static/js/389.c8f94185.chunk.js +2 -0
  13. package/build/static/js/389.c8f94185.chunk.js.map +1 -0
  14. package/build/static/js/473.02c273e8.chunk.js +2 -0
  15. package/build/static/js/473.02c273e8.chunk.js.map +1 -0
  16. package/build/static/js/678.bf349f5d.chunk.js +2 -0
  17. package/build/static/js/678.bf349f5d.chunk.js.map +1 -0
  18. package/build/static/js/713.1731d555.chunk.js +15 -0
  19. package/build/static/js/713.1731d555.chunk.js.map +1 -0
  20. package/build/static/js/main.7e6eedd0.js +188 -0
  21. package/build/static/js/main.7e6eedd0.js.map +1 -0
  22. package/build/static/js/narrow-components.11cf3591.chunk.js +2 -0
  23. package/build/static/js/narrow-components.11cf3591.chunk.js.map +1 -0
  24. package/build/static/js/reports.39b7254a.chunk.js +2 -0
  25. package/build/static/js/reports.39b7254a.chunk.js.map +1 -0
  26. package/build/static/js/resize-observer-polyfill.98a18736.chunk.js +2 -0
  27. package/build/static/js/resize-observer-polyfill.98a18736.chunk.js.map +1 -0
  28. package/build/static/js/wide-components.fd8595f4.chunk.js +2 -0
  29. package/build/static/js/wide-components.fd8595f4.chunk.js.map +1 -0
  30. package/build/static/media/browser-server.20abc230cfc504c53fa0.js +1 -0
  31. package/package.json +16 -12
  32. package/build/kcab/kcab.worker.903b11c4b36a7822451f.js +0 -3
  33. package/build/kcab/kcab.worker.903b11c4b36a7822451f.js.LICENSE.txt +0 -24
  34. package/build/kcab/kcab.worker.903b11c4b36a7822451f.js.map +0 -1
  35. package/build/kcab/xfo.xfo.kcab.worker.e800a4a41b9557f2726d.js +0 -1
  36. package/build/static/css/main.90cc2688.css +0 -7
  37. package/build/static/css/main.90cc2688.css.map +0 -1
  38. package/build/static/js/171.491e33e7.chunk.js +0 -2
  39. package/build/static/js/171.491e33e7.chunk.js.map +0 -1
  40. package/build/static/js/383.d7919241.chunk.js +0 -2
  41. package/build/static/js/383.d7919241.chunk.js.map +0 -1
  42. package/build/static/js/969.b56f4e53.chunk.js +0 -2
  43. package/build/static/js/969.b56f4e53.chunk.js.map +0 -1
  44. package/build/static/js/main.041e259e.js +0 -3
  45. package/build/static/js/main.041e259e.js.LICENSE.txt +0 -178
  46. package/build/static/js/main.041e259e.js.map +0 -1
  47. package/build/static/js/narrow-components.b48d7cb2.chunk.js +0 -2
  48. package/build/static/js/narrow-components.b48d7cb2.chunk.js.map +0 -1
  49. package/build/static/js/reports.2402a148.chunk.js +0 -2
  50. package/build/static/js/reports.2402a148.chunk.js.map +0 -1
  51. package/build/static/js/resize-observer-polyfill.68c3249b.chunk.js +0 -2
  52. package/build/static/js/resize-observer-polyfill.68c3249b.chunk.js.map +0 -1
  53. package/build/static/js/wide-components.2c2e09e4.chunk.js +0 -2
  54. package/build/static/js/wide-components.2c2e09e4.chunk.js.map +0 -1
  55. package/build/static/media/browser-server.14ed34b8682d7b10163f.js +0 -1
@@ -0,0 +1,2 @@
1
+ "use strict";(self["webpackChunk_actual_app_web"]=self["webpackChunk_actual_app_web"]||[]).push([[162],{71462:function(e,t,n){n.r(t);n.d(t,{Account:function(){return rh},Accounts:function(){return rh},Budget:function(){return tO},GoCardlessLink:function(){return tq},Schedules:function(){return t$}});var r={};n.r(r);n.d(r,{BudgetSummary:function(){return ts},BudgetTotalsMonth:function(){return tc},CategoryMonth:function(){return tp},ExpenseCategoryMonth:function(){return tf},ExpenseGroupMonth:function(){return tg},GroupMonth:function(){return tu},IncomeCategoryMonth:function(){return tm},IncomeGroupMonth:function(){return tx},IncomeHeaderMonth:function(){return td}});var o={};n.r(o);n.d(o,{BudgetSummary:function(){return tM},BudgetTotalsMonth:function(){return tD},ExpenseCategoryMonth:function(){return tL},ExpenseGroupMonth:function(){return tW},IncomeCategoryMonth:function(){return tF},IncomeGroupMonth:function(){return tN},IncomeHeaderMonth:function(){return tP}});var i=n(43188);var a=n(66204);var s=n(37496);var l=n(59379);var c=n(55833);var d=n(84094);var u=n(25258);var h=n(73416);var p=n(1447);var g=n(9579);var f=n(58068);var x=n(45492);var m=n(24307);var y=n(75970);var w=n(38638);var v=n(75025);var b=n(37418);const S=({startMonth:e,numDisplayed:t,monthBounds:n,style:r,onSelect:o})=>{const[s,l]=(0,a.useState)(null);const[c,d]=(0,a.useState)(12);const u=h.dK();const p=e;const g=h.zI(p,t-1);const f=h.Do(h.W9(p,c/2-t/2),h.zI(g,c/2-t/2));const y=Math.floor(f.length/2)-Math.floor(t/2);const w=y+t-1;const[v,S]=(0,a.useState)("small");const j=(0,b.Z)(e=>{S(e.width<=400?"small":"big");d(Math.min(Math.max(Math.floor(e.width/50),12),24))});let C=[];return(0,i.jsx)(m.Z,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",...r},children:(0,i.jsx)(m.Z,{innerRef:j,style:{flexDirection:"row",flex:1,alignItems:"center",justifyContent:"center"},children:f.map((e,r)=>{const a=h.WU(e,"MMM");const c=r>=y&&r<=w;const d=s+t-1;const p=s===null?false:r>=s&&r<=d;const g=u===e;const f=h.So(e);let b=false;if(!C.includes(f)){C.push(f);b=true}const S=e>=n.start&&e<=n.end;return(0,i.jsxs)(m.Z,{style:{padding:"3px 3px",width:v==="big"?"35px":"20px",textAlign:"center",userSelect:"none",cursor:"default",borderRadius:2,border:"none",...!S&&{textDecoration:"line-through",color:x.rS.pageTextSubdued},...x.W2.smallText,...c&&{backgroundColor:x.rS.tableBorderHover,color:x.rS.buttonPrimaryText},...(p||c)&&{borderRadius:0,cursor:"pointer"},...p&&!c&&{backgroundColor:"rgba(100, 100, 100, .15)"},...p&&c&&{backgroundColor:x.rS.tableBorderHover},...(r===y||r===s&&!c)&&{borderTopLeftRadius:2,borderBottomLeftRadius:2},...(r===w||r===d&&!c)&&{borderTopRightRadius:2,borderBottomRightRadius:2},...g&&{fontWeight:"bold"}},onClick:()=>o(e),onMouseEnter:()=>l(r),onMouseLeave:()=>l(null),children:[v==="small"?a[0]:a,b&&(0,i.jsx)(m.Z,{style:{position:"absolute",top:-14,left:0,fontSize:10,fontWeight:"bold",color:S?x.rS.pageText:x.rS.pageTextSubdued},children:f})]},e)})})})};function j(e){return[{id:"to-be-budgeted",name:"To Be Budgeted",categories:[{id:"to-be-budgeted",name:"To Be Budgeted"}]},...e]}function C(e){return[e.filter(e=>!e.is_income),e.find(e=>e.is_income)]}function Z(e){return e===0||e==="0"||e===""?{color:x.rS.altMenuItemText}:null}function k(e){const t=Z(e);if(t){return t}if(e<0){return{color:x.rS.errorText}}}function T(e){return{color:e<0?x.rS.errorText:e===0?x.rS.altMenuItemText:x.rS.noticeText}}function A(e,t,n){if(t==="top"){return{targetId:n}}else{let t=e.findIndex(e=>e.id===n);if(t===-1){throw new Error("findSort: item not found: "+n)}let r=t+1;if(r<e.length-1){return{targetId:e[r].id}}else{return{targetId:null}}}}function B(e,t,n){if(t==="bottom"){return{targetId:n}}else{let t=e.findIndex(e=>e.id===n);if(t===-1){throw new Error("findSort: item not found: "+n)}let r=t-1;if(r>=0){return{targetId:e[r].id}}else{return{targetId:null}}}}function M(){return Math.max(x.W2.scrollbarWidth-2,0)};const I=(0,a.memo)(({startMonth:e,onMonthSelect:t,numMonths:n,monthBounds:r,style:o})=>{function a(e){let t=r.start;let o=h.W9(r.end,n-1);if(e<t){return t}else if(e>o){return o}return e}return(0,i.jsx)(m.Z,{style:{marginLeft:200+5,flexShrink:0},children:(0,i.jsx)(m.Z,{style:{marginRight:5+M()},children:(0,i.jsx)(S,{startMonth:e,numDisplayed:n,monthBounds:r,style:{paddingTop:5},onSelect:e=>t(a(e))})})})});var R=I;var E=n(63541);var D=n(35562);var P=n(40774);var W=n(57201);function L(e,t,n){return{start:t<e.start?e.start:t,end:n>e.end?e.end:n}}let N=(0,a.createContext)();function F({startMonth:e,numMonths:t,monthBounds:n,type:r,children:o}){let a=h.zI(e,t-1);let s=L(n,e,a);let l=h.Do(s.start,s.end);return(0,i.jsx)(N.Provider,{value:{months:l,type:r},children:o})};function _({component:e,editingIndex:t,args:n,style:r}){let{months:o,type:s}=(0,a.useContext)(N);return o.map((o,a)=>{let l=t===a;return(0,i.jsx)(W.Z.Provider,{value:h.cv(o,s),children:(0,i.jsx)(m.Z,{style:{flex:1,borderLeft:"1px solid "+x.rS.tableBorder,...r},children:(0,i.jsx)(e,{monthIndex:a,editing:l,...n})})},a)})}var H=_;var O=n(60481);var G=n(56816);var z=n(31941);var U=n(7709);var K=n(99818);var $=n(53440);var Q=n(10959);var V=n(69304);const q=e=>(0,i.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 19 24",style:{color:"inherit",...e.style},children:(0,i.jsx)("path",{fill:"currentColor",d:"M17 24H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h9a1 1 0 0 1 .707.293l7 7A1 1 0 0 1 19 8v14a2 2 0 0 1-2 2ZM2 21.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V9a.5.5 0 0 0-.5-.5h-4a2 2 0 0 1-2-2v-4A.5.5 0 0 0 10 2H2.5a.5.5 0 0 0-.5.5v19Z"})});var X=q;var J=n(76447);function Y(){const e=this.data();function t(t,n){const r=e[t]?e[t]:e[t]=[];r.push(n)}t("fromMarkdownExtensions",{enter:{lineEndingBlank:function e(e){this.enter({type:"break",value:"",data:{},children:[]},e)}},exit:{lineEndingBlank:function e(e){this.exit(e)}}})}function ee(){return J.F}var et=n(77644);const en=[Y,$.Z,ee];const er=(0,K.iv)({display:"block",maxWidth:350,padding:8,overflowWrap:"break-word","& p":{margin:0,":not(:first-child)":{marginTop:"0.25rem"}},"& ul, & ol":{listStylePosition:"inside",margin:0,paddingLeft:0},"&>* ul, &>* ol":{marginLeft:"1.5rem"},"& li>p":{display:"contents"},"& blockquote":{paddingLeft:"0.75rem",borderLeft:"3px solid "+x.rS.markdownDark,margin:0},"& hr":{borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"1px solid "+x.rS.markdownNormal},"& code":{backgroundColor:x.rS.markdownLight,padding:"0.1rem 0.5rem",borderRadius:"0.25rem"},"& pre":{padding:"0.5rem",backgroundColor:x.rS.markdownLight,borderRadius:"0.5rem",margin:0,":not(:first-child)":{marginTop:"0.25rem"},"& code":{background:"inherit",padding:0,borderRadius:0}},"& table, & th, & td":{border:"1px solid "+x.rS.markdownNormal},"& table":{borderCollapse:"collapse",wordBreak:"break-word"},"& td":{padding:"0.25rem 0.75rem"}});function eo({editable:e,defaultNotes:t,position:n="bottom-left",onClose:r}){let[o,s]=(0,a.useState)(t);let l=(0,a.createRef)();(0,a.useEffect)(()=>{if(e){l.current.focus()}},[l,e]);return(0,i.jsx)(E.u,{position:n,onClose:()=>r(o),children:e?(0,i.jsx)("textarea",{ref:l,className:`${(0,K.iv)({border:"1px solid "+x.rS.buttonNormalBorder,padding:7,minWidth:350,minHeight:120,outline:"none"})}`,value:o||"",onChange:e=>s(e.target.value),placeholder:"Notes (markdown supported)"}):(0,i.jsx)(et.Z,{...er,children:(0,i.jsx)(U.D,{remarkPlugins:en,linkTarget:"_blank",children:o})})})}function ei({id:e,width:t=12,height:n=12,defaultColor:r=x.rS.pageBackgroundModalActive,tooltipPosition:o,style:s}){let[l,c]=(0,a.useState)(false);let u=(0,E.lL)();let h=(0,V.y)(()=>(0,Q.ZP)("notes").filter({id:e}).select("*"),[e]);let p=h&&h.length>0?h[0].note:null;let g=p&&p!=="";function f(t){(0,d.lW)("notes-save",{id:e,note:t});u.close()}const[y,w]=(0,a.useState)(null);const v=()=>{w(setTimeout(()=>{c(true)},300))};const b=()=>{clearTimeout(y);c(false)};const S=u.isOpen||g&&l;return(0,i.jsxs)(m.Z,{style:{flexShrink:0},onMouseEnter:v,onMouseLeave:b,children:[(0,i.jsx)(G.Z,{type:"bare",className:!g&&!S?"hover-visible":"",style:{color:r,...s,...g&&{display:"flex !important"},...S&&{color:x.rS.buttonNormalText}},...u.getOpenEvents(),children:(0,i.jsx)(X,{style:{width:t,height:n}})}),S&&(0,i.jsx)(eo,{editable:u.isOpen,defaultNotes:p,position:o,onClose:f})]})};function ea({innerRef:e,category:t,dragPreview:n,dragging:r,editing:o,style:s,borderColor:l=x.rS.tableBorder,isLast:c,onDragChange:d,onEditMonth:u,onEditName:h,onSave:p,onDelete:g,onHideNewCategory:f}){const y=t.id==="new";const[w,v]=(0,a.useState)(false);const b=(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none",opacity:t.hidden?.33:undefined},children:[(0,i.jsx)("div",{"data-testid":"category-name",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:t.name}),(0,i.jsxs)(m.Z,{style:{flexShrink:0,marginLeft:5},children:[(0,i.jsx)(G.Z,{type:"bare",onClick:e=>{e.stopPropagation();v(true)},style:{color:"currentColor",padding:3},children:(0,i.jsx)(O.Z,{width:14,height:14,style:{color:"currentColor"}})}),w&&(0,i.jsx)(E.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>v(false),children:(0,i.jsx)(z.Z,{onMenuSelect:e=>{if(e==="rename"){h(t.id)}else if(e==="delete"){g(t.id)}else if(e==="toggleVisibility"){p({...t,hidden:!t.hidden})}v(false)},items:[{name:"toggleVisibility",text:t.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},{name:"delete",text:"Delete"}]})})]}),(0,i.jsx)(m.Z,{style:{flex:1}}),(0,i.jsx)(ei,{id:t.id,style:r&&{color:"currentColor"}})]});return(0,i.jsx)(m.Z,{innerRef:e,style:{width:200,"& button":{display:"none"},...!r&&!n&&{"&:hover button":{display:"flex",color:x.rS.tableTextHover}},...r&&{color:x.rS.formInputTextPlaceholderSelected},...n&&{backgroundColor:"white",zIndex:1e4,borderRadius:6,overflow:"hidden"},...s},onKeyDown:e=>{if(e.key==="Enter"){h(null);e.stopPropagation()}},children:(0,i.jsx)(P.F3,{value:t.name,formatter:e=>b,width:"flex",exposed:o||y,onUpdate:e=>{if(y){if(e===""){f()}else if(e!==""){p({...t,name:e})}}else{if(e!==t.name){p({...t,name:e})}}},onBlur:()=>h(null),style:{paddingLeft:13,...c&&{borderBottomWidth:0}},inputProps:{placeholder:y?"New Category Name":""}})})}var es=ea;function el({cat:e,budgetArray:t,editingCell:n,dragState:r,MonthComponent:o,onEditName:a,onEditMonth:s,onSave:l,onDelete:c,onBudgetAction:d,onShowActivity:u,onDragChange:h,onReorder:p}){let g=r&&r.item===e;if(r&&r.item.id===e.cat_group){g=true}let{dragRef:f}=(0,D.O1)({type:"category",onDragChange:h,item:e,canDrag:n===null});let{dropRef:x,dropPos:y}=(0,D.Zj)({types:"category",id:e.id,onDrop:p});return(0,i.jsxs)(P.X2,{innerRef:x,collapsed:true,style:{backgroundColor:"transparent",opacity:e.hidden?.5:undefined},children:[(0,i.jsx)(D.OJ,{pos:y,offset:{top:1}}),(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row"},children:[(0,i.jsx)(es,{innerRef:f,category:e,dragPreview:g&&r.preview,dragging:g&&!r.preview,editing:n&&n.cell==="name"&&n.id===e.id,onEditName:a,onSave:l,onDelete:c,onDragChange:h}),(0,i.jsx)(H,{component:o,editingIndex:n&&n.id===e.id&&n.cell,args:{category:e,onEdit:s,onBudgetAction:d,onShowActivity:u}})]})]})}var ec=el;var ed=n(32951);function eu({group:e,editing:t,collapsed:n,dragPreview:r,innerRef:o,style:s,borderColor:l=x.rS.tableBorder,onEdit:c,onSave:d,onDelete:u,onShowNewCategory:h,onHideNewGroup:p,onToggleCollapse:g}){const f=e.id==="new";const[y,w]=(0,a.useState)(false);const v=(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},onClick:t=>{g(e.id)},children:[!r&&(0,i.jsx)(ed.Z,{width:8,height:8,style:{marginRight:5,marginLeft:5,flexShrink:0,transition:"transform .1s",transform:n?"rotate(-90deg)":""}}),(0,i.jsxs)("div",{style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:[r&&(0,i.jsx)(et.Z,{style:{fontWeight:500},children:"Group: "}),e.name]}),!r&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(m.Z,{style:{marginLeft:5,flexShrink:0},children:[(0,i.jsx)(G.Z,{type:"bare",onClick:e=>{e.stopPropagation();w(true)},style:{padding:3},children:(0,i.jsx)(O.Z,{width:14,height:14})}),y&&(0,i.jsx)(E.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>w(false),children:(0,i.jsx)(z.Z,{onMenuSelect:t=>{if(t==="rename"){c(e.id)}else if(t==="add-category"){h(e.id)}else if(t==="delete"){u(e.id)}else if(t==="toggleVisibility"){d({...e,hidden:!e.hidden})}w(false)},items:[{name:"add-category",text:"Add category"},{name:"toggleVisibility",text:e.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},u&&{name:"delete",text:"Delete"}]})})]}),(0,i.jsx)(m.Z,{style:{flex:1}}),(0,i.jsx)(ei,{id:e.id})]})]});return(0,i.jsx)(m.Z,{innerRef:o,style:{...s,width:200,backgroundColor:x.rS.altTableBackground,"& button":{display:"none"},"&:hover button":{display:"flex",color:x.rS.tableTextHover},...r&&{paddingLeft:10,zIndex:1e4,borderRadius:6,overflow:"hidden"}},onKeyDown:e=>{if(e.key==="Enter"){c(null);e.stopPropagation()}},children:(0,i.jsx)(P.F3,{value:e.name,formatter:e=>v,width:"flex",exposed:t,onUpdate:t=>{if(f){if(t===""){p()}else if(t!==""){d({id:e.id,name:t})}}else{d({id:e.id,name:t})}},onBlur:()=>c(null),style:{fontWeight:600},inputProps:{style:{marginLeft:20},placeholder:f?"New Group Name":""}})})}var eh=eu;function ep({group:e,collapsed:t,editingCell:n,dragState:r,itemPos:o,MonthComponent:a,onEditName:s,onSave:l,onDelete:c,onDragChange:d,onReorderGroup:u,onReorderCategory:h,onToggleCollapse:p,onShowNewCategory:g}){let f=r&&r.item===e;let{dragRef:y}=(0,D.O1)({type:"group",onDragChange:d,item:e,canDrag:n===null});let{dropRef:w,dropPos:v}=(0,D.Zj)({types:"group",id:e.id,onDrop:u});let{dropRef:b,dropPos:S}=(0,D.Zj)({types:"category",id:e.id,onDrop:h,onLongHover:()=>{if(t){p(e.id)}}});return(0,i.jsxs)(P.X2,{collapsed:true,style:{fontWeight:600,opacity:e.hidden?.33:undefined,backgroundColor:x.rS.altTableBackground},children:[r&&!r.preview&&r.type==="group"&&(0,i.jsx)(m.Z,{innerRef:w,style:{position:"absolute",left:0,right:0,height:t?P.dN-1:(1+e.categories.length)*(P.dN-1)+1,zIndex:1e4},children:(0,i.jsx)(D.OJ,{pos:v,offset:{top:1}})}),(0,i.jsx)(D.OJ,{pos:S,offset:{top:1}}),(0,i.jsxs)(m.Z,{innerRef:b,style:{flex:1,flexDirection:"row",opacity:f&&!r.preview?.3:1},children:[(0,i.jsx)(eh,{innerRef:y,group:e,editing:n&&n.cell==="name"&&n.id===e.id,dragPreview:f&&r.preview,collapsed:t,onToggleCollapse:p,onEdit:s,onSave:l,onDelete:c,onShowNewCategory:g}),(0,i.jsx)(H,{component:a,args:{group:e}})]})]})}var eg=ep;function ef({cat:e,isLast:t,editingCell:n,MonthComponent:r,onEditName:o,onEditMonth:a,onSave:s,onDelete:l,onDragChange:c,onBudgetAction:d,onReorder:u,onShowActivity:h}){let{dragRef:p}=(0,D.O1)({type:"income-category",onDragChange:c,item:e,canDrag:n===null});let{dropRef:g,dropPos:f}=(0,D.Zj)({types:"income-category",id:e.id,onDrop:u});return(0,i.jsxs)(P.X2,{innerRef:g,collapsed:true,children:[(0,i.jsx)(D.OJ,{pos:f,offset:{top:1}}),(0,i.jsx)(es,{innerRef:p,category:e,isLast:t,editing:n&&n.cell==="name"&&n.id===e.id,onEditName:o,onSave:s,onDelete:l}),(0,i.jsx)(H,{component:r,editingIndex:n&&n.id===e.id&&n.cell,args:{category:e,onEdit:a,isLast:t,onShowActivity:h,onBudgetAction:d}})]})}var ex=ef;function em({group:e,editingCell:t,collapsed:n,MonthComponent:r,onEditName:o,onSave:a,onToggleCollapse:s,onShowNewCategory:l}){return(0,i.jsxs)(P.X2,{collapsed:true,style:{fontWeight:600,backgroundColor:x.rS.altTableBackground},children:[(0,i.jsx)(eh,{group:e,collapsed:n,editing:t&&t.cell==="name"&&t.id===e.id,onEdit:o,onSave:a,onToggleCollapse:s,onShowNewCategory:l}),(0,i.jsx)(H,{component:r,args:{group:e}})]})}var ey=em;function ew({MonthComponent:e,onShowNewGroup:t}){return(0,i.jsxs)(m.Z,{style:{flexDirection:"row",flex:1},children:[(0,i.jsx)(m.Z,{style:{width:200,alignItems:"flex-start",justifyContent:"flex-start"},children:(0,i.jsx)(G.Z,{onClick:t,style:{fontSize:12,margin:10},children:"Add Group"})}),(0,i.jsx)(H,{component:e,style:{border:0,justifyContent:"flex-end"},editingIndex:undefined,args:undefined})]})}var ev=ew;const eb=(0,a.memo)(({categoryGroups:e,newCategoryForGroup:t,showHiddenCategories:n,isAddingGroup:r,editingCell:o,collapsed:s,setCollapsed:l,dataComponents:c,onBudgetAction:d,onShowActivity:u,onEditName:h,onEditMonth:p,onSaveCategory:g,onSaveGroup:f,onDeleteCategory:y,onDeleteGroup:w,onReorderCategory:v,onReorderGroup:b,onShowNewCategory:S,onHideNewCategory:j,onShowNewGroup:Z,onHideNewGroup:k})=>{let T=(0,a.useMemo)(()=>{let[o,i]=C(e);let a=Array.prototype.concat.apply([],o.map(e=>{if(e.hidden&&!n){return[]}const r=e.categories.filter(e=>n||!e.hidden);let o=[{type:"expense-group",value:{...e}}];if(t===e.id){o.push({type:"new-category"})}return[...o,...(s.includes(e.id)?[]:r).map(e=>({type:"expense-category",value:e}))]}));if(r){a.push({type:"new-group"})}if(i){a=a.concat([{type:"income-separator"},{type:"income-group",value:i},t===i.id&&{type:"new-category"},...(s.includes(i.id)?[]:i.categories.filter(e=>n||!e.hidden)).map(e=>({type:"income-category",value:e}))].filter(e=>e))}return a},[e,s,t,r,n]);let[A,B]=(0,a.useState)(null);let[M,I]=(0,a.useState)(null);function R(e){let{state:t}=e;if(t==="start-preview"){B({type:e.type,item:e.item,preview:true})}else if(t==="start"){if(A){B({...A,preview:false});I(s)}}else if(t==="hover"){B({...A,hoveredId:e.id,hoveredPos:e.pos})}else if(t==="end"){B(null);l(M||[])}}function E(e){if(s.includes(e)){l(s.filter(t=>t!==e))}else{l([...s,e])}}return(0,i.jsx)(m.Z,{style:{marginBottom:10,backgroundColor:"white",overflow:"hidden",boxShadow:x.W2.cardShadow,borderRadius:"0 0 4px 4px",flex:1},children:T.map((n,r)=>{let a;switch(n.type){case"new-group":a=(0,i.jsx)(P.X2,{style:{backgroundColor:x.rS.altTableBackground},children:(0,i.jsx)(eh,{group:{id:"new",name:""},editing:true,onSave:f,onHideNewGroup:k,onEdit:h})});break;case"new-category":a=(0,i.jsx)(P.X2,{children:(0,i.jsx)(es,{category:{name:"",cat_group:t,is_income:t===e.find(e=>e.is_income).id,id:"new"},editing:true,onSave:g,onHideNewCategory:j,onEditName:h})});break;case"expense-group":a=(0,i.jsx)(eg,{group:n.value,editingCell:o,collapsed:s.includes(n.value.id),MonthComponent:c.ExpenseGroupComponent,dragState:A,onEditName:h,onSave:f,onDelete:w,onDragChange:R,onReorderGroup:b,onReorderCategory:v,onToggleCollapse:E,onShowNewCategory:S});break;case"expense-category":a=(0,i.jsx)(ec,{cat:n.value,editingCell:o,MonthComponent:c.ExpenseCategoryComponent,dragState:A,onEditName:h,onEditMonth:p,onSave:g,onDelete:y,onDragChange:R,onReorder:v,onBudgetAction:d,onShowActivity:u});break;case"income-separator":a=(0,i.jsx)(m.Z,{style:{height:x.W2.incomeHeaderHeight,backgroundColor:"white"},children:(0,i.jsx)(ev,{MonthComponent:c.IncomeHeaderComponent,onShowNewGroup:Z})});break;case"income-group":a=(0,i.jsx)(ey,{group:n.value,editingCell:o,MonthComponent:c.IncomeGroupComponent,collapsed:s.includes(n.value.id),onEditName:h,onSave:f,onToggleCollapse:E,onShowNewCategory:S});break;case"income-category":a=(0,i.jsx)(ex,{cat:n.value,editingCell:o,isLast:r===T.length-1,MonthComponent:c.IncomeCategoryComponent,onEditName:h,onEditMonth:p,onSave:g,onDelete:y,onDragChange:R,onReorder:v,onBudgetAction:d,onShowActivity:u});break;default:throw new Error("Unknown item type: "+n.type)}let l=r===0?"first":r===T.length-1?"last":null;return(0,i.jsx)(D.aB.Provider,{value:l,children:(0,i.jsx)(m.Z,{style:!A&&{":hover":{backgroundColor:"#fcfcfc"}},children:a})},n.value?n.value.id:n.type==="income-separator"?"separator":r)})})});var eS=eb;var ej=n(13015);function eC({SummaryComponent:e}){let{months:t}=(0,a.useContext)(N);let[n,r]=(0,a.useState)(0);let[o,s]=(0,ej.q_)(()=>({x:0,config:{mass:3,tension:600,friction:80}}));let l=(0,b.Z)((0,a.useCallback)(e=>{r(e.width)},[]));let c=(0,a.useRef)(t[0]);let d=[...t];d.unshift(h.W9(t[0],1));d.push(h.zI(t[t.length-1],1));let u=n/t.length;(0,a.useLayoutEffect)(()=>{let e=c.current;let n=e>t[0];let r=u;let o=n?-r*2:0;if(e!==d[0]&&e!==d[2]){o=-r}let i=-r;s.start({from:{x:o},x:i})},[t[0]]);(0,a.useLayoutEffect)(()=>{c.current=t[0]},[t[0]]);(0,a.useLayoutEffect)(()=>{s.start({from:{x:-u},to:{x:-u}})},[u]);return(0,i.jsx)("div",{className:`${(0,K.iv)([{flex:1,overflow:"hidden"},t.length===1&&{marginLeft:-4,marginRight:-4}])}`,ref:l,children:(0,i.jsx)(ej.q.div,{className:"view",style:{flexDirection:"row",width:n,willChange:"transform",transform:o.x.to(e=>`translateX(${e}px)`)},children:d.map(t=>{return(0,i.jsx)(m.Z,{style:{flex:`0 0 ${u}px`,paddingLeft:4,paddingRight:4},children:(0,i.jsx)(e,{month:t})},t)})})})}var eZ=n(68929);const ek=(0,a.memo)(function e({MonthComponent:e,toggleHiddenCategories:t,expandAllCategories:n,collapseAllCategories:r}){const[o,s]=(0,a.useState)(false);return(0,i.jsxs)(m.Z,{"data-testid":"budget-totals",style:{backgroundColor:"white",flexDirection:"row",flexShrink:0,boxShadow:x.W2.cardShadow,marginLeft:5,marginRight:5+M(),borderRadius:"4px 4px 0 0",borderBottom:"1px solid "+x.rS.tableBorder},children:[(0,i.jsxs)(m.Z,{style:{width:200,color:x.rS.pageTextLight,justifyContent:"center",paddingLeft:15,paddingRight:5,display:"flex",flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},children:[(0,i.jsx)(m.Z,{style:{flexGrow:"1"},children:"Category"}),(0,i.jsxs)(G.Z,{type:"bare",onClick:()=>{s(true)},style:{color:"currentColor",padding:3},children:[(0,i.jsx)(eZ.Z,{width:15,height:15,style:{color:x.rS.altpageTextSubdued}}),o&&(0,i.jsx)(E.u,{position:"bottom-right",width:200,style:{padding:0},onClose:()=>{s(false)},children:(0,i.jsx)(z.Z,{onMenuSelect:e=>{if(e==="toggleVisibility"){t()}else if(e==="expandAllCategories"){n()}else if(e==="collapseAllCategories"){r()}s(false)},items:[{name:"toggleVisibility",text:"Toggle hidden"},{name:"expandAllCategories",text:"Expand all"},{name:"collapseAllCategories",text:"Collapse all"}]})})]})]}),(0,i.jsx)(H,{component:e})]})});var eT=ek;class eA extends a.Component{constructor(e){super(e);this.budgetCategoriesRef=(0,a.createRef)();this.state={editing:null,draggingState:null,showHiddenCategories:e.prefs["budget.showHiddenCategories"]??false}}onEditMonth=(e,t)=>{this.setState({editing:e?{id:e,cell:t}:null})};onEditName=e=>{this.setState({editing:e?{id:e,cell:"name"}:null})};onReorderCategory=(e,t,n)=>{let{categoryGroups:r}=this.props;let o=!!r.find(e=>e.id===n);if(o){let{targetId:o}=B(r,t,n);let i=r.find(e=>e.id===o);if(i){let{categories:n}=i;this.props.onReorderCategory({id:e,groupId:i.id,targetId:n.length===0||t==="top"?null:n[0].id})}}else{let o;for(let e of r){if(e.categories.find(e=>e.id===n)){o=e;break}}this.props.onReorderCategory({id:e,groupId:o.id,...A(o.categories,t,n)})}};onReorderGroup=(e,t,n)=>{let{categoryGroups:r}=this.props;this.props.onReorderGroup({id:e,...A(r,t,n)})};moveVertically=e=>{let{editing:t}=this.state;let{type:n,categoryGroups:r,collapsed:o}=this.props;const i=r.reduce((e,t)=>{if(o.includes(t.id)){return e.concat({id:t.id,isGroup:true})}return e.concat([{id:t.id,isGroup:true},...t.categories])},[]);if(t){const r=i.findIndex(e=>e.id===t.id);let o=r+e;while(o>=0&&o<i.length){const r=i[o];if(r.isGroup){o+=e;continue}else if(n==="report"||!r.is_income){this.onEditMonth(r.id,t.cell);return}else{break}}}};onKeyDown=e=>{if(!this.state.editing){return null}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault();this.moveVertically(e.shiftKey?-1:1)}};onShowActivity=(e,t,n)=>{this.props.onShowActivity(e,t,this.resolveMonth(n))};onBudgetAction=(e,t,n)=>{this.props.onBudgetAction(this.resolveMonth(e),t,n)};resolveMonth=e=>{return h.zI(this.props.startMonth,e)};clearEditing(){this.setState({editing:null})}toggleHiddenCategories=()=>{this.setState(e=>({showHiddenCategories:!e.showHiddenCategories}));this.props.savePrefs({"budget.showHiddenCategories":!this.state.showHiddenCategories})};expandAllCategories=()=>{this.props.setCollapsed([])};collapseAllCategories=()=>{let{setCollapsed:e,categoryGroups:t}=this.props;e(t.map(e=>e.id))};render(){let{type:e,categoryGroups:t,prewarmStartMonth:n,startMonth:r,numMonths:o,monthBounds:a,collapsed:s,setCollapsed:l,newCategoryForGroup:c,dataComponents:d,isAddingGroup:u,onSaveCategory:h,onSaveGroup:p,onDeleteCategory:g,onDeleteGroup:f,onShowNewCategory:y,onHideNewCategory:w,onShowNewGroup:v,onHideNewGroup:b}=this.props;let{editing:S,draggingState:j,showHiddenCategories:C}=this.state;return(0,i.jsxs)(m.Z,{"data-testid":"budget-table",style:{flex:1,...x.W2.lightScrollbar&&{"& ::-webkit-scrollbar":{backgroundColor:"transparent"},"& ::-webkit-scrollbar-thumb:vertical":{backgroundColor:"white"}}},children:[(0,i.jsxs)(m.Z,{style:{flexDirection:"row",overflow:"hidden",flexShrink:0,paddingLeft:5,paddingRight:5+M()},children:[(0,i.jsx)(m.Z,{style:{width:200}}),(0,i.jsx)(F,{startMonth:n,numMonths:o,monthBounds:a,type:e,children:(0,i.jsx)(eC,{SummaryComponent:d.SummaryComponent})})]}),(0,i.jsxs)(F,{startMonth:r,numMonths:o,monthBounds:a,type:e,children:[(0,i.jsx)(eT,{MonthComponent:d.BudgetTotalsComponent,toggleHiddenCategories:this.toggleHiddenCategories,expandAllCategories:this.expandAllCategories,collapseAllCategories:this.collapseAllCategories}),(0,i.jsx)(E.Hp.Provider,{value:this.budgetCategoriesRef,children:(0,i.jsx)(m.Z,{style:{overflowY:"scroll",overflowAnchor:"none",flex:1,paddingLeft:5,paddingRight:5},innerRef:this.budgetCategoriesRef,children:(0,i.jsx)(m.Z,{style:{opacity:j?.5:1,flexShrink:0},onKeyDown:this.onKeyDown,innerRef:e=>this.budgetDataNode=e,children:(0,i.jsx)(eS,{showHiddenCategories:C,categoryGroups:t,newCategoryForGroup:c,isAddingGroup:u,editingCell:S,collapsed:s,setCollapsed:l,dataComponents:d,onEditMonth:this.onEditMonth,onEditName:this.onEditName,onSaveCategory:h,onSaveGroup:p,onDeleteCategory:g,onDeleteGroup:f,onReorderCategory:this.onReorderCategory,onReorderGroup:this.onReorderGroup,onShowNewCategory:y,onHideNewCategory:w,onShowNewGroup:v,onHideNewGroup:b,onBudgetAction:this.onBudgetAction,onShowActivity:this.onShowActivity})})})})]})]})}}var eB=eA;let eM=(0,a.createContext)([]);function eI(e){let t=e-200;if(t<500){return 1}else if(t<750){return 2}else if(t<1e3){return 3}else if(t<1250){return 4}else if(t<1500){return 5}return 6}const eR=(0,a.forwardRef)(({width:e,height:t,categoryGroups:n,prewarmStartMonth:r,startMonth:o,maxMonths:l=3,monthBounds:c,onMonthSelect:d,onPreload:u,...h},g)=>{let f=(0,s.v9)(e=>e.prefs.local);let{setDisplayMax:x}=(0,v.s)();let y=(0,p.o)();let w=eI(e);let b=Math.min(w,l);let S=200+500*b;(0,a.useEffect)(()=>{x(w)},[w]);function j(e){d(e,b)}return(0,i.jsx)(eM.Provider,{value:n,children:(0,i.jsx)(m.Z,{style:{width:e,height:t,alignItems:"center",opacity:e<=0||t<=0?0:1},children:(0,i.jsxs)(m.Z,{style:{width:"100%",maxWidth:S},children:[(0,i.jsx)(R,{startMonth:r,numMonths:b,monthBounds:c,onMonthSelect:j}),(0,i.jsx)(eB,{ref:g,categoryGroups:n,prewarmStartMonth:r,startMonth:o,numMonths:b,monthBounds:c,prefs:f,...y,...h})]})})})});var eE=(0,a.forwardRef)((e,t)=>{return(0,i.jsx)(w.Z,{children:({width:n,height:r})=>(0,i.jsx)(eR,{ref:t,width:n,height:r,...e})})});var eD=n(46055);var eP=n(89362);function eW(e,t){throw new Error(t+": "+JSON.stringify(e.str.slice(e.index,10)))}function eL(e){return e.str[e.index]}function eN(e){if(e.index>=e.str.length){return null}let t=eL(e);e.index++;return t}function eF(e,t){if(eL(e)===t){eN(e);return true}return false}function e_(e){let t=eL(e)==="-";if(t){eN(e)}if(/\p{Sc}/u.test(eL(e))){eN(e)}let n="";while(eL(e)&&eL(e).match(/[0-9,.]/)){let t=(0,eP.ff)().separator===","?".":",";if(eL(e)===t){eN(e)}else{n+=eN(e)}}if(n===""){eW(e,"Unexpected character")}let r=parseFloat(n.replace((0,eP.ff)().separator,"."));return t?-r:r}function eH(e){if(eL(e)==="("){eN(e);let t=eG(e);if(eL(e)!==")"){eW(e,"Unbalanced parentheses")}eN(e);return t}return e_(e)}function eO(...e){return e.reduce((e,t)=>{return n=>{let r=e(n);while(eF(n,t)){r={op:t,left:r,right:e(n)}}return r}},eH)}let eG=eO("^","/","*","-","+");function ez(e){let t={str:e.replace(/\s/g,""),index:0};return eG(t)}function eU(e){if(typeof e==="number"){return e}let{left:t,right:n,op:r}=e;switch(r){case"+":return eU(t)+eU(n);case"-":return eU(t)-eU(n);case"*":return eU(t)*eU(n);case"/":return eU(t)/eU(n);case"^":return Math.pow(eU(t),eU(n));default:throw new Error("Unknown operator: "+r)}}function eK(e,t=null){if(e===""){return t}let n;try{n=eU(ez(e))}catch(e){return t}return isNaN(n)?t:n}var e$=n(52582);var eQ=n(5291);var eV=n(57651);var eq=n(1071);function eX({carryover:e,balance:t,disabled:n}){let r=(0,eV.Z)(e);let o=(0,eV.Z)(t);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e$.Z,{binding:t,type:"financial",getStyle:k,style:{textAlign:"right",...!n&&{cursor:"pointer",":hover":{textDecoration:"underline"}}}}),r===true&&(0,i.jsx)(m.Z,{style:{alignSelf:"center",marginLeft:2,position:"absolute",right:-4,top:0,bottom:0,justifyContent:"center"},children:(0,i.jsx)(eq.Z,{width:7,height:7,style:k(o)})})]})};const eJ=e=>(0,i.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,i.jsx)("path",{d:"M12 13.584a2.643 2.643 0 0 1-1.875-.775L.584 3.268a1.768 1.768 0 0 1 2.5-2.5l8.739 8.739a.25.25 0 0 0 .354 0L20.916.768a1.768 1.768 0 0 1 2.5 2.5l-9.541 9.541a2.643 2.643 0 0 1-1.875.775Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M12 23.75a2.643 2.643 0 0 1-1.875-.775L.584 13.434a1.768 1.768 0 0 1 2.5-2.5l8.739 8.739a.25.25 0 0 0 .354 0l8.739-8.739a1.768 1.768 0 0 1 2.5 2.5l-9.541 9.541A2.643 2.643 0 0 1 12 23.75Z",fill:"currentColor"})]});var eY=eJ;const e0=e=>(0,i.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,i.jsx)("path",{d:"M12 10.416a2.643 2.643 0 0 1 1.875.775l9.541 9.541a1.768 1.768 0 0 1-2.5 2.5l-8.739-8.739a.25.25 0 0 0-.354 0l-8.739 8.739a1.768 1.768 0 0 1-2.5-2.5l9.541-9.541A2.643 2.643 0 0 1 12 10.416Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M12 .25a2.643 2.643 0 0 1 1.875.775l9.541 9.541a1.768 1.768 0 0 1-2.5 2.5l-8.739-8.739a.25.25 0 0 0-.354 0l-8.739 8.739a1.768 1.768 0 0 1-2.5-2.5l9.541-9.541A2.643 2.643 0 0 1 12 .25Z",fill:"currentColor"})]});var e1=e0;var e2=n(30715);function e5({style:e,contentStyle:t,children:n,renderContent:r,disabled:o}){let[s,l]=(0,a.useState)(false);const c=(0,a.useCallback)(()=>{if(!o){l(true)}},[o]);const d=(0,a.useCallback)(()=>{if(!o){l(false)}},[o]);(0,a.useEffect)(()=>{if(o&&s){l(false)}},[o,s]);return(0,i.jsxs)(m.Z,{style:e,children:[(0,i.jsx)(m.Z,{onMouseEnter:c,onMouseLeave:d,style:t,children:n}),s&&r()]})}var e8=n(84196);var e4=n(16853);let e3=(0,a.createContext)(null);function e6({summaryCollapsed:e,onBudgetAction:t,onToggleSummaryCollapse:n,children:r}){let o=h.dK();return(0,i.jsx)(e3.Provider,{value:{currentMonth:o,summaryCollapsed:e,onBudgetAction:t,onToggleSummaryCollapse:n},children:r})}function e7(){return(0,a.useContext)(e3)};function e9({style:e,progress:t,color:n,backgroundColor:r}){let o=4;let a=2*Math.PI*o;let s=t*a;let l=a;return(0,i.jsxs)("svg",{viewBox:"0 0 20 20",style:e,children:[(0,i.jsx)("circle",{r:"10",cx:"10",cy:"10",fill:r}),(0,i.jsx)("circle",{r:o,cx:"10",cy:"10",fill:"none",stroke:n,strokeWidth:o*2,strokeDasharray:`${s} ${l}`,transform:"rotate(-90) translate(-20)"})," "]})}function te(e,t){if(t===0){if(e>0){return 1}return 0}return e/t}function tt({current:e,target:t}){let n=(0,eV.Z)(e)||0;let r=(0,eV.Z)(t)||0;let o=false;if(n<0){o=true;n=-n}let a=te(n,r);return(0,i.jsx)(e9,{progress:a,color:o?x.rS.errorText:x.rS.noticeText,backgroundColor:o?x.rS.errorBackground:x.rS.pageBackground,style:{width:20,height:20}})}function tn({current:e,target:t}){let n=(0,eV.Z)(e)||0;let r=(0,eV.Z)(t)||0;n=Math.max(-n,0);let o;let a=false;if(n>r){o=(n-r)/r;a=true}else{o=te(n,r)}return(0,i.jsx)(e9,{progress:o,color:a?x.rS.errorText:x.rS.noticeText,backgroundColor:a?x.rS.errorBackground:x.rS.pageBackground,style:{width:20,height:20}})}function tr({title:e,current:t,target:n,ProgressComponent:r,style:o}){return(0,i.jsxs)(m.Z,{style:{lineHeight:1.5,flexDirection:"row",alignItems:"center",fontSize:14,...o},children:[(0,i.jsx)(r,{current:t,target:n}),(0,i.jsxs)(m.Z,{style:{marginLeft:10},children:[(0,i.jsx)(m.Z,{children:(0,i.jsx)(et.Z,{style:{color:x.rS.pageTextLight},children:e})}),(0,i.jsxs)(et.Z,{children:[(0,i.jsx)(e$.Z,{binding:t,type:"financial"}),(0,i.jsxs)(et.Z,{style:{color:x.rS.pageTextSubdued,fontStyle:"italic"},children:[" of ",(0,i.jsx)(e$.Z,{binding:n,type:"financial",style:x.W2.notFixed})]})]})]})]})}function to({style:e}){return(0,i.jsx)(tr,{title:"Income",current:eD.u8.totalIncome,target:eD.u8.totalBudgetedIncome,ProgressComponent:tt,style:e})}function ti({style:e}){return(0,i.jsx)(tr,{title:"Expenses",current:eD.u8.totalSpent,target:eD.u8.totalBudgetedExpense,ProgressComponent:tn,style:e})}function ta({projected:e,style:t}){let n=(0,eV.Z)(eD.u8.totalBudgetedSaved)||0;let r=(0,eV.Z)(eD.u8.totalSaved)||0;let o=(0,eQ.Z)();let a=e?n:r;let s=a<0;return(0,i.jsxs)(m.Z,{style:{alignItems:"center",fontSize:14,...t},children:[e?(0,i.jsx)(et.Z,{style:{color:x.rS.pageTextLight},children:"Projected Savings:"}):(0,i.jsx)(m.Z,{style:{color:x.rS.pageTextLight},children:s?"Overspent:":"Saved:"}),(0,i.jsx)(e5,{renderContent:()=>{if(!e){let e=r-n;return(0,i.jsxs)(E.u,{position:"bottom-center",style:{padding:10,fontSize:14},children:[(0,i.jsx)(e2.Z,{left:"Projected Savings:",right:(0,i.jsx)(et.Z,{style:{...T(n),...x.W2.tnum},children:o(n,"financial-with-sign")})}),(0,i.jsx)(e2.Z,{left:"Difference:",right:(0,i.jsx)(et.Z,{style:{...T(e),...x.W2.tnum},children:o(e,"financial-with-sign")})})]})}return null},children:(0,i.jsx)(m.Z,{className:`${(0,K.iv)([{fontSize:25,color:e?x.rS.alt2WarningText:s?x.rS.alt2ErrorText:x.rS.altUpcomingText}])}`,children:(0,i.jsx)(e4.ZP,{blurIntensity:7,children:o(a,"financial")})})})]})}function ts({month:e}){let{currentMonth:t,summaryCollapsed:n,onBudgetAction:r,onToggleSummaryCollapse:o}=e7();const s=(0,f.Z)("goalTemplatesEnabled");let[l,c]=(0,a.useState)(false);function d(){c(true)}function u(){c(false)}let p=n?eY:e1;return(0,i.jsx)(m.Z,{style:{backgroundColor:x.rS.tableBackground,boxShadow:x.W2.cardShadow,borderRadius:6,marginLeft:0,marginRight:0,marginTop:5,flex:1,cursor:"default",marginBottom:5,overflow:"hidden","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:(0,i.jsxs)(W.Z.Provider,{value:h.cv(e),children:[(0,i.jsxs)(m.Z,{style:{padding:"0 13px",...n?{margin:"10px 0"}:{marginTop:16}},children:[(0,i.jsx)(m.Z,{style:{position:"absolute",left:10,top:0},children:(0,i.jsx)(G.Z,{type:"bare",className:"hover-visible",onClick:o,children:(0,i.jsx)(p,{width:13,height:13,style:{color:x.rS.pageTextSubdued,margin:1}})})}),(0,i.jsx)("div",{className:`${(0,K.iv)([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"}])}`,children:h.WU(e,"MMMM")}),(0,i.jsxs)(m.Z,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[(0,i.jsx)(m.Z,{children:(0,i.jsx)(ei,{id:`budget-${e}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:x.rS.pageTextSubdued})}),(0,i.jsxs)(m.Z,{style:{userSelect:"none"},children:[(0,i.jsx)(G.Z,{type:"bare",onClick:d,children:(0,i.jsx)(eZ.Z,{width:15,height:15,style:{color:x.rS.altpageTextSubdued}})}),l&&(0,i.jsx)(E.u,{position:"bottom-right",width:200,style:{padding:0},onClose:u,children:(0,i.jsx)(z.Z,{onMenuSelect:t=>{u();r(e,t)},items:[{name:"copy-last",text:"Copy last month’s budget"},{name:"set-zero",text:"Set budgets to zero"},{name:"set-3-avg",text:"Set budgets to 3 month average"},s&&{name:"check-templates",text:"Check templates"},s&&{name:"apply-goal-template",text:"Apply budget template"},s&&{name:"overwrite-goal-template",text:"Overwrite with budget template"}]})})]})]})]}),!n&&(0,i.jsxs)(e8.Z,{spacing:2,style:{alignSelf:"center",backgroundColor:x.rS.tableRowHeaderBackground,borderRadius:4,padding:"10px 15px",marginTop:13},children:[(0,i.jsx)(to,{}),(0,i.jsx)(ti,{})]}),n?(0,i.jsx)(m.Z,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:x.rS.tableRowHeaderBackground,borderTop:"1px solid "+x.rS.tableBorder},children:(0,i.jsx)(ta,{projected:e>=t})}):(0,i.jsx)(ta,{projected:e>=t,style:{marginTop:13,marginBottom:20}})]})})};let tl={flex:1,padding:"0 5px",textAlign:"right"};const tc=(0,a.memo)(function e(){const e=(0,eQ.Z)();return(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row",marginRight:x.W2.monthRightPadding,paddingTop:10,paddingBottom:10},children:[(0,i.jsxs)(m.Z,{style:tl,children:[(0,i.jsx)(et.Z,{style:{color:x.rS.pageTextLight},children:"Budgeted"}),(0,i.jsx)(e$.Z,{binding:eD.u8.totalBudgetedExpense,type:"financial",style:{color:x.rS.pageTextLight,fontWeight:600},formatter:t=>{return e(parseFloat(t||"0"),"financial")}})]}),(0,i.jsxs)(m.Z,{style:tl,children:[(0,i.jsx)(et.Z,{style:{color:x.rS.pageTextLight},children:"Spent"}),(0,i.jsx)(e$.Z,{binding:eD.u8.totalSpent,type:"financial",style:{color:x.rS.pageTextLight,fontWeight:600}})]}),(0,i.jsxs)(m.Z,{style:tl,children:[(0,i.jsx)(et.Z,{style:{color:x.rS.pageTextLight},children:"Balance"}),(0,i.jsx)(e$.Z,{binding:eD.u8.totalLeftover,type:"financial",style:{color:x.rS.pageTextLight,fontWeight:600}})]})]})});function td(){return(0,i.jsxs)(m.Z,{style:{flexDirection:"row",marginRight:x.W2.monthRightPadding,paddingBottom:5},children:[(0,i.jsx)(m.Z,{style:tl,children:(0,i.jsx)(et.Z,{style:{color:x.rS.pageTextLight},children:"Budgeted"})}),(0,i.jsx)(m.Z,{style:tl,children:(0,i.jsx)(et.Z,{style:{color:x.rS.pageTextLight},children:"Received"})})]})}const tu=(0,a.memo)(function e({group:e}){let{id:t}=e;return(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row"},children:[(0,i.jsx)(P.OX,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...x.W2.tnum},valueProps:{binding:eD.u8.groupBudgeted(t),type:"financial"}}),(0,i.jsx)(P.OX,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...x.W2.tnum},valueProps:{binding:eD.u8.groupSumAmount(t),type:"financial"}}),!e.is_income&&(0,i.jsx)(P.OX,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:x.W2.monthRightPadding,...x.W2.tnum},valueProps:{binding:eD.u8.groupBalance(t),type:"financial",privacyFilter:{style:{paddingRight:x.W2.monthRightPadding}}}})]})});function th({categoryId:e,tooltip:t,monthIndex:n,onBudgetAction:r}){let o=(0,eV.Z)(eD.u8.catCarryover(e));return(0,i.jsx)(E.u,{position:"bottom-right",width:200,style:{padding:0},onClose:t.close,children:(0,i.jsx)(z.Z,{onMenuSelect:i=>{r(n,"carryover",{category:e,flag:!o});t.close()},items:[{name:"carryover",text:o?"Remove overspending rollover":"Rollover overspending"}]})})}const tp=(0,a.memo)(function e({monthIndex:e,category:t,editing:n,onEdit:r,onBudgetAction:o,onShowActivity:s}){let l=(0,E.lL)();const[c,d]=(0,a.useState)(false);const[u,h]=(0,a.useState)(false);const p=(0,f.Z)("goalTemplatesEnabled");return(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>h(true),onMouseLeave:()=>{h(false)},children:[!n&&(u||c)&&(0,i.jsxs)(m.Z,{style:{flexShrink:0,marginRight:0,marginLeft:3,justifyContent:"center"},children:[(0,i.jsx)(G.Z,{type:"bare",onClick:e=>{e.stopPropagation();d(true)},style:{padding:3},children:(0,i.jsx)(O.Z,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&(0,i.jsx)(E.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(false),children:(0,i.jsx)(z.Z,{onMenuSelect:n=>{o(e,n,{category:t.id});d(false)},items:[{name:"copy-single-last",text:"Copy last month’s budget"},{name:"set-single-3-avg",text:"Set to 3 month average"},{name:"set-single-6-avg",text:"Set to 6 month average"},{name:"set-single-12-avg",text:"Set to yearly average"},p&&{name:"apply-single-category-template",text:"Apply budget template"}]})})]}),(0,i.jsx)(P.OX,{name:"budget",exposed:n,focused:n,width:"flex",onExpose:()=>r(t.id,e),style:{...n&&{zIndex:100},...x.W2.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+x.rS.mobileAccountShadow,backgroundColor:x.rS.tableBackground}},valueProps:{binding:eD.u8.catBudgeted(t.id),type:"financial",getValueStyle:Z,formatExpr:e=>{return(0,eP.zA)(e)},unformatExpr:e=>{return(0,eP.l9)(eK(e,0))}},inputProps:{onBlur:()=>{r(null)},style:{backgroundColor:"white"}},onSave:n=>{o(e,"budget-amount",{category:t.id,amount:n})}})]}),(0,i.jsx)(P.gN,{name:"spent",width:"flex",style:{textAlign:"right"},children:(0,i.jsx)("span",{"data-testid":"category-month-spent",onClick:()=>s(t.name,t.id,e),children:(0,i.jsx)(e$.Z,{binding:eD.u8.catSumAmount(t.id),type:"financial",getStyle:Z,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),!t.is_income&&(0,i.jsxs)(P.gN,{name:"balance",width:"flex",style:{paddingRight:x.W2.monthRightPadding,textAlign:"right"},children:[(0,i.jsx)("span",{...t.is_income?{}:l.getOpenEvents(),children:(0,i.jsx)(eX,{disabled:t.is_income,carryover:eD.u8.catCarryover(t.id),balance:eD.u8.catBalance(t.id)})}),l.isOpen&&(0,i.jsx)(th,{categoryId:t.id,tooltip:l,monthIndex:e,onBudgetAction:o})]})]})});const tg=tu;const tf=tp;const tx=tu;const tm=tp;var ty=n(50151);var tw=n(91871);var tv=n(383);function tb({initialAmount:e,initialAmountName:t,showToBeBudgeted:n,tooltipProps:r,onSubmit:o,onClose:s}){let l=(0,c.M)();let d=(0,a.useContext)(W.Z);let u=(0,a.useContext)(eM);u=u.filter(e=>!e.is_income);if(n){u=j(u)}let[h,p]=(0,a.useState)(null);let[g,f]=(0,a.useState)(null);(0,a.useEffect)(()=>{(async()=>{if(t){const e=await l.get(d,t);p((0,eP.zA)(Math.max(e.value,0)))}else{p((0,eP.zA)(Math.max(e,0)))}})()},[]);function x(){let e=eK(h,null);if(e&&g){o((0,eP.l9)(e),g);s()}}if(h===null){return null}return(0,i.jsxs)(E.u,{position:"bottom-right",width:200,style:{padding:10},...r,onClose:s,children:[(0,i.jsx)(m.Z,{style:{marginBottom:5},children:"Transfer this amount:"}),(0,i.jsx)(m.Z,{children:(0,i.jsx)(tw.Z,{children:(0,i.jsx)(tv.ZP,{value:h,onChange:e=>p(e.target["value"]),onEnter:x})})}),(0,i.jsx)(m.Z,{style:{margin:"10px 0 5px 0"},children:"To:"}),(0,i.jsx)(ty.Z,{categoryGroups:u,value:null,openOnFocus:true,onUpdate:e=>{},onSelect:e=>f(e),inputProps:{onEnter:x,placeholder:"(none)"}}),(0,i.jsx)(m.Z,{style:{alignItems:"flex-end",marginTop:10},children:(0,i.jsx)(G.Z,{type:"primary",style:{fontSize:12,paddingTop:3,paddingBottom:3},onClick:x,children:"Transfer"})})]})}var tS=n(24924);var tj=n(50606);function tC({onSubmit:e,onClose:t}){const n=(0,c.M)();const r=(0,a.useContext)(W.Z);const[o,s]=(0,a.useState)(null);(0,a.useEffect)(()=>{(async()=>{const e=await n.get(r,"to-budget");s((0,eP.zA)(Math.max(e.value,0)))})()},[]);function l(){const n=eK(o,null);if(n){e((0,eP.l9)(n))}t()}if(o===null){return null}return(0,i.jsxs)(E.u,{position:"bottom-right",width:200,style:{padding:10},onClose:t,children:[(0,i.jsx)(m.Z,{style:{marginBottom:5},children:"Hold this amount:"}),(0,i.jsx)(m.Z,{children:(0,i.jsx)(tw.Z,{children:(0,i.jsx)(tv.ZP,{value:o,onChange:e=>s(e.target.value),onEnter:l})})}),(0,i.jsx)(m.Z,{style:{alignItems:"flex-end",marginTop:10},children:(0,i.jsx)(G.Z,{type:"primary",style:{fontSize:12,paddingTop:3,paddingBottom:3},onClick:l,children:"Hold"})})]})};let tZ=(0,a.createContext)(null);function tk({categoryGroups:e,summaryCollapsed:t,onBudgetAction:n,onToggleSummaryCollapse:r,children:o}){let a=h.dK();return(0,i.jsx)(tZ.Provider,{value:{currentMonth:a,categoryGroups:e,summaryCollapsed:t,onBudgetAction:n,onToggleSummaryCollapse:r},children:o})}function tT(){return(0,a.useContext)(tZ)};function tA({prevMonthName:e,collapsed:t}){const n=(0,eQ.Z)();return(0,i.jsxs)(m.Z,{style:{flexDirection:"row",lineHeight:1.5,justifyContent:"center",...!t&&{padding:"5px 0",marginTop:17,backgroundColor:x.rS.tableRowHeaderBackground,borderTopWidth:1,borderBottomWidth:1,borderColor:x.rS.tableBorder},...t&&{padding:7},...x.W2.smallText},children:[(0,i.jsxs)(m.Z,{style:{textAlign:"right",marginRight:10,minWidth:50},children:[(0,i.jsx)(e5,{style:{flexShrink:0},renderContent:()=>(0,i.jsxs)(E.u,{width:200,style:{lineHeight:1.5,padding:"6px 10px"},children:[(0,i.jsx)(e2.Z,{left:"Income:",right:(0,i.jsx)(e$.Z,{binding:eD.aK.totalIncome,type:"financial",privacyFilter:false})}),(0,i.jsx)(e2.Z,{left:"From Last Month:",right:(0,i.jsx)(e$.Z,{binding:eD.aK.fromLastMonth,type:"financial",privacyFilter:false})})]}),children:(0,i.jsx)(e$.Z,{binding:eD.aK.incomeAvailable,type:"financial",style:{fontWeight:600}})}),(0,i.jsx)(e$.Z,{binding:eD.aK.lastMonthOverspent,type:"financial",formatter:e=>{let t=n(e,"financial");return e>0?"+"+t:e===0?"-"+t:t},style:{fontWeight:600,...x.W2.tnum}}),(0,i.jsx)(e$.Z,{binding:eD.aK.totalBudgeted,type:"financial",formatter:e=>{let t=n(e,"financial");return e>0?"+"+t:e===0?"-"+t:t},style:{fontWeight:600,...x.W2.tnum}}),(0,i.jsx)(e$.Z,{binding:eD.aK.forNextMonth,type:"financial",formatter:e=>{let t=parseInt(e)||0;let r=n(Math.abs(t),"financial");return t>=0?"-"+r:"+"+r},style:{fontWeight:600,...x.W2.tnum}})]}),(0,i.jsxs)(m.Z,{children:[(0,i.jsx)(tS.Z,{children:"Available Funds"}),(0,i.jsxs)(tS.Z,{children:["Overspent in ",e]}),(0,i.jsx)(tS.Z,{children:"Budgeted"}),(0,i.jsx)(tS.Z,{children:"For Next Month"})]})]})}function tB({month:e,prevMonthName:t,collapsed:n,onBudgetAction:r}){let[o,s]=(0,a.useState)(null);let l=(0,tj.Z)(eD.aK.toBudget);let c=(0,eV.Z)({name:eD.aK.toBudget,value:0});let d=(0,eQ.Z)();let u=parseInt(c);let h=isNaN(u)?0:u;let p=h<0;return(0,i.jsxs)(m.Z,{style:{alignItems:"center"},children:[(0,i.jsx)(tS.Z,{children:p?"Overbudgeted:":"To Budget:"}),(0,i.jsxs)(m.Z,{children:[(0,i.jsx)(e5,{disabled:!n||o,renderContent:()=>(0,i.jsx)(E.u,{position:"bottom-center",children:(0,i.jsx)(tA,{collapsed:true,prevMonthName:t})}),children:(0,i.jsx)(e4.ZP,{blurIntensity:7,children:(0,i.jsx)(tS.Z,{onClick:()=>s("actions"),"data-cellname":l,className:`${(0,K.iv)([x.W2.veryLargeText,{fontWeight:400,userSelect:"none",cursor:"pointer",color:p?x.rS.errorText:x.rS.pageTextPositive,marginBottom:-1,borderBottom:"1px solid transparent",":hover":{borderColor:p?x.rS.errorText:x.rS.pageTextPositive}}])}`,children:d(h,"financial")})})}),o==="actions"&&(0,i.jsx)(E.u,{position:"bottom-center",width:200,style:{padding:0},onClose:()=>s(null),children:(0,i.jsx)(z.Z,{onMenuSelect:t=>{if(t==="reset-buffer"){r(e,"reset-hold");s(null)}else{s(t)}},items:[{name:"transfer",text:"Move to a category"},{name:"buffer",text:"Hold for next month"},{name:"reset-buffer",text:"Reset next month’s buffer"}]})}),o==="buffer"&&(0,i.jsx)(tC,{onClose:()=>s(null),onSubmit:t=>{r(e,"hold",{amount:t})}}),o==="transfer"&&(0,i.jsx)(tb,{initialAmount:u,onClose:()=>s(null),onSubmit:(t,n)=>{r(e,"transfer-available",{amount:t,category:n})}})]})]})}function tM({month:e,isGoalTemplatesEnabled:t}){let{currentMonth:n,summaryCollapsed:r,onBudgetAction:o,onToggleSummaryCollapse:s}=tT();let[l,c]=(0,a.useState)(false);function d(e){c(true)}function u(){c(false)}let p=h.WU(h.dy(e),"MMM");let g=r?eY:e1;return(0,i.jsx)(m.Z,{"data-testid":"budget-summary",style:{backgroundColor:x.rS.tableBackground,boxShadow:x.W2.cardShadow,borderRadius:6,marginLeft:0,marginRight:0,marginTop:5,flex:1,cursor:"default",marginBottom:5,overflow:"hidden","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:(0,i.jsxs)(W.Z.Provider,{value:h.cv(e),children:[(0,i.jsxs)(m.Z,{style:{padding:"0 13px",...r?{margin:"10px 0"}:{marginTop:16}},children:[(0,i.jsx)(m.Z,{style:{position:"absolute",left:10,top:0},children:(0,i.jsx)(G.Z,{type:"bare",className:"hover-visible",onClick:s,children:(0,i.jsx)(g,{width:13,height:13,style:{color:x.rS.altTableText,margin:1}})})}),(0,i.jsx)("div",{className:`${(0,K.iv)([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"},n===e&&{fontWeight:"bold"}])}`,children:h.WU(e,"MMMM")}),(0,i.jsxs)(m.Z,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[(0,i.jsx)(m.Z,{children:(0,i.jsx)(ei,{id:`budget-${e}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:x.rS.altTableText})}),(0,i.jsxs)(m.Z,{style:{userSelect:"none",marginLeft:2},children:[(0,i.jsx)(G.Z,{type:"bare",onClick:d,children:(0,i.jsx)(eZ.Z,{width:15,height:15,style:{color:x.rS.alt2PillText}})}),l&&(0,i.jsx)(E.u,{position:"bottom-right",width:200,style:{padding:0},onClose:u,children:(0,i.jsx)(z.Z,{onMenuSelect:t=>{u();o(e,t)},items:[{name:"copy-last",text:"Copy last month’s budget"},{name:"set-zero",text:"Set budgets to zero"},{name:"set-3-avg",text:"Set budgets to 3 month average"},t&&{name:"check-templates",text:"Check templates"},t&&{name:"apply-goal-template",text:"Apply budget template"},t&&{name:"overwrite-goal-template",text:"Overwrite with budget template"},t&&{name:"cleanup-goal-template",text:"End of month cleanup"}]})})]})]})]}),r?(0,i.jsx)(m.Z,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:x.rS.tableHeaderBackground,borderTop:"1px solid "+x.rS.tableBorder},children:(0,i.jsx)(tB,{collapsed:r,prevMonthName:p,month:e,onBudgetAction:o})}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(tA,{prevMonthName:p}),(0,i.jsx)(m.Z,{style:{margin:"23px 0"},children:(0,i.jsx)(tB,{month:e,onBudgetAction:o})})]})]})})};function tI({tooltipProps:e,onSubmit:t,onClose:n}){let r=(0,a.useContext)(eM);r=j(r.filter(e=>!e.is_income));let[o,s]=(0,a.useState)(null);function l(){if(o){t(o);n()}}return(0,i.jsxs)(E.u,{position:"bottom-right",width:200,style:{padding:10},...e,onClose:n,children:[(0,i.jsx)(m.Z,{style:{marginBottom:5},children:"Cover from category:"}),(0,i.jsx)(tw.Z,{children:e=>(0,i.jsx)(ty.Z,{categoryGroups:r,value:null,openOnFocus:true,onUpdate:e=>{},onSelect:e=>s(e),inputProps:{inputRef:e,onKeyDown:e=>{if(e.key==="Enter"){l()}}}})}),(0,i.jsx)(m.Z,{style:{alignItems:"flex-end",marginTop:10},children:(0,i.jsx)(G.Z,{type:"primary",style:{fontSize:12,paddingTop:3},onClick:l,children:"Transfer"})})]})}function tR({categoryId:e,tooltip:t,monthIndex:n,onBudgetAction:r}){let o=(0,eV.Z)(eD.aK.catCarryover(e));let s=(0,eV.Z)(eD.aK.catBalance(e));let[l,c]=(0,a.useState)("menu");return(0,i.jsxs)(i.Fragment,{children:[l==="menu"&&(0,i.jsx)(E.u,{position:"bottom-right",width:200,style:{padding:0},onClose:t.close,children:(0,i.jsx)(z.Z,{onMenuSelect:i=>{if(i==="carryover"){r(n,"carryover",{category:e,flag:!o});t.close()}else{c(i)}},items:[{name:"transfer",text:"Transfer to another category"},{name:"carryover",text:o?"Remove overspending rollover":"Rollover overspending"},s<0&&{name:"cover",text:"Cover overspending"}].filter(e=>e)})}),l==="transfer"&&(0,i.jsx)(tb,{initialAmountName:eD.aK.catBalance(e),showToBeBudgeted:true,onClose:t.close,onSubmit:(t,o)=>{r(n,"transfer-category",{amount:t,from:e,to:o})}}),l==="cover"&&(0,i.jsx)(tI,{onClose:t.close,onSubmit:t=>{r(n,"cover",{to:e,from:t})}})]})}let tE={flex:1,padding:"0 5px",textAlign:"right"};const tD=(0,a.memo)(function e(){const e=(0,eQ.Z)();return(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row",marginRight:x.W2.monthRightPadding,paddingTop:10,paddingBottom:10},children:[(0,i.jsxs)(m.Z,{style:tE,children:[(0,i.jsx)(et.Z,{style:{color:x.rS.alt2TableText},children:"Budgeted"}),(0,i.jsx)(e$.Z,{binding:eD.aK.totalBudgeted,type:"financial",style:{color:x.rS.alt2TableText,fontWeight:600},formatter:t=>{return e(-parseFloat(t||"0"),"financial")}})]}),(0,i.jsxs)(m.Z,{style:tE,children:[(0,i.jsx)(et.Z,{style:{color:x.rS.alt2TableText},children:"Spent"}),(0,i.jsx)(e$.Z,{binding:eD.aK.totalSpent,type:"financial",style:{color:x.rS.alt2TableText,fontWeight:600}})]}),(0,i.jsxs)(m.Z,{style:tE,children:[(0,i.jsx)(et.Z,{style:{color:x.rS.alt2TableText},children:"Balance"}),(0,i.jsx)(e$.Z,{binding:eD.aK.totalBalance,type:"financial",style:{color:x.rS.alt2TableText,fontWeight:600}})]})]})});function tP(){return(0,i.jsx)(P.X2,{style:{color:x.rS.alt2TableText,alignItems:"center",paddingRight:10},children:(0,i.jsx)(m.Z,{style:{flex:1,textAlign:"right"},children:"Received"})})}const tW=(0,a.memo)(function e({group:e}){let{id:t}=e;return(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row"},children:[(0,i.jsx)(P.OX,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...x.W2.tnum},valueProps:{binding:eD.aK.groupBudgeted(t),type:"financial"}}),(0,i.jsx)(P.OX,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...x.W2.tnum},valueProps:{binding:eD.aK.groupSumAmount(t),type:"financial"}}),(0,i.jsx)(P.OX,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:x.W2.monthRightPadding,...x.W2.tnum},valueProps:{binding:eD.aK.groupBalance(t),type:"financial",privacyFilter:{style:{paddingRight:x.W2.monthRightPadding}}}})]})});const tL=(0,a.memo)(function e({monthIndex:e,category:t,editing:n,onEdit:r,onBudgetAction:o,onShowActivity:s}){let l=(0,E.lL)();const[c,d]=(0,a.useState)(false);const[u,h]=(0,a.useState)(false);const p=(0,f.Z)("goalTemplatesEnabled");return(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,i.jsxs)(m.Z,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>h(true),onMouseLeave:()=>{h(false)},children:[!n&&(u||c)?(0,i.jsxs)(m.Z,{style:{flexShrink:1,marginRight:0,marginLeft:3,justifyContent:"center"},children:[(0,i.jsx)(G.Z,{type:"bare",onClick:e=>{e.stopPropagation();d(true)},style:{padding:3},children:(0,i.jsx)(O.Z,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&(0,i.jsx)(E.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(false),children:(0,i.jsx)(z.Z,{onMenuSelect:n=>{o(e,n,{category:t.id});d(false)},items:[{name:"copy-single-last",text:"Copy last month’s budget"},{name:"set-single-3-avg",text:"Set to 3 month average"},{name:"set-single-6-avg",text:"Set to 6 month average"},{name:"set-single-12-avg",text:"Set to yearly average"},p&&{name:"apply-single-category-template",text:"Apply budget template"}]})})]}):null,(0,i.jsx)(P.OX,{name:"budget",exposed:n,focused:n,width:"flex",onExpose:()=>r(t.id,e),style:{...n&&{zIndex:100},...x.W2.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+x.rS.mobileAccountShadow,backgroundColor:"white"}},valueProps:{binding:eD.aK.catBudgeted(t.id),type:"financial",getValueStyle:Z,formatExpr:e=>{return(0,eP.zA)(e)},unformatExpr:e=>{return(0,eP.l9)(eK(e,0))}},inputProps:{onBlur:()=>{r(null)},style:{backgroundColor:"white"}},onSave:n=>{o(e,"budget-amount",{category:t.id,amount:n})}})]}),(0,i.jsx)(P.gN,{name:"spent",width:"flex",style:{textAlign:"right"},children:(0,i.jsx)("span",{"data-testid":"category-month-spent",onClick:()=>s(t.name,t.id,e),children:(0,i.jsx)(e$.Z,{binding:eD.aK.catSumAmount(t.id),type:"financial",getStyle:Z,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),(0,i.jsxs)(P.gN,{name:"balance",width:"flex",style:{paddingRight:x.W2.monthRightPadding,textAlign:"right"},children:[(0,i.jsx)("span",{...l.getOpenEvents(),children:(0,i.jsx)(eX,{carryover:eD.aK.catCarryover(t.id),balance:eD.aK.catBalance(t.id)})}),l.isOpen&&(0,i.jsx)(tR,{categoryId:t.id,tooltip:l,monthIndex:e,onBudgetAction:o})]})]})});function tN(){return(0,i.jsx)(m.Z,{style:{flex:1},children:(0,i.jsx)(P.OX,{name:"received",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:x.W2.monthRightPadding,...x.W2.tnum},valueProps:{binding:eD.aK.groupIncomeReceived,type:"financial",privacyFilter:{style:{paddingRight:x.W2.monthRightPadding}}}})})}function tF({category:e,isLast:t,monthIndex:n,onShowActivity:r}){return(0,i.jsx)(m.Z,{style:{flex:1},children:(0,i.jsx)(P.gN,{name:"received",width:"flex",style:{paddingRight:x.W2.monthRightPadding,textAlign:"right",...t&&{borderBottomWidth:0}},children:(0,i.jsx)("span",{onClick:()=>r(e.name,e.id,n),children:(0,i.jsx)(e$.Z,{binding:eD.aK.catSumAmount(e.id),type:"financial",style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})})})};function t_(e){const t=h.dK();const n=(0,a.useRef)(null);const[r,o]=(0,a.useState)(false);const[s,l]=(0,a.useState)(e.startMonth||t);const[c,p]=(0,a.useState)(null);const[g,f]=(0,a.useState)(false);const[x,y]=(0,a.useState)(e.collapsedPrefs||[]);const[w,v]=(0,a.useState)({start:t,end:t});const[b,S]=(0,a.useState)(null);const[j,C]=(0,a.useState)(e.summaryCollapsed);async function Z(){let t=await e.getCategories();S(t.grouped)}(0,a.useEffect)(()=>{let{titlebar:t,budgetType:r}=e;async function o(){Z();let{start:e,end:t}=await (0,d.lW)("get-budget-bounds");v({start:e,end:t});T({start:e,end:t},r)}o();let i=[(0,d.oL)("sync-event",({type:e,tables:t})=>{if(e==="success"&&(t.includes("categories")||t.includes("category_mapping")||t.includes("category_groups"))){Z()}}),(0,d.oL)("undo-event",({tables:e})=>{if(n.current){n.current.clearEditing()}if(e.includes("categories")){Z()}}),t.subscribe(G)];return()=>{i.forEach(e=>e())}},[]);(0,a.useEffect)(()=>{e.savePrefs({"budget.collapsed":x})},[x]);(0,a.useEffect)(()=>{(0,d.lW)("get-budget-bounds").then(({start:e,end:t})=>{if(w.start!==e||w.end!==t){v({start:e,end:t})}})},[e.accountId]);const k=async(t,n=null)=>{n=n||e.budgetType;let r=n==="report"?"report-budget-month":"rollover-budget-month";let o=await (0,d.lW)(r,{month:t});for(let t of o){e.spreadsheet.prewarmCache(t.name,t)}};async function T(n,r=null){let i=3;const a=e.startMonth||t;n=L(n,h.W9(a,1),h.zI(a,i+1));let s=h.Do(n.start,n.end);await Promise.all(s.map(e=>k(e,r)));o(true)}const A=async(n,r)=>{l(n);const o=n;const i=e.startMonth||t;if(n<i){await k(h.W9(n,1))}else if(n>i){await k(h.zI(n,r))}if(o===n){e.savePrefs({"budget.startMonth":n})}};const B=e=>{p(e);y(t=>t.filter(t=>t!==e))};const M=()=>{p(null)};const I=()=>{f(true)};const R=()=>{f(false)};const E=async t=>{if(t.id==="new"){let n=await e.createCategory(t.name,t.cat_group,t.is_income);p(null);S(e=>(0,u.i8)(e,{...t,is_income:t.is_income?1:0,id:n}))}else{const n={...t,hidden:t.hidden?1:0};e.updateCategory(n);S(e=>(0,u.yr)(e,n))}};const D=async t=>{const n=await (0,d.lW)("must-category-transfer",{id:t});if(n){e.pushModal("confirm-category-delete",{category:t,onDelete:n=>{if(t!==n){e.deleteCategory(t,n);S(e=>(0,u.uu)(e,t))}}})}else{e.deleteCategory(t);S(e=>(0,u.uu)(e,t))}};const P=async t=>{if(t.id==="new"){let n=await e.createGroup(t.name);f(false);S(e=>(0,u.Rp)(e,{...t,is_income:0,categories:t.categories||[],id:n}))}else{const n={...t,hidden:t.hidden?1:0};e.updateGroup(n);S(e=>(0,u.mD)(e,n))}};const W=async t=>{let n=b.find(e=>e.id===t);let r=false;for(let e of n.categories){if(await (0,d.lW)("must-category-transfer",{id:e.id})){r=true;break}}if(r){e.pushModal("confirm-category-delete",{group:t,onDelete:n=>{e.deleteGroup(t,n);S(e=>(0,u.iE)(e,t))}})}else{e.deleteGroup(t);S(e=>(0,u.iE)(e,t))}};const N=(t,n,r)=>{e.applyBudgetAction(t,n,r)};const F=(t,n,r)=>{e.navigate("/accounts",{state:{goBack:true,filterName:`${t} (${h.WU(r,"MMMM yyyy")})`,filter:{category:n,date:{$transform:"$month",$eq:r}}}})};const _=async t=>{e.moveCategory(t.id,t.groupId,t.targetId);S(e=>(0,u.Wr)(e,t.id,t.groupId,t.targetId))};const H=async t=>{e.moveCategoryGroup(t.id,t.targetId);S(e=>(0,u.eq)(e,t.id,t.targetId))};const O=()=>{let t=!j;C(t);e.savePrefs({"budget.summaryCollapsed":t})};const G=async t=>{switch(t){case"budget/switch-type":{let t=e.budgetType;let n=t==="rollover"?"report":"rollover";e.spreadsheet.disableObservers();await (0,d.lW)("budget-set-type",{type:n});await T(w,n);e.spreadsheet.enableObservers();e.loadPrefs();break}default:}};let{maxMonths:z,budgetType:U,reportComponents:K,rolloverComponents:$}=e;z=z||1;if(!r||!b){return null}const Q=e.startMonth||t;let V;if(U==="report"){V=(0,i.jsx)(e6,{summaryCollapsed:j,onBudgetAction:N,onToggleSummaryCollapse:O,children:(0,i.jsx)(eE,{ref:n,type:U,categoryGroups:b,prewarmStartMonth:s,startMonth:Q,monthBounds:w,maxMonths:z,collapsed:x,setCollapsed:y,newCategoryForGroup:c,isAddingGroup:g,dataComponents:K,onMonthSelect:A,onShowNewCategory:B,onHideNewCategory:M,onShowNewGroup:I,onHideNewGroup:R,onDeleteCategory:D,onDeleteGroup:W,onSaveCategory:E,onSaveGroup:P,onBudgetAction:N,onShowActivity:F,onReorderCategory:_,onReorderGroup:H})})}else{V=(0,i.jsx)(tk,{categoryGroups:b,summaryCollapsed:j,onBudgetAction:N,onToggleSummaryCollapse:O,children:(0,i.jsx)(eE,{ref:n,type:U,categoryGroups:b,prewarmStartMonth:s,startMonth:Q,monthBounds:w,maxMonths:z,collapsed:x,setCollapsed:y,newCategoryForGroup:c,isAddingGroup:g,dataComponents:$,onMonthSelect:A,onShowNewCategory:B,onHideNewCategory:M,onShowNewGroup:I,onHideNewGroup:R,onDeleteCategory:D,onDeleteGroup:W,onSaveCategory:E,onSaveGroup:P,onBudgetAction:N,onShowActivity:F,onReorderCategory:_,onReorderGroup:H})})}return(0,i.jsx)(m.Z,{style:{flex:1},children:V})}const tH=(0,a.memo)(e=>{const t=(0,f.Z)("goalTemplatesEnabled");return(0,i.jsx)(tM,{...e,isGoalTemplatesEnabled:t})});function tO(e){let t=(0,s.v9)(e=>e.prefs.local["budget.startMonth"]);let n=(0,s.v9)(e=>e.prefs.local["budget.collapsed"]);let d=(0,s.v9)(e=>e.prefs.local["budget.summaryCollapsed"]);let u=(0,s.v9)(e=>e.prefs.local.budgetType||"rollover");let h=(0,s.v9)(e=>e.prefs.global.maxMonths);let{grouped:f}=(0,g.Z)();let w=(0,p.o)();let v=(0,c.M)();let b=(0,a.useContext)(y.CR);let S=(0,l.TH)();let j=(0,l.bS)(S.pathname);let C=(0,l.s0)();let Z=(0,a.useMemo)(()=>({SummaryComponent:ts,ExpenseCategoryComponent:tf,ExpenseGroupComponent:tg,IncomeCategoryComponent:tm,IncomeGroupComponent:tx,BudgetTotalsComponent:tc,IncomeHeaderComponent:td}),[r]);let k=(0,a.useMemo)(()=>({SummaryComponent:tH,ExpenseCategoryComponent:tL,ExpenseGroupComponent:tW,IncomeCategoryComponent:tF,IncomeGroupComponent:tN,BudgetTotalsComponent:tD,IncomeHeaderComponent:tP}),[o]);return(0,i.jsx)(m.Z,{style:{...x.W2.page,paddingLeft:8,paddingRight:8,overflow:"hidden"},children:(0,i.jsx)(t_,{startMonth:t,collapsedPrefs:n,summaryCollapsed:d,budgetType:u,maxMonths:h,categoryGroups:f,...w,reportComponents:Z,rolloverComponents:k,spreadsheet:v,titlebar:b,navigate:C,match:j})})}var tG=n(62829);var tz=n(24198);var tU=n(13308);var tK=n(43229);function t$(){const{pushModal:e}=(0,p.o)();const[t,n]=(0,a.useState)("");const r=(0,tG.gZ)();if(r==null){return null}const{schedules:o,statuses:s}=r;function l(t){e("schedule-edit",{id:t})}function c(){e("schedule-edit")}function u(){e("schedules-discover")}async function h(e,t){switch(e){case"post-transaction":await (0,d.lW)("schedule/post-transaction",{id:t});break;case"skip":await (0,d.lW)("schedule/skip-next-date",{id:t});break;case"complete":await (0,d.lW)("schedule/update",{schedule:{id:t,completed:true}});break;case"restart":await (0,d.lW)("schedule/update",{schedule:{id:t,completed:false},resetNextDate:true});break;case"delete":await (0,d.lW)("schedule/delete",{id:t});break;default:}}return(0,i.jsxs)(tU.T,{title:"Schedules",children:[(0,i.jsx)(m.Z,{style:{flexDirection:"row",alignItems:"center",padding:"0 0 15px"},children:(0,i.jsx)(m.Z,{style:{flex:1,flexDirection:"row",justifyContent:"flex-end"},children:(0,i.jsx)(tz.Z,{placeholder:"Filter schedules…",value:t,onChange:n})})}),(0,i.jsx)(tK.Pz,{schedules:o,filter:t,statuses:s,allowCompleted:true,onSelect:l,onAction:h,style:{backgroundColor:x.rS.tableBackground}}),(0,i.jsxs)(m.Z,{style:{flexDirection:"row",justifyContent:"space-between",margin:"20px 0",flexShrink:0},children:[(0,i.jsx)(G.Z,{onClick:u,children:"Find schedules"}),(0,i.jsx)(G.Z,{type:"primary",onClick:c,children:"Add new schedule"})]})]})}var tQ=n(8987);var tV=n(42994);function tq(){window.close();return(0,i.jsx)(tQ.C,{isCurrent:true,showClose:false,title:"Account sync",children:()=>(0,i.jsxs)(m.Z,{style:{maxWidth:500},children:[(0,i.jsx)(tV.Z,{children:"Please wait..."}),(0,i.jsx)(tV.Z,{children:"The window should close automatically. If nothing happened you can close this window or tab."})]})})}var tX=n(82478);var tJ=n(65485);var tY=n(43044);var t0=n(17853);var t1=n(11504);var t2=n(76804);var t5=n(18247);var t8=n(11892);var t4=n(25432);var t3=n(41071);var t6=n(79982);var t7=n(18748);var t9=n(15685);function ne(e){const t=(0,a.useRef)();(0,a.useEffect)(()=>{t.current=e},[e]);return t.current};const nt=e=>(0,i.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 91 51",style:{color:"inherit",...e.style},children:(0,i.jsx)("path",{fill:"currentColor",d:"M30.256 48.614a3.14 3.14 0 0 0-.989-2.153L10.803 29.063h76.915a3.2 3.2 0 0 0 .315 0c1.584-.084 2.95-1.64 2.867-3.266-.082-1.625-1.598-3.028-3.182-2.943H10.803L29.267 5.49c1.284-1.099 1.456-3.057.385-4.373a2.972 2.972 0 0 0-4.48-.187L.971 23.695a3.163 3.163 0 0 0 0 4.56l24.2 22.766a2.98 2.98 0 0 0 2.205.84c1.669-.08 2.958-1.534 2.88-3.247Z"})});var nn=nt;var nr=n(86918);const no=e=>(0,i.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",style:{color:"inherit",...e.style},children:(0,i.jsx)("path",{d:"m9 16.172-6.071-6.071-1.414 1.414L10 20l.707-.707 7.778-7.778-1.414-1.414L11 16.172V0H9z",fill:"currentColor"})});var ni=no;const na=e=>(0,i.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",style:{color:"inherit",...e.style},children:(0,i.jsx)("path",{d:"M9 3.828 2.929 9.899 1.515 8.485 10 0l.707.707 7.778 7.778-1.414 1.414L11 3.828V20H9V3.828z",fill:"currentColor"})});var ns=na;var nl=n(15741);var nc=n(30739);const nd=e=>(0,i.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,i.jsx)("path",{d:"M12.406 14.905a1 1 0 0 0-.543 1.307 1 1 0 0 1-.217 1.09l-2.828 2.829a2 2 0 0 1-2.828 0L3.868 18.01a2 2 0 0 1 0-2.829L6.7 12.353a1.013 1.013 0 0 1 1.091-.217 1 1 0 0 0 .763-1.849 3.034 3.034 0 0 0-3.268.652l-2.832 2.828a4.006 4.006 0 0 0 0 5.657l2.122 2.121a4 4 0 0 0 5.656 0l2.829-2.828a3.008 3.008 0 0 0 .651-3.27 1 1 0 0 0-1.306-.542Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M7.757 16.241a1.011 1.011 0 0 0 1.414 0l7.779-7.778a1 1 0 0 0-1.414-1.414l-7.779 7.778a1 1 0 0 0 0 1.414Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"m21.546 4.574-2.121-2.121a4.006 4.006 0 0 0-5.657 0l-2.829 2.828a3.006 3.006 0 0 0-.651 3.269 1 1 0 1 0 1.849-.764 1 1 0 0 1 .217-1.086l2.828-2.828a2 2 0 0 1 2.829 0l2.121 2.121a2 2 0 0 1 0 2.829L17.3 11.645a1.015 1.015 0 0 1-1.091.217 1 1 0 0 0-.765 1.849 3.026 3.026 0 0 0 3.27-.651l2.828-2.828a4.007 4.007 0 0 0 .004-5.658Z",fill:"currentColor"})]});var nu=nd;var nh=n(6790);var np=n(31261);var ng=n(41075);var nf=n(22966);function nx(e,t){return e?e[t]:""}function nm(e,t){let{amount:n,date:r}=e;if(nD(e.id)){n=(e._inverse?-1:1)*(0,t1.lP)(n)}let o=n<0?-n:null;let i=n>0?n:null;if(n===0){if(t){i=0}else{o=0}}if(!(0,t4.Z)((0,t3.Z)(r))){r=null}return{...e,date:r,debit:o!=null?(0,eP.zA)(o):"",credit:i!=null?(0,eP.zA)(i):""}}function ny(e,t){let{debit:n,credit:r,date:o,...i}=e;let a;if(n!==""){let e=eK(n,null);a=e!=null?-e:null}else{a=eK(r,null)}a=a!=null?(0,eP.l9)(a):t.amount;if(o==null){o=t.date||(0,h.PR)()}return{...i,date:o,amount:a}}function nw(e,t){let n=e[t];return n&&n.is_child&&(e[t+1]==null||e[t+1].parent_id!==n.parent_id)}let nv=(0,a.createContext)(null);function nb(){let e=(0,a.useContext)(nv);return(0,a.useMemo)(()=>({...e,expanded:t=>e.state.mode==="collapse"?!e.state.ids.has(t):e.state.ids.has(t)}),[e])}function nS({children:e,initialMode:t="expand"}){let n=(0,s.v9)(e=>e.app.lastSplitState);let r=(0,s.I0)();let[o,l]=(0,a.useReducer)((e,t)=>{switch(t.type){case"toggle-split":{let n=new Set([...e.ids]);let{id:r}=t;if(n.has(r)){n.delete(r)}else{n.add(r)}return{...e,ids:n}}case"open-split":{let n=new Set([...e.ids]);let{id:r}=t;if(e.mode==="collapse"){n.delete(r)}else{n.add(r)}return{...e,ids:n}}case"set-mode":{return{...e,mode:t.mode,ids:new Set,transitionId:null}}case"switch-mode":if(e.transitionId!=null){return e}return{...e,mode:e.mode==="expand"?"collapse":"expand",transitionId:t.id,ids:new Set};case"finish-switch-mode":return{...e,transitionId:null};default:throw new Error("Unknown action type: "+t.type)}},n.current||{ids:new Set,mode:t});(0,a.useEffect)(()=>{if(o.transitionId!=null){setTimeout(()=>{l({type:"finish-switch-mode"})},250)}},[o.transitionId]);(0,a.useEffect)(()=>{if(o.transitionId==null){r({type:"SET_LAST_SPLIT_STATE",splitState:o})}},[o]);let c=(0,a.useMemo)(()=>({state:o,dispatch:l}),[o,l]);return(0,i.jsx)(nv.Provider,{value:c,children:e})}function nj(e,t,n,r="asc"){return e===n?t==="asc"?"desc":"asc":r}const nC=(0,a.memo)(({hasSelected:e,showAccount:t,showCategory:n,showBalance:r,showCleared:o,scrollWidth:a,onSort:s,ascDesc:l,field:c})=>{let d=(0,t8.YP)();return(0,i.jsxs)(P.X2,{style:{fontWeight:300,zIndex:200,color:x.rS.tableHeaderText,backgroundColor:x.rS.tableBackground},children:[(0,i.jsx)(P._7,{exposed:true,focused:false,selected:e,width:20,onSelect:e=>d({type:"select-all",event:e})}),(0,i.jsx)(nT,{value:"Date",width:110,alignItems:"flex",marginLeft:-5,id:"date",icon:c==="date"?l:"clickable",onClick:()=>s("date",nj(c,l,"date","desc"))}),t&&(0,i.jsx)(nT,{value:"Account",width:"flex",alignItems:"flex",marginLeft:-5,id:"account",icon:c==="account"?l:"clickable",onClick:()=>s("account",nj(c,l,"account","asc"))}),(0,i.jsx)(nT,{value:"Payee",width:"flex",alignItems:"flex",marginLeft:-5,id:"payee",icon:c==="payee"?l:"clickable",onClick:()=>s("payee",nj(c,l,"payee","asc"))}),(0,i.jsx)(nT,{value:"Notes",width:"flex",alignItems:"flex",marginLeft:-5,id:"notes",icon:c==="notes"?l:"clickable",onClick:()=>s("notes",nj(c,l,"notes","asc"))}),n&&(0,i.jsx)(nT,{value:"Category",width:"flex",alignItems:"flex",marginLeft:-5,id:"category",icon:c==="category"?l:"clickable",onClick:()=>s("category",nj(c,l,"category","asc"))}),(0,i.jsx)(nT,{value:"Payment",width:90,alignItems:"flex-end",marginRight:-5,id:"payment",icon:c==="payment"?l:"clickable",onClick:()=>s("payment",nj(c,l,"payment","asc"))}),(0,i.jsx)(nT,{value:"Deposit",width:85,alignItems:"flex-end",marginRight:-5,id:"deposit",icon:c==="deposit"?l:"clickable",onClick:()=>s("deposit",nj(c,l,"deposit","desc"))}),r&&(0,i.jsx)(P.bL,{value:"Balance",width:88,textAlign:"right"}),o&&(0,i.jsx)(P.gN,{width:23,truncate:false}),(0,i.jsx)(P.bL,{value:"",width:(5+a)??0})]})});function nZ(e,t,n){let{payee:r}=e;if(n){return(0,i.jsx)(m.Z,{style:{flexDirection:"row",alignItems:"center"},children:(0,i.jsx)("div",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:n.name})})}else if(t){return t.name}else if(r&&r.startsWith("new:")){return r.slice("new:".length)}return""}function nk({id:e,focused:t,selected:n,status:r,isChild:o,onEdit:s,onUpdate:l}){let c=r==="cleared"||r==null;let d=(0,ng.V)(r);let u=r==="cleared"?x.rS.noticeText:r==="missed"?x.rS.alt5ErrorText:r==="due"?x.rS.alt3WarningText:n?x.rS.altPageTextLink:x.rS.pageTextSubdued;function h(){if(c){l("cleared",!(r==="cleared"))}}return(0,i.jsx)(P.bL,{name:"cleared",width:23,focused:t,style:{padding:1},plain:true,children:(0,i.jsx)(P.Sx,{style:{padding:3,backgroundColor:"transparent",border:"1px solid transparent",borderRadius:50,":focus":{border:"1px solid "+x.rS.formInputBorderSelected,boxShadow:"0 1px 2px "+x.rS.formInputBorderSelected},cursor:c?"pointer":"default",...o&&{visibility:"hidden"}},onEdit:()=>s(e,"cleared"),onSelect:h,children:(0,a.createElement)(d.Icon,{style:{width:13,height:13,color:u,marginTop:r==="due"?-1:0}})})})}function nT({value:e,id:t,width:n,alignItems:r,marginLeft:o,marginRight:a,icon:s,onClick:l}){return(0,i.jsx)(P.wh,{width:n,name:t,alignItems:r,unexposedContent:(0,i.jsxs)(G.Z,{type:"bare",onClick:l,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:x.rS.tableHeaderText,fontWeight:300,marginLeft:o,marginRight:a},children:[(0,i.jsx)(P.rt,{value:e}),s==="asc"&&(0,i.jsx)(ni,{width:10,height:10,style:{marginLeft:5}}),s==="desc"&&(0,i.jsx)(ns,{width:10,height:10,style:{marginLeft:5}})]})})}function nA({id:e,payeeId:t,accountId:n,focused:r,inherited:o,payees:s,accounts:l,valueStyle:c,transaction:d,payee:u,transferAcct:h,isPreview:p,onEdit:g,onUpdate:f,onCreatePayee:m,onManagePayees:y,onNavigateToTransferAccount:w,onNavigateToSchedule:v}){let b=(0,a.useRef)(false);l=l.filter(e=>e.id!==n);s=s.filter(e=>e.transfer_acct!==n);return(0,i.jsx)(P.wh,{width:"flex",name:"payee",textAlign:"flex",value:t,valueStyle:{...c,...o&&{color:x.rS.tableTextInactive}},exposed:r,onExpose:t=>!p&&g(e,t),onUpdate:async e=>{f("payee",e);if(e&&e.startsWith("new:")&&!b.current){b.current=true;let t=await m(e.slice("new:".length));f("payee",t);b.current=false}},unexposedContent:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nB,{transaction:d,transferAccount:h,onNavigateToTransferAccount:w,onNavigateToSchedule:v}),(0,i.jsx)(P.rt,{value:t,formatter:()=>nZ(d,u,h)})]}),children:({onBlur:e,onKeyDown:n,onUpdate:r,onSave:o,shouldSaveFromKey:a,inputStyle:c})=>{return(0,i.jsx)(np.Z,{payees:s,accounts:l,value:t,shouldSaveFromKey:a,inputProps:{onBlur:e,onKeyDown:n,style:c},showManagePayees:true,tableBehavior:true,focused:true,onUpdate:r,onSelect:o,onManagePayees:()=>y(t),isCreatable:true,menuPortalTarget:undefined})}})}function nB({transaction:e,transferAccount:t,onNavigateToTransferAccount:n,onNavigateToSchedule:r,children:o}){let a=e.schedule;let s=(0,tG.oF)();let l=s?s.schedules.find(e=>e.id===a):null;if(l==null&&t==null){return o}let c={marginLeft:-5,marginRight:2,width:23,height:23,color:"inherit"};let d={width:13,height:13};let u={width:10,height:10};let h=l&&l._date&&!!l._date.frequency;return(0,i.jsxs)(i.Fragment,{children:[l&&(0,i.jsx)(G.Z,{type:"bare",style:c,onClick:e=>{e.stopPropagation();r(a)},children:h?(0,i.jsx)(nl.Z,{style:d}):(0,i.jsx)(nc.Z,{style:d})}),t&&(0,i.jsx)(G.Z,{type:"bare",style:c,onClick:r=>{r.stopPropagation();if(!nE(e.id)){n(t.id)}},children:(e._inverse?-1:1)*e.amount>0?(0,i.jsx)(nn,{style:u}):(0,i.jsx)(nr.Z,{style:u})})]})}const nM=(0,a.memo)(function e(e){let{transaction:t,editing:n,showAccount:r,showBalance:o,showCleared:s,showZeroInDeposit:l,style:c,selected:d,highlighted:u,added:h,matched:p,expanded:g,inheritedFields:f,focusedField:y,categoryGroups:w,payees:v,accounts:b,balance:S,dateFormat:j="MM/dd/yyyy",hideFraction:C,onSave:Z,onEdit:k,onDelete:T,onSplit:A,onManagePayees:B,onCreatePayee:M,onToggleSplit:I,onNavigateToTransferAccount:R,onNavigateToSchedule:E}=e;let D=(0,t8.YP)();let[W,L]=(0,a.useState)(l);let[N,F]=(0,a.useState)(t);let[_,H]=(0,a.useState)(()=>nm(t,l));let G=nD(_.id);if(t!==N||l!==W){H(nm(t,l));F(t);L(l)}function z(e,n){if(_[e]!==n){let r={..._,[e]:n};if(e==="note"&&n===""&&_.note==null){return}if(e==="account"&&n&&(0,t7.gI)(b)[n].offbudget){r.category=null}if(e==="credit"){r["debit"]=""}else if(e==="debit"){r["credit"]=""}if(e==="payee"&&n&&n.startsWith("new:")){H(r)}else{let e=ny(r,t);H(nm(e,l));Z(e)}}}let{id:U,amount:K,debit:$,credit:Q,payee:V,imported_payee:q,notes:X,date:J,account:Y,category:ee,cleared:en,is_parent:er,_unmatched:eo=false,_inverse:ei=false}=_;let ea=v&&V&&(0,t7.yG)(v)[V];let es=b&&Y&&(0,t7.gI)(b)[Y];let el;if(ei){el=b&&Y&&(0,t7.gI)(b)[Y]}else{el=ea&&ea.transfer_acct&&(0,t7.gI)(b)[ea.transfer_acct]}let ec=_.is_child;let ed=el&&el.offbudget===0;let eu=es&&es.offbudget===1;let eh=h?{fontWeight:600}:null;let ep=y==="select";let eg=C?{letterSpacing:-.5}:null;let ef=!nE(U)?S:S+(ei?-1:1)*K;return(0,i.jsxs)(P.X2,{style:{backgroundColor:d?x.rS.tableRowBackgroundHighlight:ep?x.rS.tableRowBackgroundHover:x.rS.tableBackground,":hover":!(ep||d)&&{backgroundColor:x.rS.tableRowBackgroundHover},"& .hover-visible":{opacity:0},":hover .hover-visible":{opacity:1},...u||d?{color:x.rS.tableRowBackgroundHighlightText}:{color:x.rS.tableText},...c,...G&&{color:x.rS.tableTextInactive,backgroundColor:!d?"#fcfcfc":undefined,fontStyle:"italic"},...eo&&{opacity:.5}},children:[ec&&(0,i.jsx)(P.gN,{width:110,style:{width:110,backgroundColor:x.rS.tableRowBackgroundHover,border:0}}),ec&&r&&(0,i.jsx)(P.gN,{style:{flex:1,backgroundColor:x.rS.tableRowBackgroundHover,border:0}}),nE(_.id)?ec?(0,i.jsx)(P.nu,{onDelete:()=>T&&T(_.id),exposed:n,style:{...ec&&{borderLeftWidth:1},lineHeight:0}}):(0,i.jsx)(P.bL,{width:20}):(0,i.jsx)(P._7,{exposed:true,buttonProps:{className:d||n?null:"hover-visible"},focused:y==="select",onSelect:e=>{D({type:"select",id:_.id,event:e})},onEdit:()=>k(U,"select"),selected:d,style:{...ec&&{borderLeftWidth:1}},value:p&&(0,i.jsx)(nu,{style:{width:13,height:13,color:"inherit"}})}),!ec&&(0,i.jsx)(P.wh,{name:"date",width:110,textAlign:"flex",exposed:y==="date",value:J,valueStyle:eh,formatter:e=>e?(0,t6.Z)((0,t3.Z)(e),j):"",onExpose:e=>!G&&k(U,e),onUpdate:e=>{z("date",e)},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:r,shouldSaveFromKey:o,inputStyle:a})=>(0,i.jsx)(nf.Z,{value:J||"",dateFormat:j,inputProps:{onBlur:e,onKeyDown:t,style:a},shouldSaveFromKey:o,tableBehavior:true,onUpdate:n,onSelect:r})}),!ec&&r&&(0,i.jsx)(P.wh,{name:"account",width:"flex",textAlign:"flex",value:Y,formatter:e=>{let t=e&&(0,t7.gI)(b)[e];if(t){return t.name}return""},valueStyle:eh,exposed:y==="account",onExpose:e=>!G&&k(U,e),onUpdate:async e=>{if(e){z("account",e)}},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:r,shouldSaveFromKey:o,inputStyle:a})=>(0,i.jsx)(nh.Z,{includeClosedAccounts:false,value:Y,accounts:b,shouldSaveFromKey:o,tableBehavior:true,focused:true,inputProps:{onBlur:e,onKeyDown:t,style:a},onUpdate:n,onSelect:r,menuPortalTarget:undefined})}),(()=>(0,i.jsx)(nA,{id:U,payeeId:V,accountId:Y,focused:y==="payee",inherited:f&&f.has("payee"),payees:v,accounts:b,valueStyle:eh,transaction:_,payee:ea,transferAcct:el,importedPayee:q,isPreview:G,onEdit:k,onUpdate:z,onCreatePayee:M,onManagePayees:B,onNavigateToTransferAccount:R,onNavigateToSchedule:E}))(),G?(0,i.jsx)(P.bL,{name:"notes",width:"flex"}):(0,i.jsx)(P.F3,{width:"flex",name:"notes",textAlign:"flex",exposed:y==="notes",focused:y==="notes",value:X||"",valueStyle:eh,onExpose:e=>!G&&k(U,e),inputProps:{value:X||"",onUpdate:z.bind(null,"notes")}}),G?(0,i.jsx)(P.bL,{width:"flex",style:{alignItems:"flex-start"},exposed:true,children:()=>(0,i.jsx)(m.Z,{style:{color:X==="missed"?x.rS.alt5ErrorText:X==="due"?x.rS.alt5WarningText:d?x.rS.formLabelText:x.rS.altTableText,backgroundColor:X==="missed"?x.rS.altErrorBackground:X==="due"?x.rS.altWarningBackground:d?x.rS.formLabelBackground:x.rS.alt2TableBackground,margin:"0 5px",padding:"3px 7px",borderRadius:4},children:(0,eP.VL)(X)})}):er?(0,i.jsx)(P.bL,{name:"category",width:"flex",focused:y==="category",style:{padding:0},plain:true,children:(0,i.jsx)(P.Sx,{bare:true,style:{alignSelf:"flex-start",borderRadius:4,border:"1px solid transparent",":hover":{border:"1px solid "+x.rS.buttonNormalBorder}},disabled:nE(_.id),onEdit:()=>k(U,"category"),onSelect:()=>I(U),children:(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center",alignSelf:"stretch",borderRadius:4,flex:1,padding:4},children:[er&&(0,i.jsx)(O.Z,{style:{color:"inherit",width:14,height:14,transition:"transform .08s",transform:g?"rotateZ(0)":"rotateZ(-90deg)"}}),(0,i.jsx)(et.Z,{style:{fontStyle:"italic",userSelect:"none"},children:"Split"})]})})}):ed||eu||G?(0,i.jsx)(P.F3,{name:"category",width:"flex",exposed:y==="category",focused:y==="category",onExpose:e=>!G&&k(U,e),value:er?"Split":eu?"Off Budget":ed?"Transfer":"",valueStyle:eh,style:{fontStyle:"italic",color:"#c0c0c0",fontWeight:300},inputProps:{readOnly:true,style:{fontStyle:"italic"}}}):(0,i.jsx)(P.wh,{name:"category",width:"flex",textAlign:"flex",value:ee,formatter:e=>e?nx((0,t7.ch)(w)[e],"name"):_.id?"Categorize":"",exposed:y==="category",onExpose:e=>k(U,e),valueStyle:!ee?{fontStyle:"italic",fontWeight:300,color:x.rS.formInputTextHighlight}:eh,onUpdate:async e=>{if(e==="split"){A(_.id)}else{z("category",e)}},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:r,shouldSaveFromKey:o,inputStyle:a})=>(0,i.jsx)(ty.Z,{categoryGroups:w,value:ee,focused:true,tableBehavior:true,showSplitOption:!ec&&!er,shouldSaveFromKey:o,inputProps:{onBlur:e,onKeyDown:t,style:a},onUpdate:n,onSelect:r,menuPortalTarget:undefined})}),(0,i.jsx)(P.F3,{type:"input",width:90,name:"debit",exposed:y==="debit",focused:y==="debit",value:$===""&&Q===""?"0.00":$,valueStyle:eh,textAlign:"right",title:$,onExpose:e=>!G&&k(U,e),style:{...er&&{fontStyle:"italic"},...x.W2.tnum,...eg},inputProps:{value:$===""&&Q===""?"0.00":$,onUpdate:z.bind(null,"debit")},privacyFilter:{activationFilters:[!nE(_.id)]}}),(0,i.jsx)(P.F3,{type:"input",width:85,name:"credit",exposed:y==="credit",focused:y==="credit",value:Q,valueStyle:eh,textAlign:"right",title:Q,onExpose:e=>!G&&k(U,e),style:{...er&&{fontStyle:"italic"},...x.W2.tnum,...eg},inputProps:{value:Q,onUpdate:z.bind(null,"credit")},privacyFilter:{activationFilters:[!nE(_.id)]}}),o&&(0,i.jsx)(P.bL,{name:"balance",value:ef==null||ec?"":(0,eP.zA)(ef),valueStyle:{color:ef<0?x.rS.errorText:x.rS.noticeText},style:{...x.W2.tnum,...eg},width:88,textAlign:"right",privacyFilter:true}),s&&(0,i.jsx)(nk,{id:U,focused:y==="cleared",selected:d,isPreview:G,status:G?X:en?"cleared":null,isChild:ec,onEdit:k,onUpdate:z}),(0,i.jsx)(P.bL,{width:5})]})});function nI({error:e,isDeposit:t,onAddSplit:n,style:r}){switch(e.type){case"SplitTransactionError":if(e.version===1){return(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center",padding:"0 5px",...r},"data-testid":"transaction-error",children:[(0,i.jsxs)(et.Z,{children:["Amount left:"," ",(0,i.jsx)(et.Z,{style:{fontWeight:500},children:(0,eP.zA)(t?e.difference:-e.difference)})]}),(0,i.jsx)(m.Z,{style:{flex:1}}),(0,i.jsx)(G.Z,{type:"primary",style:{marginLeft:15,padding:"4px 10px"},onClick:n,children:"Add Split"})]})}break;default:return null}}function nR(e,t,n){return[{id:"temp",date:n||(0,h.PR)(),account:e||null,category:t||null,cleared:false,amount:null}]}function nE(e){return e.indexOf("temp")!==-1}function nD(e){return e.indexOf("preview/")!==-1}function nP({transactions:e,accounts:t,categoryGroups:n,payees:r,editingTransaction:o,focusedField:a,showAccount:s,showCategory:l,showBalance:c,showCleared:d,dateFormat:u,hideFraction:h,onClose:p,onSplit:g,onEdit:f,onDelete:y,onSave:w,onAdd:v,onAddSplit:b,onManagePayees:S,onCreatePayee:j,onNavigateToTransferAccount:C,onNavigateToSchedule:Z,balance:k}){const T=e[0].error;const A=e[0].amount>0;return(0,i.jsxs)(m.Z,{style:{borderBottom:"1px solid "+x.rS.tableBorderHover,paddingBottom:6,backgroundColor:x.rS.tableBackground},"data-testid":"new-transaction",onKeyDown:e=>{if(e.key==="Escape"){p()}},children:[e.map(e=>(0,i.jsx)(nM,{isNew:true,editing:o===e.id,transaction:e,showAccount:s,showCategory:l,showBalance:c,showCleared:d,focusedField:o===e.id&&a,showZeroInDeposit:A,accounts:t,categoryGroups:n,payees:r,dateFormat:u,hideFraction:h,expanded:true,onEdit:f,onSave:w,onSplit:g,onDelete:y,onAdd:v,onManagePayees:S,onCreatePayee:j,style:{marginTop:-1},onNavigateToTransferAccount:C,onNavigateToSchedule:Z,balance:k},e.id)),(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center",justifyContent:"flex-end",marginTop:6,marginRight:20},children:[(0,i.jsx)(G.Z,{style:{marginRight:10,padding:"4px 10px"},onClick:()=>p(),"data-testid":"cancel-button",children:"Cancel"}),T?(0,i.jsx)(nI,{error:T,isDeposit:A,onAddSplit:()=>b(e[0].id)}):(0,i.jsx)(G.Z,{type:"primary",style:{padding:"4px 10px"},onClick:v,"data-testid":"add-button",children:"Add"})]})]})}function nW({tableNavigator:e,tableRef:t,dateFormat:n="MM/dd/yyyy",newNavigator:r,renderEmpty:o,onScroll:s,...l}){const c=(0,a.createRef)();const d=ne(l.isAdding);let[u,h]=(0,a.useState)(0);function p(e,t){let n=e>0&&t>0&&e-t;h(!n?0:n)}let g=(0,a.useCallback)(e=>{l.onCloseAddTransaction();l.onNavigateToTransferAccount(e)},[l.onCloseAddTransaction,l.onNavigateToTransferAccount]);let f=(0,a.useCallback)(e=>{l.onCloseAddTransaction();l.onNavigateToSchedule(e)},[l.onCloseAddTransaction,l.onNavigateToSchedule]);(0,a.useEffect)(()=>{if(!d&&l.isAdding){r.onEdit("temp","date")}},[d,l.isAdding,r]);const y=({item:t,index:r,position:o,editing:a})=>{const{transactions:s,selectedItems:c,accounts:d,categoryGroups:u,payees:h,showCleared:p,showAccount:x,showCategory:m,showBalances:y,balances:w,hideFraction:v,isNew:b,isMatched:S,isExpanded:j}=l;let C=t;let Z=c.has(C.id);let k=l.transactionMap.get(C.parent_id);let T=k&&k.amount>0;let A=j&&j((k||C).id);let B=A?k&&k.error||C.error:C.error;return(0,i.jsxs)(i.Fragment,{children:[(!A||nw(s,r))&&B&&B.type==="SplitTransactionError"&&(0,i.jsx)(E.u,{position:"bottom-right",width:250,forceTop:o,forceLayout:true,style:{transform:"translate(-5px, 2px)"},children:(0,i.jsx)(nI,{error:B,isDeposit:T,onAddSplit:()=>l.onAddSplit(C.id)})}),(0,i.jsx)(nM,{editing:a,transaction:C,showAccount:x,showCategory:m,showBalance:y,showCleared:p,selected:Z,highlighted:false,added:b?.(C.id),expanded:j?.(C.id),matched:S?.(C.id),showZeroInDeposit:T,balance:w?.[C.id]?.balance,focusedField:a&&e.focusedField,accounts:d,categoryGroups:u,payees:h,inheritedFields:k?.payee===C.payee?new Set(["payee"]):new Set,dateFormat:n,hideFraction:v,onEdit:e.onEdit,onSave:l.onSave,onDelete:l.onDelete,onSplit:l.onSplit,onManagePayees:l.onManagePayees,onCreatePayee:l.onCreatePayee,onToggleSplit:l.onToggleSplit,onNavigateToTransferAccount:g,onNavigateToSchedule:f})]})};return(0,i.jsxs)(m.Z,{innerRef:c,style:{flex:1,cursor:"default",...l.style},children:[(0,i.jsxs)(m.Z,{children:[(0,i.jsx)(nC,{hasSelected:l.selectedItems.size>0,showAccount:l.showAccount,showCategory:l.showCategory,showBalance:l.showBalances,showCleared:l.showCleared,scrollWidth:u,onSort:l.onSort,ascDesc:l.ascDesc,field:l.sortField}),l.isAdding&&(0,i.jsx)(m.Z,{...r.getNavigatorProps({onKeyDown:e=>l.onCheckNewEnter(e)}),children:(0,i.jsx)(nP,{transactions:l.newTransactions,editingTransaction:r.editingId,focusedField:r.focusedField,accounts:l.accounts,categoryGroups:l.categoryGroups,payees:l.payees||[],showAccount:l.showAccount,showCategory:l.showCategory,showBalance:l.showBalances,showCleared:l.showCleared,dateFormat:n,hideFraction:l.hideFraction,onClose:l.onCloseAddTransaction,onAdd:l.onAddTemporary,onAddSplit:l.onAddSplit,onSplit:l.onSplit,onEdit:r.onEdit,onSave:l.onSave,onDelete:l.onDelete,onManagePayees:l.onManagePayees,onCreatePayee:l.onCreatePayee,onNavigateToTransferAccount:g,onNavigateToSchedule:f,balance:l.transactions?.length>0?l.balances?.[l.transactions[0]?.id]?.balance:0})})]}),(0,i.jsxs)(m.Z,{style:{flex:1,overflow:"hidden"},"data-testid":"transaction-table",children:[(0,i.jsx)(P.iA,{navigator:e,ref:t,items:l.transactions,renderItem:y,renderEmpty:o,loadMore:l.loadMoreTransactions,isSelected:e=>l.selectedItems.has(e),onKeyDown:e=>l.onCheckEnter(e),onScroll:s,saveScrollWidth:p}),l.isAdding&&(0,i.jsx)("div",{style:{position:"absolute",top:-20,left:0,right:0,height:20,backgroundColor:x.rS.errorText,boxShadow:"0 0 6px rgba(0, 0, 0, .20)"}},"shadow")]})]})}let nL=(0,a.forwardRef)((e,t)=>{let[n,r]=(0,a.useState)(null);let[o,s]=(0,a.useState)(false);let l=nb();let c=(0,a.useRef)(null);let d=(0,a.useRef)(null);let u=(0,t9.r)(d,t);let h=(0,a.useMemo)(()=>{let t;if(l.state.transitionId!=null){let n=e.transactions.findIndex(e=>e.id===l.state.transitionId);t=e.transactions.filter((e,t)=>{if(e.parent_id){if(t>=n){return l.expanded(e.parent_id)}else if(c.current){return c.current.expanded(e.parent_id)}}return true})}else{if(c.current&&c.current.state.transitionId!=null){d.current.anchor();d.current.setRowAnimation(false)}c.current=l;t=e.transactions.filter(e=>{if(e.parent_id){return l.expanded(e.parent_id)}return true})}c.current=l;return t},[e.transactions,l]);const p=(0,a.useMemo)(()=>{return new Map(h.map(e=>[e.id,e]))},[h]);(0,a.useEffect)(()=>{if(d.current.isAnchored()){d.current.unanchor();d.current.setRowAnimation(true)}},[c.current]);let g=(0,P.wz)(n,j);let f=(0,P.wz)(h,j);let x=(0,a.useRef)(false);let m=(0,a.useRef)({newTransactions:n,newNavigator:g,tableNavigator:f});let y=(0,a.useRef)(false);let w=(0,a.useRef)(false);let[v,b]=(0,a.useState)({});let S=(0,t8.D9)();(0,a.useLayoutEffect)(()=>{m.current={newTransactions:n,newNavigator:g,tableNavigator:f,transactions:e.transactions}});if(o!==e.isAdding){if(!o&&e.isAdding){r(nR(e.currentAccountId,e.currentCategoryId))}s(e.isAdding)}(0,a.useEffect)(()=>{if(x.current){if(n[0].account==null){e.addNotification({type:"error",message:"Account is a required field"});g.onEdit("temp","account")}else{let t=m.current.newTransactions;let n=t.length>0?t[0].date:null;r(nR(e.currentAccountId,e.currentCategoryId,n));g.onEdit("temp","date");e.onAdd(t)}x.current=false}});(0,a.useEffect)(()=>{if(y.current&&w.current){w.current(e);w.current=null}y.current=false},[n,e.transactions]);function j(t){let n=["select","date","account","payee","notes","category","debit","credit","cleared"];n=t.is_child?["select","payee","notes","category","debit","credit"]:n.filter(t=>(e.showAccount||t!=="account")&&(e.showCategory||t!=="category"));if(nD(t.id)){n=["select","cleared"]}if(nE(t.id)){n=n.slice(1)}return n}function C(t){if(y.current){w.current=t}else{t(e)}}function Z(e){if(e.key==="Enter"){if(e.metaKey){e.stopPropagation();T()}else if(!e.shiftKey){function t(e){let{newTransactions:t}=e.current;return t[t.length-1]}if(g.editingId===t(m).id){e.stopPropagation()}C(()=>{let e=t(m);let n=e.parent_id||e.is_parent;if(m.current.newTransactions[0].error&&g.editingId===e.id){I(e.id)}else if(g.editingId===e.id&&(!n||!e.error)){T()}})}}}function k(e){if(e.key==="Enter"&&!e.shiftKey){let{editingId:t,focusedField:n}=f;C(()=>{let r=m.current.transactions;let o=r.findIndex(e=>e.id===t);let i=p.get(r[o]?.parent_id);if(nw(r,o)&&i&&i.error&&n!=="select"){e.stopPropagation();I(t)}})}}let T=(0,a.useCallback)(()=>{x.current=true;b({})},[e.onAdd,g.onEdit]);let A=(0,a.useCallback)(async t=>{y.current=true;if(nE(t.id)){if(e.onApplyRules){t=await e.onApplyRules(t)}let n=m.current.newTransactions;r((0,t2.Ld)(n,t).data)}else{e.onSave(t)}},[e.onSave]);let B=(0,a.useCallback)(e=>{let t=nE(e);if(t){let t=m.current.newTransactions;if(e===t[0].id){return}r((0,t2.Ks)(t,e).data)}},[]);let M=(0,a.useMemo)(()=>{return t=>{if(nE(t)){let{newNavigator:e}=m.current;let n=m.current.newTransactions;let{data:o,diff:i}=(0,t2.oQ)(n,t);r(o);if(n[0].amount===null){e.onEdit(n[0].id,"debit")}else{e.onEdit(i.added[0].id,m.current.newNavigator.focusedField)}}else{let n=m.current.transactions.find(e=>e.id===t);let r=e.onSplit(t);l.dispatch({type:"open-split",id:n.id});let{tableNavigator:o}=m.current;if(n.amount===null){o.onEdit(n.id,"debit")}else{o.onEdit(r,o.focusedField)}}}},[e.onSplit,l.dispatch]);let I=(0,a.useCallback)(t=>{if(nE(t)){let e=m.current.newTransactions;let{data:n,diff:o}=(0,t2.CX)(e,t);r(n);g.onEdit(o.added[0].id,m.current.newNavigator.focusedField)}else{let n=e.onAddSplit(t);f.onEdit(n,m.current.tableNavigator.focusedField)}},[e.onAddSplit]);function R(){r(nR(e.currentAccountId,e.currentCategoryId));e.onCloseAddTransaction()}let E=(0,a.useCallback)(e=>l.dispatch({type:"toggle-split",id:e}),[l.dispatch]);return(0,i.jsx)(nW,{tableRef:u,...e,transactions:h,transactionMap:p,selectedItems:S,isExpanded:l.expanded,onSave:A,onDelete:B,onSplit:M,onCheckNewEnter:Z,onCheckEnter:k,onAddTemporary:T,onAddSplit:I,onCloseAddTransaction:R,onToggleSplit:E,newTransactions:n,tableNavigator:f,newNavigator:g})});async function nN(e){let t=await (0,d.lW)("transactions-batch-update",{...e,learnCategories:true});if(t.length>0){return{updates:t}}return{}}async function nF(e,t,n){let r=await nN(e);n((0,t2._n)(t.newTransaction,r),(0,eP.zb)(r,t.data))}function n_({tableRef:e,transactions:t,allTransactions:n,loadMoreTransactions:r,account:o,accounts:s,category:c,categoryGroups:u,payees:h,balances:p,showBalances:g,showCleared:f,showAccount:m,headerContent:y,isAdding:w,isNew:v,isMatched:b,isFiltered:S,dateFormat:j,hideFraction:C,addNotification:Z,pushModal:k,renderEmpty:T,onSort:A,sortField:B,ascDesc:M,onChange:I,onRefetch:R,onCloseAddTransaction:E,onCreatePayee:D}){let P=(0,a.useRef)();let W=(0,l.s0)();(0,a.useLayoutEffect)(()=>{P.current=t},[t]);let L=(0,a.useCallback)(async e=>{e=(0,t2.V6)(e);await nN({added:e});R()},[]);let N=(0,a.useCallback)(async e=>{let t=(0,t2.Ld)(P.current,e);if(t.diff.updated.length>0){let e=!!t.diff.updated[0].date;if(e){t.diff.updated[0].sort_order=Date.now();await nN(t.diff);R()}else{I(t.newTransaction,t.data);nF(t.diff,t,I)}}},[]);let F=(0,a.useCallback)(e=>{const t=(0,t2.CX)(P.current,e);I(t.newTransaction,t.data);nF(t.diff,t,I);return t.diff.added[0].id},[]);let _=(0,a.useCallback)(e=>{const t=(0,t2.oQ)(P.current,e);I(t.newTransaction,t.data);nF(t.diff,t,I);return t.diff.added[0].id},[]);let H=(0,a.useCallback)(async e=>{let t=await (0,d.lW)("rules-run",{transaction:e});let n=(0,eP.k4)(e,t);let r={...e};if(n){Object.keys(n).forEach(e=>{if(r[e]==null||r[e]===""||r[e]===0||r[e]===false){r[e]=n[e]}})}return r},[]);let O=(0,a.useCallback)(e=>{W("/payees",{selectedPayee:e})});let G=(0,a.useCallback)(e=>{W(`/accounts/${e}`)});let z=(0,a.useCallback)(e=>{k("schedule-edit",{id:e})});return(0,i.jsx)(nL,{ref:e,transactions:n,loadMoreTransactions:r,accounts:s,categoryGroups:u,payees:h,showBalances:g,balances:p,showCleared:f,showAccount:m,showCategory:true,currentAccountId:o&&o.id,currentCategoryId:c&&c.id,isAdding:w,isNew:v,isMatched:b,isFiltered:S,dateFormat:j,hideFraction:C,addNotification:Z,headerContent:y,renderEmpty:T,onSave:N,onApplyRules:H,onSplit:_,onCloseAddTransaction:E,onAdd:L,onAddSplit:F,onManagePayees:O,onCreatePayee:D,style:{backgroundColor:x.rS.tableBackground},onNavigateToTransferAccount:G,onNavigateToSchedule:z,onSort:A,sortField:B,ascDesc:M})}var nH=n(63495);var nO=n(45931);var nG=n(68587);const nz=e=>(0,i.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:(0,i.jsx)("path",{fill:"currentColor",d:"M19.611 2.571h-3.754a1.286 1.286 0 1 1 0-2.571h6.857A1.286 1.286 0 0 1 24 1.286v6.857a1.286 1.286 0 0 1-2.571 0V4.39L15.48 10.34a1.286 1.286 0 0 1-1.817-1.817l5.948-5.95ZM1.286 14.571a1.286 1.286 0 0 1 1.285 1.286v3.754l5.949-5.946a1.286 1.286 0 0 1 1.817 1.817L4.39 21.429h3.753a1.285 1.285 0 1 1 0 2.571H1.286A1.286 1.286 0 0 1 0 22.714v-6.857a1.286 1.286 0 0 1 1.286-1.286Z"})});var nU=nz;const nK=e=>(0,i.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:(0,i.jsx)("path",{fill:"currentColor",d:"M14.143 1.714A1.286 1.286 0 0 1 15.429 3v3.753L21.806.377a1.286 1.286 0 0 1 1.817 1.817l-6.376 6.377H21a1.286 1.286 0 1 1 0 2.572h-6.857a1.286 1.286 0 0 1-1.286-1.286V3a1.286 1.286 0 0 1 1.286-1.286ZM9.857 22.286A1.285 1.285 0 0 1 8.571 21v-3.753l-6.377 6.376a1.286 1.286 0 0 1-1.817-1.817l6.376-6.377H3a1.286 1.286 0 0 1 0-2.572h6.857a1.286 1.286 0 0 1 1.286 1.286V21a1.286 1.286 0 0 1-1.286 1.286Z"})});var n$=nK;const nQ=e=>(0,i.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,i.jsx)("path",{d:"M8.616 1.741A1.455 1.455 0 0 1 10.07.287h3.392a1.455 1.455 0 0 1 1.453 1.454v8.228a.25.25 0 0 0 .25.25h2.9a1.138 1.138 0 0 1 .827 2l-6.1 6.1a1.489 1.489 0 0 1-2.056 0l-6.1-6.1a1.137 1.137 0 0 1 .827-2h2.9a.249.249 0 0 0 .25-.25Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M0 19.677a4.039 4.039 0 0 0 4.035 4.035h15.93A4.039 4.039 0 0 0 24 19.677V17.8a1.225 1.225 0 0 0-2.449 0v1.874a1.588 1.588 0 0 1-1.586 1.586H4.035a1.588 1.588 0 0 1-1.586-1.586V17.8A1.225 1.225 0 0 0 0 17.8Z",fill:"currentColor"})]});var nV=nQ;const nq=e=>(0,i.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:(0,i.jsx)("path",{d:"M15.067 3.986a.5.5 0 0 0-.354-.148.5.5 0 0 0-.354.147L3.437 14.91a.5.5 0 0 0 0 .707l4.948 4.948a.5.5 0 0 0 .707 0L20.009 9.648a.5.5 0 0 0 0-.706ZM2.43 16.8a.5.5 0 0 0-.489-.127.5.5 0 0 0-.351.364L.084 23.314a.5.5 0 0 0 .133.47.507.507 0 0 0 .47.132l6.272-1.5a.5.5 0 0 0 .237-.84ZM23.2 2.924 21.077.8a2.5 2.5 0 0 0-3.532 0l-1.418 1.417a.5.5 0 0 0 0 .707l4.95 4.949a.5.5 0 0 0 .707 0L23.2 6.454a2.5 2.5 0 0 0 0-3.53Z",fill:"currentColor"})});var nX=nq;var nJ=n(61130);function nY({onClick:e}){return(0,i.jsx)(G.Z,{type:"bare",onClick:e,"aria-label":"Menu",children:(0,i.jsx)(eZ.Z,{width:15,height:15,style:{transform:"rotateZ(90deg)"}})})}var n0=n(30076);var n1=n(993);var n2=n(1482);var n5=n(39235);function n8({getTransaction:e,onShow:t,onDuplicate:n,onDelete:r,onEdit:o,onUnlink:s,onCreateRule:l,onScheduleAction:c,pushModal:d}){let u=(0,t8.D9)();let h=(0,a.useMemo)(()=>{let e=[...u];return{preview:!!e.find(e=>nD(e)),trans:!!e.find(e=>!nD(e))}},[u]);let p=(0,a.useMemo)(()=>{let t=[...u].map(t=>e(t));return t.some(e=>e&&e.is_child)},[u]);let g=(0,a.useMemo)(()=>{return!h.preview&&[...u].every(t=>{let n=e(t);return n&&n.schedule})},[h.preview,u,e]);return(0,i.jsx)(P.Vg,{name:"transactions",keyHandlers:h.trans&&{f:()=>t([...u]),d:()=>r([...u]),a:()=>o("account",[...u]),p:()=>o("payee",[...u]),n:()=>o("notes",[...u]),c:()=>o("category",[...u]),l:()=>o("cleared",[...u])},items:[...!h.trans?[{name:"view-schedule",text:"View schedule"},{name:"post-transaction",text:"Post transaction"},{name:"skip",text:"Skip scheduled date"}]:[{name:"show",text:"Show",key:"F"},{name:"duplicate",text:"Duplicate",disabled:p},{name:"delete",text:"Delete",key:"D"},...g?[{name:"view-schedule",text:"View schedule",disabled:u.size>1},{name:"unlink-schedule",text:"Unlink schedule"}]:[{name:"link-schedule",text:"Link schedule"},{name:"create-rule",text:"Create rule"}],z.Z.line,{type:z.Z.label,name:"Edit field"},{name:"date",text:"Date"},{name:"account",text:"Account",key:"A"},{name:"payee",text:"Payee",key:"P"},{name:"notes",text:"Notes",key:"N"},{name:"category",text:"Category",key:"C"},{name:"amount",text:"Amount"},{name:"cleared",text:"Cleared",key:"L"}]],onSelect:i=>{switch(i){case"show":t([...u]);break;case"duplicate":n([...u]);break;case"delete":r([...u]);break;case"post-transaction":case"skip":c(i,u);break;case"view-schedule":let a=[...u][0];let h;if(nD(a)){let e=a.split("/");h=e[1]}else{let t=e(a);h=t&&t.schedule}if(h){d("schedule-edit",{id:h})}break;case"link-schedule":d("schedule-link",{transactionIds:[...u]});break;case"unlink-schedule":s([...u]);break;case"create-rule":l([...u]);break;default:o(i,[...u])}}})};const n4=e=>(0,i.jsxs)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...e.style},children:[(0,i.jsx)("path",{d:"M13.584 12a2.643 2.643 0 0 1-.775 1.875l-9.541 9.541a1.768 1.768 0 0 1-2.5-2.5l8.739-8.739a.25.25 0 0 0 0-.354L.768 3.084a1.768 1.768 0 0 1 2.5-2.5l9.541 9.541A2.643 2.643 0 0 1 13.584 12Z",fill:"currentColor"}),(0,i.jsx)("path",{d:"M23.75 12a2.643 2.643 0 0 1-.775 1.875l-9.541 9.541a1.768 1.768 0 0 1-2.5-2.5l8.739-8.739a.25.25 0 0 0 0-.354l-8.739-8.739a1.768 1.768 0 0 1 2.5-2.5l9.541 9.541A2.643 2.643 0 0 1 23.75 12Z",fill:"currentColor"})]});var n3=n4;function n6({name:e,balance:t,isExactBalance:n=true}){const r=(0,eQ.Z)();return(0,i.jsxs)(et.Z,{style:{marginLeft:15,borderRadius:4,padding:"4px 6px",color:x.rS.alt2PillText,backgroundColor:x.rS.pillBackground},children:[e," ",(0,i.jsx)(e4.ZP,{children:(0,i.jsxs)(et.Z,{style:{fontWeight:600},children:[!n&&"~ ",r(t,"financial")]})})]})}function n7({selectedItems:e,account:t}){let n=`selected-balance-${[...e].join("-")}`;let r=(0,eV.Z)({name:n,query:(0,Q.ZP)("transactions").filter({id:{$oneof:[...e]},parent_id:{$oneof:[...e]}}).select("id")});let o=new Set((r||[]).map(e=>e.id));let a=[...e].filter(e=>!o.has(e));let s=(0,eV.Z)({name:n+"-sum",query:(0,Q.ZP)("transactions").filter({id:{$oneof:a}}).options({splits:"all"}).calculate({$sum:"$amount"})});let l=null;let c=(0,tG.oF)();let d=c?c.schedules:[];let u=[...e].filter(e=>nD(e)).map(e=>e.slice(8));let h=true;for(let e of d){if(u.includes(e.id)){if(e._amountOp==="isbetween"){h=false}if(!t||t.id===e._account){l+=(0,t1.lP)(e._amount)}else{l-=(0,t1.lP)(e._amount)}}}if(s==null){if(l==null){return null}else{s=l}}else if(l!=null){s+=l}return(0,i.jsx)(n6,{name:"Selected balance:",balance:s,isExactBalance:h})}function n9({balanceQuery:e}){let t=(0,eV.Z)({name:e.name+"-cleared",query:e.query.filter({cleared:true})});let n=(0,eV.Z)({name:e.name+"-uncleared",query:e.query.filter({cleared:false})});return(0,i.jsxs)(m.Z,{style:{flexDirection:"row"},children:[(0,i.jsx)(n6,{name:"Cleared total:",balance:t}),(0,i.jsx)(n6,{name:"Uncleared total:",balance:n})]})}function re({balanceQuery:e,showExtraBalances:t,onToggleExtraBalances:n,account:r}){let o=(0,t8.D9)();return(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center",marginTop:-5,marginLeft:-5},children:[(0,i.jsxs)(G.Z,{"data-testid":"account-balance",type:"bare",onClick:n,style:{"& svg":{opacity:o.size>0||t?1:0},"&:hover svg":{opacity:1}},children:[(0,i.jsx)(e$.Z,{binding:{...e,value:0},type:"financial",style:{fontSize:22,fontWeight:400},getStyle:e=>({color:e<0?x.rS.errorText:e>0?x.rS.noticeText:x.rS.pageTextSubdued}),privacyFilter:{blurIntensity:5}}),(0,i.jsx)(n3,{style:{width:10,height:10,marginLeft:10,color:x.rS.alt2PillText,transform:t?"rotateZ(180deg)":"rotateZ(0)"}})]}),t&&(0,i.jsx)(n9,{balanceQuery:e}),o.size>0&&(0,i.jsx)(n7,{selectedItems:o,account:r})]})}var rt=n(7269);function rn({balanceQuery:e,targetBalance:t,onDone:n,onCreateTransaction:r}){let o=(0,eV.Z)({name:e.name+"-cleared",value:0,query:e.query.filter({cleared:true})});let a=(0,eQ.Z)();let s=t-o;return(0,i.jsx)(m.Z,{style:{flexDirection:"row",alignSelf:"center",backgroundColor:x.rS.tableBackground,...x.W2.shadow,borderRadius:4,marginTop:5,marginBottom:15,padding:10},children:(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center"},children:[s===0?(0,i.jsxs)(m.Z,{style:{color:x.rS.noticeText,flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},children:[(0,i.jsx)(rt.Z,{style:{width:13,height:13,color:"inherit",marginRight:3}}),"All reconciled!"]}):(0,i.jsx)(m.Z,{style:{color:x.rS.tableText},children:(0,i.jsxs)(et.Z,{style:{fontStyle:"italic",textAlign:"center"},children:["Your cleared balance"," ",(0,i.jsx)("strong",{children:a(o,"financial")})," needs"," ",(0,i.jsx)("strong",{children:(s>0?"+":"")+a(s,"financial")})," ","to match",(0,i.jsx)("br",{})," your bank’s balance of"," ",(0,i.jsx)(et.Z,{style:{fontWeight:700},children:a(t,"financial")})]})}),(0,i.jsx)(m.Z,{style:{marginLeft:15},children:(0,i.jsx)(G.Z,{type:"primary",onClick:n,children:"Done Reconciling"})}),s!==0&&(0,i.jsx)(m.Z,{style:{marginLeft:15},children:(0,i.jsx)(G.Z,{onClick:()=>r(s),children:"Create Reconciliation Transaction"})})]})})}function rr({account:e,onReconcile:t,onClose:n}){let r=eD.cW(e);let o=(0,eV.Z)({name:r.name+"-cleared",value:null,query:r.query.filter({cleared:true})});let a=(0,eQ.Z)();function s(e){e.preventDefault();let r=e.target.elements[0];let i=(0,eP.qT)(r.value);if(i!=null){t(i==null?o:i);n()}else{r.select()}}return(0,i.jsx)(E.u,{position:"bottom-right",width:275,onClose:n,children:(0,i.jsxs)(m.Z,{style:{padding:"5px 8px"},children:[(0,i.jsx)(et.Z,{children:"Enter the current balance of your bank account that you want to reconcile with:"}),(0,i.jsxs)("form",{onSubmit:s,children:[o!=null&&(0,i.jsx)(tw.Z,{children:(0,i.jsx)(tv.ZP,{defaultValue:a(o,"financial"),style:{margin:"7px 0"}})}),(0,i.jsx)(G.Z,{type:"primary",children:"Reconcile"})]})]})})};function ro({tableRef:e,editingName:t,isNameEditable:n,workingHard:r,accountName:o,account:s,filterId:l,filtersList:c,accountsSyncing:d,accounts:u,transactions:h,showBalances:p,showExtraBalances:g,showCleared:f,showEmptyMessage:y,balanceQuery:w,reconcileAmount:v,canCalculateBalance:b,isSorted:S,search:j,filters:C,conditionsOp:Z,savePrefs:k,pushModal:T,onSearch:A,onAddTransaction:B,onShowTransactions:M,onDoneReconciling:I,onCreateReconciliationTransaction:R,onToggleExtraBalances:E,onSaveName:D,onExposeName:P,onSync:W,onImport:L,onMenuSelect:N,onReconcile:F,onBatchDelete:_,onBatchDuplicate:H,onBatchEdit:O,onBatchUnlink:z,onCreateRule:U,onApplyFilter:K,onUpdateFilter:$,onClearFilters:Q,onReloadSavedFilter:V,onCondOpChange:q,onDeleteFilter:X,onScheduleAction:J}){let[Y,ee]=(0,a.useState)(false);let et=(0,a.useRef)(null);let en=nb();let er=s&&s.account_id;if(!s){er=!!u.find(e=>!!e.account_id)}function eo(){if(e.current){en.dispatch({type:"switch-mode",id:e.current.getScrolledItem()});k({"expand-splits":!(en.state.mode==="expand")})}}return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n5.U,{keys:{"ctrl+f, cmd+f":()=>{if(et.current){et.current.focus()}}}}),(0,i.jsxs)(m.Z,{style:{...x.W2.pageContent,paddingBottom:10,flexShrink:0},children:[(0,i.jsx)(m.Z,{style:{marginTop:2,alignItems:"flex-start"},children:(0,i.jsx)(m.Z,{children:t?(0,i.jsx)(tw.Z,{children:(0,i.jsx)(tv.ZP,{defaultValue:o,onEnter:e=>D(e.target.value),onBlur:()=>P(false),style:{fontSize:25,fontWeight:500,marginTop:-5,marginBottom:-2,marginLeft:-5}})}):n?(0,i.jsxs)(m.Z,{style:{flexDirection:"row",alignItems:"center",gap:3,"& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,i.jsx)(m.Z,{style:{fontSize:25,fontWeight:500,marginRight:5,marginBottom:5},"data-testid":"account-name",children:s&&s.closed?"Closed: "+o:o}),s&&(0,i.jsx)(ei,{id:`account-${s.id}`}),(0,i.jsx)(G.Z,{type:"bare",className:"hover-visible",onClick:()=>P(true),children:(0,i.jsx)(nX,{style:{width:11,height:11,color:x.rS.altButtonBareText}})})]}):(0,i.jsx)(m.Z,{style:{fontSize:25,fontWeight:500,marginBottom:5},"data-testid":"account-name",children:s&&s.closed?"Closed: "+o:o})})}),(0,i.jsx)(re,{balanceQuery:w,showExtraBalances:g,onToggleExtraBalances:E,account:s}),(0,i.jsxs)(e8.Z,{spacing:2,direction:"row",align:"center",style:{marginTop:12},children:[(s&&!s.closed||er)&&(0,i.jsx)(G.Z,{type:"bare",onClick:er?W:L,children:er?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nJ.Z,{width:13,height:13,animating:s&&d===s.name||d==="__all",style:{marginRight:4}})," ","Sync"]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nV,{width:13,height:13,style:{marginRight:4}})," ","Import"]})}),!y&&(0,i.jsxs)(G.Z,{type:"bare",onClick:B,children:[(0,i.jsx)(nG.Z,{width:10,height:10,style:{marginRight:3}})," Add New"]}),(0,i.jsx)(m.Z,{style:{flexShrink:0},children:(0,i.jsx)(n1.L,{onApply:K})}),(0,i.jsx)(m.Z,{style:{flex:1}}),(0,i.jsx)(tz.Z,{placeholder:"Search",value:j,onChange:A,inputRef:et}),r?(0,i.jsx)(m.Z,{children:(0,i.jsx)(nO.Z,{style:{width:16,height:16}})}):(0,i.jsx)(n8,{getTransaction:e=>h.find(t=>t.id===e),onShow:M,onDuplicate:H,onDelete:_,onEdit:O,onUnlink:z,onCreateRule:U,onScheduleAction:J,pushModal:T}),(0,i.jsx)(G.Z,{type:"bare",disabled:j!==""||C.length>0,style:{padding:6,marginLeft:10},onClick:eo,title:en.state.mode==="collapse"?"Collapse split transactions":"Expand split transactions",children:en.state.mode==="collapse"?(0,i.jsx)(n$,{style:{width:14,height:14}}):(0,i.jsx)(nU,{style:{width:14,height:14}})}),s?(0,i.jsxs)(m.Z,{children:[(0,i.jsx)(nY,{onClick:()=>ee(true)}),Y&&(0,i.jsx)(ri,{account:s,canSync:er,canShowBalances:b(),isSorted:S,showBalances:p,showCleared:f,onMenuSelect:e=>{ee(false);N(e)},onReconcile:F,onClose:()=>ee(false)})]}):(0,i.jsxs)(m.Z,{children:[(0,i.jsx)(nY,{onClick:()=>ee(true)}),Y&&(0,i.jsx)(ra,{onMenuSelect:e=>{ee(false);N(e)},onClose:()=>ee(false),isSorted:S})]})]}),C&&C.length>0&&(0,i.jsx)(n2.O,{filters:C,conditionsOp:Z,onUpdateFilter:$,onDeleteFilter:X,onClearFilters:Q,onReloadSavedFilter:V,filterId:l,filtersList:c,onCondOpChange:q})]}),v!=null&&(0,i.jsx)(rn,{targetBalance:v,balanceQuery:w,onDone:I,onCreateTransaction:R})]})}function ri({account:e,canSync:t,showBalances:n,canShowBalances:r,showCleared:o,onClose:s,isSorted:l,onReconcile:c,onMenuSelect:d}){let[u,h]=(0,a.useState)("default");const p=(0,nH.Z)();return u==="reconcile"?(0,i.jsx)(rr,{account:e,onClose:s,onReconcile:c}):(0,i.jsx)(n0.Z,{width:200,onClose:s,children:(0,i.jsx)(z.Z,{onMenuSelect:e=>{if(e==="reconcile"){h("reconcile")}else{d(e)}},items:[l&&{name:"remove-sorting",text:"Remove all sorting"},r&&{name:"toggle-balance",text:(n?"Hide":"Show")+" running balance"},{name:"toggle-cleared",text:(o?"Hide":"Show")+" “cleared” checkboxes"},{name:"export",text:"Export"},{name:"reconcile",text:"Reconcile"},e&&!e.closed&&(t?{name:"unlink",text:"Unlink account"}:p==="online"&&{name:"link",text:"Link account"}),e.closed?{name:"reopen",text:"Reopen account"}:{name:"close",text:"Close account"}].filter(e=>e)})})}function ra({onClose:e,onMenuSelect:t,isSorted:n}){return(0,i.jsx)(n0.Z,{width:200,onClose:e,children:(0,i.jsx)(z.Z,{onMenuSelect:e=>{t(e)},items:[n&&{name:"remove-sorting",text:"Remove all sorting"},{name:"export",text:"Export"}]})})};function rs({onAdd:e}){return(0,i.jsx)(m.Z,{style:{color:x.rS.tableText,backgroundColor:x.rS.tableBackground,flex:1,alignItems:"center",borderTopWidth:1,borderColor:x.rS.tableBorder},children:(0,i.jsxs)(m.Z,{style:{width:550,marginTop:75,fontSize:15,alignItems:"center"},children:[(0,i.jsxs)(et.Z,{style:{textAlign:"center",lineHeight:"1.4em"},children:["For Actual to be useful, you need to ",(0,i.jsx)("strong",{children:"add an account"}),". You can link an account to automatically download transactions, or manage it locally yourself."]}),(0,i.jsx)(G.Z,{type:"primary",style:{marginTop:20},onClick:e,children:"Add account"}),(0,i.jsx)(m.Z,{style:{marginTop:20,fontSize:13,color:x.rS.alttableText},children:"In the future, you can add accounts from the sidebar."})]})})}function rl({account:e={},transactions:t,balances:n,showBalances:r,filtered:o,children:i}){const{id:s}=e;let l=(0,tG.oF)();t??=[];let c=(0,a.useMemo)(()=>l?l.schedules.filter(e=>!e.completed&&["due","upcoming","missed"].includes(l.statuses.get(e.id))):[],[l]);let d=(0,a.useMemo)(()=>{return c.map(e=>({id:`preview/${e.id}`,payee:e._payee,account:e._account,amount:e._amount,date:e.next_date,notes:l.statuses.get(e.id),schedule:e.id,_inverse:s?s!==e._account:false}))},[c,s]);let u=(0,a.useMemo)(()=>{if(!r){return 0}return n&&t?.length>0?n[t[0].id]?.balance??0:0},[r,n,t]);let h=(0,a.useMemo)(()=>{if(!r){return null}let e=[...d].reverse().map(e=>{let t=(e._inverse?-1:1)*(0,t1.lP)(e.amount);return{balance:u+=t,id:e.id}});return(0,eP.ZZ)(e)},[r,d,u]);let p=(0,a.useMemo)(()=>{if(!o&&d.length>0){return d.concat(t)}return t},[o,d,t]);let g=(0,a.useMemo)(()=>{if(!o&&h&&n){return{...h,...n}}return n},[o,h,n]);if(l==null){return i(t,n)}return i(p,g)}function rc(e){switch(e){case"account":return"account.name";case"payee":return"payee.name";case"category":return"category.name";case"payment":return"amount";case"deposit":return"amount";default:return e}}class rd extends a.PureComponent{constructor(e){super(e);this.paged=null;this.table=(0,a.createRef)();this.animated=true;this.state={search:"",filters:[],loading:true,workingHard:false,reconcileAmount:null,transactions:[],transactionsCount:0,showBalances:e.showBalances,balances:null,showCleared:e.showCleared,editingName:false,isAdding:false,latestDate:null,filterId:[],conditionsOp:"and",sort:[]}}async componentDidMount(){let e=e=>{if(e.includes("transactions")||e.includes("category_mapping")||e.includes("payee_mapping")){return this.refetchTransactions()}};let t=async({tables:t,messages:n,undoTag:r})=>{await e(t);let o;if(n.every(e=>e.dataset==="transactions")&&!n.find(e=>e.column==="tombstone")){let e=n.filter(e=>e.dataset==="transactions"&&!(e.column==="tombstone"));o=e.length===1?e[0].row:null}if(this.table.current){this.table.current.edit(null);if(o){this.table.current.scrollTo(o)}}this.props.setLastUndoState(null)};let n=[(0,d.oL)("undo-event",t)];this.unlisten=()=>{n.forEach(e=>e())};await this.props.initiallyLoadPayees();await this.fetchTransactions();if(this.props.lastUndoState&&this.props.lastUndoState.current){t(this.props.lastUndoState.current)}}componentDidUpdate(e){if(this.state.isAdding&&this.props.accountId!==e.accountId){this.setState({isAdding:false})}if(e.modalShowing&&!this.props.modalShowing){setTimeout(()=>{this.refetchTransactions()},100)}if(this.props.accountId!==e.accountId){this.setState({sort:[],search:"",filters:[]})}}componentWillUnmount(){if(this.unlisten){this.unlisten()}if(this.paged){this.paged.unsubscribe()}}fetchAllIds=async()=>{let{data:e}=await (0,Q.Vn)(this.paged.getQuery().select("id"));return e.reduce((e,t)=>{e.push(t.id);t.subtransactions.forEach(t=>e.push(t.id));return e},[])};refetchTransactions=async()=>{this.paged?.run()};fetchTransactions=()=>{let e=this.makeRootQuery();this.rootQuery=this.currentQuery=e;this.updateQuery(e);if(this.props.accountId){this.props.markAccountRead(this.props.accountId)}};makeRootQuery=()=>{let e=this.props.location.state;let t=this.props.accountId;if(e&&e.filter){return(0,Q.ZP)("transactions").options({splits:"grouped"}).filter({"account.offbudget":false,...e.filter})}return eD.yf(t)};updateQuery(e,t){if(this.paged){this.paged.unsubscribe()}this.paged=(0,Q.Fr)(e.select("*"),async(e,n)=>{const r=n==null;if(r){this.table.current?.setRowAnimation(false);if(t){this.props.splitsExpandedDispatch({type:"set-mode",mode:"collapse"})}else{this.props.splitsExpandedDispatch({type:"set-mode",mode:this.props.expandSplits?"expand":"collapse"})}}this.setState({transactions:e,transactionCount:this.paged.getTotalCount(),transactionsFiltered:t,loading:false,workingHard:false,balances:this.state.showBalances?await this.calculateBalances():null},()=>{if(r){this.table.current?.scrollToTop()}setTimeout(()=>{this.table.current?.setRowAnimation(true)},0)})},{pageCount:150,onlySync:true,mapper:t2.Xt})}UNSAFE_componentWillReceiveProps(e){if(this.props.accountId!==e.accountId){this.setState({editingName:false,loading:true,search:"",showBalances:e.showBalances,balances:null,showCleared:e.showCleared,reconcileAmount:null},()=>{this.fetchTransactions()})}}onSearch=e=>{this.paged.unsubscribe();this.setState({search:e},this.onSearchDone)};onSearchDone=(0,tX.debounce)(()=>{if(this.state.search===""){this.updateQuery(this.currentQuery,this.state.filters.length>0)}else{this.updateQuery(eD.jS(this.currentQuery,this.state.search,this.props.dateFormat),true)}},150);onSync=async()=>{const e=this.props.accountId;const t=this.props.accounts.find(t=>t.id===e);await this.props.syncAndDownload(t?t.id:null)};onImport=async()=>{const e=this.props.accountId;const t=this.props.accounts.find(t=>t.id===e);if(t){const t=await window.Actual.openFileDialog({filters:[{name:"Financial Files",extensions:["qif","ofx","qfx","csv","tsv"]}]});if(t){this.props.pushModal("import-transactions",{accountId:e,filename:t[0],onImported:e=>{if(e){this.fetchTransactions()}}})}}};onExport=async e=>{let t=await (0,d.lW)("transactions-export-query",{query:this.currentQuery.serialize()});let n=e&&e.replace(/[()]/g,"").replace(/\s+/g,"-");let r=`${n||"transactions"}.csv`;window.Actual.saveFile(t,r,"Export Transactions")};onTransactionsChange=(e,t)=>{this.paged.optimisticUpdate(t=>{if(e._deleted){return t.filter(t=>t.id!==e.id)}else{return t.map(t=>{return t.id===e.id?e:t})}},e=>{return t});this.props.updateNewTransactions(e.id)};canCalculateBalance=()=>{let e=this.props.accountId;let t=this.props.accounts.find(t=>t.id===e);return t&&this.state.search===""&&this.state.filters.length===0&&(this.state.sort.length===0||this.state.sort.field==="date"&&this.state.sort.ascDesc==="desc")};async calculateBalances(){if(!this.canCalculateBalance()){return null}let{data:e}=await (0,Q.Vn)(this.paged.getQuery().options({splits:"none"}).select([{balance:{$sumOver:"$amount"}}]));return(0,eP.ZZ)(e)}onAddTransaction=()=>{this.setState({isAdding:true})};onExposeName=e=>{this.setState({editingName:e})};onSaveName=e=>{if(e.trim().length){const t=this.props.accountId;const n=this.props.accounts.find(e=>e.id===t);this.props.updateAccount({...n,name:e});this.setState({editingName:false})}};onToggleExtraBalances=()=>{let{accountId:e,showExtraBalances:t}=this.props;let n="show-extra-balances-"+e||0;this.props.savePrefs({[n]:!t})};onMenuSelect=async e=>{const t=this.props.accountId;const n=this.props.accounts.find(e=>e.id===t);switch(e){case"link":(0,t5.F)(this.props.pushModal,{upgradingAccountId:t});break;case"unlink":this.props.unlinkAccount(t);break;case"close":this.props.openAccountCloseModal(t);break;case"reopen":this.props.reopenAccount(t);break;case"export":const r=this.getAccountTitle(n,t);this.onExport(r);break;case"toggle-balance":if(this.state.showBalances){this.props.savePrefs({["show-balances-"+t]:false});this.setState({showBalances:false,balances:null})}else{this.props.savePrefs({["show-balances-"+t]:true});this.setState({transactions:[],transactionCount:0,filters:[],search:"",sort:[],showBalances:true},()=>{this.fetchTransactions()})}break;case"remove-sorting":{this.setState({sort:[]},()=>{let e=this.state.filters;if(e.length>0){this.applyFilters([...e])}else{this.fetchTransactions()}if(this.state.search!==""){this.onSearch(this.state.search)}});break}case"toggle-cleared":if(this.state.showCleared){this.props.savePrefs({["hide-cleared-"+t]:true});this.setState({showCleared:false})}else{this.props.savePrefs({["hide-cleared-"+t]:false});this.setState({showCleared:true})}break;default:}};getAccountTitle(e,t){let{filterName:n}=this.props.location.state||{};if(n){return n}if(!e){if(t==="budgeted"){return"Budgeted Accounts"}else if(t==="offbudget"){return"Off Budget Accounts"}else if(t==="uncategorized"){return"Uncategorized"}else if(!t){return"All Accounts"}return null}return e.name}getBalanceQuery(e,t){return{name:`balance-query-${t}`,query:this.makeRootQuery().calculate({$sum:"$amount"})}}isNew=e=>{return this.props.newTransactions.includes(e)};isMatched=e=>{return this.props.matchedTransactions.includes(e)};onCreatePayee=e=>{let t=e.trim();if(t!==""){return this.props.createPayee(e)}return null};onReconcile=e=>{this.setState({reconcileAmount:e})};onDoneReconciling=()=>{this.setState({reconcileAmount:null})};onCreateReconciliationTransaction=async e=>{const t=(0,t2.V6)([{id:"temp",account:this.props.accountId,cleared:true,amount:e,date:(0,h.PR)(),notes:"Reconciliation balance adjustment"}]);this.setState({transactions:[...this.state.transactions,...t]});await (0,d.lW)("transactions-batch-update",{added:t});await this.refetchTransactions()};onShowTransactions=async e=>{this.onApplyFilter({customName:"Selected transactions",filter:{id:{$oneof:e}}})};onBatchEdit=async(e,t)=>{let n=async(e,n)=>{this.setState({workingHard:true});let{data:r}=await (0,Q.Vn)((0,Q.ZP)("transactions").filter({id:{$oneof:t}}).select("*").options({splits:"grouped"}));let o=(0,t2.Xt)(r);let i={deleted:[],updated:[]};if(e==="cleared"){n=!!o.find(e=>!e.cleared)}const a=new Set(t);o.forEach(t=>{if(!a.has(t.id)){return}let{diff:r}=(0,t2.Ld)(o,{...t,[e]:n});o=(0,eP.zb)(r,o);i.deleted=i.deleted?i.deleted.concat(r.deleted):r.deleted;i.updated=i.updated?i.updated.concat(r.updated):r.updated;i.added=i.added?i.added.concat(r.added):r.added});await (0,d.lW)("transactions-batch-update",i);await this.refetchTransactions();if(this.table.current){this.table.current.edit(o[0].id,"select",false)}};if(e==="cleared"){n("cleared",null)}else{this.props.pushModal("edit-field",{name:e,onSubmit:n})}};onBatchDuplicate=async e=>{this.setState({workingHard:true});let{data:t}=await (0,Q.Vn)((0,Q.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n={added:t.reduce((e,t)=>{return e.concat((0,t2.V6)((0,t2.F6)(t)))},[]).map(({sort_order:e,...t})=>({...t}))};await (0,d.lW)("transactions-batch-update",n);await this.refetchTransactions()};onBatchDelete=async e=>{this.setState({workingHard:true});let{data:t}=await (0,Q.Vn)((0,Q.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n=(0,t2.Xt)(t);let r=new Set(e);let o={deleted:[],updated:[]};n.forEach(e=>{let t=e.parent_id;if(!r.has(e.id)||t&&r.has(t)){return}let{diff:i}=(0,t2.Ks)(n,e.id);n=(0,eP.zb)(i,n);o.deleted=i.deleted?o.deleted.concat(i.deleted):i.deleted;o.updated=i.updated?o.updated.concat(i.updated):i.updated});await (0,d.lW)("transactions-batch-update",o);await this.refetchTransactions()};onBatchUnlink=async e=>{await (0,d.lW)("transactions-batch-update",{updated:e.map(e=>({id:e,schedule:null}))});await this.refetchTransactions()};onCreateRule=async e=>{let{data:t}=await (0,Q.Vn)((0,Q.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n=(0,t2.Xt)(t);let r=n[0].imported_payee?{field:"imported_payee",op:"is",value:n[0].imported_payee,type:"string"}:{field:"payee",op:"is",value:n[0].payee,type:"id"};let o={stage:null,conditionsOp:"and",conditions:[r],actions:[{op:"set",field:"category",value:n[0].category,type:"id"}]};this.props.pushModal("edit-rule",{rule:o})};onCondOpChange=(e,t)=>{this.setState({conditionsOp:e});this.setState({filterId:{...this.state.filterId,status:"changed"}});this.applyFilters([...t]);if(this.state.search!==""){this.onSearch(this.state.search)}};onReloadSavedFilter=(e,t)=>{if(t==="reload"){let[e]=this.props.filtersList.filter(e=>e.id===this.state.filterId.id);this.setState({conditionsOp:e.conditionsOp});this.applyFilters([...e.conditions])}else{if(e.status){this.setState({conditionsOp:e.conditionsOp});this.applyFilters([...e.conditions])}}this.setState({filterId:{...this.state.filterId,...e}})};onClearFilters=()=>{this.setState({conditionsOp:"and"});this.setState({filterId:[]});this.applyFilters([]);if(this.state.search!==""){this.onSearch(this.state.search)}};onUpdateFilter=(e,t)=>{this.applyFilters(this.state.filters.map(n=>n===e?t:n));this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}});if(this.state.search!==""){this.onSearch(this.state.search)}};onDeleteFilter=e=>{this.applyFilters(this.state.filters.filter(t=>t!==e));if(this.state.filters.length===1){this.setState({filterId:[]});this.setState({conditionsOp:"and"})}else{this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}})}if(this.state.search!==""){this.onSearch(this.state.search)}};onApplyFilter=async e=>{let t=this.state.filters;if(e.customName){t=t.filter(t=>t.customName!==e.customName)}if(e.conditions){this.setState({filterId:{...e,status:"saved"}});this.setState({conditionsOp:e.conditionsOp});this.applyFilters([...e.conditions])}else{this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}});this.applyFilters([...t,e])}if(this.state.search!==""){this.onSearch(this.state.search)}};onScheduleAction=async(e,t)=>{switch(e){case"post-transaction":for(let e of t){let t=e.split("/");await (0,d.lW)("schedule/post-transaction",{id:t[1]})}this.refetchTransactions();break;case"skip":for(let e of t){let t=e.split("/");await (0,d.lW)("schedule/skip-next-date",{id:t[1]})}break;default:}};applyFilters=async e=>{if(e.length>0){let t=e.filter(e=>!!e.customName).map(e=>e.filter);let{filters:n}=await (0,d.lW)("make-filters-from-conditions",{conditions:e.filter(e=>!e.customName)});const r=this.state.conditionsOp==="or"?"$or":"$and";this.currentQuery=this.rootQuery.filter({[r]:[...n,...t]});this.setState({filters:e},()=>{this.updateQuery(this.currentQuery,true)})}else{this.setState({transactions:[],transactionCount:0,filters:e},()=>{this.fetchTransactions()})}if(this.state.sort.length!==0){this.applySort()}};applySort=(e,t,n,r)=>{let o=this.state.filters;let i=rc(!e?this.state.sort.field:e);let a=!t?this.state.sort.ascDesc:t;let s=rc(!n?this.state.sort.prevField:n);let l=!n?this.state.sort.prevAscDesc:r;if(!e){this.currentQuery=this.currentQuery.orderBy({[i]:a})}else{if(o.length>0){this.applyFilters([...o]);this.currentQuery=this.currentQuery.orderBy({[i]:a})}else{this.currentQuery=this.rootQuery.orderBy({[i]:a})}}if(s){this.currentQuery=this.currentQuery.orderBy({[s]:l})}this.updateQuery(this.currentQuery,this.state.filters.length>0)};onSort=(e,t)=>{let n;let r;if(e===this.state.sort.field){n=this.state.sort.prevField;r=this.state.sort.prevAscDesc;this.setState({sort:{...this.state.sort,ascDesc:t}})}else{n=this.state.sort.field;r=this.state.sort.ascDesc;this.setState({sort:{field:e,ascDesc:t,prevField:this.state.sort.field,prevAscDesc:this.state.sort.ascDesc}})}this.applySort(e,t,n,r);if(this.state.search!==""){this.onSearch(this.state.search)}};render(){let{accounts:e,categoryGroups:t,payees:n,dateFormat:r,hideFraction:o,addNotification:a,accountsSyncing:s,pushModal:c,replaceModal:d,showExtraBalances:u,accountId:h,categoryId:p}=this.props;let{transactions:g,loading:f,workingHard:y,filterId:w,reconcileAmount:v,transactionsFiltered:b,editingName:S,showBalances:j,balances:C,showCleared:Z}=this.state;let k=e.find(e=>e.id===h);const T=this.getAccountTitle(k,h);if(!T&&!f){return(0,i.jsx)(l.Fg,{to:"/accounts",replace:true})}let A=t.flatMap(e=>e.categories).find(e=>e.id===p);let B=!f&&!h&&e.length===0;let M=h&&h!=="budgeted"&&h!=="offbudget"&&h!=="uncategorized";let I=this.getBalanceQuery(k,h);return(0,i.jsx)(rl,{account:k,transactions:g,balances:C,showBalances:j,filtered:b,children:(l,p)=>(0,i.jsx)(t8.mL,{name:"transactions",items:l,fetchAllIds:this.fetchAllIds,registerDispatch:e=>this.dispatchSelected=e,children:(0,i.jsxs)(m.Z,{style:x.W2.page,children:[(0,i.jsx)(ro,{tableRef:this.table,editingName:S,isNameEditable:M,workingHard:y,account:k,filterId:w,filtersList:this.props.filtersList,location:this.props.location,accountName:T,accountsSyncing:s,accounts:e,transactions:g,showBalances:j,showExtraBalances:u,showCleared:Z,showEmptyMessage:B,balanceQuery:I,canCalculateBalance:this.canCalculateBalance,isSorted:this.state.sort.length!==0,reconcileAmount:v,search:this.state.search,filters:this.state.filters,conditionsOp:this.state.conditionsOp,savePrefs:this.props.savePrefs,pushModal:this.props.pushModal,onSearch:this.onSearch,onShowTransactions:this.onShowTransactions,onMenuSelect:this.onMenuSelect,onAddTransaction:this.onAddTransaction,onToggleExtraBalances:this.onToggleExtraBalances,onSaveName:this.onSaveName,onExposeName:this.onExposeName,onReconcile:this.onReconcile,onDoneReconciling:this.onDoneReconciling,onCreateReconciliationTransaction:this.onCreateReconciliationTransaction,onSync:this.onSync,onImport:this.onImport,onBatchDelete:this.onBatchDelete,onBatchDuplicate:this.onBatchDuplicate,onBatchEdit:this.onBatchEdit,onBatchUnlink:this.onBatchUnlink,onCreateRule:this.onCreateRule,onUpdateFilter:this.onUpdateFilter,onClearFilters:this.onClearFilters,onReloadSavedFilter:this.onReloadSavedFilter,onCondOpChange:this.onCondOpChange,onDeleteFilter:this.onDeleteFilter,onApplyFilter:this.onApplyFilter,onScheduleAction:this.onScheduleAction}),(0,i.jsx)(m.Z,{style:{flex:1},children:(0,i.jsx)(n_,{tableRef:this.table,account:k,transactions:g,allTransactions:l,animated:this.animated,loadMoreTransactions:()=>this.paged&&this.paged.fetchNext(),accounts:e,category:A,categoryGroups:t,payees:n,balances:p,showBalances:!!p,showCleared:Z,showAccount:!h||h==="offbudget"||h==="budgeted"||h==="uncategorized",isAdding:this.state.isAdding,isNew:this.isNew,isMatched:this.isMatched,isFiltered:this.state.search!==""||this.state.filters.length>0,dateFormat:r,hideFraction:o,addNotification:a,renderEmpty:()=>B?(0,i.jsx)(rs,{onAdd:()=>d("add-account")}):!f?(0,i.jsx)(m.Z,{style:{color:x.rS.tableText,marginTop:20,textAlign:"center",fontStyle:"italic"},children:"No transactions"}):null,pushModal:c,onSort:this.onSort,sortField:this.state.sort.field,ascDesc:this.state.sort.ascDesc,onChange:this.onTransactionsChange,onRefetch:this.refetchTransactions,onRefetchUpToRow:e=>this.paged.refetchUpToRow(e,{field:"date",order:"desc"}),onCloseAddTransaction:()=>this.setState({isAdding:false}),onCreatePayee:this.onCreatePayee})})]})})})}}function ru(e){let{dispatch:t}=nb();let n=(0,l.bS)(e.location.pathname);return(0,i.jsx)(rd,{...e,match:n,splitsExpandedDispatch:t})}function rh(){let e=(0,l.UO)();let t=(0,l.TH)();let{grouped:n}=(0,g.Z)();let r=(0,s.v9)(t=>({newTransactions:t.queries.newTransactions,matchedTransactions:t.queries.matchedTransactions,accounts:t.queries.accounts,failedAccounts:t.account.failedAccounts,dateFormat:t.prefs.local.dateFormat||"MM/dd/yyyy",hideFraction:t.prefs.local.hideFraction||false,expandSplits:t.prefs.local["expand-splits"],showBalances:e.id&&t.prefs.local["show-balances-"+e.id],showCleared:e.id&&!t.prefs.local["hide-cleared-"+e.id],showExtraBalances:t.prefs.local["show-extra-balances-"+e.id||0],payees:t.queries.payees,modalShowing:t.modals.modalStack.length>0,accountsSyncing:t.account.accountsSyncing,lastUndoState:t.app.lastUndoState}));let o=(0,s.I0)();let c=(0,t0.m)();let d=(0,a.useMemo)(()=>(0,tJ.DE)(tY,o),[o]);let u=(0,a.useMemo)(()=>{let n=eD.PK(e.id,"_account");let r=eD.PK(e.id,"_payee.transfer_acct");if(t.state&&t.state.filter||e.id==="uncategorized"){n={id:null};r={id:null}}return e=>{e=e.filter({$and:[{"_account.closed":false}],$or:[n,r]});return e.orderBy({next_date:"desc"})}},[e.id]);return(0,i.jsx)(tG.up,{transform:u,children:(0,i.jsx)(nS,{initialMode:r.expandSplits?"collapse":"expand",children:(0,i.jsx)(ru,{...r,categoryGroups:n,...d,modalShowing:r.modalShowing,accountId:e.id,categoryId:t?.state?.filter?.category,location:t,filtersList:c})})})};},25258:function(e,t,n){n.d(t,{Rp:function(){return l},Wr:function(){return i},eq:function(){return a},i8:function(){return r},iE:function(){return d},mD:function(){return c},uu:function(){return s},yr:function(){return o}});function r(e,t){return e.map(e=>{if(e.id===t.cat_group){e.categories=[t,...e.categories]}return{...e}})}function o(e,t){return e.map(e=>{if(e.id===t.cat_group){e.categories=e.categories.map(e=>{if(e.id===t.id){return{...e,...t}}return e})}return e})}function i(e,t,n,r){if(t===r){return e}let o=e.reduce((e,n)=>{return e||n.categories.find(e=>e.id===t)},null);o={...o,cat_group:n};return e.map(e=>{if(e.id===n){e.categories=e.categories.reduce((e,n)=>{if(n.id===r){e.push(o);e.push(n)}else if(n.id!==t){e.push(n)}return e},[]);if(!r){e.categories.push(o)}}else{e.categories=e.categories.filter(e=>e.id!==t)}return{...e}})}function a(e,t,n){if(t===n){return e}let r=e.find(e=>e.id===t);e=e.reduce((e,o)=>{if(o.id===n){e.push(r);e.push(o)}else if(o.id!==t){e.push(o)}return e},[]);if(!n){e.push(r)}return e}function s(e,t){return e.map(e=>{e.categories=e.categories.filter(e=>e.id!==t);return e})}function l(e,t){return[...e,t]}function c(e,t){return e.map(e=>{if(e.id===t.id){return{...e,...t}}return e})}function d(e,t){return e.filter(e=>e.id!==t)}}}]);
2
+ //# sourceMappingURL=wide-components.fd8595f4.chunk.js.map