diff --git a/README.md b/README.md index 1544601..0f2113d 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,18 @@ https://forevermatt.github.io/svelte-budget/ - [ ] Edit a financial account - [x] Record an expense - [x] Create separate repo to document data structure versions +- [x] Subtract the transaction amount from a category's budget upon completion + of recording an expense +- [ ] Move assembly of new transaction to separate local variable (to simplify + process of updating remaining amounts for budget categories, both for + when creating a new transaction and when editing an existing transaction) +- [ ] Enable seeing a category's transactions +- [ ] Update Category view to show both budgeted and remaining amounts +- [ ] Add "next" buttons to allow progressing through record-an-expense using + a mouse - [x] Autofocus the appropriate input (where applicable) on arrival at each page +- [ ] Allow adding a comment/note on each transaction - [ ] ... ## Data Structure diff --git a/assets/bundle.js b/assets/bundle.js index 130bae3..af4dcd4 100644 --- a/assets/bundle.js +++ b/assets/bundle.js @@ -1 +1 @@ -var app=function(){"use strict";function t(){}function e(t,e){for(const n in e)t[n]=e[n];return t}function n(t){return t()}function r(){return Object.create(null)}function o(t){t.forEach(n)}function s(t){return"function"==typeof t}function c(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function u(e,...n){if(null==e)return t;const r=e.subscribe(...n);return r.unsubscribe?()=>r.unsubscribe():r}function a(t){let e;return u(t,t=>e=t)(),e}function i(t,e,n){t.$$.on_destroy.push(u(e,n))}function l(t,e,n,r){if(t){const o=f(t,e,n,r);return t[0](o)}}function f(t,n,r,o){return t[1]&&o?e(r.ctx.slice(),t[1](o(n))):r.ctx}function $(t,e,n,r,o,s,c){const u=function(t,e,n,r){if(t[2]&&r){const o=t[2](r(n));if(void 0===e.dirty)return o;if("object"==typeof o){const t=[],n=Math.max(e.dirty.length,o.length);for(let r=0;rt.removeEventListener(e,n,r)}function C(t){return function(e){return e.preventDefault(),t.call(this,e)}}function A(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function _(t,e){e=""+e,t.data!==e&&(t.data=e)}function N(t,e){t.value=null==e?"":e}function j(t,e,n,r){t.style.setProperty(e,n,r?"important":"")}function M(t,e,n){t.classList[n?"add":"remove"](e)}let O;function S(t){O=t}function L(){if(!O)throw new Error("Function called outside component initialization");return O}function D(t){L().$$.on_mount.push(t)}function H(){const t=L();return(e,n)=>{const r=t.$$.callbacks[e];if(r){const o=function(t,e){const n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!1,!1,e),n}(e,n);r.slice().forEach(e=>{e.call(t,o)})}}}function T(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(t=>t(e))}const V=[],z=[],R=[],P=[],I=Promise.resolve();let B=!1;function F(){B||(B=!0,I.then(W))}function q(){return F(),I}function U(t){R.push(t)}let Y=!1;const J=new Set;function W(){if(!Y){Y=!0;do{for(let t=0;t{K.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function nt(t,e){t.d(1),e.delete(t.key)}function rt(t,e,n,r,o,s,c,u,a,i,l,f){let $=t.length,d=s.length,p=$;const m={};for(;p--;)m[t[p].key]=p;const g=[],h=new Map,y=new Map;for(p=d;p--;){const t=f(o,s,p),u=n(t);let a=c.get(u);a?r&&a.p(t,e):(a=i(u,t),a.c()),h.set(u,g[p]=a),u in m&&y.set(u,Math.abs(p-m[u]))}const b=new Set,x=new Set;function w(t){tt(t,1),t.m(u,l),c.set(t.key,t),l=t.first,d--}for(;$&&d;){const e=g[d-1],n=t[$-1],r=e.key,o=n.key;e===n?(l=e.first,$--,d--):h.has(o)?!c.has(r)||b.has(r)?w(e):x.has(o)?$--:y.get(r)>y.get(o)?(x.add(r),w(e)):(b.add(o),$--):(a(n,c),$--)}for(;$--;){const e=t[$];h.has(e.key)||a(e,c)}for(;d;)w(g[d-1]);return g}function ot(t){t&&t.c()}function st(t,e,r){const{fragment:c,on_mount:u,on_destroy:a,after_update:i}=t.$$;c&&c.m(e,r),U(()=>{const e=u.map(n).filter(s);a?a.push(...e):o(e),t.$$.on_mount=[]}),i.forEach(U)}function ct(t,e){const n=t.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function ut(e,n,s,c,u,a,i=[-1]){const l=O;S(e);const f=n.props||{},$=e.$$={fragment:null,ctx:null,props:a,update:t,not_equal:u,bound:r(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(l?l.$$.context:[]),callbacks:r(),dirty:i};let d=!1;if($.ctx=s?s(e,f,(t,n,...r)=>{const o=r.length?r[0]:n;return $.ctx&&u($.ctx[t],$.ctx[t]=o)&&($.bound[t]&&$.bound[t](o),d&&function(t,e){-1===t.$$.dirty[0]&&(V.push(t),F(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(){}}const it=(t,e)=>{e.update(e=>[t,...e])},lt=(t,e,n,r)=>{r.update(r=>{const o=r.find(n=>n[t]===e),s=Object.assign({},o,n);let c=!1;for(let n=0;n{const e=dt(t);return ft(e)?e:[]},dt=t=>{const e=localStorage.getItem(t);return JSON.parse(e)},pt=(t,e)=>{localStorage.setItem(t,JSON.stringify(e))},mt=[];function gt(t,e){return{subscribe:ht(t,e).subscribe}}function ht(e,n=t){let r;const o=[];function s(t){if(c(e,t)&&(e=t,r)){const t=!mt.length;for(let t=0;t{const t=o.indexOf(a);-1!==t&&o.splice(t,1),0===o.length&&(r(),r=null)}}}}function yt(e,n,r){const c=!Array.isArray(e),a=c?[e]:e,i=n.length<2;return gt(r,e=>{let r=!1;const l=[];let f=0,$=t;const d=()=>{if(f)return;$();const r=n(c?l[0]:l,e);i?e(r):$=s(r)?r:t},p=a.map((t,e)=>u(t,t=>{l[e]=t,f&=~(1<{f|=1<Ct.set("");function _t(t){let e,n,r,o,s,c;return{c(){e=b("div"),n=b("button"),n.innerHTML='',r=v(),o=w(t[0]),A(n,"type","button"),A(n,"class","close"),A(n,"aria-label","Close"),A(e,"class","alert alert-danger keep-line-breaks svelte-1anyckn"),A(e,"role","alert")},m(t,u){g(t,e,u),m(e,n),m(e,r),m(e,o),s||(c=k(n,"click",At),s=!0)},p(t,e){1&e&&_(o,t[0])},d(t){t&&h(e),s=!1,c()}}}function Nt(e){let n,r=e[0]&&_t(e);return{c(){r&&r.c(),n=E()},m(t,e){r&&r.m(t,e),g(t,n,e)},p(t,[e]){t[0]?r?r.p(t,e):(r=_t(t),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:t,o:t,d(t){r&&r.d(t),t&&h(n)}}}function jt(t,e,n){let r;return i(t,Ct,t=>n(0,r=t)),[r]}window.onunhandledrejection=t=>{let e=t.reason;Ct.set(e.message)};class Mt extends at{constructor(t){super(),ut(this,t,jt,Nt,c,{})}}const Ot=ht([]),St=()=>pt("accounts",a(Ot)),Lt=ht([]),Dt=(t,e)=>e.find(e=>e.uuid===t)||{},Ht=()=>pt("categories",a(Lt)),Tt=t=>{let e=new Date(t);const n=e.getFullYear(),r=e.getMonth()+1,o=e.getDate();return`${n}-${String(r).padStart(2,"0")}-${String(o).padStart(2,"0")}`},Vt=(t,e)=>{var n=e.getFullYear(),r=e.getMonth(),o=new Date(n,r-t),s=o.getFullYear(),c=o.getMonth()+1;return s+"-"+String("0"+c).slice(-2)},zt=ht({}),Rt=t=>(a(zt)[t]||{}).budgeted||0,Pt=()=>{zt.set((t=>{const e=dt(t);return null!==e?e:{}})("budget"))},It=(t,e)=>{a(zt);(t=>a(zt).hasOwnProperty(t))(t)?Ft(t,e):((t,e)=>{Bt(t,{budgeted:e,remaining:e,refilled:Vt(0,new Date)})})(t,e)},Bt=(t,e)=>{((t,e,n)=>{n.update(n=>(n.hasOwnProperty(t)?n[t]=Object.assign(n[t],e):n[t]=e,n))})(t,e,zt),pt("budget",a(zt))},Ft=(t,e)=>{let n=a(zt)[t],r=n.budgeted,o=n.remaining;Bt(t,{budgeted:e,remaining:o+(e-r)})},qt=ht([]),Ut=(t,e)=>e.find(e=>e.uuid===t)||{},Yt=()=>pt("transactions",a(qt)),Jt=(t,e)=>{lt("uuid",t,e,qt),Yt()};function Wt(t){let e,n,r;var o=t[0];return o&&(e=new o({}),e.$on("routeEvent",t[5])),{c(){e&&ot(e.$$.fragment),n=E()},m(t,o){e&&st(e,t,o),g(t,n,o),r=!0},p(t,r){if(o!==(o=t[0])){if(e){X();const t=e;et(t.$$.fragment,1,0,()=>{ct(t,1)}),Z()}o?(e=new o({}),e.$on("routeEvent",t[5]),ot(e.$$.fragment),tt(e.$$.fragment,1),st(e,n.parentNode,n)):e=null}},i(t){r||(e&&tt(e.$$.fragment,t),r=!0)},o(t){e&&et(e.$$.fragment,t),r=!1},d(t){t&&h(n),e&&ct(e,t)}}}function Gt(t){let e,n,r;var o=t[0];function s(t){return{props:{params:t[1]}}}return o&&(e=new o(s(t)),e.$on("routeEvent",t[4])),{c(){e&&ot(e.$$.fragment),n=E()},m(t,o){e&&st(e,t,o),g(t,n,o),r=!0},p(t,r){const c={};if(2&r&&(c.params=t[1]),o!==(o=t[0])){if(e){X();const t=e;et(t.$$.fragment,1,0,()=>{ct(t,1)}),Z()}o?(e=new o(s(t)),e.$on("routeEvent",t[4]),ot(e.$$.fragment),tt(e.$$.fragment,1),st(e,n.parentNode,n)):e=null}else o&&e.$set(c)},i(t){r||(e&&tt(e.$$.fragment,t),r=!0)},o(t){e&&et(e.$$.fragment,t),r=!1},d(t){t&&h(n),e&&ct(e,t)}}}function Kt(t){let e,n,r,o;const s=[Gt,Wt],c=[];function u(t,e){return t[1]?0:1}return e=u(t),n=c[e]=s[e](t),{c(){n.c(),r=E()},m(t,n){c[e].m(t,n),g(t,r,n),o=!0},p(t,[o]){let a=e;e=u(t),e===a?c[e].p(t,o):(X(),et(c[a],1,1,()=>{c[a]=null}),Z(),n=c[e],n||(n=c[e]=s[e](t),n.c()),tt(n,1),n.m(r.parentNode,r))},i(t){o||(tt(n),o=!0)},o(t){et(n),o=!1},d(t){c[e].d(t),t&&h(r)}}}function Qt(){const t=window.location.href.indexOf("#/");let e=t>-1?window.location.href.substr(t+1):"/";const n=e.indexOf("?");let r="";return n>-1&&(r=e.substr(n+1),e=e.substr(0,n)),{location:e,querystring:r}}const Xt=gt(null,(function(t){t(Qt());const e=()=>{t(Qt())};return window.addEventListener("hashchange",e,!1),function(){window.removeEventListener("hashchange",e,!1)}}));yt(Xt,t=>t.location),yt(Xt,t=>t.querystring);function Zt(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");return q().then(()=>{window.location.hash=("#"==t.charAt(0)?"":"#")+t})}function te(e,n,r){let o,s=t;i(e,Xt,t=>r(6,o=t)),e.$$.on_destroy.push(()=>s());let{routes:c={}}=n,{prefix:u=""}=n;class a{constructor(t,e){if(!e||"function"!=typeof e&&("object"!=typeof e||!0!==e._sveltesparouter))throw Error("Invalid component object");if(!t||"string"==typeof t&&(t.length<1||"/"!=t.charAt(0)&&"*"!=t.charAt(0))||"object"==typeof t&&!(t instanceof RegExp))throw Error('Invalid value for "path" argument');const{pattern:n,keys:r}=function(t,e){if(t instanceof RegExp)return{keys:!1,pattern:t};var n,r,o,s,c=[],u="",a=t.split("/");for(a[0]||a.shift();o=a.shift();)"*"===(n=o[0])?(c.push("wild"),u+="/(.*)"):":"===n?(r=o.indexOf("?",1),s=o.indexOf(".",1),c.push(o.substring(1,~r?r:~s?s:o.length)),u+=~r&&!~s?"(?:/([^/]+?))?":"/([^/]+?)",~s&&(u+=(~r?"?":"")+"\\"+o.substring(s))):u+="/"+o;return{keys:c,pattern:new RegExp("^"+u+(e?"(?=$|/)":"/?$"),"i")}}(t);this.path=t,"object"==typeof e&&!0===e._sveltesparouter?(this.component=e.route,this.conditions=e.conditions||[],this.userData=e.userData):(this.component=e,this.conditions=[],this.userData=void 0),this._pattern=n,this._keys=r}match(t){u&&t.startsWith(u)&&(t=t.substr(u.length)||"/");const e=this._pattern.exec(t);if(null===e)return null;if(!1===this._keys)return e;const n={};let r=0;for(;r{l.push(new a(e,t))}):Object.keys(c).forEach(t=>{l.push(new a(t,c[t]))});let f=null,$=null;const d=H(),p=(t,e)=>{q().then(()=>{d(t,e)})};return e.$set=t=>{"routes"in t&&r(2,c=t.routes),"prefix"in t&&r(3,u=t.prefix)},e.$$.update=()=>{if(65&e.$$.dirty){r(0,f=null);let t=0;for(;!f&&t{"autofocusElement"in t&&n(0,r=t.autofocusElement),"$$scope"in t&&n(1,s=t.$$scope)},t.$$.update=()=>{1&t.$$.dirty&&r.focus&&r.focus()},[r,s,o,function(e){T(t,e)}]}class oe extends at{constructor(t){super(),ut(this,t,re,ne,c,{autofocusElement:0})}}function se(t){let e,n,r;return{c(){e=b("input"),A(e,"class","form-control"),A(e,"placeholder","New account name")},m(o,s){g(o,e,s),N(e,t[0]),t[4](e),n||(r=k(e,"input",t[3]),n=!0)},p(t,n){1&n&&e.value!==t[0]&&N(e,t[0])},d(o){o&&h(e),t[4](null),n=!1,r()}}}function ce(t){let e,n,r,o;return r=new oe({props:{autofocusElement:t[1],$$slots:{default:[se]},$$scope:{ctx:t}}}),r.$on("submit",t[2]),{c(){e=b("h2"),e.textContent="New Account",n=v(),ot(r.$$.fragment)},m(t,s){g(t,e,s),g(t,n,s),st(r,t,s),o=!0},p(t,[e]){const n={};2&e&&(n.autofocusElement=t[1]),35&e&&(n.$$scope={dirty:e,ctx:t}),r.$set(n)},i(t){o||(tt(r.$$.fragment,t),o=!0)},o(t){et(r.$$.fragment,t),o=!1},d(t){t&&h(e),t&&h(n),ct(r,t)}}}function ue(t,e,n){let r="",o={};return[r,o,function(){(t=>{const e={uuid:kt(),name:t};it(e,Ot),St()})(r),Zt("/accounts")},function(){r=this.value,n(0,r)},function(t){z[t?"unshift":"push"](()=>{o=t,n(1,o)})}]}function ae(e){let n,r,o;return{c(){n=x("svg"),r=x("path"),A(r,"fill","currentColor"),A(r,"d",e[0]),A(n,"aria-hidden","true"),A(n,"class",o=p(e[1])+" svelte-1d15yci"),A(n,"role","img"),A(n,"xmlns","http://www.w3.org/2000/svg"),A(n,"viewBox",e[2])},m(t,e){g(t,n,e),m(n,r)},p(t,[e]){1&e&&A(r,"d",t[0]),2&e&&o!==(o=p(t[1])+" svelte-1d15yci")&&A(n,"class",o),4&e&&A(n,"viewBox",t[2])},i:t,o:t,d(t){t&&h(n)}}}function ie(t,n,r){let{icon:o}=n,s=[],c="",u="";return t.$set=t=>{r(4,n=e(e({},n),d(t))),"icon"in t&&r(3,o=t.icon)},t.$$.update=()=>{8&t.$$.dirty&&r(2,u="0 0 "+o.icon[0]+" "+o.icon[1]),r(1,c="fa-svelte "+(n.class?n.class:"")),8&t.$$.dirty&&r(0,s=o.icon[4])},n=d(n),[s,c,u,o]}class le extends at{constructor(t){super(),ut(this,t,ie,ae,c,{icon:3})}}function fe(t){let e,n,r;return e=new le({props:{icon:t[0]}}),{c(){ot(e.$$.fragment),n=v()},m(t,o){st(e,t,o),g(t,n,o),r=!0},p(t,n){const r={};1&n&&(r.icon=t[0]),e.$set(r)},i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){et(e.$$.fragment,t),r=!1},d(t){ct(e,t),t&&h(n)}}}function $e(t){let e,n,r,o,s,c,u,a,i,l,f=t[0]&&fe(t);return{c(){e=b("a"),n=b("span"),f&&f.c(),r=b("br"),o=v(),s=b("br"),c=v(),u=w(t[1]),A(n,"class","button-circle svelte-2b5sup"),A(e,"id",a="button-"+t[1]),A(e,"class","btn svelte-2b5sup"),A(e,"href",i=t[3]||"javascript:void(0)"),A(e,"role","button"),M(e,"float-left",t[2])},m(t,a){g(t,e,a),m(e,n),f&&f.m(n,null),m(n,r),m(n,o),m(e,s),m(e,c),m(e,u),l=!0},p(t,[o]){t[0]?f?(f.p(t,o),1&o&&tt(f,1)):(f=fe(t),f.c(),tt(f,1),f.m(n,r)):f&&(X(),et(f,1,1,()=>{f=null}),Z()),(!l||2&o)&&_(u,t[1]),(!l||2&o&&a!==(a="button-"+t[1]))&&A(e,"id",a),(!l||8&o&&i!==(i=t[3]||"javascript:void(0)"))&&A(e,"href",i),4&o&&M(e,"float-left",t[2])},i(t){l||(tt(f),l=!0)},o(t){et(f),l=!1},d(t){t&&h(e),f&&f.d()}}}function de(t,e,n){let{icon:r}=e,{name:o}=e,{left:s=!1}=e,{url:c=""}=e;return t.$set=t=>{"icon"in t&&n(0,r=t.icon),"name"in t&&n(1,o=t.name),"left"in t&&n(2,s=t.left),"url"in t&&n(3,c=t.url)},[r,o,s,c]}class pe extends at{constructor(t){super(),ut(this,t,de,$e,c,{icon:0,name:1,left:2,url:3})}}function me(t){let e,n,r,o,s,c;const u=t[1].default,a=l(u,t,t[0],null);return{c(){e=b("div"),n=v(),r=b("div"),a&&a.c(),o=v(),s=b("div"),A(e,"id","button-row-spacer"),A(e,"class","svelte-17rvsyv"),A(s,"class","clearfix"),A(r,"id","button-row"),A(r,"class","svelte-17rvsyv")},m(t,u){g(t,e,u),g(t,n,u),g(t,r,u),a&&a.m(r,null),m(r,o),m(r,s),c=!0},p(t,[e]){a&&a.p&&1&e&&$(a,u,t,t[0],e,null,null)},i(t){c||(tt(a,t),c=!0)},o(t){et(a,t),c=!1},d(t){t&&h(e),t&&h(n),t&&h(r),a&&a.d(t)}}}function ge(t,e,n){let{$$slots:r={},$$scope:o}=e;return t.$set=t=>{"$$scope"in t&&n(0,o=t.$$scope)},[o,r]}class he extends at{constructor(t){super(),ut(this,t,ge,me,c,{})}}var ye={prefix:"fas",iconName:"home",icon:[576,512,[],"f015","M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"]},be={prefix:"fas",iconName:"list-ul",icon:[512,512,[],"f0ca","M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"]},xe={prefix:"fas",iconName:"minus",icon:[448,512,[],"f068","M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"]};function we(t,e,n){const r=t.slice();return r[1]=e[n],r}function ve(t){let e,n,r=t[1].name+"";return{c(){e=b("li"),n=w(r)},m(t,r){g(t,e,r),m(e,n)},p(t,e){1&e&&r!==(r=t[1].name+"")&&_(n,r)},d(t){t&&h(e)}}}function Ee(e){let n,r;return n=new pe({props:{icon:ye,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function ke(t){let e,n,r,o,s,c,u,a,i=t[0],l=[];for(let e=0;eAdd new account',c=v(),ot(u.$$.fragment)},m(t,i){g(t,e,i),g(t,n,i),g(t,r,i);for(let t=0;tn(0,r=t)),[r]}const Ae=t=>Me(t)?"danger":"",_e=t=>je(t,2),Ne=t=>je(t,0),je=(t,e)=>(null==t&&(t=0),(Number(t)/100).toFixed(e)),Me=t=>t&&t<0;function Oe(e){let n,r,o,s;return{c(){n=b("div"),r=b("div"),A(r,"class",o="category-graph-line "+e[2](e[1],e[0])+" svelte-6b2uyp"),j(r,"width",e[3](e[1],e[0])+"%"),A(n,"class",s="category-graph "+Ae(e[1])+" svelte-6b2uyp")},m(t,e){g(t,n,e),m(n,r)},p(t,[e]){3&e&&o!==(o="category-graph-line "+t[2](t[1],t[0])+" svelte-6b2uyp")&&A(r,"class",o),3&e&&j(r,"width",t[3](t[1],t[0])+"%"),2&e&&s!==(s="category-graph "+Ae(t[1])+" svelte-6b2uyp")&&A(n,"class",s)},i:t,o:t,d(t){t&&h(n)}}}function Se(t,e,n){let{budgeted:r}=e,{remaining:o}=e;return t.$set=t=>{"budgeted"in t&&n(0,r=t.budgeted),"remaining"in t&&n(1,o=t.remaining)},[r,o,(t,e)=>null==t?"":t<0?"danger":tt<0?0:0===e?t>0?100:0:t/e*100]}class Le extends at{constructor(t){super(),ut(this,t,Se,Oe,c,{budgeted:0,remaining:1})}}function De(t,e,n){const r=t.slice();return r[3]=e[n].budgeted,r[4]=e[n].remaining,r[5]=e[n].name,r[6]=e[n].uuid,r}function He(t){let e,n,r,o,s,c,u,a,i,l,f,$,d,p,y,x,E,k,C,N,j,M=t[5]+"",O=_e(t[4])+"",S=Ne(t[3])+"";return a=new Le({props:{budgeted:t[3],remaining:t[4]}}),{c(){e=b("tr"),n=b("td"),r=b("a"),o=w(M),c=v(),u=b("td"),ot(a.$$.fragment),i=v(),l=b("td"),f=b("div"),$=b("sup"),$.textContent="$",d=w(O),y=v(),x=b("div"),E=b("span"),k=w("/ "),C=w(S),N=v(),A(r,"href",s="#/category/"+t[6]),A(r,"class","btn btn-outline-secondary"),A(n,"class","category-name width-10 svelte-1g8xb6x"),A(u,"class","width-80 svelte-1g8xb6x"),A($,"class","svelte-1g8xb6x"),A(f,"class",p="category-available "+Ae(t[4])+" svelte-1g8xb6x"),A(x,"class","category-budgeted svelte-1g8xb6x"),A(l,"class","category-amount width-10 svelte-1g8xb6x")},m(t,s){g(t,e,s),m(e,n),m(n,r),m(r,o),m(e,c),m(e,u),st(a,u,null),m(e,i),m(e,l),m(l,f),m(f,$),m(f,d),m(l,y),m(l,x),m(x,E),m(E,k),m(E,C),m(e,N),j=!0},p(t,e){(!j||1&e)&&M!==(M=t[5]+"")&&_(o,M),(!j||1&e&&s!==(s="#/category/"+t[6]))&&A(r,"href",s);const n={};1&e&&(n.budgeted=t[3]),1&e&&(n.remaining=t[4]),a.$set(n),(!j||1&e)&&O!==(O=_e(t[4])+"")&&_(d,O),(!j||1&e&&p!==(p="category-available "+Ae(t[4])+" svelte-1g8xb6x"))&&A(f,"class",p),(!j||1&e)&&S!==(S=Ne(t[3])+"")&&_(C,S)},i(t){j||(tt(a.$$.fragment,t),j=!0)},o(t){et(a.$$.fragment,t),j=!1},d(t){t&&h(e),ct(a)}}}function Te(t){let e,n,r,o=t[0],s=[];for(let e=0;eet(s[t],1,1,()=>{s[t]=null});return{c(){e=b("table"),n=b("tbody");for(let t=0;tn(1,r=t)),i(t,Lt,t=>n(2,o=t)),t.$$.update=()=>{6&t.$$.dirty&&n(0,s=((t,e)=>{let n=[];for(var r in t)if(t.hasOwnProperty(r)){let o=Dt(r,e);n.push({budgeted:t[r].budgeted,remaining:t[r].remaining,name:o.name,uuid:o.uuid})}return n.sort((t,e)=>(t.name||"").localeCompare(e.name||""))})(r,o))},[s]}class ze extends at{constructor(t){super(),ut(this,t,Ve,Te,c,{})}}function Re(e){let n,r,o,s;return n=new pe({props:{icon:be,name:"accounts",url:"#/accounts",left:!0}}),o=new pe({props:{icon:xe,name:"expense",url:"#/expense/new"}}),{c(){ot(n.$$.fragment),r=v(),ot(o.$$.fragment)},m(t,e){st(n,t,e),g(t,r,e),st(o,t,e),s=!0},p:t,i(t){s||(tt(n.$$.fragment,t),tt(o.$$.fragment,t),s=!0)},o(t){et(n.$$.fragment,t),et(o.$$.fragment,t),s=!1},d(t){ct(n,t),t&&h(r),ct(o,t)}}}function Pe(t){let e,n,r,o,s,c,u,a;return r=new ze({}),u=new he({props:{$$slots:{default:[Re]},$$scope:{ctx:t}}}),{c(){e=b("h2"),e.textContent="Budget",n=v(),ot(r.$$.fragment),o=v(),s=b("p"),s.innerHTML='Add new category',c=v(),ot(u.$$.fragment)},m(t,i){g(t,e,i),g(t,n,i),st(r,t,i),g(t,o,i),g(t,s,i),g(t,c,i),st(u,t,i),a=!0},p(t,[e]){const n={};1&e&&(n.$$scope={dirty:e,ctx:t}),u.$set(n)},i(t){a||(tt(r.$$.fragment,t),tt(u.$$.fragment,t),a=!0)},o(t){et(r.$$.fragment,t),et(u.$$.fragment,t),a=!1},d(t){t&&h(e),t&&h(n),ct(r,t),t&&h(o),t&&h(s),t&&h(c),ct(u,t)}}}function Ie(e){let n,r,s,c,u,a,i;return{c(){n=b("form"),r=b("div"),s=b("div"),s.innerHTML='$',c=v(),u=b("input"),A(s,"class","input-group-prepend"),A(u,"type","tel"),A(u,"aria-describedby","amount-input-currency-symbol"),A(u,"aria-label","Amount"),A(u,"class","text-right form-control"),A(r,"class","input-group input-group-lg"),n.noValidate=!0},m(t,o){g(t,n,o),m(n,r),m(r,s),m(r,c),m(r,u),e[4](u),a||(i=[k(u,"keydown",e[1]),k(n,"submit",C(e[2]))],a=!0)},p:t,i:t,o:t,d(t){t&&h(n),e[4](null),a=!1,o(i)}}}function Be(t,e,n){let{amount:r=0}=e;const o=H();let s,c=[],u=null;function a(t){for(var e="",r=0;r{var t;c=(t=r)?String(t).split("").filter((function(t){return"0123456789".indexOf(t)>=0})):[],a(c),i(Number(c.join(""))),s.focus()}),t.$set=t=>{"amount"in t&&n(3,r=t.amount)},[s,function(t){var e=t.which;(t=>t>=32&&t<112||t>=123&&t<127||t>=186)(e)&&t.preventDefault();var n=(t=>t>=48&&t<58?String(t-48):t>=96&&t<106?String(t-96):"")(e);n?c.push(n):(t=>8===t)(e)&&(t.preventDefault(),c.pop()),a(c),i(Number(c.join("")))},function(t){o("next",u)},r,function(t){z[t?"unshift":"push"](()=>{s=t,n(0,s)})}]}class Fe extends at{constructor(t){super(),ut(this,t,Be,Ie,c,{amount:3})}}function qe(t){let e,n,r,o,s,c,u=t[0].name+"";return s=new Fe({props:{amount:t[1]}}),s.$on("next",t[2]),{c(){e=b("h2"),n=w("Amount for "),r=w(u),o=v(),ot(s.$$.fragment)},m(t,u){g(t,e,u),m(e,n),m(e,r),g(t,o,u),st(s,t,u),c=!0},p(t,[e]){(!c||1&e)&&u!==(u=t[0].name+"")&&_(r,u);const n={};2&e&&(n.amount=t[1]),s.$set(n)},i(t){c||(tt(s.$$.fragment,t),c=!0)},o(t){et(s.$$.fragment,t),c=!1},d(t){t&&h(e),t&&h(o),ct(s,t)}}}function Ue(t,e,n){let r;i(t,Lt,t=>n(5,r=t));let o,s,c,{params:u}=e;return t.$set=t=>{"params"in t&&n(3,u=t.params)},t.$$.update=()=>{8&t.$$.dirty&&n(4,o=u.uuid),48&t.$$.dirty&&n(0,s=r.find(t=>t.uuid===o)||{}),16&t.$$.dirty&&n(1,c=Rt(o)||0)},[s,c,function(t){let e=t.detail;It(o,e),Zt("/budget")},u]}function Ye(e){let n,r,s,c,u,a;return{c(){n=b("form"),r=b("h2"),r.innerHTML='',s=v(),c=b("input"),A(c,"class","form-control"),A(c,"placeholder","New category name"),A(c,"id","new-category-name")},m(t,o){g(t,n,o),m(n,r),m(n,s),m(n,c),N(c,e[0]),e[4](c),u||(a=[k(c,"input",e[3]),k(n,"submit",C(e[2]))],u=!0)},p(t,[e]){1&e&&c.value!==t[0]&&N(c,t[0])},i:t,o:t,d(t){t&&h(n),e[4](null),u=!1,o(a)}}}function Je(t,e,n){let r="",o={};return D(()=>{o.focus()}),[r,o,function(){Zt(`/category/${(t=>{const e=a(Lt).find(e=>e.name===t);if(e)return e;{const e={uuid:kt(),name:t};return it(e,Lt),Ht(),e}})(r).uuid}/amount`)},function(){r=this.value,n(0,r)},function(t){z[t?"unshift":"push"](()=>{o=t,n(1,o)})}]}function We(e){let n,r;return n=new pe({props:{icon:ye,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function Ge(t){let e,n,r,o,s,c,u,a,i,l,f,$,d,p,y,x,E,C=t[1].name+"",N=_e(Rt(t[0]))+"";return p=new he({props:{$$slots:{default:[We]},$$scope:{ctx:t}}}),{c(){e=b("h2"),n=b("b"),r=w(C),o=w(":"),s=v(),c=b("a"),u=b("sup"),u.textContent="$",a=v(),i=w(N),f=v(),$=b("hr"),d=v(),ot(p.$$.fragment),A(n,"class","editable svelte-1uc4ts5"),A(n,"title","(Click to rename)"),A(c,"class","btn btn-default"),A(c,"href",l="#/category/"+t[0]+"/amount"),A($,"class","small")},m(l,h){g(l,e,h),m(e,n),m(n,r),m(n,o),m(e,s),m(e,c),m(c,u),m(c,a),m(c,i),g(l,f,h),g(l,$,h),g(l,d,h),st(p,l,h),y=!0,x||(E=k(n,"click",t[2]),x=!0)},p(t,[e]){(!y||2&e)&&C!==(C=t[1].name+"")&&_(r,C),(!y||1&e)&&N!==(N=_e(Rt(t[0]))+"")&&_(i,N),(!y||1&e&&l!==(l="#/category/"+t[0]+"/amount"))&&A(c,"href",l);const n={};32&e&&(n.$$scope={dirty:e,ctx:t}),p.$set(n)},i(t){y||(tt(p.$$.fragment,t),y=!0)},o(t){et(p.$$.fragment,t),y=!1},d(t){t&&h(e),t&&h(f),t&&h($),t&&h(d),ct(p,t),x=!1,E()}}}function Ke(t,e,n){let r;i(t,Lt,t=>n(4,r=t));let{params:o={}}=e;let s,c;return t.$set=t=>{"params"in t&&n(3,o=t.params)},t.$$.update=()=>{8&t.$$.dirty&&n(0,s=o.uuid||""),17&t.$$.dirty&&n(1,c=r.find(t=>t.uuid===s)||{})},[s,c,()=>{var t=prompt("Edit category name:",c.name);null!=t&&((t,e)=>{lt("uuid",t,e,Lt),Ht()})(s,{name:t})},o]}function Qe(t,e,n){const r=t.slice();return r[3]=e[n],r}function Xe(t,e){let n,r,o,s,c,u,a=e[3].name+"";function i(...t){return e[2](e[3],...t)}return{key:t,first:null,c(){n=b("p"),r=b("button"),o=w(a),s=v(),A(r,"class","btn btn-outline-secondary"),this.first=n},m(t,e){g(t,n,e),m(n,r),m(r,o),m(n,s),c||(u=k(r,"click",i),c=!0)},p(t,n){e=t,1&n&&a!==(a=e[3].name+"")&&_(o,a)},d(t){t&&h(n),c=!1,u()}}}function Ze(e){let n,r=[],o=new Map,s=e[0];const c=t=>t[3].uuid;for(let t=0;t{"accounts"in t&&n(0,r=t.accounts)},[r,o,t=>o("select",t.uuid)]}class en extends at{constructor(t){super(),ut(this,t,tn,Ze,c,{accounts:0})}}function nn(e){let n,r;return n=new pe({props:{icon:ye,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function rn(t){let e,n,r,o,s,c;return r=new en({props:{accounts:t[0]}}),r.$on("select",t[1]),s=new he({props:{$$slots:{default:[nn]},$$scope:{ctx:t}}}),{c(){e=b("h2"),e.textContent="Paid using",n=v(),ot(r.$$.fragment),o=v(),ot(s.$$.fragment)},m(t,u){g(t,e,u),g(t,n,u),st(r,t,u),g(t,o,u),st(s,t,u),c=!0},p(t,[e]){const n={};1&e&&(n.accounts=t[0]),r.$set(n);const o={};64&e&&(o.$$scope={dirty:e,ctx:t}),s.$set(o)},i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){et(r.$$.fragment,t),et(s.$$.fragment,t),c=!1},d(t){t&&h(e),t&&h(n),ct(r,t),t&&h(o),ct(s,t)}}}function on(t,e,n){let r,o;i(t,qt,t=>n(5,r=t)),i(t,Ot,t=>n(0,o=t));let s,c,{params:u}=e;return t.$set=t=>{"params"in t&&n(2,u=t.params)},t.$$.update=()=>{4&t.$$.dirty&&n(3,s=u.uuid),40&t.$$.dirty&&(c=Ut(s,r))},[o,function(t){let e=t.detail;Jt(s,{accountUuid:e}),Zt("/expense/amount/"+c.uuid)},u]}function sn(e){let n,r;return n=new pe({props:{icon:ye,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function cn(t){let e,n,r,o,s,c,u,a,i=t[0].who+"";return s=new Fe({}),s.$on("next",t[1]),u=new he({props:{$$slots:{default:[sn]},$$scope:{ctx:t}}}),{c(){e=b("h2"),n=w("Amount paid to "),r=w(i),o=v(),ot(s.$$.fragment),c=v(),ot(u.$$.fragment)},m(t,i){g(t,e,i),m(e,n),m(e,r),g(t,o,i),st(s,t,i),g(t,c,i),st(u,t,i),a=!0},p(t,[e]){(!a||1&e)&&i!==(i=t[0].who+"")&&_(r,i);const n={};32&e&&(n.$$scope={dirty:e,ctx:t}),u.$set(n)},i(t){a||(tt(s.$$.fragment,t),tt(u.$$.fragment,t),a=!0)},o(t){et(s.$$.fragment,t),et(u.$$.fragment,t),a=!1},d(t){t&&h(e),t&&h(o),ct(s,t),t&&h(c),ct(u,t)}}}function un(t,e,n){let r;i(t,qt,t=>n(4,r=t));let o,s,{params:c}=e;return t.$set=t=>{"params"in t&&n(2,c=t.params)},t.$$.update=()=>{4&t.$$.dirty&&n(3,o=c.uuid),24&t.$$.dirty&&n(0,s=Ut(o,r))},[s,function(t){let e=t.detail;Jt(o,{amountTotal:e}),Zt("/expense/category/"+s.uuid)},c]}function an(t,e,n){const r=t.slice();return r[4]=e[n],r}function ln(t,e){let n,r,o,s,c,u,a=e[4].name+"";function i(...t){return e[2](e[4],...t)}return{key:t,first:null,c(){n=b("p"),r=b("button"),o=w(a),s=v(),A(r,"class","btn btn-outline-secondary"),this.first=n},m(t,e){g(t,n,e),m(n,r),m(r,o),m(n,s),c||(u=k(r,"click",i),c=!0)},p(t,n){e=t,1&n&&a!==(a=e[4].name+"")&&_(o,a)},d(t){t&&h(n),c=!1,u()}}}function fn(e){let n,r=[],o=new Map,s=e[0];const c=t=>t[4].uuid;for(let t=0;t{"categories"in t&&n(0,r=t.categories)},[r,o,t=>o("select",t.uuid)]}class dn extends at{constructor(t){super(),ut(this,t,$n,fn,c,{categories:0})}}function pn(e){let n,r;return n=new pe({props:{icon:ye,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function mn(t){let e,n,r,o,s,c;return r=new dn({props:{categories:t[0]}}),r.$on("select",t[1]),s=new he({props:{$$slots:{default:[pn]},$$scope:{ctx:t}}}),{c(){e=b("h2"),e.textContent="Category",n=v(),ot(r.$$.fragment),o=v(),ot(s.$$.fragment)},m(t,u){g(t,e,u),g(t,n,u),st(r,t,u),g(t,o,u),st(s,t,u),c=!0},p(t,[e]){const n={};1&e&&(n.categories=t[0]),r.$set(n);const o={};64&e&&(o.$$scope={dirty:e,ctx:t}),s.$set(o)},i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){et(r.$$.fragment,t),et(s.$$.fragment,t),c=!1},d(t){t&&h(e),t&&h(n),ct(r,t),t&&h(o),ct(s,t)}}}function gn(t,e,n){let r,o;i(t,qt,t=>n(5,r=t)),i(t,Lt,t=>n(0,o=t));let s,c,{params:u}=e;return t.$set=t=>{"params"in t&&n(2,u=t.params)},t.$$.update=()=>{4&t.$$.dirty&&n(3,s=u.uuid),40&t.$$.dirty&&(c=Ut(s,r))},[o,function(t){let e={};e[t.detail]=c.amountTotal,Jt(s,{categoryAmounts:e}),Zt("/expense/review/"+c.uuid)},u]}function hn(t){return Zt("/expense/who/"+(t=>{const e=kt(),n=Object.assign({},t,{uuid:e});return it(n,qt),Yt(),n})({timestamp:Date.now()}).uuid),[]}function yn(e){let n,r,o,s,c=_e(e[1])+"";return{c(){n=b("span"),r=w(e[0]),o=w(": $ "),s=w(c),A(n,"class","badge badge-info")},m(t,e){g(t,n,e),m(n,r),m(n,o),m(n,s)},p(t,[e]){1&e&&_(r,t[0]),2&e&&c!==(c=_e(t[1])+"")&&_(s,c)},i:t,o:t,d(t){t&&h(n)}}}function bn(t,e,n){let{name:r=""}=e,{amount:o=0}=e;return t.$set=t=>{"name"in t&&n(0,r=t.name),"amount"in t&&n(1,o=t.amount)},[r,o]}class xn extends at{constructor(t){super(),ut(this,t,bn,yn,c,{name:0,amount:1})}}function wn(t,e,n){const r=t.slice();return r[4]=e[n],r}function vn(t){let e,n;return e=new xn({props:{name:Dt(t[4],t[2]).name,amount:t[0][t[4]]}}),{c(){ot(e.$$.fragment)},m(t,r){st(e,t,r),n=!0},p(t,n){const r={};6&n&&(r.name=Dt(t[4],t[2]).name),3&n&&(r.amount=t[0][t[4]]),e.$set(r)},i(t){n||(tt(e.$$.fragment,t),n=!0)},o(t){et(e.$$.fragment,t),n=!1},d(t){ct(e,t)}}}function En(t){let e,n,r=t[1],o=[];for(let e=0;eet(o[t],1,1,()=>{o[t]=null});return{c(){for(let t=0;tn(2,r=t));let o,s,{transaction:c={}}=e;return t.$set=t=>{"transaction"in t&&n(3,c=t.transaction)},t.$$.update=()=>{8&t.$$.dirty&&n(0,o=c.categoryAmounts||{}),1&t.$$.dirty&&n(1,s=Object.keys(o))},[o,s,r,c]}class Cn extends at{constructor(t){super(),ut(this,t,kn,En,c,{transaction:3})}}function An(e){let n,r;return n=new pe({props:{icon:ye,name:"done",url:"#/budget"}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function _n(t){let e,n,r,o,s,c,u,a,i,l,f,$,d,p,y,x,E,C,N,j,M,O,S,L,D,H,T,V,z,R,P,I,B,F,q=t[1].who+"",U=_e(t[3])+"";return x=new Cn({props:{transaction:t[1]}}),P=new he({props:{$$slots:{default:[An]},$$scope:{ctx:t}}}),{c(){e=b("div"),n=b("div"),r=b("h2"),r.textContent="Review Expense",o=v(),s=b("p"),c=b("a"),u=w(q),i=v(),l=b("a"),f=w("$"),$=w(U),p=v(),y=b("p"),ot(x.$$.fragment),E=v(),C=b("p"),N=b("b"),N.textContent="Account:",j=v(),M=b("a"),O=w(t[2]),L=v(),D=b("p"),H=b("b"),H.textContent="Date:",T=v(),V=b("input"),R=v(),ot(P.$$.fragment),A(c,"class","btn btn-outline-secondary"),A(c,"href",a="#/expense/who/"+t[0]),A(l,"class","btn btn-outline-secondary float-right"),A(l,"href",d="#/expense/amount/"+t[0]),A(M,"class","btn btn-outline-secondary float-right"),A(M,"href",S="#/expense/account/"+t[0]),A(V,"type","date"),A(V,"class","float-right"),V.value=z=Tt(t[1].timestamp),A(n,"class","col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-3"),A(e,"class","row")},m(a,d){g(a,e,d),m(e,n),m(n,r),m(n,o),m(n,s),m(s,c),m(c,u),m(s,i),m(s,l),m(l,f),m(l,$),m(n,p),m(n,y),st(x,y,null),m(n,E),m(n,C),m(C,N),m(C,j),m(C,M),m(M,O),m(n,L),m(n,D),m(D,H),m(D,T),m(D,V),g(a,R,d),st(P,a,d),I=!0,B||(F=k(V,"change",t[4]),B=!0)},p(t,[e]){(!I||2&e)&&q!==(q=t[1].who+"")&&_(u,q),(!I||1&e&&a!==(a="#/expense/who/"+t[0]))&&A(c,"href",a),(!I||8&e)&&U!==(U=_e(t[3])+"")&&_($,U),(!I||1&e&&d!==(d="#/expense/amount/"+t[0]))&&A(l,"href",d);const n={};2&e&&(n.transaction=t[1]),x.$set(n),(!I||4&e)&&_(O,t[2]),(!I||1&e&&S!==(S="#/expense/account/"+t[0]))&&A(M,"href",S),(!I||2&e&&z!==(z=Tt(t[1].timestamp)))&&(V.value=z);const r={};1024&e&&(r.$$scope={dirty:e,ctx:t}),P.$set(r)},i(t){I||(tt(x.$$.fragment,t),tt(P.$$.fragment,t),I=!0)},o(t){et(x.$$.fragment,t),et(P.$$.fragment,t),I=!1},d(t){t&&h(e),ct(x),t&&h(R),ct(P,t),B=!1,F()}}}function Nn(t,e,n){let r,o;i(t,qt,t=>n(6,r=t)),i(t,Ot,t=>n(8,o=t));let{params:s}=e;let c,u,a,l,f;return t.$set=t=>{"params"in t&&n(5,s=t.params)},t.$$.update=()=>{32&t.$$.dirty&&n(0,c=s.uuid),65&t.$$.dirty&&n(1,u=Ut(c,r)),258&t.$$.dirty&&n(7,a=((t,e)=>e.find(e=>e.uuid===t)||{})(u.accountUuid,o)),128&t.$$.dirty&&n(2,l=a.name||""),2&t.$$.dirty&&n(3,f=u.amountTotal||0)},[c,u,l,f,t=>{let e=t.target.value,n=new Date(e+" 12:00:00");Jt(c,{timestamp:n.getTime()})},s]}function jn(t){let e,n,r,o,s,c,u;return{c(){e=b("h2"),n=b("label"),r=w(t[1]),o=v(),s=b("input"),A(n,"for","who"),A(s,"type","text"),A(s,"class","form-control"),A(s,"id","who")},m(a,i){g(a,e,i),m(e,n),m(n,r),g(a,o,i),g(a,s,i),N(s,t[0]),t[5](s),c||(u=k(s,"input",t[4]),c=!0)},p(t,e){2&e&&_(r,t[1]),1&e&&s.value!==t[0]&&N(s,t[0])},d(n){n&&h(e),n&&h(o),n&&h(s),t[5](null),c=!1,u()}}}function Mn(t){let e,n;return e=new oe({props:{autofocusElement:t[2],$$slots:{default:[jn]},$$scope:{ctx:t}}}),e.$on("submit",t[3]),{c(){ot(e.$$.fragment)},m(t,r){st(e,t,r),n=!0},p(t,[n]){const r={};4&n&&(r.autofocusElement=t[2]),135&n&&(r.$$scope={dirty:n,ctx:t}),e.$set(r)},i(t){n||(tt(e.$$.fragment,t),n=!0)},o(t){et(e.$$.fragment,t),n=!1},d(t){ct(e,t)}}}function On(t,e,n){let{title:r}=e,{who:o=""}=e;const s=H();let c={};return t.$set=t=>{"title"in t&&n(1,r=t.title),"who"in t&&n(0,o=t.who)},[o,r,c,()=>{s("select",o)},function(){o=this.value,n(0,o)},function(t){z[t?"unshift":"push"](()=>{c=t,n(2,c)})}]}class Sn extends at{constructor(t){super(),ut(this,t,On,Mn,c,{title:1,who:0})}}function Ln(e){let n,r;return n=new pe({props:{icon:ye,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function Dn(t){let e,n,r,o;return e=new Sn({props:{title:"Paid to:"}}),e.$on("select",t[0]),r=new he({props:{$$slots:{default:[Ln]},$$scope:{ctx:t}}}),{c(){ot(e.$$.fragment),n=v(),ot(r.$$.fragment)},m(t,s){st(e,t,s),g(t,n,s),st(r,t,s),o=!0},p(t,[e]){const n={};32&e&&(n.$$scope={dirty:e,ctx:t}),r.$set(n)},i(t){o||(tt(e.$$.fragment,t),tt(r.$$.fragment,t),o=!0)},o(t){et(e.$$.fragment,t),et(r.$$.fragment,t),o=!1},d(t){ct(e,t),t&&h(n),ct(r,t)}}}function Hn(t,e,n){let r;i(t,qt,t=>n(4,r=t));let{params:o}=e;let s,c;return t.$set=t=>{"params"in t&&n(1,o=t.params)},t.$$.update=()=>{2&t.$$.dirty&&n(2,s=o.uuid),20&t.$$.dirty&&(c=Ut(s,r))},[t=>{const e=t.detail;Jt(s,{who:e}),Zt("/expense/account/"+c.uuid)},o]}function Tn(t){return function(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");q().then(()=>{const e=("#"==t.charAt(0)?"":"#")+t;try{window.history.replaceState(void 0,void 0,e)}catch(t){console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event("hashchange"))})}("/budget"),[]}function Vn(e){let n,r,o,s,c;return{c(){n=b("h2"),n.textContent="Hmm...",r=v(),o=b("p"),o.textContent="We can't seem to find that page.",s=v(),c=b("p"),c.innerHTML='\n Try going back to the Home screen. Perhaps there's a link\n from there to where you were trying to go.\n'},m(t,e){g(t,n,e),g(t,r,e),g(t,o,e),g(t,s,e),g(t,c,e)},p:t,i:t,o:t,d(t){t&&h(n),t&&h(r),t&&h(o),t&&h(s),t&&h(c)}}}const zn={"/":class extends at{constructor(t){super(),ut(this,t,Tn,null,c,{})}},"/account/new":class extends at{constructor(t){super(),ut(this,t,ue,ce,c,{})}},"/accounts":class extends at{constructor(t){super(),ut(this,t,Ce,ke,c,{})}},"/budget":class extends at{constructor(t){super(),ut(this,t,null,Pe,c,{})}},"/category/new":class extends at{constructor(t){super(),ut(this,t,Je,Ye,c,{})}},"/category/:uuid":class extends at{constructor(t){super(),ut(this,t,Ke,Ge,c,{params:3})}},"/category/:uuid/amount":class extends at{constructor(t){super(),ut(this,t,Ue,qe,c,{params:3})}},"/expense/account/:uuid":class extends at{constructor(t){super(),ut(this,t,on,rn,c,{params:2})}},"/expense/amount/:uuid":class extends at{constructor(t){super(),ut(this,t,un,cn,c,{params:2})}},"/expense/category/:uuid":class extends at{constructor(t){super(),ut(this,t,gn,mn,c,{params:2})}},"/expense/new":class extends at{constructor(t){super(),ut(this,t,hn,null,c,{})}},"/expense/review/:uuid":class extends at{constructor(t){super(),ut(this,t,Nn,_n,c,{params:5})}},"/expense/who/:uuid":class extends at{constructor(t){super(),ut(this,t,Hn,Dn,c,{params:1})}},"*":class extends at{constructor(t){super(),ut(this,t,null,Vn,c,{})}}};function Rn(e){let n,r,o,s,c;return r=new Mt({}),s=new ee({props:{routes:zn}}),{c(){n=b("div"),ot(r.$$.fragment),o=v(),ot(s.$$.fragment),A(n,"class","container-xl my-3")},m(t,e){g(t,n,e),st(r,n,null),m(n,o),st(s,n,null),c=!0},p:t,i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){et(r.$$.fragment,t),et(s.$$.fragment,t),c=!1},d(t){t&&h(n),ct(r),ct(s)}}}function Pn(t){return D(async()=>{Ot.set($t("accounts")),Lt.set($t("categories")),Pt(),qt.set($t("transactions"))}),[]}return new class extends at{constructor(t){super(),ut(this,t,Pn,Rn,c,{})}}({target:document.body})}(); +var app=function(){"use strict";function t(){}function e(t,e){for(const n in e)t[n]=e[n];return t}function n(t){return t()}function r(){return Object.create(null)}function o(t){t.forEach(n)}function s(t){return"function"==typeof t}function c(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function u(e,...n){if(null==e)return t;const r=e.subscribe(...n);return r.unsubscribe?()=>r.unsubscribe():r}function a(t){let e;return u(t,t=>e=t)(),e}function i(t,e,n){t.$$.on_destroy.push(u(e,n))}function l(t,e,n,r){if(t){const o=f(t,e,n,r);return t[0](o)}}function f(t,n,r,o){return t[1]&&o?e(r.ctx.slice(),t[1](o(n))):r.ctx}function $(t,e,n,r,o,s,c){const u=function(t,e,n,r){if(t[2]&&r){const o=t[2](r(n));if(void 0===e.dirty)return o;if("object"==typeof o){const t=[],n=Math.max(e.dirty.length,o.length);for(let r=0;rt.removeEventListener(e,n,r)}function A(t){return function(e){return e.preventDefault(),t.call(this,e)}}function C(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}function _(t,e){e=""+e,t.wholeText!==e&&(t.data=e)}function N(t,e){t.value=null==e?"":e}function j(t,e,n,r){t.style.setProperty(e,n,r?"important":"")}function O(t,e,n){t.classList[n?"add":"remove"](e)}let M;function S(t){M=t}function L(){if(!M)throw new Error("Function called outside component initialization");return M}function D(t){L().$$.on_mount.push(t)}function T(){const t=L();return(e,n)=>{const r=t.$$.callbacks[e];if(r){const o=function(t,e){const n=document.createEvent("CustomEvent");return n.initCustomEvent(t,!1,!1,e),n}(e,n);r.slice().forEach(e=>{e.call(t,o)})}}}function H(t,e){const n=t.$$.callbacks[e.type];n&&n.slice().forEach(t=>t(e))}const V=[],z=[],R=[],P=[],I=Promise.resolve();let B=!1;function F(){B||(B=!0,I.then(W))}function q(){return F(),I}function U(t){R.push(t)}let Y=!1;const J=new Set;function W(){if(!Y){Y=!0;do{for(let t=0;t{K.delete(t),r&&(n&&t.d(1),r())}),t.o(e)}}function nt(t,e){t.d(1),e.delete(t.key)}function rt(t,e,n,r,o,s,c,u,a,i,l,f){let $=t.length,d=s.length,p=$;const m={};for(;p--;)m[t[p].key]=p;const g=[],h=new Map,y=new Map;for(p=d;p--;){const t=f(o,s,p),u=n(t);let a=c.get(u);a?r&&a.p(t,e):(a=i(u,t),a.c()),h.set(u,g[p]=a),u in m&&y.set(u,Math.abs(p-m[u]))}const b=new Set,w=new Set;function x(t){tt(t,1),t.m(u,l),c.set(t.key,t),l=t.first,d--}for(;$&&d;){const e=g[d-1],n=t[$-1],r=e.key,o=n.key;e===n?(l=e.first,$--,d--):h.has(o)?!c.has(r)||b.has(r)?x(e):w.has(o)?$--:y.get(r)>y.get(o)?(w.add(r),x(e)):(b.add(o),$--):(a(n,c),$--)}for(;$--;){const e=t[$];h.has(e.key)||a(e,c)}for(;d;)x(g[d-1]);return g}function ot(t){t&&t.c()}function st(t,e,r){const{fragment:c,on_mount:u,on_destroy:a,after_update:i}=t.$$;c&&c.m(e,r),U(()=>{const e=u.map(n).filter(s);a?a.push(...e):o(e),t.$$.on_mount=[]}),i.forEach(U)}function ct(t,e){const n=t.$$;null!==n.fragment&&(o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function ut(e,n,s,c,u,a,i=[-1]){const l=M;S(e);const f=n.props||{},$=e.$$={fragment:null,ctx:null,props:a,update:t,not_equal:u,bound:r(),on_mount:[],on_destroy:[],before_update:[],after_update:[],context:new Map(l?l.$$.context:[]),callbacks:r(),dirty:i,skip_bound:!1};let d=!1;if($.ctx=s?s(e,f,(t,n,...r)=>{const o=r.length?r[0]:n;return $.ctx&&u($.ctx[t],$.ctx[t]=o)&&(!$.skip_bound&&$.bound[t]&&$.bound[t](o),d&&function(t,e){-1===t.$$.dirty[0]&&(V.push(t),F(),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}const it=(t,e)=>{e.update(e=>[t,...e])},lt=(t,e,n,r)=>{r.update(r=>{const o=r.find(n=>n[t]===e),s=Object.assign({},o,n);let c=!1;for(let n=0;n{const e=dt(t);return ft(e)?e:[]},dt=t=>{const e=localStorage.getItem(t);return JSON.parse(e)},pt=(t,e)=>{localStorage.setItem(t,JSON.stringify(e))},mt=[];function gt(t,e){return{subscribe:ht(t,e).subscribe}}function ht(e,n=t){let r;const o=[];function s(t){if(c(e,t)&&(e=t,r)){const t=!mt.length;for(let t=0;t{const t=o.indexOf(a);-1!==t&&o.splice(t,1),0===o.length&&(r(),r=null)}}}}function yt(e,n,r){const c=!Array.isArray(e),a=c?[e]:e,i=n.length<2;return gt(r,e=>{let r=!1;const l=[];let f=0,$=t;const d=()=>{if(f)return;$();const r=n(c?l[0]:l,e);i?e(r):$=s(r)?r:t},p=a.map((t,e)=>u(t,t=>{l[e]=t,f&=~(1<{f|=1<At.set("");function _t(t){let e,n,r,o,s,c;return{c(){e=b("div"),n=b("button"),n.innerHTML='',r=v(),o=x(t[0]),C(n,"type","button"),C(n,"class","close"),C(n,"aria-label","Close"),C(e,"class","alert alert-danger keep-line-breaks svelte-1anyckn"),C(e,"role","alert")},m(t,u){g(t,e,u),m(e,n),m(e,r),m(e,o),s||(c=E(n,"click",Ct),s=!0)},p(t,e){1&e&&_(o,t[0])},d(t){t&&h(e),s=!1,c()}}}function Nt(e){let n,r=e[0]&&_t(e);return{c(){r&&r.c(),n=k()},m(t,e){r&&r.m(t,e),g(t,n,e)},p(t,[e]){t[0]?r?r.p(t,e):(r=_t(t),r.c(),r.m(n.parentNode,n)):r&&(r.d(1),r=null)},i:t,o:t,d(t){r&&r.d(t),t&&h(n)}}}function jt(t,e,n){let r;return i(t,At,t=>n(0,r=t)),[r]}window.onunhandledrejection=t=>{let e=t.reason;At.set(e.message)};class Ot extends at{constructor(t){super(),ut(this,t,jt,Nt,c,{})}}const Mt=ht([]),St=()=>pt("accounts",a(Mt)),Lt=ht([]),Dt=(t,e)=>e.find(e=>e.uuid===t)||{},Tt=()=>pt("categories",a(Lt)),Ht=t=>{let e=new Date(t);const n=e.getFullYear(),r=e.getMonth()+1,o=e.getDate();return`${n}-${String(r).padStart(2,"0")}-${String(o).padStart(2,"0")}`},Vt=(t,e)=>{var n=e.getFullYear(),r=e.getMonth(),o=new Date(n,r-t),s=o.getFullYear(),c=o.getMonth()+1;return s+"-"+String("0"+c).slice(-2)},zt=ht({}),Rt=t=>a(zt)[t]||{},Pt=t=>Rt(t).budgeted||0,It=()=>{zt.set((t=>{const e=dt(t);return null!==e?e:{}})("budget"))},Bt=(t,e)=>{a(zt);(t=>a(zt).hasOwnProperty(t))(t)?Ut(t,e):((t,e)=>{qt(t,{budgeted:e,remaining:e,refilled:Vt(0,new Date)})})(t,e)},Ft=(t,e)=>{const n=Rt(t).remaining||0;qt(t,{remaining:n-e})},qt=(t,e)=>{((t,e,n)=>{n.update(n=>(n.hasOwnProperty(t)?n[t]=Object.assign(n[t],e):n[t]=e,n))})(t,e,zt),pt("budget",a(zt))},Ut=(t,e)=>{let n=a(zt)[t],r=n.budgeted,o=n.remaining;qt(t,{budgeted:e,remaining:o+(e-r)})},Yt=ht([]),Jt=(t,e)=>e.find(e=>e.uuid===t)||{},Wt=()=>pt("transactions",a(Yt)),Gt=(t,e)=>{lt("uuid",t,e,Yt),Wt()};function Kt(t){let e,n,r;var o=t[0];return o&&(e=new o({}),e.$on("routeEvent",t[5])),{c(){e&&ot(e.$$.fragment),n=k()},m(t,o){e&&st(e,t,o),g(t,n,o),r=!0},p(t,r){if(o!==(o=t[0])){if(e){X();const t=e;et(t.$$.fragment,1,0,()=>{ct(t,1)}),Z()}o?(e=new o({}),e.$on("routeEvent",t[5]),ot(e.$$.fragment),tt(e.$$.fragment,1),st(e,n.parentNode,n)):e=null}},i(t){r||(e&&tt(e.$$.fragment,t),r=!0)},o(t){e&&et(e.$$.fragment,t),r=!1},d(t){t&&h(n),e&&ct(e,t)}}}function Qt(t){let e,n,r;var o=t[0];function s(t){return{props:{params:t[1]}}}return o&&(e=new o(s(t)),e.$on("routeEvent",t[4])),{c(){e&&ot(e.$$.fragment),n=k()},m(t,o){e&&st(e,t,o),g(t,n,o),r=!0},p(t,r){const c={};if(2&r&&(c.params=t[1]),o!==(o=t[0])){if(e){X();const t=e;et(t.$$.fragment,1,0,()=>{ct(t,1)}),Z()}o?(e=new o(s(t)),e.$on("routeEvent",t[4]),ot(e.$$.fragment),tt(e.$$.fragment,1),st(e,n.parentNode,n)):e=null}else o&&e.$set(c)},i(t){r||(e&&tt(e.$$.fragment,t),r=!0)},o(t){e&&et(e.$$.fragment,t),r=!1},d(t){t&&h(n),e&&ct(e,t)}}}function Xt(t){let e,n,r,o;const s=[Qt,Kt],c=[];function u(t,e){return t[1]?0:1}return e=u(t),n=c[e]=s[e](t),{c(){n.c(),r=k()},m(t,n){c[e].m(t,n),g(t,r,n),o=!0},p(t,[o]){let a=e;e=u(t),e===a?c[e].p(t,o):(X(),et(c[a],1,1,()=>{c[a]=null}),Z(),n=c[e],n||(n=c[e]=s[e](t),n.c()),tt(n,1),n.m(r.parentNode,r))},i(t){o||(tt(n),o=!0)},o(t){et(n),o=!1},d(t){c[e].d(t),t&&h(r)}}}function Zt(){const t=window.location.href.indexOf("#/");let e=t>-1?window.location.href.substr(t+1):"/";const n=e.indexOf("?");let r="";return n>-1&&(r=e.substr(n+1),e=e.substr(0,n)),{location:e,querystring:r}}const te=gt(null,(function(t){t(Zt());const e=()=>{t(Zt())};return window.addEventListener("hashchange",e,!1),function(){window.removeEventListener("hashchange",e,!1)}}));yt(te,t=>t.location),yt(te,t=>t.querystring);function ee(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");return q().then(()=>{window.location.hash=("#"==t.charAt(0)?"":"#")+t})}function ne(e,n,r){let o,s=t;i(e,te,t=>r(6,o=t)),e.$$.on_destroy.push(()=>s());let{routes:c={}}=n,{prefix:u=""}=n;class a{constructor(t,e){if(!e||"function"!=typeof e&&("object"!=typeof e||!0!==e._sveltesparouter))throw Error("Invalid component object");if(!t||"string"==typeof t&&(t.length<1||"/"!=t.charAt(0)&&"*"!=t.charAt(0))||"object"==typeof t&&!(t instanceof RegExp))throw Error('Invalid value for "path" argument');const{pattern:n,keys:r}=function(t,e){if(t instanceof RegExp)return{keys:!1,pattern:t};var n,r,o,s,c=[],u="",a=t.split("/");for(a[0]||a.shift();o=a.shift();)"*"===(n=o[0])?(c.push("wild"),u+="/(.*)"):":"===n?(r=o.indexOf("?",1),s=o.indexOf(".",1),c.push(o.substring(1,~r?r:~s?s:o.length)),u+=~r&&!~s?"(?:/([^/]+?))?":"/([^/]+?)",~s&&(u+=(~r?"?":"")+"\\"+o.substring(s))):u+="/"+o;return{keys:c,pattern:new RegExp("^"+u+(e?"(?=$|/)":"/?$"),"i")}}(t);this.path=t,"object"==typeof e&&!0===e._sveltesparouter?(this.component=e.route,this.conditions=e.conditions||[],this.userData=e.userData):(this.component=e,this.conditions=[],this.userData=void 0),this._pattern=n,this._keys=r}match(t){u&&t.startsWith(u)&&(t=t.substr(u.length)||"/");const e=this._pattern.exec(t);if(null===e)return null;if(!1===this._keys)return e;const n={};let r=0;for(;r{l.push(new a(e,t))}):Object.keys(c).forEach(t=>{l.push(new a(t,c[t]))});let f=null,$=null;const d=T(),p=(t,e)=>{q().then(()=>{d(t,e)})};return e.$$set=t=>{"routes"in t&&r(2,c=t.routes),"prefix"in t&&r(3,u=t.prefix)},e.$$.update=()=>{if(65&e.$$.dirty){r(0,f=null);let t=0;for(;!f&&t{"autofocusElement"in t&&n(0,s=t.autofocusElement),"$$scope"in t&&n(1,o=t.$$scope)},t.$$.update=()=>{1&t.$$.dirty&&s.focus&&s.focus()},[s,o,r,function(e){H(t,e)}]}class ce extends at{constructor(t){super(),ut(this,t,se,oe,c,{autofocusElement:0})}}function ue(t){let e,n,r;return{c(){e=b("input"),C(e,"class","form-control"),C(e,"placeholder","New account name")},m(o,s){g(o,e,s),N(e,t[0]),t[4](e),n||(r=E(e,"input",t[3]),n=!0)},p(t,n){1&n&&e.value!==t[0]&&N(e,t[0])},d(o){o&&h(e),t[4](null),n=!1,r()}}}function ae(t){let e,n,r,o;return r=new ce({props:{autofocusElement:t[1],$$slots:{default:[ue]},$$scope:{ctx:t}}}),r.$on("submit",t[2]),{c(){e=b("h2"),e.textContent="New Account",n=v(),ot(r.$$.fragment)},m(t,s){g(t,e,s),g(t,n,s),st(r,t,s),o=!0},p(t,[e]){const n={};2&e&&(n.autofocusElement=t[1]),35&e&&(n.$$scope={dirty:e,ctx:t}),r.$set(n)},i(t){o||(tt(r.$$.fragment,t),o=!0)},o(t){et(r.$$.fragment,t),o=!1},d(t){t&&h(e),t&&h(n),ct(r,t)}}}function ie(t,e,n){let r="",o={};return[r,o,function(){(t=>{const e={uuid:Et(),name:t};it(e,Mt),St()})(r),ee("/accounts")},function(){r=this.value,n(0,r)},function(t){z[t?"unshift":"push"](()=>{o=t,n(1,o)})}]}function le(e){let n,r,o;return{c(){n=w("svg"),r=w("path"),C(r,"fill","currentColor"),C(r,"d",e[0]),C(n,"aria-hidden","true"),C(n,"class",o=p(e[1])+" svelte-1d15yci"),C(n,"role","img"),C(n,"xmlns","http://www.w3.org/2000/svg"),C(n,"viewBox",e[2])},m(t,e){g(t,n,e),m(n,r)},p(t,[e]){1&e&&C(r,"d",t[0]),2&e&&o!==(o=p(t[1])+" svelte-1d15yci")&&C(n,"class",o),4&e&&C(n,"viewBox",t[2])},i:t,o:t,d(t){t&&h(n)}}}function fe(t,n,r){let{icon:o}=n,s=[],c="",u="";return t.$$set=t=>{r(4,n=e(e({},n),d(t))),"icon"in t&&r(3,o=t.icon)},t.$$.update=()=>{8&t.$$.dirty&&r(2,u="0 0 "+o.icon[0]+" "+o.icon[1]),r(1,c="fa-svelte "+(n.class?n.class:"")),8&t.$$.dirty&&r(0,s=o.icon[4])},n=d(n),[s,c,u,o]}class $e extends at{constructor(t){super(),ut(this,t,fe,le,c,{icon:3})}}function de(t){let e,n,r;return e=new $e({props:{icon:t[0]}}),{c(){ot(e.$$.fragment),n=v()},m(t,o){st(e,t,o),g(t,n,o),r=!0},p(t,n){const r={};1&n&&(r.icon=t[0]),e.$set(r)},i(t){r||(tt(e.$$.fragment,t),r=!0)},o(t){et(e.$$.fragment,t),r=!1},d(t){ct(e,t),t&&h(n)}}}function pe(t){let e,n,r,o,s,c,u,a,i,l,f,$,d=t[0]&&de(t);return{c(){e=b("a"),n=b("span"),d&&d.c(),r=b("br"),o=v(),s=b("br"),c=v(),u=x(t[1]),C(n,"class","button-circle svelte-2b5sup"),C(e,"id",a="button-"+t[1]),C(e,"class","btn svelte-2b5sup"),C(e,"href",i=t[3]||"javascript:void(0)"),C(e,"role","button"),O(e,"float-left",t[2])},m(a,i){g(a,e,i),m(e,n),d&&d.m(n,null),m(n,r),m(n,o),m(e,s),m(e,c),m(e,u),l=!0,f||($=E(e,"click",t[4]),f=!0)},p(t,[o]){t[0]?d?(d.p(t,o),1&o&&tt(d,1)):(d=de(t),d.c(),tt(d,1),d.m(n,r)):d&&(X(),et(d,1,1,()=>{d=null}),Z()),(!l||2&o)&&_(u,t[1]),(!l||2&o&&a!==(a="button-"+t[1]))&&C(e,"id",a),(!l||8&o&&i!==(i=t[3]||"javascript:void(0)"))&&C(e,"href",i),4&o&&O(e,"float-left",t[2])},i(t){l||(tt(d),l=!0)},o(t){et(d),l=!1},d(t){t&&h(e),d&&d.d(),f=!1,$()}}}function me(t,e,n){let{icon:r}=e,{name:o}=e,{left:s=!1}=e,{url:c=""}=e;return t.$$set=t=>{"icon"in t&&n(0,r=t.icon),"name"in t&&n(1,o=t.name),"left"in t&&n(2,s=t.left),"url"in t&&n(3,c=t.url)},[r,o,s,c,function(e){H(t,e)}]}class ge extends at{constructor(t){super(),ut(this,t,me,pe,c,{icon:0,name:1,left:2,url:3})}}function he(t){let e,n,r,o,s,c;const u=t[1].default,a=l(u,t,t[0],null);return{c(){e=b("div"),n=v(),r=b("div"),a&&a.c(),o=v(),s=b("div"),C(e,"id","button-row-spacer"),C(e,"class","svelte-17rvsyv"),C(s,"class","clearfix"),C(r,"id","button-row"),C(r,"class","svelte-17rvsyv")},m(t,u){g(t,e,u),g(t,n,u),g(t,r,u),a&&a.m(r,null),m(r,o),m(r,s),c=!0},p(t,[e]){a&&a.p&&1&e&&$(a,u,t,t[0],e,null,null)},i(t){c||(tt(a,t),c=!0)},o(t){et(a,t),c=!1},d(t){t&&h(e),t&&h(n),t&&h(r),a&&a.d(t)}}}function ye(t,e,n){let{$$slots:r={},$$scope:o}=e;return t.$$set=t=>{"$$scope"in t&&n(0,o=t.$$scope)},[o,r]}class be extends at{constructor(t){super(),ut(this,t,ye,he,c,{})}}var we={prefix:"fas",iconName:"home",icon:[576,512,[],"f015","M280.37 148.26L96 300.11V464a16 16 0 0 0 16 16l112.06-.29a16 16 0 0 0 15.92-16V368a16 16 0 0 1 16-16h64a16 16 0 0 1 16 16v95.64a16 16 0 0 0 16 16.05L464 480a16 16 0 0 0 16-16V300L295.67 148.26a12.19 12.19 0 0 0-15.3 0zM571.6 251.47L488 182.56V44.05a12 12 0 0 0-12-12h-56a12 12 0 0 0-12 12v72.61L318.47 43a48 48 0 0 0-61 0L4.34 251.47a12 12 0 0 0-1.6 16.9l25.5 31A12 12 0 0 0 45.15 301l235.22-193.74a12.19 12.19 0 0 1 15.3 0L530.9 301a12 12 0 0 0 16.9-1.6l25.5-31a12 12 0 0 0-1.7-16.93z"]},xe={prefix:"fas",iconName:"list-ul",icon:[512,512,[],"f0ca","M48 48a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm0 160a48 48 0 1 0 48 48 48 48 0 0 0-48-48zm448 16H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z"]},ve={prefix:"fas",iconName:"minus",icon:[448,512,[],"f068","M416 208H32c-17.67 0-32 14.33-32 32v32c0 17.67 14.33 32 32 32h384c17.67 0 32-14.33 32-32v-32c0-17.67-14.33-32-32-32z"]};function ke(t,e,n){const r=t.slice();return r[1]=e[n],r}function Ee(t){let e,n,r=t[1].name+"";return{c(){e=b("li"),n=x(r)},m(t,r){g(t,e,r),m(e,n)},p(t,e){1&e&&r!==(r=t[1].name+"")&&_(n,r)},d(t){t&&h(e)}}}function Ae(e){let n,r;return n=new ge({props:{icon:we,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function Ce(t){let e,n,r,o,s,c,u,a,i=t[0],l=[];for(let e=0;eAdd new account',c=v(),ot(u.$$.fragment)},m(t,i){g(t,e,i),g(t,n,i),g(t,r,i);for(let t=0;tn(0,r=t)),[r]}const Ne=t=>Se(t)?"danger":"",je=t=>Me(t,2),Oe=t=>Me(t,0),Me=(t,e)=>(null==t&&(t=0),(Number(t)/100).toFixed(e)),Se=t=>t&&t<0;function Le(e){let n,r,o,s;return{c(){n=b("div"),r=b("div"),C(r,"class",o="category-graph-line "+e[2](e[1],e[0])+" svelte-6b2uyp"),j(r,"width",e[3](e[1],e[0])+"%"),C(n,"class",s="category-graph "+Ne(e[1])+" svelte-6b2uyp")},m(t,e){g(t,n,e),m(n,r)},p(t,[e]){3&e&&o!==(o="category-graph-line "+t[2](t[1],t[0])+" svelte-6b2uyp")&&C(r,"class",o),3&e&&j(r,"width",t[3](t[1],t[0])+"%"),2&e&&s!==(s="category-graph "+Ne(t[1])+" svelte-6b2uyp")&&C(n,"class",s)},i:t,o:t,d(t){t&&h(n)}}}function De(t,e,n){let{budgeted:r}=e,{remaining:o}=e;return t.$$set=t=>{"budgeted"in t&&n(0,r=t.budgeted),"remaining"in t&&n(1,o=t.remaining)},[r,o,(t,e)=>null==t?"":t<0?"danger":tt<0?0:0===e?t>0?100:0:t/e*100]}class Te extends at{constructor(t){super(),ut(this,t,De,Le,c,{budgeted:0,remaining:1})}}function He(t,e,n){const r=t.slice();return r[3]=e[n].budgeted,r[4]=e[n].remaining,r[5]=e[n].name,r[6]=e[n].uuid,r}function Ve(t){let e,n,r,o,s,c,u,a,i,l,f,$,d,p,y,w,k,E,A,N,j,O=t[5]+"",M=je(t[4])+"",S=Oe(t[3])+"";return a=new Te({props:{budgeted:t[3],remaining:t[4]}}),{c(){e=b("tr"),n=b("td"),r=b("a"),o=x(O),c=v(),u=b("td"),ot(a.$$.fragment),i=v(),l=b("td"),f=b("div"),$=b("sup"),$.textContent="$",d=x(M),y=v(),w=b("div"),k=b("span"),E=x("/ "),A=x(S),N=v(),C(r,"href",s="#/category/"+t[6]),C(r,"class","btn btn-outline-secondary"),C(n,"class","category-name width-10 svelte-1g8xb6x"),C(u,"class","width-80 svelte-1g8xb6x"),C($,"class","svelte-1g8xb6x"),C(f,"class",p="category-available "+Ne(t[4])+" svelte-1g8xb6x"),C(w,"class","category-budgeted svelte-1g8xb6x"),C(l,"class","category-amount width-10 svelte-1g8xb6x")},m(t,s){g(t,e,s),m(e,n),m(n,r),m(r,o),m(e,c),m(e,u),st(a,u,null),m(e,i),m(e,l),m(l,f),m(f,$),m(f,d),m(l,y),m(l,w),m(w,k),m(k,E),m(k,A),m(e,N),j=!0},p(t,e){(!j||1&e)&&O!==(O=t[5]+"")&&_(o,O),(!j||1&e&&s!==(s="#/category/"+t[6]))&&C(r,"href",s);const n={};1&e&&(n.budgeted=t[3]),1&e&&(n.remaining=t[4]),a.$set(n),(!j||1&e)&&M!==(M=je(t[4])+"")&&_(d,M),(!j||1&e&&p!==(p="category-available "+Ne(t[4])+" svelte-1g8xb6x"))&&C(f,"class",p),(!j||1&e)&&S!==(S=Oe(t[3])+"")&&_(A,S)},i(t){j||(tt(a.$$.fragment,t),j=!0)},o(t){et(a.$$.fragment,t),j=!1},d(t){t&&h(e),ct(a)}}}function ze(t){let e,n,r,o=t[0],s=[];for(let e=0;eet(s[t],1,1,()=>{s[t]=null});return{c(){e=b("table"),n=b("tbody");for(let t=0;tn(1,r=t)),i(t,Lt,t=>n(2,o=t)),t.$$.update=()=>{6&t.$$.dirty&&n(0,s=((t,e)=>{let n=[];for(var r in t)if(t.hasOwnProperty(r)){let o=Dt(r,e);n.push({budgeted:t[r].budgeted,remaining:t[r].remaining,name:o.name,uuid:o.uuid})}return n.sort((t,e)=>(t.name||"").localeCompare(e.name||""))})(r,o))},[s]}class Pe extends at{constructor(t){super(),ut(this,t,Re,ze,c,{})}}function Ie(e){let n,r,o,s;return n=new ge({props:{icon:xe,name:"accounts",url:"#/accounts",left:!0}}),o=new ge({props:{icon:ve,name:"expense",url:"#/expense/new"}}),{c(){ot(n.$$.fragment),r=v(),ot(o.$$.fragment)},m(t,e){st(n,t,e),g(t,r,e),st(o,t,e),s=!0},p:t,i(t){s||(tt(n.$$.fragment,t),tt(o.$$.fragment,t),s=!0)},o(t){et(n.$$.fragment,t),et(o.$$.fragment,t),s=!1},d(t){ct(n,t),t&&h(r),ct(o,t)}}}function Be(t){let e,n,r,o,s,c,u,a;return r=new Pe({}),u=new be({props:{$$slots:{default:[Ie]},$$scope:{ctx:t}}}),{c(){e=b("h2"),e.textContent="Budget",n=v(),ot(r.$$.fragment),o=v(),s=b("p"),s.innerHTML='Add new category',c=v(),ot(u.$$.fragment)},m(t,i){g(t,e,i),g(t,n,i),st(r,t,i),g(t,o,i),g(t,s,i),g(t,c,i),st(u,t,i),a=!0},p(t,[e]){const n={};1&e&&(n.$$scope={dirty:e,ctx:t}),u.$set(n)},i(t){a||(tt(r.$$.fragment,t),tt(u.$$.fragment,t),a=!0)},o(t){et(r.$$.fragment,t),et(u.$$.fragment,t),a=!1},d(t){t&&h(e),t&&h(n),ct(r,t),t&&h(o),t&&h(s),t&&h(c),ct(u,t)}}}function Fe(e){let n,r,s,c,u,a,i;return{c(){n=b("form"),r=b("div"),s=b("div"),s.innerHTML='$',c=v(),u=b("input"),C(s,"class","input-group-prepend"),C(u,"type","tel"),C(u,"aria-describedby","amount-input-currency-symbol"),C(u,"aria-label","Amount"),C(u,"class","text-right form-control"),C(r,"class","input-group input-group-lg"),n.noValidate=!0},m(t,o){g(t,n,o),m(n,r),m(r,s),m(r,c),m(r,u),e[4](u),a||(i=[E(u,"keydown",e[1]),E(n,"submit",A(e[2]))],a=!0)},p:t,i:t,o:t,d(t){t&&h(n),e[4](null),a=!1,o(i)}}}function qe(t,e,n){let{amount:r=0}=e;const o=T();let s,c=[],u=null;function a(t){for(var e="",r=0;r{var t;c=(t=r)?String(t).split("").filter((function(t){return"0123456789".indexOf(t)>=0})):[],a(c),i(Number(c.join(""))),s.focus()}),t.$$set=t=>{"amount"in t&&n(3,r=t.amount)},[s,function(t){var e=t.which;(t=>t>=32&&t<112||t>=123&&t<127||t>=186)(e)&&t.preventDefault();var n=(t=>t>=48&&t<58?String(t-48):t>=96&&t<106?String(t-96):"")(e);n?c.push(n):(t=>8===t)(e)&&(t.preventDefault(),c.pop()),a(c),i(Number(c.join("")))},function(t){o("next",u)},r,function(t){z[t?"unshift":"push"](()=>{s=t,n(0,s)})}]}class Ue extends at{constructor(t){super(),ut(this,t,qe,Fe,c,{amount:3})}}function Ye(t){let e,n,r,o,s,c,u=t[0].name+"";return s=new Ue({props:{amount:t[1]}}),s.$on("next",t[2]),{c(){e=b("h2"),n=x("Amount for "),r=x(u),o=v(),ot(s.$$.fragment)},m(t,u){g(t,e,u),m(e,n),m(e,r),g(t,o,u),st(s,t,u),c=!0},p(t,[e]){(!c||1&e)&&u!==(u=t[0].name+"")&&_(r,u);const n={};2&e&&(n.amount=t[1]),s.$set(n)},i(t){c||(tt(s.$$.fragment,t),c=!0)},o(t){et(s.$$.fragment,t),c=!1},d(t){t&&h(e),t&&h(o),ct(s,t)}}}function Je(t,e,n){let r;i(t,Lt,t=>n(5,r=t));let o,s,c,{params:u}=e;return t.$$set=t=>{"params"in t&&n(3,u=t.params)},t.$$.update=()=>{8&t.$$.dirty&&n(4,o=u.uuid),48&t.$$.dirty&&n(0,s=r.find(t=>t.uuid===o)||{}),16&t.$$.dirty&&n(1,c=Pt(o)||0)},[s,c,function(t){let e=t.detail;Bt(o,e),ee("/budget")},u]}function We(e){let n,r,s,c,u,a;return{c(){n=b("form"),r=b("h2"),r.innerHTML='',s=v(),c=b("input"),C(c,"class","form-control"),C(c,"placeholder","New category name"),C(c,"id","new-category-name")},m(t,o){g(t,n,o),m(n,r),m(n,s),m(n,c),N(c,e[0]),e[4](c),u||(a=[E(c,"input",e[3]),E(n,"submit",A(e[2]))],u=!0)},p(t,[e]){1&e&&c.value!==t[0]&&N(c,t[0])},i:t,o:t,d(t){t&&h(n),e[4](null),u=!1,o(a)}}}function Ge(t,e,n){let r="",o={};return D(()=>{o.focus()}),[r,o,function(){ee(`/category/${(t=>{const e=a(Lt).find(e=>e.name===t);if(e)return e;{const e={uuid:Et(),name:t};return it(e,Lt),Tt(),e}})(r).uuid}/amount`)},function(){r=this.value,n(0,r)},function(t){z[t?"unshift":"push"](()=>{o=t,n(1,o)})}]}function Ke(e){let n,r;return n=new ge({props:{icon:we,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function Qe(t){let e,n,r,o,s,c,u,a,i,l,f,$,d,p,y,w,k,A=t[1].name+"",N=je(Pt(t[0]))+"";return p=new be({props:{$$slots:{default:[Ke]},$$scope:{ctx:t}}}),{c(){e=b("h2"),n=b("b"),r=x(A),o=x(":"),s=v(),c=b("a"),u=b("sup"),u.textContent="$",a=v(),i=x(N),f=v(),$=b("hr"),d=v(),ot(p.$$.fragment),C(n,"class","editable svelte-1uc4ts5"),C(n,"title","(Click to rename)"),C(c,"class","btn btn-default"),C(c,"href",l="#/category/"+t[0]+"/amount"),C($,"class","small")},m(l,h){g(l,e,h),m(e,n),m(n,r),m(n,o),m(e,s),m(e,c),m(c,u),m(c,a),m(c,i),g(l,f,h),g(l,$,h),g(l,d,h),st(p,l,h),y=!0,w||(k=E(n,"click",t[2]),w=!0)},p(t,[e]){(!y||2&e)&&A!==(A=t[1].name+"")&&_(r,A),(!y||1&e)&&N!==(N=je(Pt(t[0]))+"")&&_(i,N),(!y||1&e&&l!==(l="#/category/"+t[0]+"/amount"))&&C(c,"href",l);const n={};32&e&&(n.$$scope={dirty:e,ctx:t}),p.$set(n)},i(t){y||(tt(p.$$.fragment,t),y=!0)},o(t){et(p.$$.fragment,t),y=!1},d(t){t&&h(e),t&&h(f),t&&h($),t&&h(d),ct(p,t),w=!1,k()}}}function Xe(t,e,n){let r;i(t,Lt,t=>n(4,r=t));let{params:o={}}=e;let s,c;return t.$$set=t=>{"params"in t&&n(3,o=t.params)},t.$$.update=()=>{8&t.$$.dirty&&n(0,s=o.uuid||""),17&t.$$.dirty&&n(1,c=r.find(t=>t.uuid===s)||{})},[s,c,()=>{var t=prompt("Edit category name:",c.name);null!=t&&((t,e)=>{lt("uuid",t,e,Lt),Tt()})(s,{name:t})},o]}function Ze(t,e,n){const r=t.slice();return r[3]=e[n],r}function tn(t,e){let n,r,o,s,c,u,a=e[3].name+"";function i(...t){return e[2](e[3],...t)}return{key:t,first:null,c(){n=b("p"),r=b("button"),o=x(a),s=v(),C(r,"class","btn btn-outline-secondary"),this.first=n},m(t,e){g(t,n,e),m(n,r),m(r,o),m(n,s),c||(u=E(r,"click",i),c=!0)},p(t,n){e=t,1&n&&a!==(a=e[3].name+"")&&_(o,a)},d(t){t&&h(n),c=!1,u()}}}function en(e){let n,r=[],o=new Map,s=e[0];const c=t=>t[3].uuid;for(let t=0;t{"accounts"in t&&n(0,r=t.accounts)},[r,o,t=>o("select",t.uuid)]}class rn extends at{constructor(t){super(),ut(this,t,nn,en,c,{accounts:0})}}function on(e){let n,r;return n=new ge({props:{icon:we,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function sn(t){let e,n,r,o,s,c;return r=new rn({props:{accounts:t[0]}}),r.$on("select",t[1]),s=new be({props:{$$slots:{default:[on]},$$scope:{ctx:t}}}),{c(){e=b("h2"),e.textContent="Paid using",n=v(),ot(r.$$.fragment),o=v(),ot(s.$$.fragment)},m(t,u){g(t,e,u),g(t,n,u),st(r,t,u),g(t,o,u),st(s,t,u),c=!0},p(t,[e]){const n={};1&e&&(n.accounts=t[0]),r.$set(n);const o={};64&e&&(o.$$scope={dirty:e,ctx:t}),s.$set(o)},i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){et(r.$$.fragment,t),et(s.$$.fragment,t),c=!1},d(t){t&&h(e),t&&h(n),ct(r,t),t&&h(o),ct(s,t)}}}function cn(t,e,n){let r,o;i(t,Yt,t=>n(5,r=t)),i(t,Mt,t=>n(0,o=t));let s,c,{params:u}=e;return t.$$set=t=>{"params"in t&&n(2,u=t.params)},t.$$.update=()=>{4&t.$$.dirty&&n(3,s=u.uuid),40&t.$$.dirty&&(c=Jt(s,r))},[o,function(t){let e=t.detail;Gt(s,{accountUuid:e}),ee("/expense/amount/"+c.uuid)},u]}function un(e){let n,r;return n=new ge({props:{icon:we,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function an(t){let e,n,r,o,s,c,u,a,i=t[0].who+"";return s=new Ue({}),s.$on("next",t[1]),u=new be({props:{$$slots:{default:[un]},$$scope:{ctx:t}}}),{c(){e=b("h2"),n=x("Amount paid to "),r=x(i),o=v(),ot(s.$$.fragment),c=v(),ot(u.$$.fragment)},m(t,i){g(t,e,i),m(e,n),m(e,r),g(t,o,i),st(s,t,i),g(t,c,i),st(u,t,i),a=!0},p(t,[e]){(!a||1&e)&&i!==(i=t[0].who+"")&&_(r,i);const n={};32&e&&(n.$$scope={dirty:e,ctx:t}),u.$set(n)},i(t){a||(tt(s.$$.fragment,t),tt(u.$$.fragment,t),a=!0)},o(t){et(s.$$.fragment,t),et(u.$$.fragment,t),a=!1},d(t){t&&h(e),t&&h(o),ct(s,t),t&&h(c),ct(u,t)}}}function ln(t,e,n){let r;i(t,Yt,t=>n(4,r=t));let o,s,{params:c}=e;return t.$$set=t=>{"params"in t&&n(2,c=t.params)},t.$$.update=()=>{4&t.$$.dirty&&n(3,o=c.uuid),24&t.$$.dirty&&n(0,s=Jt(o,r))},[s,function(t){let e=t.detail;Gt(o,{amountTotal:e}),ee("/expense/category/"+s.uuid)},c]}function fn(t,e,n){const r=t.slice();return r[4]=e[n],r}function $n(t,e){let n,r,o,s,c,u,a=e[4].name+"";function i(...t){return e[2](e[4],...t)}return{key:t,first:null,c(){n=b("p"),r=b("button"),o=x(a),s=v(),C(r,"class","btn btn-outline-secondary"),this.first=n},m(t,e){g(t,n,e),m(n,r),m(r,o),m(n,s),c||(u=E(r,"click",i),c=!0)},p(t,n){e=t,1&n&&a!==(a=e[4].name+"")&&_(o,a)},d(t){t&&h(n),c=!1,u()}}}function dn(e){let n,r=[],o=new Map,s=e[0];const c=t=>t[4].uuid;for(let t=0;t{"categories"in t&&n(0,r=t.categories)},[r,o,t=>o("select",t.uuid)]}class mn extends at{constructor(t){super(),ut(this,t,pn,dn,c,{categories:0})}}function gn(e){let n,r;return n=new ge({props:{icon:we,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function hn(t){let e,n,r,o,s,c;return r=new mn({props:{categories:t[0]}}),r.$on("select",t[1]),s=new be({props:{$$slots:{default:[gn]},$$scope:{ctx:t}}}),{c(){e=b("h2"),e.textContent="Category",n=v(),ot(r.$$.fragment),o=v(),ot(s.$$.fragment)},m(t,u){g(t,e,u),g(t,n,u),st(r,t,u),g(t,o,u),st(s,t,u),c=!0},p(t,[e]){const n={};1&e&&(n.categories=t[0]),r.$set(n);const o={};64&e&&(o.$$scope={dirty:e,ctx:t}),s.$set(o)},i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){et(r.$$.fragment,t),et(s.$$.fragment,t),c=!1},d(t){t&&h(e),t&&h(n),ct(r,t),t&&h(o),ct(s,t)}}}function yn(t,e,n){let r,o;i(t,Yt,t=>n(5,r=t)),i(t,Lt,t=>n(0,o=t));let s,c,{params:u}=e;return t.$$set=t=>{"params"in t&&n(2,u=t.params)},t.$$.update=()=>{4&t.$$.dirty&&n(3,s=u.uuid),40&t.$$.dirty&&(c=Jt(s,r))},[o,function(t){let e={};e[t.detail]=c.amountTotal,Gt(s,{categoryAmounts:e}),ee("/expense/review/"+c.uuid)},u]}function bn(t){return ee("/expense/who/"+(t=>{const e=Et(),n=Object.assign({},t,{uuid:e});return it(n,Yt),Wt(),n})({timestamp:Date.now()}).uuid),[]}function wn(e){let n,r,o,s,c=je(e[1])+"";return{c(){n=b("span"),r=x(e[0]),o=x(": $ "),s=x(c),C(n,"class","badge badge-info")},m(t,e){g(t,n,e),m(n,r),m(n,o),m(n,s)},p(t,[e]){1&e&&_(r,t[0]),2&e&&c!==(c=je(t[1])+"")&&_(s,c)},i:t,o:t,d(t){t&&h(n)}}}function xn(t,e,n){let{name:r=""}=e,{amount:o=0}=e;return t.$$set=t=>{"name"in t&&n(0,r=t.name),"amount"in t&&n(1,o=t.amount)},[r,o]}class vn extends at{constructor(t){super(),ut(this,t,xn,wn,c,{name:0,amount:1})}}function kn(t,e,n){const r=t.slice();return r[4]=e[n],r}function En(t){let e,n;return e=new vn({props:{name:Dt(t[4],t[2]).name,amount:t[0][t[4]]}}),{c(){ot(e.$$.fragment)},m(t,r){st(e,t,r),n=!0},p(t,n){const r={};6&n&&(r.name=Dt(t[4],t[2]).name),3&n&&(r.amount=t[0][t[4]]),e.$set(r)},i(t){n||(tt(e.$$.fragment,t),n=!0)},o(t){et(e.$$.fragment,t),n=!1},d(t){ct(e,t)}}}function An(t){let e,n,r=t[1],o=[];for(let e=0;eet(o[t],1,1,()=>{o[t]=null});return{c(){for(let t=0;tn(2,r=t));let o,s,{transaction:c={}}=e;return t.$$set=t=>{"transaction"in t&&n(3,c=t.transaction)},t.$$.update=()=>{8&t.$$.dirty&&n(0,o=c.categoryAmounts||{}),1&t.$$.dirty&&n(1,s=Object.keys(o))},[o,s,r,c]}class _n extends at{constructor(t){super(),ut(this,t,Cn,An,c,{transaction:3})}}function Nn(e){let n,r;return n=new ge({props:{icon:we,name:"done"}}),n.$on("click",e[4]),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function jn(t){let e,n,r,o,s,c,u,a,i,l,f,$,d,p,y,w,k,A,N,j,O,M,S,L,D,T,H,V,z,R,P,I,B,F,q=t[1].who+"",U=je(t[3])+"";return w=new _n({props:{transaction:t[1]}}),P=new be({props:{$$slots:{default:[Nn]},$$scope:{ctx:t}}}),{c(){e=b("div"),n=b("div"),r=b("h2"),r.textContent="Review Expense",o=v(),s=b("p"),c=b("a"),u=x(q),i=v(),l=b("a"),f=x("$"),$=x(U),p=v(),y=b("p"),ot(w.$$.fragment),k=v(),A=b("p"),N=b("b"),N.textContent="Account:",j=v(),O=b("a"),M=x(t[2]),L=v(),D=b("p"),T=b("b"),T.textContent="Date:",H=v(),V=b("input"),R=v(),ot(P.$$.fragment),C(c,"class","btn btn-outline-secondary"),C(c,"href",a="#/expense/who/"+t[0]),C(l,"class","btn btn-outline-secondary float-right"),C(l,"href",d="#/expense/amount/"+t[0]),C(O,"class","btn btn-outline-secondary float-right"),C(O,"href",S="#/expense/account/"+t[0]),C(V,"type","date"),C(V,"class","float-right"),V.value=z=Ht(t[1].timestamp),C(n,"class","col-12 col-sm-8 offset-sm-2 col-md-6 offset-md-3"),C(e,"class","row")},m(a,d){g(a,e,d),m(e,n),m(n,r),m(n,o),m(n,s),m(s,c),m(c,u),m(s,i),m(s,l),m(l,f),m(l,$),m(n,p),m(n,y),st(w,y,null),m(n,k),m(n,A),m(A,N),m(A,j),m(A,O),m(O,M),m(n,L),m(n,D),m(D,T),m(D,H),m(D,V),g(a,R,d),st(P,a,d),I=!0,B||(F=E(V,"change",t[5]),B=!0)},p(t,[e]){(!I||2&e)&&q!==(q=t[1].who+"")&&_(u,q),(!I||1&e&&a!==(a="#/expense/who/"+t[0]))&&C(c,"href",a),(!I||8&e)&&U!==(U=je(t[3])+"")&&_($,U),(!I||1&e&&d!==(d="#/expense/amount/"+t[0]))&&C(l,"href",d);const n={};2&e&&(n.transaction=t[1]),w.$set(n),(!I||4&e)&&_(M,t[2]),(!I||1&e&&S!==(S="#/expense/account/"+t[0]))&&C(O,"href",S),(!I||2&e&&z!==(z=Ht(t[1].timestamp)))&&(V.value=z);const r={};2048&e&&(r.$$scope={dirty:e,ctx:t}),P.$set(r)},i(t){I||(tt(w.$$.fragment,t),tt(P.$$.fragment,t),I=!0)},o(t){et(w.$$.fragment,t),et(P.$$.fragment,t),I=!1},d(t){t&&h(e),ct(w),t&&h(R),ct(P,t),B=!1,F()}}}function On(t,e,n){let r,o;i(t,Yt,t=>n(7,r=t)),i(t,Mt,t=>n(9,o=t));let{params:s}=e;let c,u,l,f,$;return t.$$set=t=>{"params"in t&&n(6,s=t.params)},t.$$.update=()=>{64&t.$$.dirty&&n(0,c=s.uuid),129&t.$$.dirty&&n(1,u=Jt(c,r)),514&t.$$.dirty&&n(8,l=((t,e)=>e.find(e=>e.uuid===t)||{})(u.accountUuid,o)),256&t.$$.dirty&&n(2,f=l.name||""),2&t.$$.dirty&&n(3,$=u.amountTotal||0)},[c,u,f,$,function(){(t=>{const e=Jt(t,a(Yt));if(e.applied)throw new Error("Already applied this one!");const n=e.categoryAmounts||{};for(const t in n){const e=n[t]||0;Ft(t,e)}Gt(t,{applied:!0})})(c),ee("/budget")},t=>{let e=t.target.value,n=new Date(e+" 12:00:00");Gt(c,{timestamp:n.getTime()})},s]}function Mn(t){let e,n,r,o,s,c,u;return{c(){e=b("h2"),n=b("label"),r=x(t[1]),o=v(),s=b("input"),C(n,"for","who"),C(s,"type","text"),C(s,"class","form-control"),C(s,"id","who")},m(a,i){g(a,e,i),m(e,n),m(n,r),g(a,o,i),g(a,s,i),N(s,t[0]),t[5](s),c||(u=E(s,"input",t[4]),c=!0)},p(t,e){2&e&&_(r,t[1]),1&e&&s.value!==t[0]&&N(s,t[0])},d(n){n&&h(e),n&&h(o),n&&h(s),t[5](null),c=!1,u()}}}function Sn(t){let e,n;return e=new ce({props:{autofocusElement:t[2],$$slots:{default:[Mn]},$$scope:{ctx:t}}}),e.$on("submit",t[3]),{c(){ot(e.$$.fragment)},m(t,r){st(e,t,r),n=!0},p(t,[n]){const r={};4&n&&(r.autofocusElement=t[2]),135&n&&(r.$$scope={dirty:n,ctx:t}),e.$set(r)},i(t){n||(tt(e.$$.fragment,t),n=!0)},o(t){et(e.$$.fragment,t),n=!1},d(t){ct(e,t)}}}function Ln(t,e,n){let{title:r}=e,{who:o=""}=e;const s=T();let c={};return t.$$set=t=>{"title"in t&&n(1,r=t.title),"who"in t&&n(0,o=t.who)},[o,r,c,()=>{s("select",o)},function(){o=this.value,n(0,o)},function(t){z[t?"unshift":"push"](()=>{c=t,n(2,c)})}]}class Dn extends at{constructor(t){super(),ut(this,t,Ln,Sn,c,{title:1,who:0})}}function Tn(e){let n,r;return n=new ge({props:{icon:we,name:"budget",url:"#/budget",left:!0}}),{c(){ot(n.$$.fragment)},m(t,e){st(n,t,e),r=!0},p:t,i(t){r||(tt(n.$$.fragment,t),r=!0)},o(t){et(n.$$.fragment,t),r=!1},d(t){ct(n,t)}}}function Hn(t){let e,n,r,o;return e=new Dn({props:{title:"Paid to:"}}),e.$on("select",t[0]),r=new be({props:{$$slots:{default:[Tn]},$$scope:{ctx:t}}}),{c(){ot(e.$$.fragment),n=v(),ot(r.$$.fragment)},m(t,s){st(e,t,s),g(t,n,s),st(r,t,s),o=!0},p(t,[e]){const n={};32&e&&(n.$$scope={dirty:e,ctx:t}),r.$set(n)},i(t){o||(tt(e.$$.fragment,t),tt(r.$$.fragment,t),o=!0)},o(t){et(e.$$.fragment,t),et(r.$$.fragment,t),o=!1},d(t){ct(e,t),t&&h(n),ct(r,t)}}}function Vn(t,e,n){let r;i(t,Yt,t=>n(4,r=t));let{params:o}=e;let s,c;return t.$$set=t=>{"params"in t&&n(1,o=t.params)},t.$$.update=()=>{2&t.$$.dirty&&n(2,s=o.uuid),20&t.$$.dirty&&(c=Jt(s,r))},[t=>{const e=t.detail;Gt(s,{who:e}),ee("/expense/account/"+c.uuid)},o]}function zn(t){return function(t){if(!t||t.length<1||"/"!=t.charAt(0)&&0!==t.indexOf("#/"))throw Error("Invalid parameter location");q().then(()=>{const e=("#"==t.charAt(0)?"":"#")+t;try{window.history.replaceState(void 0,void 0,e)}catch(t){console.warn("Caught exception while replacing the current page. If you're running this in the Svelte REPL, please note that the `replace` method might not work in this environment.")}window.dispatchEvent(new Event("hashchange"))})}("/budget"),[]}function Rn(e){let n,r,o,s,c;return{c(){n=b("h2"),n.textContent="Hmm...",r=v(),o=b("p"),o.textContent="We can't seem to find that page.",s=v(),c=b("p"),c.innerHTML='Try going back to the Home screen. Perhaps there's a link\n from there to where you were trying to go.'},m(t,e){g(t,n,e),g(t,r,e),g(t,o,e),g(t,s,e),g(t,c,e)},p:t,i:t,o:t,d(t){t&&h(n),t&&h(r),t&&h(o),t&&h(s),t&&h(c)}}}const Pn={"/":class extends at{constructor(t){super(),ut(this,t,zn,null,c,{})}},"/account/new":class extends at{constructor(t){super(),ut(this,t,ie,ae,c,{})}},"/accounts":class extends at{constructor(t){super(),ut(this,t,_e,Ce,c,{})}},"/budget":class extends at{constructor(t){super(),ut(this,t,null,Be,c,{})}},"/category/new":class extends at{constructor(t){super(),ut(this,t,Ge,We,c,{})}},"/category/:uuid":class extends at{constructor(t){super(),ut(this,t,Xe,Qe,c,{params:3})}},"/category/:uuid/amount":class extends at{constructor(t){super(),ut(this,t,Je,Ye,c,{params:3})}},"/expense/account/:uuid":class extends at{constructor(t){super(),ut(this,t,cn,sn,c,{params:2})}},"/expense/amount/:uuid":class extends at{constructor(t){super(),ut(this,t,ln,an,c,{params:2})}},"/expense/category/:uuid":class extends at{constructor(t){super(),ut(this,t,yn,hn,c,{params:2})}},"/expense/new":class extends at{constructor(t){super(),ut(this,t,bn,null,c,{})}},"/expense/review/:uuid":class extends at{constructor(t){super(),ut(this,t,On,jn,c,{params:6})}},"/expense/who/:uuid":class extends at{constructor(t){super(),ut(this,t,Vn,Hn,c,{params:1})}},"*":class extends at{constructor(t){super(),ut(this,t,null,Rn,c,{})}}};function In(e){let n,r,o,s,c;return r=new Ot({}),s=new re({props:{routes:Pn}}),{c(){n=b("div"),ot(r.$$.fragment),o=v(),ot(s.$$.fragment),C(n,"class","container-xl my-3")},m(t,e){g(t,n,e),st(r,n,null),m(n,o),st(s,n,null),c=!0},p:t,i(t){c||(tt(r.$$.fragment,t),tt(s.$$.fragment,t),c=!0)},o(t){et(r.$$.fragment,t),et(s.$$.fragment,t),c=!1},d(t){t&&h(n),ct(r),ct(s)}}}function Bn(t){return D(async()=>{Mt.set($t("accounts")),Lt.set($t("categories")),It(),Yt.set($t("transactions"))}),[]}return new class extends at{constructor(t){super(),ut(this,t,Bn,In,c,{})}}({target:document.body})}(); diff --git a/package-lock.json b/package-lock.json index 12e59bf..dea3fbe 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,44 +5,44 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz", - "integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.4.tgz", + "integrity": "sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg==", "dev": true, "requires": { - "@babel/highlight": "^7.8.3" + "@babel/highlight": "^7.10.4" } }, "@babel/helper-validator-identifier": { - "version": "7.9.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.5.tgz", - "integrity": "sha512-/8arLKUFq882w4tWGj9JYzRpAlZgiWUJ+dtteNTDqrRBz9Iguck9Rn3ykuBDoUwh2TO4tSAJlrxDUOXWklJe4g==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.4.tgz", + "integrity": "sha512-3U9y+43hz7ZM+rzG24Qe2mufW5KhvFg/NhnNph+i9mgCtdTCtMJuI1TMkrIUiK7Ix4PYlRF9I5dhqaLYA/ADXw==", "dev": true }, "@babel/highlight": { - "version": "7.9.0", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz", - "integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==", + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.4.tgz", + "integrity": "sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA==", "dev": true, "requires": { - "@babel/helper-validator-identifier": "^7.9.0", + "@babel/helper-validator-identifier": "^7.10.4", "chalk": "^2.0.0", "js-tokens": "^4.0.0" } }, "@fortawesome/fontawesome-common-types": { - "version": "0.2.28", - "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.28.tgz", - "integrity": "sha512-gtis2/5yLdfI6n0ia0jH7NJs5i/Z/8M/ZbQL6jXQhCthEOe5Cr5NcQPhgTvFxNOtURE03/ZqUcEskdn2M+QaBg==", + "version": "0.2.30", + "resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.30.tgz", + "integrity": "sha512-TsRwpTuKwFNiPhk1UfKgw7zNPeV5RhNp2Uw3pws+9gDAkPGKrtjR1y2lI3SYn7+YzyfuNknflpBA1LRKjt7hMg==", "dev": true }, "@fortawesome/free-solid-svg-icons": { - "version": "5.13.0", - "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.13.0.tgz", - "integrity": "sha512-IHUgDJdomv6YtG4p3zl1B5wWf9ffinHIvebqQOmV3U+3SLw4fC+LUCCgwfETkbTtjy5/Qws2VoVf6z/ETQpFpg==", + "version": "5.14.0", + "resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-5.14.0.tgz", + "integrity": "sha512-M933RDM8cecaKMWDSk3FRYdnzWGW7kBBlGNGfvqLVwcwhUPNj9gcw+xZMrqBdRqxnSXdl3zWzTCNNGEtFUq67Q==", "dev": true, "requires": { - "@fortawesome/fontawesome-common-types": "^0.2.28" + "@fortawesome/fontawesome-common-types": "^0.2.30" } }, "@polka/url": { @@ -432,6 +432,15 @@ "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "dev": true }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, "readdirp": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.4.0.tgz", @@ -483,9 +492,9 @@ } }, "rollup-plugin-svelte": { - "version": "5.2.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-svelte/-/rollup-plugin-svelte-5.2.2.tgz", - "integrity": "sha512-I+TJ2T+VLKGbKQcpeMJ4AR2ciROqTZNjxbiMiH4Cn1yByaB9OEuy3CnrgHHuWatQcPuF3yIViyKX7OlETWDKOQ==", + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/rollup-plugin-svelte/-/rollup-plugin-svelte-5.2.3.tgz", + "integrity": "sha512-513vOht9A93OV7fvmpIq8mD1JFgTZ5LidmpULKM2Od9P1l8oI5KwvO32fwCnASuVJS1EkRfvCnS7vKQ8DF4srg==", "dev": true, "requires": { "require-relative": "^0.8.7", @@ -494,15 +503,15 @@ } }, "rollup-plugin-terser": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-5.3.0.tgz", - "integrity": "sha512-XGMJihTIO3eIBsVGq7jiNYOdDMb3pVxuzY0uhOE/FM4x/u9nQgr3+McsjzqBn3QfHIpNSZmFnpoKAwHBEcsT7g==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-5.3.1.tgz", + "integrity": "sha512-1pkwkervMJQGFYvM9nscrUoncPwiKR/K+bHdjv6PFgRo3cgPHoRT83y2Aa3GvINj4539S15t/tpFPb775TDs6w==", "dev": true, "requires": { "@babel/code-frame": "^7.5.5", "jest-worker": "^24.9.0", "rollup-pluginutils": "^2.8.2", - "serialize-javascript": "^2.1.2", + "serialize-javascript": "^4.0.0", "terser": "^4.6.2" } }, @@ -531,12 +540,21 @@ "mri": "^1.1.0" } }, - "serialize-javascript": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", - "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==", + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true }, + "serialize-javascript": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", + "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, "sirv": { "version": "0.4.6", "resolved": "https://registry.npmjs.org/sirv/-/sirv-0.4.6.tgz", @@ -567,9 +585,9 @@ "dev": true }, "source-map-support": { - "version": "0.5.18", - "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.18.tgz", - "integrity": "sha512-9luZr/BZ2QeU6tO2uG8N2aZpVSli4TSAOAqFOyTO51AJcD9P99c0K1h6dD6r6qo5dyT44BR5exweOaLLeldTkQ==", + "version": "0.5.19", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", + "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", "dev": true, "requires": { "buffer-from": "^1.0.0", @@ -592,9 +610,9 @@ } }, "svelte": { - "version": "3.23.2", - "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.23.2.tgz", - "integrity": "sha512-hE8GeTM83YVR4GY6/6PeDEcGct4JS5aCi+IYbCAa76oaPSfuF7L85DQYULQxlTK/KPWzw3L1GRGmC3oPG/PQoA==", + "version": "3.25.1", + "resolved": "https://registry.npmjs.org/svelte/-/svelte-3.25.1.tgz", + "integrity": "sha512-IbrVKTmuR0BvDw4ii8/gBNy8REu7nWTRy9uhUz+Yuae5lIjWgSGwKlWtJGC2Vg95s+UnXPqDu0Kk/sUwe0t2GQ==", "dev": true }, "svelte-spa-router": { @@ -607,9 +625,9 @@ } }, "terser": { - "version": "4.6.11", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.11.tgz", - "integrity": "sha512-76Ynm7OXUG5xhOpblhytE7X58oeNSmC8xnNhjWVo8CksHit0U0kO4hfNbPrrYwowLWFgM2n9L176VNx2QaHmtA==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.8.0.tgz", + "integrity": "sha512-EAPipTNeWsb/3wLPeup1tVPaXfIaU68xMnVdPafIL1TV05OhASArYyIfFvnvJCNrR2NIOvDVNNTFRa+Re2MWyw==", "dev": true, "requires": { "commander": "^2.20.0", diff --git a/package.json b/package.json index 4aa49f5..3971fe3 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,15 @@ }, "homepage": "https://github.com/forevermatt/svelte-budget#readme", "devDependencies": { - "@fortawesome/free-solid-svg-icons": "^5.13.0", + "@fortawesome/free-solid-svg-icons": "^5.14.0", "@rollup/plugin-commonjs": "11.0.2", "@rollup/plugin-node-resolve": "^7.0.0", "fa-svelte": "^3.1.0", "rollup": "^1.20.0", "rollup-plugin-livereload": "^1.3.0", - "rollup-plugin-svelte": "^5.2.2", - "rollup-plugin-terser": "^5.1.2", - "svelte": "^3.23.2", + "rollup-plugin-svelte": "^5.2.3", + "rollup-plugin-terser": "^5.3.1", + "svelte": "^3.25.1", "svelte-spa-router": "^2.2.0" }, "dependencies": { diff --git a/src/components/Button.svelte b/src/components/Button.svelte index b9b18ce..d7b8229 100644 --- a/src/components/Button.svelte +++ b/src/components/Button.svelte @@ -39,7 +39,7 @@ a:hover .button-circle { + href="{ url || 'javascript:void(0)' }" role="button" on:click> {#if icon } diff --git a/src/data/budget.js b/src/data/budget.js index 0b35bcb..a66bb7a 100644 --- a/src/data/budget.js +++ b/src/data/budget.js @@ -17,8 +17,12 @@ const addCategoryToBudget = (categoryUuid, budgeted) => { }) } -export const getBudgetedFor = uuid => { - let budgetCategory = get(budgetStore)[uuid] || {} +export const getBudgetDataFor = categoryUuid => { + return get(budgetStore)[categoryUuid] || {} +} + +export const getBudgetedFor = categoryUuid => { + let budgetCategory = getBudgetDataFor(categoryUuid) return budgetCategory.budgeted || 0 } @@ -55,6 +59,13 @@ export const sortBudgetByCategory = (budget, categories) => { return list.sort((a, b) => (a.name || '').localeCompare(b.name || '')); } +export const subtractAmountFromBudgetCategory = (categoryUuid, amountToSubtract) => { + const budgetCategory = getBudgetDataFor(categoryUuid) + const oldRemaining = budgetCategory.remaining || 0 + const newRemaining = oldRemaining - amountToSubtract + updateBudget(categoryUuid, { remaining: newRemaining }) +} + export const updateBudget = (categoryUuid, changes) => { updateInObject(categoryUuid, changes, budgetStore) saveBudget() diff --git a/src/data/transactions.js b/src/data/transactions.js index 005d688..d78bb90 100644 --- a/src/data/transactions.js +++ b/src/data/transactions.js @@ -2,6 +2,7 @@ import { addToList, updateInList } from '../helpers/data-store-helpers' import { getListFromStorage, saveToStorage } from './storage' import { get, writable } from 'svelte/store' import { v4 as uuidv4 } from 'uuid' +import { subtractAmountFromBudgetCategory } from './budget' const TRANSACTIONS = 'transactions' @@ -29,3 +30,16 @@ export const updateTransaction = (uuid, changes) => { updateInList('uuid', uuid, changes, transactions) saveTransactions() } + +export const applyTransaction = (uuid) => { + const transaction = getTransactionFrom(uuid, get(transactions)) + if (transaction.applied) { + throw new Error('Already applied this one!') // TEMP + } + const categoryAmounts = transaction.categoryAmounts || {} + for (const categoryUuid in categoryAmounts) { + const categoryAmount = categoryAmounts[categoryUuid] || 0 + subtractAmountFromBudgetCategory(categoryUuid, categoryAmount) + } + updateTransaction(uuid, { applied: true }) +} diff --git a/src/views/ExpenseReview.svelte b/src/views/ExpenseReview.svelte index c784148..afef96f 100644 --- a/src/views/ExpenseReview.svelte +++ b/src/views/ExpenseReview.svelte @@ -4,7 +4,7 @@ import ButtonRow from '../components/ButtonRow.svelte' import CategoryTags from '../components/CategoryTags.svelte' import { accounts, getAccountFrom } from '../data/accounts' import { categories, getCategoryFrom } from '../data/categories' -import { getTransactionFrom, transactions, updateTransaction } from '../data/transactions' +import { applyTransaction, getTransactionFrom, transactions, updateTransaction } from '../data/transactions' import { faHome } from '@fortawesome/free-solid-svg-icons' import { formatDateISO8601 } from "../helpers/dates"; import { formatAmount } from "../helpers/numbers"; @@ -18,6 +18,11 @@ $: account = getAccountFrom(transaction.accountUuid, $accounts) $: accountName = account.name || '' $: amountTotal = transaction.amountTotal || 0 +function onDone() { + applyTransaction(uuid) + push(`/budget`) +} + function setComment(event) { let comment = event.detail updateTransaction(uuid, { comment }) @@ -58,5 +63,5 @@ const setTimestamp = event => { -