@actual-app/web 24.3.0 → 24.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/.vite/manifest.json +27 -17
- package/build/index.html +1 -1
- package/build/kcab/{kcab.worker.fb5495b79632bd06ea0f.js → kcab.worker.d3576baccc44df86e1d9.js} +57 -57
- package/build/kcab/{kcab.worker.fb5495b79632bd06ea0f.js.map → kcab.worker.d3576baccc44df86e1d9.js.map} +1 -1
- package/build/static/js/AppliedFilters.6hw_SZMi.chunk.js +2 -0
- package/build/static/js/AppliedFilters.6hw_SZMi.chunk.js.map +1 -0
- package/build/static/js/{BackgroundImage.Jugq91td.chunk.js → BackgroundImage.UwhfLEYN.chunk.js} +2 -2
- package/build/static/js/{BackgroundImage.Jugq91td.chunk.js.map → BackgroundImage.UwhfLEYN.chunk.js.map} +1 -1
- package/build/static/js/BalanceTooltip.hDG0UB7U.chunk.js +2 -0
- package/build/static/js/BalanceTooltip.hDG0UB7U.chunk.js.map +1 -0
- package/build/static/js/ButtonLink.WYXFzja-.chunk.js +2 -0
- package/build/static/js/{ButtonLink.ElUV7DMx.chunk.js.map → ButtonLink.WYXFzja-.chunk.js.map} +1 -1
- package/build/static/js/ReportRouter.mLx3JUh2.chunk.js +66 -0
- package/build/static/js/ReportRouter.mLx3JUh2.chunk.js.map +1 -0
- package/build/static/js/import.M8LEm-Nc.chunk.js +2 -0
- package/build/static/js/import.M8LEm-Nc.chunk.js.map +1 -0
- package/build/static/js/index.MAk9r4yg.js +216 -0
- package/build/static/js/index.MAk9r4yg.js.map +1 -0
- package/build/static/js/narrow.vxy14QoE.chunk.js +108 -0
- package/build/static/js/narrow.vxy14QoE.chunk.js.map +1 -0
- package/build/static/js/wide.GDttRuTJ.chunk.js +2 -0
- package/build/static/js/wide.GDttRuTJ.chunk.js.map +1 -0
- package/build/sw.js +1 -1
- package/build/sw.js.map +1 -1
- package/package.json +3 -2
- package/build/static/js/AppliedFilters.ggJl8zjp.chunk.js +0 -2
- package/build/static/js/AppliedFilters.ggJl8zjp.chunk.js.map +0 -1
- package/build/static/js/BalanceTooltip.nSDrDsfc.chunk.js +0 -2
- package/build/static/js/BalanceTooltip.nSDrDsfc.chunk.js.map +0 -1
- package/build/static/js/ButtonLink.ElUV7DMx.chunk.js +0 -2
- package/build/static/js/ReportRouter.8mlKGqxC.chunk.js +0 -69
- package/build/static/js/ReportRouter.8mlKGqxC.chunk.js.map +0 -1
- package/build/static/js/index.O6ABAWXP.js +0 -216
- package/build/static/js/index.O6ABAWXP.js.map +0 -1
- package/build/static/js/narrow.BvCotSUP.chunk.js +0 -108
- package/build/static/js/narrow.BvCotSUP.chunk.js.map +0 -1
- package/build/static/js/wide.Puo4nQYF.chunk.js +0 -2
- package/build/static/js/wide.Puo4nQYF.chunk.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{be as nt,bf as _e,R as Fe,bg as Yt,d as h,bh as us,bi as hs,bj as ps,bk as fs,j as e,z as ct,a3 as Ve,n as gs,L as dt,V as y,a2 as Ze,aF as xs,t as g,s as U,bl as Rt,bm as mn,an as At,ao as Bt,au as Pt,bn as ms,q as he,Q as z,a7 as be,bo as ys,m as Y,bp as Ye,U as ie,bq as Le,br as It,bs as st,I as ke,bt as ot,ag as yn,T as X,bu as Jt,ah as fe,bv as bs,bw as ws,bx as vs,F as Et,by as Ss,av as Dt,bz as js,bA as Xt,bB as en,bC as Cs,bD as tn,bE as Ts,aG as bn,D as ks,Z as ut,S as Ke,bF as Ms,bG as Rs,bH as nn,am as Je,ar as ye,as as pe,bI as Te,aB as at,i as Oe,J as Ft,bJ as rt,bK as Ee,bL as As,bM as sn,bN as Bs,aq as re,bO as Ps,x as Is,aL as Nt,aN as wn,bP as Es,X as vn,aI as jt,bQ as Ds,aK as Fs,bR as Ns,bS as _s,bT as Ls,aJ as on,bU as Os,bV as Hs,bW as an,bX as rn,bY as $s,bZ as Us,b_ as ln,b$ as Ws,c0 as Gs,c1 as qs,c2 as zs,c3 as Qs,ap as Vs,c4 as Sn,c5 as Zs,c6 as Ks,a4 as cn,aM as Ne,c7 as jn,c8 as Cn,K as Ce,c9 as ze,ca as Tn,cb as Ys,cc as dn,cd as _t,ce as Js,bb as je,cf as it,cg as kn,ch as Mn,ci as Rn,y as Lt,cj as Xs,ck as eo,cl as to,cm as qe,cn as no,h as so,p as An,co as oo,cp as ao,cq as ro,cr as Bn,cs as io,ct as lo,cu as lt,cv as co,cw as uo,cx as ho,b8 as Ot,cy as po,cz as fo,cA as go,cB as Ct,cC as xo,cD as mo,cE as tt,M as yo,N as bo,O as Ht,W as xt,cF as wo,ax as He,C as vo,cG as So,aO as jo,cH as Pn,cI as Co,cJ as In,cK as To,cL as ko,aR as Mo,A as Ro,b1 as Ao,$ as Bo,_ as Po,ai as Io,cM as Eo,a_ as Do,cN as Fo,a$ as No,b0 as _o,b7 as un,b6 as Lo,bd as Oo,l as me,bc as Ho,b9 as $o,cO as Uo,b3 as Wo,cP as En,cQ as Go,cR as qo,cS as zo}from"./index.O6ABAWXP.js";import{B as Dn,a as Qo,b as Vo}from"./BalanceTooltip.nSDrDsfc.chunk.js";import{M as ht,A as Zo,F as Ko,a as hn}from"./AppliedFilters.ggJl8zjp.chunk.js";var Yo=["getDisplayName","methodName","renderCountProp","shouldHandleStateChanges","storeKey","withRef","forwardRef","context"],Jo=["reactReduxForwardedRef"],Xo=[],ea=[null,null];function ta(n,t){var s=n[1];return[t.payload,s+1]}function pn(n,t,s){ps(function(){return n.apply(void 0,t)},s)}function na(n,t,s,o,a,i,r){n.current=o,t.current=a,s.current=!1,i.current&&(i.current=null,r())}function sa(n,t,s,o,a,i,r,l,c,d){if(n){var u=!1,f=null,p=function(){if(!u){var x=t.getState(),v,M;try{v=o(x,a.current)}catch(D){M=D,f=D}M||(f=null),v===i.current?r.current||c():(i.current=v,l.current=v,r.current=!0,d({type:"STORE_UPDATED",payload:{error:M}}))}};s.onStateChange=p,s.trySubscribe(),p();var b=function(){if(u=!0,s.tryUnsubscribe(),s.onStateChange=null,f)throw f};return b}}var oa=function(){return[null,0]};function aa(n,t){t===void 0&&(t={});var s=t,o=s.getDisplayName,a=o===void 0?function(T){return"ConnectAdvanced("+T+")"}:o,i=s.methodName,r=i===void 0?"connectAdvanced":i,l=s.renderCountProp,c=l===void 0?void 0:l,d=s.shouldHandleStateChanges,u=d===void 0?!0:d,f=s.storeKey,p=f===void 0?"store":f;s.withRef;var b=s.forwardRef,w=b===void 0?!1:b,x=s.context,v=x===void 0?fs:x,M=nt(s,Yo),D=v;return function(k){var O=k.displayName||k.name||"Component",A=a(O),N=_e({},M,{getDisplayName:a,methodName:r,renderCountProp:c,shouldHandleStateChanges:u,storeKey:p,displayName:A,wrappedComponentName:O,WrappedComponent:k}),E=M.pure;function G(H){return n(H.dispatch,N)}var $=E?h.useMemo:function(H){return H()};function W(H){var q=h.useMemo(function(){var Se=H.reactReduxForwardedRef,se=nt(H,Jo);return[H.context,Se,se]},[H]),K=q[0],j=q[1],B=q[2],S=h.useMemo(function(){return K&&K.Consumer&&us.isContextConsumer(Fe.createElement(K.Consumer,null))?K:D},[K,D]),m=h.useContext(S),C=!!H.store&&!!H.store.getState&&!!H.store.dispatch;m&&m.store;var R=C?H.store:m.store,I=h.useMemo(function(){return G(R)},[R]),F=h.useMemo(function(){if(!u)return ea;var Se=hs(R,C?null:m.subscription),se=Se.notifyNestedSubs.bind(Se);return[Se,se]},[R,C,m]),_=F[0],J=F[1],te=h.useMemo(function(){return C?m:_e({},m,{subscription:_})},[C,m,_]),V=h.useReducer(ta,Xo,oa),we=V[0],Z=we[0],de=V[1];if(Z&&Z.error)throw Z.error;var le=h.useRef(),ve=h.useRef(B),ne=h.useRef(),Me=h.useRef(!1),oe=$(function(){return ne.current&&B===ve.current?ne.current:I(R.getState(),B)},[R,Z,B]);pn(na,[ve,le,Me,B,oe,ne,J]),pn(sa,[u,R,_,I,ve,le,Me,ne,J,de],[R,_,I]);var ge=h.useMemo(function(){return Fe.createElement(k,_e({},oe,{ref:j}))},[j,k,oe]),et=h.useMemo(function(){return u?Fe.createElement(S.Provider,{value:te},ge):ge},[S,ge,te]);return et}var Q=E?Fe.memo(W):W;if(Q.WrappedComponent=k,Q.displayName=W.displayName=A,w){var L=Fe.forwardRef(function(q,K){return Fe.createElement(Q,_e({},q,{reactReduxForwardedRef:K}))});return L.displayName=A,L.WrappedComponent=k,Yt(L,k)}return Yt(Q,k)}}function fn(n,t){return n===t?n!==0||t!==0||1/n===1/t:n!==n&&t!==t}function mt(n,t){if(fn(n,t))return!0;if(typeof n!="object"||n===null||typeof t!="object"||t===null)return!1;var s=Object.keys(n),o=Object.keys(t);if(s.length!==o.length)return!1;for(var a=0;a<s.length;a++)if(!Object.prototype.hasOwnProperty.call(t,s[a])||!fn(n[s[a]],t[s[a]]))return!1;return!0}function ra(n,t){var s={},o=function(r){var l=n[r];typeof l=="function"&&(s[r]=function(){return t(l.apply(void 0,arguments))})};for(var a in n)o(a);return s}function $t(n){return function(s,o){var a=n(s,o);function i(){return a}return i.dependsOnOwnProps=!1,i}}function gn(n){return n.dependsOnOwnProps!==null&&n.dependsOnOwnProps!==void 0?!!n.dependsOnOwnProps:n.length!==1}function Fn(n,t){return function(o,a){a.displayName;var i=function(l,c){return i.dependsOnOwnProps?i.mapToProps(l,c):i.mapToProps(l)};return i.dependsOnOwnProps=!0,i.mapToProps=function(l,c){i.mapToProps=n,i.dependsOnOwnProps=gn(n);var d=i(l,c);return typeof d=="function"&&(i.mapToProps=d,i.dependsOnOwnProps=gn(d),d=i(l,c)),d},i}}function ia(n){return typeof n=="function"?Fn(n):void 0}function la(n){return n?void 0:$t(function(t){return{dispatch:t}})}function ca(n){return n&&typeof n=="object"?$t(function(t){return ra(n,t)}):void 0}const da=[ia,la,ca];function ua(n){return typeof n=="function"?Fn(n):void 0}function ha(n){return n?void 0:$t(function(){return{}})}const pa=[ua,ha];function fa(n,t,s){return _e({},s,n,t)}function ga(n){return function(s,o){o.displayName;var a=o.pure,i=o.areMergedPropsEqual,r=!1,l;return function(d,u,f){var p=n(d,u,f);return r?(!a||!i(p,l))&&(l=p):(r=!0,l=p),l}}}function xa(n){return typeof n=="function"?ga(n):void 0}function ma(n){return n?void 0:function(){return fa}}const ya=[xa,ma];var ba=["initMapStateToProps","initMapDispatchToProps","initMergeProps"];function wa(n,t,s,o){return function(i,r){return s(n(i,r),t(o,r),r)}}function va(n,t,s,o,a){var i=a.areStatesEqual,r=a.areOwnPropsEqual,l=a.areStatePropsEqual,c=!1,d,u,f,p,b;function w(T,k){return d=T,u=k,f=n(d,u),p=t(o,u),b=s(f,p,u),c=!0,b}function x(){return f=n(d,u),t.dependsOnOwnProps&&(p=t(o,u)),b=s(f,p,u),b}function v(){return n.dependsOnOwnProps&&(f=n(d,u)),t.dependsOnOwnProps&&(p=t(o,u)),b=s(f,p,u),b}function M(){var T=n(d,u),k=!l(T,f);return f=T,k&&(b=s(f,p,u)),b}function D(T,k){var O=!r(k,u),A=!i(T,d,k,u);return d=T,u=k,O&&A?x():O?v():A?M():b}return function(k,O){return c?D(k,O):w(k,O)}}function Sa(n,t){var s=t.initMapStateToProps,o=t.initMapDispatchToProps,a=t.initMergeProps,i=nt(t,ba),r=s(n,i),l=o(n,i),c=a(n,i),d=i.pure?va:wa;return d(r,l,c,n,i)}var ja=["pure","areStatesEqual","areOwnPropsEqual","areStatePropsEqual","areMergedPropsEqual"];function yt(n,t,s){for(var o=t.length-1;o>=0;o--){var a=t[o](n);if(a)return a}return function(i,r){throw new Error("Invalid value of type "+typeof n+" for "+s+" argument when connecting component "+r.wrappedComponentName+".")}}function Ca(n,t){return n===t}function Ta(n){var t=n===void 0?{}:n,s=t.connectHOC,o=s===void 0?aa:s,a=t.mapStateToPropsFactories,i=a===void 0?pa:a,r=t.mapDispatchToPropsFactories,l=r===void 0?da:r,c=t.mergePropsFactories,d=c===void 0?ya:c,u=t.selectorFactory,f=u===void 0?Sa:u;return function(b,w,x,v){v===void 0&&(v={});var M=v,D=M.pure,T=D===void 0?!0:D,k=M.areStatesEqual,O=k===void 0?Ca:k,A=M.areOwnPropsEqual,N=A===void 0?mt:A,E=M.areStatePropsEqual,G=E===void 0?mt:E,$=M.areMergedPropsEqual,W=$===void 0?mt:$,Q=nt(M,ja),L=yt(b,i,"mapStateToProps"),H=yt(w,l,"mapDispatchToProps"),q=yt(x,d,"mergeProps");return o(f,_e({methodName:"connect",getDisplayName:function(j){return"Connect("+j+")"},shouldHandleStateChanges:!!b,initMapStateToProps:L,initMapDispatchToProps:H,initMergeProps:q,pure:T,areStatesEqual:O,areOwnPropsEqual:N,areStatePropsEqual:G,areMergedPropsEqual:W},Q))}}const ka=Ta(),Ma=n=>e.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 91 51",style:{color:"inherit",...n.style},children:e.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"})}),Ra=n=>e.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",style:{color:"inherit",...n.style},children:e.jsx("path",{d:"m9 16.172-6.071-6.071-1.414 1.414L10 20l.707-.707 7.778-7.778-1.414-1.414L11 16.172V0H9z",fill:"currentColor"})}),Aa=n=>e.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",style:{color:"inherit",...n.style},children:e.jsx("path",{d:"M9 3.828 2.929 9.899 1.515 8.485 10 0l.707.707 7.778 7.778-1.414 1.414L11 3.828V20H9V3.828z",fill:"currentColor"})}),Nn=n=>e.jsxs("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:[e.jsx("path",{d:"M12 13.584a2.643 2.643 0 0 1-1.875-.775L.584 3.268a1.768 1.768 0 0 1 2.5-2.5l8.739 8.739a.25.25 0 0 0 .354 0L20.916.768a1.768 1.768 0 0 1 2.5 2.5l-9.541 9.541a2.643 2.643 0 0 1-1.875.775Z",fill:"currentColor"}),e.jsx("path",{d:"M12 23.75a2.643 2.643 0 0 1-1.875-.775L.584 13.434a1.768 1.768 0 0 1 2.5-2.5l8.739 8.739a.25.25 0 0 0 .354 0l8.739-8.739a1.768 1.768 0 0 1 2.5 2.5l-9.541 9.541A2.643 2.643 0 0 1 12 23.75Z",fill:"currentColor"})]}),Ba=n=>e.jsxs("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:[e.jsx("path",{d:"M13.584 12a2.643 2.643 0 0 1-.775 1.875l-9.541 9.541a1.768 1.768 0 0 1-2.5-2.5l8.739-8.739a.25.25 0 0 0 0-.354L.768 3.084a1.768 1.768 0 0 1 2.5-2.5l9.541 9.541A2.643 2.643 0 0 1 13.584 12Z",fill:"currentColor"}),e.jsx("path",{d:"M23.75 12a2.643 2.643 0 0 1-.775 1.875l-9.541 9.541a1.768 1.768 0 0 1-2.5-2.5l8.739-8.739a.25.25 0 0 0 0-.354l-8.739-8.739a1.768 1.768 0 0 1 2.5-2.5l9.541 9.541A2.643 2.643 0 0 1 23.75 12Z",fill:"currentColor"})]}),_n=n=>e.jsxs("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:[e.jsx("path",{d:"M12 10.416a2.643 2.643 0 0 1 1.875.775l9.541 9.541a1.768 1.768 0 0 1-2.5 2.5l-8.739-8.739a.25.25 0 0 0-.354 0l-8.739 8.739a1.768 1.768 0 0 1-2.5-2.5l9.541-9.541A2.643 2.643 0 0 1 12 10.416Z",fill:"currentColor"}),e.jsx("path",{d:"M12 .25a2.643 2.643 0 0 1 1.875.775l9.541 9.541a1.768 1.768 0 0 1-2.5 2.5l-8.739-8.739a.25.25 0 0 0-.354 0l-8.739 8.739a1.768 1.768 0 0 1-2.5-2.5l9.541-9.541A2.643 2.643 0 0 1 12 .25Z",fill:"currentColor"})]}),Pa=n=>e.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:e.jsx("path",{fill:"currentColor",d:"M19.611 2.571h-3.754a1.286 1.286 0 1 1 0-2.571h6.857A1.286 1.286 0 0 1 24 1.286v6.857a1.286 1.286 0 0 1-2.571 0V4.39L15.48 10.34a1.286 1.286 0 0 1-1.817-1.817l5.948-5.95ZM1.286 14.571a1.286 1.286 0 0 1 1.285 1.286v3.754l5.949-5.946a1.286 1.286 0 0 1 1.817 1.817L4.39 21.429h3.753a1.285 1.285 0 1 1 0 2.571H1.286A1.286 1.286 0 0 1 0 22.714v-6.857a1.286 1.286 0 0 1 1.286-1.286Z"})}),Ia=n=>e.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:e.jsx("path",{fill:"currentColor",d:"M14.143 1.714A1.286 1.286 0 0 1 15.429 3v3.753L21.806.377a1.286 1.286 0 0 1 1.817 1.817l-6.376 6.377H21a1.286 1.286 0 1 1 0 2.572h-6.857a1.286 1.286 0 0 1-1.286-1.286V3a1.286 1.286 0 0 1 1.286-1.286ZM9.857 22.286A1.285 1.285 0 0 1 8.571 21v-3.753l-6.377 6.376a1.286 1.286 0 0 1-1.817-1.817l6.376-6.377H3a1.286 1.286 0 0 1 0-2.572h6.857a1.286 1.286 0 0 1 1.286 1.286V21a1.286 1.286 0 0 1-1.286 1.286Z"})}),Ea=n=>e.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 19 24",style:{color:"inherit",...n.style},children:e.jsx("path",{fill:"currentColor",d:"M17 24H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h9a1 1 0 0 1 .707.293l7 7A1 1 0 0 1 19 8v14a2 2 0 0 1-2 2ZM2 21.5a.5.5 0 0 0 .5.5h14a.5.5 0 0 0 .5-.5V9a.5.5 0 0 0-.5-.5h-4a2 2 0 0 1-2-2v-4A.5.5 0 0 0 10 2H2.5a.5.5 0 0 0-.5.5v19Z"})}),Da=n=>e.jsxs("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:[e.jsx("path",{d:"M8.616 1.741A1.455 1.455 0 0 1 10.07.287h3.392a1.455 1.455 0 0 1 1.453 1.454v8.228a.25.25 0 0 0 .25.25h2.9a1.138 1.138 0 0 1 .827 2l-6.1 6.1a1.489 1.489 0 0 1-2.056 0l-6.1-6.1a1.137 1.137 0 0 1 .827-2h2.9a.249.249 0 0 0 .25-.25Z",fill:"currentColor"}),e.jsx("path",{d:"M0 19.677a4.039 4.039 0 0 0 4.035 4.035h15.93A4.039 4.039 0 0 0 24 19.677V17.8a1.225 1.225 0 0 0-2.449 0v1.874a1.588 1.588 0 0 1-1.586 1.586H4.035a1.588 1.588 0 0 1-1.586-1.586V17.8A1.225 1.225 0 0 0 0 17.8Z",fill:"currentColor"})]}),Fa=n=>e.jsxs("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:[e.jsx("path",{d:"M12.406 14.905a1 1 0 0 0-.543 1.307 1 1 0 0 1-.217 1.09l-2.828 2.829a2 2 0 0 1-2.828 0L3.868 18.01a2 2 0 0 1 0-2.829L6.7 12.353a1.013 1.013 0 0 1 1.091-.217 1 1 0 0 0 .763-1.849 3.034 3.034 0 0 0-3.268.652l-2.832 2.828a4.006 4.006 0 0 0 0 5.657l2.122 2.121a4 4 0 0 0 5.656 0l2.829-2.828a3.008 3.008 0 0 0 .651-3.27 1 1 0 0 0-1.306-.542Z",fill:"currentColor"}),e.jsx("path",{d:"M7.757 16.241a1.011 1.011 0 0 0 1.414 0l7.779-7.778a1 1 0 0 0-1.414-1.414l-7.779 7.778a1 1 0 0 0 0 1.414Z",fill:"currentColor"}),e.jsx("path",{d:"m21.546 4.574-2.121-2.121a4.006 4.006 0 0 0-5.657 0l-2.829 2.828a3.006 3.006 0 0 0-.651 3.269 1 1 0 1 0 1.849-.764 1 1 0 0 1 .217-1.086l2.828-2.828a2 2 0 0 1 2.829 0l2.121 2.121a2 2 0 0 1 0 2.829L17.3 11.645a1.015 1.015 0 0 1-1.091.217 1 1 0 0 0-.765 1.849 3.026 3.026 0 0 0 3.27-.651l2.828-2.828a4.007 4.007 0 0 0 .004-5.658Z",fill:"currentColor"})]}),Na=n=>e.jsx("svg",{...n,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",style:{color:"inherit",...n.style},children:e.jsx("path",{d:"M15.067 3.986a.5.5 0 0 0-.354-.148.5.5 0 0 0-.354.147L3.437 14.91a.5.5 0 0 0 0 .707l4.948 4.948a.5.5 0 0 0 .707 0L20.009 9.648a.5.5 0 0 0 0-.706ZM2.43 16.8a.5.5 0 0 0-.489-.127.5.5 0 0 0-.351.364L.084 23.314a.5.5 0 0 0 .133.47.507.507 0 0 0 .47.132l6.272-1.5a.5.5 0 0 0 .237-.84ZM23.2 2.924 21.077.8a2.5 2.5 0 0 0-3.532 0l-1.418 1.417a.5.5 0 0 0 0 .707l4.95 4.949a.5.5 0 0 0 .707 0L23.2 6.454a2.5 2.5 0 0 0 0-3.53Z",fill:"currentColor"})});function Ln(n){const t=h.useRef(null);return t.current||(t.current=new ResizeObserver(o=>{n(o[0].contentRect)})),h.useCallback(o=>{t.current.disconnect(),o&&t.current.observe(o,{box:"border-box"})},[])}const _a=({startMonth:n,numDisplayed:t,monthBounds:s,style:o,onSelect:a})=>{const[i,r]=h.useState(null),[l,c]=h.useState(12),d=ct(),u=n,f=Ve(u,t-1),p=gs(dt(u,l/2-t/2),Ve(f,l/2-t/2)),b=Math.floor(p.length/2)-Math.floor(t/2),w=b+t-1,[x,v]=h.useState("small"),M=Ln(T=>{v(T.width<=400?"small":"big"),c(Math.min(Math.max(Math.floor(T.width/50),12),24))}),D=[];return e.jsx(y,{style:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",...o},children:e.jsx(y,{innerRef:M,style:{flexDirection:"row",flex:1,alignItems:"center",justifyContent:"center"},children:p.map((T,k)=>{const O=Ze(T,"MMM"),A=k>=b&&k<=w,N=i+t-1,E=i===null?!1:k>=i&&k<=N,G=d===T,$=xs(T);let W=!1;D.includes($)||(D.push($),W=!0);const Q=T>=s.start&&T<=s.end;return e.jsxs(y,{style:{padding:"3px 3px",width:x==="big"?"35px":"20px",textAlign:"center",userSelect:"none",cursor:"default",borderRadius:2,border:"none",...!Q&&{textDecoration:"line-through",color:g.pageTextSubdued},...U.smallText,...A&&{backgroundColor:g.tableBorderHover,color:g.buttonPrimaryText},...(E||A)&&{borderRadius:0,cursor:"pointer"},...E&&!A&&{backgroundColor:g.buttonBareBackgroundHover},...E&&A&&{backgroundColor:g.tableBorderHover},...(k===b||k===i&&!A)&&{borderTopLeftRadius:2,borderBottomLeftRadius:2},...(k===w||k===N&&!A)&&{borderTopRightRadius:2,borderBottomRightRadius:2},...G&&{fontWeight:"bold"}},onClick:()=>a(T),onMouseEnter:()=>r(k),onMouseLeave:()=>r(null),children:[x==="small"?O[0]:O,W&&e.jsx(y,{style:{position:"absolute",top:-14,left:0,fontSize:10,fontWeight:"bold",color:Q?g.pageText:g.pageTextSubdued},children:$})]},T)})})})},On=h.memo(({startMonth:n,onMonthSelect:t,numMonths:s,monthBounds:o})=>{function a(i){const r=o.start,l=dt(o.end,s-1);return i<r?r:i>l?l:i}return e.jsx(y,{style:{marginLeft:205,flexShrink:0},children:e.jsx(y,{style:{marginRight:5+Rt()},children:e.jsx(_a,{startMonth:n,numDisplayed:s,monthBounds:o,style:{paddingTop:5},onSelect:i=>t(a(i))})})})});On.displayName="BudgetPageHeader";function $e({component:n,editingIndex:t,args:s,style:o}){const{months:a}=h.useContext(mn);return a.map((i,r)=>{const l=t===r;return e.jsx(At.Provider,{value:Bt(i),children:e.jsx(y,{style:{flex:1,borderLeft:"1px solid "+g.tableBorder,...o},children:e.jsx(n,{monthIndex:r,editing:l,...s})})},r)})}function La({editable:n,defaultNotes:t,position:s="bottom-left",onClose:o}){const[a,i]=h.useState(t);return e.jsx(be,{position:s,onClose:()=>o(a),children:e.jsx(ys,{notes:a,editable:n,focused:n,onChange:i})})}function Xe({id:n,width:t=12,height:s=12,defaultColor:o=g.buttonNormalText,tooltipPosition:a,style:i}){const[r,l]=h.useState(!1),c=Pt(),d=ms(()=>he("notes").filter({id:n}).select("*"),[n]),u=d&&d.length>0?d[0].note:null,f=u&&u!=="";function p(D){Y("notes-save",{id:n,note:D}),c.close()}const[b,w]=h.useState(null),x=()=>{w(setTimeout(()=>{l(!0)},300))},v=()=>{clearTimeout(b),l(!1)},M=c.isOpen||f&&r;return e.jsxs(y,{style:{flexShrink:0},onMouseEnter:x,onMouseLeave:v,children:[e.jsx(z,{type:"bare","aria-label":"View notes",className:!f&&!M?"hover-visible":"",style:{color:o,...i,...f&&{display:"flex !important"},...M&&{color:g.buttonNormalText}},...c.getOpenEvents(),children:e.jsx(Ea,{style:{width:t,height:s}})}),M&&e.jsx(La,{editable:c.isOpen,defaultNotes:u,position:a,onClose:p})]})}function Ut({innerRef:n,category:t,dragPreview:s,dragging:o,editing:a,style:i,isLast:r,onEditName:l,onSave:c,onDelete:d,onHideNewCategory:u}){const f=t.id==="new",[p,b]=h.useState(!1),w=e.jsxs(y,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none",opacity:t.hidden?.33:void 0},children:[e.jsx("div",{"data-testid":"category-name",style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:t.name}),e.jsxs(y,{style:{flexShrink:0,marginLeft:5},children:[e.jsx(z,{type:"bare",className:"hover-visible",onClick:x=>{x.stopPropagation(),b(!0)},style:{color:"currentColor",padding:3},children:e.jsx(Ye,{width:14,height:14,style:{color:"currentColor"}})}),p&&e.jsx(be,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>b(!1),children:e.jsx(ie,{onMenuSelect:x=>{x==="rename"?l(t.id):x==="delete"?d(t.id):x==="toggle-visibility"&&c({...t,hidden:!t.hidden}),b(!1)},items:[{name:"toggle-visibility",text:t.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},{name:"delete",text:"Delete"}]})})]}),e.jsx(y,{style:{flex:1}}),e.jsx(Xe,{id:t.id,style:o&&{color:"currentColor"},defaultColor:g.pageTextLight})]});return e.jsx(y,{innerRef:n,style:{width:200,overflow:"hidden","& .hover-visible":{display:"none"},...!o&&!s&&{"&:hover .hover-visible":{display:"flex"}},...o&&{color:g.formInputTextPlaceholderSelected},...s&&{backgroundColor:g.tableBackground,zIndex:1e4,borderRadius:6,overflow:"hidden"},...i},onKeyDown:x=>{x.key==="Enter"&&(l(null),x.stopPropagation())},children:e.jsx(Le,{value:t.name,formatter:()=>w,width:"flex",exposed:a||f,onUpdate:x=>{f?x===""?u():x!==""&&c({...t,name:x}):x!==t.name&&c({...t,name:x})},onBlur:()=>l(null),style:{paddingLeft:13,...r&&{borderBottomWidth:0}},inputProps:{placeholder:f?"New Category Name":""}})})}function Oa({cat:n,editingCell:t,dragState:s,MonthComponent:o,onEditName:a,onEditMonth:i,onSave:r,onDelete:l,onBudgetAction:c,onShowActivity:d,onDragChange:u,onReorder:f}){let p=s&&s.item===n;s&&s.item.id===n.cat_group&&(p=!0);const{dragRef:b}=It({type:"category",onDragChange:u,item:n,canDrag:t===null}),{dropRef:w,dropPos:x}=st({types:"category",id:n.id,onDrop:f});return e.jsxs(ke,{innerRef:w,collapsed:!0,style:{backgroundColor:g.tableBackground,opacity:n.hidden?.5:void 0},children:[e.jsx(ot,{pos:x,offset:{top:1}}),e.jsxs(y,{style:{flex:1,flexDirection:"row"},children:[e.jsx(Ut,{innerRef:b,category:n,dragPreview:p&&s.preview,dragging:p&&!s.preview,editing:t&&t.cell==="name"&&t.id===n.id,onEditName:a,onSave:r,onDelete:l}),e.jsx($e,{component:o,editingIndex:t&&t.id===n.id&&t.cell,args:{category:n,onEdit:i,onBudgetAction:c,onShowActivity:d}})]})]})}function Wt({group:n,editing:t,collapsed:s,dragPreview:o,innerRef:a,style:i,onEdit:r,onSave:l,onDelete:c,onShowNewCategory:d,onHideNewGroup:u,onToggleCollapse:f}){const p=n.id==="new",[b,w]=h.useState(!1),x=e.jsxs(y,{style:{flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},onClick:()=>{f(n.id)},children:[!o&&e.jsx(yn,{width:8,height:8,style:{marginRight:5,marginLeft:5,flexShrink:0,transition:"transform .1s",transform:s?"rotate(-90deg)":""}}),e.jsxs("div",{style:{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",minWidth:0},children:[o&&e.jsx(X,{style:{fontWeight:500},children:"Group: "}),n.name]}),!o&&e.jsxs(e.Fragment,{children:[e.jsxs(y,{style:{marginLeft:5,flexShrink:0},children:[e.jsx(z,{type:"bare",className:"hover-visible",onClick:v=>{v.stopPropagation(),w(!0)},style:{padding:3},children:e.jsx(Ye,{width:14,height:14})}),b&&e.jsx(be,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>w(!1),children:e.jsx(ie,{onMenuSelect:v=>{v==="rename"?r(n.id):v==="add-category"?d(n.id):v==="delete"?c(n.id):v==="toggle-visibility"&&l({...n,hidden:!n.hidden}),w(!1)},items:[{name:"add-category",text:"Add category"},{name:"toggle-visibility",text:n.hidden?"Show":"Hide"},{name:"rename",text:"Rename"},c&&{name:"delete",text:"Delete"}]})})]}),e.jsx(y,{style:{flex:1}}),e.jsx(Xe,{id:n.id,style:o&&{color:"currentColor"},defaultColor:g.pageTextLight})]})]});return e.jsx(y,{innerRef:a,style:{...i,width:200,backgroundColor:g.tableRowHeaderBackground,overflow:"hidden","& .hover-visible":{display:"none"},...!o&&{"&:hover .hover-visible":{display:"flex"}},...o&&{paddingLeft:10,zIndex:1e4,borderRadius:6,overflow:"hidden"}},onKeyDown:v=>{v.key==="Enter"&&(r(null),v.stopPropagation())},children:e.jsx(Le,{value:n.name,formatter:()=>x,width:"flex",exposed:t,onUpdate:v=>{p?v===""?u():v!==""&&l({id:n.id,name:v}):l({id:n.id,name:v})},onBlur:()=>r(null),style:{fontWeight:600},inputProps:{style:{marginLeft:20},placeholder:p?"New Group Name":""}})})}function Ha({group:n,collapsed:t,editingCell:s,dragState:o,MonthComponent:a,onEditName:i,onSave:r,onDelete:l,onDragChange:c,onReorderGroup:d,onReorderCategory:u,onToggleCollapse:f,onShowNewCategory:p}){const b=o&&o.item===n,{dragRef:w}=It({type:"group",onDragChange:c,item:n,canDrag:s===null}),{dropRef:x,dropPos:v}=st({types:"group",id:n.id,onDrop:d}),{dropRef:M,dropPos:D}=st({types:"category",id:n.id,onDrop:u,onLongHover:()=>{t&&f(n.id)}});return e.jsxs(ke,{collapsed:!0,style:{fontWeight:600,opacity:n.hidden?.33:void 0,backgroundColor:g.tableRowHeaderBackground},children:[o&&!o.preview&&o.type==="group"&&e.jsx(y,{innerRef:x,style:{position:"absolute",left:0,right:0,height:t?Jt-1:(1+n.categories.length)*(Jt-1)+1,zIndex:1e4},children:e.jsx(ot,{pos:v,offset:{top:1}})}),e.jsx(ot,{pos:D,offset:{top:1}}),e.jsxs(y,{innerRef:M,style:{flex:1,flexDirection:"row",opacity:b&&!o.preview?.3:1},children:[e.jsx(Wt,{innerRef:w,group:n,editing:s&&s.cell==="name"&&s.id===n.id,dragPreview:b&&o.preview,collapsed:t,onToggleCollapse:f,onEdit:i,onSave:r,onDelete:l,onShowNewCategory:p}),e.jsx($e,{component:a,args:{group:n}})]})]})}function $a({cat:n,isLast:t,editingCell:s,MonthComponent:o,onEditName:a,onEditMonth:i,onSave:r,onDelete:l,onDragChange:c,onBudgetAction:d,onReorder:u,onShowActivity:f}){const{dragRef:p}=It({type:"income-category",onDragChange:c,item:n,canDrag:s===null}),{dropRef:b,dropPos:w}=st({types:"income-category",id:n.id,onDrop:u});return e.jsxs(ke,{innerRef:b,collapsed:!0,children:[e.jsx(ot,{pos:w,offset:{top:1}}),e.jsx(Ut,{innerRef:p,category:n,isLast:t,editing:s&&s.cell==="name"&&s.id===n.id,onEditName:a,onSave:r,onDelete:l}),e.jsx($e,{component:o,editingIndex:s&&s.id===n.id&&s.cell,args:{category:n,onEdit:i,isLast:t,onShowActivity:f,onBudgetAction:d}})]})}function Ua({group:n,editingCell:t,collapsed:s,MonthComponent:o,onEditName:a,onSave:i,onToggleCollapse:r,onShowNewCategory:l}){return e.jsxs(ke,{collapsed:!0,style:{fontWeight:600,backgroundColor:g.tableRowHeaderBackground},children:[e.jsx(Wt,{group:n,collapsed:s,editing:t&&t.cell==="name"&&t.id===n.id,onEdit:a,onSave:i,onToggleCollapse:r,onShowNewCategory:l}),e.jsx($e,{component:o,args:{group:n}})]})}function Wa({MonthComponent:n,onShowNewGroup:t}){return e.jsxs(y,{style:{flexDirection:"row",flex:1},children:[e.jsx(y,{style:{width:200,alignItems:"flex-start",justifyContent:"flex-start"},children:e.jsx(z,{onClick:t,style:{fontSize:12,margin:10},children:"Add Group"})}),e.jsx($e,{component:n,style:{border:0,justifyContent:"flex-end"}})]})}const Hn=h.memo(({categoryGroups:n,editingCell:t,dataComponents:s,onBudgetAction:o,onShowActivity:a,onEditName:i,onEditMonth:r,onSaveCategory:l,onSaveGroup:c,onDeleteCategory:d,onDeleteGroup:u,onReorderCategory:f,onReorderGroup:p})=>{const[b,w]=fe("budget.collapsed"),x=b||[],[v]=fe("budget.showHiddenCategories");function M(S){w(S)}const[D,T]=h.useState(!1),[k,O]=h.useState(null),A=h.useMemo(()=>{const[S,m]=bs(n);let C=Array.prototype.concat.apply([],S.map(R=>{if(R.hidden&&!v)return[];const I=R.categories.filter(_=>v||!_.hidden),F=[{type:"expense-group",value:{...R}}];return k===R.id&&F.push({type:"new-category"}),[...F,...(x.includes(R.id)?[]:I).map(_=>({type:"expense-category",value:_}))]}));return D&&C.push({type:"new-group"}),m&&(C=C.concat([{type:"income-separator"},{type:"income-group",value:m},k===m.id&&{type:"new-category"},...(x.includes(m.id)?[]:m.categories.filter(R=>v||!R.hidden)).map(R=>({type:"income-category",value:R}))].filter(R=>R))),C},[n,x,k,D,v]),[N,E]=h.useState(null),[G,$]=h.useState(null);function W(S){const{state:m}=S;m==="start-preview"?E({type:S.type,item:S.item,preview:!0}):m==="start"?N&&(E({...N,preview:!1}),$(x)):m==="hover"?E({...N,hoveredId:S.id,hoveredPos:S.pos}):m==="end"&&(E(null),M(G||[]))}function Q(S){x.includes(S)?M(x.filter(m=>m!==S)):M([...x,S])}function L(){T(!0)}function H(){T(!1)}function q(S){c?.(S),S.id==="new"&&H()}function K(S){M(x.filter(m=>m!==S)),O(S)}function j(){O(null)}function B(S){l?.(S),S.id==="new"&&j()}return e.jsx(y,{style:{marginBottom:10,backgroundColor:g.tableBackground,overflow:"hidden",boxShadow:U.cardShadow,borderRadius:"0 0 4px 4px",flex:1},children:A.map((S,m)=>{let C;switch(S.type){case"new-group":C=e.jsx(ke,{style:{backgroundColor:g.tableRowHeaderBackground},children:e.jsx(Wt,{group:{id:"new",name:""},editing:!0,onSave:q,onHideNewGroup:H,onEdit:i})});break;case"new-category":C=e.jsx(ke,{children:e.jsx(Ut,{category:{name:"",cat_group:k,is_income:k===n.find(I=>I.is_income).id,id:"new"},editing:!0,onSave:B,onHideNewCategory:j,onEditName:i})});break;case"expense-group":C=e.jsx(Ha,{group:S.value,editingCell:t,collapsed:x.includes(S.value.id),MonthComponent:s.ExpenseGroupComponent,dragState:N,onEditName:i,onSave:q,onDelete:u,onDragChange:W,onReorderGroup:p,onReorderCategory:f,onToggleCollapse:Q,onShowNewCategory:K});break;case"expense-category":C=e.jsx(Oa,{cat:S.value,editingCell:t,MonthComponent:s.ExpenseCategoryComponent,dragState:N,onEditName:i,onEditMonth:r,onSave:B,onDelete:d,onDragChange:W,onReorder:f,onBudgetAction:o,onShowActivity:a});break;case"income-separator":C=e.jsx(y,{style:{height:U.incomeHeaderHeight,backgroundColor:g.tableBackground},children:e.jsx(Wa,{MonthComponent:s.IncomeHeaderComponent,onShowNewGroup:L})});break;case"income-group":C=e.jsx(Ua,{group:S.value,editingCell:t,MonthComponent:s.IncomeGroupComponent,collapsed:x.includes(S.value.id),onEditName:i,onSave:q,onToggleCollapse:Q,onShowNewCategory:K});break;case"income-category":C=e.jsx($a,{cat:S.value,editingCell:t,isLast:m===A.length-1,MonthComponent:s.IncomeCategoryComponent,onEditName:i,onEditMonth:r,onSave:B,onDelete:d,onDragChange:W,onReorder:f,onBudgetAction:o,onShowActivity:a});break;default:throw new Error("Unknown item type: "+S.type)}const R=m===0?"first":m===A.length-1?"last":null;return e.jsx(ws.Provider,{value:R,children:e.jsx(y,{style:!N&&{":hover":{backgroundColor:g.tableBackground}},children:C})},S.value?S.value.id:S.type==="income-separator"?"separator":m)})})});Hn.displayName="BudgetCategories";function Ga({SummaryComponent:n}){const{months:t}=h.useContext(mn),[s,o]=h.useState(0),[a,i]=vs(()=>({x:0,config:{mass:3,tension:600,friction:80}})),r=Ln(h.useCallback(u=>{o(u.width)},[])),l=h.useRef(t[0]),c=[...t];c.unshift(dt(t[0],1)),c.push(Ve(t[t.length-1],1));const d=s/t.length;return h.useLayoutEffect(()=>{const u=l.current,f=u>t[0],p=d;let b=f?-p*2:0;u!==c[0]&&u!==c[2]&&(b=-p);const w=-p;i.start({from:{x:b},x:w})},[t[0]]),h.useLayoutEffect(()=>{l.current=t[0]},[t[0]]),h.useLayoutEffect(()=>{i.start({from:{x:-d},to:{x:-d}})},[d]),e.jsx("div",{className:`${Et([{flex:1,overflow:"hidden"},t.length===1&&{marginLeft:-4,marginRight:-4}])}`,ref:r,children:e.jsx(Ss.div,{className:"view",style:{flexDirection:"row",width:s,willChange:"transform",transform:a.x.to(u=>`translateX(${u}px)`)},children:c.map(u=>e.jsx(y,{style:{flex:`0 0 ${d}px`,paddingLeft:4,paddingRight:4},children:e.jsx(n,{month:u})},u))})})}const qa=h.memo(function({MonthComponent:t,toggleHiddenCategories:s,expandAllCategories:o,collapseAllCategories:a}){const[i,r]=h.useState(!1);return e.jsxs(y,{"data-testid":"budget-totals",style:{backgroundColor:g.tableBackground,flexDirection:"row",flexShrink:0,boxShadow:U.cardShadow,marginLeft:5,marginRight:5+Rt(),borderRadius:"4px 4px 0 0",borderBottom:"1px solid "+g.tableBorder},children:[e.jsxs(y,{style:{width:200,color:g.pageTextLight,justifyContent:"center",paddingLeft:15,paddingRight:5,display:"flex",flexDirection:"row",alignItems:"center",userSelect:"none",WebkitUserSelect:"none"},children:[e.jsx(y,{style:{flexGrow:"1"},children:"Category"}),e.jsxs(z,{type:"bare","aria-label":"Menu",onClick:()=>{r(!0)},style:{color:"currentColor",padding:3},children:[e.jsx(Dt,{width:15,height:15,style:{color:g.pageTextLight}}),i&&e.jsx(be,{position:"bottom-right",width:200,style:{padding:0},onClose:()=>{r(!1)},children:e.jsx(ie,{onMenuSelect:l=>{l==="toggle-visibility"?s():l==="expandAllCategories"?o():l==="collapseAllCategories"&&a(),r(!1)},items:[{name:"toggle-visibility",text:"Toggle hidden categories"},{name:"expandAllCategories",text:"Expand all"},{name:"collapseAllCategories",text:"Collapse all"}]})})]})]}),e.jsx($e,{component:t})]})});class za extends h.Component{constructor(t){super(t),this.budgetCategoriesRef=h.createRef(),this.state={editing:null,draggingState:null}}onEditMonth=(t,s)=>{this.setState({editing:t?{id:t,cell:s}:null})};onEditName=t=>{this.setState({editing:t?{id:t,cell:"name"}:null})};onReorderCategory=(t,s,o)=>{const{categoryGroups:a}=this.props;if(!!a.find(r=>r.id===o)){const{targetId:r}=js(a,s,o),l=a.find(c=>c.id===r);if(l){const{categories:c}=l;this.props.onReorderCategory({id:t,groupId:l.id,targetId:c.length===0||s==="top"?null:c[0].id})}}else{let r;for(const l of a)if(l.categories.find(c=>c.id===o)){r=l;break}this.props.onReorderCategory({id:t,groupId:r.id,...Xt(r.categories,s,o)})}};onReorderGroup=(t,s,o)=>{const{categoryGroups:a}=this.props;this.props.onReorderGroup({id:t,...Xt(a,s,o)})};moveVertically=t=>{const{editing:s}=this.state,{type:o,categoryGroups:a,collapsed:i}=this.props,r=a.reduce((l,c)=>i.includes(c.id)?l.concat({id:c.id,isGroup:!0}):l.concat([{id:c.id,isGroup:!0},...c.categories]),[]);if(s){let c=r.findIndex(d=>d.id===s.id)+t;for(;c>=0&&c<r.length;){const d=r[c];if(d.isGroup){c+=t;continue}else if(o==="report"||!d.is_income){this.onEditMonth(d.id,s.cell);return}else break}}};onKeyDown=t=>{if(!this.state.editing)return null;(t.key==="Enter"||t.key==="Tab")&&(t.preventDefault(),this.moveVertically(t.shiftKey?-1:1))};onShowActivity=(t,s,o)=>{this.props.onShowActivity(t,s,this.resolveMonth(o))};onBudgetAction=(t,s,o)=>{this.props.onBudgetAction(this.resolveMonth(t),s,o)};resolveMonth=t=>Ve(this.props.startMonth,t);clearEditing(){this.setState({editing:null})}toggleHiddenCategories=()=>{this.props.onToggleHiddenCategories()};expandAllCategories=()=>{this.props.onCollapse([])};collapseAllCategories=()=>{const{onCollapse:t,categoryGroups:s}=this.props;t(s.map(o=>o.id))};render(){const{type:t,categoryGroups:s,prewarmStartMonth:o,startMonth:a,numMonths:i,monthBounds:r,dataComponents:l,onSaveCategory:c,onSaveGroup:d,onDeleteCategory:u,onDeleteGroup:f}=this.props,{editing:p,draggingState:b}=this.state;return e.jsxs(y,{"data-testid":"budget-table",style:{flex:1,...U.lightScrollbar&&{"& ::-webkit-scrollbar":{backgroundColor:"transparent"},"& ::-webkit-scrollbar-thumb:vertical":{backgroundColor:g.tableHeaderBackground}}},children:[e.jsxs(y,{style:{flexDirection:"row",overflow:"hidden",flexShrink:0,paddingLeft:5,paddingRight:5+Rt()},children:[e.jsx(y,{style:{width:200}}),e.jsx(en,{startMonth:o,numMonths:i,monthBounds:r,type:t,children:e.jsx(Ga,{SummaryComponent:l.SummaryComponent})})]}),e.jsxs(en,{startMonth:a,numMonths:i,monthBounds:r,type:t,children:[e.jsx(qa,{MonthComponent:l.BudgetTotalsComponent,toggleHiddenCategories:this.toggleHiddenCategories,expandAllCategories:this.expandAllCategories,collapseAllCategories:this.collapseAllCategories}),e.jsx(Cs.Provider,{value:this.budgetCategoriesRef,children:e.jsx(y,{style:{overflowY:"scroll",overflowAnchor:"none",flex:1,paddingLeft:5,paddingRight:5},innerRef:this.budgetCategoriesRef,children:e.jsx(y,{style:{opacity:b?.5:1,flexShrink:0},onKeyDown:this.onKeyDown,innerRef:w=>this.budgetDataNode=w,children:e.jsx(Hn,{categoryGroups:s,editingCell:p,dataComponents:l,onEditMonth:this.onEditMonth,onEditName:this.onEditName,onSaveCategory:c,onSaveGroup:d,onDeleteCategory:u,onDeleteGroup:f,onReorderCategory:this.onReorderCategory,onReorderGroup:this.onReorderGroup,onBudgetAction:this.onBudgetAction,onShowActivity:this.onShowActivity})})})})]})]})}}const Qa=n=>{const{grouped:t}=n.queries.categories;return{categoryGroups:t}},Va=n=>({onCollapse:o=>{n(tn({"budget.collapsed":o}))},onToggleHiddenCategories:()=>n((o,a)=>{const{prefs:i}=a(),r=i.local["budget.showHiddenCategories"];o(tn({"budget.showHiddenCategories":!r}))})}),Za=ka(Qa,Va,null,{forwardRef:!0})(za);function Ka(n){const t=n-200;return t<500?1:t<750?2:t<1e3?3:t<1250?4:t<1500?5:6}const $n=h.forwardRef(({width:n,height:t,prewarmStartMonth:s,startMonth:o,maxMonths:a=3,monthBounds:i,onMonthSelect:r,onPreload:l,...c},d)=>{const{setDisplayMax:u}=Ts(),f=bn(),p=Ka(n),b=Math.min(p,a),w=200+500*b;h.useEffect(()=>{u(p)},[p]);function x(v){r(v,b)}return e.jsx(y,{style:{width:n,height:t,alignItems:"center",opacity:n<=0||t<=0?0:1},children:e.jsxs(y,{style:{width:"100%",maxWidth:w},children:[e.jsx(On,{startMonth:s,numMonths:b,monthBounds:i,onMonthSelect:x}),e.jsx(Za,{ref:d,prewarmStartMonth:s,startMonth:o,numMonths:b,monthBounds:i,...f,...c})]})})});$n.displayName="DynamicBudgetTableInner";const Tt=h.forwardRef((n,t)=>e.jsx(ks,{children:({width:s,height:o})=>e.jsx($n,{ref:t,width:s,height:o,...n})}));Tt.displayName="DynamicBudgetTable";const Un=h.createContext(null);function Ya({summaryCollapsed:n,onBudgetAction:t,onToggleSummaryCollapse:s,children:o}){const a=ct();return e.jsx(Un.Provider,{value:{currentMonth:a,summaryCollapsed:n,onBudgetAction:t,onToggleSummaryCollapse:s},children:o})}function Ja(){return h.useContext(Un)}function Wn({month:n}){const{currentMonth:t,summaryCollapsed:s,onBudgetAction:o,onToggleSummaryCollapse:a}=Ja(),i=ut("goalTemplatesEnabled"),[r,l]=h.useState(!1);function c(){l(!0)}function d(){l(!1)}const u=s?Nn:_n;return e.jsx(y,{style:{backgroundColor:g.tableBackground,boxShadow:U.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:e.jsxs(At.Provider,{value:Bt(n),children:[e.jsxs(y,{style:{padding:"0 13px",...s?{margin:"10px 0"}:{marginTop:16}},children:[e.jsx(y,{style:{position:"absolute",left:10,top:0},children:e.jsx(z,{type:"bare","aria-label":`${s?"Expand":"Collapse"} month summary`,className:"hover-visible",onClick:a,children:e.jsx(u,{width:13,height:13,style:{color:g.pageTextSubdued,margin:1}})})}),e.jsx("div",{className:`${Et([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"}])}`,children:Ze(n,"MMMM")}),e.jsxs(y,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[e.jsx(y,{children:e.jsx(Xe,{id:`budget-${n}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:g.pageTextLight})}),e.jsxs(y,{style:{userSelect:"none"},children:[e.jsx(z,{type:"bare","aria-label":"Menu",onClick:c,children:e.jsx(Dt,{width:15,height:15,style:{color:g.pageTextLight}})}),r&&e.jsx(be,{position:"bottom-right",width:200,style:{padding:0},onClose:d,children:e.jsx(ie,{onMenuSelect:f=>{d(),o(n,f)},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"},i&&{name:"check-templates",text:"Check templates"},i&&{name:"apply-goal-template",text:"Apply budget template"},i&&{name:"overwrite-goal-template",text:"Overwrite with budget template"}]})})]})]})]}),!s&&e.jsxs(Ke,{spacing:2,style:{alignSelf:"center",backgroundColor:g.tableRowHeaderBackground,borderRadius:4,padding:"10px 15px",marginTop:13},children:[e.jsx(Ms,{}),e.jsx(Rs,{})]}),s?e.jsx(y,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:g.tableRowHeaderBackground,borderTop:"1px solid "+g.tableBorder},children:e.jsx(nn,{projected:n>=t})}):e.jsx(nn,{projected:n>=t,style:{marginTop:13,marginBottom:20}})]})})}const Qe={flex:1,padding:"0 5px",textAlign:"right"},Gn=h.memo(function(){const t=Je();return e.jsxs(y,{style:{flex:1,flexDirection:"row",marginRight:U.monthRightPadding,paddingTop:10,paddingBottom:10},children:[e.jsxs(y,{style:Qe,children:[e.jsx(X,{style:{color:g.pageTextLight},children:"Budgeted"}),e.jsx(ye,{binding:pe.totalBudgetedExpense,type:"financial",style:{color:g.pageTextLight,fontWeight:600},formatter:s=>t(parseFloat(s||"0"),"financial")})]}),e.jsxs(y,{style:Qe,children:[e.jsx(X,{style:{color:g.pageTextLight},children:"Spent"}),e.jsx(ye,{binding:pe.totalSpent,type:"financial",style:{color:g.pageTextLight,fontWeight:600}})]}),e.jsxs(y,{style:Qe,children:[e.jsx(X,{style:{color:g.pageTextLight},children:"Balance"}),e.jsx(ye,{binding:pe.totalLeftover,type:"financial",style:{color:g.pageTextLight,fontWeight:600}})]})]})});function qn(){return e.jsxs(y,{style:{flexDirection:"row",marginRight:U.monthRightPadding,paddingBottom:5},children:[e.jsx(y,{style:Qe,children:e.jsx(X,{style:{color:g.pageTextLight},children:"Budgeted"})}),e.jsx(y,{style:Qe,children:e.jsx(X,{style:{color:g.pageTextLight},children:"Received"})})]})}const Gt=h.memo(function({group:t}){const{id:s}=t;return e.jsxs(y,{style:{flex:1,flexDirection:"row"},children:[e.jsx(Te,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...U.tnum},valueProps:{binding:pe.groupBudgeted(s),type:"financial"}}),e.jsx(Te,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...U.tnum},valueProps:{binding:pe.groupSumAmount(s),type:"financial"}}),!t.is_income&&e.jsx(Te,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:U.monthRightPadding,...U.tnum},valueProps:{binding:pe.groupBalance(s),type:"financial",privacyFilter:{style:{paddingRight:U.monthRightPadding}}}})]})}),qt=h.memo(function({monthIndex:t,category:s,editing:o,onEdit:a,onBudgetAction:i,onShowActivity:r}){const l=Pt(),[c,d]=h.useState(!1),[u,f]=h.useState(!1),p=ut("goalTemplatesEnabled");return e.jsxs(y,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[e.jsxs(y,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>f(!0),onMouseLeave:()=>{f(!1)},children:[!o&&(u||c)&&e.jsxs(y,{style:{flexShrink:0,paddingLeft:3,justifyContent:"center",borderTopWidth:1,borderBottomWidth:1,borderColor:g.tableBorder},children:[e.jsx(z,{type:"bare",onClick:b=>{b.stopPropagation(),d(!0)},style:{padding:3},children:e.jsx(Ye,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&e.jsx(be,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(!1),children:e.jsx(ie,{onMenuSelect:b=>{i(t,b,{category:s.id}),d(!1)},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"}]})})]}),e.jsx(Te,{name:"budget",exposed:o,focused:o,width:"flex",onExpose:()=>a(s.id,t),style:{...o&&{zIndex:100},...U.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+g.mobileAccountShadow,backgroundColor:g.tableBackground}},valueProps:{binding:pe.catBudgeted(s.id),type:"financial",getValueStyle:at,formatExpr:b=>Oe(b),unformatExpr:b=>Ft(rt(b,0))},inputProps:{onBlur:()=>{a(null)},style:{backgroundColor:g.tableBackground}},onSave:b=>{i(t,"budget-amount",{category:s.id,amount:b})}})]}),e.jsx(Ee,{name:"spent",width:"flex",style:{textAlign:"right"},children:e.jsx("span",{"data-testid":"category-month-spent",onClick:()=>r(s.name,s.id,t),children:e.jsx(ye,{binding:pe.catSumAmount(s.id),type:"financial",getStyle:at,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),!s.is_income&&e.jsxs(Ee,{name:"balance",truncate:!1,width:"flex",style:{paddingRight:U.monthRightPadding,textAlign:"right"},children:[e.jsx("span",{...s.is_income?{}:l.getOpenEvents(),children:e.jsx(Dn,{disabled:s.is_income,carryover:pe.catCarryover(s.id),balance:pe.catBalance(s.id),goal:pe.catGoal(s.id),budgeted:pe.catBudgeted(s.id)})}),l.isOpen&&e.jsx(Qo,{categoryId:s.id,tooltip:l,monthIndex:t,onBudgetAction:i})]})]})}),zn=Gt,Qn=qt,Vn=Gt,Zn=qt,Xa=Object.freeze(Object.defineProperty({__proto__:null,BudgetSummary:Wn,BudgetTotalsMonth:Gn,CategoryMonth:qt,ExpenseCategoryMonth:Qn,ExpenseGroupMonth:zn,GroupMonth:Gt,IncomeCategoryMonth:Zn,IncomeGroupMonth:Vn,IncomeHeaderMonth:qn},Symbol.toStringTag,{value:"Module"})),Kn=h.createContext(null);function er({summaryCollapsed:n,onBudgetAction:t,onToggleSummaryCollapse:s,children:o}){const a=ct();return e.jsx(Kn.Provider,{value:{currentMonth:a,summaryCollapsed:n,onBudgetAction:t,onToggleSummaryCollapse:s},children:o})}function tr(){return h.useContext(Kn)}function Yn({month:n,isGoalTemplatesEnabled:t}){const{currentMonth:s,summaryCollapsed:o,onBudgetAction:a,onToggleSummaryCollapse:i}=tr(),[r,l]=h.useState(!1);function c(){l(!0)}function d(){l(!1)}const u=Ze(As(n),"MMM"),f=o?Nn:_n;return e.jsx(y,{"data-testid":"budget-summary",style:{backgroundColor:g.tableBackground,boxShadow:U.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:e.jsxs(At.Provider,{value:Bt(n),children:[e.jsxs(y,{style:{padding:"0 13px",...o?{margin:"10px 0"}:{marginTop:16}},children:[e.jsx(y,{style:{position:"absolute",left:10,top:0},children:e.jsx(z,{type:"bare","aria-label":`${o?"Expand":"Collapse"} month summary`,className:"hover-visible",onClick:i,children:e.jsx(f,{width:13,height:13,style:{color:g.tableTextLight,margin:1}})})}),e.jsx("div",{className:`${Et([{textAlign:"center",marginTop:3,fontSize:18,fontWeight:500,textDecorationSkip:"ink"},s===n&&{fontWeight:"bold"}])}`,children:Ze(n,"MMMM")}),e.jsxs(y,{style:{position:"absolute",right:10,top:0,flexDirection:"row",alignItems:"center"},children:[e.jsx(y,{children:e.jsx(Xe,{id:`budget-${n}`,width:15,height:15,tooltipPosition:"bottom-right",defaultColor:g.tableTextLight})}),e.jsxs(y,{style:{userSelect:"none",marginLeft:2},children:[e.jsx(z,{type:"bare","aria-label":"Menu",onClick:c,children:e.jsx(Dt,{width:15,height:15,style:{color:g.pageTextLight}})}),r&&e.jsx(be,{position:"bottom-right",width:200,style:{padding:0},onClose:d,children:e.jsx(ie,{onMenuSelect:p=>{d(),a(n,p)},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?e.jsx(y,{style:{alignItems:"center",padding:"10px 20px",justifyContent:"space-between",backgroundColor:g.tableBackground,borderTop:"1px solid "+g.tableBorder},children:e.jsx(sn,{showTotalsTooltipOnHover:!0,prevMonthName:u,month:n,onBudgetAction:a})}):e.jsxs(e.Fragment,{children:[e.jsx(Bs,{prevMonthName:u,style:{padding:"5px 0",marginTop:17,backgroundColor:g.tableRowHeaderBackground,borderTopWidth:1,borderBottomWidth:1,borderColor:g.tableBorder}}),e.jsx(y,{style:{margin:"23px 0"},children:e.jsx(sn,{month:n,onBudgetAction:a})})]})]})})}const bt={flex:1,padding:"0 5px",textAlign:"right"},Jn=h.memo(function(){const t=Je();return e.jsxs(y,{style:{flex:1,flexDirection:"row",marginRight:U.monthRightPadding,paddingTop:10,paddingBottom:10},children:[e.jsxs(y,{style:bt,children:[e.jsx(X,{style:{color:g.tableHeaderText},children:"Budgeted"}),e.jsx(ye,{binding:re.totalBudgeted,type:"financial",style:{color:g.tableHeaderText,fontWeight:600},formatter:s=>t(-parseFloat(s||"0"),"financial")})]}),e.jsxs(y,{style:bt,children:[e.jsx(X,{style:{color:g.tableHeaderText},children:"Spent"}),e.jsx(ye,{binding:re.totalSpent,type:"financial",style:{color:g.tableHeaderText,fontWeight:600}})]}),e.jsxs(y,{style:bt,children:[e.jsx(X,{style:{color:g.tableHeaderText},children:"Balance"}),e.jsx(ye,{binding:re.totalBalance,type:"financial",style:{color:g.tableHeaderText,fontWeight:600}})]})]})});function Xn(){return e.jsx(ke,{style:{color:g.tableHeaderText,alignItems:"center",paddingRight:10},children:e.jsx(y,{style:{flex:1,textAlign:"right"},children:"Received"})})}const es=h.memo(function({group:t}){const{id:s}=t;return e.jsxs(y,{style:{flex:1,flexDirection:"row"},children:[e.jsx(Te,{name:"budgeted",width:"flex",textAlign:"right",style:{fontWeight:600,...U.tnum},valueProps:{binding:re.groupBudgeted(s),type:"financial"}}),e.jsx(Te,{name:"spent",width:"flex",textAlign:"right",style:{fontWeight:600,...U.tnum},valueProps:{binding:re.groupSumAmount(s),type:"financial"}}),e.jsx(Te,{name:"balance",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:U.monthRightPadding,...U.tnum},valueProps:{binding:re.groupBalance(s),type:"financial",privacyFilter:{style:{paddingRight:U.monthRightPadding}}}})]})}),ts=h.memo(function({monthIndex:t,category:s,editing:o,onEdit:a,onBudgetAction:i,onShowActivity:r}){const l=Pt(),[c,d]=h.useState(!1),[u,f]=h.useState(!1),p=ut("goalTemplatesEnabled");return e.jsxs(y,{style:{flex:1,flexDirection:"row","& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[e.jsxs(y,{style:{flex:1,flexDirection:"row"},onMouseOverCapture:()=>f(!0),onMouseLeave:()=>{f(!1)},children:[!o&&(u||c)?e.jsxs(y,{style:{flexShrink:1,paddingLeft:3,justifyContent:"center",borderTopWidth:1,borderBottomWidth:1,borderColor:g.tableBorder},children:[e.jsx(z,{type:"bare",onClick:b=>{b.stopPropagation(),d(!0)},style:{padding:3},children:e.jsx(Ye,{width:14,height:14,className:"hover-visible",style:c&&{opacity:1}})}),c&&e.jsx(be,{position:"bottom-left",width:200,style:{padding:0},onClose:()=>d(!1),children:e.jsx(ie,{onMenuSelect:b=>{i(t,b,{category:s.id}),d(!1)},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,e.jsx(Te,{name:"budget",exposed:o,focused:o,width:"flex",onExpose:()=>a(s.id,t),style:{...o&&{zIndex:100},...U.tnum},textAlign:"right",valueStyle:{cursor:"default",margin:1,padding:"0 4px",borderRadius:4,":hover":{boxShadow:"inset 0 0 0 1px "+g.mobileAccountShadow,backgroundColor:g.tableBackground}},valueProps:{binding:re.catBudgeted(s.id),type:"financial",getValueStyle:at,formatExpr:b=>Oe(b),unformatExpr:b=>Ft(rt(b,0))},inputProps:{onBlur:()=>{a(null)},style:{backgroundColor:g.tableBackground}},onSave:b=>{i(t,"budget-amount",{category:s.id,amount:b})}})]}),e.jsx(Ee,{name:"spent",width:"flex",style:{textAlign:"right"},children:e.jsx("span",{"data-testid":"category-month-spent",onClick:()=>r(s.name,s.id,t),children:e.jsx(ye,{binding:re.catSumAmount(s.id),type:"financial",getStyle:at,style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})}),e.jsxs(Ee,{name:"balance",truncate:!1,width:"flex",style:{paddingRight:U.monthRightPadding,textAlign:"right"},children:[e.jsx("span",{...l.getOpenEvents(),children:e.jsx(Dn,{carryover:re.catCarryover(s.id),balance:re.catBalance(s.id),goal:re.catGoal(s.id),budgeted:re.catBudgeted(s.id)})}),l.isOpen&&e.jsx(Vo,{categoryId:s.id,tooltip:l,monthIndex:t,onBudgetAction:i})]})]})});function ns(){return e.jsx(y,{style:{flex:1},children:e.jsx(Te,{name:"received",width:"flex",textAlign:"right",style:{fontWeight:600,paddingRight:U.monthRightPadding,...U.tnum},valueProps:{binding:re.groupIncomeReceived,type:"financial",privacyFilter:{style:{paddingRight:U.monthRightPadding}}}})})}function ss({category:n,isLast:t,monthIndex:s,onShowActivity:o}){return e.jsx(y,{style:{flex:1},children:e.jsx(Ee,{name:"received",width:"flex",style:{paddingRight:U.monthRightPadding,textAlign:"right",...t&&{borderBottomWidth:0}},children:e.jsx("span",{onClick:()=>o(n.name,n.id,s),children:e.jsx(ye,{binding:re.catSumAmount(n.id),type:"financial",style:{cursor:"pointer",":hover":{textDecoration:"underline"}}})})})})}const nr=Object.freeze(Object.defineProperty({__proto__:null,BudgetSummary:Yn,BudgetTotalsMonth:Jn,ExpenseCategoryMonth:ts,ExpenseGroupMonth:es,IncomeCategoryMonth:ss,IncomeGroupMonth:ns,IncomeHeaderMonth:Xn},Symbol.toStringTag,{value:"Module"}));function sr(n){const t=ct(),s=h.useRef(null),o=Is(),a=Nt(),i=wn(),[r,l]=fe("budget.startMonth"),c=r||t,[d,u]=fe("budget.summaryCollapsed"),[f]=fe("budgetType"),p=f||"rollover",[b]=Es("maxMonths"),w=b||1,[x,v]=h.useState(!1),[M,D]=h.useState({start:t,end:t}),{grouped:T}=vn();function k(){a(Ns())}h.useEffect(()=>{const{titlebar:m}=n;async function C(){k();const{start:I,end:F}=await Y("get-budget-bounds");D({start:I,end:F}),await _s(p,o,{start:I,end:F},c),v(!0)}C();const R=[jt("sync-event",({type:I,tables:F})=>{I==="success"&&(F.includes("categories")||F.includes("category_mapping")||F.includes("category_groups"))&&k()}),jt("undo-event",({tables:I})=>{s.current&&s.current.clearEditing(),I.includes("categories")&&k()}),m.subscribe(K)];return()=>{R.forEach(I=>I())}},[]),h.useEffect(()=>{Y("get-budget-bounds").then(({start:m,end:C})=>{(M.start!==m||M.end!==C)&&D({start:m,end:C})})},[n.accountId]);const O=async(m,C)=>{l(m);const R=m;m<c?await on(p,o,dt(m,1)):m>c&&await on(p,o,Ve(m,C)),R===m&&l(m)},A=m=>{a(zs({type:"error",message:`Category ‘${m}’ already exists in group (May be Hidden)`}))},N=async m=>{if((await Y("get-categories")).grouped.filter(I=>I.id===m.cat_group)[0].categories.filter(I=>I.name.toUpperCase()===m.name.toUpperCase()).filter(I=>m.id==="new"?!0:I.id!==m.id).length>0){A(m.name);return}m.id==="new"?a(Os(m.name,m.cat_group,m.is_income,m.hidden)):a(Hs(m))},E=async m=>{const C=await Y("must-category-transfer",{id:m});a(C?an("confirm-category-delete",{category:m,onDelete:R=>{m!==R&&a(rn(m,R))}}):rn(m))},G=m=>{m.id==="new"?a($s(m.name)):a(Us(m))},$=async m=>{const C=T.find(I=>I.id===m);let R=!1;for(const I of C.categories)if(await Y("must-category-transfer",{id:I.id})){R=!0;break}a(R?an("confirm-category-delete",{group:m,onDelete:I=>{a(ln(m,I))}}):ln(m))},W=(m,C,R)=>{a(Ws(m,C,R))},Q=(m,C,R)=>{i("/accounts",{state:{goBack:!0,filterName:`${m} (${Ze(R,"MMMM yyyy")})`,filter:{category:C,date:{$transform:"$month",$eq:R}}}})},L=async m=>{const C=await Y("get-categories"),R=C.list.filter(F=>F.id===m.id)[0];if(C.grouped.filter(F=>F.id===m.groupId)[0].categories.filter(F=>F.name.toUpperCase()===R.name.toUpperCase()).filter(F=>F.id!==R.id).length>0){A(R.name);return}a(Gs(m.id,m.groupId,m.targetId))},H=async m=>{a(qs(m.id,m.targetId))},q=()=>{u(!d)},K=async({type:m,payload:C})=>{switch(m){case Ds:{await Fs(C.newBudgetType,o,M,c,async()=>{a(Ls())});break}}},{reportComponents:j,rolloverComponents:B}=n;if(!x||!T)return null;let S;return p==="report"?S=e.jsx(Ya,{summaryCollapsed:d,onBudgetAction:W,onToggleSummaryCollapse:q,children:e.jsx(Tt,{ref:s,type:p,prewarmStartMonth:c,startMonth:c,monthBounds:M,maxMonths:w,dataComponents:j,onMonthSelect:O,onDeleteCategory:E,onDeleteGroup:$,onSaveCategory:N,onSaveGroup:G,onBudgetAction:W,onShowActivity:Q,onReorderCategory:L,onReorderGroup:H})}):S=e.jsx(er,{summaryCollapsed:d,onBudgetAction:W,onToggleSummaryCollapse:q,children:e.jsx(Tt,{ref:s,type:p,prewarmStartMonth:c,startMonth:c,monthBounds:M,maxMonths:w,dataComponents:B,onMonthSelect:O,onDeleteCategory:E,onDeleteGroup:$,onSaveCategory:N,onSaveGroup:G,onBudgetAction:W,onShowActivity:Q,onReorderCategory:L,onReorderGroup:H})}),e.jsx(y,{style:{flex:1},children:S})}const os=h.memo(n=>{const t=ut("goalTemplatesEnabled");return e.jsx(Yn,{...n,isGoalTemplatesEnabled:t})});os.displayName="RolloverBudgetSummary";function Dr(){const n=h.useContext(Ps),t=h.useMemo(()=>({SummaryComponent:Wn,ExpenseCategoryComponent:Qn,ExpenseGroupComponent:zn,IncomeCategoryComponent:Zn,IncomeGroupComponent:Vn,BudgetTotalsComponent:Gn,IncomeHeaderComponent:qn}),[Xa]),s=h.useMemo(()=>({SummaryComponent:os,ExpenseCategoryComponent:ts,ExpenseGroupComponent:es,IncomeCategoryComponent:ss,IncomeGroupComponent:ns,BudgetTotalsComponent:Jn,IncomeHeaderComponent:Xn}),[nr]);return e.jsx(y,{style:{...U.page,paddingLeft:8,paddingRight:8,overflow:"hidden"},children:e.jsx(sr,{reportComponents:t,rolloverComponents:s,titlebar:n})})}function Fr(){const{pushModal:n}=bn(),[t,s]=h.useState(""),o=Qs();if(o==null)return null;const{schedules:a,statuses:i}=o;function r(u){n("schedule-edit",{id:u})}function l(){n("schedule-edit")}function c(){n("schedules-discover")}async function d(u,f){switch(u){case"post-transaction":await Y("schedule/post-transaction",{id:f});break;case"skip":await Y("schedule/skip-next-date",{id:f});break;case"complete":await Y("schedule/update",{schedule:{id:f,completed:!0}});break;case"restart":await Y("schedule/update",{schedule:{id:f,completed:!1},resetNextDate:!0});break;case"delete":await Y("schedule/delete",{id:f});break}}return e.jsxs(Vs,{title:"Schedules",children:[e.jsx(y,{style:{flexDirection:"row",alignItems:"center",padding:"0 0 15px"},children:e.jsx(y,{style:{flex:1,flexDirection:"row",justifyContent:"flex-end"},children:e.jsx(Sn,{placeholder:"Filter schedules…",value:t,onChange:s})})}),e.jsx(Zs,{schedules:a,filter:t,statuses:i,allowCompleted:!0,onSelect:r,onAction:d,style:{backgroundColor:g.tableBackground}}),e.jsxs(y,{style:{flexDirection:"row",justifyContent:"space-between",margin:"20px 0",flexShrink:0},children:[e.jsx(z,{onClick:c,children:"Find schedules"}),e.jsx(z,{type:"primary",onClick:l,children:"Add new schedule"})]})]})}function Nr(){return window.close(),e.jsx(Ks,{isCurrent:!0,showClose:!1,title:"Account sync",children:()=>e.jsxs(y,{style:{maxWidth:500},children:[e.jsx(cn,{children:"Please wait..."}),e.jsx(cn,{children:"The window should close automatically. If nothing happened you can close this window or tab."})]})})}function or(n,t){return n?n[t]:""}function wt(n,t){let{amount:s,date:o}=n;Ie(n.id)&&(s=(n._inverse?-1:1)*lt(s));let a=s<0?-s:null,i=s>0?s:null;return s===0&&(t?i=0:a=0),co(An(o))||(o=null),{...n,date:o,debit:a!=null?Oe(a):"",credit:i!=null?Oe(i):""}}function ar(n,t){const{debit:s,credit:o,date:a,...i}=n;let r;if(s!==""){const c=rt(s,null);r=c!=null?-c:null}else r=rt(o,null);r=r!=null?Ft(r):t.amount;let l=a;return l==null&&(l=t.date||Lt()),{...i,date:l,amount:r}}function as(n,t){const s=n[t];return s&&s.is_child&&(n[t+1]==null||n[t+1].parent_id!==s.parent_id)}const rs=h.createContext(null);function zt(){const n=h.useContext(rs);return h.useMemo(()=>({...n,expanded:t=>n.state.mode==="collapse"?!n.state.ids.has(t):n.state.ids.has(t)}),[n])}function rr({children:n,initialMode:t="expand"}){const s=Ne(l=>l.app.lastSplitState),o=Nt(),[a,i]=h.useReducer((l,c)=>{switch(c.type){case"toggle-split":{const d=new Set([...l.ids]),{id:u}=c;return d.has(u)?d.delete(u):d.add(u),{...l,ids:d}}case"open-split":{const d=new Set([...l.ids]),{id:u}=c;return l.mode==="collapse"?d.delete(u):d.add(u),{...l,ids:d}}case"set-mode":return{...l,mode:c.mode,ids:new Set,transitionId:null};case"switch-mode":return l.transitionId!=null?l:{...l,mode:l.mode==="expand"?"collapse":"expand",transitionId:c.id,ids:new Set};case"finish-switch-mode":return{...l,transitionId:null};default:throw new Error("Unknown action type: "+c.type)}},s.current||{ids:new Set,mode:t});h.useEffect(()=>{a.transitionId!=null&&setTimeout(()=>{i({type:"finish-switch-mode"})},250)},[a.transitionId]),h.useEffect(()=>{a.transitionId==null&&o({type:"SET_LAST_SPLIT_STATE",splitState:a})},[a]);const r=h.useMemo(()=>({state:a,dispatch:i}),[a,i]);return e.jsx(rs.Provider,{value:r,children:n})}function Be(n,t,s,o="asc"){return n===s?t==="asc"?"desc":"asc":o}const is=h.memo(({hasSelected:n,showAccount:t,showCategory:s,showBalance:o,showCleared:a,scrollWidth:i,onSort:r,ascDesc:l,field:c})=>{const d=jn();return e.jsxs(ke,{style:{fontWeight:300,zIndex:200,color:g.tableHeaderText,backgroundColor:g.tableBackground},children:[e.jsx(Cn,{exposed:!0,focused:!1,selected:n,width:20,onSelect:u=>d({type:"select-all",event:u})}),e.jsx(Pe,{value:"Date",width:110,alignItems:"flex",marginLeft:-5,id:"date",icon:c==="date"?l:"clickable",onClick:()=>r("date",Be(c,l,"date","desc"))}),t&&e.jsx(Pe,{value:"Account",width:"flex",alignItems:"flex",marginLeft:-5,id:"account",icon:c==="account"?l:"clickable",onClick:()=>r("account",Be(c,l,"account","asc"))}),e.jsx(Pe,{value:"Payee",width:"flex",alignItems:"flex",marginLeft:-5,id:"payee",icon:c==="payee"?l:"clickable",onClick:()=>r("payee",Be(c,l,"payee","asc"))}),e.jsx(Pe,{value:"Notes",width:"flex",alignItems:"flex",marginLeft:-5,id:"notes",icon:c==="notes"?l:"clickable",onClick:()=>r("notes",Be(c,l,"notes","asc"))}),s&&e.jsx(Pe,{value:"Category",width:"flex",alignItems:"flex",marginLeft:-5,id:"category",icon:c==="category"?l:"clickable",onClick:()=>r("category",Be(c,l,"category","asc"))}),e.jsx(Pe,{value:"Payment",width:90,alignItems:"flex-end",marginRight:-5,id:"payment",icon:c==="payment"?l:"clickable",onClick:()=>r("payment",Be(c,l,"payment","asc"))}),e.jsx(Pe,{value:"Deposit",width:85,alignItems:"flex-end",marginRight:-5,id:"deposit",icon:c==="deposit"?l:"clickable",onClick:()=>r("deposit",Be(c,l,"deposit","desc"))}),o&&e.jsx(Ce,{value:"Balance",width:88,textAlign:"right"}),a&&e.jsx(Pe,{value:"✓",width:23,alignItems:"center",id:"cleared",icon:c==="cleared"?l:"clickable",onClick:()=>{r("cleared",Be(c,l,"cleared","asc"))}}),e.jsx(Ce,{value:"",width:5+(i??0)})]})});is.displayName="TransactionHeader";function ir(n,t,s){const{payee:o}=n;return s?e.jsx(y,{style:{flexDirection:"row",alignItems:"center"},children:e.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:s.name})}):t?t.name:o&&o.startsWith("new:")?o.slice(4):""}function lr({id:n,focused:t,selected:s,status:o,isChild:a,onEdit:i,onUpdate:r}){const l=o==="cleared"||o==="reconciled"||o==null,c=uo(o),d=o==="cleared"?g.noticeTextLight:o==="reconciled"?g.noticeTextLight:o==="missed"?g.errorText:o==="due"?g.warningText:s?g.pageTextLinkLight:g.pageTextSubdued;function u(){l&&r("cleared",o!=="cleared")}return e.jsx(Ce,{name:"cleared",width:23,focused:t,style:{padding:1},plain:!0,children:e.jsx(Bn,{style:{padding:3,backgroundColor:"transparent",border:"1px solid transparent",borderRadius:50,":focus":{border:"1px solid "+g.formInputBorderSelected,boxShadow:"0 1px 2px "+g.formInputBorderSelected},cursor:l?"pointer":"default",...a&&{visibility:"hidden"}},onEdit:()=>i(n,"cleared"),onSelect:u,children:h.createElement(c.Icon,{style:{width:13,height:13,color:d,marginTop:o==="due"?-1:0}})})})}function Pe({value:n,id:t,width:s,alignItems:o,marginLeft:a,marginRight:i,icon:r,onClick:l}){return e.jsx(ze,{width:s,name:t,alignItems:o,unexposedContent:e.jsxs(z,{type:"bare",onClick:l,style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:g.tableHeaderText,fontWeight:300,marginLeft:a,marginRight:i},children:[e.jsx(Tn,{value:n}),r==="asc"&&e.jsx(Ra,{width:10,height:10,style:{marginLeft:5}}),r==="desc"&&e.jsx(Aa,{width:10,height:10,style:{marginLeft:5}})]})})}function cr({id:n,payeeId:t,accountId:s,focused:o,inherited:a,payees:i,accounts:r,valueStyle:l,transaction:c,payee:d,transferAcct:u,isPreview:f,onEdit:p,onUpdate:b,onCreatePayee:w,onManagePayees:x,onNavigateToTransferAccount:v,onNavigateToSchedule:M}){const D=h.useRef(!1);return r=r.filter(T=>T.id!==s),i=i.filter(T=>T.transfer_acct!==s),e.jsx(ze,{width:"flex",name:"payee",textAlign:"flex",value:t,valueStyle:{...l,...a&&{color:g.tableTextInactive}},exposed:o,onExpose:T=>!f&&p(n,T),onUpdate:async T=>{if(b("payee",T),T&&T.startsWith("new:")&&!D.current){D.current=!0;const k=await w(T.slice(4));b("payee",k),D.current=!1}},unexposedContent:e.jsxs(e.Fragment,{children:[e.jsx(dr,{transaction:c,transferAccount:u,onNavigateToTransferAccount:v,onNavigateToSchedule:M}),e.jsx(Tn,{value:t,formatter:()=>ir(c,d,u)})]}),children:({onBlur:T,onKeyDown:k,onUpdate:O,onSave:A,shouldSaveFromKey:N,inputStyle:E})=>e.jsx(ho,{payees:i,accounts:r,value:t,shouldSaveFromKey:N,inputProps:{onBlur:T,onKeyDown:k,style:E},showManagePayees:!0,tableBehavior:!0,focused:!0,onUpdate:O,onSelect:A,onManagePayees:()=>x(t),isCreatable:!0,menuPortalTarget:void 0})})}function dr({transaction:n,transferAccount:t,onNavigateToTransferAccount:s,onNavigateToSchedule:o,children:a}){const i=n.schedule,r=Ot(),l=r?r.schedules.find(p=>p.id===i):null;if(l==null&&t==null)return a;const c={marginLeft:-5,marginRight:2,width:23,height:23,color:"inherit"},d={width:13,height:13},u={width:10,height:10},f=l&&l._date&&!!l._date.frequency;return e.jsxs(e.Fragment,{children:[l&&e.jsx(z,{type:"bare",style:c,onClick:p=>{p.stopPropagation(),o(i)},children:f?e.jsx(po,{style:d}):e.jsx(fo,{style:d})}),t&&e.jsx(z,{type:"bare","aria-label":"Transfer",style:c,onClick:p=>{p.stopPropagation(),ce(n.id)||s(t.id)},children:(n._inverse?-1:1)*n.amount>0?e.jsx(Ma,{style:u}):e.jsx(go,{style:u})})]})}const ls=h.memo(function(t){const{transaction:s,subtransactions:o,editing:a,showAccount:i,showBalance:r,showCleared:l,showZeroInDeposit:c,style:d,selected:u,highlighted:f,added:p,matched:b,expanded:w,inheritedFields:x,focusedField:v,categoryGroups:M,payees:D,accounts:T,balance:k,dateFormat:O="MM/dd/yyyy",hideFraction:A,onSave:N,onEdit:E,onDelete:G,onSplit:$,onManagePayees:W,onCreatePayee:Q,onToggleSplit:L,onNavigateToTransferAccount:H,onNavigateToSchedule:q}=t,K=jn(),[j,B]=h.useState(c),[S,m]=h.useState(s),[C,R]=h.useState(()=>wt(s,c)),I=Ie(C.id);(s!==S||c!==j)&&(R(wt(s,c)),m(s),B(c));const[F,_]=h.useState(!1);function J(P,ee){C[P]!==ee&&(C.reconciled===!0&&(P==="credit"||P==="debit"||P==="payee"||P==="account"||P==="date")?F===!1&&(_(!0),t.pushModal("confirm-transaction-edit",{onConfirm:()=>{_(!1),te(P,ee)},confirmReason:"editReconciled"})):te(P,ee)),P==="cleared"&&C.reconciled&&t.pushModal("confirm-transaction-edit",{onConfirm:()=>{te("reconciled",!1)},confirmReason:"unlockReconciled"})}function te(P,ee){const ue={...C,[P]:ee};if(!(P==="note"&&ee===""&&C.note==null))if(P==="account"&&ee&&qe(T)[ee].offbudget&&(ue.category=null),P==="credit"?ue.debit="":P==="debit"&&(ue.credit=""),P==="account"&&C.account!==ee&&(ue.reconciled=!1),P==="payee"&&ee&&ee.startsWith("new:"))R(ue);else{const Ae=ar(ue,s);R(wt(Ae,c)),N(Ae,o)}}const{id:V,amount:we,debit:Z,credit:de,payee:le,imported_payee:ve,notes:ne,date:Me,account:oe,category:ge,cleared:et,reconciled:Se,is_parent:se,_unmatched:pt=!1,_inverse:ae=!1}=C,De=D&&le&&to(D)[le],Qt=T&&oe&&qe(T)[oe];let Ue;ae?Ue=T&&oe&&qe(T)[oe]:Ue=De&&De.transfer_acct&&qe(T)[De.transfer_acct];const xe=C.is_child,Vt=Ue&&Ue.offbudget===0,Zt=Qt&&Qt.offbudget===1,Re=p?{fontWeight:600}:null,Kt=v==="select",ft=A?{letterSpacing:-.5}:null,gt=ce(V)?k+(ae?-1:1)*we:k;return e.jsxs(ke,{style:{backgroundColor:u?g.tableRowBackgroundHighlight:Kt?g.tableRowBackgroundHover:g.tableBackground,":hover":!(Kt||u)&&{backgroundColor:g.tableRowBackgroundHover},"& .hover-visible":{opacity:0},":hover .hover-visible":{opacity:1},...f||u?{color:g.tableRowBackgroundHighlightText}:{color:g.tableText},...d,...I&&{color:g.tableTextInactive,backgroundColor:u?void 0:g.tableBackground,fontStyle:"italic"},...pt&&{opacity:.5}},children:[xe&&e.jsx(Ee,{width:110,style:{width:110,backgroundColor:g.tableRowBackgroundHover,border:0}}),xe&&i&&e.jsx(Ee,{style:{flex:1,backgroundColor:g.tableRowBackgroundHover,border:0}}),ce(C.id)?xe?e.jsx(no,{onDelete:()=>G&&G(C.id),exposed:a,style:{...xe&&{borderLeftWidth:1},lineHeight:0}}):e.jsx(Ce,{width:20}):e.jsx(Cn,{exposed:!0,buttonProps:{className:u||a?null:"hover-visible"},focused:v==="select",onSelect:P=>{K({type:"select",id:C.id,event:P})},onEdit:()=>E(V,"select"),selected:u,style:{...xe&&{borderLeftWidth:1}},value:b&&e.jsx(Fa,{style:{width:13,height:13,color:"inherit"}})}),!xe&&e.jsx(ze,{name:"date",width:110,textAlign:"flex",exposed:v==="date",value:Me,valueStyle:Re,formatter:P=>P?so(An(P),O):"",onExpose:P=>!I&&E(V,P),onUpdate:P=>{J("date",P)},children:({onBlur:P,onKeyDown:ee,onUpdate:ue,onSave:Ae,shouldSaveFromKey:We,inputStyle:Ge})=>e.jsx(oo,{value:Me||"",dateFormat:O,inputProps:{onBlur:P,onKeyDown:ee,style:Ge},shouldSaveFromKey:We,tableBehavior:!0,onUpdate:ue,onSelect:Ae})}),!xe&&i&&e.jsx(ze,{name:"account",width:"flex",textAlign:"flex",value:oe,formatter:P=>{const ee=P&&qe(T)[P];return ee?ee.name:""},valueStyle:Re,exposed:v==="account",onExpose:P=>!I&&E(V,P),onUpdate:async P=>{P&&J("account",P)},children:({onBlur:P,onKeyDown:ee,onUpdate:ue,onSave:Ae,shouldSaveFromKey:We,inputStyle:Ge})=>e.jsx(ao,{includeClosedAccounts:!1,value:oe,accounts:T,shouldSaveFromKey:We,tableBehavior:!0,focused:!0,inputProps:{onBlur:P,onKeyDown:ee,style:Ge},onUpdate:ue,onSelect:Ae,menuPortalTarget:void 0})}),e.jsx(cr,{id:V,payeeId:le,accountId:oe,focused:v==="payee",inherited:x&&x.has("payee"),payees:D,accounts:T,valueStyle:Re,transaction:C,payee:De,transferAcct:Ue,importedPayee:ve,isPreview:I,onEdit:E,onUpdate:J,onCreatePayee:Q,onManagePayees:W,onNavigateToTransferAccount:H,onNavigateToSchedule:q}),I?e.jsx(Ce,{name:"notes",width:"flex"}):e.jsx(Le,{width:"flex",name:"notes",textAlign:"flex",exposed:v==="notes",focused:v==="notes",value:ne||"",valueStyle:Re,onExpose:P=>!I&&E(V,P),inputProps:{value:ne||"",onUpdate:J.bind(null,"notes")}}),I?e.jsx(Ce,{width:"flex",style:{alignItems:"flex-start"},exposed:!0,children:()=>e.jsx(y,{style:{color:ne==="missed"?g.errorText:ne==="due"?g.warningText:u?g.formLabelText:g.upcomingText,backgroundColor:ne==="missed"?g.errorBackground:ne==="due"?g.warningBackground:u?g.formLabelBackground:g.upcomingBackground,margin:"0 5px",padding:"3px 7px",borderRadius:4},children:ro(ne)})}):se?e.jsx(Ce,{name:"category",width:"flex",focused:v==="category",style:{padding:0},plain:!0,children:e.jsx(Bn,{bare:!0,style:{alignSelf:"flex-start",borderRadius:4,border:"1px solid transparent",":hover":{border:"1px solid "+g.buttonNormalBorder}},disabled:ce(C.id),onEdit:()=>E(V,"category"),onSelect:()=>L(V),children:e.jsxs(y,{style:{flexDirection:"row",alignItems:"center",alignSelf:"stretch",borderRadius:4,flex:1,padding:4},children:[se&&e.jsx(Ye,{style:{color:"inherit",width:14,height:14,transition:"transform .08s",transform:w?"rotateZ(0)":"rotateZ(-90deg)"}}),e.jsx(X,{style:{fontStyle:"italic",userSelect:"none"},children:"Split"})]})})}):Vt||Zt||I?e.jsx(Le,{name:"category",width:"flex",exposed:v==="category",focused:v==="category",onExpose:P=>!I&&E(V,P),value:se?"Split":Zt?"Off Budget":Vt?"Transfer":"",valueStyle:Re,style:{fontStyle:"italic",color:g.pageTextSubdued,fontWeight:300},inputProps:{readOnly:!0,style:{fontStyle:"italic"}}}):e.jsx(ze,{name:"category",width:"flex",textAlign:"flex",value:ge,formatter:P=>P?or(io(M)[P],"name"):C.id?"Categorize":"",exposed:v==="category",onExpose:P=>E(V,P),valueStyle:ge?Re:{fontStyle:"italic",fontWeight:300,color:g.formInputTextHighlight},onUpdate:async P=>{P==="split"?$(C.id):J("category",P)},children:({onBlur:P,onKeyDown:ee,onUpdate:ue,onSave:Ae,shouldSaveFromKey:We,inputStyle:Ge})=>e.jsx(lo,{categoryGroups:M,value:ge,focused:!0,tableBehavior:!0,showSplitOption:!xe&&!se,shouldSaveFromKey:We,inputProps:{onBlur:P,onKeyDown:ee,style:Ge},onUpdate:ue,onSelect:Ae,menuPortalTarget:void 0})}),e.jsx(Le,{type:"input",width:90,name:"debit",exposed:v==="debit",focused:v==="debit",value:Z===""&&de===""?"0.00":Z,valueStyle:Re,textAlign:"right",title:Z,onExpose:P=>!I&&E(V,P),style:{...se&&{fontStyle:"italic"},...U.tnum,...ft},inputProps:{value:Z===""&&de===""?"0.00":Z,onUpdate:J.bind(null,"debit")},privacyFilter:{activationFilters:[!ce(C.id)]}}),e.jsx(Le,{type:"input",width:85,name:"credit",exposed:v==="credit",focused:v==="credit",value:de,valueStyle:Re,textAlign:"right",title:de,onExpose:P=>!I&&E(V,P),style:{...se&&{fontStyle:"italic"},...U.tnum,...ft},inputProps:{value:de,onUpdate:J.bind(null,"credit")},privacyFilter:{activationFilters:[!ce(C.id)]}}),r&&e.jsx(Ce,{name:"balance",value:gt==null||xe?"":Oe(gt),valueStyle:{color:gt<0?g.errorText:g.noticeTextLight},style:{...U.tnum,...ft},width:88,textAlign:"right",privacyFilter:!0}),l&&e.jsx(lr,{id:V,focused:v==="cleared",selected:u,isPreview:I,status:I?ne:Se?"reconciled":et?"cleared":null,isChild:xe,onEdit:E,onUpdate:J}),e.jsx(Ce,{width:5})]})});function cs({error:n,isDeposit:t,onAddSplit:s,onDistributeRemainder:o,style:a,canDistributeRemainder:i}){switch(n.type){case"SplitTransactionError":if(n.version===1)return e.jsxs(y,{style:{flexDirection:"row",alignItems:"center",padding:"0 5px",...a},"data-testid":"transaction-error",children:[e.jsxs(X,{children:["Amount left:"," ",e.jsx(X,{style:{fontWeight:500},children:Oe(t?n.difference:-n.difference)})]}),e.jsx(y,{style:{flex:1}}),e.jsx(z,{type:"normal",style:{marginLeft:15},onClick:o,"data-testid":"distribute-split-button",disabled:!i,children:"Distribute"}),e.jsx(z,{type:"primary",style:{marginLeft:10,padding:"4px 10px"},onClick:s,"data-testid":"add-split-button",children:"Add Split"})]});break;default:return null}}function vt(n,t,s){return[{id:"temp",date:s||Lt(),account:n||null,category:t||null,cleared:!1,amount:null}]}function ce(n){return n.indexOf("temp")!==-1}function Ie(n){return n.indexOf("preview/")!==-1}function ur({transactions:n,accounts:t,categoryGroups:s,payees:o,editingTransaction:a,focusedField:i,showAccount:r,showCategory:l,showBalance:c,showCleared:d,dateFormat:u,hideFraction:f,onClose:p,onSplit:b,onEdit:w,onDelete:x,onSave:v,onAdd:M,onAddSplit:D,onDistributeRemainder:T,onManagePayees:k,onCreatePayee:O,onNavigateToTransferAccount:A,onNavigateToSchedule:N,balance:E}){const G=n[0].error,$=n[0].amount>0,W=n.filter(L=>L.parent_id===n[0].id),Q=W.filter(L=>L.amount===0);return e.jsxs(y,{style:{borderBottom:"1px solid "+g.tableBorderHover,paddingBottom:6,backgroundColor:g.tableBackground},"data-testid":"new-transaction",onKeyDown:L=>{L.key==="Escape"&&p()},children:[n.map(L=>e.jsx(ls,{isNew:!0,editing:a===L.id,transaction:L,subtransactions:L.is_parent?W:null,showAccount:r,showCategory:l,showBalance:c,showCleared:d,focusedField:a===L.id&&i,showZeroInDeposit:$,accounts:t,categoryGroups:s,payees:o,dateFormat:u,hideFraction:f,expanded:!0,onEdit:w,onSave:v,onSplit:b,onDelete:x,onAdd:M,onManagePayees:k,onCreatePayee:O,style:{marginTop:-1},onNavigateToTransferAccount:A,onNavigateToSchedule:N,balance:E},L.id)),e.jsxs(y,{style:{flexDirection:"row",alignItems:"center",justifyContent:"flex-end",marginTop:6,marginRight:20},children:[e.jsx(z,{style:{marginRight:10,padding:"4px 10px"},onClick:()=>p(),"data-testid":"cancel-button",children:"Cancel"}),G?e.jsx(cs,{error:G,isDeposit:$,onAddSplit:()=>D(n[0].id),onDistributeRemainder:()=>T(n[0].id),canDistributeRemainder:Q.length>0}):e.jsx(z,{type:"primary",style:{padding:"4px 10px"},onClick:M,"data-testid":"add-button",children:"Add"})]})]})}function hr({tableNavigator:n,tableRef:t,dateFormat:s="MM/dd/yyyy",newNavigator:o,renderEmpty:a,onScroll:i,...r}){const l=h.createRef(),c=Xs(r.isAdding),[d,u]=h.useState(0);function f(x,v){const M=x>0&&v>0&&x-v;u(M||0)}const p=h.useCallback(x=>{r.onCloseAddTransaction(),r.onNavigateToTransferAccount(x)},[r.onCloseAddTransaction,r.onNavigateToTransferAccount]),b=h.useCallback(x=>{r.onCloseAddTransaction(),r.onNavigateToSchedule(x)},[r.onCloseAddTransaction,r.onNavigateToSchedule]);h.useEffect(()=>{!c&&r.isAdding&&o.onEdit("temp","date")},[c,r.isAdding,o]);const w=({item:x,index:v,position:M,editing:D})=>{const{transactions:T,selectedItems:k,accounts:O,categoryGroups:A,payees:N,showCleared:E,showAccount:G,showCategory:$,showBalances:W,balances:Q,hideFraction:L,isNew:H,isMatched:q,isExpanded:K}=r,j=x,B=k.has(j.id),S=r.transactionMap.get(j.parent_id),m=S&&S.amount>0,C=K&&K((S||j).id),R=C&&S&&S.error||j.error,I=(!C||as(T,v))&&R&&R.type==="SplitTransactionError",F=T.filter(_=>_.parent_id===(j.is_parent?j.id:j.parent_id)&&_.amount===0);return e.jsxs(e.Fragment,{children:[I&&e.jsx(be,{position:"bottom-right",width:350,forceTop:M,forceLayout:!0,style:{transform:"translate(-5px, 2px)"},children:e.jsx(cs,{error:R,isDeposit:m,onAddSplit:()=>r.onAddSplit(j.id),onDistributeRemainder:()=>r.onDistributeRemainder(j.id),canDistributeRemainder:F.length>0})}),e.jsx(ls,{editing:D,transaction:j,showAccount:G,showCategory:$,showBalance:W,showCleared:E,selected:B,highlighted:!1,added:H?.(j.id),expanded:K?.(j.id),matched:q?.(j.id),showZeroInDeposit:m,balance:Q?.[j.id]?.balance,focusedField:D&&n.focusedField,accounts:O,categoryGroups:A,payees:N,inheritedFields:S?.payee===j.payee?new Set(["payee"]):new Set,dateFormat:s,hideFraction:L,onEdit:n.onEdit,onSave:r.onSave,onDelete:r.onDelete,onSplit:r.onSplit,onManagePayees:r.onManagePayees,onCreatePayee:r.onCreatePayee,onToggleSplit:r.onToggleSplit,onNavigateToTransferAccount:p,onNavigateToSchedule:b,pushModal:r.pushModal})]})};return e.jsxs(y,{innerRef:l,style:{flex:1,cursor:"default",...r.style},children:[e.jsxs(y,{children:[e.jsx(is,{hasSelected:r.selectedItems.size>0,showAccount:r.showAccount,showCategory:r.showCategory,showBalance:r.showBalances,showCleared:r.showCleared,scrollWidth:d,onSort:r.onSort,ascDesc:r.ascDesc,field:r.sortField}),r.isAdding&&e.jsx(y,{...o.getNavigatorProps({onKeyDown:x=>r.onCheckNewEnter(x)}),children:e.jsx(ur,{transactions:r.newTransactions,editingTransaction:o.editingId,focusedField:o.focusedField,accounts:r.accounts,categoryGroups:r.categoryGroups,payees:r.payees||[],showAccount:r.showAccount,showCategory:r.showCategory,showBalance:r.showBalances,showCleared:r.showCleared,dateFormat:s,hideFraction:r.hideFraction,onClose:r.onCloseAddTransaction,onAdd:r.onAddTemporary,onAddSplit:r.onAddSplit,onSplit:r.onSplit,onEdit:o.onEdit,onSave:r.onSave,onDelete:r.onDelete,onManagePayees:r.onManagePayees,onCreatePayee:r.onCreatePayee,onNavigateToTransferAccount:p,onNavigateToSchedule:b,onDistributeRemainder:r.onDistributeRemainder,balance:r.transactions?.length>0?r.balances?.[r.transactions[0]?.id]?.balance:0})})]}),e.jsxs(y,{style:{flex:1,overflow:"hidden"},"data-testid":"transaction-table",children:[e.jsx(eo,{navigator:n,ref:t,items:r.transactions,renderItem:w,renderEmpty:a,loadMore:r.loadMoreTransactions,isSelected:x=>r.selectedItems.has(x),onKeyDown:x=>r.onCheckEnter(x),onScroll:i,saveScrollWidth:f}),r.isAdding&&e.jsx("div",{style:{position:"absolute",top:-20,left:0,right:0,height:20,backgroundColor:g.errorText,boxShadow:"0 0 6px rgba(0, 0, 0, .20)"}},"shadow")]})]})}const ds=h.forwardRef((n,t)=>{const[s,o]=h.useState(null),[a,i]=h.useState(!1),r=zt(),l=h.useRef(null),c=h.useRef(null),d=Ys(c,t),u=h.useMemo(()=>{let j;if(r.state.transitionId!=null){const B=n.transactions.findIndex(S=>S.id===r.state.transitionId);j=n.transactions.filter((S,m)=>{if(S.parent_id){if(m>=B)return r.expanded(S.parent_id);if(l.current)return l.current.expanded(S.parent_id)}return!0})}else l.current&&l.current.state.transitionId!=null&&(c.current.anchor(),c.current.setRowAnimation(!1)),l.current=r,j=n.transactions.filter(B=>B.parent_id?r.expanded(B.parent_id):!0);return l.current=r,j},[n.transactions,r]),f=h.useMemo(()=>new Map(u.map(j=>[j.id,j])),[u]);h.useEffect(()=>{c.current.isAnchored()&&(c.current.unanchor(),c.current.setRowAnimation(!0))},[l.current]);const p=dn(s,O),b=dn(u,O),w=h.useRef(!1),x=h.useRef({newTransactions:s,newNavigator:p,tableNavigator:b}),v=h.useRef(!1),M=h.useRef(!1),[D,T]=h.useState({}),k=_t();h.useLayoutEffect(()=>{x.current={newTransactions:s,newNavigator:p,tableNavigator:b,transactions:n.transactions}}),a!==n.isAdding&&(!a&&n.isAdding&&o(vt(n.currentAccountId,n.currentCategoryId)),i(n.isAdding)),h.useEffect(()=>{if(w.current){if(s[0].account==null)n.addNotification({type:"error",message:"Account is a required field"}),p.onEdit("temp","account");else{const j=x.current.newTransactions,B=j.length>0?j[0].date:null;o(vt(n.currentAccountId,n.currentCategoryId,B)),p.onEdit("temp","date"),n.onAdd(j)}w.current=!1}}),h.useEffect(()=>{v.current&&M.current&&(M.current(n),M.current=null),v.current=!1},[s,n.transactions]);function O(j){let B=["select","date","account","payee","notes","category","debit","credit","cleared"];return B=j.is_child?["select","payee","notes","category","debit","credit"]:B.filter(S=>(n.showAccount||S!=="account")&&(n.showCategory||S!=="category")),Ie(j.id)&&(B=["select","cleared"]),ce(j.id)&&(B=B.slice(1)),B}function A(j){v.current?M.current=j:j(n)}function N(j){if(j.key==="Enter"){if(j.metaKey)j.stopPropagation(),G();else if(!j.shiftKey){let B=function(S){const{newTransactions:m}=S.current;return m[m.length-1]};p.editingId===B(x).id&&j.stopPropagation(),A(()=>{const S=B(x),m=S.parent_id||S.is_parent;x.current.newTransactions[0].error&&p.editingId===S.id?L(S.id):p.editingId===S.id&&(!m||!S.error)&&G()})}}}function E(j){if(j.key==="Enter"&&!j.shiftKey){const{editingId:B,focusedField:S}=b;A(()=>{const m=x.current.transactions,C=m.findIndex(I=>I.id===B),R=m.find(I=>I.id===m[C]?.parent_id);as(m,C)&&R&&R.error&&S!=="select"&&(j.stopPropagation(),L(B))})}}const G=h.useCallback(()=>{w.current=!0,T({})},[n.onAdd,p.onEdit]),$=h.useCallback(async(j,B=null)=>{v.current=!0;let S=B?Js([j,...B]):j;if(ce(j.id)){n.onApplyRules&&(S=await n.onApplyRules(S));const m=x.current.newTransactions;o(je(it(m,S).data))}else n.onSave(S)},[n.onSave]),W=h.useCallback(j=>{if(ce(j)){const S=x.current.newTransactions;if(j===S[0].id)return;o(kn(S,j).data)}},[]),Q=h.useMemo(()=>j=>{if(ce(j)){const{newNavigator:B}=x.current,S=x.current.newTransactions,{data:m,diff:C}=Mn(S,j);o(m),S[0].amount===null?B.onEdit(S[0].id,"debit"):B.onEdit(C.added[0].id,x.current.newNavigator.focusedField)}else{const B=x.current.transactions.find(C=>C.id===j),S=n.onSplit(j);r.dispatch({type:"open-split",id:B.id});const{tableNavigator:m}=x.current;B.amount===null?m.onEdit(B.id,"debit"):m.onEdit(S,m.focusedField)}},[n.onSplit,r.dispatch]),L=h.useCallback(j=>{if(ce(j)){const B=x.current.newTransactions,{data:S,diff:m}=Rn(B,j);o(S),p.onEdit(m.added[0].id,x.current.newNavigator.focusedField)}else{const B=n.onAddSplit(j);b.onEdit(B,x.current.tableNavigator.focusedField)}},[n.onAddSplit]),H=h.useCallback(async j=>{const{transactions:B,tableNavigator:S,newTransactions:m}=x.current,C=ce(j)?m:B,R=C.find(Z=>Z.id===j),I=R.is_parent?R:C.find(Z=>Z.id===R.parent_id),F=C.filter(Z=>Z.parent_id===(R.is_parent?R.id:R.parent_id)),_=F.filter(Z=>Z.amount===0),J=I.amount-F.reduce((Z,de)=>Z+de.amount,0),te=Math.floor(J/_.length);let V=J-te*_.length;const we=new Array(_.length).fill(te);for(const Z in we){if(V===0)break;we[Z]+=1,V--}ce(j)?p.onEdit(null):S.onEdit(null);for(const Z in _)await $({..._[Z],amount:we[Z]})},[x]);function q(){o(vt(n.currentAccountId,n.currentCategoryId)),n.onCloseAddTransaction()}const K=h.useCallback(j=>r.dispatch({type:"toggle-split",id:j}),[r.dispatch]);return e.jsx(hr,{tableRef:d,...n,transactions:u,transactionMap:f,selectedItems:k,isExpanded:r.expanded,onSave:$,onDelete:W,onSplit:Q,onCheckNewEnter:N,onCheckEnter:E,onAddTemporary:G,onAddSplit:L,onDistributeRemainder:H,onCloseAddTransaction:q,onToggleSplit:K,newTransactions:s,tableNavigator:b,newNavigator:p})});ds.displayName="TransactionTable";async function kt(n){const t=await Y("transactions-batch-update",{...n,learnCategories:!0});return t.length>0?{updates:t}:{}}async function St(n,t,s){const o=await kt(n);s(mo(t.newTransaction,o),tt(o,t.data))}function pr({tableRef:n,transactions:t,allTransactions:s,loadMoreTransactions:o,account:a,accounts:i,category:r,categoryGroups:l,payees:c,balances:d,showBalances:u,showCleared:f,showAccount:p,headerContent:b,isAdding:w,isNew:x,isMatched:v,isFiltered:M,dateFormat:D,hideFraction:T,addNotification:k,pushModal:O,renderEmpty:A,onSort:N,sortField:E,ascDesc:G,onChange:$,onRefetch:W,onCloseAddTransaction:Q,onCreatePayee:L}){const H=h.useRef(),q=wn();h.useLayoutEffect(()=>{H.current=t},[t]);const K=h.useCallback(async F=>{F=Ct(F),await kt({added:F}),W()},[]),j=h.useCallback(async F=>{const _=it(H.current,F);_.diff.updated.length>0&&(!!_.diff.updated[0].date?(_.diff.updated[0].sort_order=Date.now(),await kt(_.diff),W()):($(_.newTransaction,_.data),St(_.diff,_,$)))},[]),B=h.useCallback(F=>{const _=Rn(H.current,F);return $(_.newTransaction,_.data),St(_.diff,_,$),_.diff.added[0].id},[]),S=h.useCallback(F=>{const _=Mn(H.current,F);return $(_.newTransaction,_.data),St(_.diff,_,$),_.diff.added[0].id},[]),m=h.useCallback(async F=>{const _=await Y("rules-run",{transaction:F}),J=xo(F,_),te={...F};return J&&Object.keys(J).forEach(V=>{(te[V]==null||te[V]===""||te[V]===0||te[V]===!1)&&(te[V]=J[V])}),te},[]),C=h.useCallback(F=>{q("/payees",{selectedPayee:F})}),R=h.useCallback(F=>{q(`/accounts/${F}`)}),I=h.useCallback(F=>{O("schedule-edit",{id:F})});return e.jsx(ds,{ref:n,pushModal:O,transactions:s,loadMoreTransactions:o,accounts:i,categoryGroups:l,payees:c,showBalances:u,balances:d,showCleared:f,showAccount:p,showCategory:!0,currentAccountId:a&&a.id,currentCategoryId:r&&r.id,isAdding:w,isNew:x,isMatched:v,isFiltered:M,dateFormat:D,hideFraction:T,addNotification:k,headerContent:b,renderEmpty:A,onSave:j,onApplyRules:m,onSplit:S,onCloseAddTransaction:Q,onAdd:K,onAddSplit:B,onManagePayees:C,onCreatePayee:L,style:{backgroundColor:g.tableBackground},onNavigateToTransferAccount:R,onNavigateToSchedule:I,onSort:N,sortField:E,ascDesc:G})}function fr({onClose:n,filterId:t,onFilterMenuSelect:s}){return e.jsx(ht,{width:200,onClose:n,children:e.jsx(ie,{onMenuSelect:o=>{s(o)},items:t.id?t.id!==null&&t.status==="saved"?[{name:"rename-filter",text:"Rename"},{name:"delete-filter",text:"Delete"},ie.line,{name:"save-filter",text:"Save new filter",disabled:!0},{name:"clear-filter",text:"Clear all conditions"}]:[{name:"rename-filter",text:"Rename"},{name:"update-filter",text:"Update condtions"},{name:"reload-filter",text:"Revert changes"},{name:"delete-filter",text:"Delete"},ie.line,{name:"save-filter",text:"Save new filter"},{name:"clear-filter",text:"Clear all conditions"}]:[{name:"save-filter",text:"Save new filter"},{name:"clear-filter",text:"Clear all conditions"}]})})}function gr({onClose:n,menuItem:t,name:s,setName:o,adding:a,onAddUpdate:i,err:r}){const l=h.useRef(null);return h.useEffect(()=>{l.current&&l.current.focus()},[]),e.jsxs(ht,{width:325,onClose:n,children:[t!=="update-filter"&&e.jsx("form",{children:e.jsxs(Ke,{direction:"row",justify:"flex-end",align:"center",style:{padding:10},children:[e.jsxs(yo,{style:{flex:1},children:[e.jsx(bo,{title:"Filter Name",htmlFor:"name-field",style:{userSelect:"none"}}),e.jsx(Ht,{id:"name-field",inputRef:l,defaultValue:s||"",onUpdate:o})]}),e.jsx(z,{type:"primary",style:{marginTop:18},onClick:c=>{c.preventDefault(),i()},children:a?"Add":"Update"})]})}),r&&e.jsx(Ke,{direction:"row",align:"center",style:{padding:10},children:e.jsx(X,{style:{color:g.errorText},children:r})})]})}function xr({filters:n,conditionsOp:t,filterId:s,onClearFilters:o,onReloadSavedFilter:a,filtersList:i}){const[r,l]=h.useState(!1),[c,d]=h.useState(!1),[u,f]=h.useState(!1),[p,b]=h.useState(null),[w,x]=h.useState(""),[v,M]=h.useState(s.name),D=s.id;let T;const k=async A=>{switch(x(A),A){case"rename-filter":b(null),d(!1),f(!1),l(!0);break;case"delete-filter":f(!1),await Y("filter-delete",D),o();break;case"update-filter":b(null),d(!1),f(!1),T={conditions:n,conditionsOp:t,id:s.id,name:s.name,status:"saved"};const N=await xt("filter-update",{state:T,filters:[...i]});if(N.error){b(N.error.message),l(!0);return}a(T,"update");break;case"save-filter":b(null),d(!0),f(!1),l(!0);break;case"reload-filter":f(!1),T={...T,status:"saved"},a(T,"reload");break;case"clear-filter":f(!1),o();break}};async function O(){if(c){const E={conditions:n,conditionsOp:t,name:v,status:"saved"},G=await xt("filter-create",{state:E,filters:[...i]});if(G.error){b(G.error.message),l(!0);return}l(!1),a({...E,id:G.data});return}const A={conditions:s.conditions,conditionsOp:s.conditionsOp,id:s.id,name:v},N=await xt("filter-update",{state:A,filters:[...i]});if(N.error){b(N.error.message),l(!0);return}l(!1),a(A)}return e.jsxs(y,{children:[n.length>0&&e.jsxs(z,{type:"bare",style:{marginTop:10},onClick:()=>{f(!0)},children:[e.jsxs(X,{style:{maxWidth:150,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flexShrink:0},children:[s.id?s.name:"Unsaved filter"," "]}),s.id&&s.status!=="saved"&&e.jsx(X,{children:"(modified) "}),e.jsx(yn,{width:8,height:8,style:{marginRight:5}})]}),u&&e.jsx(fr,{onClose:()=>f(!1),filterId:s,onFilterMenuSelect:k}),r&&e.jsx(gr,{onClose:()=>l(!1),menuItem:w,name:v,setName:M,adding:c,onAddUpdate:O,err:p})]})}function mr({filters:n,conditionsOp:t,onUpdateFilter:s,onDeleteFilter:o,onClearFilters:a,onReloadSavedFilter:i,filterId:r,filtersList:l,onCondOpChange:c}){return e.jsx(y,{children:e.jsxs(Ke,{spacing:2,direction:"row",justify:"flex-start",align:"flex-start",children:[e.jsx(Zo,{filters:n,conditionsOp:t,onCondOpChange:c,onUpdate:s,onDelete:o}),e.jsx(y,{style:{flex:1}}),e.jsx(xr,{filters:n,conditionsOp:t,filterId:r,onClearFilters:a,onReloadSavedFilter:i,filtersList:l})]})})}function yr({getTransaction:n,onShow:t,onDuplicate:s,onDelete:o,onEdit:a,onUnlink:i,onCreateRule:r,onScheduleAction:l,pushModal:c}){const d=_t(),u=h.useMemo(()=>{const b=[...d];return{preview:!!b.find(w=>Ie(w)),trans:!!b.find(w=>!Ie(w))}},[d]),f=h.useMemo(()=>[...d].map(w=>n(w)).some(w=>w&&w.is_child),[d]),p=h.useMemo(()=>!u.preview&&[...d].every(b=>{const w=n(b);return w&&w.schedule}),[u.preview,d,n]);return e.jsx(wo,{name:"transactions",keyHandlers:u.trans&&{f:()=>t([...d]),d:()=>o([...d]),a:()=>a("account",[...d]),p:()=>a("payee",[...d]),n:()=>a("notes",[...d]),c:()=>a("category",[...d]),l:()=>a("cleared",[...d])},items:[...u.trans?[{name:"show",text:"Show",key:"F"},{name:"duplicate",text:"Duplicate",disabled:f},{name:"delete",text:"Delete",key:"D"},...p?[{name:"view-schedule",text:"View schedule",disabled:d.size>1},{name:"unlink-schedule",text:"Unlink schedule"}]:[{name:"link-schedule",text:"Link schedule"},{name:"create-rule",text:"Create rule"}],ie.line,{type:ie.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"}]:[{name:"view-schedule",text:"View schedule"},{name:"post-transaction",text:"Post transaction"},{name:"skip",text:"Skip scheduled date"}]],onSelect:b=>{switch(b){case"show":t([...d]);break;case"duplicate":s([...d]);break;case"delete":o([...d]);break;case"post-transaction":case"skip":l(b,d);break;case"view-schedule":const w=[...d][0];let x;if(Ie(w))x=w.split("/")[1];else{const v=n(w);x=v&&v.schedule}x&&c("schedule-edit",{id:x});break;case"link-schedule":c("schedule-link",{transactionIds:[...d],getTransaction:n,pushModal:c});break;case"unlink-schedule":i([...d]);break;case"create-rule":r([...d]);break;default:a(b,[...d])}}})}function Mt({name:n,balance:t,isExactBalance:s=!0}){const o=Je();return e.jsxs(X,{style:{marginLeft:15,borderRadius:4,padding:"4px 6px",color:g.pillText,backgroundColor:g.pillBackground},children:[n," ",e.jsx(vo,{children:e.jsxs(X,{style:{fontWeight:600},children:[!s&&"~ ",o(t,"financial")]})})]})}function br({selectedItems:n,account:t}){const s=`selected-balance-${[...n].join("-")}`,o=He({name:s,query:he("transactions").filter({id:{$oneof:[...n]},parent_id:{$oneof:[...n]}}).select("id")}),a=new Set((o||[]).map(p=>p.id)),i=[...n].filter(p=>!a.has(p));let r=He({name:s+"-sum",query:he("transactions").filter({id:{$oneof:i}}).options({splits:"all"}).calculate({$sum:"$amount"})}),l=null;const c=Ot(),d=c?c.schedules:[],u=[...n].filter(p=>Ie(p)).map(p=>p.slice(8));let f=!0;for(const p of d)u.includes(p.id)&&(p._amountOp==="isbetween"&&(f=!1),!t||t.id===p._account?l+=lt(p._amount):l-=lt(p._amount));if(r==null){if(l==null)return null;r=l}else l!=null&&(r+=l);return e.jsx(Mt,{name:"Selected balance:",balance:r,isExactBalance:f})}function wr({balanceQuery:n}){const t=He({name:n.name+"-cleared",query:n.query.filter({cleared:!0})}),s=He({name:n.name+"-uncleared",query:n.query.filter({cleared:!1})});return e.jsxs(y,{style:{flexDirection:"row"},children:[e.jsx(Mt,{name:"Cleared total:",balance:t}),e.jsx(Mt,{name:"Uncleared total:",balance:s})]})}function vr({balanceQuery:n,showExtraBalances:t,onToggleExtraBalances:s,account:o}){const a=_t();return e.jsxs(y,{style:{flexDirection:"row",alignItems:"center",marginTop:-5,marginLeft:-5},children:[e.jsxs(z,{"data-testid":"account-balance",type:"bare",onClick:s,style:{"& svg":{opacity:a.size>0||t?1:0},"&:hover svg":{opacity:1},paddingTop:1,paddingBottom:1},children:[e.jsx(ye,{binding:{...n,value:0},type:"financial",style:{fontSize:22,fontWeight:400},getStyle:i=>({color:i<0?g.errorText:i>0?g.noticeTextLight:g.pageTextSubdued}),privacyFilter:{blurIntensity:5}}),e.jsx(Ba,{style:{width:10,height:10,marginLeft:10,color:g.pillText,transform:t?"rotateZ(180deg)":"rotateZ(0)"}})]}),t&&e.jsx(wr,{balanceQuery:n}),a.size>0&&e.jsx(br,{selectedItems:a,account:o})]})}function Sr({balanceQuery:n,targetBalance:t,onDone:s,onCreateTransaction:o}){const a=He({name:n.name+"-cleared",value:0,query:n.query.filter({cleared:!0})}),i=Je(),r=t-a;return e.jsx(y,{style:{flexDirection:"row",alignSelf:"center",backgroundColor:g.tableBackground,...U.shadow,borderRadius:4,marginTop:5,marginBottom:15,padding:10},children:e.jsxs(y,{style:{flexDirection:"row",alignItems:"center"},children:[r===0?e.jsxs(y,{style:{color:g.noticeTextLight,flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center"},children:[e.jsx(So,{style:{width:13,height:13,color:"inherit",marginRight:3}}),"All reconciled!"]}):e.jsx(y,{style:{color:g.tableText},children:e.jsxs(X,{style:{fontStyle:"italic",textAlign:"center"},children:["Your cleared balance"," ",e.jsx("strong",{children:i(a,"financial")})," needs"," ",e.jsx("strong",{children:(r>0?"+":"")+i(r,"financial")})," ","to match",e.jsx("br",{})," your bank’s balance of"," ",e.jsx(X,{style:{fontWeight:700},children:i(t,"financial")})]})}),e.jsx(y,{style:{marginLeft:15},children:e.jsx(z,{type:"primary",onClick:s,children:"Done Reconciling"})}),r!==0&&e.jsx(y,{style:{marginLeft:15},children:e.jsx(z,{onClick:()=>o(r),children:"Create Reconciliation Transaction"})})]})})}function jr({account:n,onReconcile:t,onClose:s}){const o=jo(n),a=He({name:o.name+"-cleared",value:null,query:o.query.filter({cleared:!0})}),i=Je();function r(l){l.preventDefault();const c=l.target.elements[0],d=Co(c.value);d!=null?(t(d??a),s()):c.select()}return e.jsx(be,{position:"bottom-right",width:275,onClose:s,children:e.jsxs(y,{style:{padding:"5px 8px"},children:[e.jsx(X,{children:"Enter the current balance of your bank account that you want to reconcile with:"}),e.jsxs("form",{onSubmit:r,children:[a!=null&&e.jsx(Pn,{children:e.jsx(Ht,{defaultValue:i(a,"financial"),style:{margin:"7px 0"}})}),e.jsx(z,{type:"primary",children:"Reconcile"})]})]})})}function Cr({tableRef:n,editingName:t,isNameEditable:s,workingHard:o,accountName:a,account:i,filterId:r,filtersList:l,accountsSyncing:c,accounts:d,transactions:u,showBalances:f,showExtraBalances:p,showCleared:b,showEmptyMessage:w,balanceQuery:x,reconcileAmount:v,canCalculateBalance:M,isSorted:D,search:T,filters:k,conditionsOp:O,pushModal:A,onSearch:N,onAddTransaction:E,onShowTransactions:G,onDoneReconciling:$,onCreateReconciliationTransaction:W,onToggleExtraBalances:Q,onSaveName:L,onExposeName:H,onSync:q,onImport:K,onMenuSelect:j,onReconcile:B,onBatchDelete:S,onBatchDuplicate:m,onBatchEdit:C,onBatchUnlink:R,onCreateRule:I,onApplyFilter:F,onUpdateFilter:_,onClearFilters:J,onReloadSavedFilter:te,onCondOpChange:V,onDeleteFilter:we,onScheduleAction:Z}){const[de,le]=h.useState(!1),ve=h.useRef(null),ne=zt(),Me=In(),oe=Me!=="no-server",ge=Me==="offline",[et,Se]=fe("expand-splits");let se=i&&i.account_id&&oe;i||(se=!!d.find(ae=>!!ae.account_id)&&oe);function pt(){n.current&&(ne.dispatch({type:"switch-mode",id:n.current.getScrolledItem()}),Se(ne.state.mode!=="expand"))}return e.jsxs(e.Fragment,{children:[e.jsx(To,{keys:{"ctrl+f, cmd+f":()=>{ve.current&&ve.current.focus()}}}),e.jsxs(y,{style:{...U.pageContent,paddingBottom:10,flexShrink:0},children:[e.jsx(y,{style:{marginTop:2,marginBottom:10,alignItems:"flex-start"},children:e.jsx(y,{children:t?e.jsx(Pn,{children:e.jsx(Ht,{defaultValue:a,onEnter:ae=>L(ae.target.value),onBlur:ae=>L(ae.target.value),onEscape:()=>H(!1),style:{fontSize:25,fontWeight:500,marginTop:-5,marginBottom:-2,marginLeft:-5,paddingTop:2,paddingBottom:2}})}):s?e.jsxs(y,{style:{flexDirection:"row",alignItems:"center",gap:3,"& .hover-visible":{opacity:0,transition:"opacity .25s"},"&:hover .hover-visible":{opacity:1}},children:[e.jsx(y,{style:{fontSize:25,fontWeight:500,marginRight:5,marginBottom:-1},"data-testid":"account-name",children:i&&i.closed?"Closed: "+a:a}),i&&e.jsx(Xe,{id:`account-${i.id}`,defaultColor:g.pageTextSubdued}),e.jsx(z,{type:"bare","aria-label":"Edit account name",className:"hover-visible",onClick:()=>H(!0),children:e.jsx(Na,{style:{width:11,height:11,color:g.pageTextSubdued}})})]}):e.jsx(y,{style:{fontSize:25,fontWeight:500,marginBottom:-1},"data-testid":"account-name",children:i&&i.closed?"Closed: "+a:a})})}),e.jsx(vr,{balanceQuery:x,showExtraBalances:p,onToggleExtraBalances:Q,account:i}),e.jsxs(Ke,{spacing:2,direction:"row",align:"center",style:{marginTop:12},children:[(i&&!i.closed||se)&&e.jsx(z,{type:"bare",onClick:se?q:K,disabled:se&&ge,children:se?e.jsxs(e.Fragment,{children:[e.jsx(ko,{width:13,height:13,animating:i&&c===i.name||c==="__all",style:{marginRight:4}})," ",ge?"Sync offline":"Sync"]}):e.jsxs(e.Fragment,{children:[e.jsx(Da,{width:13,height:13,style:{marginRight:4}})," ","Import"]})}),!w&&e.jsxs(z,{type:"bare",onClick:E,children:[e.jsx(Mo,{width:10,height:10,style:{marginRight:3}})," Add New"]}),e.jsx(y,{style:{flexShrink:0},children:e.jsx(Ko,{onApply:F,type:"accounts"})}),e.jsx(y,{style:{flex:1}}),e.jsx(Sn,{placeholder:"Search",value:T,onChange:N,inputRef:ve}),o?e.jsx(y,{children:e.jsx(Ro,{style:{width:16,height:16}})}):e.jsx(yr,{getTransaction:ae=>u.find(De=>De.id===ae),onShow:G,onDuplicate:m,onDelete:S,onEdit:C,onUnlink:R,onCreateRule:I,onScheduleAction:Z,pushModal:A}),e.jsx(z,{type:"bare",disabled:T!==""||k.length>0,style:{padding:6,marginLeft:10},onClick:pt,title:ne.state.mode==="collapse"?"Collapse split transactions":"Expand split transactions",children:ne.state.mode==="collapse"?e.jsx(Ia,{style:{width:14,height:14}}):e.jsx(Pa,{style:{width:14,height:14}})}),i?e.jsxs(y,{children:[e.jsx(hn,{onClick:()=>le(!0)}),de&&e.jsx(Tr,{account:i,canSync:se,canShowBalances:M(),isSorted:D,showBalances:f,showCleared:b,onMenuSelect:ae=>{le(!1),j(ae)},onReconcile:B,onClose:()=>le(!1)})]}):e.jsxs(y,{children:[e.jsx(hn,{onClick:()=>le(!0)}),de&&e.jsx(kr,{onMenuSelect:ae=>{le(!1),j(ae)},onClose:()=>le(!1),isSorted:D})]})]}),k&&k.length>0&&e.jsx(mr,{filters:k,conditionsOp:O,onUpdateFilter:_,onDeleteFilter:we,onClearFilters:J,onReloadSavedFilter:te,filterId:r,filtersList:l,onCondOpChange:V})]}),v!=null&&e.jsx(Sr,{targetBalance:v,balanceQuery:x,onDone:$,onCreateTransaction:W})]})}function Tr({account:n,canSync:t,showBalances:s,canShowBalances:o,showCleared:a,onClose:i,isSorted:r,onReconcile:l,onMenuSelect:c}){const[d,u]=h.useState("default"),f=In();return d==="reconcile"?e.jsx(jr,{account:n,onClose:i,onReconcile:l}):e.jsx(ht,{width:200,onClose:i,children:e.jsx(ie,{onMenuSelect:p=>{p==="reconcile"?u("reconcile"):c(p)},items:[r&&{name:"remove-sorting",text:"Remove all sorting"},o&&{name:"toggle-balance",text:(s?"Hide":"Show")+" running balance"},{name:"toggle-cleared",text:(a?"Hide":"Show")+" “cleared” checkboxes"},{name:"export",text:"Export"},{name:"reconcile",text:"Reconcile"},n&&!n.closed&&(t?{name:"unlink",text:"Unlink account"}:f==="online"&&{name:"link",text:"Link account"}),n.closed?{name:"reopen",text:"Reopen account"}:{name:"close",text:"Close account"}].filter(p=>p)})})}function kr({onClose:n,onMenuSelect:t,isSorted:s}){return e.jsx(ht,{width:200,onClose:n,children:e.jsx(ie,{onMenuSelect:o=>{t(o)},items:[s&&{name:"remove-sorting",text:"Remove all sorting"},{name:"export",text:"Export"}]})})}function Mr({onAdd:n}){return e.jsx(y,{style:{color:g.tableText,backgroundColor:g.tableBackground,flex:1,alignItems:"center",borderTopWidth:1,borderColor:g.tableBorder},children:e.jsxs(y,{style:{width:550,marginTop:75,fontSize:15,alignItems:"center"},children:[e.jsxs(X,{style:{textAlign:"center",lineHeight:"1.4em"},children:["For Actual to be useful, you need to ",e.jsx("strong",{children:"add an account"}),". You can link an account to automatically download transactions, or manage it locally yourself."]}),e.jsx(z,{type:"primary",style:{marginTop:20},onClick:n,children:"Add account"}),e.jsx(y,{style:{marginTop:20,fontSize:13,color:g.tableTextLight},children:"In the future, you can add accounts from the sidebar."})]})})}function Rr({account:n={},transactions:t,balances:s,showBalances:o,filtered:a,children:i}){const{id:r}=n,l=Ot();t??=[];const c=h.useMemo(()=>l?l.schedules.filter(w=>!w.completed&&["due","upcoming","missed"].includes(l.statuses.get(w.id))):[],[l]),d=h.useMemo(()=>c.map(w=>({id:`preview/${w.id}`,payee:w._payee,account:w._account,amount:w._amount,date:w.next_date,notes:l.statuses.get(w.id),schedule:w.id,_inverse:r?r!==w._account:!1})),[c,r]);let u=h.useMemo(()=>o&&s&&t?.length>0?s[t[0].id]?.balance??0:0,[o,s,t]);const f=h.useMemo(()=>{if(!o)return null;const w=[...d].reverse().map(x=>{const v=(x._inverse?-1:1)*lt(x.amount);return{balance:u+=v,id:x.id}});return En(w)},[o,d,u]),p=h.useMemo(()=>!a&&d.length>0?d.concat(t):t,[a,d,t]),b=h.useMemo(()=>!a&&f&&s?{...f,...s}:s,[a,f,s]);return l==null?i(t,s):i(p,b)}function xn(n){switch(n){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 n}}class Ar extends h.PureComponent{constructor(t){super(t),this.paged=null,this.table=h.createRef(),this.animated=!0,this.state={search:"",filters:[],loading:!0,workingHard:!1,reconcileAmount:null,transactions:[],transactionsCount:0,showBalances:t.showBalances,balances:null,showCleared:t.showCleared,editingName:!1,isAdding:!1,latestDate:null,filterId:[],conditionsOp:"and",sort:[]}}async componentDidMount(){const t=a=>{if(a.includes("transactions")||a.includes("category_mapping")||a.includes("payee_mapping"))return this.refetchTransactions()},s=async({tables:a,messages:i})=>{await t(a);let r;if(i.every(l=>l.dataset==="transactions")&&!i.find(l=>l.column==="tombstone")){const l=i.filter(c=>c.dataset==="transactions"&&c.column!=="tombstone");r=l.length===1?l[0].row:null}this.table.current&&(this.table.current.edit(null),r&&this.table.current.scrollTo(r)),this.props.setLastUndoState(null)},o=[jt("undo-event",s)];this.unlisten=()=>{o.forEach(a=>a())},await this.props.initiallyLoadPayees(),await this.fetchTransactions(),this.props.lastUndoState&&this.props.lastUndoState.current&&s(this.props.lastUndoState.current)}componentDidUpdate(t){this.state.isAdding&&this.props.accountId!==t.accountId&&this.setState({isAdding:!1}),t.modalShowing&&!this.props.modalShowing&&setTimeout(()=>{this.refetchTransactions()},100),this.props.accountId!==t.accountId&&this.setState({sort:[],search:"",filters:[]})}componentWillUnmount(){this.unlisten&&this.unlisten(),this.paged&&this.paged.unsubscribe()}fetchAllIds=async()=>{const{data:t}=await me(this.paged.getQuery().select("id"));return t.reduce((s,o)=>(s.push(o.id),o.subtransactions.forEach(a=>s.push(a.id)),s),[])};refetchTransactions=async()=>{this.paged?.run()};fetchTransactions=()=>{const t=this.makeRootQuery();this.rootQuery=this.currentQuery=t,this.updateQuery(t),this.props.accountId&&this.props.markAccountRead(this.props.accountId)};makeRootQuery=()=>{const t=this.props.location.state,s=this.props.accountId;return t&&t.filter?he("transactions").options({splits:"grouped"}).filter({"account.offbudget":!1,...t.filter}):Ho(s)};updateQuery(t,s){this.paged&&this.paged.unsubscribe(),this.paged=$o(t.select("*"),async(o,a)=>{const i=a==null;i&&(this.table.current?.setRowAnimation(!1),s?this.props.splitsExpandedDispatch({type:"set-mode",mode:"collapse"}):this.props.splitsExpandedDispatch({type:"set-mode",mode:this.props.expandSplits?"expand":"collapse"})),this.setState({transactions:o,transactionCount:this.paged.getTotalCount(),transactionsFiltered:s,loading:!1,workingHard:!1,balances:this.state.showBalances?await this.calculateBalances():null},()=>{i&&this.table.current?.scrollToTop(),setTimeout(()=>{this.table.current?.setRowAnimation(!0)},0)})},{pageCount:150,onlySync:!0,mapper:je})}UNSAFE_componentWillReceiveProps(t){this.props.accountId!==t.accountId&&this.setState({editingName:!1,loading:!0,search:"",showBalances:t.showBalances,balances:null,showCleared:t.showCleared,reconcileAmount:null},()=>{this.fetchTransactions()})}onSearch=t=>{this.paged.unsubscribe(),this.setState({search:t},this.onSearchDone)};onSearchDone=Uo.debounce(()=>{this.state.search===""?this.updateQuery(this.currentQuery,this.state.filters.length>0):this.updateQuery(Wo(this.currentQuery,this.state.search,this.props.dateFormat),!0)},150);onSync=async()=>{const t=this.props.accountId,s=this.props.accounts.find(o=>o.id===t);await this.props.syncAndDownload(s?s.id:null)};onImport=async()=>{const t=this.props.accountId,s=this.props.accounts.find(a=>a.id===t),o=await this.props.getCategories();if(s){const a=await window.Actual.openFileDialog({filters:[{name:"Financial Files",extensions:["qif","ofx","qfx","csv","tsv"]}]});a&&this.props.pushModal("import-transactions",{accountId:t,categories:o,filename:a[0],onImported:i=>{i&&this.fetchTransactions()}})}};onExport=async t=>{const s=await Y("transactions-export-query",{query:this.currentQuery.serialize()}),a=`${t&&t.replace(/[()]/g,"").replace(/\s+/g,"-")||"transactions"}.csv`;window.Actual.saveFile(s,a,"Export Transactions")};onTransactionsChange=(t,s)=>{this.paged.optimisticUpdate(o=>t._deleted?o.filter(a=>a.id!==t.id):o.map(a=>a.id===t.id?t:a),()=>s),this.props.updateNewTransactions(t.id)};canCalculateBalance=()=>{const t=this.props.accountId;return this.props.accounts.find(o=>o.id===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;const{data:t}=await me(this.paged.getQuery().options({splits:"none"}).select([{balance:{$sumOver:"$amount"}}]));return En(t)}onAddTransaction=()=>{this.setState({isAdding:!0})};onExposeName=t=>{this.setState({editingName:t})};onSaveName=t=>{if(t.trim().length){const s=this.props.accountId,o=this.props.accounts.find(a=>a.id===s);this.props.updateAccount({...o,name:t}),this.setState({editingName:!1})}};onToggleExtraBalances=()=>{const{accountId:t,showExtraBalances:s}=this.props,o="show-extra-balances-"+t||"all-accounts";this.props.savePrefs({[o]:!s})};onMenuSelect=async t=>{const s=this.props.accountId,o=this.props.accounts.find(a=>a.id===s);switch(t){case"link":this.props.pushModal("add-account",{upgradingAccountId:s});break;case"unlink":this.props.unlinkAccount(s);break;case"close":this.props.openAccountCloseModal(s);break;case"reopen":this.props.reopenAccount(s);break;case"export":const a=this.getAccountTitle(o,s);this.onExport(a);break;case"toggle-balance":this.state.showBalances?(this.props.savePrefs({["show-balances-"+s]:!1}),this.setState({showBalances:!1,balances:null})):(this.props.savePrefs({["show-balances-"+s]:!0}),this.setState({transactions:[],transactionCount:0,filters:[],search:"",sort:[],showBalances:!0},()=>{this.fetchTransactions()}));break;case"remove-sorting":{this.setState({sort:[]},()=>{const i=this.state.filters;i.length>0?this.applyFilters([...i]):this.fetchTransactions(),this.state.search!==""&&this.onSearch(this.state.search)});break}case"toggle-cleared":this.state.showCleared?(this.props.savePrefs({["hide-cleared-"+s]:!0}),this.setState({showCleared:!1})):(this.props.savePrefs({["hide-cleared-"+s]:!1}),this.setState({showCleared:!0}));break}};getAccountTitle(t,s){const{filterName:o}=this.props.location.state||{};return o||(t?t.name:s==="budgeted"?"Budgeted Accounts":s==="offbudget"?"Off Budget Accounts":s==="uncategorized"?"Uncategorized":s?null:"All Accounts")}getBalanceQuery(t,s){return{name:`balance-query-${s}`,query:this.makeRootQuery().calculate({$sum:"$amount"})}}isNew=t=>this.props.newTransactions.includes(t);isMatched=t=>this.props.matchedTransactions.includes(t);onCreatePayee=t=>t.trim()!==""?this.props.createPayee(t):null;lockTransactions=async()=>{this.setState({workingHard:!0});const{accountId:t}=this.props,{data:s}=await me(he("transactions").filter({cleared:!0,reconciled:!1,account:t}).select("*").options({splits:"grouped"}));let o=je(s);const a={updated:[]};o.forEach(i=>{const{diff:r}=it(o,{...i,reconciled:!0});o=tt(r,o),a.updated=a.updated?a.updated.concat(r.updated):r.updated}),await Y("transactions-batch-update",a),await this.refetchTransactions()};onReconcile=async t=>{this.setState({reconcileAmount:t})};onDoneReconciling=async()=>{const{accountId:t}=this.props,{reconcileAmount:s}=this.state,{data:o}=await me(he("transactions").filter({cleared:!0,account:t}).select("*").options({splits:"grouped"})),a=je(o);let i=0;a.forEach(l=>{l.is_parent||(i+=l.amount)}),s-i===0&&await this.lockTransactions(),this.setState({reconcileAmount:null})};onCreateReconciliationTransaction=async t=>{const s=Ct([{id:"temp",account:this.props.accountId,cleared:!0,reconciled:!1,amount:t,date:Lt(),notes:"Reconciliation balance adjustment"}]);this.setState({transactions:[...s,...this.state.transactions]}),await Y("transactions-batch-update",{added:s}),await this.refetchTransactions()};onShowTransactions=async t=>{this.onApplyFilter({customName:"Selected transactions",filter:{id:{$oneof:t}}})};onBatchEdit=async(t,s)=>{const o=async(a,i)=>{this.setState({workingHard:!0});const{data:r}=await me(he("transactions").filter({id:{$oneof:s}}).select("*").options({splits:"grouped"}));let l=je(r);const c={deleted:[],updated:[]};a==="cleared"&&(i=!!l.find(u=>!u.cleared));const d=new Set(s);l.forEach(u=>{if(a==="cleared"&&u.reconciled||!d.has(u.id))return;const f={...u,[a]:i};a==="account"&&u.account!==i&&(f.reconciled=!1);const{diff:p}=it(l,f);l=tt(p,l),c.deleted=c.deleted?c.deleted.concat(p.deleted):p.deleted,c.updated=c.updated?c.updated.concat(p.updated):p.updated,c.added=c.added?c.added.concat(p.added):p.added}),await Y("transactions-batch-update",c),await this.refetchTransactions(),this.table.current&&this.table.current.edit(l[0].id,"select",!1)};if(t==="amount"||t==="payee"||t==="account"||t==="date"){const{data:a}=await me(he("transactions").filter({id:{$oneof:s},reconciled:!0}).select("*").options({splits:"grouped"}));if(je(a).length>0){this.props.pushModal("confirm-transaction-edit",{onConfirm:()=>{this.props.pushModal("edit-field",{name:t,onSubmit:o})},confirmReason:"batchEditWithReconciled"});return}}t==="cleared"?o("cleared",null):this.props.pushModal("edit-field",{name:t,onSubmit:o})};onBatchDuplicate=async t=>{const s=async o=>{this.setState({workingHard:!0});const{data:a}=await me(he("transactions").filter({id:{$oneof:o}}).select("*").options({splits:"grouped"})),i={added:a.reduce((r,l)=>r.concat(Ct(zo(l))),[]).map(({sort_order:r,...l})=>({...l}))};await Y("transactions-batch-update",i),await this.refetchTransactions()};await this.checkForReconciledTransactions(t,"batchDuplicateWithReconciled",s)};onBatchDelete=async t=>{const s=async o=>{this.setState({workingHard:!0});const{data:a}=await me(he("transactions").filter({id:{$oneof:o}}).select("*").options({splits:"grouped"}));let i=je(a);const r=new Set(o),l={deleted:[],updated:[]};i.forEach(c=>{const d=c.parent_id;if(!r.has(c.id)||d&&r.has(d))return;const{diff:u}=kn(i,c.id);i=tt(u,i),l.deleted=u.deleted?l.deleted.concat(u.deleted):u.deleted,l.updated=u.updated?l.updated.concat(u.updated):u.updated}),await Y("transactions-batch-update",l),await this.refetchTransactions()};await this.checkForReconciledTransactions(t,"batchDeleteWithReconciled",s)};checkForReconciledTransactions=async(t,s,o)=>{const{data:a}=await me(he("transactions").filter({id:{$oneof:t},reconciled:!0}).select("*").options({splits:"grouped"}));je(a).length>0?this.props.pushModal("confirm-transaction-edit",{onConfirm:()=>{o(t)},confirmReason:s}):o(t)};onBatchUnlink=async t=>{await Y("transactions-batch-update",{updated:t.map(s=>({id:s,schedule:null}))}),await this.refetchTransactions()};onCreateRule=async t=>{const{data:s}=await me(he("transactions").filter({id:{$oneof:t}}).select("*").options({splits:"grouped"})),o=je(s),i={stage:null,conditionsOp:"and",conditions:[o[0].imported_payee?{field:"imported_payee",op:"is",value:o[0].imported_payee,type:"string"}:{field:"payee",op:"is",value:o[0].payee,type:"id"}],actions:[{op:"set",field:"category",value:o[0].category,type:"id"}]};this.props.pushModal("edit-rule",{rule:i})};onCondOpChange=(t,s)=>{this.setState({conditionsOp:t}),this.setState({filterId:{...this.state.filterId,status:"changed"}}),this.applyFilters([...s]),this.state.search!==""&&this.onSearch(this.state.search)};onReloadSavedFilter=(t,s)=>{if(s==="reload"){const[o]=this.props.filtersList.filter(a=>a.id===this.state.filterId.id);this.setState({conditionsOp:o.conditionsOp}),this.applyFilters([...o.conditions])}else t.status&&(this.setState({conditionsOp:t.conditionsOp}),this.applyFilters([...t.conditions]));this.setState({filterId:{...this.state.filterId,...t}})};onClearFilters=()=>{this.setState({conditionsOp:"and"}),this.setState({filterId:[]}),this.applyFilters([]),this.state.search!==""&&this.onSearch(this.state.search)};onUpdateFilter=(t,s)=>{this.applyFilters(this.state.filters.map(o=>o===t?s:o)),this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}}),this.state.search!==""&&this.onSearch(this.state.search)};onDeleteFilter=t=>{this.applyFilters(this.state.filters.filter(s=>s!==t)),this.state.filters.length===1?(this.setState({filterId:[]}),this.setState({conditionsOp:"and"})):this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}}),this.state.search!==""&&this.onSearch(this.state.search)};onApplyFilter=async t=>{let s=this.state.filters;t.customName&&(s=s.filter(o=>o.customName!==t.customName)),t.conditions?(this.setState({filterId:{...t,status:"saved"}}),this.setState({conditionsOp:t.conditionsOp}),this.applyFilters([...t.conditions])):(this.setState({filterId:{...this.state.filterId,status:this.state.filterId&&"changed"}}),this.applyFilters([...s,t])),this.state.search!==""&&this.onSearch(this.state.search)};onScheduleAction=async(t,s)=>{switch(t){case"post-transaction":for(const o of s){const a=o.split("/");await Y("schedule/post-transaction",{id:a[1]})}this.refetchTransactions();break;case"skip":for(const o of s){const a=o.split("/");await Y("schedule/skip-next-date",{id:a[1]})}break}};applyFilters=async t=>{if(t.length>0){const s=t.filter(i=>!!i.customName).map(i=>i.filter),{filters:o}=await Y("make-filters-from-conditions",{conditions:t.filter(i=>!i.customName)}),a=this.state.conditionsOp==="or"?"$or":"$and";this.currentQuery=this.rootQuery.filter({[a]:[...o,...s]}),this.setState({filters:t},()=>{this.updateQuery(this.currentQuery,!0)})}else this.setState({transactions:[],transactionCount:0,filters:t},()=>{this.fetchTransactions()});this.state.sort.length!==0&&this.applySort()};applySort=(t,s,o,a)=>{const i=this.state.filters,r=i.length>0,l=xn(t||this.state.sort.field),c=s||this.state.sort.ascDesc,d=xn(o||this.state.sort.prevField),u=o?a:this.state.sort.prevAscDesc,f=function(w,x,v){x==="cleared"&&(w.currentQuery=w.currentQuery.orderBy({reconciled:v})),w.currentQuery=w.currentQuery.orderBy({[x]:v})},p=function(w,x,v){x==="cleared"?(w.currentQuery=w.rootQuery.orderBy({reconciled:v}),w.currentQuery=w.currentQuery.orderBy({cleared:v})):w.currentQuery=w.rootQuery.orderBy({[x]:v})},b=function(w,x,v){x&&(x==="cleared"&&(w.currentQuery=w.currentQuery.orderBy({reconciled:v})),w.currentQuery=w.currentQuery.orderBy({[x]:v}))};switch(!0){case!t:f(this,l,c);break;case r:this.applyFilters([...i]),f(this,l,c);break;case!r:p(this,l,c);break}b(this,d,u),this.updateQuery(this.currentQuery,r)};onSort=(t,s)=>{let o,a;t===this.state.sort.field?(o=this.state.sort.prevField,a=this.state.sort.prevAscDesc,this.setState({sort:{...this.state.sort,ascDesc:s}})):(o=this.state.sort.field,a=this.state.sort.ascDesc,this.setState({sort:{field:t,ascDesc:s,prevField:this.state.sort.field,prevAscDesc:this.state.sort.ascDesc}})),this.applySort(t,s,o,a),this.state.search!==""&&this.onSearch(this.state.search)};render(){const{accounts:t,categoryGroups:s,payees:o,dateFormat:a,hideFraction:i,addNotification:r,accountsSyncing:l,pushModal:c,replaceModal:d,showExtraBalances:u,accountId:f,categoryId:p}=this.props,{transactions:b,loading:w,workingHard:x,filterId:v,reconcileAmount:M,transactionsFiltered:D,editingName:T,showBalances:k,balances:O,showCleared:A}=this.state,N=t.find(L=>L.id===f),E=this.getAccountTitle(N,f);if(!E&&!w)return e.jsx(Go,{to:"/accounts",replace:!0});const G=s.flatMap(L=>L.categories).find(L=>L.id===p),$=!w&&!f&&t.length===0,W=f&&f!=="budgeted"&&f!=="offbudget"&&f!=="uncategorized",Q=this.getBalanceQuery(N,f);return e.jsx(Rr,{account:N,transactions:b,balances:O,showBalances:k,filtered:D,children:(L,H)=>e.jsx(qo,{name:"transactions",items:L,fetchAllIds:this.fetchAllIds,registerDispatch:q=>this.dispatchSelected=q,selectAllFilter:q=>!q._unmatched&&!q.is_parent,children:e.jsxs(y,{style:U.page,children:[e.jsx(Cr,{tableRef:this.table,editingName:T,isNameEditable:W,workingHard:x,account:N,filterId:v,filtersList:this.props.filtersList,location:this.props.location,accountName:E,accountsSyncing:l,accounts:t,transactions:b,showBalances:k,showExtraBalances:u,showCleared:A,showEmptyMessage:$,balanceQuery:Q,canCalculateBalance:this.canCalculateBalance,isSorted:this.state.sort.length!==0,reconcileAmount:M,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}),e.jsx(y,{style:{flex:1},children:e.jsx(pr,{tableRef:this.table,account:N,transactions:b,allTransactions:L,animated:this.animated,loadMoreTransactions:()=>this.paged&&this.paged.fetchNext(),accounts:t,category:G,categoryGroups:s,payees:o,balances:H,showBalances:!!H,showCleared:A,showAccount:!f||f==="offbudget"||f==="budgeted"||f==="uncategorized",isAdding:this.state.isAdding,isNew:this.isNew,isMatched:this.isMatched,isFiltered:this.state.search!==""||this.state.filters.length>0,dateFormat:a,hideFraction:i,addNotification:r,renderEmpty:()=>$?e.jsx(Mr,{onAdd:()=>d("add-account")}):w?null:e.jsx(y,{style:{color:g.tableText,marginTop:20,textAlign:"center",fontStyle:"italic"},children:"No transactions"}),pushModal:c,onSort:this.onSort,sortField:this.state.sort.field,ascDesc:this.state.sort.ascDesc,onChange:this.onTransactionsChange,onRefetch:this.refetchTransactions,onRefetchUpToRow:q=>this.paged.refetchUpToRow(q,{field:"date",order:"desc"}),onCloseAddTransaction:()=>this.setState({isAdding:!1}),onCreatePayee:this.onCreatePayee})})]})})})}}function Br(n){const{dispatch:t}=zt(),s=Oo(n.location.pathname);return e.jsx(Ar,{...n,match:s,splitsExpandedDispatch:t})}function _r(){const n=Ao(),t=Bo(),{grouped:s}=vn(),o=Ne(A=>A.queries.newTransactions),a=Ne(A=>A.queries.matchedTransactions),i=Po(),r=Io(),l=Eo(),c=Do()||"MM/dd/yyyy",[d=!1]=fe("hideFraction"),[u]=fe("expand-splits"),[f]=fe(`show-balances-${n.id}`),[p]=fe(`hide-cleared-${n.id}`),[b]=fe(`show-extra-balances-${n.id||"all-accounts"}`),w=Ne(A=>A.modals.modalStack.length>0),x=Ne(A=>A.account.accountsSyncing),v=Ne(A=>A.app.lastUndoState),M={newTransactions:o,matchedTransactions:a,accounts:i,failedAccounts:l,dateFormat:c,hideFraction:d,expandSplits:u,showBalances:f,showCleared:!p,showExtraBalances:b,payees:r,modalShowing:w,accountsSyncing:x,lastUndoState:v},D=Nt(),T=Fo(),k=h.useMemo(()=>No(_o,D),[D]),O=h.useMemo(()=>{let A=un(n.id,"_account"),N=un(n.id,"_payee.transfer_acct");return(t.state&&t.state.filter||n.id==="uncategorized")&&(A={id:null},N={id:null}),E=>(E=E.filter({$and:[{"_account.closed":!1}],$or:[A,N]}),E.orderBy({next_date:"desc"}))},[n.id]);return e.jsx(Lo,{transform:O,children:e.jsx(rr,{initialMode:M.expandSplits?"collapse":"expand",children:e.jsx(Br,{...M,categoryGroups:s,...k,modalShowing:M.modalShowing,accountId:n.id,categoryId:t?.state?.filter?.category,location:t,filtersList:T})})})}export{_r as Account,_r as Accounts,Dr as Budget,Nr as GoCardlessLink,Fr as Schedules};
|
|
2
|
-
//# sourceMappingURL=wide.Puo4nQYF.chunk.js.map
|