@actual-app/web 23.12.0 → 24.1.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 (33) hide show
  1. package/build/asset-manifest.json +13 -15
  2. package/build/data/migrations/1632571489012_remove_cache.js +18 -17
  3. package/build/index.html +1 -1
  4. package/build/kcab/{kcab.worker.676aa69de34599d64b7b.js → kcab.worker.26846256cb1531298b26.js} +61 -56
  5. package/build/kcab/kcab.worker.26846256cb1531298b26.js.map +1 -0
  6. package/build/static/js/231.e37c027b.chunk.js +2 -0
  7. package/build/static/js/231.e37c027b.chunk.js.map +1 -0
  8. package/build/static/js/553.e06509f6.chunk.js +2 -0
  9. package/build/static/js/553.e06509f6.chunk.js.map +1 -0
  10. package/build/static/js/main.eea3298c.js +201 -0
  11. package/build/static/js/main.eea3298c.js.map +1 -0
  12. package/build/static/js/narrow-components.574c7b46.chunk.js +2 -0
  13. package/build/static/js/narrow-components.574c7b46.chunk.js.map +1 -0
  14. package/build/static/js/reports.892e778c.chunk.js +2 -0
  15. package/build/static/js/reports.892e778c.chunk.js.map +1 -0
  16. package/build/static/js/wide-components.8ded5c13.chunk.js +2 -0
  17. package/build/static/js/wide-components.8ded5c13.chunk.js.map +1 -0
  18. package/package.json +1 -2
  19. package/build/kcab/kcab.worker.676aa69de34599d64b7b.js.map +0 -1
  20. package/build/static/js/226.8132a539.chunk.js +0 -2
  21. package/build/static/js/226.8132a539.chunk.js.map +0 -1
  22. package/build/static/js/231.370f17f8.chunk.js +0 -2
  23. package/build/static/js/231.370f17f8.chunk.js.map +0 -1
  24. package/build/static/js/444.301f7ece.chunk.js +0 -15
  25. package/build/static/js/444.301f7ece.chunk.js.map +0 -1
  26. package/build/static/js/main.39d3269d.js +0 -188
  27. package/build/static/js/main.39d3269d.js.map +0 -1
  28. package/build/static/js/narrow-components.b0c96dd8.chunk.js +0 -2
  29. package/build/static/js/narrow-components.b0c96dd8.chunk.js.map +0 -1
  30. package/build/static/js/reports.dec86016.chunk.js +0 -2
  31. package/build/static/js/reports.dec86016.chunk.js.map +0 -1
  32. package/build/static/js/wide-components.eb0a5f91.chunk.js +0 -2
  33. package/build/static/js/wide-components.eb0a5f91.chunk.js.map +0 -1
@@ -1,2 +0,0 @@
1
- "use strict";(self["webpackChunk_actual_app_web"]=self["webpackChunk_actual_app_web"]||[]).push([[162],{18535:function(e,t,n){n.d(t,{Z:function(){return u}});var o=n(43188);var r=n(66204);var a=n(58068);var i=n(75433);var s=n(24307);var l=n(52582);var c=n(57651);var d=n(31038);function u({carryover:e,balance:t,goal:n,budgeted:r,disabled:u,style:h,balanceStyle:p,carryoverStyle:g}){let f=(0,c.Z)(e);let x=(0,c.Z)(t);let m=(0,c.Z)(n);let y=(0,c.Z)(r);let v=(0,a.Z)("goalTemplatesEnabled");return(0,o.jsxs)(s.Z,{style:h,children:[(0,o.jsx)(l.Z,{binding:t,type:"financial",getStyle:e=>(0,d.TV)(e,v?m:null,y),style:{textAlign:"right",...!u&&{cursor:"pointer",":hover":{textDecoration:"underline"}},...p}}),f&&(0,o.jsx)(s.Z,{style:{alignSelf:"center",marginLeft:2,position:"absolute",right:-8,top:0,bottom:0,justifyContent:"center",...g},children:(0,o.jsx)(i.Z,{width:7,height:7,style:(0,d.TV)(x,m,y)})})]})}},38543:function(e,t,n){n.d(t,{Z:function(){return c}});var o=n(43188);var r=n(66204);var a=n(46055);var i=n(31941);var s=n(57651);var l=n(63541);function c({categoryId:e,tooltip:t,monthIndex:n,onBudgetAction:r,onClose:c,...d}){let u=(0,s.Z)(a.u8.catCarryover(e));let h=()=>{t.close();c?.()};return(0,o.jsx)(l.u,{position:"bottom-right",width:200,style:{padding:0},onClose:h,...d,children:(0,o.jsx)(i.Z,{onMenuSelect:t=>{r(n,"carryover",{category:e,flag:!u});h()},items:[{name:"carryover",text:u?"Remove overspending rollover":"Rollover overspending"}]})})}},94477:function(e,t,n){n.d(t,{Z:function(){return m}});var o=n(43188);var r=n(66204);var a=n(46055);var i=n(31941);var s=n(57651);var l=n(63541);var c=n(9579);var d=n(44048);var u=n(56816);var h=n(91871);var p=n(24307);var g=n(31038);function f({tooltipProps:e,onSubmit:t,onClose:n}){let{grouped:a}=(0,c.Z)();a=(0,g.iX)(a.filter(e=>!e.is_income));let[i,s]=(0,r.useState)(null);function f(){if(i){t(i);n()}}return(0,o.jsxs)(l.u,{position:"bottom-right",width:200,style:{padding:10},...e,onClose:n,children:[(0,o.jsx)(p.Z,{style:{marginBottom:5},children:"Cover from category:"}),(0,o.jsx)(h.Z,{children:e=>(0,o.jsx)(d.ZP,{categoryGroups:a,value:null,openOnFocus:true,onUpdate:e=>{},onSelect:e=>s(e),inputProps:{inputRef:e,onKeyDown:e=>{if(e.key==="Enter"){f()}}}})}),(0,o.jsx)(p.Z,{style:{alignItems:"flex-end",marginTop:10},children:(0,o.jsx)(u.Z,{type:"primary",style:{fontSize:12,paddingTop:3},onClick:f,children:"Transfer"})})]})}var x=n(45990);function m({categoryId:e,tooltip:t,monthIndex:n,onBudgetAction:c,onClose:d,...u}){let h=(0,s.Z)(a.aK.catCarryover(e));let p=(0,s.Z)(a.aK.catBalance(e));let[g,m]=(0,r.useState)("menu");let y=()=>{t.close();d?.()};return(0,o.jsxs)(o.Fragment,{children:[g==="menu"&&(0,o.jsx)(l.u,{position:"bottom-right",width:200,style:{padding:0},onClose:y,...u,children:(0,o.jsx)(i.Z,{onMenuSelect:t=>{if(t==="carryover"){c(n,"carryover",{category:e,flag:!h});y()}else{m(t)}},items:[{name:"transfer",text:"Transfer to another category"},{name:"carryover",text:h?"Remove overspending rollover":"Rollover overspending"},p<0&&{name:"cover",text:"Cover overspending"}].filter(e=>e)})}),g==="transfer"&&(0,o.jsx)(x.Z,{initialAmountName:a.aK.catBalance(e),showToBeBudgeted:true,onClose:y,onSubmit:(t,o)=>{c(n,"transfer-category",{amount:t,from:e,to:o})}}),g==="cover"&&(0,o.jsx)(f,{onClose:y,onSubmit:t=>{c(n,"cover",{to:e,from:t})}})]})}},7831:function(e,t,n){n.r(t);n.d(t,{Account:function(){return nE},Accounts:function(){return nE},Budget:function(){return tn},GoCardlessLink:function(){return td},Schedules:function(){return ts}});var o={};n.r(o);n.d(o,{BudgetSummary:function(){return e_},BudgetTotalsMonth:function(){return eG},CategoryMonth:function(){return ez},ExpenseCategoryMonth:function(){return e$},ExpenseGroupMonth:function(){return eK},GroupMonth:function(){return eU},IncomeCategoryMonth:function(){return eq},IncomeGroupMonth:function(){return eQ},IncomeHeaderMonth:function(){return eO}});var r={};n.r(r);n.d(r,{BudgetSummary:function(){return e5},BudgetTotalsMonth:function(){return e3},ExpenseCategoryMonth:function(){return e6},ExpenseGroupMonth:function(){return e8},IncomeCategoryMonth:function(){return e7},IncomeGroupMonth:function(){return e9},IncomeHeaderMonth:function(){return e4}});var a=n(43188);var i=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(24868);var m=n(45492);var y=n(24307);var v=n(39717);var b=n(38638);var w=n(75025);var S=n(37418);const j=({startMonth:e,numDisplayed:t,monthBounds:n,style:o,onSelect:r})=>{const[s,l]=(0,i.useState)(null);const[c,d]=(0,i.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 x=Math.floor(f.length/2)-Math.floor(t/2);const v=x+t-1;const[b,w]=(0,i.useState)("small");const j=(0,S.Z)(e=>{w(e.width<=400?"small":"big");d(Math.min(Math.max(Math.floor(e.width/50),12),24))});let C=[];return(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",...o},children:(0,a.jsx)(y.Z,{innerRef:j,style:{flexDirection:"row",flex:1,alignItems:"center",justifyContent:"center"},children:f.map((e,o)=>{const i=h.WU(e,"MMM");const c=o>=x&&o<=v;const d=s+t-1;const p=s===null?false:o>=s&&o<=d;const g=u===e;const f=h.So(e);let w=false;if(!C.includes(f)){C.push(f);w=true}const S=e>=n.start&&e<=n.end;return(0,a.jsxs)(y.Z,{style:{padding:"3px 3px",width:b==="big"?"35px":"20px",textAlign:"center",userSelect:"none",cursor:"default",borderRadius:2,border:"none",...!S&&{textDecoration:"line-through",color:m.rS.pageTextSubdued},...m.W2.smallText,...c&&{backgroundColor:m.rS.tableBorderHover,color:m.rS.buttonPrimaryText},...(p||c)&&{borderRadius:0,cursor:"pointer"},...p&&!c&&{backgroundColor:"rgba(100, 100, 100, .15)"},...p&&c&&{backgroundColor:m.rS.tableBorderHover},...(o===x||o===s&&!c)&&{borderTopLeftRadius:2,borderBottomLeftRadius:2},...(o===v||o===d&&!c)&&{borderTopRightRadius:2,borderBottomRightRadius:2},...g&&{fontWeight:"bold"}},onClick:()=>r(e),onMouseEnter:()=>l(o),onMouseLeave:()=>l(null),children:[b==="small"?i[0]:i,w&&(0,a.jsx)(y.Z,{style:{position:"absolute",top:-14,left:0,fontSize:10,fontWeight:"bold",color:S?m.rS.pageText:m.rS.pageTextSubdued},children:f})]},e)})})})};var C=n(31038);const Z=(0,i.memo)(({startMonth:e,onMonthSelect:t,numMonths:n,monthBounds:o})=>{function r(e){let t=o.start;let r=h.W9(o.end,n-1);if(e<t){return t}else if(e>r){return r}return e}return(0,a.jsx)(y.Z,{style:{marginLeft:200+5,flexShrink:0},children:(0,a.jsx)(y.Z,{style:{marginRight:5+(0,C.np)()},children:(0,a.jsx)(j,{startMonth:e,numDisplayed:n,monthBounds:o,style:{paddingTop:5},onSelect:e=>t(r(e))})})})});var k=Z;var T=n(63541);var A=n(35562);var R=n(59128);var B=n(57201);var I=n(24630);function M({component:e,editingIndex:t,args:n,style:o}){let{months:r}=(0,i.useContext)(I.Tv);return r.map((r,i)=>{let s=t===i;return(0,a.jsx)(B.Z.Provider,{value:h.cv(r),children:(0,a.jsx)(y.Z,{style:{flex:1,borderLeft:"1px solid "+m.rS.tableBorder,...o},children:(0,a.jsx)(e,{monthIndex:i,editing:s,...n})})},i)})}var E=M;var D=n(85025);var P=n(56816);var W=n(31941);var N=n(7709);var L=n(99818);var F=n(53440);var _=n(10959);var H=n(69304);var G=n(78101);var O=n(76447);function U(){const e=this.data();function t(t,n){const o=e[t]?e[t]:e[t]=[];o.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 z(){return O.F}var K=n(77644);const $=[U,F.Z,z];const Q=(0,L.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 "+m.rS.markdownDark,margin:0},"& hr":{borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:"1px solid "+m.rS.markdownNormal},"& code":{backgroundColor:m.rS.markdownLight,padding:"0.1rem 0.5rem",borderRadius:"0.25rem"},"& pre":{padding:"0.5rem",backgroundColor:m.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 "+m.rS.markdownNormal},"& table":{borderCollapse:"collapse",wordBreak:"break-word"},"& td":{padding:"0.25rem 0.75rem"}});function q({editable:e,defaultNotes:t,position:n="bottom-left",onClose:o}){let[r,s]=(0,i.useState)(t);let l=(0,i.createRef)();(0,i.useEffect)(()=>{if(e){l.current.focus()}},[l,e]);return(0,a.jsx)(T.u,{position:n,onClose:()=>o(r),children:e?(0,a.jsx)("textarea",{ref:l,className:`${(0,L.iv)({border:"1px solid "+m.rS.buttonNormalBorder,padding:7,minWidth:350,minHeight:120,outline:"none",backgroundColor:m.rS.tableBackground,color:m.rS.tableText})}`,value:r||"",onChange:e=>s(e.target.value),placeholder:"Notes (markdown supported)"}):(0,a.jsx)(K.Z,{...Q,children:(0,a.jsx)(N.D,{remarkPlugins:$,linkTarget:"_blank",children:r})})})}function X({id:e,width:t=12,height:n=12,defaultColor:o=m.rS.pageBackgroundModalActive,tooltipPosition:r,style:s}){let[l,c]=(0,i.useState)(false);let u=(0,T.lL)();let h=(0,H.y)(()=>(0,_.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[x,v]=(0,i.useState)(null);const b=()=>{v(setTimeout(()=>{c(true)},300))};const w=()=>{clearTimeout(x);c(false)};const S=u.isOpen||g&&l;return(0,a.jsxs)(y.Z,{style:{flexShrink:0},onMouseEnter:b,onMouseLeave:w,children:[(0,a.jsx)(P.Z,{type:"bare",className:!g&&!S?"hover-visible":"",style:{color:o,...s,...g&&{display:"flex !important"},...S&&{color:m.rS.buttonNormalText}},...u.getOpenEvents(),children:(0,a.jsx)(G.Z,{style:{width:t,height:n}})}),S&&(0,a.jsx)(q,{editable:u.isOpen,defaultNotes:p,position:r,onClose:f})]})};function V({innerRef:e,category:t,dragPreview:n,dragging:o,editing:r,style:s,isLast:l,onEditName:c,onSave:d,onDelete:u,onHideNewCategory:h}){const p=t.id==="new";const[g,f]=(0,i.useState)(false);const x=(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none",opacity:t.hidden?.33:undefined},children:[(0,a.jsx)("div",{"data-testid":"category-name",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:t.name}),(0,a.jsxs)(y.Z,{style:{flexShrink:0,marginLeft:5},children:[(0,a.jsx)(P.Z,{type:"bare",onClick:e=>{e.stopPropagation();f(true)},style:{color:"currentColor",padding:3},children:(0,a.jsx)(D.Z,{width:14,height:14,style:{color:"currentColor"}})}),g&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>f(false),children:(0,a.jsx)(W.Z,{onMenuSelect:e=>{if(e==="rename"){c(t.id)}else if(e==="delete"){u(t.id)}else if(e==="toggle-visibility"){d({...t,hidden:!t.hidden})}f(false)},items:[{name:"toggle-visibility",text:t.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},{name:"delete",text:"Delete"}]})})]}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(X,{id:t.id,style:o&&{color:"currentColor"}})]});return(0,a.jsx)(y.Z,{innerRef:e,style:{width:200,"& button":{display:"none"},...!o&&!n&&{"&:hover button":{display:"flex",color:m.rS.tableTextHover}},...o&&{color:m.rS.formInputTextPlaceholderSelected},...n&&{backgroundColor:m.rS.tableBackground,zIndex:1e4,borderRadius:6,overflow:"hidden"},...s},onKeyDown:e=>{if(e.key==="Enter"){c(null);e.stopPropagation()}},children:(0,a.jsx)(R.F3,{value:t.name,formatter:e=>x,width:"flex",exposed:r||p,onUpdate:e=>{if(p){if(e===""){h()}else if(e!==""){d({...t,name:e})}}else{if(e!==t.name){d({...t,name:e})}}},onBlur:()=>c(null),style:{paddingLeft:13,...l&&{borderBottomWidth:0}},inputProps:{placeholder:p?"New Category Name":""}})})}var Y=V;function J({cat:e,editingCell:t,dragState:n,MonthComponent:o,onEditName:r,onEditMonth:i,onSave:s,onDelete:l,onBudgetAction:c,onShowActivity:d,onDragChange:u,onReorder:h}){let p=n&&n.item===e;if(n&&n.item.id===e.cat_group){p=true}let{dragRef:g}=(0,A.O1)({type:"category",onDragChange:u,item:e,canDrag:t===null});let{dropRef:f,dropPos:x}=(0,A.Zj)({types:"category",id:e.id,onDrop:h});return(0,a.jsxs)(R.X2,{innerRef:f,collapsed:true,style:{backgroundColor:m.rS.tableBackground,opacity:e.hidden?.5:undefined},children:[(0,a.jsx)(A.OJ,{pos:x,offset:{top:1}}),(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},children:[(0,a.jsx)(Y,{innerRef:g,category:e,dragPreview:p&&n.preview,dragging:p&&!n.preview,editing:t&&t.cell==="name"&&t.id===e.id,onEditName:r,onSave:s,onDelete:l}),(0,a.jsx)(E,{component:o,editingIndex:t&&t.id===e.id&&t.cell,args:{category:e,onEdit:i,onBudgetAction:c,onShowActivity:d}})]})]})}var ee=J;var et=n(67459);function en({group:e,editing:t,collapsed:n,dragPreview:o,innerRef:r,style:s,borderColor:l=m.rS.tableBorder,onEdit:c,onSave:d,onDelete:u,onShowNewCategory:h,onHideNewGroup:p,onToggleCollapse:g}){const f=e.id==="new";const[x,v]=(0,i.useState)(false);const b=(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},onClick:t=>{g(e.id)},children:[!o&&(0,a.jsx)(et.Z,{width:8,height:8,style:{marginRight:5,marginLeft:5,flexShrink:0,transition:"transform .1s",transform:n?"rotate(-90deg)":""}}),(0,a.jsxs)("div",{style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:[o&&(0,a.jsx)(K.Z,{style:{fontWeight:500},children:"Group: "}),e.name]}),!o&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(y.Z,{style:{marginLeft:5,flexShrink:0},children:[(0,a.jsx)(P.Z,{type:"bare",onClick:e=>{e.stopPropagation();v(true)},style:{padding:3},children:(0,a.jsx)(D.Z,{width:14,height:14})}),x&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>v(false),children:(0,a.jsx)(W.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==="toggle-visibility"){d({...e,hidden:!e.hidden})}v(false)},items:[{name:"add-category",text:"Add category"},{name:"toggle-visibility",text:e.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},u&&{name:"delete",text:"Delete"}]})})]}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(X,{id:e.id})]})]});return(0,a.jsx)(y.Z,{innerRef:r,style:{...s,width:200,backgroundColor:m.rS.tableRowHeaderBackground,"& button":{display:"none"},"&:hover button":{display:"flex",color:m.rS.tableTextHover},...o&&{paddingLeft:10,zIndex:1e4,borderRadius:6,overflow:"hidden"}},onKeyDown:e=>{if(e.key==="Enter"){c(null);e.stopPropagation()}},children:(0,a.jsx)(R.F3,{value:e.name,formatter:e=>b,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 eo=en;function er({group:e,collapsed:t,editingCell:n,dragState:o,MonthComponent:r,onEditName:i,onSave:s,onDelete:l,onDragChange:c,onReorderGroup:d,onReorderCategory:u,onToggleCollapse:h,onShowNewCategory:p}){let g=o&&o.item===e;let{dragRef:f}=(0,A.O1)({type:"group",onDragChange:c,item:e,canDrag:n===null});let{dropRef:x,dropPos:v}=(0,A.Zj)({types:"group",id:e.id,onDrop:d});let{dropRef:b,dropPos:w}=(0,A.Zj)({types:"category",id:e.id,onDrop:u,onLongHover:()=>{if(t){h(e.id)}}});return(0,a.jsxs)(R.X2,{collapsed:true,style:{fontWeight:600,opacity:e.hidden?.33:undefined,backgroundColor:m.rS.tableRowHeaderBackground},children:[o&&!o.preview&&o.type==="group"&&(0,a.jsx)(y.Z,{innerRef:x,style:{position:"absolute",left:0,right:0,height:t?R.dN-1:(1+e.categories.length)*(R.dN-1)+1,zIndex:1e4},children:(0,a.jsx)(A.OJ,{pos:v,offset:{top:1}})}),(0,a.jsx)(A.OJ,{pos:w,offset:{top:1}}),(0,a.jsxs)(y.Z,{innerRef:b,style:{flex:1,flexDirection:"row",opacity:g&&!o.preview?.3:1},children:[(0,a.jsx)(eo,{innerRef:f,group:e,editing:n&&n.cell==="name"&&n.id===e.id,dragPreview:g&&o.preview,collapsed:t,onToggleCollapse:h,onEdit:i,onSave:s,onDelete:l,onShowNewCategory:p}),(0,a.jsx)(E,{component:r,args:{group:e}})]})]})}var ea=er;function ei({cat:e,isLast:t,editingCell:n,MonthComponent:o,onEditName:r,onEditMonth:i,onSave:s,onDelete:l,onDragChange:c,onBudgetAction:d,onReorder:u,onShowActivity:h}){let{dragRef:p}=(0,A.O1)({type:"income-category",onDragChange:c,item:e,canDrag:n===null});let{dropRef:g,dropPos:f}=(0,A.Zj)({types:"income-category",id:e.id,onDrop:u});return(0,a.jsxs)(R.X2,{innerRef:g,collapsed:true,children:[(0,a.jsx)(A.OJ,{pos:f,offset:{top:1}}),(0,a.jsx)(Y,{innerRef:p,category:e,isLast:t,editing:n&&n.cell==="name"&&n.id===e.id,onEditName:r,onSave:s,onDelete:l}),(0,a.jsx)(E,{component:o,editingIndex:n&&n.id===e.id&&n.cell,args:{category:e,onEdit:i,isLast:t,onShowActivity:h,onBudgetAction:d}})]})}var es=ei;function el({group:e,editingCell:t,collapsed:n,MonthComponent:o,onEditName:r,onSave:i,onToggleCollapse:s,onShowNewCategory:l}){return(0,a.jsxs)(R.X2,{collapsed:true,style:{fontWeight:600,backgroundColor:m.rS.tableRowHeaderBackground},children:[(0,a.jsx)(eo,{group:e,collapsed:n,editing:t&&t.cell==="name"&&t.id===e.id,onEdit:r,onSave:i,onToggleCollapse:s,onShowNewCategory:l}),(0,a.jsx)(E,{component:o,args:{group:e}})]})}var ec=el;function ed({MonthComponent:e,onShowNewGroup:t}){return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",flex:1},children:[(0,a.jsx)(y.Z,{style:{width:200,alignItems:"flex-start",justifyContent:"flex-start"},children:(0,a.jsx)(P.Z,{onClick:t,style:{fontSize:12,margin:10},children:"Add Group"})}),(0,a.jsx)(E,{component:e,style:{border:0,justifyContent:"flex-end"}})]})}var eu=ed;const eh=(0,i.memo)(({categoryGroups:e,newCategoryForGroup:t,showHiddenCategories:n,isAddingGroup:o,editingCell:r,collapsed:s,setCollapsed:l,dataComponents:c,onBudgetAction:d,onShowActivity:u,onEditName:h,onEditMonth:p,onSaveCategory:g,onSaveGroup:f,onDeleteCategory:x,onDeleteGroup:v,onReorderCategory:b,onReorderGroup:w,onShowNewCategory:S,onHideNewCategory:j,onShowNewGroup:Z,onHideNewGroup:k})=>{let T=(0,i.useMemo)(()=>{let[r,a]=(0,C.Rk)(e);let i=Array.prototype.concat.apply([],r.map(e=>{if(e.hidden&&!n){return[]}const o=e.categories.filter(e=>n||!e.hidden);let r=[{type:"expense-group",value:{...e}}];if(t===e.id){r.push({type:"new-category"})}return[...r,...(s.includes(e.id)?[]:o).map(e=>({type:"expense-category",value:e}))]}));if(o){i.push({type:"new-group"})}if(a){i=i.concat([{type:"income-separator"},{type:"income-group",value:a},t===a.id&&{type:"new-category"},...(s.includes(a.id)?[]:a.categories.filter(e=>n||!e.hidden)).map(e=>({type:"income-category",value:e}))].filter(e=>e))}return i},[e,s,t,o,n]);let[B,I]=(0,i.useState)(null);let[M,E]=(0,i.useState)(null);function D(e){let{state:t}=e;if(t==="start-preview"){I({type:e.type,item:e.item,preview:true})}else if(t==="start"){if(B){I({...B,preview:false});E(s)}}else if(t==="hover"){I({...B,hoveredId:e.id,hoveredPos:e.pos})}else if(t==="end"){I(null);l(M||[])}}function P(e){if(s.includes(e)){l(s.filter(t=>t!==e))}else{l([...s,e])}}return(0,a.jsx)(y.Z,{style:{marginBottom:10,backgroundColor:m.rS.tableBackground,overflow:"hidden",boxShadow:m.W2.cardShadow,borderRadius:"0 0 4px 4px",flex:1},children:T.map((n,o)=>{let i;switch(n.type){case"new-group":i=(0,a.jsx)(R.X2,{style:{backgroundColor:m.rS.tableRowHeaderBackground},children:(0,a.jsx)(eo,{group:{id:"new",name:""},editing:true,onSave:f,onHideNewGroup:k,onEdit:h})});break;case"new-category":i=(0,a.jsx)(R.X2,{children:(0,a.jsx)(Y,{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":i=(0,a.jsx)(ea,{group:n.value,editingCell:r,collapsed:s.includes(n.value.id),MonthComponent:c.ExpenseGroupComponent,dragState:B,onEditName:h,onSave:f,onDelete:v,onDragChange:D,onReorderGroup:w,onReorderCategory:b,onToggleCollapse:P,onShowNewCategory:S});break;case"expense-category":i=(0,a.jsx)(ee,{cat:n.value,editingCell:r,MonthComponent:c.ExpenseCategoryComponent,dragState:B,onEditName:h,onEditMonth:p,onSave:g,onDelete:x,onDragChange:D,onReorder:b,onBudgetAction:d,onShowActivity:u});break;case"income-separator":i=(0,a.jsx)(y.Z,{style:{height:m.W2.incomeHeaderHeight,backgroundColor:m.rS.tableBackground},children:(0,a.jsx)(eu,{MonthComponent:c.IncomeHeaderComponent,onShowNewGroup:Z})});break;case"income-group":i=(0,a.jsx)(ec,{group:n.value,editingCell:r,MonthComponent:c.IncomeGroupComponent,collapsed:s.includes(n.value.id),onEditName:h,onSave:f,onToggleCollapse:P,onShowNewCategory:S});break;case"income-category":i=(0,a.jsx)(es,{cat:n.value,editingCell:r,isLast:o===T.length-1,MonthComponent:c.IncomeCategoryComponent,onEditName:h,onEditMonth:p,onSave:g,onDelete:x,onDragChange:D,onReorder:b,onBudgetAction:d,onShowActivity:u});break;default:throw new Error("Unknown item type: "+n.type)}let l=o===0?"first":o===T.length-1?"last":null;return(0,a.jsx)(A.aB.Provider,{value:l,children:(0,a.jsx)(y.Z,{style:!B&&{":hover":{backgroundColor:m.rS.tableBackground}},children:i})},n.value?n.value.id:n.type==="income-separator"?"separator":o)})})});var ep=eh;var eg=n(13015);function ef({SummaryComponent:e}){let{months:t}=(0,i.useContext)(I.Tv);let[n,o]=(0,i.useState)(0);let[r,s]=(0,eg.q_)(()=>({x:0,config:{mass:3,tension:600,friction:80}}));let l=(0,S.Z)((0,i.useCallback)(e=>{o(e.width)},[]));let c=(0,i.useRef)(t[0]);let d=[...t];d.unshift((0,h.W9)(t[0],1));d.push((0,h.zI)(t[t.length-1],1));let u=n/t.length;(0,i.useLayoutEffect)(()=>{let e=c.current;let n=e>t[0];let o=u;let r=n?-o*2:0;if(e!==d[0]&&e!==d[2]){r=-o}let a=-o;s.start({from:{x:r},x:a})},[t[0]]);(0,i.useLayoutEffect)(()=>{c.current=t[0]},[t[0]]);(0,i.useLayoutEffect)(()=>{s.start({from:{x:-u},to:{x:-u}})},[u]);return(0,a.jsx)("div",{className:`${(0,L.iv)([{flex:1,overflow:"hidden"},t.length===1&&{marginLeft:-4,marginRight:-4}])}`,ref:l,children:(0,a.jsx)(eg.q.div,{className:"view",style:{flexDirection:"row",width:n,willChange:"transform",transform:r.x.to(e=>`translateX(${e}px)`)},children:d.map(t=>{return(0,a.jsx)(y.Z,{style:{flex:`0 0 ${u}px`,paddingLeft:4,paddingRight:4},children:(0,a.jsx)(e,{month:t})},t)})})})}var ex=n(94276);const em=(0,i.memo)(function e({MonthComponent:e,toggleHiddenCategories:t,expandAllCategories:n,collapseAllCategories:o}){const[r,s]=(0,i.useState)(false);return(0,a.jsxs)(y.Z,{"data-testid":"budget-totals",style:{backgroundColor:m.rS.tableBackground,flexDirection:"row",flexShrink:0,boxShadow:m.W2.cardShadow,marginLeft:5,marginRight:5+(0,C.np)(),borderRadius:"4px 4px 0 0",borderBottom:"1px solid "+m.rS.tableBorder},children:[(0,a.jsxs)(y.Z,{style:{width:200,color:m.rS.pageTextLight,justifyContent:"center",paddingLeft:15,paddingRight:5,display:"flex",flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},children:[(0,a.jsx)(y.Z,{style:{flexGrow:"1"},children:"Category"}),(0,a.jsxs)(P.Z,{type:"bare",onClick:()=>{s(true)},style:{color:"currentColor",padding:3},children:[(0,a.jsx)(ex.Z,{width:15,height:15,style:{color:m.rS.pageTextLight}}),r&&(0,a.jsx)(T.u,{position:"bottom-right",width:200,style:{padding:0},onClose:()=>{s(false)},children:(0,a.jsx)(W.Z,{onMenuSelect:e=>{if(e==="toggle-visibility"){t()}else if(e==="expandAllCategories"){n()}else if(e==="collapseAllCategories"){o()}s(false)},items:[{name:"toggle-visibility",text:"Toggle hidden categories"},{name:"expandAllCategories",text:"Expand all"},{name:"collapseAllCategories",text:"Collapse all"}]})})]})]}),(0,a.jsx)(E,{component:e})]})});var ey=em;class ev extends i.Component{constructor(e){super(e);this.budgetCategoriesRef=(0,i.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:o}=this.props;let r=!!o.find(e=>e.id===n);if(r){let{targetId:r}=(0,C.qc)(o,t,n);let a=o.find(e=>e.id===r);if(a){let{categories:n}=a;this.props.onReorderCategory({id:e,groupId:a.id,targetId:n.length===0||t==="top"?null:n[0].id})}}else{let r;for(let e of o){if(e.categories.find(e=>e.id===n)){r=e;break}}this.props.onReorderCategory({id:e,groupId:r.id,...(0,C.Df)(r.categories,t,n)})}};onReorderGroup=(e,t,n)=>{let{categoryGroups:o}=this.props;this.props.onReorderGroup({id:e,...(0,C.Df)(o,t,n)})};moveVertically=e=>{let{editing:t}=this.state;let{type:n,categoryGroups:o,collapsed:r}=this.props;const a=o.reduce((e,t)=>{if(r.includes(t.id)){return e.concat({id:t.id,isGroup:true})}return e.concat([{id:t.id,isGroup:true},...t.categories])},[]);if(t){const o=a.findIndex(e=>e.id===t.id);let r=o+e;while(r>=0&&r<a.length){const o=a[r];if(o.isGroup){r+=e;continue}else if(n==="report"||!o.is_income){this.onEditMonth(o.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:o,numMonths:r,monthBounds:i,collapsed:s,setCollapsed:l,newCategoryForGroup:c,dataComponents:d,isAddingGroup:u,onSaveCategory:h,onSaveGroup:p,onDeleteCategory:g,onDeleteGroup:f,onShowNewCategory:x,onHideNewCategory:v,onShowNewGroup:b,onHideNewGroup:w}=this.props;let{editing:S,draggingState:j,showHiddenCategories:Z}=this.state;return(0,a.jsxs)(y.Z,{"data-testid":"budget-table",style:{flex:1,...m.W2.lightScrollbar&&{"& ::-webkit-scrollbar":{backgroundColor:"transparent"},"& ::-webkit-scrollbar-thumb:vertical":{backgroundColor:m.rS.tableHeaderBackground}}},children:[(0,a.jsxs)(y.Z,{style:{flexDirection:"row",overflow:"hidden",flexShrink:0,paddingLeft:5,paddingRight:5+(0,C.np)()},children:[(0,a.jsx)(y.Z,{style:{width:200}}),(0,a.jsx)(I.uC,{startMonth:n,numMonths:r,monthBounds:i,type:e,children:(0,a.jsx)(ef,{SummaryComponent:d.SummaryComponent})})]}),(0,a.jsxs)(I.uC,{startMonth:o,numMonths:r,monthBounds:i,type:e,children:[(0,a.jsx)(ey,{MonthComponent:d.BudgetTotalsComponent,toggleHiddenCategories:this.toggleHiddenCategories,expandAllCategories:this.expandAllCategories,collapseAllCategories:this.collapseAllCategories}),(0,a.jsx)(T.Hp.Provider,{value:this.budgetCategoriesRef,children:(0,a.jsx)(y.Z,{style:{overflowY:"scroll",overflowAnchor:"none",flex:1,paddingLeft:5,paddingRight:5},innerRef:this.budgetCategoriesRef,children:(0,a.jsx)(y.Z,{style:{opacity:j?.5:1,flexShrink:0},onKeyDown:this.onKeyDown,innerRef:e=>this.budgetDataNode=e,children:(0,a.jsx)(ep,{showHiddenCategories:Z,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:x,onHideNewCategory:v,onShowNewGroup:b,onHideNewGroup:w,onBudgetAction:this.onBudgetAction,onShowActivity:this.onShowActivity})})})})]})]})}}var eb=ev;function ew(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 eS=(0,i.forwardRef)(({width:e,height:t,categoryGroups:n,prewarmStartMonth:o,startMonth:r,maxMonths:l=3,monthBounds:c,onMonthSelect:d,onPreload:u,...h},g)=>{let f=(0,s.v9)(e=>e.prefs.local);let{setDisplayMax:x}=(0,w.s)();let m=(0,p.o)();let v=ew(e);let b=Math.min(v,l);let S=200+500*b;(0,i.useEffect)(()=>{x(v)},[v]);function j(e){d(e,b)}return(0,a.jsx)(y.Z,{style:{width:e,height:t,alignItems:"center",opacity:e<=0||t<=0?0:1},children:(0,a.jsxs)(y.Z,{style:{width:"100%",maxWidth:S},children:[(0,a.jsx)(k,{startMonth:o,numMonths:b,monthBounds:c,onMonthSelect:j}),(0,a.jsx)(eb,{ref:g,categoryGroups:n,prewarmStartMonth:o,startMonth:r,numMonths:b,monthBounds:c,prefs:f,...m,...h})]})})});var ej=(0,i.forwardRef)((e,t)=>{return(0,a.jsx)(b.Z,{children:({width:n,height:o})=>(0,a.jsx)(eS,{ref:t,width:n,height:o,...e})})});var eC=n(46055);var eZ=n(11535);var ek=n(89362);var eT=n(52582);var eA=n(5291);var eR=n(18535);var eB=n(38543);var eI=n(35928);var eM=n(17503);var eE=n(84196);let eD=(0,i.createContext)(null);function eP({summaryCollapsed:e,onBudgetAction:t,onToggleSummaryCollapse:n,children:o}){let r=h.dK();return(0,a.jsx)(eD.Provider,{value:{currentMonth:r,summaryCollapsed:e,onBudgetAction:t,onToggleSummaryCollapse:n},children:o})}function eW(){return(0,i.useContext)(eD)}var eN=n(78125);var eL=n(28376);var eF=n(59343);function e_({month:e}){let{currentMonth:t,summaryCollapsed:n,onBudgetAction:o,onToggleSummaryCollapse:r}=eW();const s=(0,f.Z)("goalTemplatesEnabled");let[l,c]=(0,i.useState)(false);function d(){c(true)}function u(){c(false)}let p=n?eI.Z:eM.Z;return(0,a.jsx)(y.Z,{style:{backgroundColor:m.rS.tableBackground,boxShadow:m.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,a.jsxs)(B.Z.Provider,{value:h.cv(e),children:[(0,a.jsxs)(y.Z,{style:{padding:"0 13px",...n?{margin:"10px 0"}:{marginTop:16}},children:[(0,a.jsx)(y.Z,{style:{position:"absolute",left:10,top:0},children:(0,a.jsx)(P.Z,{type:"bare",className:"hover-visible",onClick:r,children:(0,a.jsx)(p,{width:13,height:13,style:{color:m.rS.pageTextSubdued,margin:1}})})}),(0,a.jsx)("div",{className:`${(0,L.iv)([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"}])}`,children:h.WU(e,"MMMM")}),(0,a.jsxs)(y.Z,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[(0,a.jsx)(y.Z,{children:(0,a.jsx)(X,{id:`budget-${e}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:m.rS.pageTextSubdued})}),(0,a.jsxs)(y.Z,{style:{userSelect:"none"},children:[(0,a.jsx)(P.Z,{type:"bare",onClick:d,children:(0,a.jsx)(ex.Z,{width:15,height:15,style:{color:m.rS.pageTextLight}})}),l&&(0,a.jsx)(T.u,{position:"bottom-right",width:200,style:{padding:0},onClose:u,children:(0,a.jsx)(W.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"},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,a.jsxs)(eE.Z,{spacing:2,style:{alignSelf:"center",backgroundColor:m.rS.tableRowHeaderBackground,borderRadius:4,padding:"10px 15px",marginTop:13},children:[(0,a.jsx)(eL.Z,{}),(0,a.jsx)(eN.Z,{})]}),n?(0,a.jsx)(y.Z,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:m.rS.tableRowHeaderBackground,borderTop:"1px solid "+m.rS.tableBorder},children:(0,a.jsx)(eF.Z,{projected:e>=t})}):(0,a.jsx)(eF.Z,{projected:e>=t,style:{marginTop:13,marginBottom:20}})]})})};let eH={flex:1,padding:"0 5px",textAlign:"right"};const eG=(0,i.memo)(function e(){const e=(0,eA.Z)();return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row",marginRight:m.W2.monthRightPadding,paddingTop:10,paddingBottom:10},children:[(0,a.jsxs)(y.Z,{style:eH,children:[(0,a.jsx)(K.Z,{style:{color:m.rS.pageTextLight},children:"Budgeted"}),(0,a.jsx)(eT.Z,{binding:eC.u8.totalBudgetedExpense,type:"financial",style:{color:m.rS.pageTextLight,fontWeight:600},formatter:t=>{return e(parseFloat(t||"0"),"financial")}})]}),(0,a.jsxs)(y.Z,{style:eH,children:[(0,a.jsx)(K.Z,{style:{color:m.rS.pageTextLight},children:"Spent"}),(0,a.jsx)(eT.Z,{binding:eC.u8.totalSpent,type:"financial",style:{color:m.rS.pageTextLight,fontWeight:600}})]}),(0,a.jsxs)(y.Z,{style:eH,children:[(0,a.jsx)(K.Z,{style:{color:m.rS.pageTextLight},children:"Balance"}),(0,a.jsx)(eT.Z,{binding:eC.u8.totalLeftover,type:"financial",style:{color:m.rS.pageTextLight,fontWeight:600}})]})]})});function eO(){return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",marginRight:m.W2.monthRightPadding,paddingBottom:5},children:[(0,a.jsx)(y.Z,{style:eH,children:(0,a.jsx)(K.Z,{style:{color:m.rS.pageTextLight},children:"Budgeted"})}),(0,a.jsx)(y.Z,{style:eH,children:(0,a.jsx)(K.Z,{style:{color:m.rS.pageTextLight},children:"Received"})})]})}const eU=(0,i.memo)(function e({group:e}){let{id:t}=e;return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},children:[(0,a.jsx)(R.OX,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eC.u8.groupBudgeted(t),type:"financial"}}),(0,a.jsx)(R.OX,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eC.u8.groupSumAmount(t),type:"financial"}}),!e.is_income&&(0,a.jsx)(R.OX,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:m.W2.monthRightPadding,...m.W2.tnum},valueProps:{binding:eC.u8.groupBalance(t),type:"financial",privacyFilter:{style:{paddingRight:m.W2.monthRightPadding}}}})]})});const ez=(0,i.memo)(function e({monthIndex:e,category:t,editing:n,onEdit:o,onBudgetAction:r,onShowActivity:s}){let l=(0,T.lL)();const[c,d]=(0,i.useState)(false);const[u,h]=(0,i.useState)(false);const p=(0,f.Z)("goalTemplatesEnabled");return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>h(true),onMouseLeave:()=>{h(false)},children:[!n&&(u||c)&&(0,a.jsxs)(y.Z,{style:{flexShrink:0,marginRight:0,marginLeft:3,justifyContent:"center"},children:[(0,a.jsx)(P.Z,{type:"bare",onClick:e=>{e.stopPropagation();d(true)},style:{padding:3},children:(0,a.jsx)(D.Z,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(false),children:(0,a.jsx)(W.Z,{onMenuSelect:n=>{r(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,a.jsx)(R.OX,{name:"budget",exposed:n,focused:n,width:"flex",onExpose:()=>o(t.id,e),style:{...n&&{zIndex:100},...m.W2.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+m.rS.mobileAccountShadow,backgroundColor:m.rS.tableBackground}},valueProps:{binding:eC.u8.catBudgeted(t.id),type:"financial",getValueStyle:C.hd,formatExpr:e=>{return(0,ek.zA)(e)},unformatExpr:e=>{return(0,ek.l9)((0,eZ.Z)(e,0))}},inputProps:{onBlur:()=>{o(null)},style:{backgroundColor:m.rS.tableBackground}},onSave:n=>{r(e,"budget-amount",{category:t.id,amount:n})}})]}),(0,a.jsx)(R.gN,{name:"spent",width:"flex",style:{textAlign:"right"},children:(0,a.jsx)("span",{"data-testid":"category-month-spent",onClick:()=>s(t.name,t.id,e),children:(0,a.jsx)(eT.Z,{binding:eC.u8.catSumAmount(t.id),type:"financial",getStyle:C.hd,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),!t.is_income&&(0,a.jsxs)(R.gN,{name:"balance",truncate:false,width:"flex",style:{paddingRight:m.W2.monthRightPadding,textAlign:"right"},children:[(0,a.jsx)("span",{...t.is_income?{}:l.getOpenEvents(),children:(0,a.jsx)(eR.Z,{disabled:t.is_income,carryover:eC.u8.catCarryover(t.id),balance:eC.u8.catBalance(t.id),goal:eC.u8.catGoal(t.id),budgeted:eC.u8.catBudgeted(t.id)})}),l.isOpen&&(0,a.jsx)(eB.Z,{categoryId:t.id,tooltip:l,monthIndex:e,onBudgetAction:r})]})]})});const eK=eU;const e$=ez;const eQ=eU;const eq=ez;var eX=n(94477);let eV=(0,i.createContext)(null);function eY({categoryGroups:e,summaryCollapsed:t,onBudgetAction:n,onToggleSummaryCollapse:o,children:r}){let i=h.dK();return(0,a.jsx)(eV.Provider,{value:{currentMonth:i,categoryGroups:e,summaryCollapsed:t,onBudgetAction:n,onToggleSummaryCollapse:o},children:r})}function eJ(){return(0,i.useContext)(eV)}var e0=n(36467);var e1=n(28536);function e5({month:e,isGoalTemplatesEnabled:t}){let{currentMonth:n,summaryCollapsed:o,onBudgetAction:r,onToggleSummaryCollapse:s}=eJ();let[l,c]=(0,i.useState)(false);function d(e){c(true)}function u(){c(false)}let p=h.WU(h.dy(e),"MMM");let g=o?eI.Z:eM.Z;return(0,a.jsx)(y.Z,{"data-testid":"budget-summary",style:{backgroundColor:m.rS.tableBackground,boxShadow:m.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,a.jsxs)(B.Z.Provider,{value:h.cv(e),children:[(0,a.jsxs)(y.Z,{style:{padding:"0 13px",...o?{margin:"10px 0"}:{marginTop:16}},children:[(0,a.jsx)(y.Z,{style:{position:"absolute",left:10,top:0},children:(0,a.jsx)(P.Z,{type:"bare",className:"hover-visible",onClick:s,children:(0,a.jsx)(g,{width:13,height:13,style:{color:m.rS.tableTextLight,margin:1}})})}),(0,a.jsx)("div",{className:`${(0,L.iv)([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"},n===e&&{fontWeight:"bold"}])}`,children:h.WU(e,"MMMM")}),(0,a.jsxs)(y.Z,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[(0,a.jsx)(y.Z,{children:(0,a.jsx)(X,{id:`budget-${e}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:m.rS.tableTextLight})}),(0,a.jsxs)(y.Z,{style:{userSelect:"none",marginLeft:2},children:[(0,a.jsx)(P.Z,{type:"bare",onClick:d,children:(0,a.jsx)(ex.Z,{width:15,height:15,style:{color:m.rS.pageTextLight}})}),l&&(0,a.jsx)(T.u,{position:"bottom-right",width:200,style:{padding:0},onClose:u,children:(0,a.jsx)(W.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"},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"}]})})]})]})]}),o?(0,a.jsx)(y.Z,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:m.rS.tableHeaderBackground,borderTop:"1px solid "+m.rS.tableBorder},children:(0,a.jsx)(e0.Z,{showTotalsTooltipOnHover:true,prevMonthName:p,month:e,onBudgetAction:r})}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(e1.Z,{prevMonthName:p,style:{padding:"5px 0",marginTop:17,backgroundColor:m.rS.tableRowHeaderBackground,borderTopWidth:1,borderBottomWidth:1,borderColor:m.rS.tableBorder}}),(0,a.jsx)(y.Z,{style:{margin:"23px 0"},children:(0,a.jsx)(e0.Z,{month:e,onBudgetAction:r})})]})]})})};let e2={flex:1,padding:"0 5px",textAlign:"right"};const e3=(0,i.memo)(function e(){const e=(0,eA.Z)();return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row",marginRight:m.W2.monthRightPadding,paddingTop:10,paddingBottom:10},children:[(0,a.jsxs)(y.Z,{style:e2,children:[(0,a.jsx)(K.Z,{style:{color:m.rS.tableHeaderText},children:"Budgeted"}),(0,a.jsx)(eT.Z,{binding:eC.aK.totalBudgeted,type:"financial",style:{color:m.rS.tableHeaderText,fontWeight:600},formatter:t=>{return e(-parseFloat(t||"0"),"financial")}})]}),(0,a.jsxs)(y.Z,{style:e2,children:[(0,a.jsx)(K.Z,{style:{color:m.rS.tableHeaderText},children:"Spent"}),(0,a.jsx)(eT.Z,{binding:eC.aK.totalSpent,type:"financial",style:{color:m.rS.tableHeaderText,fontWeight:600}})]}),(0,a.jsxs)(y.Z,{style:e2,children:[(0,a.jsx)(K.Z,{style:{color:m.rS.tableHeaderText},children:"Balance"}),(0,a.jsx)(eT.Z,{binding:eC.aK.totalBalance,type:"financial",style:{color:m.rS.tableHeaderText,fontWeight:600}})]})]})});function e4(){return(0,a.jsx)(R.X2,{style:{color:m.rS.tableHeaderText,alignItems:"center",paddingRight:10},children:(0,a.jsx)(y.Z,{style:{flex:1,textAlign:"right"},children:"Received"})})}const e8=(0,i.memo)(function e({group:e}){let{id:t}=e;return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},children:[(0,a.jsx)(R.OX,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eC.aK.groupBudgeted(t),type:"financial"}}),(0,a.jsx)(R.OX,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...m.W2.tnum},valueProps:{binding:eC.aK.groupSumAmount(t),type:"financial"}}),(0,a.jsx)(R.OX,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:m.W2.monthRightPadding,...m.W2.tnum},valueProps:{binding:eC.aK.groupBalance(t),type:"financial",privacyFilter:{style:{paddingRight:m.W2.monthRightPadding}}}})]})});const e6=(0,i.memo)(function e({monthIndex:e,category:t,editing:n,onEdit:o,onBudgetAction:r,onShowActivity:s}){let l=(0,T.lL)();const[c,d]=(0,i.useState)(false);const[u,h]=(0,i.useState)(false);const p=(0,f.Z)("goalTemplatesEnabled");return(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,a.jsxs)(y.Z,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>h(true),onMouseLeave:()=>{h(false)},children:[!n&&(u||c)?(0,a.jsxs)(y.Z,{style:{flexShrink:1,paddingLeft:3,justifyContent:"center",borderTopWidth:1,borderColor:m.rS.tableBorder},children:[(0,a.jsx)(P.Z,{type:"bare",onClick:e=>{e.stopPropagation();d(true)},style:{padding:3},children:(0,a.jsx)(D.Z,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&(0,a.jsx)(T.u,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(false),children:(0,a.jsx)(W.Z,{onMenuSelect:n=>{r(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,a.jsx)(R.OX,{name:"budget",exposed:n,focused:n,width:"flex",onExpose:()=>o(t.id,e),style:{...n&&{zIndex:100},...m.W2.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+m.rS.mobileAccountShadow,backgroundColor:m.rS.tableBackground}},valueProps:{binding:eC.aK.catBudgeted(t.id),type:"financial",getValueStyle:C.hd,formatExpr:e=>{return(0,ek.zA)(e)},unformatExpr:e=>{return(0,ek.l9)((0,eZ.Z)(e,0))}},inputProps:{onBlur:()=>{o(null)},style:{backgroundColor:m.rS.tableBackground}},onSave:n=>{r(e,"budget-amount",{category:t.id,amount:n})}})]}),(0,a.jsx)(R.gN,{name:"spent",width:"flex",style:{textAlign:"right"},children:(0,a.jsx)("span",{"data-testid":"category-month-spent",onClick:()=>s(t.name,t.id,e),children:(0,a.jsx)(eT.Z,{binding:eC.aK.catSumAmount(t.id),type:"financial",getStyle:C.hd,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),(0,a.jsxs)(R.gN,{name:"balance",truncate:false,width:"flex",style:{paddingRight:m.W2.monthRightPadding,textAlign:"right"},children:[(0,a.jsx)("span",{...l.getOpenEvents(),children:(0,a.jsx)(eR.Z,{carryover:eC.aK.catCarryover(t.id),balance:eC.aK.catBalance(t.id),goal:eC.aK.catGoal(t.id),budgeted:eC.aK.catBudgeted(t.id)})}),l.isOpen&&(0,a.jsx)(eX.Z,{categoryId:t.id,tooltip:l,monthIndex:e,onBudgetAction:r})]})]})});function e9(){return(0,a.jsx)(y.Z,{style:{flex:1},children:(0,a.jsx)(R.OX,{name:"received",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:m.W2.monthRightPadding,...m.W2.tnum},valueProps:{binding:eC.aK.groupIncomeReceived,type:"financial",privacyFilter:{style:{paddingRight:m.W2.monthRightPadding}}}})})}function e7({category:e,isLast:t,monthIndex:n,onShowActivity:o}){return(0,a.jsx)(y.Z,{style:{flex:1},children:(0,a.jsx)(R.gN,{name:"received",width:"flex",style:{paddingRight:m.W2.monthRightPadding,textAlign:"right",...t&&{borderBottomWidth:0}},children:(0,a.jsx)("span",{onClick:()=>o(e.name,e.id,n),children:(0,a.jsx)(eT.Z,{binding:eC.aK.catSumAmount(e.id),type:"financial",style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})})})};function te(e){const t=h.dK();const n=(0,i.useRef)(null);const[o,r]=(0,i.useState)(false);const[s,l]=(0,i.useState)(e.startMonth||t);const[c,p]=(0,i.useState)(null);const[g,f]=(0,i.useState)(false);const[x,m]=(0,i.useState)(e.collapsedPrefs||[]);const[b,w]=(0,i.useState)({start:t,end:t});const[S,j]=(0,i.useState)(null);const[Z,k]=(0,i.useState)(e.summaryCollapsed);async function T(){let t=await e.getCategories();j(t.grouped)}(0,i.useEffect)(()=>{let{titlebar:t,budgetType:o}=e;async function a(){T();let{start:t,end:n}=await (0,d.lW)("get-budget-bounds");w({start:t,end:n});await (0,C.jR)(o,e.spreadsheet,{start:t,end:n},s);r(true)}a();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"))){T()}}),(0,d.oL)("undo-event",({tables:e})=>{if(n.current){n.current.clearEditing()}if(e.includes("categories")){T()}}),t.subscribe(O)];return()=>{i.forEach(e=>e())}},[]);(0,i.useEffect)(()=>{e.savePrefs({"budget.collapsed":x})},[x]);(0,i.useEffect)(()=>{(0,d.lW)("get-budget-bounds").then(({start:e,end:t})=>{if(b.start!==e||b.end!==t){w({start:e,end:t})}})},[e.accountId]);const A=async(n,o)=>{l(n);const r=n;const a=e.startMonth||t;if(n<a){await (0,C.UC)(e.budgetType,e.spreadsheet,h.W9(n,1))}else if(n>a){await (0,C.UC)(e.budgetType,e.spreadsheet,h.zI(n,o))}if(r===n){e.savePrefs({"budget.startMonth":n})}};const R=e=>{p(e);m(t=>t.filter(t=>t!==e))};const B=()=>{p(null)};const I=()=>{f(true)};const M=()=>{f(false)};const E=t=>{e.addNotification({type:"error",message:`Category ‘${t}’ already exists in group (May be Hidden)`})};const D=async t=>{let n=(await e.getCategories()).grouped.filter(e=>e.id===t.cat_group)[0].categories.filter(e=>e.name.toUpperCase()===t.name.toUpperCase()).filter(e=>t.id==="new"?true:e.id!==t.id).length>0;if(n){E(t.name);return}if(t.id==="new"){let n=await e.createCategory(t.name,t.cat_group,t.is_income);p(null);j(e=>(0,u.i8)(e,{...t,is_income:t.is_income?1:0,id:n}))}else{e.updateCategory(t);j(e=>(0,u.yr)(e,t))}};const P=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);j(e=>(0,u.uu)(e,t))}}})}else{e.deleteCategory(t);j(e=>(0,u.uu)(e,t))}};const W=async t=>{if(t.id==="new"){let n=await e.createGroup(t.name);f(false);j(e=>(0,u.Rp)(e,{...t,is_income:0,categories:t.categories||[],id:n}))}else{e.updateGroup(t);j(e=>(0,u.mD)(e,t))}};const N=async t=>{let n=S.find(e=>e.id===t);let o=false;for(let e of n.categories){if(await (0,d.lW)("must-category-transfer",{id:e.id})){o=true;break}}if(o){e.pushModal("confirm-category-delete",{group:t,onDelete:n=>{e.deleteGroup(t,n);j(e=>(0,u.iE)(e,t))}})}else{e.deleteGroup(t);j(e=>(0,u.iE)(e,t))}};const L=(t,n,o)=>{e.applyBudgetAction(t,n,o)};const F=(t,n,o)=>{e.navigate("/accounts",{state:{goBack:true,filterName:`${t} (${h.WU(o,"MMMM yyyy")})`,filter:{category:n,date:{$transform:"$month",$eq:o}}}})};const _=async t=>{let n=await e.getCategories();let o=n.list.filter(e=>e.id===t.id)[0];let r=n.grouped.filter(e=>e.id===t.groupId)[0].categories.filter(e=>e.name.toUpperCase()===o.name.toUpperCase()).filter(e=>e.id!==o.id).length>0;if(r){E(o.name);return}e.moveCategory(t.id,t.groupId,t.targetId);j(e=>(0,u.Wr)(e,t.id,t.groupId,t.targetId))};const H=async t=>{e.moveCategoryGroup(t.id,t.targetId);j(e=>(0,u.eq)(e,t.id,t.targetId))};const G=()=>{let t=!Z;k(t);e.savePrefs({"budget.summaryCollapsed":t})};const O=async({type:t,payload:n})=>{switch(t){case v.Kk:{await (0,C.Gz)(n.newBudgetType,e.spreadsheet,b,s,()=>e.loadPrefs());break}default:}};let{maxMonths:U,budgetType:z,reportComponents:K,rolloverComponents:$}=e;U=U||1;if(!o||!S){return null}const Q=e.startMonth||t;let q;if(z==="report"){q=(0,a.jsx)(eP,{summaryCollapsed:Z,onBudgetAction:L,onToggleSummaryCollapse:G,children:(0,a.jsx)(ej,{ref:n,type:z,categoryGroups:S,prewarmStartMonth:s,startMonth:Q,monthBounds:b,maxMonths:U,collapsed:x,setCollapsed:m,newCategoryForGroup:c,isAddingGroup:g,dataComponents:K,onMonthSelect:A,onShowNewCategory:R,onHideNewCategory:B,onShowNewGroup:I,onHideNewGroup:M,onDeleteCategory:P,onDeleteGroup:N,onSaveCategory:D,onSaveGroup:W,onBudgetAction:L,onShowActivity:F,onReorderCategory:_,onReorderGroup:H})})}else{q=(0,a.jsx)(eY,{categoryGroups:S,summaryCollapsed:Z,onBudgetAction:L,onToggleSummaryCollapse:G,children:(0,a.jsx)(ej,{ref:n,type:z,categoryGroups:S,prewarmStartMonth:s,startMonth:Q,monthBounds:b,maxMonths:U,collapsed:x,setCollapsed:m,newCategoryForGroup:c,isAddingGroup:g,dataComponents:$,onMonthSelect:A,onShowNewCategory:R,onHideNewCategory:B,onShowNewGroup:I,onHideNewGroup:M,onDeleteCategory:P,onDeleteGroup:N,onSaveCategory:D,onSaveGroup:W,onBudgetAction:L,onShowActivity:F,onReorderCategory:_,onReorderGroup:H})})}return(0,a.jsx)(y.Z,{style:{flex:1},children:q})}const tt=(0,i.memo)(e=>{const t=(0,f.Z)("goalTemplatesEnabled");return(0,a.jsx)(e5,{...e,isGoalTemplatesEnabled:t})});function tn(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 b=(0,p.o)();let w=(0,c.M)();let S=(0,i.useContext)(v.CR);let j=(0,l.TH)();let C=(0,l.bS)(j.pathname);let Z=(0,x.Z)();let k=(0,i.useMemo)(()=>({SummaryComponent:e_,ExpenseCategoryComponent:e$,ExpenseGroupComponent:eK,IncomeCategoryComponent:eq,IncomeGroupComponent:eQ,BudgetTotalsComponent:eG,IncomeHeaderComponent:eO}),[o]);let T=(0,i.useMemo)(()=>({SummaryComponent:tt,ExpenseCategoryComponent:e6,ExpenseGroupComponent:e8,IncomeCategoryComponent:e7,IncomeGroupComponent:e9,BudgetTotalsComponent:e3,IncomeHeaderComponent:e4}),[r]);return(0,a.jsx)(y.Z,{style:{...m.W2.page,paddingLeft:8,paddingRight:8,overflow:"hidden"},children:(0,a.jsx)(te,{startMonth:t,collapsedPrefs:n,summaryCollapsed:d,budgetType:u,maxMonths:h,categoryGroups:f,...b,reportComponents:k,rolloverComponents:T,spreadsheet:w,titlebar:S,navigate:Z,match:C})})}var to=n(62829);var tr=n(24198);var ta=n(13308);var ti=n(75497);function ts(){const{pushModal:e}=(0,p.o)();const[t,n]=(0,i.useState)("");const o=(0,to.gZ)();if(o==null){return null}const{schedules:r,statuses:s}=o;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,a.jsxs)(ta.T,{title:"Schedules",children:[(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignItems:"center",padding:"0 0 15px"},children:(0,a.jsx)(y.Z,{style:{flex:1,flexDirection:"row",justifyContent:"flex-end"},children:(0,a.jsx)(tr.Z,{placeholder:"Filter schedules…",value:t,onChange:n})})}),(0,a.jsx)(ti.Pz,{schedules:r,filter:t,statuses:s,allowCompleted:true,onSelect:l,onAction:h,style:{backgroundColor:m.rS.tableBackground}}),(0,a.jsxs)(y.Z,{style:{flexDirection:"row",justifyContent:"space-between",margin:"20px 0",flexShrink:0},children:[(0,a.jsx)(P.Z,{onClick:u,children:"Find schedules"}),(0,a.jsx)(P.Z,{type:"primary",onClick:c,children:"Add new schedule"})]})]})}var tl=n(8987);var tc=n(42994);function td(){window.close();return(0,a.jsx)(tl.C,{isCurrent:true,showClose:false,title:"Account sync",children:()=>(0,a.jsxs)(y.Z,{style:{maxWidth:500},children:[(0,a.jsx)(tc.Z,{children:"Please wait..."}),(0,a.jsx)(tc.Z,{children:"The window should close automatically. If nothing happened you can close this window or tab."})]})})}var tu=n(82478);var th=n(65485);var tp=n(43044);var tg=n(17853);var tf=n(11504);var tx=n(76804);var tm=n(70425);var ty=n(11892);var tv=n(25432);var tb=n(41071);var tw=n(79982);var tS=n(18748);var tj=n(15685);var tC=n(69289);const tZ=e=>(0,a.jsx)("svg",{...e,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 91 51",style:{color:"inherit",...e.style},children:(0,a.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 tk=tZ;var tT=n(45219);var tA=n(2483);var tR=n(67473);var tB=n(78393);var tI=n(48880);var tM=n(25147);var tE=n(49374);var tD=n(44048);var tP=n(5710);var tW=n(60002);var tN=n(37998);function tL(e,t){return e?e[t]:""}function tF(e,t){let{amount:n,date:o}=e;if(t5(e.id)){n=(e._inverse?-1:1)*(0,tf.lP)(n)}let r=n<0?-n:null;let a=n>0?n:null;if(n===0){if(t){a=0}else{r=0}}if(!(0,tv.Z)((0,tb.Z)(o))){o=null}return{...e,date:o,debit:r!=null?(0,ek.zA)(r):"",credit:a!=null?(0,ek.zA)(a):""}}function t_(e,t){let{debit:n,credit:o,date:r,...a}=e;let i;if(n!==""){let e=(0,eZ.Z)(n,null);i=e!=null?-e:null}else{i=(0,eZ.Z)(o,null)}i=i!=null?(0,ek.l9)(i):t.amount;if(r==null){r=t.date||(0,h.PR)()}return{...a,date:r,amount:i}}function tH(e,t){let n=e[t];return n&&n.is_child&&(e[t+1]==null||e[t+1].parent_id!==n.parent_id)}let tG=(0,i.createContext)(null);function tO(){let e=(0,i.useContext)(tG);return(0,i.useMemo)(()=>({...e,expanded:t=>e.state.mode==="collapse"?!e.state.ids.has(t):e.state.ids.has(t)}),[e])}function tU({children:e,initialMode:t="expand"}){let n=(0,s.v9)(e=>e.app.lastSplitState);let o=(0,s.I0)();let[r,l]=(0,i.useReducer)((e,t)=>{switch(t.type){case"toggle-split":{let n=new Set([...e.ids]);let{id:o}=t;if(n.has(o)){n.delete(o)}else{n.add(o)}return{...e,ids:n}}case"open-split":{let n=new Set([...e.ids]);let{id:o}=t;if(e.mode==="collapse"){n.delete(o)}else{n.add(o)}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,i.useEffect)(()=>{if(r.transitionId!=null){setTimeout(()=>{l({type:"finish-switch-mode"})},250)}},[r.transitionId]);(0,i.useEffect)(()=>{if(r.transitionId==null){o({type:"SET_LAST_SPLIT_STATE",splitState:r})}},[r]);let c=(0,i.useMemo)(()=>({state:r,dispatch:l}),[r,l]);return(0,a.jsx)(tG.Provider,{value:c,children:e})}function tz(e,t,n,o="asc"){return e===n?t==="asc"?"desc":"asc":o}const tK=(0,i.memo)(({hasSelected:e,showAccount:t,showCategory:n,showBalance:o,showCleared:r,scrollWidth:i,onSort:s,ascDesc:l,field:c})=>{let d=(0,ty.YP)();return(0,a.jsxs)(R.X2,{style:{fontWeight:300,zIndex:200,color:m.rS.tableHeaderText,backgroundColor:m.rS.tableBackground},children:[(0,a.jsx)(R._7,{exposed:true,focused:false,selected:e,width:20,onSelect:e=>d({type:"select-all",event:e})}),(0,a.jsx)(tq,{value:"Date",width:110,alignItems:"flex",marginLeft:-5,id:"date",icon:c==="date"?l:"clickable",onClick:()=>s("date",tz(c,l,"date","desc"))}),t&&(0,a.jsx)(tq,{value:"Account",width:"flex",alignItems:"flex",marginLeft:-5,id:"account",icon:c==="account"?l:"clickable",onClick:()=>s("account",tz(c,l,"account","asc"))}),(0,a.jsx)(tq,{value:"Payee",width:"flex",alignItems:"flex",marginLeft:-5,id:"payee",icon:c==="payee"?l:"clickable",onClick:()=>s("payee",tz(c,l,"payee","asc"))}),(0,a.jsx)(tq,{value:"Notes",width:"flex",alignItems:"flex",marginLeft:-5,id:"notes",icon:c==="notes"?l:"clickable",onClick:()=>s("notes",tz(c,l,"notes","asc"))}),n&&(0,a.jsx)(tq,{value:"Category",width:"flex",alignItems:"flex",marginLeft:-5,id:"category",icon:c==="category"?l:"clickable",onClick:()=>s("category",tz(c,l,"category","asc"))}),(0,a.jsx)(tq,{value:"Payment",width:90,alignItems:"flex-end",marginRight:-5,id:"payment",icon:c==="payment"?l:"clickable",onClick:()=>s("payment",tz(c,l,"payment","asc"))}),(0,a.jsx)(tq,{value:"Deposit",width:85,alignItems:"flex-end",marginRight:-5,id:"deposit",icon:c==="deposit"?l:"clickable",onClick:()=>s("deposit",tz(c,l,"deposit","desc"))}),o&&(0,a.jsx)(R.bL,{value:"Balance",width:88,textAlign:"right"}),r&&(0,a.jsx)(R.gN,{width:23,truncate:false}),(0,a.jsx)(R.bL,{value:"",width:(5+i)??0})]})});function t$(e,t,n){let{payee:o}=e;if(n){return(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignItems:"center"},children:(0,a.jsx)("div",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:n.name})})}else if(t){return t.name}else if(o&&o.startsWith("new:")){return o.slice("new:".length)}return""}function tQ({id:e,focused:t,selected:n,status:o,isChild:r,onEdit:s,onUpdate:l}){let c=o==="cleared"||o==="reconciled"||o==null;let d=(0,tW.V)(o);let u=o==="cleared"?m.rS.noticeTextLight:o==="reconciled"?m.rS.noticeTextLight:o==="missed"?m.rS.errorText:o==="due"?m.rS.warningText:n?m.rS.pageTextLinkLight:m.rS.pageTextSubdued;function h(){if(c){l("cleared",!(o==="cleared"))}}return(0,a.jsx)(R.bL,{name:"cleared",width:23,focused:t,style:{padding:1},plain:true,children:(0,a.jsx)(R.Sx,{style:{padding:3,backgroundColor:"transparent",border:"1px solid transparent",borderRadius:50,":focus":{border:"1px solid "+m.rS.formInputBorderSelected,boxShadow:"0 1px 2px "+m.rS.formInputBorderSelected},cursor:c?"pointer":"default",...r&&{visibility:"hidden"}},onEdit:()=>s(e,"cleared"),onSelect:h,children:(0,i.createElement)(d.Icon,{style:{width:13,height:13,color:u,marginTop:o==="due"?-1:0}})})})}function tq({value:e,id:t,width:n,alignItems:o,marginLeft:r,marginRight:i,icon:s,onClick:l}){return(0,a.jsx)(R.wh,{width:n,name:t,alignItems:o,unexposedContent:(0,a.jsxs)(P.Z,{type:"bare",onClick:l,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:m.rS.tableHeaderText,fontWeight:300,marginLeft:r,marginRight:i},children:[(0,a.jsx)(R.rt,{value:e}),s==="asc"&&(0,a.jsx)(tA.Z,{width:10,height:10,style:{marginLeft:5}}),s==="desc"&&(0,a.jsx)(tR.Z,{width:10,height:10,style:{marginLeft:5}})]})})}function tX({id:e,payeeId:t,accountId:n,focused:o,inherited:r,payees:s,accounts:l,valueStyle:c,transaction:d,payee:u,transferAcct:h,isPreview:p,onEdit:g,onUpdate:f,onCreatePayee:x,onManagePayees:y,onNavigateToTransferAccount:v,onNavigateToSchedule:b}){let w=(0,i.useRef)(false);l=l.filter(e=>e.id!==n);s=s.filter(e=>e.transfer_acct!==n);return(0,a.jsx)(R.wh,{width:"flex",name:"payee",textAlign:"flex",value:t,valueStyle:{...c,...r&&{color:m.rS.tableTextInactive}},exposed:o,onExpose:t=>!p&&g(e,t),onUpdate:async e=>{f("payee",e);if(e&&e.startsWith("new:")&&!w.current){w.current=true;let t=await x(e.slice("new:".length));f("payee",t);w.current=false}},unexposedContent:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tV,{transaction:d,transferAccount:h,onNavigateToTransferAccount:v,onNavigateToSchedule:b}),(0,a.jsx)(R.rt,{value:t,formatter:()=>t$(d,u,h)})]}),children:({onBlur:e,onKeyDown:n,onUpdate:o,onSave:r,shouldSaveFromKey:i,inputStyle:c})=>{return(0,a.jsx)(tP.ZP,{payees:s,accounts:l,value:t,shouldSaveFromKey:i,inputProps:{onBlur:e,onKeyDown:n,style:c},showManagePayees:true,tableBehavior:true,focused:true,onUpdate:o,onSelect:r,onManagePayees:()=>y(t),isCreatable:true,menuPortalTarget:undefined})}})}function tV({transaction:e,transferAccount:t,onNavigateToTransferAccount:n,onNavigateToSchedule:o,children:r}){let i=e.schedule;let s=(0,to.oF)();let l=s?s.schedules.find(e=>e.id===i):null;if(l==null&&t==null){return r}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,a.jsxs)(a.Fragment,{children:[l&&(0,a.jsx)(P.Z,{type:"bare",style:c,onClick:e=>{e.stopPropagation();o(i)},children:h?(0,a.jsx)(tB.Z,{style:d}):(0,a.jsx)(tI.Z,{style:d})}),t&&(0,a.jsx)(P.Z,{type:"bare",style:c,onClick:o=>{o.stopPropagation();if(!t1(e.id)){n(t.id)}},children:(e._inverse?-1:1)*e.amount>0?(0,a.jsx)(tk,{style:u}):(0,a.jsx)(tT.Z,{style:u})})]})}const tY=(0,i.memo)(function e(e){let{transaction:t,editing:n,showAccount:o,showBalance:r,showCleared:s,showZeroInDeposit:l,style:c,selected:d,highlighted:u,added:h,matched:p,expanded:g,inheritedFields:f,focusedField:x,categoryGroups:v,payees:b,accounts:w,balance:S,dateFormat:j="MM/dd/yyyy",hideFraction:C,onSave:Z,onEdit:k,onDelete:T,onSplit:A,onManagePayees:B,onCreatePayee:I,onToggleSplit:M,onNavigateToTransferAccount:E,onNavigateToSchedule:P}=e;let W=(0,ty.YP)();let[N,L]=(0,i.useState)(l);let[F,_]=(0,i.useState)(t);let[H,G]=(0,i.useState)(()=>tF(t,l));let O=t5(H.id);if(t!==F||l!==N){G(tF(t,l));_(t);L(l)}let[U,z]=(0,i.useState)(false);function $(t,n){if(H[t]!==n){if(H.reconciled===true&&(t==="credit"||t==="debit"||t==="payee"||t==="account")){if(U===false){z(true);e.pushModal("confirm-transaction-edit",{onConfirm:()=>{z(false);Q(t,n)},confirmReason:"editReconciled"})}}else{Q(t,n)}}}function Q(e,n){let o={...H,[e]:n};if(e==="note"&&n===""&&H.note==null){return}if(e==="account"&&n&&(0,tS.gI)(w)[n].offbudget){o.category=null}if(e==="credit"){o["debit"]=""}else if(e==="debit"){o["credit"]=""}if(e==="account"&&H.account!==n){o.reconciled=false}if(e==="payee"&&n&&n.startsWith("new:")){G(o)}else{let e=t_(o,t);G(tF(e,l));Z(e)}}let{id:q,amount:X,debit:V,credit:Y,payee:J,imported_payee:ee,notes:et,date:en,account:eo,category:er,cleared:ea,reconciled:ei,is_parent:es,_unmatched:el=false,_inverse:ec=false}=H;let ed=b&&J&&(0,tS.yG)(b)[J];let eu=w&&eo&&(0,tS.gI)(w)[eo];let eh;if(ec){eh=w&&eo&&(0,tS.gI)(w)[eo]}else{eh=ed&&ed.transfer_acct&&(0,tS.gI)(w)[ed.transfer_acct]}let ep=H.is_child;let eg=eh&&eh.offbudget===0;let ef=eu&&eu.offbudget===1;let ex=h?{fontWeight:600}:null;let em=x==="select";let ey=C?{letterSpacing:-.5}:null;let ev=!t1(q)?S:S+(ec?-1:1)*X;return(0,a.jsxs)(R.X2,{style:{backgroundColor:d?m.rS.tableRowBackgroundHighlight:em?m.rS.tableRowBackgroundHover:m.rS.tableBackground,":hover":!(em||d)&&{backgroundColor:m.rS.tableRowBackgroundHover},"& .hover-visible":{opacity:0},":hover .hover-visible":{opacity:1},...u||d?{color:m.rS.tableRowBackgroundHighlightText}:{color:m.rS.tableText},...c,...O&&{color:m.rS.tableTextInactive,backgroundColor:!d?m.rS.tableBackground:undefined,fontStyle:"italic"},...el&&{opacity:.5}},children:[ep&&(0,a.jsx)(R.gN,{width:110,style:{width:110,backgroundColor:m.rS.tableRowBackgroundHover,border:0}}),ep&&o&&(0,a.jsx)(R.gN,{style:{flex:1,backgroundColor:m.rS.tableRowBackgroundHover,border:0}}),t1(H.id)?ep?(0,a.jsx)(R.nu,{onDelete:()=>T&&T(H.id),exposed:n,style:{...ep&&{borderLeftWidth:1},lineHeight:0}}):(0,a.jsx)(R.bL,{width:20}):(0,a.jsx)(R._7,{exposed:true,buttonProps:{className:d||n?null:"hover-visible"},focused:x==="select",onSelect:e=>{W({type:"select",id:H.id,event:e})},onEdit:()=>k(q,"select"),selected:d,style:{...ep&&{borderLeftWidth:1}},value:p&&(0,a.jsx)(tM.Z,{style:{width:13,height:13,color:"inherit"}})}),!ep&&(0,a.jsx)(R.wh,{name:"date",width:110,textAlign:"flex",exposed:x==="date",value:en,valueStyle:ex,formatter:e=>e?(0,tw.Z)((0,tb.Z)(e),j):"",onExpose:e=>!O&&k(q,e),onUpdate:e=>{$("date",e)},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:o,shouldSaveFromKey:r,inputStyle:i})=>(0,a.jsx)(tN.Z,{value:en||"",dateFormat:j,inputProps:{onBlur:e,onKeyDown:t,style:i},shouldSaveFromKey:r,tableBehavior:true,onUpdate:n,onSelect:o})}),!ep&&o&&(0,a.jsx)(R.wh,{name:"account",width:"flex",textAlign:"flex",value:eo,formatter:e=>{let t=e&&(0,tS.gI)(w)[e];if(t){return t.name}return""},valueStyle:ex,exposed:x==="account",onExpose:e=>!O&&k(q,e),onUpdate:async e=>{if(e){$("account",e)}},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:o,shouldSaveFromKey:r,inputStyle:i})=>(0,a.jsx)(tE.ZP,{includeClosedAccounts:false,value:eo,accounts:w,shouldSaveFromKey:r,tableBehavior:true,focused:true,inputProps:{onBlur:e,onKeyDown:t,style:i},onUpdate:n,onSelect:o,menuPortalTarget:undefined})}),(()=>(0,a.jsx)(tX,{id:q,payeeId:J,accountId:eo,focused:x==="payee",inherited:f&&f.has("payee"),payees:b,accounts:w,valueStyle:ex,transaction:H,payee:ed,transferAcct:eh,importedPayee:ee,isPreview:O,onEdit:k,onUpdate:$,onCreatePayee:I,onManagePayees:B,onNavigateToTransferAccount:E,onNavigateToSchedule:P}))(),O?(0,a.jsx)(R.bL,{name:"notes",width:"flex"}):(0,a.jsx)(R.F3,{width:"flex",name:"notes",textAlign:"flex",exposed:x==="notes",focused:x==="notes",value:et||"",valueStyle:ex,onExpose:e=>!O&&k(q,e),inputProps:{value:et||"",onUpdate:$.bind(null,"notes")}}),O?(0,a.jsx)(R.bL,{width:"flex",style:{alignItems:"flex-start"},exposed:true,children:()=>(0,a.jsx)(y.Z,{style:{color:et==="missed"?m.rS.errorText:et==="due"?m.rS.warningText:d?m.rS.formLabelText:m.rS.tableTextLight,backgroundColor:et==="missed"?m.rS.errorBackground:et==="due"?m.rS.warningBackground:d?m.rS.formLabelBackground:m.rS.pageBackground,margin:"0 5px",padding:"3px 7px",borderRadius:4},children:(0,ek.VL)(et)})}):es?(0,a.jsx)(R.bL,{name:"category",width:"flex",focused:x==="category",style:{padding:0},plain:true,children:(0,a.jsx)(R.Sx,{bare:true,style:{alignSelf:"flex-start",borderRadius:4,border:"1px solid transparent",":hover":{border:"1px solid "+m.rS.buttonNormalBorder}},disabled:t1(H.id),onEdit:()=>k(q,"category"),onSelect:()=>M(q),children:(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",alignSelf:"stretch",borderRadius:4,flex:1,padding:4},children:[es&&(0,a.jsx)(D.Z,{style:{color:"inherit",width:14,height:14,transition:"transform .08s",transform:g?"rotateZ(0)":"rotateZ(-90deg)"}}),(0,a.jsx)(K.Z,{style:{fontStyle:"italic",userSelect:"none"},children:"Split"})]})})}):eg||ef||O?(0,a.jsx)(R.F3,{name:"category",width:"flex",exposed:x==="category",focused:x==="category",onExpose:e=>!O&&k(q,e),value:es?"Split":ef?"Off Budget":eg?"Transfer":"",valueStyle:ex,style:{fontStyle:"italic",color:m.rS.pageTextSubdued,fontWeight:300},inputProps:{readOnly:true,style:{fontStyle:"italic"}}}):(0,a.jsx)(R.wh,{name:"category",width:"flex",textAlign:"flex",value:er,formatter:e=>e?tL((0,tS.ch)(v)[e],"name"):H.id?"Categorize":"",exposed:x==="category",onExpose:e=>k(q,e),valueStyle:!er?{fontStyle:"italic",fontWeight:300,color:m.rS.formInputTextHighlight}:ex,onUpdate:async e=>{if(e==="split"){A(H.id)}else{$("category",e)}},children:({onBlur:e,onKeyDown:t,onUpdate:n,onSave:o,shouldSaveFromKey:r,inputStyle:i})=>(0,a.jsx)(tD.ZP,{categoryGroups:v,value:er,focused:true,tableBehavior:true,showSplitOption:!ep&&!es,shouldSaveFromKey:r,inputProps:{onBlur:e,onKeyDown:t,style:i},onUpdate:n,onSelect:o,menuPortalTarget:undefined})}),(0,a.jsx)(R.F3,{type:"input",width:90,name:"debit",exposed:x==="debit",focused:x==="debit",value:V===""&&Y===""?"0.00":V,valueStyle:ex,textAlign:"right",title:V,onExpose:e=>!O&&k(q,e),style:{...es&&{fontStyle:"italic"},...m.W2.tnum,...ey},inputProps:{value:V===""&&Y===""?"0.00":V,onUpdate:$.bind(null,"debit")},privacyFilter:{activationFilters:[!t1(H.id)]}}),(0,a.jsx)(R.F3,{type:"input",width:85,name:"credit",exposed:x==="credit",focused:x==="credit",value:Y,valueStyle:ex,textAlign:"right",title:Y,onExpose:e=>!O&&k(q,e),style:{...es&&{fontStyle:"italic"},...m.W2.tnum,...ey},inputProps:{value:Y,onUpdate:$.bind(null,"credit")},privacyFilter:{activationFilters:[!t1(H.id)]}}),r&&(0,a.jsx)(R.bL,{name:"balance",value:ev==null||ep?"":(0,ek.zA)(ev),valueStyle:{color:ev<0?m.rS.errorText:m.rS.noticeTextLight},style:{...m.W2.tnum,...ey},width:88,textAlign:"right",privacyFilter:true}),s&&(0,a.jsx)(tQ,{id:q,focused:x==="cleared",selected:d,isPreview:O,status:O?et:ei?"reconciled":ea?"cleared":null,isChild:ep,onEdit:k,onUpdate:$}),(0,a.jsx)(R.bL,{width:5})]})});function tJ({error:e,isDeposit:t,onAddSplit:n,style:o}){switch(e.type){case"SplitTransactionError":if(e.version===1){return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",padding:"0 5px",...o},"data-testid":"transaction-error",children:[(0,a.jsxs)(K.Z,{children:["Amount left:"," ",(0,a.jsx)(K.Z,{style:{fontWeight:500},children:(0,ek.zA)(t?e.difference:-e.difference)})]}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(P.Z,{type:"primary",style:{marginLeft:15,padding:"4px 10px"},onClick:n,children:"Add Split"})]})}break;default:return null}}function t0(e,t,n){return[{id:"temp",date:n||(0,h.PR)(),account:e||null,category:t||null,cleared:false,amount:null}]}function t1(e){return e.indexOf("temp")!==-1}function t5(e){return e.indexOf("preview/")!==-1}function t2({transactions:e,accounts:t,categoryGroups:n,payees:o,editingTransaction:r,focusedField:i,showAccount:s,showCategory:l,showBalance:c,showCleared:d,dateFormat:u,hideFraction:h,onClose:p,onSplit:g,onEdit:f,onDelete:x,onSave:v,onAdd:b,onAddSplit:w,onManagePayees:S,onCreatePayee:j,onNavigateToTransferAccount:C,onNavigateToSchedule:Z,balance:k}){const T=e[0].error;const A=e[0].amount>0;return(0,a.jsxs)(y.Z,{style:{borderBottom:"1px solid "+m.rS.tableBorderHover,paddingBottom:6,backgroundColor:m.rS.tableBackground},"data-testid":"new-transaction",onKeyDown:e=>{if(e.key==="Escape"){p()}},children:[e.map(e=>(0,a.jsx)(tY,{isNew:true,editing:r===e.id,transaction:e,showAccount:s,showCategory:l,showBalance:c,showCleared:d,focusedField:r===e.id&&i,showZeroInDeposit:A,accounts:t,categoryGroups:n,payees:o,dateFormat:u,hideFraction:h,expanded:true,onEdit:f,onSave:v,onSplit:g,onDelete:x,onAdd:b,onManagePayees:S,onCreatePayee:j,style:{marginTop:-1},onNavigateToTransferAccount:C,onNavigateToSchedule:Z,balance:k},e.id)),(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",justifyContent:"flex-end",marginTop:6,marginRight:20},children:[(0,a.jsx)(P.Z,{style:{marginRight:10,padding:"4px 10px"},onClick:()=>p(),"data-testid":"cancel-button",children:"Cancel"}),T?(0,a.jsx)(tJ,{error:T,isDeposit:A,onAddSplit:()=>w(e[0].id)}):(0,a.jsx)(P.Z,{type:"primary",style:{padding:"4px 10px"},onClick:b,"data-testid":"add-button",children:"Add"})]})]})}function t3({tableNavigator:e,tableRef:t,dateFormat:n="MM/dd/yyyy",newNavigator:o,renderEmpty:r,onScroll:s,...l}){const c=(0,i.createRef)();const d=(0,tC.Z)(l.isAdding);let[u,h]=(0,i.useState)(0);function p(e,t){let n=e>0&&t>0&&e-t;h(!n?0:n)}let g=(0,i.useCallback)(e=>{l.onCloseAddTransaction();l.onNavigateToTransferAccount(e)},[l.onCloseAddTransaction,l.onNavigateToTransferAccount]);let f=(0,i.useCallback)(e=>{l.onCloseAddTransaction();l.onNavigateToSchedule(e)},[l.onCloseAddTransaction,l.onNavigateToSchedule]);(0,i.useEffect)(()=>{if(!d&&l.isAdding){o.onEdit("temp","date")}},[d,l.isAdding,o]);const x=({item:t,index:o,position:r,editing:i})=>{const{transactions:s,selectedItems:c,accounts:d,categoryGroups:u,payees:h,showCleared:p,showAccount:x,showCategory:m,showBalances:y,balances:v,hideFraction:b,isNew:w,isMatched:S,isExpanded:j}=l;let C=t;let Z=c.has(C.id);let k=l.transactionMap.get(C.parent_id);let A=k&&k.amount>0;let R=j&&j((k||C).id);let B=R?k&&k.error||C.error:C.error;return(0,a.jsxs)(a.Fragment,{children:[(!R||tH(s,o))&&B&&B.type==="SplitTransactionError"&&(0,a.jsx)(T.u,{position:"bottom-right",width:250,forceTop:r,forceLayout:true,style:{transform:"translate(-5px, 2px)"},children:(0,a.jsx)(tJ,{error:B,isDeposit:A,onAddSplit:()=>l.onAddSplit(C.id)})}),(0,a.jsx)(tY,{editing:i,transaction:C,showAccount:x,showCategory:m,showBalance:y,showCleared:p,selected:Z,highlighted:false,added:w?.(C.id),expanded:j?.(C.id),matched:S?.(C.id),showZeroInDeposit:A,balance:v?.[C.id]?.balance,focusedField:i&&e.focusedField,accounts:d,categoryGroups:u,payees:h,inheritedFields:k?.payee===C.payee?new Set(["payee"]):new Set,dateFormat:n,hideFraction:b,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,pushModal:l.pushModal})]})};return(0,a.jsxs)(y.Z,{innerRef:c,style:{flex:1,cursor:"default",...l.style},children:[(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(tK,{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,a.jsx)(y.Z,{...o.getNavigatorProps({onKeyDown:e=>l.onCheckNewEnter(e)}),children:(0,a.jsx)(t2,{transactions:l.newTransactions,editingTransaction:o.editingId,focusedField:o.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:o.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,a.jsxs)(y.Z,{style:{flex:1,overflow:"hidden"},"data-testid":"transaction-table",children:[(0,a.jsx)(R.iA,{navigator:e,ref:t,items:l.transactions,renderItem:x,renderEmpty:r,loadMore:l.loadMoreTransactions,isSelected:e=>l.selectedItems.has(e),onKeyDown:e=>l.onCheckEnter(e),onScroll:s,saveScrollWidth:p}),l.isAdding&&(0,a.jsx)("div",{style:{position:"absolute",top:-20,left:0,right:0,height:20,backgroundColor:m.rS.errorText,boxShadow:"0 0 6px rgba(0, 0, 0, .20)"}},"shadow")]})]})}let t4=(0,i.forwardRef)((e,t)=>{let[n,o]=(0,i.useState)(null);let[r,s]=(0,i.useState)(false);let l=tO();let c=(0,i.useRef)(null);let d=(0,i.useRef)(null);let u=(0,tj.r)(d,t);let h=(0,i.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,i.useMemo)(()=>{return new Map(h.map(e=>[e.id,e]))},[h]);(0,i.useEffect)(()=>{if(d.current.isAnchored()){d.current.unanchor();d.current.setRowAnimation(true)}},[c.current]);let g=(0,R.wz)(n,j);let f=(0,R.wz)(h,j);let x=(0,i.useRef)(false);let m=(0,i.useRef)({newTransactions:n,newNavigator:g,tableNavigator:f});let y=(0,i.useRef)(false);let v=(0,i.useRef)(false);let[b,w]=(0,i.useState)({});let S=(0,ty.D9)();(0,i.useLayoutEffect)(()=>{m.current={newTransactions:n,newNavigator:g,tableNavigator:f,transactions:e.transactions}});if(r!==e.isAdding){if(!r&&e.isAdding){o(t0(e.currentAccountId,e.currentCategoryId))}s(e.isAdding)}(0,i.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;o(t0(e.currentAccountId,e.currentCategoryId,n));g.onEdit("temp","date");e.onAdd(t)}x.current=false}});(0,i.useEffect)(()=>{if(y.current&&v.current){v.current(e);v.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(t5(t.id)){n=["select","cleared"]}if(t1(t.id)){n=n.slice(1)}return n}function C(t){if(y.current){v.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){M(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 o=m.current.transactions;let r=o.findIndex(e=>e.id===t);let a=p.get(o[r]?.parent_id);if(tH(o,r)&&a&&a.error&&n!=="select"){e.stopPropagation();M(t)}})}}let T=(0,i.useCallback)(()=>{x.current=true;w({})},[e.onAdd,g.onEdit]);let A=(0,i.useCallback)(async t=>{y.current=true;if(t1(t.id)){if(e.onApplyRules){t=await e.onApplyRules(t)}let n=m.current.newTransactions;o((0,tx.Ld)(n,t).data)}else{e.onSave(t)}},[e.onSave]);let B=(0,i.useCallback)(e=>{let t=t1(e);if(t){let t=m.current.newTransactions;if(e===t[0].id){return}o((0,tx.Ks)(t,e).data)}},[]);let I=(0,i.useMemo)(()=>{return t=>{if(t1(t)){let{newNavigator:e}=m.current;let n=m.current.newTransactions;let{data:r,diff:a}=(0,tx.oQ)(n,t);o(r);if(n[0].amount===null){e.onEdit(n[0].id,"debit")}else{e.onEdit(a.added[0].id,m.current.newNavigator.focusedField)}}else{let n=m.current.transactions.find(e=>e.id===t);let o=e.onSplit(t);l.dispatch({type:"open-split",id:n.id});let{tableNavigator:r}=m.current;if(n.amount===null){r.onEdit(n.id,"debit")}else{r.onEdit(o,r.focusedField)}}}},[e.onSplit,l.dispatch]);let M=(0,i.useCallback)(t=>{if(t1(t)){let e=m.current.newTransactions;let{data:n,diff:r}=(0,tx.CX)(e,t);o(n);g.onEdit(r.added[0].id,m.current.newNavigator.focusedField)}else{let n=e.onAddSplit(t);f.onEdit(n,m.current.tableNavigator.focusedField)}},[e.onAddSplit]);function E(){o(t0(e.currentAccountId,e.currentCategoryId));e.onCloseAddTransaction()}let D=(0,i.useCallback)(e=>l.dispatch({type:"toggle-split",id:e}),[l.dispatch]);return(0,a.jsx)(t3,{tableRef:u,...e,transactions:h,transactionMap:p,selectedItems:S,isExpanded:l.expanded,onSave:A,onDelete:B,onSplit:I,onCheckNewEnter:Z,onCheckEnter:k,onAddTemporary:T,onAddSplit:M,onCloseAddTransaction:E,onToggleSplit:D,newTransactions:n,tableNavigator:f,newNavigator:g})});async function t8(e){let t=await (0,d.lW)("transactions-batch-update",{...e,learnCategories:true});if(t.length>0){return{updates:t}}return{}}async function t6(e,t,n){let o=await t8(e);n((0,tx._n)(t.newTransaction,o),(0,ek.zb)(o,t.data))}function t9({tableRef:e,transactions:t,allTransactions:n,loadMoreTransactions:o,account:r,accounts:s,category:c,categoryGroups:u,payees:h,balances:p,showBalances:g,showCleared:f,showAccount:x,headerContent:y,isAdding:v,isNew:b,isMatched:w,isFiltered:S,dateFormat:j,hideFraction:C,addNotification:Z,pushModal:k,renderEmpty:T,onSort:A,sortField:R,ascDesc:B,onChange:I,onRefetch:M,onCloseAddTransaction:E,onCreatePayee:D}){let P=(0,i.useRef)();let W=(0,l.s0)();(0,i.useLayoutEffect)(()=>{P.current=t},[t]);let N=(0,i.useCallback)(async e=>{e=(0,tx.V6)(e);await t8({added:e});M()},[]);let L=(0,i.useCallback)(async e=>{let t=(0,tx.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 t8(t.diff);M()}else{I(t.newTransaction,t.data);t6(t.diff,t,I)}}},[]);let F=(0,i.useCallback)(e=>{const t=(0,tx.CX)(P.current,e);I(t.newTransaction,t.data);t6(t.diff,t,I);return t.diff.added[0].id},[]);let _=(0,i.useCallback)(e=>{const t=(0,tx.oQ)(P.current,e);I(t.newTransaction,t.data);t6(t.diff,t,I);return t.diff.added[0].id},[]);let H=(0,i.useCallback)(async e=>{let t=await (0,d.lW)("rules-run",{transaction:e});let n=(0,ek.k4)(e,t);let o={...e};if(n){Object.keys(n).forEach(e=>{if(o[e]==null||o[e]===""||o[e]===0||o[e]===false){o[e]=n[e]}})}return o},[]);let G=(0,i.useCallback)(e=>{W("/payees",{selectedPayee:e})});let O=(0,i.useCallback)(e=>{W(`/accounts/${e}`)});let U=(0,i.useCallback)(e=>{k("schedule-edit",{id:e})});return(0,a.jsx)(t4,{ref:e,pushModal:k,transactions:n,loadMoreTransactions:o,accounts:s,categoryGroups:u,payees:h,showBalances:g,balances:p,showCleared:f,showAccount:x,showCategory:true,currentAccountId:r&&r.id,currentCategoryId:c&&c.id,isAdding:v,isNew:b,isMatched:w,isFiltered:S,dateFormat:j,hideFraction:C,addNotification:Z,headerContent:y,renderEmpty:T,onSave:L,onApplyRules:H,onSplit:_,onCloseAddTransaction:E,onAdd:N,onAddSplit:F,onManagePayees:G,onCreatePayee:D,style:{backgroundColor:m.rS.tableBackground},onNavigateToTransferAccount:O,onNavigateToSchedule:U,onSort:A,sortField:R,ascDesc:B})}var t7=n(63495);var ne=n(99458);var nt=n(74684);var nn=n(82093);var no=n(35644);var nr=n(93702);var na=n(23880);var ni=n(6083);var ns=n(91871);var nl=n(383);function nc({onClick:e}){return(0,a.jsx)(P.Z,{type:"bare",onClick:e,"aria-label":"Menu",children:(0,a.jsx)(ex.Z,{width:15,height:15,style:{transform:"rotateZ(90deg)"}})})}var nd=n(30076);var nu=n(52355);var nh=n(1482);var np=n(39235);function ng({getTransaction:e,onShow:t,onDuplicate:n,onDelete:o,onEdit:r,onUnlink:s,onCreateRule:l,onScheduleAction:c,pushModal:d}){let u=(0,ty.D9)();let h=(0,i.useMemo)(()=>{let e=[...u];return{preview:!!e.find(e=>t5(e)),trans:!!e.find(e=>!t5(e))}},[u]);let p=(0,i.useMemo)(()=>{let t=[...u].map(t=>e(t));return t.some(e=>e&&e.is_child)},[u]);let g=(0,i.useMemo)(()=>{return!h.preview&&[...u].every(t=>{let n=e(t);return n&&n.schedule})},[h.preview,u,e]);return(0,a.jsx)(R.Vg,{name:"transactions",keyHandlers:h.trans&&{f:()=>t([...u]),d:()=>o([...u]),a:()=>r("account",[...u]),p:()=>r("payee",[...u]),n:()=>r("notes",[...u]),c:()=>r("category",[...u]),l:()=>r("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"}],W.Z.line,{type:W.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:a=>{switch(a){case"show":t([...u]);break;case"duplicate":n([...u]);break;case"delete":o([...u]);break;case"post-transaction":case"skip":c(a,u);break;case"view-schedule":let i=[...u][0];let h;if(t5(i)){let e=i.split("/");h=e[1]}else{let t=e(i);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:r(a,[...u])}}})}var nf=n(97095);var nx=n(44710);var nm=n(57651);function ny({name:e,balance:t,isExactBalance:n=true}){const o=(0,eA.Z)();return(0,a.jsxs)(K.Z,{style:{marginLeft:15,borderRadius:4,padding:"4px 6px",color:m.rS.pillText,backgroundColor:m.rS.pillBackground},children:[e," ",(0,a.jsx)(nx.ZP,{children:(0,a.jsxs)(K.Z,{style:{fontWeight:600},children:[!n&&"~ ",o(t,"financial")]})})]})}function nv({selectedItems:e,account:t}){let n=`selected-balance-${[...e].join("-")}`;let o=(0,nm.Z)({name:n,query:(0,_.ZP)("transactions").filter({id:{$oneof:[...e]},parent_id:{$oneof:[...e]}}).select("id")});let r=new Set((o||[]).map(e=>e.id));let i=[...e].filter(e=>!r.has(e));let s=(0,nm.Z)({name:n+"-sum",query:(0,_.ZP)("transactions").filter({id:{$oneof:i}}).options({splits:"all"}).calculate({$sum:"$amount"})});let l=null;let c=(0,to.oF)();let d=c?c.schedules:[];let u=[...e].filter(e=>t5(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,tf.lP)(e._amount)}else{l-=(0,tf.lP)(e._amount)}}}if(s==null){if(l==null){return null}else{s=l}}else if(l!=null){s+=l}return(0,a.jsx)(ny,{name:"Selected balance:",balance:s,isExactBalance:h})}function nb({balanceQuery:e}){let t=(0,nm.Z)({name:e.name+"-cleared",query:e.query.filter({cleared:true})});let n=(0,nm.Z)({name:e.name+"-uncleared",query:e.query.filter({cleared:false})});return(0,a.jsxs)(y.Z,{style:{flexDirection:"row"},children:[(0,a.jsx)(ny,{name:"Cleared total:",balance:t}),(0,a.jsx)(ny,{name:"Uncleared total:",balance:n})]})}function nw({balanceQuery:e,showExtraBalances:t,onToggleExtraBalances:n,account:o}){let r=(0,ty.D9)();return(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",marginTop:-5,marginLeft:-5},children:[(0,a.jsxs)(P.Z,{"data-testid":"account-balance",type:"bare",onClick:n,style:{"& svg":{opacity:r.size>0||t?1:0},"&:hover svg":{opacity:1}},children:[(0,a.jsx)(eT.Z,{binding:{...e,value:0},type:"financial",style:{fontSize:22,fontWeight:400},getStyle:e=>({color:e<0?m.rS.errorText:e>0?m.rS.noticeTextLight:m.rS.pageTextSubdued}),privacyFilter:{blurIntensity:5}}),(0,a.jsx)(nf.Z,{style:{width:10,height:10,marginLeft:10,color:m.rS.pillText,transform:t?"rotateZ(180deg)":"rotateZ(0)"}})]}),t&&(0,a.jsx)(nb,{balanceQuery:e}),r.size>0&&(0,a.jsx)(nv,{selectedItems:r,account:o})]})}var nS=n(6564);function nj({balanceQuery:e,targetBalance:t,onDone:n,onCreateTransaction:o}){let r=(0,nm.Z)({name:e.name+"-cleared",value:0,query:e.query.filter({cleared:true})});let i=(0,eA.Z)();let s=t-r;return(0,a.jsx)(y.Z,{style:{flexDirection:"row",alignSelf:"center",backgroundColor:m.rS.tableBackground,...m.W2.shadow,borderRadius:4,marginTop:5,marginBottom:15,padding:10},children:(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center"},children:[s===0?(0,a.jsxs)(y.Z,{style:{color:m.rS.noticeTextLight,flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},children:[(0,a.jsx)(nS.Z,{style:{width:13,height:13,color:"inherit",marginRight:3}}),"All reconciled!"]}):(0,a.jsx)(y.Z,{style:{color:m.rS.tableText},children:(0,a.jsxs)(K.Z,{style:{fontStyle:"italic",textAlign:"center"},children:["Your cleared balance"," ",(0,a.jsx)("strong",{children:i(r,"financial")})," needs"," ",(0,a.jsx)("strong",{children:(s>0?"+":"")+i(s,"financial")})," ","to match",(0,a.jsx)("br",{})," your bank’s balance of"," ",(0,a.jsx)(K.Z,{style:{fontWeight:700},children:i(t,"financial")})]})}),(0,a.jsx)(y.Z,{style:{marginLeft:15},children:(0,a.jsx)(P.Z,{type:"primary",onClick:n,children:"Done Reconciling"})}),s!==0&&(0,a.jsx)(y.Z,{style:{marginLeft:15},children:(0,a.jsx)(P.Z,{onClick:()=>o(s),children:"Create Reconciliation Transaction"})})]})})}function nC({account:e,onReconcile:t,onClose:n}){let o=eC.cW(e);let r=(0,nm.Z)({name:o.name+"-cleared",value:null,query:o.query.filter({cleared:true})});let i=(0,eA.Z)();function s(e){e.preventDefault();let o=e.target.elements[0];let a=(0,ek.qT)(o.value);if(a!=null){t(a==null?r:a);n()}else{o.select()}}return(0,a.jsx)(T.u,{position:"bottom-right",width:275,onClose:n,children:(0,a.jsxs)(y.Z,{style:{padding:"5px 8px"},children:[(0,a.jsx)(K.Z,{children:"Enter the current balance of your bank account that you want to reconcile with:"}),(0,a.jsxs)("form",{onSubmit:s,children:[r!=null&&(0,a.jsx)(ns.Z,{children:(0,a.jsx)(nl.ZP,{defaultValue:i(r,"financial"),style:{margin:"7px 0"}})}),(0,a.jsx)(P.Z,{type:"primary",children:"Reconcile"})]})]})})};function nZ({tableRef:e,editingName:t,isNameEditable:n,workingHard:o,accountName:r,account:s,filterId:l,filtersList:c,accountsSyncing:d,accounts:u,transactions:h,showBalances:p,showExtraBalances:g,showCleared:f,showEmptyMessage:x,balanceQuery:v,reconcileAmount:b,canCalculateBalance:w,isSorted:S,search:j,filters:C,conditionsOp:Z,savePrefs:k,pushModal:T,onSearch:A,onAddTransaction:R,onShowTransactions:B,onDoneReconciling:I,onCreateReconciliationTransaction:M,onToggleExtraBalances:E,onSaveName:D,onExposeName:W,onSync:N,onImport:L,onMenuSelect:F,onReconcile:_,onBatchDelete:H,onBatchDuplicate:G,onBatchEdit:O,onBatchUnlink:U,onCreateRule:z,onApplyFilter:K,onUpdateFilter:$,onClearFilters:Q,onReloadSavedFilter:q,onCondOpChange:V,onDeleteFilter:Y,onScheduleAction:J}){let[ee,et]=(0,i.useState)(false);let en=(0,i.useRef)(null);let eo=tO();let er=s&&s.account_id;if(!s){er=!!u.find(e=>!!e.account_id)}function ea(){if(e.current){eo.dispatch({type:"switch-mode",id:e.current.getScrolledItem()});k({"expand-splits":!(eo.state.mode==="expand")})}}return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(np.U,{keys:{"ctrl+f, cmd+f":()=>{if(en.current){en.current.focus()}}}}),(0,a.jsxs)(y.Z,{style:{...m.W2.pageContent,paddingBottom:10,flexShrink:0},children:[(0,a.jsx)(y.Z,{style:{marginTop:2,alignItems:"flex-start"},children:(0,a.jsx)(y.Z,{children:t?(0,a.jsx)(ns.Z,{children:(0,a.jsx)(nl.ZP,{defaultValue:r,onEnter:e=>D(e.target.value),onBlur:()=>W(false),style:{fontSize:25,fontWeight:500,marginTop:-5,marginBottom:-2,marginLeft:-5}})}):n?(0,a.jsxs)(y.Z,{style:{flexDirection:"row",alignItems:"center",gap:3,"& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[(0,a.jsx)(y.Z,{style:{fontSize:25,fontWeight:500,marginRight:5,marginBottom:5},"data-testid":"account-name",children:s&&s.closed?"Closed: "+r:r}),s&&(0,a.jsx)(X,{id:`account-${s.id}`,defaultColor:m.rS.pageTextSubdued}),(0,a.jsx)(P.Z,{type:"bare",className:"hover-visible",onClick:()=>W(true),children:(0,a.jsx)(na.Z,{style:{width:11,height:11,color:m.rS.pageTextSubdued}})})]}):(0,a.jsx)(y.Z,{style:{fontSize:25,fontWeight:500,marginBottom:5},"data-testid":"account-name",children:s&&s.closed?"Closed: "+r:r})})}),(0,a.jsx)(nw,{balanceQuery:v,showExtraBalances:g,onToggleExtraBalances:E,account:s}),(0,a.jsxs)(eE.Z,{spacing:2,direction:"row",align:"center",style:{marginTop:12},children:[(s&&!s.closed||er)&&(0,a.jsx)(P.Z,{type:"bare",onClick:er?N:L,children:er?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ni.Z,{width:13,height:13,animating:s&&d===s.name||d==="__all",style:{marginRight:4}})," ","Sync"]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(nr.Z,{width:13,height:13,style:{marginRight:4}})," ","Import"]})}),!x&&(0,a.jsxs)(P.Z,{type:"bare",onClick:R,children:[(0,a.jsx)(nt.Z,{width:10,height:10,style:{marginRight:3}})," Add New"]}),(0,a.jsx)(y.Z,{style:{flexShrink:0},children:(0,a.jsx)(nu.L,{onApply:K,type:"accounts"})}),(0,a.jsx)(y.Z,{style:{flex:1}}),(0,a.jsx)(tr.Z,{placeholder:"Search",value:j,onChange:A,inputRef:en}),o?(0,a.jsx)(y.Z,{children:(0,a.jsx)(ne.Z,{style:{width:16,height:16}})}):(0,a.jsx)(ng,{getTransaction:e=>h.find(t=>t.id===e),onShow:B,onDuplicate:G,onDelete:H,onEdit:O,onUnlink:U,onCreateRule:z,onScheduleAction:J,pushModal:T}),(0,a.jsx)(P.Z,{type:"bare",disabled:j!==""||C.length>0,style:{padding:6,marginLeft:10},onClick:ea,title:eo.state.mode==="collapse"?"Collapse split transactions":"Expand split transactions",children:eo.state.mode==="collapse"?(0,a.jsx)(no.Z,{style:{width:14,height:14}}):(0,a.jsx)(nn.Z,{style:{width:14,height:14}})}),s?(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(nc,{onClick:()=>et(true)}),ee&&(0,a.jsx)(nk,{account:s,canSync:er,canShowBalances:w(),isSorted:S,showBalances:p,showCleared:f,onMenuSelect:e=>{et(false);F(e)},onReconcile:_,onClose:()=>et(false)})]}):(0,a.jsxs)(y.Z,{children:[(0,a.jsx)(nc,{onClick:()=>et(true)}),ee&&(0,a.jsx)(nT,{onMenuSelect:e=>{et(false);F(e)},onClose:()=>et(false),isSorted:S})]})]}),C&&C.length>0&&(0,a.jsx)(nh.O,{filters:C,conditionsOp:Z,onUpdateFilter:$,onDeleteFilter:Y,onClearFilters:Q,onReloadSavedFilter:q,filterId:l,filtersList:c,onCondOpChange:V})]}),b!=null&&(0,a.jsx)(nj,{targetBalance:b,balanceQuery:v,onDone:I,onCreateTransaction:M})]})}function nk({account:e,canSync:t,showBalances:n,canShowBalances:o,showCleared:r,onClose:s,isSorted:l,onReconcile:c,onMenuSelect:d}){let[u,h]=(0,i.useState)("default");const p=(0,t7.Z)();return u==="reconcile"?(0,a.jsx)(nC,{account:e,onClose:s,onReconcile:c}):(0,a.jsx)(nd.Z,{width:200,onClose:s,children:(0,a.jsx)(W.Z,{onMenuSelect:e=>{if(e==="reconcile"){h("reconcile")}else{d(e)}},items:[l&&{name:"remove-sorting",text:"Remove all sorting"},o&&{name:"toggle-balance",text:(n?"Hide":"Show")+" running balance"},{name:"toggle-cleared",text:(r?"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 nT({onClose:e,onMenuSelect:t,isSorted:n}){return(0,a.jsx)(nd.Z,{width:200,onClose:e,children:(0,a.jsx)(W.Z,{onMenuSelect:e=>{t(e)},items:[n&&{name:"remove-sorting",text:"Remove all sorting"},{name:"export",text:"Export"}]})})};function nA({onAdd:e}){return(0,a.jsx)(y.Z,{style:{color:m.rS.tableText,backgroundColor:m.rS.tableBackground,flex:1,alignItems:"center",borderTopWidth:1,borderColor:m.rS.tableBorder},children:(0,a.jsxs)(y.Z,{style:{width:550,marginTop:75,fontSize:15,alignItems:"center"},children:[(0,a.jsxs)(K.Z,{style:{textAlign:"center",lineHeight:"1.4em"},children:["For Actual to be useful, you need to ",(0,a.jsx)("strong",{children:"add an account"}),". You can link an account to automatically download transactions, or manage it locally yourself."]}),(0,a.jsx)(P.Z,{type:"primary",style:{marginTop:20},onClick:e,children:"Add account"}),(0,a.jsx)(y.Z,{style:{marginTop:20,fontSize:13,color:m.rS.tableTextLight},children:"In the future, you can add accounts from the sidebar."})]})})}function nR({account:e={},transactions:t,balances:n,showBalances:o,filtered:r,children:a}){const{id:s}=e;let l=(0,to.oF)();t??=[];let c=(0,i.useMemo)(()=>l?l.schedules.filter(e=>!e.completed&&["due","upcoming","missed"].includes(l.statuses.get(e.id))):[],[l]);let d=(0,i.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,i.useMemo)(()=>{if(!o){return 0}return n&&t?.length>0?n[t[0].id]?.balance??0:0},[o,n,t]);let h=(0,i.useMemo)(()=>{if(!o){return null}let e=[...d].reverse().map(e=>{let t=(e._inverse?-1:1)*(0,tf.lP)(e.amount);return{balance:u+=t,id:e.id}});return(0,ek.ZZ)(e)},[o,d,u]);let p=(0,i.useMemo)(()=>{if(!r&&d.length>0){return d.concat(t)}return t},[r,d,t]);let g=(0,i.useMemo)(()=>{if(!r&&h&&n){return{...h,...n}}return n},[r,h,n]);if(l==null){return a(t,n)}return a(p,g)}function nB(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 nI extends i.PureComponent{constructor(e){super(e);this.paged=null;this.table=(0,i.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:o})=>{await e(t);let r;if(n.every(e=>e.dataset==="transactions")&&!n.find(e=>e.column==="tombstone")){let e=n.filter(e=>e.dataset==="transactions"&&!(e.column==="tombstone"));r=e.length===1?e[0].row:null}if(this.table.current){this.table.current.edit(null);if(r){this.table.current.scrollTo(r)}}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,_.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,_.ZP)("transactions").options({splits:"grouped"}).filter({"account.offbudget":false,...e.filter})}return eC.yf(t)};updateQuery(e,t){if(this.paged){this.paged.unsubscribe()}this.paged=(0,_.Fr)(e.select("*"),async(e,n)=>{const o=n==null;if(o){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(o){this.table.current?.scrollToTop()}setTimeout(()=>{this.table.current?.setRowAnimation(true)},0)})},{pageCount:150,onlySync:true,mapper:tx.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,tu.debounce)(()=>{if(this.state.search===""){this.updateQuery(this.currentQuery,this.state.filters.length>0)}else{this.updateQuery(eC.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 o=`${n||"transactions"}.csv`;window.Actual.saveFile(t,o,"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,_.Vn)(this.paged.getQuery().options({splits:"none"}).select([{balance:{$sumOver:"$amount"}}]));return(0,ek.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,tm.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 o=this.getAccountTitle(n,t);this.onExport(o);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};lockTransactions=async()=>{this.setState({workingHard:true});let{accountId:e}=this.props;let{data:t}=await (0,_.Vn)((0,_.ZP)("transactions").filter({cleared:true,reconciled:false,account:e}).select("*").options({splits:"grouped"}));let n=(0,tx.Xt)(t);let o={updated:[]};n.forEach(e=>{let{diff:t}=(0,tx.Ld)(n,{...e,reconciled:true});n=(0,ek.zb)(t,n);o.updated=o.updated?o.updated.concat(t.updated):t.updated});await (0,d.lW)("transactions-batch-update",o);await this.refetchTransactions()};onReconcile=async e=>{this.setState({reconcileAmount:e})};onDoneReconciling=async()=>{let{accountId:e}=this.props;let{reconcileAmount:t}=this.state;let{data:n}=await (0,_.Vn)((0,_.ZP)("transactions").filter({cleared:true,account:e}).select("*").options({splits:"grouped"}));let o=(0,tx.Xt)(n);let r=0;o.forEach(e=>{if(!e.is_parent){r+=e.amount}});let a=t-r;if(a===0){await this.lockTransactions()}this.setState({reconcileAmount:null})};onCreateReconciliationTransaction=async e=>{const t=(0,tx.V6)([{id:"temp",account:this.props.accountId,cleared:true,reconciled:false,amount:e,date:(0,h.PR)(),notes:"Reconciliation balance adjustment"}]);this.setState({transactions:[...t,...this.state.transactions]});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:o}=await (0,_.Vn)((0,_.ZP)("transactions").filter({id:{$oneof:t}}).select("*").options({splits:"grouped"}));let r=(0,tx.Xt)(o);let a={deleted:[],updated:[]};if(e==="cleared"){n=!!r.find(e=>!e.cleared)}const i=new Set(t);r.forEach(t=>{if(e==="cleared"&&t.reconciled){return}if(!i.has(t.id)){return}let o={...t,[e]:n};if(e==="account"&&t.account!==n){o.reconciled=false}let{diff:s}=(0,tx.Ld)(r,o);r=(0,ek.zb)(s,r);a.deleted=a.deleted?a.deleted.concat(s.deleted):s.deleted;a.updated=a.updated?a.updated.concat(s.updated):s.updated;a.added=a.added?a.added.concat(s.added):s.added});await (0,d.lW)("transactions-batch-update",a);await this.refetchTransactions();if(this.table.current){this.table.current.edit(r[0].id,"select",false)}};if(e==="amount"||e==="payee"||e==="account"){let{data:o}=await (0,_.Vn)((0,_.ZP)("transactions").filter({id:{$oneof:t},reconciled:true}).select("*").options({splits:"grouped"}));let r=(0,tx.Xt)(o);if(r.length>0){this.props.pushModal("confirm-transaction-edit",{onConfirm:()=>{this.props.pushModal("edit-field",{name:e,onSubmit:n})},confirmReason:"batchEditWithReconciled"});return}}if(e==="cleared"){n("cleared",null)}else{this.props.pushModal("edit-field",{name:e,onSubmit:n})}};onBatchDuplicate=async e=>{let t=async e=>{this.setState({workingHard:true});let{data:t}=await (0,_.Vn)((0,_.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n={added:t.reduce((e,t)=>{return e.concat((0,tx.V6)((0,tx.F6)(t)))},[]).map(({sort_order:e,...t})=>({...t}))};await (0,d.lW)("transactions-batch-update",n);await this.refetchTransactions()};await this.checkForReconciledTransactions(e,"batchDuplicateWithReconciled",t)};onBatchDelete=async e=>{let t=async e=>{this.setState({workingHard:true});let{data:t}=await (0,_.Vn)((0,_.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n=(0,tx.Xt)(t);let o=new Set(e);let r={deleted:[],updated:[]};n.forEach(e=>{let t=e.parent_id;if(!o.has(e.id)||t&&o.has(t)){return}let{diff:a}=(0,tx.Ks)(n,e.id);n=(0,ek.zb)(a,n);r.deleted=a.deleted?r.deleted.concat(a.deleted):a.deleted;r.updated=a.updated?r.updated.concat(a.updated):a.updated});await (0,d.lW)("transactions-batch-update",r);await this.refetchTransactions()};await this.checkForReconciledTransactions(e,"batchDeleteWithReconciled",t)};checkForReconciledTransactions=async(e,t,n)=>{let{data:o}=await (0,_.Vn)((0,_.ZP)("transactions").filter({id:{$oneof:e},reconciled:true}).select("*").options({splits:"grouped"}));let r=(0,tx.Xt)(o);if(r.length>0){this.props.pushModal("confirm-transaction-edit",{onConfirm:()=>{n(e)},confirmReason:t})}else{n(e)}};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,_.Vn)((0,_.ZP)("transactions").filter({id:{$oneof:e}}).select("*").options({splits:"grouped"}));let n=(0,tx.Xt)(t);let o=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 r={stage:null,conditionsOp:"and",conditions:[o],actions:[{op:"set",field:"category",value:n[0].category,type:"id"}]};this.props.pushModal("edit-rule",{rule:r})};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 o=this.state.conditionsOp==="or"?"$or":"$and";this.currentQuery=this.rootQuery.filter({[o]:[...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,o)=>{let r=this.state.filters;let a=nB(!e?this.state.sort.field:e);let i=!t?this.state.sort.ascDesc:t;let s=nB(!n?this.state.sort.prevField:n);let l=!n?this.state.sort.prevAscDesc:o;if(!e){this.currentQuery=this.currentQuery.orderBy({[a]:i})}else{if(r.length>0){this.applyFilters([...r]);this.currentQuery=this.currentQuery.orderBy({[a]:i})}else{this.currentQuery=this.rootQuery.orderBy({[a]:i})}}if(s){this.currentQuery=this.currentQuery.orderBy({[s]:l})}this.updateQuery(this.currentQuery,this.state.filters.length>0)};onSort=(e,t)=>{let n;let o;if(e===this.state.sort.field){n=this.state.sort.prevField;o=this.state.sort.prevAscDesc;this.setState({sort:{...this.state.sort,ascDesc:t}})}else{n=this.state.sort.field;o=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,o);if(this.state.search!==""){this.onSearch(this.state.search)}};render(){let{accounts:e,categoryGroups:t,payees:n,dateFormat:o,hideFraction:r,addNotification:i,accountsSyncing:s,pushModal:c,replaceModal:d,showExtraBalances:u,accountId:h,categoryId:p}=this.props;let{transactions:g,loading:f,workingHard:x,filterId:v,reconcileAmount:b,transactionsFiltered:w,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,a.jsx)(l.Fg,{to:"/accounts",replace:true})}let A=t.flatMap(e=>e.categories).find(e=>e.id===p);let R=!f&&!h&&e.length===0;let B=h&&h!=="budgeted"&&h!=="offbudget"&&h!=="uncategorized";let I=this.getBalanceQuery(k,h);return(0,a.jsx)(nR,{account:k,transactions:g,balances:C,showBalances:j,filtered:w,children:(l,p)=>(0,a.jsx)(ty.mL,{name:"transactions",items:l,fetchAllIds:this.fetchAllIds,registerDispatch:e=>this.dispatchSelected=e,selectAllFilter:e=>!e._unmatched&&!e.is_parent,children:(0,a.jsxs)(y.Z,{style:m.W2.page,children:[(0,a.jsx)(nZ,{tableRef:this.table,editingName:S,isNameEditable:B,workingHard:x,account:k,filterId:v,filtersList:this.props.filtersList,location:this.props.location,accountName:T,accountsSyncing:s,accounts:e,transactions:g,showBalances:j,showExtraBalances:u,showCleared:Z,showEmptyMessage:R,balanceQuery:I,canCalculateBalance:this.canCalculateBalance,isSorted:this.state.sort.length!==0,reconcileAmount:b,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,a.jsx)(y.Z,{style:{flex:1},children:(0,a.jsx)(t9,{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:o,hideFraction:r,addNotification:i,renderEmpty:()=>R?(0,a.jsx)(nA,{onAdd:()=>d("add-account")}):!f?(0,a.jsx)(y.Z,{style:{color:m.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 nM(e){let{dispatch:t}=tO();let n=(0,l.bS)(e.location.pathname);return(0,a.jsx)(nI,{...e,match:n,splitsExpandedDispatch:t})}function nE(){let e=(0,l.UO)();let t=(0,l.TH)();let{grouped:n}=(0,g.Z)();let o=(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 r=(0,s.I0)();let c=(0,tg.m)();let d=(0,i.useMemo)(()=>(0,th.DE)(tp,r),[r]);let u=(0,i.useMemo)(()=>{let n=eC.PK(e.id,"_account");let o=eC.PK(e.id,"_payee.transfer_acct");if(t.state&&t.state.filter||e.id==="uncategorized"){n={id:null};o={id:null}}return e=>{e=e.filter({$and:[{"_account.closed":false}],$or:[n,o]});return e.orderBy({next_date:"desc"})}},[e.id]);return(0,a.jsx)(to.up,{transform:u,children:(0,a.jsx)(tU,{initialMode:o.expandSplits?"collapse":"expand",children:(0,a.jsx)(nM,{...o,categoryGroups:n,...d,modalShowing:o.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 a},eq:function(){return i},i8:function(){return o},iE:function(){return d},mD:function(){return c},uu:function(){return s},yr:function(){return r}});function o(e,t){return e.map(e=>{if(e.id===t.cat_group){e.categories=[t,...e.categories]}return{...e}})}function r(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 a(e,t,n,o){if(t===o){return e}let r=e.reduce((e,n)=>{return e||n.categories.find(e=>e.id===t)},null);r={...r,cat_group:n};return e.map(e=>{if(e.id===n){e.categories=e.categories.reduce((e,n)=>{if(n.id===o){e.push(r);e.push(n)}else if(n.id!==t){e.push(n)}return e},[]);if(!o){e.categories.push(r)}}else{e.categories=e.categories.filter(e=>e.id!==t)}return{...e}})}function i(e,t,n){if(t===n){return e}const o=e.find(e=>e.id===t);e=e.reduce((e,r)=>{if(r.id===n){e.push(o);e.push(r)}else if(r.id!==t){e.push(r)}return e},[]);if(!n){e.push(o)}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.eb0a5f91.chunk.js.map